From 53962a2cd8ffccfd72f84b84a875c8372e3f8534 Mon Sep 17 00:00:00 2001 From: Leonid Kapitonov Date: Wed, 27 Nov 2024 19:50:44 +0100 Subject: Document Actor "Fidget Tables" (#2287) * Document `func_80034F54` and related data new name: `UpdateLimbOverrides` reason: - `0x814` and `0x940` constants - `*_OverrideLimbDraw` functions additionally: - move constants into `z64animation.h` - use these constant for existing formulas - properly name corresponding actors' fields - add occasional explicit limbs limit constants * port over the MM "fidget" naming * remove redundant comments * move and rename `FIDGET_*` constants * introduce a `FIDGET_SCALE` constant, as no other value is applied * remove generally unrelated changes * apply PR suggestion Co-authored-by: mzxrules * fix (?) fidgetTable size following the https://github.com/zeldaret/oot/pull/2287#discussion_r1832371833 suggestion * remove an unused `struct EnMu` field @ `0x024A` a continuation to the 211263295cd8768d63c1426025cf913ba6bedc18 automatic padding commpensates its absence * remove MM mention as "it would get unruly fast" https://github.com/zeldaret/oot/pull/2287#discussion_r1833470468 * rename `overridePerLimb` -> `fidgetFrequency` https://github.com/zeldaret/oot/pull/2287#discussion_r1837211873 * give better names to the constants https://github.com/zeldaret/oot/pull/2287#discussion_r1837211873 * remove unnecesasry braces from a comment https://github.com/zeldaret/oot/pull/2287#discussion_r1842642196 * make the comment multiline "officially" * restore `limbIndex` naming for this PR https://github.com/zeldaret/oot/pull/2287/commits/43afb7b7cb54aa7b086d8cb7fca4cffaa7d145bf#r1842644602 * apply a PR suggestion https://github.com/zeldaret/oot/pull/2287#discussion_r1842787653 --------- Co-authored-by: mzxrules --- src/code/z_actor.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/code') diff --git a/src/code/z_actor.c b/src/code/z_actor.c index b5e96201d..b96801fc4 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -4441,13 +4441,24 @@ void Animation_ChangeByInfo(SkelAnime* skelAnime, AnimationInfo* animationInfo, frameCount, animationInfo->mode, animationInfo->morphFrames); } -void func_80034F54(PlayState* play, s16* arg1, s16* arg2, s32 arg3) { +/** + * Fills two tables with rotation angles that can be used to simulate idle animations. + * + * The rotation angles are dependent on the current frame, so should be updated regularly, generally every frame. + * + * This is done for the desired limb by taking either the `sin` of the yTable value or the `cos` of the zTable value, + * multiplying by some scale factor (generally 200), and adding that to the already existing rotation. + * + * Note: With the common scale factor of 200, this effect is practically unnoticeable if the current animation already + * has motion involved. + */ +void Actor_UpdateFidgetTables(PlayState* play, s16* fidgetTableY, s16* fidgetTableZ, s32 tableLen) { u32 frames = play->gameplayFrames; s32 i; - for (i = 0; i < arg3; i++) { - arg1[i] = (0x814 + 50 * i) * frames; - arg2[i] = (0x940 + 50 * i) * frames; + for (i = 0; i < tableLen; i++) { + fidgetTableY[i] = (FIDGET_FREQ_Y + FIDGET_FREQ_LIMB * i) * frames; + fidgetTableZ[i] = (FIDGET_FREQ_Z + FIDGET_FREQ_LIMB * i) * frames; } } -- cgit v1.2.3