mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-12-01 16:41:09 +00:00
- 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
This commit is contained in:
parent
af18c78156
commit
e9a7dcd17b
1 changed files with 24 additions and 8 deletions
|
@ -96,6 +96,8 @@ static void AddToList(uint8_t *hitlist, FTextureID texid, int bitmask)
|
||||||
if (hitlist[texid.GetIndex()] & bitmask) return; // already done, no need to process everything again.
|
if (hitlist[texid.GetIndex()] & bitmask) return; // already done, no need to process everything again.
|
||||||
hitlist[texid.GetIndex()] |= (uint8_t)bitmask;
|
hitlist[texid.GetIndex()] |= (uint8_t)bitmask;
|
||||||
|
|
||||||
|
const auto addAnimations = [hitlist, bitmask](const FTextureID texid)
|
||||||
|
{
|
||||||
for (auto anim : TexMan.mAnimations)
|
for (auto anim : TexMan.mAnimations)
|
||||||
{
|
{
|
||||||
if (texid == anim->BasePic || (!anim->bDiscrete && anim->BasePic < texid && texid < anim->BasePic + anim->NumFrames))
|
if (texid == anim->BasePic || (!anim->bDiscrete && anim->BasePic < texid && texid < anim->BasePic + anim->NumFrames))
|
||||||
|
@ -106,17 +108,31 @@ static void AddToList(uint8_t *hitlist, FTextureID texid, int bitmask)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
addAnimations(texid);
|
||||||
|
|
||||||
auto switchdef = TexMan.FindSwitch(texid);
|
auto switchdef = TexMan.FindSwitch(texid);
|
||||||
if (switchdef)
|
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;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue