From 336f2fd75073f0564459b191c4ea046e3fe71385 Mon Sep 17 00:00:00 2001 From: q66 Date: Tue, 23 Jun 2020 00:02:51 +0200 Subject: [PATCH] visibility for octarender --- src/engine/octa.hh | 3 +- src/engine/octarender.cc | 52 +++++++++++++++++------------------ src/engine/octarender.hh | 3 ++ src/engine/rendermodel.cc | 1 + src/engine/renderparticles.cc | 1 + src/engine/rendersky.cc | 1 + 6 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/engine/octa.hh b/src/engine/octa.hh index 16d13b3..007e4b8 100644 --- a/src/engine/octa.hh +++ b/src/engine/octa.hh @@ -273,8 +273,7 @@ struct undoblock // undo header, all data sits in payload }; extern cube *worldroot; // the world data. only a ptr to 8 cubes (ie: like cube.children above) -extern int wtris, wverts, vtris, vverts, glde, gbatches, rplanes; -extern int allocnodes, allocva, selchildcount, selchildmat; +extern int allocnodes, selchildcount, selchildmat; const uint F_EMPTY = 0; // all edges in the range (0,0) const uint F_SOLID = 0x80808080; // all edges in the range (0,8) diff --git a/src/engine/octarender.cc b/src/engine/octarender.cc index 8d371f9..74a394b 100644 --- a/src/engine/octarender.cc +++ b/src/engine/octarender.cc @@ -23,7 +23,7 @@ struct vboinfo uchar *data; }; -hashtable vbos; +static hashtable vbos; VAR(printvbo, 0, 0, 1); VARFN(vbosize, maxvbosize, 0, 1<<14, 1<<16, allchanged()); @@ -41,7 +41,7 @@ static vector vbodata[NUMVBO]; static vector vbovas[NUMVBO]; static int vbosize[NUMVBO]; -void destroyvbo(GLuint vbo) +static void destroyvbo(GLuint vbo) { vboinfo *exists = vbos.access(vbo); if(!exists) return; @@ -56,7 +56,7 @@ void destroyvbo(GLuint vbo) } } -void genvbo(int type, void *buf, int len, vtxarray **vas, int numva) +static void genvbo(int type, void *buf, int len, vtxarray **vas, int numva) { gle::disable(); @@ -99,7 +99,7 @@ void genvbo(int type, void *buf, int len, vtxarray **vas, int numva) } } -void flushvbo(int type = -1) +static void flushvbo(int type = -1) { if(type < 0) { @@ -116,7 +116,7 @@ void flushvbo(int type = -1) vbosize[type] = 0; } -uchar *addvbo(vtxarray *va, int type, int numelems, int elemsize) +static uchar *addvbo(vtxarray *va, int type, int numelems, int elemsize) { switch(type) { @@ -636,7 +636,7 @@ struct vacollect : verthash } } vc; -int recalcprogress = 0; +static int recalcprogress = 0; #define progress(s) if((recalcprogress++&0xFFF)==0) renderprogress(recalcprogress/(float)allocnodes, s); vector tjoints; @@ -683,7 +683,7 @@ extern const vec orientation_bitangent[8][6] = { vec( 0, -1, 0), vec( 0, 1, 0), vec( 1, 0, 0), vec(-1, 0, 0), vec(-1, 0, 0), vec(-1, 0, 0) }, }; -void addtris(VSlot &vslot, int orient, const sortkey &key, vertex *verts, int *index, int numverts, int convex, int tj) +static void addtris(VSlot &vslot, int orient, const sortkey &key, vertex *verts, int *index, int numverts, int convex, int tj) { int &total = key.tex==DEFAULT_SKY ? vc.skytris : vc.worldtris; int edge = orient*(MAXFACEVERTS+1); @@ -771,7 +771,7 @@ void addtris(VSlot &vslot, int orient, const sortkey &key, vertex *verts, int *i } } -void addgrasstri(int face, vertex *verts, int numv, ushort texture, int layer) +static void addgrasstri(int face, vertex *verts, int numv, ushort texture, int layer) { grasstri &g = vc.grasstris.add(); int i1, i2, i3, i4; @@ -877,7 +877,7 @@ void guessnormals(const vec *pos, int numverts, vec *normals) normals[3] = n2; } -void addcubeverts(VSlot &vslot, int orient, int size, vec *pos, int convex, ushort texture, vertinfo *vinfo, int numverts, int tj = -1, ushort envmap = EMID_NONE, int grassy = 0, bool alpha = false, int layer = LAYER_TOP) +static void addcubeverts(VSlot &vslot, int orient, int size, vec *pos, int convex, ushort texture, vertinfo *vinfo, int numverts, int tj = -1, ushort envmap = EMID_NONE, int grassy = 0, bool alpha = false, int layer = LAYER_TOP) { vec4 sgen, tgen; calctexgen(vslot, orient, sgen, tgen); @@ -977,10 +977,10 @@ struct cubeedge uchar index, flags; }; -vector cubeedges; -hashtable edgegroups(1<<13); +static vector cubeedges; +static hashtable edgegroups(1<<13); -void gencubeedges(cube &c, const ivec &co, int size) +static void gencubeedges(cube &c, const ivec &co, int size) { ivec pos[MAXFACEVERTS]; int vis; @@ -1081,7 +1081,7 @@ void gencubeedges(cube &c, const ivec &co, int size) } } -void gencubeedges(cube *c = worldroot, const ivec &co = ivec(0, 0, 0), int size = worldsize>>1) +static void gencubeedges(cube *c = worldroot, const ivec &co = ivec(0, 0, 0), int size = worldsize>>1) { progress("fixing t-joints..."); neighbourstack[++neighbourdepth] = c; @@ -1095,7 +1095,7 @@ void gencubeedges(cube *c = worldroot, const ivec &co = ivec(0, 0, 0), int size --neighbourdepth; } -void gencubeverts(cube &c, const ivec &co, int size, int csi) +static void gencubeverts(cube &c, const ivec &co, int size, int csi) { if(!(c.visible&0xC0)) return; @@ -1155,7 +1155,7 @@ int allocva = 0; int wtris = 0, wverts = 0, vtris = 0, vverts = 0, glde = 0, gbatches = 0; vector valist, varoot; -vtxarray *newva(const ivec &o, int size) +static vtxarray *newva(const ivec &o, int size) { vtxarray *va = new vtxarray; va->parent = NULL; @@ -1310,7 +1310,7 @@ struct mergedface static int vahasmerges = 0, vamergemax = 0; static vector vamerges[MAXMERGELEVEL+1]; -int genmergedfaces(cube &c, const ivec &co, int size, int minlevel = -1) +static int genmergedfaces(cube &c, const ivec &co, int size, int minlevel = -1) { if(!c.ext || isempty(c)) return -1; int tj = c.ext->tjoints, maxlevel = -1; @@ -1364,7 +1364,7 @@ int genmergedfaces(cube &c, const ivec &co, int size, int minlevel = -1) return maxlevel; } -int findmergedfaces(cube &c, const ivec &co, int size, int csi, int minlevel) +static int findmergedfaces(cube &c, const ivec &co, int size, int csi, int minlevel) { if(c.ext && c.ext->va && !(c.ext->va->hasmerges&MERGE_ORIGIN)) return c.ext->va->mergelevel; else if(c.children) @@ -1382,7 +1382,7 @@ int findmergedfaces(cube &c, const ivec &co, int size, int csi, int minlevel) else return -1; } -void addmergedverts(int level, const ivec &o) +static void addmergedverts(int level, const ivec &o) { vector &mfl = vamerges[level]; if(mfl.empty()) return; @@ -1414,7 +1414,7 @@ static inline void finddecals(vtxarray *va) } } -void rendercube(cube &c, const ivec &co, int size, int csi, int &maxlevel) // creates vertices and indices ready to be put into a va +static void rendercube(cube &c, const ivec &co, int size, int csi, int &maxlevel) // creates vertices and indices ready to be put into a va { //if(size<=16) return; if(c.ext && c.ext->va) @@ -1473,7 +1473,7 @@ void rendercube(cube &c, const ivec &co, int size, int csi, int &maxlevel) // cr if(csi <= MAXMERGELEVEL && vamerges[csi].length()) addmergedverts(csi, co); } -void calcgeombb(const ivec &co, int size, ivec &bbmin, ivec &bbmax) +static void calcgeombb(const ivec &co, int size, ivec &bbmin, ivec &bbmax) { vec vmin(co), vmax = vmin; vmin.add(size); @@ -1492,7 +1492,7 @@ void calcgeombb(const ivec &co, int size, ivec &bbmin, ivec &bbmax) static int entdepth = -1; static octaentities *entstack[32]; -void setva(cube &c, const ivec &co, int size, int csi) +static void setva(cube &c, const ivec &co, int size, int csi) { ASSERT(size <= 0x1000); @@ -1558,7 +1558,7 @@ VARF(vafacemax, 64, 384, 256*256, allchanged()); VARF(vafacemin, 0, 96, 256*256, allchanged()); VARF(vacubesize, 32, 128, 0x1000, allchanged()); -int updateva(cube *c, const ivec &co, int size, int csi) +static int updateva(cube *c, const ivec &co, int size, int csi) { progress("recalculating geometry..."); int ccount = 0, cmergemax = vamergemax, chasmerges = vahasmerges; @@ -1619,7 +1619,7 @@ int updateva(cube *c, const ivec &co, int size, int csi) return ccount; } -void addtjoint(const edgegroup &g, const cubeedge &e, int offset) +static void addtjoint(const edgegroup &g, const cubeedge &e, int offset) { int vcoord = (g.slope[g.axis]*offset + g.origin[g.axis]) & 0x7FFF; tjoint &tj = tjoints.add(); @@ -1640,7 +1640,7 @@ void addtjoint(const edgegroup &g, const cubeedge &e, int offset) else tjoints[prev].next = tjoints.length()-1; } -void findtjoints(int cur, const edgegroup &g) +static void findtjoints(int cur, const edgegroup &g) { int active = -1; while(cur >= 0) @@ -1713,7 +1713,7 @@ void octarender() // creates va s for all leaf cub visibleva = NULL; } -void precachetextures() +static void precachetextures() { vector texs; loopv(valist) @@ -1767,7 +1767,7 @@ void allchanged(bool load) } } -void recalc() +static void recalc() { allchanged(true); } diff --git a/src/engine/octarender.hh b/src/engine/octarender.hh index 046a071..a496aed 100644 --- a/src/engine/octarender.hh +++ b/src/engine/octarender.hh @@ -6,6 +6,9 @@ #include "octa.hh" +extern int wtris, wverts, vtris, vverts, glde, gbatches; +extern int allocva; + extern ivec worldmin, worldmax, nogimin, nogimax; extern vector tjoints; extern vector varoot, valist; diff --git a/src/engine/rendermodel.cc b/src/engine/rendermodel.cc index 6410907..8cec77f 100644 --- a/src/engine/rendermodel.cc +++ b/src/engine/rendermodel.cc @@ -4,6 +4,7 @@ #include "command.hh" // identflags #include "console.hh" /* conoutf */ #include "main.hh" // loadprogress, renderprogress +#include "octarender.hh" #include "pvs.hh" #include "rendergl.hh" #include "renderva.hh" diff --git a/src/engine/renderparticles.cc b/src/engine/renderparticles.cc index e666dcc..31fc1db 100644 --- a/src/engine/renderparticles.cc +++ b/src/engine/renderparticles.cc @@ -4,6 +4,7 @@ #include "main.hh" // initing, minimized, loadprogress #include "renderparticles.hh" #include "octaedit.hh" // editmode +#include "octarender.hh" #include "pvs.hh" #include "rendergl.hh" #include "rendertext.hh" diff --git a/src/engine/rendersky.cc b/src/engine/rendersky.cc index 880a4dd..5710720 100644 --- a/src/engine/rendersky.cc +++ b/src/engine/rendersky.cc @@ -1,5 +1,6 @@ #include "console.hh" /* conoutf */ #include "octaedit.hh" // editmode +#include "octarender.hh" #include "rendergl.hh" #include "renderlights.hh" #include "renderva.hh"