Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Macros | Enumerations | Functions | Variables
octree.hpp File Reference
#include <boost/algorithm/clamp.hpp>
#include "inexor/network/SharedVar.hpp"
#include "inexor/shared/cube_loops.hpp"
#include "inexor/shared/cube_types.hpp"
#include "inexor/shared/cube_vector.hpp"
#include "inexor/shared/ents.hpp"
#include "inexor/shared/geom.hpp"

Go to the source code of this file.

Classes

struct  elementset
 
struct  materialsurface
 
struct  vertinfo
 
struct  surfaceinfo
 
struct  grasstri
 
struct  occludequery
 
struct  octaentities
 
struct  vtxarray
 
struct  clipplanes
 
struct  facebounds
 
struct  tjoint
 
struct  cubeext
 
struct  cube
 
struct  selinfo
 Selection info: the marked area when editing. More...
 
struct  block3
 
struct  editinfo
 
struct  undoent
 
struct  undoblock
 
union  materialsurface.__unnamed__
 
union  materialsurface.__unnamed__
 
union  cube.__unnamed__
 
union  cube.__unnamed__
 

Macros

#define isempty(c)   ((c).faces[0]==F_EMPTY)
 
#define isentirelysolid(c)   ((c).faces[0]==F_SOLID && (c).faces[1]==F_SOLID && (c).faces[2]==F_SOLID)
 
#define setfaces(c, face)   { (c).faces[0] = (c).faces[1] = (c).faces[2] = face; }
 
#define solidfaces(c)   setfaces(c, F_SOLID)
 
#define emptyfaces(c)   setfaces(c, F_EMPTY)
 
#define edgemake(a, b)   ((b)<<4|a)
 
#define edgeget(edge, coord)   ((coord) ? (edge)>>4 : (edge)&0xF)
 
#define edgeset(edge, coord, val)   ((edge) = ((coord) ? ((edge)&0xF)|((val)<<4) : ((edge)&0xF0)|(val)))
 
#define cubeedge(c, d, x, y)   ((c).edges[(((d)<<2)+((y)<<1)+(x))])
 
#define octadim(d)   (1<<(d))
 
#define octacoord(d, i)   (((i)&octadim(d))>>(d))
 
#define oppositeocta(d, i)   ((i)^octadim(D[d]))
 
#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))
 
#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))
 
#define dimension(orient)   ((orient)>>1)
 
#define dimcoord(orient)   ((orient)&1)
 
#define opposite(orient)   ((orient)^1)
 
#define GENCUBEVERTS(x0, x1, y0, y1, z0, z1)
 
#define GENFACEVERTX(o, n, x, y, z, xv, yv, zv)   GENFACEVERT(o,n, x,y,z, xv,yv,zv)
 
#define GENFACEVERTSX(x0, x1, y0, y1, z0, z1, c0, c1, r0, r1, d0, d1)
 
#define GENFACEVERTY(o, n, x, y, z, xv, yv, zv)   GENFACEVERT(o,n, x,y,z, xv,yv,zv)
 
#define GENFACEVERTSY(x0, x1, y0, y1, z0, z1, c0, c1, r0, r1, d0, d1)
 
#define GENFACEVERTZ(o, n, x, y, z, xv, yv, zv)   GENFACEVERT(o,n, x,y,z, xv,yv,zv)
 
#define GENFACEVERTSZ(x0, x1, y0, y1, z0, z1, c0, c1, r0, r1, d0, d1)
 
#define GENFACEVERTSXY(x0, x1, y0, y1, z0, z1, c0, c1, r0, r1, d0, d1)
 
#define GENFACEVERTS(x0, x1, y0, y1, z0, z1, c0, c1, r0, r1, d0, d1)
 

Enumerations

enum  { EMID_NONE = 0, EMID_CUSTOM, EMID_SKY, EMID_RESERVED }
 
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
}
 
enum  { OCCLUDE_NOTHING = 0, OCCLUDE_GEOM, OCCLUDE_BB, OCCLUDE_PARENT }
 
enum  { MERGE_ORIGIN = 1<<0, MERGE_PART = 1<<1, MERGE_USE = 1<<2 }
 
enum  {
  O_LEFT = 0, O_RIGHT, O_BACK, O_FRONT,
  O_BOTTOM, O_TOP
}
 
enum  {
  VFC_FULL_VISIBLE = 0, VFC_PART_VISIBLE, VFC_FOGGED, VFC_NOT_VISIBLE,
  PVS_FULL_VISIBLE, PVS_PART_VISIBLE, PVS_FOGGED
}
 

Functions

static uchar octaboxoverlap (const ivec &o, int size, const ivec &bbmin, const ivec &bbmax)
 

