Libprimis
Imprimis' 3D destroyable world engine
Loading...
Searching...
No Matches
octa.h File Reference

Objects representing the octree and its manipulation methods. More...

Go to the source code of this file.

Classes

class  cube
 The fundemental building block of the octree world, representing a 3D cube. More...
 
struct  selinfo
 A representation of a rectangular volume of cubes. More...
 
struct  block3
 A representation of a rectangular volume of cubes, with less metadata. More...
 
struct  editinfo
 
struct  undoent
 
struct  undoblock
 
class  cubeworld
 An object representing the entirety of an octree world. More...
 

Macros

#define LOOP_XY(b)
 
#define LOOP_XYZ(b, r, f)
 
#define LOOP_SEL_XYZ(f)
 
#define SELECT_CUBE(x, y, z)
 
#define PROTECT_SEL(f)
 
#define DIMENSION(orient)
 
#define DIM_COORD(orient)
 

Functions

void setcubefaces (cube &c, uint face)
 sets the faces to a given value face given
 
int octadim (int d)
 

Variables

const int Face_MaxVerts = 15
 
constexpr uint faceempty = 0
 
constexpr uint facesolid = 0x80808080
 
int selchildcount
 
int selchildmat
 
ivec lu
 
int lusize
 
cubeworld rootworld
 

Detailed Description

Objects representing the octree and its manipulation methods.

This file describes objects that build the octal tree structure of the world (a cubeworld containing cube objects) as well as convenient representations of selections of cubes (in a Cartesian sense) that allow simpler reasoning about spatial relationships between nodes.

Macro Definition Documentation

◆ DIM_COORD

#define DIM_COORD ( orient)
Value:
((orient)&1)

◆ DIMENSION

#define DIMENSION ( orient)
Value:
((orient)>>1)

◆ LOOP_SEL_XYZ

#define LOOP_SEL_XYZ ( f)
Value:
{ if(local) makeundo(); LOOP_XYZ(sel, sel.grid, f); rootworld.changed(sel); }
void makeundo()
Adds an undo entry to the undos vector given the current selection.
int grid
Definition octa.h:302

◆ LOOP_XY

#define LOOP_XY ( b)
Value:
for(int y = 0; y < (b).s[C[DIMENSION((b).orient)]]; ++y) for(int x = 0; x < (b).s[R[DIMENSION((b).orient)]]; ++x)
const int R[3]
Definition geom.h:2067
const int C[3]
Definition geom.h:2068

◆ LOOP_XYZ

#define LOOP_XYZ ( b,
r,
f )
Value:
{ for(int z = 0; z < (b).s[D[DIMENSION((b).orient)]]; ++z) LOOP_XY((b)) { cube &c = blockcube(x,y,z,b,r); f; } }
The fundemental building block of the octree world, representing a 3D cube.
Definition octa.h:100
const int D[3]
Definition geom.h:2069
cube & blockcube(int x, int y, int z, const block3 &b, int rgrid)
Looks up a world cube inside the block passed.

◆ PROTECT_SEL

#define PROTECT_SEL ( f)
Value:
{ undoblock *_u = newundocube(sel); f; if(_u) { pasteundoblock(_u->block(), _u->gridmap()); freeundo(_u); } }
undoblock * newundocube(const selinfo &s)
Creates an undoblock object given a cube selection.
void pasteundoblock(block3 *b, const uchar *g)
Pastes an undo block associated with the passed block3 object.
void freeundo(undoblock *u)
Deletes an undoblock object.
Definition octa.h:393

◆ SELECT_CUBE

#define SELECT_CUBE ( x,
y,
z )
Value:
blockcube(x, y, z, sel, sel.grid)

Variable Documentation

◆ faceempty

uint faceempty = 0
constexpr

internal engine data for the cube object, not accessible via external API all edges in the range (0,0)

◆ facesolid

uint facesolid = 0x80808080
constexpr

all edges in the range (0,8)