soft: make r_worldentity local

This commit is contained in:
Denis Pauk 2021-09-19 21:37:30 +03:00
parent 083cfca305
commit f3f8c9a1f6
5 changed files with 19 additions and 25 deletions

View file

@ -443,7 +443,7 @@ extern int *pfrustum_indexes[4];
//=============================================================================
void R_RenderWorld(void);
void R_RenderWorld(entity_t *currententity);
//=============================================================================
@ -451,7 +451,6 @@ extern cplane_t screenedge[4];
extern vec3_t r_origin;
extern entity_t r_worldentity;
extern vec3_t modelorg;
extern vec3_t r_entorigin;
@ -477,7 +476,7 @@ void R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *
void R_AliasDrawModel(entity_t *currententity, const model_t *currentmodel);
void R_BeginEdgeFrame(void);
void R_ScanEdges(surf_t *surface);
void R_ScanEdges(entity_t *currententity, surf_t *surface);
void R_PushDlights(const model_t *model);
void R_RotateBmodel(const entity_t *currententity);

View file

@ -587,7 +587,7 @@ R_RecursiveWorldNode (entity_t *currententity, const model_t *currentmodel, mnod
{
msurface_t *surf;
surf = r_worldmodel->surfaces + node->firstsurface;
surf = currentmodel->surfaces + node->firstsurface;
if (dot < -BACKFACE_EPSILON)
{
@ -631,7 +631,7 @@ R_RenderWorld
================
*/
void
R_RenderWorld (void)
R_RenderWorld (entity_t *currententity)
{
const model_t *currentmodel = r_worldmodel;
@ -643,10 +643,10 @@ R_RenderWorld (void)
c_drawnode=0;
// auto cycle the world frame for texture animation
r_worldentity.frame = (int)(r_newrefdef.time*2);
currententity->frame = (int)(r_newrefdef.time*2);
VectorCopy (r_origin, modelorg);
r_pcurrentvertbase = currentmodel->vertexes;
R_RecursiveWorldNode (&r_worldentity, currentmodel, currentmodel->nodes, ALIAS_XY_CLIP_MASK, false);
R_RecursiveWorldNode (currententity, currentmodel, currentmodel->nodes, ALIAS_XY_CLIP_MASK, false);
}

View file

@ -581,7 +581,7 @@ R_GenerateSpansBackward (void)
R_CleanupSpan ();
}
static void D_DrawSurfaces (surf_t *surface);
static void D_DrawSurfaces (entity_t *currententity, surf_t *surface);
/*
==============
@ -597,7 +597,7 @@ Each surface has a linked list of its visible spans
==============
*/
void
R_ScanEdges (surf_t *surface)
R_ScanEdges (entity_t *currententity, surf_t *surface)
{
shift20_t iv, bottom;
surf_t *s;
@ -672,7 +672,7 @@ R_ScanEdges (surf_t *surface)
if (span_p + r_refdef.vrect.width >= max_span_p)
{
// Draw stuff on screen
D_DrawSurfaces (surface);
D_DrawSurfaces (currententity, surface);
// clear the surface span pointers
for (s = &surfaces[1] ; s<surface ; s++)
@ -707,7 +707,7 @@ R_ScanEdges (surf_t *surface)
(*pdrawfunc) ();
// draw whatever's left in the span list
D_DrawSurfaces (surface);
D_DrawSurfaces (currententity, surface);
}
@ -935,10 +935,8 @@ Normal surface cached, texture mapped surface
==============
*/
static void
D_SolidSurf (surf_t *s)
D_SolidSurf (entity_t *currententity, surf_t *s)
{
entity_t *currententity;
if (s->insubmodel)
{
vec3_t local_modelorg;
@ -952,8 +950,6 @@ D_SolidSurf (surf_t *s)
R_RotateBmodel(currententity); // FIXME: don't mess with the frustum,
// make entity passed in
}
else
currententity = &r_worldentity;
pface = s->msurf;
miplevel = D_MipLevelForScale(s->nearzi * scale_for_mip * pface->texinfo->mipadjust);
@ -1022,7 +1018,7 @@ May be called more than once a frame if the surf list overflows (higher res)
==============
*/
static void
D_DrawSurfaces (surf_t *surface)
D_DrawSurfaces (entity_t *currententity, surf_t *surface)
{
VectorSubtract (r_origin, vec3_origin, modelorg);
TransformVector (modelorg, transformed_modelorg);
@ -1040,7 +1036,7 @@ D_DrawSurfaces (surf_t *surface)
r_drawnpolycount++;
if (! (s->flags & (SURF_DRAWSKYBOX|SURF_DRAWBACKGROUND|SURF_DRAWTURB) ) )
D_SolidSurf (s);
D_SolidSurf (currententity, s);
else if (s->flags & SURF_DRAWSKYBOX)
D_SkySurf (s);
else if (s->flags & SURF_DRAWBACKGROUND)

View file

@ -53,8 +53,6 @@ refimport_t ri;
static unsigned d_8to24table[256];
entity_t r_worldentity;
char skyname[MAX_QPATH];
vec3_t skyaxis;
@ -1163,7 +1161,7 @@ Render the map
================
*/
static void
R_EdgeDrawing (void)
R_EdgeDrawing (entity_t *currententity)
{
if ( r_newrefdef.rdflags & RDF_NOWORLDMODEL )
return;
@ -1181,7 +1179,7 @@ R_EdgeDrawing (void)
// Build the Global Edget Table
// Also populate the surface stack and count # surfaces to render (surf_max is the max)
R_RenderWorld ();
R_RenderWorld (currententity);
if (r_dspeeds->value)
{
@ -1199,7 +1197,7 @@ R_EdgeDrawing (void)
// Use the Global Edge Table to maintin the Active Edge Table: Draw the world as scanlines
// Write the Z-Buffer (but no read)
R_ScanEdges (surface_p);
R_ScanEdges (currententity, surface_p);
}
//=======================================================================
@ -1300,6 +1298,7 @@ static void
RE_RenderFrame (refdef_t *fd)
{
r_newrefdef = *fd;
entity_t r_worldentity;
if (!r_worldmodel && !( r_newrefdef.rdflags & RDF_NOWORLDMODEL ) )
{
@ -1342,7 +1341,7 @@ RE_RenderFrame (refdef_t *fd)
// Build the Global Edge Table and render it via the Active Edge Table
// Render the map
R_EdgeDrawing ();
R_EdgeDrawing (&r_worldentity);
if (r_dspeeds->value)
{

View file

@ -230,7 +230,7 @@ Mod_PointInLeaf
===============
*/
mleaf_t *
Mod_PointInLeaf (vec3_t p, model_t *model)
Mod_PointInLeaf (vec3_t p, const model_t *model)
{
mnode_t *node;