Variables

static const surfaceinfo ambientsurface = {{LMID_AMBIENT, LMID_AMBIENT}, 0, LAYER_TOP}
 
static const surfaceinfo brightsurface = {{LMID_BRIGHT, LMID_AMBIENT}, 0, LAYER_TOP}
 
static const surfaceinfo brightbottomsurface = {{LMID_AMBIENT, LMID_BRIGHT}, 0, LAYER_BOTTOM}
 
SharedVar< int > worldsize
 
cubeworldroot
 
int wtris
 
int wverts
 
int vtris
 
int vverts
 
int glde
 
int gbatches
 
int rplanes
 
int allocnodes
 
int allocva
 
int selchildcount
 the amount of selected child cubes they will be displayed in the bottom left of you screen in coopedit mode More...
 
int selchildmat
 
const uint F_EMPTY = 0
 
const uint F_SOLID = 0x80808080
 

Class Documentation

struct elementset
Class Members
uchar dim
ushort envmap
uchar layer
ushort length[2]
ushort lmid
ushort maxvert[2]
ushort minvert[2]
ushort texture
struct materialsurface
Class Members
union materialsurface __unnamed__
union materialsurface __unnamed__
ushort csize
ushort material
ivec o
uchar orient
ushort rsize
ushort skip
uchar visible
struct grasstri
Class Members
vec center
ushort lmid
float maxz
float minz
int numv
float radius
plane surface
vec4 tcu
vec4 tcv
ushort texture
vec v[4]
struct occludequery
Class Members
int fragments
uint id
void * owner
struct vtxarray
Class Members
int alphaback
int alphabacktris
int alphafront
int alphafronttris
ivec bbmax
ivec bbmin
int blends
int blendtris
vector< vtxarray * > children
uchar curvfc
int distance
uint dynlightmask
uint ebuf
ushort * edata
elementset * eslist
int explicitsky
ivec geommax
ivec geommin
vector< grasstri > grasstris
int hasmerges
vector< octaentities * > mapmodels
materialsurface * matbuf
ivec matmax
ivec matmin
int matsurfs
ushort maxvert
int mergelevel
ushort minvert
vtxarray * next
ivec o
uchar occluded
vtxarray * parent
occludequery * query
vtxarray * rnext
bool shadowed
ivec shadowmapmax
ivec shadowmapmin
int size
int sky
double skyarea
uint skybuf
int skyclip
ushort * skydata
int skyfaces
int texmask
int texs
int tris
uint vbuf
vertex * vdata
int verts
ushort voffset
struct clipplanes
Class Members
vec o
const cube * owner
plane p[12]
vec r
uchar side[12]
uchar size
vec v[8]
int version
uchar visible
struct tjoint
Class Members
uchar edge
int next
ushort offset
struct cube
Class Members
union cube __unnamed__
union cube __unnamed__
cube * children
cubeext * ext
ushort material
uchar merged
ushort texture[6]
struct undoent
Class Members
entity e
int i
union materialsurface.__unnamed__
Class Members
short depth
short index
union materialsurface.__unnamed__
Class Members
uchar ends
ushort envmap
entity * light
union cube.__unnamed__
Class Members
uchar edges[12]
uint faces[3]
union cube.__unnamed__
Class Members
uchar escaped
uchar visible

Macro Definition Documentation

#define cubeedge (   c,
  d,
  x,
 
)    ((c).edges[(((d)<<2)+((y)<<1)+(x))])
#define dimcoord (   orient)    ((orient)&1)
#define dimension (   orient)    ((orient)>>1)
#define edgeget (   edge,
  coord 
)    ((coord) ? (edge)>>4 : (edge)&0xF)

Referenced by edgeval(), getcubevector(), and pushedge().

#define edgemake (   a,
 
)    ((b)<<4|a)
#define edgeset (   edge,
  coord,
  val 
)    ((edge) = ((coord) ? ((edge)&0xF)|((val)<<4) : ((edge)&0xF0)|(val)))
#define emptyfaces (   c)    setfaces(c, F_EMPTY)
#define GENCUBEVERTS (   x0,
  x1,
  y0,
  y1,
  z0,
  z1 
)
Value:
GENCUBEVERT(0, x1, y1, z0) \
GENCUBEVERT(1, x0, y1, z0) \
GENCUBEVERT(2, x0, y1, z1) \
GENCUBEVERT(3, x1, y1, z1) \
GENCUBEVERT(4, x1, y0, z1) \
GENCUBEVERT(5, x0, y0, z1) \
GENCUBEVERT(6, x0, y0, z0) \
GENCUBEVERT(7, x1, y0, z0)
#define GENCUBEVERT(n, x, y, z)

