#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)<