2006-03-20 17:12:09 +00:00
|
|
|
/*
|
2014-06-01 17:55:23 +00:00
|
|
|
* Portions of this file are copyright Rebirth contributors and licensed as
|
|
|
|
* described in COPYING.txt.
|
|
|
|
* Portions of this file are copyright Parallax Software and licensed
|
|
|
|
* according to the Parallax license below.
|
|
|
|
* See COPYING.txt for license details.
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
|
|
|
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
|
|
|
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
|
|
|
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
|
|
|
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
|
|
|
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
|
|
|
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
|
|
|
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
|
|
|
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
|
|
|
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Include file for functions which need to access segment data structure.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-12-22 04:35:49 +00:00
|
|
|
#pragma once
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-07-20 01:09:55 +00:00
|
|
|
#include <physfs.h>
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "pstypes.h"
|
2012-07-01 02:54:33 +00:00
|
|
|
#include "maths.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "vecmat.h"
|
2013-11-17 00:17:58 +00:00
|
|
|
#include "dxxsconf.h"
|
2016-03-19 19:08:10 +00:00
|
|
|
#include "dsx-ns.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2012-11-11 22:12:51 +00:00
|
|
|
#ifdef __cplusplus
|
2014-07-20 01:09:55 +00:00
|
|
|
#include <cassert>
|
2013-12-26 22:21:16 +00:00
|
|
|
#include <cstdint>
|
2013-11-17 00:17:58 +00:00
|
|
|
#include <stdexcept>
|
2016-12-24 18:12:17 +00:00
|
|
|
#include "fwd-segment.h"
|
2013-12-11 23:59:36 +00:00
|
|
|
#include "countarray.h"
|
2014-10-02 03:02:34 +00:00
|
|
|
#include "valptridx.h"
|
2013-12-29 04:28:07 +00:00
|
|
|
#include "objnum.h"
|
2014-10-04 17:33:25 +00:00
|
|
|
#include "pack.h"
|
2012-11-11 22:12:51 +00:00
|
|
|
|
2014-07-20 01:09:55 +00:00
|
|
|
#include "compiler-type_traits.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2016-01-09 16:38:15 +00:00
|
|
|
#ifdef dsx
|
2015-12-22 04:18:50 +00:00
|
|
|
namespace dsx {
|
2006-03-20 17:12:09 +00:00
|
|
|
// Returns true if segnum references a child, else returns false.
|
|
|
|
// Note that -1 means no connection, -2 means a connection to the outside world.
|
2014-06-07 17:46:32 +00:00
|
|
|
static inline bool IS_CHILD(segnum_t s)
|
|
|
|
{
|
|
|
|
return s != segment_none && s != segment_exit;
|
|
|
|
}
|
2015-12-22 04:18:50 +00:00
|
|
|
}
|
2015-11-26 02:56:55 +00:00
|
|
|
#endif
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2015-12-22 04:18:50 +00:00
|
|
|
namespace dcx {
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
//Structure for storing u,v,light values.
|
|
|
|
//NOTE: this structure should be the same as the one in 3d.h
|
2013-12-22 22:03:07 +00:00
|
|
|
struct uvl
|
|
|
|
{
|
2006-03-20 17:12:09 +00:00
|
|
|
fix u, v, l;
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-09-06 22:36:58 +00:00
|
|
|
enum side_type : uint8_t
|
|
|
|
{
|
|
|
|
SIDE_IS_QUAD = 1, // render side as quadrilateral
|
|
|
|
SIDE_IS_TRI_02 = 2, // render side as two triangles, triangulated along edge from 0 to 2
|
|
|
|
SIDE_IS_TRI_13 = 3, // render side as two triangles, triangulated along edge from 1 to 3
|
|
|
|
};
|
|
|
|
|
2016-02-06 22:12:54 +00:00
|
|
|
#if 0
|
2014-10-04 17:33:25 +00:00
|
|
|
struct wallnum_t : prohibit_void_ptr<wallnum_t>
|
2014-10-04 17:30:18 +00:00
|
|
|
{
|
|
|
|
typedef int16_t integral_type;
|
|
|
|
integral_type value;
|
|
|
|
wallnum_t() = default;
|
|
|
|
wallnum_t(const integral_type &v) : value(v)
|
|
|
|
{
|
|
|
|
#ifdef DXX_HAVE_BUILTIN_CONSTANT_P
|
|
|
|
if (__builtin_constant_p(v))
|
|
|
|
DXX_ALWAYS_ERROR_FUNCTION(dxx_trap_constant_wall, "constant wall number constructed");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
wallnum_t &operator=(integral_type v)
|
|
|
|
{
|
|
|
|
#ifdef DXX_HAVE_BUILTIN_CONSTANT_P
|
|
|
|
if (__builtin_constant_p(v))
|
|
|
|
DXX_ALWAYS_ERROR_FUNCTION(dxx_trap_constant_wall, "constant wall number assigned");
|
|
|
|
#endif
|
|
|
|
value = v;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
template <integral_type I>
|
|
|
|
wallnum_t &operator=(const wall_magic_constant_t<I> &)
|
|
|
|
{
|
|
|
|
value = I;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
bool operator==(const wallnum_t &v) const { return value == v.value; }
|
|
|
|
bool operator==(const int &v) const
|
|
|
|
{
|
|
|
|
#ifdef DXX_HAVE_BUILTIN_CONSTANT_P
|
|
|
|
if (__builtin_constant_p(v))
|
|
|
|
DXX_ALWAYS_ERROR_FUNCTION(dxx_trap_constant_wall, "constant wall number compared");
|
|
|
|
#endif
|
|
|
|
return value == v;
|
|
|
|
}
|
|
|
|
template <integral_type I>
|
|
|
|
bool operator==(const wall_magic_constant_t<I> &) const { return value == I; }
|
|
|
|
template <typename T>
|
|
|
|
bool operator!=(const T &v) const { return !(*this == v); }
|
|
|
|
template <typename T>
|
|
|
|
bool operator==(const T &v) const = delete;
|
|
|
|
template <typename T>
|
|
|
|
bool operator<(const T &v) const
|
|
|
|
{
|
2014-10-12 22:11:28 +00:00
|
|
|
static_assert(tt::is_integral<T>::value, "non-integral wall number compared");
|
2014-10-04 17:30:18 +00:00
|
|
|
#ifdef DXX_HAVE_BUILTIN_CONSTANT_P
|
|
|
|
if (__builtin_constant_p(v))
|
|
|
|
DXX_ALWAYS_ERROR_FUNCTION(dxx_trap_constant_wall, "constant wall number compared");
|
|
|
|
#endif
|
|
|
|
return value < v;
|
|
|
|
}
|
|
|
|
template <typename T>
|
|
|
|
bool operator>(const T &v) const
|
|
|
|
{
|
|
|
|
return v < *this;
|
|
|
|
}
|
|
|
|
template <typename T>
|
|
|
|
bool operator<=(const T &) const = delete;
|
|
|
|
template <typename T>
|
|
|
|
bool operator>=(const T &) const = delete;
|
|
|
|
constexpr operator integral_type() const { return value; }
|
|
|
|
operator integral_type &() { return value; }
|
|
|
|
};
|
2016-02-06 22:12:54 +00:00
|
|
|
#endif
|
2014-10-04 17:30:18 +00:00
|
|
|
|
2013-12-22 22:03:07 +00:00
|
|
|
struct side
|
|
|
|
{
|
2014-10-05 20:59:54 +00:00
|
|
|
struct illegal_type;
|
2014-09-06 22:36:58 +00:00
|
|
|
side_type m_type; // replaces num_faces and tri_edge, 1 = quad, 2 = 0:2 triangulation, 3 = 1:3 triangulation
|
|
|
|
const side_type &get_type() const { return m_type; }
|
|
|
|
void set_type(side_type t) { m_type = t; }
|
2014-10-05 20:59:54 +00:00
|
|
|
inline void set_type(unsigned t);
|
2014-10-04 17:30:18 +00:00
|
|
|
wallnum_t wall_num;
|
2006-03-20 17:12:09 +00:00
|
|
|
short tmap_num;
|
|
|
|
short tmap_num2;
|
2014-09-13 22:05:52 +00:00
|
|
|
array<uvl, 4> uvls;
|
|
|
|
array<vms_vector, 2> normals; // 2 normals, if quadrilateral, both the same.
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2015-12-05 22:57:25 +00:00
|
|
|
}
|
|
|
|
|
2016-01-09 16:38:15 +00:00
|
|
|
#ifdef dsx
|
2015-12-13 18:00:49 +00:00
|
|
|
namespace dsx {
|
2015-12-05 22:57:25 +00:00
|
|
|
|
2013-03-16 02:54:33 +00:00
|
|
|
struct segment {
|
2016-09-11 18:49:16 +00:00
|
|
|
#if DXX_USE_EDITOR
|
2013-12-29 04:28:07 +00:00
|
|
|
segnum_t segnum; // segment number, not sure what it means
|
2013-03-16 02:54:33 +00:00
|
|
|
short group; // group number to which the segment belongs.
|
2006-03-20 17:12:09 +00:00
|
|
|
#endif
|
2013-12-29 04:28:07 +00:00
|
|
|
objnum_t objects; // pointer to objects in this segment
|
2014-08-16 18:14:00 +00:00
|
|
|
array<segnum_t, MAX_SIDES_PER_SEGMENT> children; // indices of 6 children segments, front, left, top, right, bottom, back
|
2013-12-31 04:05:48 +00:00
|
|
|
// If bit n (1 << n) is set, then side #n in segment has had light subtracted from original (editor-computed) value.
|
|
|
|
ubyte light_subtracted;
|
2015-05-17 20:37:59 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_II)
|
|
|
|
uint8_t slide_textures;
|
|
|
|
#endif
|
2014-08-16 18:14:00 +00:00
|
|
|
array<int, MAX_VERTICES_PER_SEGMENT> verts; // vertex ids of 4 front and 4 back vertices
|
2013-03-17 18:55:32 +00:00
|
|
|
ubyte special; // what type of center this is
|
|
|
|
sbyte matcen_num; // which center segment is associated with.
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
|
|
|
short value;
|
|
|
|
#elif defined(DXX_BUILD_DESCENT_II)
|
2013-03-17 18:55:32 +00:00
|
|
|
sbyte value;
|
|
|
|
ubyte s2_flags;
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2013-11-10 23:21:49 +00:00
|
|
|
fix static_light;
|
2015-10-18 21:01:20 +00:00
|
|
|
array<side, MAX_SIDES_PER_SEGMENT> sides; // 6 sides
|
2013-03-16 02:54:33 +00:00
|
|
|
};
|
2015-12-05 22:57:25 +00:00
|
|
|
|
|
|
|
}
|
2015-07-18 21:01:55 +00:00
|
|
|
#endif
|
2013-03-16 02:54:33 +00:00
|
|
|
|
2015-12-13 18:00:49 +00:00
|
|
|
namespace dcx {
|
2015-12-05 22:57:25 +00:00
|
|
|
|
2014-10-02 03:02:34 +00:00
|
|
|
struct count_segment_array_t : public count_array_t<segnum_t, MAX_SEGMENTS> {};
|
2013-12-11 23:59:36 +00:00
|
|
|
|
2013-12-11 23:59:36 +00:00
|
|
|
struct group
|
|
|
|
{
|
2013-12-11 23:59:36 +00:00
|
|
|
struct segment_array_type_t : public count_segment_array_t {};
|
2013-12-11 23:59:36 +00:00
|
|
|
struct vertex_array_type_t : public count_array_t<int, MAX_VERTICES> {};
|
|
|
|
segment_array_type_t segments;
|
|
|
|
vertex_array_type_t vertices;
|
|
|
|
void clear()
|
|
|
|
{
|
|
|
|
segments.clear();
|
|
|
|
vertices.clear();
|
|
|
|
}
|
|
|
|
};
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2015-12-05 22:57:25 +00:00
|
|
|
}
|
|
|
|
|
2016-01-09 16:38:15 +00:00
|
|
|
#ifdef dsx
|
2016-01-09 16:38:14 +00:00
|
|
|
#define Highest_segment_index (Segments.get_count() - 1)
|
2014-07-12 20:54:36 +00:00
|
|
|
|
2015-12-22 04:18:50 +00:00
|
|
|
namespace dsx {
|
2016-04-06 03:34:13 +00:00
|
|
|
DXX_VALPTRIDX_DEFINE_GLOBAL_FACTORIES(segment, seg);
|
2015-12-22 04:18:50 +00:00
|
|
|
}
|
2015-07-18 21:01:55 +00:00
|
|
|
#endif
|
|
|
|
|
2015-12-13 18:00:49 +00:00
|
|
|
namespace dcx {
|
2015-12-05 22:57:25 +00:00
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
// Globals from mglobal.c
|
2014-10-02 03:02:34 +00:00
|
|
|
struct vertex : vms_vector
|
|
|
|
{
|
|
|
|
vertex() = default;
|
|
|
|
vertex(const fix &a, const fix &b, const fix &c) :
|
2015-12-05 22:57:25 +00:00
|
|
|
vms_vector{a, b, c}
|
2014-10-02 03:02:34 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
explicit vertex(const vms_vector &v) :
|
|
|
|
vms_vector(v)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2015-12-05 22:57:25 +00:00
|
|
|
}
|
|
|
|
|
2016-01-09 16:38:15 +00:00
|
|
|
#ifdef dsx
|
2014-10-05 20:59:54 +00:00
|
|
|
struct side::illegal_type : std::runtime_error
|
|
|
|
{
|
2014-10-02 03:02:34 +00:00
|
|
|
csegptr_t m_segment;
|
2014-10-05 20:59:54 +00:00
|
|
|
const side *m_side;
|
2014-10-02 03:02:34 +00:00
|
|
|
illegal_type(csegptr_t seg, const side *s) :
|
2014-10-05 20:59:54 +00:00
|
|
|
runtime_error("illegal side type"),
|
|
|
|
m_segment(seg), m_side(s)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
illegal_type(const side *s) :
|
|
|
|
runtime_error("illegal side type"),
|
|
|
|
m_segment(nullptr), m_side(s)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void side::set_type(unsigned t)
|
|
|
|
{
|
|
|
|
switch (t)
|
|
|
|
{
|
|
|
|
case SIDE_IS_QUAD:
|
|
|
|
case SIDE_IS_TRI_02:
|
|
|
|
case SIDE_IS_TRI_13:
|
|
|
|
set_type(static_cast<side_type>(t));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
throw illegal_type(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-13 18:00:49 +00:00
|
|
|
namespace dsx {
|
2015-12-05 22:57:25 +00:00
|
|
|
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_II)
|
2006-03-20 17:12:09 +00:00
|
|
|
// New stuff, 10/14/95: For shooting out lights and monitors.
|
|
|
|
// Light cast upon vert_light vertices in segnum:sidenum by some light
|
2015-02-28 19:36:01 +00:00
|
|
|
struct delta_light : prohibit_void_ptr<delta_light>
|
|
|
|
{
|
2013-12-29 04:28:07 +00:00
|
|
|
segnum_t segnum;
|
2006-03-20 17:12:09 +00:00
|
|
|
sbyte sidenum;
|
2015-04-02 02:36:52 +00:00
|
|
|
array<ubyte, 4> vert_light;
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
// Light at segnum:sidenum casts light on count sides beginning at index (in array Delta_lights)
|
2013-12-22 22:03:07 +00:00
|
|
|
struct dl_index {
|
2013-12-29 04:28:07 +00:00
|
|
|
segnum_t segnum;
|
2006-03-20 17:12:09 +00:00
|
|
|
sbyte sidenum;
|
2014-11-23 04:36:59 +00:00
|
|
|
uint8_t count;
|
|
|
|
uint16_t index;
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2015-12-05 22:57:25 +00:00
|
|
|
|
|
|
|
}
|
2015-11-26 02:56:55 +00:00
|
|
|
#endif
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2015-12-13 18:00:49 +00:00
|
|
|
namespace dcx {
|
2015-12-05 22:57:25 +00:00
|
|
|
|
2013-11-17 00:17:58 +00:00
|
|
|
template <typename T, unsigned bits>
|
|
|
|
class visited_segment_mask_t
|
|
|
|
{
|
|
|
|
static_assert(bits == 1 || bits == 2 || bits == 4, "bits must align in bytes");
|
|
|
|
protected:
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
divisor = 8 / bits,
|
|
|
|
};
|
|
|
|
typedef array<ubyte, (MAX_SEGMENTS + (divisor - 1)) / divisor> array_t;
|
|
|
|
typedef typename array_t::size_type size_type;
|
|
|
|
array_t a;
|
|
|
|
struct base_maskproxy_t
|
|
|
|
{
|
|
|
|
unsigned m_shift;
|
2012-12-02 18:57:09 +00:00
|
|
|
unsigned shift() const
|
|
|
|
{
|
|
|
|
return m_shift * bits;
|
|
|
|
}
|
|
|
|
static unsigned bitmask_low_aligned()
|
|
|
|
{
|
|
|
|
return (1 << bits) - 1;
|
|
|
|
}
|
2013-11-17 00:17:58 +00:00
|
|
|
typename array_t::value_type mask() const
|
|
|
|
{
|
2012-12-02 18:57:09 +00:00
|
|
|
return bitmask_low_aligned() << shift();
|
2013-11-17 00:17:58 +00:00
|
|
|
}
|
2016-05-29 17:46:32 +00:00
|
|
|
base_maskproxy_t(const unsigned s) :
|
|
|
|
m_shift(s)
|
2013-11-17 00:17:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
template <typename R>
|
|
|
|
struct tmpl_maskproxy_t : public base_maskproxy_t
|
|
|
|
{
|
|
|
|
R m_byte;
|
2016-06-01 01:52:45 +00:00
|
|
|
tmpl_maskproxy_t(R byte, unsigned s) :
|
|
|
|
base_maskproxy_t(s), m_byte(byte)
|
2013-11-17 00:17:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
template <typename R, typename A>
|
|
|
|
static R make_maskproxy(A &a, size_type segnum)
|
|
|
|
{
|
|
|
|
size_type idx = segnum / divisor;
|
|
|
|
if (idx >= a.size())
|
|
|
|
throw std::out_of_range("index exceeds segment range");
|
|
|
|
size_type bit = segnum % divisor;
|
|
|
|
return R(a[idx], bit);
|
|
|
|
}
|
|
|
|
public:
|
2013-12-22 05:27:46 +00:00
|
|
|
visited_segment_mask_t()
|
|
|
|
{
|
|
|
|
clear();
|
|
|
|
}
|
2013-11-17 00:17:58 +00:00
|
|
|
void clear()
|
|
|
|
{
|
2015-09-29 02:41:22 +00:00
|
|
|
a = {};
|
2013-11-17 00:17:58 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class visited_segment_bitarray_t : public visited_segment_mask_t<bool, 1>
|
|
|
|
{
|
|
|
|
template <typename R>
|
|
|
|
struct tmpl_bitproxy_t : public tmpl_maskproxy_t<R>
|
|
|
|
{
|
2016-06-01 01:52:45 +00:00
|
|
|
tmpl_bitproxy_t(R byte, unsigned s) :
|
|
|
|
tmpl_maskproxy_t<R>(byte, s)
|
2013-11-17 00:17:58 +00:00
|
|
|
{
|
|
|
|
}
|
2015-08-03 03:11:25 +00:00
|
|
|
explicit operator bool() const
|
2013-11-17 00:17:58 +00:00
|
|
|
{
|
|
|
|
return !!(this->m_byte & this->mask());
|
|
|
|
}
|
2015-05-01 02:18:33 +00:00
|
|
|
operator int() const = delete;
|
2013-11-17 00:17:58 +00:00
|
|
|
};
|
2014-06-30 03:25:47 +00:00
|
|
|
struct bitproxy_t : public tmpl_bitproxy_t<array_t::reference>
|
2013-11-17 00:17:58 +00:00
|
|
|
{
|
2016-06-01 01:52:45 +00:00
|
|
|
bitproxy_t(array_t::reference byte, unsigned s) :
|
|
|
|
tmpl_bitproxy_t<array_t::reference>(byte, s)
|
2013-11-17 00:17:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
bitproxy_t& operator=(bool b)
|
|
|
|
{
|
|
|
|
if (b)
|
|
|
|
this->m_byte |= this->mask();
|
|
|
|
else
|
|
|
|
this->m_byte &= ~this->mask();
|
|
|
|
return *this;
|
|
|
|
}
|
2015-05-01 02:18:33 +00:00
|
|
|
bitproxy_t& operator=(int) = delete;
|
2013-11-17 00:17:58 +00:00
|
|
|
};
|
2014-06-30 03:25:47 +00:00
|
|
|
typedef tmpl_bitproxy_t<array_t::const_reference> const_bitproxy_t;
|
2013-11-17 00:17:58 +00:00
|
|
|
public:
|
|
|
|
bitproxy_t operator[](size_type segnum)
|
|
|
|
{
|
|
|
|
return make_maskproxy<bitproxy_t>(a, segnum);
|
|
|
|
}
|
|
|
|
const_bitproxy_t operator[](size_type segnum) const
|
|
|
|
{
|
|
|
|
return make_maskproxy<const_bitproxy_t>(a, segnum);
|
|
|
|
}
|
|
|
|
};
|
2012-12-02 18:57:09 +00:00
|
|
|
|
|
|
|
template <unsigned bits>
|
|
|
|
class visited_segment_multibit_array_t : public visited_segment_mask_t<unsigned, bits>
|
|
|
|
{
|
|
|
|
typedef typename visited_segment_mask_t<unsigned, bits>::array_t array_t;
|
|
|
|
typedef typename visited_segment_mask_t<unsigned, bits>::size_type size_type;
|
|
|
|
template <typename R>
|
|
|
|
struct tmpl_multibit_proxy_t : public visited_segment_mask_t<unsigned, bits>::template tmpl_maskproxy_t<R>
|
|
|
|
{
|
2016-06-01 01:52:45 +00:00
|
|
|
tmpl_multibit_proxy_t(R byte, unsigned s) :
|
|
|
|
visited_segment_mask_t<unsigned, bits>::template tmpl_maskproxy_t<R>(byte, s)
|
2012-12-02 18:57:09 +00:00
|
|
|
{
|
|
|
|
}
|
2015-08-03 03:11:25 +00:00
|
|
|
explicit operator bool() const
|
2012-12-02 18:57:09 +00:00
|
|
|
{
|
|
|
|
return !!(this->m_byte & this->mask());
|
|
|
|
}
|
|
|
|
operator unsigned() const
|
|
|
|
{
|
|
|
|
return (this->m_byte >> this->shift()) & this->bitmask_low_aligned();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
struct bitproxy_t : public tmpl_multibit_proxy_t<typename array_t::reference>
|
|
|
|
{
|
2016-06-01 01:52:45 +00:00
|
|
|
bitproxy_t(typename array_t::reference byte, unsigned s) :
|
|
|
|
tmpl_multibit_proxy_t<typename array_t::reference>(byte, s)
|
2012-12-02 18:57:09 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
bitproxy_t& operator=(unsigned u)
|
|
|
|
{
|
|
|
|
assert(!(u & ~this->bitmask_low_aligned()));
|
|
|
|
this->m_byte = (this->m_byte & ~this->mask()) | (u << this->shift());
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
typedef tmpl_multibit_proxy_t<typename array_t::const_reference> const_bitproxy_t;
|
|
|
|
public:
|
|
|
|
bitproxy_t operator[](size_type segnum)
|
|
|
|
{
|
|
|
|
return this->template make_maskproxy<bitproxy_t>(this->a, segnum);
|
|
|
|
}
|
|
|
|
const_bitproxy_t operator[](size_type segnum) const
|
|
|
|
{
|
|
|
|
return this->template make_maskproxy<const_bitproxy_t>(this->a, segnum);
|
|
|
|
}
|
|
|
|
};
|
2015-12-05 22:57:25 +00:00
|
|
|
|
|
|
|
}
|
2006-03-20 17:12:09 +00:00
|
|
|
#endif
|