Browse Source

Added support for leaf-based frustum culling, but leaving it disabled for now.

unrollquadloop
Nico de Poel 3 years ago
parent
commit
b0893a902d
  1. 4
      ps1bsp.h
  2. BIN
      test.ps1bsp
  3. 5
      world.c

4
ps1bsp.h

@ -135,7 +135,6 @@ typedef struct
int planeId;
short children[2];
// TODO: add bounding box for frustum culling (or bounding sphere, might be cheaper)
SVECTOR boundingSphere;
} ps1bsp_node_t;
@ -144,8 +143,7 @@ typedef struct
int type;
int vislist;
// TODO: add bounding box for frustum culling (or do we? could save half the number of bounds checks if we only check nodes)
//SVECTOR center;
SVECTOR boundingSphere;
u_short firstLeafFace;
u_short numLeafFaces;

BIN
test.ps1bsp

5
world.c

@ -193,8 +193,11 @@ static void world_drawnode(const world_t *world, short nodeIdx, u_char *pvs)
if ((pvs[test >> 3] & (1 << (test & 0x7))) == 0)
return;
u_long frameNum = time_getFrameNumber();
const ps1bsp_leaf_t *leaf = &world->leaves[~nodeIdx];
// if (!frustum_sphereInside(&leaf->boundingSphere)) // TODO: not sure if it's actually faster to do all these additional frustum checks
// return;
u_long frameNum = time_getFrameNumber();
const u_short *leafFace = &world->leafFaces[leaf->firstLeafFace];
for (u_short leafFaceIdx = 0; leafFaceIdx < leaf->numLeafFaces; ++leafFaceIdx, ++leafFace)

Loading…
Cancel
Save