Referenced by gencubevert().

#define GENFACEVERTS (   x0,
  x1,
  y0,
  y1,
  z0,
  z1,
  c0,
  c1,
  r0,
  r1,
  d0,
  d1 
)
Value:
GENFACEVERTSXY(x0,x1, y0,y1, z0,z1, c0,c1, r0,r1, d0,d1) \
GENFACEVERTSZ(x0,x1, y0,y1, z0,z1, c0,c1, r0,r1, d0,d1)
#define GENFACEVERTSZ(x0, x1, y0, y1, z0, z1, c0, c1, r0, r1, d0, d1)
Definition: octree.hpp:372
#define GENFACEVERTSXY(x0, x1, y0, y1, z0, z1, c0, c1, r0, r1, d0, d1)
Definition: octree.hpp:375

Referenced by drawglass(), drawmaterial(), drawmaterialquery(), genfacevecs(), genfaceverts(), blobrenderer::gentris(), decalrenderer::gentris(), and setupbb().

#define GENFACEVERTSX (   x0,
  x1,
  y0,
  y1,
  z0,
  z1,
  c0,
  c1,
  r0,
  r1,
  d0,
  d1 
)
Value:
GENFACEORIENT(0, GENFACEVERTX(0,0, x0,y1,z1, d0,r1,c1), GENFACEVERTX(0,1, x0,y1,z0, d0,r1,c0), GENFACEVERTX(0,2, x0,y0,z0, d0,r0,c0), GENFACEVERTX(0,3, x0,y0,z1, d0,r0,c1)) \
GENFACEORIENT(1, GENFACEVERTX(1,0, x1,y1,z1, d1,r1,c1), GENFACEVERTX(1,1, x1,y0,z1, d1,r0,c1), GENFACEVERTX(1,2, x1,y0,z0, d1,r0,c0), GENFACEVERTX(1,3, x1,y1,z0, d1,r1,c0))
#define GENFACEVERTX(o, n, x, y, z, xv, yv, zv)
Definition: octree.hpp:363
#define GENFACEORIENT(orient, v0, v1, v2, v3)
#define GENFACEVERTSXY (   x0,
  x1,
  y0,
  y1,
  z0,
  z1,
  c0,
  c1,
  r0,
  r1,
  d0,
  d1 
)
Value:
GENFACEVERTSX(x0,x1, y0,y1, z0,z1, c0,c1, r0,r1, d0,d1) \
GENFACEVERTSY(x0,x1, y0,y1, z0,z1, c0,c1, r0,r1, d0,d1)
#define GENFACEVERTSY(x0, x1, y0, y1, z0, z1, c0, c1, r0, r1, d0, d1)
Definition: octree.hpp:368
#define GENFACEVERTSX(x0, x1, y0, y1, z0, z1, c0, c1, r0, r1, d0, d1)
Definition: octree.hpp:364

Referenced by renderwaterfall().

#define GENFACEVERTSY (   x0,
  x1,
  y0,
  y1,
  z0,
  z1,
  c0,
  c1,
  r0,
  r1,
  d0,
  d1 
)
Value:
GENFACEORIENT(2, GENFACEVERTY(2,0, x1,y0,z1, c1,d0,r1), GENFACEVERTY(2,1, x0,y0,z1, c0,d0,r1), GENFACEVERTY(2,2, x0,y0,z0, c0,d0,r0), GENFACEVERTY(2,3, x1,y0,z0, c1,d0,r0)) \
GENFACEORIENT(3, GENFACEVERTY(3,0, x0,y1,z0, c0,d1,r0), GENFACEVERTY(3,1, x0,y1,z1, c0,d1,r1), GENFACEVERTY(3,2, x1,y1,z1, c1,d1,r1), GENFACEVERTY(3,3, x1,y1,z0, c1,d1,r0))
#define GENFACEVERTY(o, n, x, y, z, xv, yv, zv)
Definition: octree.hpp:367
#define GENFACEORIENT(orient, v0, v1, v2, v3)
#define GENFACEVERTSZ (   x0,
  x1,
  y0,
  y1,
  z0,
  z1,
  c0,
  c1,
  r0,
  r1,
  d0,
  d1 
)
Value:
GENFACEORIENT(4, GENFACEVERTZ(4,0, x0,y0,z0, r0,c0,d0), GENFACEVERTZ(4,1, x0,y1,z0, r0,c1,d0), GENFACEVERTZ(4,2, x1,y1,z0, r1,c1,d0), GENFACEVERTZ(4,3, x1,y0,z0, r1,c0,d0)) \
GENFACEORIENT(5, GENFACEVERTZ(5,0, x0,y0,z1, r0,c0,d1), GENFACEVERTZ(5,1, x1,y0,z1, r1,c0,d1), GENFACEVERTZ(5,2, x1,y1,z1, r1,c1,d1), GENFACEVERTZ(5,3, x0,y1,z1, r0,c1,d1))
#define GENFACEVERTZ(o, n, x, y, z, xv, yv, zv)
Definition: octree.hpp:371
#define GENFACEORIENT(orient, v0, v1, v2, v3)
#define GENFACEVERTX (   o,
  n,
  x,
  y,
  z,
  xv,
  yv,
  zv 
)    GENFACEVERT(o,n, x,y,z, xv,yv,zv)
#define GENFACEVERTY (   o,
  n,
  x,
  y,
  z,
  xv,
  yv,
  zv 
)    GENFACEVERT(o,n, x,y,z, xv,yv,zv)
#define GENFACEVERTZ (   o,
  n,
  x,
  y,
  z,
  xv,
  yv,
  zv 
)    GENFACEVERT(o,n, x,y,z, xv,yv,zv)
#define isempty (   c)    ((c).faces[0]==F_EMPTY)
#define isentirelysolid (   c)    ((c).faces[0]==F_SOLID && (c).faces[1]==F_SOLID && (c).faces[2]==F_SOLID)
#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))

