From 347cdc5e3396ac934cabcffac56dfc043e3e0f44 Mon Sep 17 00:00:00 2001 From: Chris Ison Date: Mon, 15 Apr 2002 03:26:08 +0000 Subject: [PATCH] some small performance optimizations with textures and animations --- libs/video/renderer/gl/gl_mod_alias.c | 3 +- libs/video/renderer/gl/gl_rmain.c | 13 ++++++++- libs/video/renderer/gl/gl_rsurf.c | 40 +++++++++++++++++++-------- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/libs/video/renderer/gl/gl_mod_alias.c b/libs/video/renderer/gl/gl_mod_alias.c index da715b344..3eb2841d5 100644 --- a/libs/video/renderer/gl/gl_mod_alias.c +++ b/libs/video/renderer/gl/gl_mod_alias.c @@ -468,8 +468,7 @@ R_DrawAliasModel (entity_t *e, qboolean cull) if (cull && R_CullBox (mins, maxs)) return; - VectorCopy (e->origin, r_entorigin); - VectorSubtract (r_origin, r_entorigin, modelorg); + VectorSubtract (r_origin, e->origin, modelorg); if (clmodel->fullbright) { shadelight = 1.0; // make certain models full brightness always diff --git a/libs/video/renderer/gl/gl_rmain.c b/libs/video/renderer/gl/gl_rmain.c index 367ef7fd4..f79276c98 100644 --- a/libs/video/renderer/gl/gl_rmain.c +++ b/libs/video/renderer/gl/gl_rmain.c @@ -468,7 +468,18 @@ R_Mirror (void) qfglColor4ubv (color_white); s = r_worldentity.model->textures[mirrortexturenum]->texturechain; for (; s; s = s->texturechain) { - texture_t *tex = R_TextureAnimation (s); + texture_t *tex; + if (!s->texinfo->texture->anim_total) + tex = s->texinfo->texture; + else + tex = R_TextureAnimation (s); + +// FIXME: if this is needed, then include header for fullbright_polys +// if ( tex->gl_fb_texturenum > 0) { +// s->polys->fb_chain = fullbright_polys[tex->gl_fb_texturenum]; +// fullbright_polys[tex->gl_fb_texturenum] = s->polys; +// } + qfglBindTexture (GL_TEXTURE_2D, tex->gl_texturenum); R_RenderBrushPoly (s); } diff --git a/libs/video/renderer/gl/gl_rsurf.c b/libs/video/renderer/gl/gl_rsurf.c index c84263777..7996a9ec2 100644 --- a/libs/video/renderer/gl/gl_rsurf.c +++ b/libs/video/renderer/gl/gl_rsurf.c @@ -324,9 +324,6 @@ R_TextureAnimation (msurface_t *surf) base = base->alternate_anims; } - if (!base->anim_total) - goto found; - relative = (int) (r_realtime * 10) % base->anim_total; count = 0; @@ -337,11 +334,6 @@ R_TextureAnimation (msurface_t *surf) if (++count > 100) Sys_Error ("R_TextureAnimation: infinite cycle"); } -found: - if (base->gl_fb_texturenum > 0) { - surf->polys->fb_chain = fullbright_polys[base->gl_fb_texturenum]; - fullbright_polys[base->gl_fb_texturenum] = surf->polys; - } return base; } @@ -380,8 +372,16 @@ R_DrawMultitexturePoly (msurface_t *s) { float *v; int maps, i; - texture_t *texture = R_TextureAnimation (s); - + texture_t *texture; + + if (!s->texinfo->texture->anim_total) + texture = s->texinfo->texture; + else + texture = R_TextureAnimation (s); + if ( texture->gl_fb_texturenum > 0) { + s->polys->fb_chain = fullbright_polys[texture->gl_fb_texturenum]; + fullbright_polys[texture->gl_fb_texturenum] = s->polys; + } c_brush_polys++; i = s->lightmaptexturenum; @@ -707,7 +707,15 @@ R_DrawBrushModel (entity_t *e) } else if (gl_mtex_active) { R_DrawMultitexturePoly (psurf); } else { - texture_t *tex = R_TextureAnimation (psurf); + texture_t *tex; + if (!psurf->texinfo->texture->anim_total) + tex = psurf->texinfo->texture; + else + tex = R_TextureAnimation (psurf); + if ( tex->gl_fb_texturenum > 0) { + psurf->polys->fb_chain = fullbright_polys[tex->gl_fb_texturenum]; + fullbright_polys[tex->gl_fb_texturenum] = psurf->polys; + } qfglBindTexture (GL_TEXTURE_2D, tex->gl_texturenum); R_RenderBrushPoly (psurf); } @@ -789,7 +797,15 @@ R_RecursiveWorldNode (mnode_t *node) } else if (gl_mtex_active) { R_DrawMultitexturePoly (surf); } else { - texture_t *tex = R_TextureAnimation (surf); + texture_t *tex; + if (!surf->texinfo->texture->anim_total) + tex = surf->texinfo->texture; + else + tex = R_TextureAnimation (surf); + if (tex->gl_fb_texturenum > 0) { + surf->polys->fb_chain = fullbright_polys[tex->gl_fb_texturenum]; + fullbright_polys[tex->gl_fb_texturenum] = surf->polys; + } CHAIN_SURF (surf, tex->texturechain); } }