mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-17 22:50:51 +00:00
build the texture chains such that they get rendered front to back. seems to
only get about 0.17% speedup in overkill (with just about every thing off), but it might make more of a difference in-game.
This commit is contained in:
parent
9f4a565523
commit
dc779acdb5
3 changed files with 43 additions and 17 deletions
|
@ -86,6 +86,7 @@ typedef struct texture_s
|
|||
int gl_texturenum;
|
||||
int gl_fb_texturenum;
|
||||
struct msurface_s *texturechain; // for gl_texsort drawing
|
||||
struct msurface_s **texturechain_tail;
|
||||
int anim_total; // total tenths in sequence ( 0 = no)
|
||||
int anim_min, anim_max; // time for this frame min <=time< max
|
||||
struct texture_s *anim_next; // in the animation sequence
|
||||
|
|
|
@ -194,14 +194,15 @@ R_NewMap (model_t *worldmodel, struct model_s **models, int num_models)
|
|||
skytexturenum = -1;
|
||||
mirrortexturenum = -1;
|
||||
for (i = 0; i < r_worldentity.model->numtextures; i++) {
|
||||
if (!r_worldentity.model->textures[i])
|
||||
texture_t *tex = r_worldentity.model->textures[i];
|
||||
if (!tex)
|
||||
continue;
|
||||
if (!strncmp (r_worldentity.model->textures[i]->name, "sky", 3))
|
||||
if (!strncmp (tex->name, "sky", 3))
|
||||
skytexturenum = i;
|
||||
if (!strncmp (r_worldentity.model->textures[i]->name,
|
||||
"window02_1", 10))
|
||||
if (!strncmp (tex->name, "window02_1", 10))
|
||||
mirrortexturenum = i;
|
||||
r_worldentity.model->textures[i]->texturechain = NULL;
|
||||
tex->texturechain = NULL;
|
||||
tex->texturechain_tail = &tex->texturechain;
|
||||
}
|
||||
r_skyname = Cvar_FindVar ("r_skyname");
|
||||
if (r_skyname != NULL)
|
||||
|
|
|
@ -88,7 +88,28 @@ glpoly_t *lightmap_polys[MAX_LIGHTMAPS];
|
|||
glRect_t lightmap_rectchange[MAX_LIGHTMAPS];
|
||||
|
||||
msurface_t *waterchain = NULL;
|
||||
msurface_t **waterchain_tail = &waterchain;
|
||||
msurface_t *sky_chain;
|
||||
msurface_t **sky_chain_tail;
|
||||
|
||||
#define CHAIN_SURF_F2B(surf,chain) \
|
||||
do { \
|
||||
*(chain##_tail) = (surf); \
|
||||
(chain##_tail) = &(surf)->texturechain; \
|
||||
*(chain##_tail) = 0; \
|
||||
} while (0)
|
||||
|
||||
#define CHAIN_SURF_B2F(surf,chain) \
|
||||
do { \
|
||||
(surf)->texturechain = (chain); \
|
||||
(chain) = (surf); \
|
||||
} while (0)
|
||||
|
||||
#if 1
|
||||
# define CHAIN_SURF CHAIN_SURF_F2B
|
||||
#else
|
||||
# define CHAIN_SURF CHAIN_SURF_B2F
|
||||
#endif
|
||||
|
||||
|
||||
// LordHavoc: place for gl_rsurf setup code
|
||||
|
@ -582,6 +603,7 @@ R_DrawWaterSurfaces (void)
|
|||
}
|
||||
|
||||
waterchain = NULL;
|
||||
waterchain_tail = &waterchain;
|
||||
|
||||
if (r_wateralpha->value < 1.0) {
|
||||
qfglDepthMask (GL_TRUE);
|
||||
|
@ -598,12 +620,14 @@ DrawTextureChains (void)
|
|||
qfglDisable (GL_BLEND);
|
||||
|
||||
for (i = 0; i < r_worldentity.model->numtextures; i++) {
|
||||
if (!r_worldentity.model->textures[i])
|
||||
texture_t *tex = r_worldentity.model->textures[i];
|
||||
if (!tex)
|
||||
continue;
|
||||
for (s = r_worldentity.model->textures[i]->texturechain; s;
|
||||
s = s->texturechain) R_RenderBrushPoly (s);
|
||||
for (s = tex->texturechain; s; s = s->texturechain)
|
||||
R_RenderBrushPoly (s);
|
||||
|
||||
r_worldentity.model->textures[i]->texturechain = NULL;
|
||||
tex->texturechain = NULL;
|
||||
tex->texturechain_tail = &tex->texturechain;
|
||||
}
|
||||
|
||||
qfglEnable (GL_BLEND);
|
||||
|
@ -689,8 +713,7 @@ R_DrawBrushModel (entity_t *e)
|
|||
if (psurf->flags & SURF_DRAWTURB) {
|
||||
GL_WaterSurface (psurf);
|
||||
} else if (psurf->flags & SURF_DRAWSKY) {
|
||||
psurf->texturechain = sky_chain;
|
||||
sky_chain = psurf;
|
||||
CHAIN_SURF (psurf, sky_chain);
|
||||
return;
|
||||
} else if (gl_mtex_active) {
|
||||
R_DrawMultitexturePoly (psurf);
|
||||
|
@ -766,16 +789,16 @@ R_RecursiveWorldNode (mnode_t *node)
|
|||
continue; // wrong side
|
||||
|
||||
if (surf->flags & SURF_DRAWTURB) {
|
||||
surf->texturechain = waterchain;
|
||||
waterchain = surf;
|
||||
if (r_wateralpha->value < 1)
|
||||
CHAIN_SURF_B2F (surf, waterchain);
|
||||
else
|
||||
CHAIN_SURF (surf, waterchain);
|
||||
} else if (surf->flags & SURF_DRAWSKY) {
|
||||
surf->texturechain = sky_chain;
|
||||
sky_chain = surf;
|
||||
CHAIN_SURF (surf, sky_chain);
|
||||
} else if (gl_mtex_active) {
|
||||
R_DrawMultitexturePoly (surf);
|
||||
} else {
|
||||
surf->texturechain = surf->texinfo->texture->texturechain;
|
||||
surf->texinfo->texture->texturechain = surf;
|
||||
CHAIN_SURF (surf, surf->texinfo->texture->texturechain);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -799,6 +822,7 @@ R_DrawWorld (void)
|
|||
memset (fullbright_polys, 0, sizeof (fullbright_polys));
|
||||
|
||||
sky_chain = 0;
|
||||
sky_chain_tail = &sky_chain;
|
||||
if (!gl_sky_clip->int_val) {
|
||||
R_DrawSky ();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue