gl3: make currententity local

This commit is contained in:
Denis Pauk 2021-09-20 13:14:08 +03:00
parent 46c654b379
commit 7576d2d300
5 changed files with 30 additions and 36 deletions

View file

@ -252,7 +252,7 @@ RecursiveLightPoint(mnode_t *node, vec3_t start, vec3_t end)
} }
void void
GL3_LightPoint(vec3_t p, vec3_t color) GL3_LightPoint(entity_t *currententity, vec3_t p, vec3_t color)
{ {
vec3_t end; vec3_t end;
float r; float r;

View file

@ -50,7 +50,6 @@ refdef_t gl3_newrefdef;
viddef_t vid; viddef_t vid;
gl3model_t *gl3_worldmodel; gl3model_t *gl3_worldmodel;
entity_t *currententity;
float gl3depthmin=0.0f, gl3depthmax=1.0f; float gl3depthmin=0.0f, gl3depthmax=1.0f;
@ -851,7 +850,7 @@ GL3_DrawSpriteModel(entity_t *e, gl3model_t *currentmodel)
} }
static void static void
GL3_DrawNullModel(void) GL3_DrawNullModel(entity_t *currententity)
{ {
vec3_t shadelight; vec3_t shadelight;
@ -861,7 +860,7 @@ GL3_DrawNullModel(void)
} }
else else
{ {
GL3_LightPoint(currententity->origin, shadelight); GL3_LightPoint(currententity, currententity->origin, shadelight);
} }
hmm_mat4 origModelMat = gl3state.uni3DData.transModelMat4; hmm_mat4 origModelMat = gl3state.uni3DData.transModelMat4;
@ -976,7 +975,7 @@ GL3_DrawEntitiesOnList(void)
/* draw non-transparent first */ /* draw non-transparent first */
for (i = 0; i < gl3_newrefdef.num_entities; i++) for (i = 0; i < gl3_newrefdef.num_entities; i++)
{ {
currententity = &gl3_newrefdef.entities[i]; entity_t *currententity = &gl3_newrefdef.entities[i];
if (currententity->flags & RF_TRANSLUCENT) if (currententity->flags & RF_TRANSLUCENT)
{ {
@ -993,7 +992,7 @@ GL3_DrawEntitiesOnList(void)
if (!currentmodel) if (!currentmodel)
{ {
GL3_DrawNullModel(); GL3_DrawNullModel(currententity);
continue; continue;
} }
@ -1022,7 +1021,7 @@ GL3_DrawEntitiesOnList(void)
for (i = 0; i < gl3_newrefdef.num_entities; i++) for (i = 0; i < gl3_newrefdef.num_entities; i++)
{ {
currententity = &gl3_newrefdef.entities[i]; entity_t *currententity = &gl3_newrefdef.entities[i];
if (!(currententity->flags & RF_TRANSLUCENT)) if (!(currententity->flags & RF_TRANSLUCENT))
{ {
@ -1039,7 +1038,7 @@ GL3_DrawEntitiesOnList(void)
if (!currentmodel) if (!currentmodel)
{ {
GL3_DrawNullModel(); GL3_DrawNullModel(currententity);
continue; continue;
} }
@ -1579,7 +1578,7 @@ GL3_GetSpecialBufferModeForStereoMode(enum stereo_modes stereo_mode) {
#endif // 0 #endif // 0
static void static void
GL3_SetLightLevel(void) GL3_SetLightLevel(entity_t *currententity)
{ {
vec3_t shadelight = {0}; vec3_t shadelight = {0};
@ -1589,7 +1588,7 @@ GL3_SetLightLevel(void)
} }
/* save off light value for server to look at */ /* save off light value for server to look at */
GL3_LightPoint(gl3_newrefdef.vieworg, shadelight); GL3_LightPoint(currententity, gl3_newrefdef.vieworg, shadelight);
/* pick the greatest component, which should be the /* pick the greatest component, which should be the
* same as the mono value returned by software */ * same as the mono value returned by software */
@ -1621,7 +1620,7 @@ static void
GL3_RenderFrame(refdef_t *fd) GL3_RenderFrame(refdef_t *fd)
{ {
GL3_RenderView(fd); GL3_RenderView(fd);
GL3_SetLightLevel(); GL3_SetLightLevel(NULL);
GL3_SetGL2D(); GL3_SetGL2D();
if(v_blend[3] != 0.0f) if(v_blend[3] != 0.0f)

View file

@ -711,7 +711,7 @@ GL3_DrawAliasModel(entity_t *entity)
} }
else else
{ {
GL3_LightPoint(entity->origin, shadelight); GL3_LightPoint(entity, entity->origin, shadelight);
/* player lighting hack for communication back to server */ /* player lighting hack for communication back to server */
if (entity->flags & RF_WEAPONMODEL) if (entity->flags & RF_WEAPONMODEL)

View file

@ -159,7 +159,7 @@ CullBox(vec3_t mins, vec3_t maxs)
* Returns the proper texture for a given time and base texture * Returns the proper texture for a given time and base texture
*/ */
static gl3image_t * static gl3image_t *
TextureAnimation(mtexinfo_t *tex) TextureAnimation(entity_t *currententity, mtexinfo_t *tex)
{ {
int c; int c;
@ -337,14 +337,14 @@ UpdateLMscales(const hmm_vec4 lmScales[MAX_LIGHTMAPS_PER_SURFACE], gl3ShaderInfo
} }
static void static void
RenderBrushPoly(msurface_t *fa) RenderBrushPoly(entity_t *currententity, msurface_t *fa)
{ {
int map; int map;
gl3image_t *image; gl3image_t *image;
c_brush_polys++; c_brush_polys++;
image = TextureAnimation(fa->texinfo); image = TextureAnimation(currententity, fa->texinfo);
if (fa->flags & SURF_DRAWTURB) if (fa->flags & SURF_DRAWTURB)
{ {
@ -449,7 +449,7 @@ GL3_DrawAlphaSurfaces(void)
} }
static void static void
DrawTextureChains(void) DrawTextureChains(entity_t *currententity)
{ {
int i; int i;
msurface_t *s; msurface_t *s;
@ -476,7 +476,7 @@ DrawTextureChains(void)
for ( ; s; s = s->texturechain) for ( ; s; s = s->texturechain)
{ {
SetLightFlags(s); SetLightFlags(s);
RenderBrushPoly(s); RenderBrushPoly(currententity, s);
} }
image->texturechain = NULL; image->texturechain = NULL;
@ -486,10 +486,10 @@ DrawTextureChains(void)
} }
static void static void
RenderLightmappedPoly(msurface_t *surf) RenderLightmappedPoly(entity_t *currententity, msurface_t *surf)
{ {
int map; int map;
gl3image_t *image = TextureAnimation(surf->texinfo); gl3image_t *image = TextureAnimation(currententity, surf->texinfo);
hmm_vec4 lmScales[MAX_LIGHTMAPS_PER_SURFACE] = {0}; hmm_vec4 lmScales[MAX_LIGHTMAPS_PER_SURFACE] = {0};
lmScales[0] = HMM_Vec4(1.0f, 1.0f, 1.0f, 1.0f); lmScales[0] = HMM_Vec4(1.0f, 1.0f, 1.0f, 1.0f);
@ -526,7 +526,7 @@ RenderLightmappedPoly(msurface_t *surf)
} }
static void static void
DrawInlineBModel(gl3model_t *currentmodel) DrawInlineBModel(entity_t *currententity, gl3model_t *currentmodel)
{ {
int i, k; int i, k;
cplane_t *pplane; cplane_t *pplane;
@ -574,11 +574,11 @@ DrawInlineBModel(gl3model_t *currentmodel)
else if(!(psurf->flags & SURF_DRAWTURB)) else if(!(psurf->flags & SURF_DRAWTURB))
{ {
SetAllLightFlags(psurf); SetAllLightFlags(psurf);
RenderLightmappedPoly(psurf); RenderLightmappedPoly(currententity, psurf);
} }
else else
{ {
RenderBrushPoly(psurf); RenderBrushPoly(currententity, psurf);
} }
} }
} }
@ -601,7 +601,6 @@ GL3_DrawBrushModel(entity_t *e, gl3model_t *currentmodel)
return; return;
} }
currententity = e;
gl3state.currenttexture = -1; gl3state.currenttexture = -1;
if (e->angles[0] || e->angles[1] || e->angles[2]) if (e->angles[0] || e->angles[1] || e->angles[2])
@ -656,7 +655,7 @@ GL3_DrawBrushModel(entity_t *e, gl3model_t *currentmodel)
e->angles[0] = -e->angles[0]; e->angles[0] = -e->angles[0];
e->angles[2] = -e->angles[2]; e->angles[2] = -e->angles[2];
DrawInlineBModel(currentmodel); DrawInlineBModel(e, currentmodel);
// glPopMatrix(); // glPopMatrix();
gl3state.uni3DData.transModelMat4 = oldMat; gl3state.uni3DData.transModelMat4 = oldMat;
@ -669,7 +668,7 @@ GL3_DrawBrushModel(entity_t *e, gl3model_t *currentmodel)
} }
static void static void
RecursiveWorldNode(mnode_t *node) RecursiveWorldNode(entity_t *currententity, mnode_t *node)
{ {
int c, side, sidebit; int c, side, sidebit;
cplane_t *plane; cplane_t *plane;
@ -755,7 +754,7 @@ RecursiveWorldNode(mnode_t *node)
} }
/* recurse down the children, front side first */ /* recurse down the children, front side first */
RecursiveWorldNode(node->children[side]); RecursiveWorldNode(currententity, node->children[side]);
/* draw stuff */ /* draw stuff */
for (c = node->numsurfaces, for (c = node->numsurfaces,
@ -782,7 +781,7 @@ RecursiveWorldNode(mnode_t *node)
/* add to the translucent chain */ /* add to the translucent chain */
surf->texturechain = gl3_alpha_surfaces; surf->texturechain = gl3_alpha_surfaces;
gl3_alpha_surfaces = surf; gl3_alpha_surfaces = surf;
gl3_alpha_surfaces->texinfo->image = TextureAnimation(surf->texinfo); gl3_alpha_surfaces->texinfo->image = TextureAnimation(currententity, surf->texinfo);
} }
else else
{ {
@ -798,7 +797,7 @@ RecursiveWorldNode(mnode_t *node)
#endif // 0 #endif // 0
{ {
/* the polygon is visible, so add it to the texture sorted chain */ /* the polygon is visible, so add it to the texture sorted chain */
image = TextureAnimation(surf->texinfo); image = TextureAnimation(currententity, surf->texinfo);
surf->texturechain = image->texturechain; surf->texturechain = image->texturechain;
image->texturechain = surf; image->texturechain = surf;
} }
@ -806,7 +805,7 @@ RecursiveWorldNode(mnode_t *node)
} }
/* recurse down the back side */ /* recurse down the back side */
RecursiveWorldNode(node->children[!side]); RecursiveWorldNode(currententity, node->children[!side]);
} }
void void
@ -829,17 +828,14 @@ GL3_DrawWorld(void)
/* auto cycle the world frame for texture animation */ /* auto cycle the world frame for texture animation */
memset(&ent, 0, sizeof(ent)); memset(&ent, 0, sizeof(ent));
ent.frame = (int)(gl3_newrefdef.time * 2); ent.frame = (int)(gl3_newrefdef.time * 2);
currententity = &ent;
gl3state.currenttexture = -1; gl3state.currenttexture = -1;
GL3_ClearSkyBox(); GL3_ClearSkyBox();
RecursiveWorldNode(gl3_worldmodel->nodes); RecursiveWorldNode(&ent, gl3_worldmodel->nodes);
DrawTextureChains(); DrawTextureChains(&ent);
GL3_DrawSkyBox(); GL3_DrawSkyBox();
DrawTriangleOutlines(); DrawTriangleOutlines();
currententity = NULL;
} }
/* /*

View file

@ -300,7 +300,6 @@ typedef struct
} gl3lightmapstate_t; } gl3lightmapstate_t;
extern gl3model_t *gl3_worldmodel; extern gl3model_t *gl3_worldmodel;
extern entity_t *currententity;
extern float gl3depthmin, gl3depthmax; extern float gl3depthmin, gl3depthmax;
@ -426,7 +425,7 @@ extern void GL3_ImageList_f(void);
// gl3_light.c // gl3_light.c
extern void GL3_MarkLights(dlight_t *light, int bit, mnode_t *node); extern void GL3_MarkLights(dlight_t *light, int bit, mnode_t *node);
extern void GL3_PushDlights(void); extern void GL3_PushDlights(void);
extern void GL3_LightPoint(vec3_t p, vec3_t color); extern void GL3_LightPoint(entity_t *currententity, vec3_t p, vec3_t color);
extern void GL3_BuildLightMap(msurface_t *surf, int offsetInLMbuf, int stride); extern void GL3_BuildLightMap(msurface_t *surf, int offsetInLMbuf, int stride);
// gl3_lightmap.c // gl3_lightmap.c