Use local currentmodel

This commit is contained in:
Denis Pauk 2018-09-16 15:33:50 +03:00
parent 0ff5dc804d
commit c30cffd1ed
8 changed files with 48 additions and 50 deletions

View file

@ -446,7 +446,6 @@ extern mplane_t screenedge[4];
extern vec3_t r_origin; extern vec3_t r_origin;
extern entity_t r_worldentity; extern entity_t r_worldentity;
extern model_t *currentmodel;
extern vec3_t modelorg; extern vec3_t modelorg;
extern vec3_t r_entorigin; extern vec3_t r_entorigin;
@ -463,20 +462,19 @@ extern qboolean insubmodel;
void R_DrawAlphaSurfaces(const entity_t *currententity); 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_RenderBmodelFace(entity_t *currententity, bedge_t *pedges, msurface_t *psurf);
void R_TransformFrustum(void); void R_TransformFrustum(void);
void R_DrawSubmodelPolygons(entity_t *currententity, const model_t *pmodel, int clipflags, 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 *pmodel, 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_BeginEdgeFrame(void);
void R_ScanEdges(surf_t *surface); void R_ScanEdges(surf_t *surface);
void R_PushDlights(const model_t *model); void R_PushDlights(const model_t *model);
void R_RotateBmodel(const entity_t *currententity); void R_RotateBmodel(const entity_t *currententity);
extern int c_faceclip; extern int c_faceclip;

View file

@ -482,7 +482,7 @@ R_AliasSetupSkin
=============== ===============
*/ */
static qboolean static qboolean
R_AliasSetupSkin(const entity_t *currententity) R_AliasSetupSkin(const entity_t *currententity, const model_t *currentmodel)
{ {
image_t *pskindesc; image_t *pskindesc;
@ -616,7 +616,7 @@ R_AliasSetupFrames
================= =================
*/ */
static void 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 thisframe = currententity->frame;
int lastframe = currententity->oldframe; int lastframe = currententity->oldframe;
@ -701,7 +701,7 @@ R_AliasDrawModel
================ ================
*/ */
void void
R_AliasDrawModel(entity_t *currententity) R_AliasDrawModel(entity_t *currententity, const model_t *currentmodel)
{ {
s_pmdl = (dmdl_t *)currentmodel->extradata; 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 ** we have to set our frame pointers and transformations before
** doing any real work ** doing any real work
*/ */
R_AliasSetupFrames(currententity, s_pmdl); R_AliasSetupFrames(currententity, currentmodel, s_pmdl);
R_AliasSetUpTransform(currententity); R_AliasSetUpTransform(currententity);
// see if the bounding box lets us trivially reject, also sets // 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 // 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", R_Printf( PRINT_ALL, "R_AliasDrawModel %s: NULL skin found\n",
currentmodel->name); currentmodel->name);

View file

@ -338,7 +338,7 @@ Bmodel crosses multiple leafs
================ ================
*/ */
void 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; int i, j, lindex;
vec_t dot; vec_t dot;
@ -348,9 +348,9 @@ R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *pmode
medge_t *pedge, *pedges; medge_t *pedge, *pedges;
// FIXME: use bounding-box-based frustum clipping info? // FIXME: use bounding-box-based frustum clipping info?
psurf = &pmodel->surfaces[pmodel->firstmodelsurface]; psurf = &currentmodel->surfaces[currentmodel->firstmodelsurface];
numsurfaces = pmodel->nummodelsurfaces; numsurfaces = currentmodel->nummodelsurfaces;
pedges = pmodel->edges; pedges = currentmodel->edges;
for (i=0 ; i<numsurfaces ; i++, psurf++) for (i=0 ; i<numsurfaces ; i++, psurf++)
{ {
@ -380,7 +380,7 @@ R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *pmode
for (j=0 ; j<psurf->numedges ; j++) for (j=0 ; j<psurf->numedges ; j++)
{ {
lindex = pmodel->surfedges[psurf->firstedge+j]; lindex = currentmodel->surfedges[psurf->firstedge+j];
if (lindex > 0) if (lindex > 0)
{ {
@ -417,7 +417,7 @@ All in one leaf
================ ================
*/ */
void 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; int i;
vec_t dot; vec_t dot;
@ -425,8 +425,8 @@ R_DrawSubmodelPolygons(entity_t *currententity, const model_t *pmodel, int clipf
int numsurfaces; int numsurfaces;
// FIXME: use bounding-box-based frustum clipping info? // FIXME: use bounding-box-based frustum clipping info?
psurf = &pmodel->surfaces[pmodel->firstmodelsurface]; psurf = &currentmodel->surfaces[currentmodel->firstmodelsurface];
numsurfaces = pmodel->nummodelsurfaces; numsurfaces = currentmodel->nummodelsurfaces;
for (i=0 ; i<numsurfaces ; i++, psurf++) for (i=0 ; i<numsurfaces ; i++, psurf++)
{ {
@ -443,7 +443,7 @@ R_DrawSubmodelPolygons(entity_t *currententity, const model_t *pmodel, int clipf
r_currentkey = ((mleaf_t *)topnode)->key; r_currentkey = ((mleaf_t *)topnode)->key;
// FIXME: use bounding-box-based frustum clipping info? // 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 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; int c;
vec3_t acceptpt, rejectpt; vec3_t acceptpt, rejectpt;
@ -570,7 +570,7 @@ R_RecursiveWorldNode (entity_t *currententity, mnode_t *node, int clipflags)
side = 1; side = 1;
// recurse down the children, front side first // recurse down the children, front side first
R_RecursiveWorldNode (currententity, node->children[side], clipflags); R_RecursiveWorldNode (currententity, currentmodel, node->children[side], clipflags);
// draw stuff // draw stuff
c = node->numsurfaces; c = node->numsurfaces;
@ -588,7 +588,7 @@ R_RecursiveWorldNode (entity_t *currententity, mnode_t *node, int clipflags)
if ((surf->flags & SURF_PLANEBACK) && if ((surf->flags & SURF_PLANEBACK) &&
(surf->visframe == r_framecount)) (surf->visframe == r_framecount))
{ {
R_RenderFace (currententity, surf, clipflags); R_RenderFace (currententity, currentmodel, surf, clipflags);
} }
surf++; surf++;
@ -601,7 +601,7 @@ R_RecursiveWorldNode (entity_t *currententity, mnode_t *node, int clipflags)
if (!(surf->flags & SURF_PLANEBACK) && if (!(surf->flags & SURF_PLANEBACK) &&
(surf->visframe == r_framecount)) (surf->visframe == r_framecount))
{ {
R_RenderFace (currententity, surf, clipflags); R_RenderFace (currententity, currentmodel, surf, clipflags);
} }
surf++; surf++;
@ -613,7 +613,7 @@ R_RecursiveWorldNode (entity_t *currententity, mnode_t *node, int clipflags)
} }
// recurse down the back side // 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 void
R_RenderWorld (void) R_RenderWorld (void)
{ {
const model_t *currentmodel = r_worldmodel;
if (!r_drawworld->value) if (!r_drawworld->value)
return; return;
@ -637,8 +638,7 @@ R_RenderWorld (void)
r_worldentity.frame = (int)(r_newrefdef.time*2); r_worldentity.frame = (int)(r_newrefdef.time*2);
VectorCopy (r_origin, modelorg); VectorCopy (r_origin, modelorg);
currentmodel = r_worldmodel;
r_pcurrentvertbase = currentmodel->vertexes; 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);
} }

View file

@ -738,7 +738,6 @@ static msurface_t *pface;
static surfcache_t *pcurrentcache; static surfcache_t *pcurrentcache;
static vec3_t transformed_modelorg; static vec3_t transformed_modelorg;
static vec3_t world_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) if (s->insubmodel)
{ {
entity_t *currententity; entity_t *currententity;
vec3_t local_modelorg;
// FIXME: we don't want to do all this for every polygon! // FIXME: we don't want to do all this for every polygon!
// TODO: store once at start of frame // TODO: store once at start of frame
@ -979,6 +979,8 @@ D_SolidSurf (surf_t *s)
if (s->insubmodel) if (s->insubmodel)
{ {
vec3_t local_modelorg;
// FIXME: we don't want to do all this for every polygon! // FIXME: we don't want to do all this for every polygon!
// TODO: store once at start of frame // TODO: store once at start of frame
currententity = s->entity; currententity = s->entity;

View file

@ -46,7 +46,6 @@ char skyname[MAX_QPATH];
vec3_t skyaxis; vec3_t skyaxis;
refdef_t r_newrefdef; refdef_t r_newrefdef;
model_t *currentmodel;
model_t *r_worldmodel; model_t *r_worldmodel;
@ -655,12 +654,12 @@ R_DrawEntitiesOnList (void)
modelorg[0] = -r_origin[0]; modelorg[0] = -r_origin[0];
modelorg[1] = -r_origin[1]; modelorg[1] = -r_origin[1];
modelorg[2] = -r_origin[2]; modelorg[2] = -r_origin[2];
VectorCopy( vec3_origin, r_entorigin ); VectorCopy(vec3_origin, r_entorigin);
R_DrawBeam( currententity ); R_DrawBeam(currententity);
} }
else else
{ {
currentmodel = currententity->model; const model_t *currentmodel = currententity->model;
if (!currentmodel) if (!currentmodel)
{ {
R_DrawNullModel(); R_DrawNullModel();
@ -672,11 +671,11 @@ R_DrawEntitiesOnList (void)
switch (currentmodel->type) switch (currentmodel->type)
{ {
case mod_sprite: case mod_sprite:
R_DrawSprite(currententity); R_DrawSprite(currententity, currentmodel);
break; break;
case mod_alias: case mod_alias:
R_AliasDrawModel(currententity); R_AliasDrawModel(currententity, currentmodel);
break; break;
default: default:
@ -705,7 +704,7 @@ R_DrawEntitiesOnList (void)
} }
else else
{ {
currentmodel = currententity->model; const model_t *currentmodel = currententity->model;
if (!currentmodel) if (!currentmodel)
{ {
R_DrawNullModel(); R_DrawNullModel();
@ -717,11 +716,11 @@ R_DrawEntitiesOnList (void)
switch (currentmodel->type) switch (currentmodel->type)
{ {
case mod_sprite: case mod_sprite:
R_DrawSprite(currententity); R_DrawSprite(currententity, currentmodel);
break; break;
case mod_alias: case mod_alias:
R_AliasDrawModel(currententity); R_AliasDrawModel(currententity, currentmodel);
break; break;
default: default:
@ -909,7 +908,7 @@ R_DrawBEntitiesOnList (void)
for (i=0 ; i<r_newrefdef.num_entities ; i++) for (i=0 ; i<r_newrefdef.num_entities ; i++)
{ {
entity_t *currententity = &r_newrefdef.entities[i]; entity_t *currententity = &r_newrefdef.entities[i];
currentmodel = currententity->model; const model_t *currentmodel = currententity->model;
if (!currentmodel) if (!currentmodel)
continue; continue;
if (currentmodel->nummodelsurfaces == 0) if (currentmodel->nummodelsurfaces == 0)

View file

@ -1026,9 +1026,9 @@ R_ClipAndDrawPoly ( float alpha, int isturbulent, qboolean textured )
** R_BuildPolygonFromSurface ** R_BuildPolygonFromSurface
*/ */
static void 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; medge_t *pedges, *r_pedge;
float *vec; float *vec;
vec5_t *pverts; vec5_t *pverts;
@ -1213,8 +1213,7 @@ void
R_DrawAlphaSurfaces(const entity_t *currententity) R_DrawAlphaSurfaces(const entity_t *currententity)
{ {
msurface_t *s = r_alpha_surfaces; msurface_t *s = r_alpha_surfaces;
const model_t *currentmodel = r_worldmodel;
currentmodel = r_worldmodel;
modelorg[0] = -r_origin[0]; modelorg[0] = -r_origin[0];
modelorg[1] = -r_origin[1]; modelorg[1] = -r_origin[1];
@ -1222,7 +1221,7 @@ R_DrawAlphaSurfaces(const entity_t *currententity)
while ( s ) while ( s )
{ {
R_BuildPolygonFromSurface(currententity, s); R_BuildPolygonFromSurface(currententity, currentmodel, s);
//======= //=======
//PGM //PGM

View file

@ -163,7 +163,7 @@ R_EmitSkyBox
================ ================
*/ */
static void static void
R_EmitSkyBox(entity_t *currententity) R_EmitSkyBox(entity_t *currententity, const model_t *currentmodel)
{ {
int i, j; int i, j;
int oldkey; int oldkey;
@ -199,7 +199,7 @@ R_EmitSkyBox(entity_t *currententity)
r_currentkey = 0x7ffffff0; r_currentkey = 0x7ffffff0;
for (i=0 ; i<6 ; i++) 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 r_currentkey = oldkey; // bsp sorting order
} }
@ -519,7 +519,7 @@ R_RenderFace
================ ================
*/ */
void 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; int i;
unsigned mask; unsigned mask;
@ -541,7 +541,7 @@ R_RenderFace (entity_t *currententity, msurface_t *fa, int clipflags)
// environment box surfaces to be emited // environment box surfaces to be emited
if ( fa->texinfo->flags & SURF_SKY ) if ( fa->texinfo->flags & SURF_SKY )
{ {
R_EmitSkyBox (currententity); R_EmitSkyBox (currententity, currentmodel);
return; return;
} }

View file

@ -24,7 +24,7 @@ extern polydesc_t r_polydesc;
extern vec5_t r_clip_verts[2][MAXWORKINGVERTS+2]; 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 ** R_DrawSprite
@ -33,7 +33,7 @@ extern void R_ClipAndDrawPoly( float alpha, qboolean isturbulent, qboolean textu
** mapped polygon ** mapped polygon
*/ */
void void
R_DrawSprite(entity_t *currententity) R_DrawSprite(entity_t *currententity, const model_t *currentmodel)
{ {
vec5_t *pverts; vec5_t *pverts;
vec3_t left, up, right, down; vec3_t left, up, right, down;