diff --git a/src/client/refresh/soft/header/local.h b/src/client/refresh/soft/header/local.h index 573c1f9c..f46a5d96 100644 --- a/src/client/refresh/soft/header/local.h +++ b/src/client/refresh/soft/header/local.h @@ -446,7 +446,6 @@ extern mplane_t screenedge[4]; extern vec3_t r_origin; extern entity_t r_worldentity; -extern model_t *currentmodel; extern vec3_t modelorg; extern vec3_t r_entorigin; @@ -463,20 +462,19 @@ extern qboolean insubmodel; void R_DrawAlphaSurfaces(const entity_t *currententity); -void R_DrawSprite(entity_t *currententity); +void R_DrawSprite(entity_t *currententity, const model_t *currentmodel); -void R_RenderFace(entity_t *currententity, msurface_t *fa, int clipflags); +void R_RenderFace(entity_t *currententity, const model_t *currentmodel, msurface_t *fa, int clipflags); void R_RenderBmodelFace(entity_t *currententity, bedge_t *pedges, msurface_t *psurf); void R_TransformFrustum(void); -void R_DrawSubmodelPolygons(entity_t *currententity, const model_t *pmodel, int clipflags, mnode_t *topnode); -void R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *pmodel, mnode_t *topnode); +void R_DrawSubmodelPolygons(entity_t *currententity, const model_t *currentmodel, int clipflags, mnode_t *topnode); +void R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *currentmodel, mnode_t *topnode); -void R_AliasDrawModel(entity_t *currententity); +void R_AliasDrawModel(entity_t *currententity, const model_t *currentmodel); void R_BeginEdgeFrame(void); void R_ScanEdges(surf_t *surface); void R_PushDlights(const model_t *model); - void R_RotateBmodel(const entity_t *currententity); extern int c_faceclip; diff --git a/src/client/refresh/soft/sw_alias.c b/src/client/refresh/soft/sw_alias.c index 8b95a39d..590e5781 100644 --- a/src/client/refresh/soft/sw_alias.c +++ b/src/client/refresh/soft/sw_alias.c @@ -482,7 +482,7 @@ R_AliasSetupSkin =============== */ static qboolean -R_AliasSetupSkin(const entity_t *currententity) +R_AliasSetupSkin(const entity_t *currententity, const model_t *currentmodel) { image_t *pskindesc; @@ -616,7 +616,7 @@ R_AliasSetupFrames ================= */ static void -R_AliasSetupFrames(const entity_t *currententity, dmdl_t *pmdl) +R_AliasSetupFrames(const entity_t *currententity, const model_t *currentmodel, dmdl_t *pmdl) { int thisframe = currententity->frame; int lastframe = currententity->oldframe; @@ -701,7 +701,7 @@ R_AliasDrawModel ================ */ void -R_AliasDrawModel(entity_t *currententity) +R_AliasDrawModel(entity_t *currententity, const model_t *currentmodel) { s_pmdl = (dmdl_t *)currentmodel->extradata; @@ -730,7 +730,7 @@ R_AliasDrawModel(entity_t *currententity) ** we have to set our frame pointers and transformations before ** doing any real work */ - R_AliasSetupFrames(currententity, s_pmdl); + R_AliasSetupFrames(currententity, currentmodel, s_pmdl); R_AliasSetUpTransform(currententity); // see if the bounding box lets us trivially reject, also sets @@ -746,7 +746,7 @@ R_AliasDrawModel(entity_t *currententity) } // set up the skin and verify it exists - if ( !R_AliasSetupSkin(currententity) ) + if ( !R_AliasSetupSkin(currententity, currentmodel) ) { R_Printf( PRINT_ALL, "R_AliasDrawModel %s: NULL skin found\n", currentmodel->name); diff --git a/src/client/refresh/soft/sw_bsp.c b/src/client/refresh/soft/sw_bsp.c index ab236de8..557e8bd5 100644 --- a/src/client/refresh/soft/sw_bsp.c +++ b/src/client/refresh/soft/sw_bsp.c @@ -338,7 +338,7 @@ Bmodel crosses multiple leafs ================ */ void -R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *pmodel, mnode_t *topnode) +R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *currentmodel, mnode_t *topnode) { int i, j, lindex; vec_t dot; @@ -348,9 +348,9 @@ R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *pmode medge_t *pedge, *pedges; // FIXME: use bounding-box-based frustum clipping info? - psurf = &pmodel->surfaces[pmodel->firstmodelsurface]; - numsurfaces = pmodel->nummodelsurfaces; - pedges = pmodel->edges; + psurf = ¤tmodel->surfaces[currentmodel->firstmodelsurface]; + numsurfaces = currentmodel->nummodelsurfaces; + pedges = currentmodel->edges; for (i=0 ; inumedges ; j++) { - lindex = pmodel->surfedges[psurf->firstedge+j]; + lindex = currentmodel->surfedges[psurf->firstedge+j]; if (lindex > 0) { @@ -417,7 +417,7 @@ All in one leaf ================ */ void -R_DrawSubmodelPolygons(entity_t *currententity, const model_t *pmodel, int clipflags, mnode_t *topnode) +R_DrawSubmodelPolygons(entity_t *currententity, const model_t *currentmodel, int clipflags, mnode_t *topnode) { int i; vec_t dot; @@ -425,8 +425,8 @@ R_DrawSubmodelPolygons(entity_t *currententity, const model_t *pmodel, int clipf int numsurfaces; // FIXME: use bounding-box-based frustum clipping info? - psurf = &pmodel->surfaces[pmodel->firstmodelsurface]; - numsurfaces = pmodel->nummodelsurfaces; + psurf = ¤tmodel->surfaces[currentmodel->firstmodelsurface]; + numsurfaces = currentmodel->nummodelsurfaces; for (i=0 ; ikey; // FIXME: use bounding-box-based frustum clipping info? - R_RenderFace(currententity, psurf, clipflags); + R_RenderFace(currententity, currentmodel, psurf, clipflags); } } } @@ -457,7 +457,7 @@ R_RecursiveWorldNode ================ */ static void -R_RecursiveWorldNode (entity_t *currententity, mnode_t *node, int clipflags) +R_RecursiveWorldNode (entity_t *currententity, const model_t *currentmodel, mnode_t *node, int clipflags) { int c; vec3_t acceptpt, rejectpt; @@ -570,7 +570,7 @@ R_RecursiveWorldNode (entity_t *currententity, mnode_t *node, int clipflags) side = 1; // recurse down the children, front side first - R_RecursiveWorldNode (currententity, node->children[side], clipflags); + R_RecursiveWorldNode (currententity, currentmodel, node->children[side], clipflags); // draw stuff c = node->numsurfaces; @@ -588,7 +588,7 @@ R_RecursiveWorldNode (entity_t *currententity, mnode_t *node, int clipflags) if ((surf->flags & SURF_PLANEBACK) && (surf->visframe == r_framecount)) { - R_RenderFace (currententity, surf, clipflags); + R_RenderFace (currententity, currentmodel, surf, clipflags); } surf++; @@ -601,7 +601,7 @@ R_RecursiveWorldNode (entity_t *currententity, mnode_t *node, int clipflags) if (!(surf->flags & SURF_PLANEBACK) && (surf->visframe == r_framecount)) { - R_RenderFace (currententity, surf, clipflags); + R_RenderFace (currententity, currentmodel, surf, clipflags); } surf++; @@ -613,7 +613,7 @@ R_RecursiveWorldNode (entity_t *currententity, mnode_t *node, int clipflags) } // recurse down the back side - R_RecursiveWorldNode (currententity, node->children[!side], clipflags); + R_RecursiveWorldNode (currententity, currentmodel, node->children[!side], clipflags); } } @@ -625,6 +625,7 @@ R_RenderWorld void R_RenderWorld (void) { + const model_t *currentmodel = r_worldmodel; if (!r_drawworld->value) return; @@ -637,8 +638,7 @@ R_RenderWorld (void) r_worldentity.frame = (int)(r_newrefdef.time*2); VectorCopy (r_origin, modelorg); - currentmodel = r_worldmodel; r_pcurrentvertbase = currentmodel->vertexes; - R_RecursiveWorldNode (&r_worldentity, currentmodel->nodes, ALIAS_XY_CLIP_MASK); + R_RecursiveWorldNode (&r_worldentity, currentmodel, currentmodel->nodes, ALIAS_XY_CLIP_MASK); } diff --git a/src/client/refresh/soft/sw_edge.c b/src/client/refresh/soft/sw_edge.c index f188e740..38cdf682 100644 --- a/src/client/refresh/soft/sw_edge.c +++ b/src/client/refresh/soft/sw_edge.c @@ -738,7 +738,6 @@ static msurface_t *pface; static surfcache_t *pcurrentcache; static vec3_t transformed_modelorg; static vec3_t world_transformed_modelorg; -static vec3_t local_modelorg; /* ============= @@ -887,6 +886,7 @@ D_TurbulentSurf(surf_t *s) if (s->insubmodel) { entity_t *currententity; + vec3_t local_modelorg; // FIXME: we don't want to do all this for every polygon! // TODO: store once at start of frame @@ -979,6 +979,8 @@ D_SolidSurf (surf_t *s) if (s->insubmodel) { + vec3_t local_modelorg; + // FIXME: we don't want to do all this for every polygon! // TODO: store once at start of frame currententity = s->entity; diff --git a/src/client/refresh/soft/sw_main.c b/src/client/refresh/soft/sw_main.c index 4e055069..184cb6bb 100644 --- a/src/client/refresh/soft/sw_main.c +++ b/src/client/refresh/soft/sw_main.c @@ -46,7 +46,6 @@ char skyname[MAX_QPATH]; vec3_t skyaxis; refdef_t r_newrefdef; -model_t *currentmodel; model_t *r_worldmodel; @@ -655,12 +654,12 @@ R_DrawEntitiesOnList (void) modelorg[0] = -r_origin[0]; modelorg[1] = -r_origin[1]; modelorg[2] = -r_origin[2]; - VectorCopy( vec3_origin, r_entorigin ); - R_DrawBeam( currententity ); + VectorCopy(vec3_origin, r_entorigin); + R_DrawBeam(currententity); } else { - currentmodel = currententity->model; + const model_t *currentmodel = currententity->model; if (!currentmodel) { R_DrawNullModel(); @@ -672,11 +671,11 @@ R_DrawEntitiesOnList (void) switch (currentmodel->type) { case mod_sprite: - R_DrawSprite(currententity); + R_DrawSprite(currententity, currentmodel); break; case mod_alias: - R_AliasDrawModel(currententity); + R_AliasDrawModel(currententity, currentmodel); break; default: @@ -705,7 +704,7 @@ R_DrawEntitiesOnList (void) } else { - currentmodel = currententity->model; + const model_t *currentmodel = currententity->model; if (!currentmodel) { R_DrawNullModel(); @@ -717,11 +716,11 @@ R_DrawEntitiesOnList (void) switch (currentmodel->type) { case mod_sprite: - R_DrawSprite(currententity); + R_DrawSprite(currententity, currentmodel); break; case mod_alias: - R_AliasDrawModel(currententity); + R_AliasDrawModel(currententity, currentmodel); break; default: @@ -909,7 +908,7 @@ R_DrawBEntitiesOnList (void) for (i=0 ; imodel; + const model_t *currentmodel = currententity->model; if (!currentmodel) continue; if (currentmodel->nummodelsurfaces == 0) diff --git a/src/client/refresh/soft/sw_poly.c b/src/client/refresh/soft/sw_poly.c index 0a3df0ad..3566ea98 100644 --- a/src/client/refresh/soft/sw_poly.c +++ b/src/client/refresh/soft/sw_poly.c @@ -1026,9 +1026,9 @@ R_ClipAndDrawPoly ( float alpha, int isturbulent, qboolean textured ) ** R_BuildPolygonFromSurface */ static void -R_BuildPolygonFromSurface(const entity_t *currententity, msurface_t *fa) +R_BuildPolygonFromSurface(const entity_t *currententity, const model_t *currentmodel, msurface_t *fa) { - int i, lnumverts; + int i, lnumverts; medge_t *pedges, *r_pedge; float *vec; vec5_t *pverts; @@ -1213,8 +1213,7 @@ void R_DrawAlphaSurfaces(const entity_t *currententity) { msurface_t *s = r_alpha_surfaces; - - currentmodel = r_worldmodel; + const model_t *currentmodel = r_worldmodel; modelorg[0] = -r_origin[0]; modelorg[1] = -r_origin[1]; @@ -1222,7 +1221,7 @@ R_DrawAlphaSurfaces(const entity_t *currententity) while ( s ) { - R_BuildPolygonFromSurface(currententity, s); + R_BuildPolygonFromSurface(currententity, currentmodel, s); //======= //PGM diff --git a/src/client/refresh/soft/sw_rast.c b/src/client/refresh/soft/sw_rast.c index ee7b8947..9cd8e36e 100644 --- a/src/client/refresh/soft/sw_rast.c +++ b/src/client/refresh/soft/sw_rast.c @@ -163,7 +163,7 @@ R_EmitSkyBox ================ */ static void -R_EmitSkyBox(entity_t *currententity) +R_EmitSkyBox(entity_t *currententity, const model_t *currentmodel) { int i, j; int oldkey; @@ -199,7 +199,7 @@ R_EmitSkyBox(entity_t *currententity) r_currentkey = 0x7ffffff0; for (i=0 ; i<6 ; i++) { - R_RenderFace(currententity, r_skyfaces + i, ALIAS_XY_CLIP_MASK); + R_RenderFace(currententity, currentmodel, r_skyfaces + i, ALIAS_XY_CLIP_MASK); } r_currentkey = oldkey; // bsp sorting order } @@ -519,7 +519,7 @@ R_RenderFace ================ */ void -R_RenderFace (entity_t *currententity, msurface_t *fa, int clipflags) +R_RenderFace (entity_t *currententity, const model_t *currentmodel, msurface_t *fa, int clipflags) { int i; unsigned mask; @@ -541,7 +541,7 @@ R_RenderFace (entity_t *currententity, msurface_t *fa, int clipflags) // environment box surfaces to be emited if ( fa->texinfo->flags & SURF_SKY ) { - R_EmitSkyBox (currententity); + R_EmitSkyBox (currententity, currentmodel); return; } diff --git a/src/client/refresh/soft/sw_sprite.c b/src/client/refresh/soft/sw_sprite.c index c68962f7..840b8ccf 100644 --- a/src/client/refresh/soft/sw_sprite.c +++ b/src/client/refresh/soft/sw_sprite.c @@ -24,7 +24,7 @@ extern polydesc_t r_polydesc; extern vec5_t r_clip_verts[2][MAXWORKINGVERTS+2]; -extern void R_ClipAndDrawPoly( float alpha, qboolean isturbulent, qboolean textured ); +extern void R_ClipAndDrawPoly(float alpha, qboolean isturbulent, qboolean textured); /* ** R_DrawSprite @@ -33,7 +33,7 @@ extern void R_ClipAndDrawPoly( float alpha, qboolean isturbulent, qboolean textu ** mapped polygon */ void -R_DrawSprite(entity_t *currententity) +R_DrawSprite(entity_t *currententity, const model_t *currentmodel) { vec5_t *pverts; vec3_t left, up, right, down;