some micro-optimisations

This commit is contained in:
Bill Currie 2004-02-23 07:17:41 +00:00
parent 680c246e22
commit f9b95cee92
3 changed files with 6 additions and 13 deletions

View file

@ -190,9 +190,6 @@ typedef struct mleaf_s
struct mnode_s *parent; struct mnode_s *parent;
// leaf specific // leaf specific
int dlightbits;
int dlightframe;
byte *compressed_vis; byte *compressed_vis;
efrag_t *efrags; efrag_t *efrags;

View file

@ -81,7 +81,7 @@ Mod_PointInLeaf (const vec3_t p, model_t *model)
return NULL; // never reached return NULL; // never reached
} }
static byte * static inline byte *
Mod_DecompressVis (byte * in, model_t *model) Mod_DecompressVis (byte * in, model_t *model)
{ {
static byte decompressed[MAX_MAP_LEAFS / 8]; static byte decompressed[MAX_MAP_LEAFS / 8];
@ -116,7 +116,7 @@ Mod_DecompressVis (byte * in, model_t *model)
return decompressed; return decompressed;
} }
byte * byte *
Mod_LeafPVS (mleaf_t *leaf, model_t *model) Mod_LeafPVS (mleaf_t *leaf, model_t *model)
{ {
if (leaf == model->leafs) if (leaf == model->leafs)

View file

@ -236,15 +236,16 @@ R_MarkLights (const vec3_t lightorigin, dlight_t *light, int bit,
maxs[1] = lightorigin[1] + radius; maxs[1] = lightorigin[1] + radius;
maxs[2] = lightorigin[2] + radius; maxs[2] = lightorigin[2] + radius;
while (leafnum < model->numleafs) { while (leafnum < model->numleafs) {
int i; int b;
if (!(vis_bits = *in++)) { if (!(vis_bits = *in++)) {
leafnum += (*in++) * 8; leafnum += (*in++) * 8;
continue; continue;
} }
for (i = 0; i < 8 && leafnum < model->numleafs; i++, leafnum++) { for (b = 1; b < 256 && leafnum < model->numleafs;
b <<= 1, leafnum++) {
int m; int m;
mleaf_t *leaf = &model->leafs[leafnum + 1]; mleaf_t *leaf = &model->leafs[leafnum + 1];
if (!(vis_bits & (1 << i))) if (!(vis_bits & b))
continue; continue;
if (leaf->visframe != r_visframecount) if (leaf->visframe != r_visframecount)
continue; continue;
@ -254,11 +255,6 @@ R_MarkLights (const vec3_t lightorigin, dlight_t *light, int bit,
continue; continue;
if (R_CullBox (leaf->mins, leaf->maxs)) if (R_CullBox (leaf->mins, leaf->maxs))
continue; continue;
if (leaf->dlightframe != r_framecount) {
leaf->dlightbits = 0;
leaf->dlightframe = r_framecount;
}
leaf->dlightbits |= bit;
for (m = 0; m < leaf->nummarksurfaces; m++) { for (m = 0; m < leaf->nummarksurfaces; m++) {
msurface_t *surf = leaf->firstmarksurface[m]; msurface_t *surf = leaf->firstmarksurface[m];
if (surf->visframe != r_visframecount) if (surf->visframe != r_visframecount)