Referenced by countselchild().

#define octacoord (   d,
 
)    (((i)&octadim(d))>>(d))

Referenced by mincubeface(), and occludesface().

#define octadim (   d)    (1<<(d))

Referenced by flipcube(), and rotatecube().

#define octaindex (   d,
  x,
  y,
 
)    (((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))
#define opposite (   orient)    ((orient)^1)
#define oppositeocta (   d,
 
)    ((i)^octadim(D[d]))

Referenced by getmippedtexture().

#define setfaces (   c,
  face 
)    { (c).faces[0] = (c).faces[1] = (c).faces[2] = face; }

Referenced by newcubes().

#define solidfaces (   c)    setfaces(c, F_SOLID)

Enumeration Type Documentation

anonymous enum
Enumerator
EMID_NONE 
EMID_CUSTOM 
EMID_SKY 
EMID_RESERVED 
anonymous enum
Enumerator
LAYER_TOP 
LAYER_BOTTOM 
LAYER_DUP 
LAYER_BLEND 
MAXFACEVERTS 
anonymous enum
Enumerator
LMID_AMBIENT 
LMID_AMBIENT1 
LMID_BRIGHT 
LMID_BRIGHT1 
LMID_DARK 
LMID_DARK1 
LMID_RESERVED 
anonymous enum
Enumerator
OCCLUDE_NOTHING 
OCCLUDE_GEOM 
OCCLUDE_BB 
OCCLUDE_PARENT 
anonymous enum
Enumerator
MERGE_ORIGIN 
MERGE_PART 
MERGE_USE 
anonymous enum
Enumerator
O_LEFT 
O_RIGHT 
O_BACK 
O_FRONT 
O_BOTTOM 
O_TOP 
anonymous enum
Enumerator
VFC_FULL_VISIBLE 
VFC_PART_VISIBLE 
VFC_FOGGED 
VFC_NOT_VISIBLE 
PVS_FULL_VISIBLE 
PVS_PART_VISIBLE 
PVS_FOGGED 

Function Documentation

static uchar octaboxoverlap ( const ivec o,
int  size,
const ivec bbmin,
const ivec bbmax 
)
inlinestatic

Variable Documentation

int allocnodes
int allocva

Referenced by gl_drawhud().

const surfaceinfo ambientsurface = {{LMID_AMBIENT, LMID_AMBIENT}, 0, LAYER_TOP}
static

Referenced by addmerge().

const surfaceinfo brightbottomsurface = {{LMID_AMBIENT, LMID_BRIGHT}, 0, LAYER_BOTTOM}
static

Referenced by previewblends().

const surfaceinfo brightsurface = {{LMID_BRIGHT, LMID_AMBIENT}, 0, LAYER_TOP}
static

Referenced by addmerge(), clearmerge(), and previewblends().

const uint F_EMPTY = 0
const uint F_SOLID = 0x80808080
int gbatches
int glde
int rplanes
int selchildcount

the amount of selected child cubes they will be displayed in the bottom left of you screen in coopedit mode

Referenced by countselchild(), gl_drawhud(), and rendereditcursor().

int selchildmat
int vtris
int vverts
cube* worldroot
SharedVar<int> worldsize
int wtris

Referenced by gl_drawhud().

int wverts

Referenced by destroyva(), gl_drawhud(), and newva().