Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
octa.hpp
Go to the documentation of this file.
1 // 6-directional octree heightfield map format
2 
3 #pragma once
4 
5 #include "inexor/engine/material.hpp" // for ::MAT_AIR, ::MATF_VOLUME
6 #include "inexor/engine/octree.hpp" // for cubeext (ptr only), faceboun...
7 #include "inexor/engine/world.hpp" // for worldsize
8 #include "inexor/network/SharedVar.hpp" // for SharedVar
9 #include "inexor/shared/cube_types.hpp" // for uint, ushort, uchar
10 #include "inexor/shared/geom.hpp" // for ivec, vec, vec::(anonymous u...
11 
12 extern cube *newcubes(uint face = F_EMPTY, int mat = MAT_AIR);
13 extern cubeext *growcubeext(cubeext *ext, int maxverts);
14 extern void setcubeext(cube &c, cubeext *ext);
15 extern cubeext *newcubeext(cube &c, int maxverts = 0, bool init = true);
16 extern void getcubevector(cube &c, int d, int x, int y, int z, ivec &p);
17 extern void setcubevector(cube &c, int d, int x, int y, int z, const ivec &p);
18 extern int familysize(const cube &c);
19 extern void freeocta(cube *c);
20 extern void discardchildren(cube &c, bool fixtex = false, int depth = 0);
21 extern void optiface(uchar *p, cube &c);
22 extern void validatec(cube *c, int size = 0);
23 extern bool isvalidcube(const cube &c);
24 extern ivec lu;
25 extern int lusize;
26 extern cube &lookupcube(const ivec &to, int tsize = 0, ivec &ro = lu, int &rsize = lusize);
27 extern const cube *neighbourstack[32];
28 extern int neighbourdepth;
29 extern const cube &neighbourcube(const cube &c, int orient, const ivec &co, int size, ivec &ro = lu, int &rsize = lusize);
30 extern void resetclipplanes();
31 extern int getmippedtexture(const cube &p, int orient);
32 extern void forcemip(cube &c, bool fixtex = true);
33 extern bool subdividecube(cube &c, bool fullcheck=true, bool brighten=true);
34 extern void edgespan2vectorcube(cube &c);
35 extern int faceconvexity(const ivec v[4]);
36 extern int faceconvexity(const ivec v[4], int &vis);
37 extern int faceconvexity(const vertinfo *verts, int numverts, int size);
38 extern int faceconvexity(const cube &c, int orient);
39 extern void calcvert(const cube &c, const ivec &co, int size, ivec &vert, int i, bool solid = false);
40 extern void calcvert(const cube &c, const ivec &co, int size, vec &vert, int i, bool solid = false);
41 extern uint faceedges(const cube &c, int orient);
42 extern bool collapsedface(const cube &c, int orient);
43 extern bool touchingface(const cube &c, int orient);
44 extern bool flataxisface(const cube &c, int orient);
45 extern bool collideface(const cube &c, int orient);
46 extern int genclipplane(const cube &c, int i, vec *v, plane *clip);
47 extern void genclipplanes(const cube &c, const ivec &co, int size, clipplanes &p, bool collide = true);
48 extern bool visibleface(const cube &c, int orient, const ivec &co, int size, ushort mat = MAT_AIR, ushort nmat = MAT_AIR, ushort matmask = MATF_VOLUME);
49 extern int classifyface(const cube &c, int orient, const ivec &co, int size);
50 extern int visibletris(const cube &c, int orient, const ivec &co, int size, ushort nmat = MAT_ALPHA, ushort matmask = MAT_ALPHA);
51 extern int visibleorient(const cube &c, int orient);
52 extern void genfaceverts(const cube &c, int orient, ivec v[4]);
53 extern int calcmergedsize(int orient, const ivec &co, int size, const vertinfo *verts, int numverts);
54 extern void invalidatemerges(cube &c, const ivec &co, int size, bool msg);
55 extern void calcmerges();
56 
57 extern int mergefaces(int orient, facebounds *m, int sz);
58 extern void mincubeface(const cube &cu, int orient, const ivec &o, int size, const facebounds &orig, facebounds &cf, ushort nmat = MAT_AIR, ushort matmask = MATF_VOLUME);
59 
60 static inline cubeext &ext(cube &c)
61 {
62  return *(c.ext ? c.ext : newcubeext(c));
63 }
64 
65 extern int lookupmaterial(const vec &o);
66 
67 static inline bool insideworld(const vec &o)
68 {
69  return o.x>=0 && o.x<worldsize && o.y>=0 && o.y<worldsize && o.z>=0 && o.z<worldsize;
70 }
71 
72 static inline bool insideworld(const ivec &o)
73 {
74  return uint(o.x)<uint(worldsize) && uint(o.y)<uint(worldsize) && uint(o.z)<uint(worldsize);
75 }
76 extern const ivec cubecoords[8];
77 extern const ivec facecoords[6][4];
78 extern const uchar fv[6][4];
79 extern const uchar fvmasks[64];
80 extern const uchar faceedgesidx[6][4];
uint faceedges(const cube &c, int orient)
Definition: octa.cpp:857
cubeext * growcubeext(cubeext *ext, int maxverts)
Definition: octa.cpp:36
cubeext * ext
Definition: octree.hpp:211
bool isvalidcube(const cube &c)
Definition: octa.cpp:203
int mergefaces(int orient, facebounds *m, int sz)
Definition: octa.cpp:1340
unsigned int uint
Definition: cube_types.hpp:9
int classifyface(const cube &c, int orient, const ivec &co, int size)
Definition: octa.cpp:1092
bool subdividecube(cube &c, bool fullcheck=true, bool brighten=true)
Definition: octa.cpp:400
cube * newcubes(uint face=F_EMPTY, int mat=MAT_AIR)
Definition: octa.cpp:80
void mincubeface(const cube &cu, int orient, const ivec &o, int size, const facebounds &orig, facebounds &cf, ushort nmat=MAT_AIR, ushort matmask=MATF_VOLUME)
Definition: octa.cpp:1367
const uchar fv[6][4]
Definition: octa.cpp:738
int faceconvexity(const ivec v[4])
Definition: octa.cpp:801
Definition: octree.hpp:183
const ivec cubecoords[8]
Definition: octa.cpp:686
SharedVar< int > worldsize
int familysize(const cube &c)
Definition: octa.cpp:98
Definition: octree.hpp:173
Definition: material.hpp:36
void calcmerges()
Definition: octa.cpp:1912
void init(int slices, int stacks)
Definition: explosion.cpp:38
const uchar faceedgesidx[6][4]
Definition: octa.cpp:760
Definition: material.hpp:19
const uint F_EMPTY
Definition: octree.hpp:291
int numverts
Definition: explosion.cpp:35
void genfaceverts(const cube &c, int orient, ivec v[4])
Definition: octa.cpp:710
int visibleorient(const cube &c, int orient)
Definition: octa.cpp:479
void calcvert(const cube &c, const ivec &co, int size, ivec &vert, int i, bool solid=false)
Definition: octa.cpp:1216
const ivec facecoords[6][4]
Definition: octa.cpp:727
unsigned short ushort
Definition: cube_types.hpp:8
bool touchingface(const cube &c, int orient)
Definition: octa.cpp:789
int neighbourdepth
Definition: octa.cpp:297
static bool insideworld(const vec &o)
Definition: octa.hpp:67
bool visibleface(const cube &c, int orient, const ivec &co, int size, ushort mat=MAT_AIR, ushort nmat=MAT_AIR, ushort matmask=MATF_VOLUME)
Definition: octa.cpp:1050
void validatec(cube *c, int size=0)
Definition: octa.cpp:217
void setcubeext(cube &c, cubeext *ext)
Definition: octa.cpp:55
bool collideface(const cube &c, int orient)
Definition: octa.cpp:777
vector with 3 floats and some useful methods.
Definition: geom.hpp:110
int getmippedtexture(const cube &p, int orient)
Definition: octa.cpp:330
void discardchildren(cube &c, bool fixtex=false, int depth=0)
Definition: octa.cpp:122
int lookupmaterial(const vec &o)
Definition: octa.cpp:282
void optiface(uchar *p, cube &c)
Definition: octa.cpp:183
const cube & neighbourcube(const cube &c, int orient, const ivec &co, int size, ivec &ro=lu, int &rsize=lusize)
Definition: octa.cpp:299
cube & lookupcube(const ivec &to, int tsize=0, ivec &ro=lu, int &rsize=lusize)
Definition: octa.cpp:255
int genclipplane(const cube &c, int i, vec *v, plane *clip)
Definition: octa.cpp:1231
void getcubevector(cube &c, int d, int x, int y, int z, ivec &p)
Definition: octa.cpp:153
int orient
Definition: octaedit.cpp:164
bool collapsedface(const cube &c, int orient)
Definition: octa.cpp:1001
int lusize
lookup size
Definition: octa.cpp:253
int d
Definition: octaedit.cpp:1749
const cube * neighbourstack[32]
Definition: octa.cpp:296
static cubeext & ext(cube &c)
Definition: octa.hpp:60
unsigned char uchar
Basic type definitions.
Definition: cube_types.hpp:7
const uchar fvmasks[64]
Definition: octa.cpp:748
GLuint GLuint GLintptr GLsizeiptr size
Definition: glexts.hpp:412
Definition: octree.hpp:197
struct sphere::vert * verts
void freeocta(cube *c)
Definition: octa.cpp:105
cubeext * newcubeext(cube &c, int maxverts=0, bool init=true)
Definition: octa.cpp:63
void edgespan2vectorcube(cube &c)
Definition: octa.cpp:670
void setcubevector(cube &c, int d, int x, int y, int z, const ivec &p)
Definition: octa.cpp:161
int calcmergedsize(int orient, const ivec &co, int size, const vertinfo *verts, int numverts)
Definition: octa.cpp:1848
bool collide(const T &p1, const U &p2)
Definition: mpr.hpp:286
bool flataxisface(const cube &c, int orient)
Definition: octa.cpp:770
void resetclipplanes()
Definition: physics.cpp:55
mathmatics for vectors, matrices, quaterions and more
void forcemip(cube &c, bool fixtex=true)
Definition: octa.cpp:351
void invalidatemerges(cube &c, const ivec &co, int size, bool msg)
Definition: octa.cpp:1902
Definition: geom.hpp:1121
3-dimensional INTEGER vectors
Definition: geom.hpp:1226
void genclipplanes(const cube &c, const ivec &co, int size, clipplanes &p, bool collide=true)
Definition: octa.cpp:1241
ivec lu
lookup integer vector
Definition: octa.cpp:251
int visibletris(const cube &c, int orient, const ivec &co, int size, ushort nmat=MAT_ALPHA, ushort matmask=MAT_ALPHA)
Definition: octa.cpp:1131
Definition: octree.hpp:208
Definition: material.hpp:26
Definition: octree.hpp:50