diff --git a/include/r_local.h b/include/r_local.h index f762452d4..dab2e26de 100644 --- a/include/r_local.h +++ b/include/r_local.h @@ -302,8 +302,6 @@ extern qboolean r_dowarpold, r_viewchanged; extern mleaf_t *r_viewleaf, *r_oldviewleaf; -extern vec3_t r_emins, r_emaxs; -extern mnode_t *r_pefragtopnode; extern int r_clipflags; extern int r_dlightframecount; extern qboolean r_fov_greater_than_90; @@ -325,7 +323,6 @@ void R_SetupFrame (void); void R_cshift_f (void); void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1); void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip); -void R_SplitEntityOnNode2 (mnode_t *node); void R_RecursiveMarkLights (const vec3_t lightorigin, struct dlight_s *light, int bit, mnode_t *node); void R_MarkLights (const vec3_t lightorigin, struct dlight_s *light, int bit, diff --git a/libs/video/renderer/r_efrag.c b/libs/video/renderer/r_efrag.c index 763ebe86c..bc583c82f 100644 --- a/libs/video/renderer/r_efrag.c +++ b/libs/video/renderer/r_efrag.c @@ -38,8 +38,8 @@ static __attribute__ ((used)) const char rcsid[] = #include "r_local.h" -mnode_t *r_pefragtopnode; -vec3_t r_emins, r_emaxs; +static mnode_t *r_pefragtopnode; +static vec3_t r_emins, r_emaxs; typedef struct s_efrag_list { struct s_efrag_list *next; @@ -189,43 +189,10 @@ R_SplitEntityOnNode (mnode_t *node) } } -void -R_SplitEntityOnNode2 (mnode_t *node) -{ - mplane_t *splitplane; - int sides; - - if (node->visframe != r_visframecount) - return; - - if (node->contents < 0) { - if (node->contents != CONTENTS_SOLID) - r_pefragtopnode = node; // we've reached a non-solid leaf, so - // it's visible and not BSP clipped - return; - } - - splitplane = node->plane; - sides = BOX_ON_PLANE_SIDE (r_emins, r_emaxs, splitplane); - - if (sides == 3) { - // remember first splitter - r_pefragtopnode = node; - return; - } - - // not split yet; recurse down the contacted side - if (sides & 1) - R_SplitEntityOnNode2 (node->children[0]); - else - R_SplitEntityOnNode2 (node->children[1]); -} - void R_AddEfrags (entity_t *ent) { model_t *entmodel; - int i; if (!ent->model) return; @@ -240,10 +207,8 @@ R_AddEfrags (entity_t *ent) entmodel = ent->model; - for (i = 0; i < 3; i++) { - r_emins[i] = ent->origin[i] + entmodel->mins[i]; - r_emaxs[i] = ent->origin[i] + entmodel->maxs[i]; - } + VectorAdd (ent->origin, entmodel->mins, r_emins); + VectorAdd (ent->origin, entmodel->maxs, r_emaxs); R_SplitEntityOnNode (r_worldentity.model->nodes); diff --git a/libs/video/renderer/sw/sw_rmain.c b/libs/video/renderer/sw/sw_rmain.c index 33d001a17..ed4e52a03 100644 --- a/libs/video/renderer/sw/sw_rmain.c +++ b/libs/video/renderer/sw/sw_rmain.c @@ -658,19 +658,10 @@ R_DrawBEntitiesOnList (void) if (r_drawpolys | r_drawculledpolys) { R_ZDrawSubmodelPolys (clmodel); } else { - r_pefragtopnode = NULL; + if (currententity->topnode) { + mnode_t *topnode = currententity->topnode; - for (j = 0; j < 3; j++) { - r_emins[j] = minmaxs[j]; - r_emaxs[j] = minmaxs[3 + j]; - } - - R_SplitEntityOnNode2 (r_worldentity.model->nodes); - - if (r_pefragtopnode) { - currententity->topnode = r_pefragtopnode; - - if (r_pefragtopnode->contents >= 0) { + if (topnode->contents >= 0) { // not a leaf; has to be clipped to the world // BSP r_clipflags = clipflags; @@ -682,7 +673,6 @@ R_DrawBEntitiesOnList (void) R_DrawSubmodelPolygons (clmodel, clipflags); } - currententity->topnode = NULL; } } diff --git a/libs/video/renderer/sw32/sw32_rmain.c b/libs/video/renderer/sw32/sw32_rmain.c index 96230e655..3f27c92ae 100644 --- a/libs/video/renderer/sw32/sw32_rmain.c +++ b/libs/video/renderer/sw32/sw32_rmain.c @@ -677,19 +677,10 @@ R_DrawBEntitiesOnList (void) if (r_drawpolys | r_drawculledpolys) { R_ZDrawSubmodelPolys (clmodel); } else { - r_pefragtopnode = NULL; + if (currententity->topnode) { + mnode_t *topnode = currententity->topnode; - for (j = 0; j < 3; j++) { - r_emins[j] = minmaxs[j]; - r_emaxs[j] = minmaxs[3 + j]; - } - - R_SplitEntityOnNode2 (r_worldentity.model->nodes); - - if (r_pefragtopnode) { - currententity->topnode = r_pefragtopnode; - - if (r_pefragtopnode->contents >= 0) { + if (topnode->contents >= 0) { // not a leaf; has to be clipped to the world // BSP r_clipflags = clipflags; @@ -700,8 +691,6 @@ R_DrawBEntitiesOnList (void) // sorting handle drawing order R_DrawSubmodelPolygons (clmodel, clipflags); } - - currententity->topnode = NULL; } }