From 29b93f63f7afdb625fb28047ef2b7f7b50fba8f7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 15 Feb 2025 16:22:16 +0100 Subject: [PATCH] precache animated textures too --- src/hardware/hw_cache.c | 32 ++++++++++++++++++++++++++++++++ src/p_spec.c | 17 ++--------------- src/p_spec.h | 16 ++++++++++++++++ 3 files changed, 50 insertions(+), 15 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 5a7cd8b33..991032ac5 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -30,6 +30,7 @@ #include "../r_main.h" #include "../r_patch.h" // patch rotation #include "../p_setup.h" // levelflats +#include "../p_spec.h" // anim_t #include "../r_sky.h" INT32 patchformat = GL_TEXFMT_AP_88; // use alpha for holes @@ -610,6 +611,8 @@ static void HWR_PrecacheLevelTextures(void) { char *texturepresent; size_t i, j; + INT32 h; + anim_t *anim; texturepresent = calloc(numtextures, sizeof (*texturepresent)); if (texturepresent == NULL) I_Error("%s: Out of memory looking up textures", "HWR_PrecacheLevel"); @@ -646,6 +649,31 @@ static void HWR_PrecacheLevelTextures(void) } } + for (anim = anims; anim < lastanim; anim++) + { + if (!anim->istexture) + continue; + + if (!texturepresent[anim->basepic]) + continue; + + if (texturepresent[anim->basepic] & 1) + { + for (h = 0; h < anim->numpics; h++) + { + HWR_GetTexture(anim->basepic+h, false); + } + } + + if (texturepresent[anim->basepic] & 2) + { + for (h = 0; h < anim->numpics; h++) + { + HWR_GetTexture(anim->basepic+h, true); + } + } + } + // Sky texture is always present. // Note that F_SKY1 is the name used to indicate a sky floor/ceiling as a flat, // while the sky texture is stored like a wall texture, with a skynum dependent name. @@ -657,10 +685,14 @@ static void HWR_PrecacheLevelTextures(void) continue; if (texturepresent[i] & 1) + { HWR_GetTexture(i, false); + } if (texturepresent[i] & 2) + { HWR_GetTexture(i, true); + } } free(texturepresent); } diff --git a/src/p_spec.c b/src/p_spec.c index 3f9dfd626..4eb380df0 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -51,19 +51,6 @@ mobj_t *skyboxmo[2]; // This must be updated whenever we up the max flat size - quicker to assume rather than figuring out the sqrt of the specific flat's filesize. #define MAXFLATSIZE (2048<> ((j-1)*4))&15) +/** Animated texture descriptor + * This keeps track of an animated texture or an animated flat. + * \sa P_UpdateSpecials, P_InitPicAnims, animdef_t + */ +typedef struct +{ + SINT8 istexture; ///< ::true for a texture, ::false for a flat + INT32 picnum; ///< The end flat number + INT32 basepic; ///< The start flat number + INT32 numpics; ///< Number of frames in the animation + tic_t speed; ///< Number of tics for which each frame is shown +} anim_t; + +extern anim_t *lastanim; +extern anim_t *anims; + // at game start void P_InitPicAnims(void);