nipkownix / re4_tweaks

Fixes and tweaks for the "UHD" port of Resident Evil 4
zlib License
341 stars 32 forks source link

Misc: add fix for ShapeMove / PlSetFace single frame anim bug #338

Closed emoose closed 2 years ago

emoose commented 2 years ago

Should hopefully fix the bug with face animations not being shown, could possibly affect other anims that use ShapeSet/ShapeMove too, I think only hands & face anims use that (during gameplay and cutscenes), but could be wrong - in any case I'm pretty sure the original code was bugged and negative frame numbers weren't intended, so this fix shouldn't break anything at least, if we're lucky maybe it'd help fix some other things too :p

The posts around https://github.com/nipkownix/re4_tweaks/issues/333#issuecomment-1252207436 go into it some more (thanks to albert for testing & brainstorming it with me 😸), code comments should explain what was changed:

ShapeMove has a bug that makes the current animation frame get set to -1, only letting it stay visible for a single frame (only happens with face anims that only have a single frame, which were meant to be shown until something disabled it) Seems to be due to the code at 6CCBDC in 1.1.0, on GC that would just set currentFrame to 0, but some reason UHD changed it to (currentFrame - 2) This code is only ran when currentFrame >= maxFrames, guess that was changed so once anim reached end it'd repeat the last 1 or 2 frames in the anim, while on GC it repeats from beginning frame 0 instead Bug happens when currentFrame is 1 and maxFrames is 1, that code will get ran, which results in currentFrame being set to -1... There is a flag check in that func that can force it to 0 instead, but that flag can affect some other things too, so it's better to hook it & check if below 0 instead

Seems to work fine across all the EXEs, might want to wait until it's been tested some more before merging though, not sure if it might affect cutscenes in some way.

E: since this only changes what happens at the end of the anim, and hand anims seem to use the same thing, I wonder if it'd have any effect with the weapon reloads - removing the 30fps flag from sniper reload still gave the jittery mess though, but https://github.com/nipkownix/re4_tweaks/issues/23#issuecomment-1187924132 mentioned removing the flag for crossbow would only break frames at end of the animation, maybe these changes could help with it somehow?

nipkownix commented 2 years ago

Oops, missed this one. Pretty nice work! Wouldn't surprise me if the hermite stuff is broken in a similar way, honestly.

Judging by albert's test, I think we should be safe to merge this?

emoose commented 2 years ago

Yeah played through first few stages and cutscenes all seemed fine for me too, should be good to merge.