return false;
}
+int R_BoxVisible(const vec3_t mins, const vec3_t maxs)
+{
+ int side, nodestackindex = 0;
+ mnode_t *node, *nodestack[1024];
+ if (R_CullBox(mins, maxs))
+ return false;
+ if (!r_refdef.worldmodel || !r_refdef.worldmodel->brush.data_nodes)
+ return true;
+ node = r_refdef.worldmodel->brush.data_nodes;
+ for (;;)
+ {
+ if (node->plane)
+ {
+ // node - recurse down the BSP tree
+ side = BoxOnPlaneSide(mins, maxs, node->plane) - 1;
+ if (side < 2)
+ {
+ // box is on one side of plane, take that path
+ node = node->children[side];
+ }
+ else
+ {
+ // box crosses plane, take one path and remember the other
+ if (nodestackindex < 1024)
+ nodestack[nodestackindex++] = node->children[0];
+ node = node->children[1];
+ }
+ }
+ else
+ {
+ // leaf - check leaf visibility
+ if (r_worldleafvisible[(mleaf_t *)node - r_refdef.worldmodel->brush.data_leafs])
+ {
+ // it is visible, return immediately with the news
+ return true;
+ }
+ else
+ {
+ // nothing to see here, try another path we didn't take earlier
+ if (nodestackindex == 0)
+ break;
+ node = nodestack[--nodestackindex];
+ }
+ }
+ }
+ // it is not visible
+ return false;
+}
+
+
//==================================================================================
static void R_MarkEntities (void)
{
- int i;
+ int i, renderimask;
entity_render_t *ent;
if (!r_drawentities.integer)
return;
+ renderimask = envmap ? (RENDER_EXTERIORMODEL | RENDER_VIEWMODEL) : (chase_active.integer ? 0 : RENDER_EXTERIORMODEL);
for (i = 0;i < r_refdef.numentities;i++)
{
ent = r_refdef.entities[i];
Matrix4x4_OriginFromMatrix(&ent->matrix, ent->origin);
// some of the renderer still relies on scale...
ent->scale = Matrix4x4_ScaleFromMatrix(&ent->matrix);
- R_UpdateEntLights(ent);
- if ((chase_active.integer || !(ent->flags & RENDER_EXTERIORMODEL))
- && (!VIS_CullBox(ent->mins, ent->maxs) || (ent->effects & EF_NODEPTHTEST))
- && (!envmap || !(ent->flags & (RENDER_VIEWMODEL | RENDER_EXTERIORMODEL))))
+ if (!(ent->flags & renderimask) && ((ent->effects & EF_NODEPTHTEST) ? R_CullBox(ent->mins, ent->maxs) : R_BoxVisible(ent->mins, ent->maxs)))
+ {
+ R_UpdateEntLights(ent);
ent->visframe = r_framecount;
+ }
}
}
#define gl_alpha_format 4
int R_CullBox(const vec3_t mins, const vec3_t maxs);
-#define VIS_CullBox(mins,maxs) (R_CullBox((mins), (maxs)) || (r_refdef.worldmodel && r_refdef.worldmodel->brush.BoxTouchingPVS && !r_refdef.worldmodel->brush.BoxTouchingPVS(r_refdef.worldmodel, r_pvsbits, (mins), (maxs))))
+int R_BoxVisible(const vec3_t mins, const vec3_t maxs);
extern qboolean fogenabled;
extern vec3_t fogcolor;