diff --git a/src/engine/aa.cc b/src/engine/aa.cc index 27099be..62efa4f 100644 --- a/src/engine/aa.cc +++ b/src/engine/aa.cc @@ -1,5 +1,6 @@ #include "aa.hh" #include "rendergl.hh" +#include "renderlights.hh" #include "texture.hh" #include "engine.hh" diff --git a/src/engine/engine.hh b/src/engine/engine.hh index 5d58f0a..f39e78a 100644 --- a/src/engine/engine.hh +++ b/src/engine/engine.hh @@ -37,45 +37,6 @@ extern void compactmruvslots(); // renderlights -#include "renderlights.hh" - -extern int lighttilealignw, lighttilealignh, lighttilevieww, lighttileviewh, lighttilew, lighttileh; - -extern int vieww, viewh; /* rendergl */ - -template -static inline void calctilebounds(float sx1, float sy1, float sx2, float sy2, T &bx1, T &by1, T &bx2, T &by2) -{ - int tx1 = max(int(floor(((sx1 + 1)*0.5f*vieww)/lighttilealignw)), 0), - ty1 = max(int(floor(((sy1 + 1)*0.5f*viewh)/lighttilealignh)), 0), - tx2 = min(int(ceil(((sx2 + 1)*0.5f*vieww)/lighttilealignw)), lighttilevieww), - ty2 = min(int(ceil(((sy2 + 1)*0.5f*viewh)/lighttilealignh)), lighttileviewh); - bx1 = T((tx1 * lighttilew) / lighttilevieww); - by1 = T((ty1 * lighttileh) / lighttileviewh); - bx2 = T((tx2 * lighttilew + lighttilevieww - 1) / lighttilevieww); - by2 = T((ty2 * lighttileh + lighttileviewh - 1) / lighttileviewh); -} - -static inline void masktiles(uint *tiles, float sx1, float sy1, float sx2, float sy2) -{ - int tx1, ty1, tx2, ty2; - calctilebounds(sx1, sy1, sx2, sy2, tx1, ty1, tx2, ty2); - for(int ty = ty1; ty < ty2; ty++) tiles[ty] |= ((1<<(tx2-tx1))-1)< mapmodels; -extern float transmdlsx1, transmdlsy1, transmdlsx2, transmdlsy2; -extern uint transmdltiles[LIGHTTILE_MAXH]; - extern void loadskin(const char *dir, const char *altdir, Texture *&skin, Texture *&masks); extern void resetmodelbatches(); extern void startmodelquery(occludequery *query); diff --git a/src/engine/light.cc b/src/engine/light.cc index dcc9a24..4565bf2 100644 --- a/src/engine/light.cc +++ b/src/engine/light.cc @@ -1,5 +1,6 @@ #include "blend.hh" #include "octa.hh" +#include "renderlights.hh" #include "texture.hh" #include "engine.hh" diff --git a/src/engine/material.cc b/src/engine/material.cc index ebc96de..56ed5a7 100644 --- a/src/engine/material.cc +++ b/src/engine/material.cc @@ -1,5 +1,6 @@ #include "material.hh" #include "rendergl.hh" +#include "renderlights.hh" #include "renderva.hh" #include "texture.hh" #include "water.hh" diff --git a/src/engine/octaedit.cc b/src/engine/octaedit.cc index 8ee7480..1394f2a 100644 --- a/src/engine/octaedit.cc +++ b/src/engine/octaedit.cc @@ -3,6 +3,7 @@ #include "octa.hh" #include "pvs.hh" #include "rendergl.hh" +#include "renderlights.hh" #include "renderva.hh" #include "texture.hh" #include "world.hh" diff --git a/src/engine/octarender.cc b/src/engine/octarender.cc index 70d0f38..c552641 100644 --- a/src/engine/octarender.cc +++ b/src/engine/octarender.cc @@ -4,6 +4,7 @@ #include "grass.hh" #include "material.hh" #include "rendergl.hh" +#include "renderlights.hh" #include "renderparticles.hh" #include "rendersky.hh" #include "renderva.hh" diff --git a/src/engine/rendergl.cc b/src/engine/rendergl.cc index 2dd9a62..d6e0cc1 100644 --- a/src/engine/rendergl.cc +++ b/src/engine/rendergl.cc @@ -6,6 +6,7 @@ #include "material.hh" #include "pvs.hh" #include "rendergl.hh" +#include "renderlights.hh" #include "renderparticles.hh" #include "rendersky.hh" #include "rendertext.hh" diff --git a/src/engine/renderlights.cc b/src/engine/renderlights.cc index 5f76d94..3c30502 100644 --- a/src/engine/renderlights.cc +++ b/src/engine/renderlights.cc @@ -4,6 +4,7 @@ #include "material.hh" #include "pvs.hh" #include "rendergl.hh" +#include "rendermodel.hh" #include "renderparticles.hh" #include "rendersky.hh" #include "renderva.hh" diff --git a/src/engine/renderlights.hh b/src/engine/renderlights.hh index 6baaa38..23cea9c 100644 --- a/src/engine/renderlights.hh +++ b/src/engine/renderlights.hh @@ -1,9 +1,62 @@ #ifndef ENGINE_RENDERLIGHTS_HH #define ENGINE_RENDERLIGHTS_HH +#include +#include + #define LIGHTTILE_MAXW 16 #define LIGHTTILE_MAXH 16 enum { L_NOSHADOW = 1<<0, L_NODYNSHADOW = 1<<1, L_VOLUMETRIC = 1<<2, L_NOSPEC = 1<<3 }; +/* only for the inlines below */ +extern int lighttilealignw, lighttilealignh, lighttilevieww, lighttileviewh, lighttilew, lighttileh; +extern int vieww, viewh; /* rendergl */ + +template +static inline void calctilebounds(float sx1, float sy1, float sx2, float sy2, T &bx1, T &by1, T &bx2, T &by2) +{ + int tx1 = max(int(floor(((sx1 + 1)*0.5f*vieww)/lighttilealignw)), 0), + ty1 = max(int(floor(((sy1 + 1)*0.5f*viewh)/lighttilealignh)), 0), + tx2 = min(int(ceil(((sx2 + 1)*0.5f*vieww)/lighttilealignw)), lighttilevieww), + ty2 = min(int(ceil(((sy2 + 1)*0.5f*viewh)/lighttilealignh)), lighttileviewh); + bx1 = T((tx1 * lighttilew) / lighttilevieww); + by1 = T((ty1 * lighttileh) / lighttileviewh); + bx2 = T((tx2 * lighttilew + lighttilevieww - 1) / lighttilevieww); + by2 = T((ty2 * lighttileh + lighttileviewh - 1) / lighttileviewh); +} + +static inline void masktiles(uint *tiles, float sx1, float sy1, float sx2, float sy2) +{ + int tx1, ty1, tx2, ty2; + calctilebounds(sx1, sy1, sx2, sy2, tx1, ty1, tx2, ty2); + for(int ty = ty1; ty < ty2; ty++) tiles[ty] |= ((1<<(tx2-tx1))-1)<