From f612b97fc9d08538af966bda20f92e63b26ae5ca Mon Sep 17 00:00:00 2001 From: Eukara Date: Mon, 3 Jan 2022 01:57:23 +0000 Subject: [PATCH] Animate surfaces at twice the speed when rendering HLBSP. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6147 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/gl/gl_model.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/engine/gl/gl_model.c b/engine/gl/gl_model.c index c48a26e8..befb302f 100644 --- a/engine/gl/gl_model.c +++ b/engine/gl/gl_model.c @@ -2709,6 +2709,37 @@ static void Mod_UpdateBatchShader_Q1 (struct batch_s *batch) batch->shader = base->shader; } + +// copy of Q1s, but with a different framerate +static void Mod_UpdateBatchShader_HL (struct batch_s *batch) +{ + texture_t *base = batch->texture; + unsigned int relative; + int count; + + if (batch->ent->framestate.g[FS_REG].frame[0]) + { + if (base->alternate_anims) + base = base->alternate_anims; + } + + if (base->anim_total) + { + relative = (unsigned int)(cl.time*20) % base->anim_total; + + count = 0; + while (base->anim_min > relative || base->anim_max <= relative) + { + base = base->anim_next; + if (!base) + Sys_Error ("R_TextureAnimation: broken cycle"); + if (++count > 100) + Sys_Error ("R_TextureAnimation: infinite cycle"); + } + } + + batch->shader = base->shader; +} #endif #ifdef Q2BSPS @@ -2882,9 +2913,11 @@ static int Mod_Batches_Generate(model_t *mod) #endif #ifdef Q1BSPS case fg_quake: - case fg_halflife: batch->buildmeshes = Mod_UpdateBatchShader_Q1; break; + case fg_halflife: + batch->buildmeshes = Mod_UpdateBatchShader_HL; + break; #endif default: break;