From e4110ded3c19e2bc5177ba350685f7e98266cfd5 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 23 Dec 2019 13:17:16 +0200 Subject: [PATCH] - precache switch textures from ANIMATED lump For example, SW1SKULL and SW2SKULL switches are animated in TNT: Evilution Their frames are defined in ANIMATED lump which is old BOOM binary format Textures other than base were not cached because the corresponding switch definitions (in ANIMDEFS lump) have one frame only and BOOM style animations were not taken into account https://forum.zdoom.org/viewtopic.php?t=66652 # Conflicts: # src/p_setup.cpp --- src/p_setup.cpp | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 8f9f1ae85..28050288b 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -2999,27 +2999,43 @@ static void AddToList(uint8_t *hitlist, FTextureID texid, int bitmask) if (hitlist[texid.GetIndex()] & bitmask) return; // already done, no need to process everything again. hitlist[texid.GetIndex()] |= (uint8_t)bitmask; - for (auto anim : TexMan.mAnimations) + const auto addAnimations = [hitlist, bitmask](const FTextureID texid) { - if (texid == anim->BasePic || (!anim->bDiscrete && anim->BasePic < texid && texid < anim->BasePic + anim->NumFrames)) + for (auto anim : TexMan.mAnimations) { - for (int i = anim->BasePic.GetIndex(); i < anim->BasePic.GetIndex() + anim->NumFrames; i++) + if (texid == anim->BasePic || (!anim->bDiscrete && anim->BasePic < texid && texid < anim->BasePic + anim->NumFrames)) { - hitlist[i] |= (uint8_t)bitmask; + for (int i = anim->BasePic.GetIndex(); i < anim->BasePic.GetIndex() + anim->NumFrames; i++) + { + hitlist[i] |= (uint8_t)bitmask; + } } } - } + }; + + addAnimations(texid); auto switchdef = TexMan.FindSwitch(texid); if (switchdef) { - for (int i = 0; i < switchdef->NumFrames; i++) + const FSwitchDef *const pair = switchdef->PairDef; + const uint16_t numFrames = switchdef->NumFrames; + const uint16_t pairNumFrames = pair->NumFrames; + + for (int i = 0; i < numFrames; i++) { hitlist[switchdef->frames[i].Texture.GetIndex()] |= (uint8_t)bitmask; } - for (int i = 0; i < switchdef->PairDef->NumFrames; i++) + for (int i = 0; i < pairNumFrames; i++) { - hitlist[switchdef->PairDef->frames[i].Texture.GetIndex()] |= (uint8_t)bitmask; + hitlist[pair->frames[i].Texture.GetIndex()] |= (uint8_t)bitmask; + } + + if (numFrames == 1 && pairNumFrames == 1) + { + // Switch can still be animated via BOOM binary definition from ANIMATED lump + addAnimations(switchdef->frames[0].Texture); + addAnimations(pair->frames[0].Texture); } }