Texture chains working properly

Somehow, R_TextureAnimation() returns different results for the same
surface when called consecutively. We force it to be called once, so
the chains in R_DrawTextureChains() are getting respected now.
This commit is contained in:
Jaime Moreira 2024-04-23 12:21:40 -04:00
parent e5ee2a74a5
commit 3dde0d5859

View file

@ -418,17 +418,12 @@ static void
R_RenderBrushPoly(entity_t *currententity, msurface_t *fa)
{
int maps;
image_t *image;
qboolean is_dynamic = false;
c_brush_polys++;
image = R_TextureAnimation(currententity, fa->texinfo);
if (fa->flags & SURF_DRAWTURB)
{
R_Bind(image->texnum);
/* This is a hack ontop of a hack. Warping surfaces like those generated
by R_EmitWaterPolys() don't have a lightmap. Original Quake II therefore
negated the global intensity on those surfaces, because otherwise they
@ -459,12 +454,8 @@ R_RenderBrushPoly(entity_t *currententity, msurface_t *fa)
return;
}
else
{
R_Bind(image->texnum);
R_TexEnv(GL_REPLACE);
}
R_TexEnv(GL_REPLACE);
if (fa->texinfo->flags & SURF_FLOWING)
{
@ -625,6 +616,7 @@ R_DrawTextureChains(entity_t *currententity)
for ( ; s; s = s->texturechain)
{
R_Bind(image->texnum); // may reset because of dynamic lighting in R_RenderBrushPoly
R_RenderBrushPoly(currententity, s);
}
@ -642,6 +634,7 @@ R_DrawInlineBModel(entity_t *currententity, const model_t *currentmodel)
float dot;
msurface_t *psurf;
dlight_t *lt;
image_t *image;
/* calculate dynamic lighting for bmodel */
if (!gl1_flashblend->value)
@ -685,6 +678,8 @@ R_DrawInlineBModel(entity_t *currententity, const model_t *currentmodel)
}
else
{
image = R_TextureAnimation(currententity, psurf->texinfo);
R_Bind(image->texnum);
R_RenderBrushPoly(currententity, psurf);
}
}
@ -692,7 +687,6 @@ R_DrawInlineBModel(entity_t *currententity, const model_t *currentmodel)
if (!(currententity->flags & RF_TRANSLUCENT))
{
R_BlendLightmaps(currentmodel);
}
else
@ -917,7 +911,6 @@ void
R_DrawWorld(void)
{
entity_t ent;
const model_t *currentmodel;
if (!r_drawworld->value)
{
@ -929,8 +922,6 @@ R_DrawWorld(void)
return;
}
currentmodel = r_worldmodel;
VectorCopy(r_newrefdef.vieworg, modelorg);
/* auto cycle the world frame for texture animation */
@ -945,7 +936,7 @@ R_DrawWorld(void)
R_ClearSkyBox();
R_RecursiveWorldNode(&ent, r_worldmodel->nodes);
R_DrawTextureChains(&ent);
R_BlendLightmaps(currentmodel);
R_BlendLightmaps(r_worldmodel);
R_DrawSkyBox();
R_DrawTriangleOutlines();
}
@ -1045,4 +1036,3 @@ R_MarkLeaves(void)
}
}
}