summaryrefslogtreecommitdiff
path: root/src/engine/octa.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/octa.h')
-rw-r--r--src/engine/octa.h93
1 files changed, 29 insertions, 64 deletions
diff --git a/src/engine/octa.h b/src/engine/octa.h
index 9452ad0..d8a2c45 100644
--- a/src/engine/octa.h
+++ b/src/engine/octa.h
@@ -1,34 +1,28 @@
// 6-directional octree heightfield map format
-struct elementset
-{
+struct elementset {
ushort texture, lmid;
uchar dim, layer;
ushort length[2], minvert[2], maxvert[2];
};
-struct materialsurface
-{
+struct materialsurface {
ivec o;
ushort csize, rsize;
ushort material, skip;
uchar orient, visible;
- union
- {
+ union {
short index;
short depth;
};
- union
- {
+ union {
entity *light;
uchar ends;
};
};
-struct vertinfo
-{
+struct vertinfo {
ushort x, y, z, u, v, norm;
-
void setxyz(ushort a, ushort b, ushort c) { x = a; y = b; z = c; }
void setxyz(const ivec &v) { setxyz(v.x, v.y, v.z); }
void set(ushort a, ushort b, ushort c, ushort s = 0, ushort t = 0, ushort n = 0) { setxyz(a, b, c); u = s; v = t; norm = n; }
@@ -36,24 +30,19 @@ struct vertinfo
ivec getxyz() const { return ivec(x, y, z); }
};
-enum
-{
+enum {
LAYER_TOP = (1<<5),
LAYER_BOTTOM = (1<<6),
LAYER_DUP = (1<<7),
-
LAYER_BLEND = LAYER_TOP|LAYER_BOTTOM,
-
MAXFACEVERTS = 15
};
enum { LMID_AMBIENT = 0, LMID_AMBIENT1, LMID_BRIGHT, LMID_BRIGHT1, LMID_DARK, LMID_DARK1, LMID_RESERVED };
-struct surfaceinfo
-{
+struct surfaceinfo {
uchar lmid[2];
uchar verts, numverts;
-
int totalverts() const { return numverts&LAYER_DUP ? (numverts&MAXFACEVERTS)*2 : numverts&MAXFACEVERTS; }
bool used() const { return lmid[0] != LMID_AMBIENT || lmid[1] != LMID_AMBIENT || numverts&~LAYER_TOP; }
void clear() { lmid[0] = LMID_AMBIENT; lmid[1] = LMID_AMBIENT; numverts = (numverts&MAXFACEVERTS) | LAYER_TOP; }
@@ -64,8 +53,7 @@ static const surfaceinfo ambientsurface = {{LMID_AMBIENT, LMID_AMBIENT}, 0, LAYE
static const surfaceinfo brightsurface = {{LMID_BRIGHT, LMID_AMBIENT}, 0, LAYER_TOP};
static const surfaceinfo brightbottomsurface = {{LMID_AMBIENT, LMID_BRIGHT}, 0, LAYER_BOTTOM};
-struct occludequery
-{
+struct occludequery {
void *owner;
GLuint id;
int fragments;
@@ -73,8 +61,7 @@ struct occludequery
struct vtxarray;
-struct octaentities
-{
+struct octaentities {
vector<int> mapmodels;
vector<int> other;
occludequery *query;
@@ -83,30 +70,25 @@ struct octaentities
ivec o;
int size;
ivec bbmin, bbmax;
-
- octaentities(const ivec &o, int size) : query(0), o(o), size(size), bbmin(o), bbmax(o)
- {
+ octaentities(const ivec &o, int size) : query(0), o(o), size(size), bbmin(o), bbmax(o) {
bbmin.add(size);
}
};
-enum
-{
+enum {
OCCLUDE_NOTHING = 0,
OCCLUDE_GEOM,
OCCLUDE_BB,
OCCLUDE_PARENT
};
-enum
-{
+enum {
MERGE_ORIGIN = 1<<0,
MERGE_PART = 1<<1,
MERGE_USE = 1<<2
};
-struct vtxarray
-{
+struct vtxarray {
vtxarray *parent;
vector<vtxarray *> children;
vtxarray *next, *rnext; // linked list of visible VOBs
@@ -134,8 +116,7 @@ struct vtxarray
struct cube;
-struct clipplanes
-{
+struct clipplanes {
vec o, r, v[8];
plane p[12];
uchar side[12];
@@ -144,37 +125,30 @@ struct clipplanes
int version;
};
-struct facebounds
-{
+struct facebounds {
ushort u1, u2, v1, v2;
-
bool empty() const { return u1 >= u2 || v1 >= v2; }
};
-struct tjoint
-{
+struct tjoint {
int next;
ushort offset;
uchar edge;
};
-struct cubeext
-{
+struct cubeext {
vtxarray *va; // vertex array for children, or NULL
octaentities *ents; // map entities inside cube
surfaceinfo surfaces[6]; // render info for each surface
int tjoints; // linked list of t-joints
uchar maxverts; // allocated space for verts
-
vertinfo *verts() { return (vertinfo *)(this+1); }
};
-struct cube
-{
+struct cube {
cube *children; // points to 8 cube structures which are its children, or NULL. -Z first, then -Y, -X
cubeext *ext; // extended info for the cube
- union
- {
+ union {
uchar edges[12]; // edges of the cube, each uchar is 2 4bit values denoting the range.
// see documentation jpgs for more info.
uint faces[3]; // 4 edges of each dimension together representing 2 perpendicular faces
@@ -182,38 +156,32 @@ struct cube
ushort texture[6]; // one for each face. same order as orient.
ushort material; // empty-space material
uchar merged; // merged faces of the cube
- union
- {
+ union {
uchar escaped; // mask of which children have escaped merges
uchar visible; // visibility info for faces
};
};
-struct block3
-{
+struct block3 {
ivec o, s;
int grid, orient;
block3() {}
block3(const selinfo &sel) : o(sel.o), s(sel.s), grid(sel.grid), orient(sel.orient) {}
- cube *c() { return (cube *)(this+1); }
+ cube *c() { return (cube *)(this+1); }
int size() const { return s.x*s.y*s.z; }
};
-struct editinfo
-{
+struct editinfo {
block3 *copy;
editinfo() : copy(NULL) {}
};
-struct undoent { int i; entity e; };
-struct undoblock // undo header, all data sits in payload
-{
+struct undoent { int i; entity e; };
+struct undoblock { // undo header, all data sits in payload {
undoblock *prev, *next;
int size, timestamp, numents; // if numents is 0, is a cube undo record, otherwise an entity undo record
-
block3 *block() { return (block3 *)(this + 1); }
- uchar *gridmap()
- {
+ uchar *gridmap() {
block3 *ub = block();
return (uchar *)(ub->c() + ub->size());
}
@@ -245,8 +213,7 @@ const uint F_SOLID = 0x80808080; // all edges in the range (0,8)
#define octaindex(d,x,y,z) (((z)<<D[d])+((y)<<C[d])+((x)<<R[d]))
#define octastep(x, y, z, scale) (((((z)>>(scale))&1)<<2) | ((((y)>>(scale))&1)<<1) | (((x)>>(scale))&1))
-static inline uchar octaboxoverlap(const ivec &o, int size, const ivec &bbmin, const ivec &bbmax)
-{
+static inline uchar octaboxoverlap(const ivec &o, int size, const ivec &bbmin, const ivec &bbmax) {
uchar p = 0xFF; // bitmask of possible collisions with octants. 0 bit = 0 octant, etc
ivec mid = ivec(o).add(size);
if(mid.z <= bbmin.z) p &= 0xF0; // not in a -ve Z octant
@@ -261,8 +228,7 @@ static inline uchar octaboxoverlap(const ivec &o, int size, const ivec &bbmin, c
#define loopoctabox(o, size, bbmin, bbmax) uchar possible = octaboxoverlap(o, size, bbmin, bbmax); loopi(8) if(possible&(1<<i))
#define loopoctaboxsize(o, size, bborigin, bbsize) uchar possible = octaboxoverlap(o, size, bborigin, ivec(bborigin).add(bbsize)); loopi(8) if(possible&(1<<i))
-enum
-{
+enum {
O_LEFT = 0,
O_RIGHT,
O_BACK,
@@ -275,8 +241,7 @@ enum
#define dimcoord(orient) ((orient)&1)
#define opposite(orient) ((orient)^1)
-enum
-{
+enum {
VFC_FULL_VISIBLE = 0,
VFC_PART_VISIBLE,
VFC_NOT_VISIBLE,