From 1fcacd202ea94b3085531df04c3a2f4b6f19eca3 Mon Sep 17 00:00:00 2001 From: feacur Date: Thu, 7 Nov 2024 01:02:55 +0100 Subject: [PATCH] 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 --- include/z64actor.h | 10 ++++++++- include/z64animation.h | 7 ------ src/code/z_actor.c | 22 ++++++++++++++----- .../ovl_En_Diving_Game/z_en_diving_game.c | 5 ++--- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 5 ++--- src/overlays/actors/ovl_En_Ge1/z_en_ge1.c | 5 ++--- src/overlays/actors/ovl_En_Go/z_en_go.c | 6 ++--- src/overlays/actors/ovl_En_Go/z_en_go.h | 4 ++-- src/overlays/actors/ovl_En_Go2/z_en_go2.c | 6 ++--- src/overlays/actors/ovl_En_Go2/z_en_go2.h | 4 ++-- src/overlays/actors/ovl_En_Guest/z_en_guest.c | 6 ++--- src/overlays/actors/ovl_En_Guest/z_en_guest.h | 4 ++-- src/overlays/actors/ovl_En_Hy/z_en_hy.c | 8 +++---- src/overlays/actors/ovl_En_Hy/z_en_hy.h | 4 ++-- src/overlays/actors/ovl_En_Ko/z_en_ko.c | 18 +++++++-------- src/overlays/actors/ovl_En_Ko/z_en_ko.h | 4 ++-- src/overlays/actors/ovl_En_Kz/z_en_kz.c | 8 +++---- src/overlays/actors/ovl_En_Kz/z_en_kz.h | 4 ++-- src/overlays/actors/ovl_En_Md/z_en_md.c | 12 +++++----- src/overlays/actors/ovl_En_Md/z_en_md.h | 4 ++-- src/overlays/actors/ovl_En_Mu/z_en_mu.c | 6 ++--- src/overlays/actors/ovl_En_Mu/z_en_mu.h | 6 ++--- .../actors/ovl_En_Niw_Lady/z_en_niw_lady.c | 7 ++---- src/overlays/actors/ovl_En_Sth/z_en_sth.c | 6 ++--- src/overlays/actors/ovl_En_Ta/z_en_ta.c | 6 ++--- src/overlays/actors/ovl_En_Zo/z_en_zo.c | 8 +++---- src/overlays/actors/ovl_En_Zo/z_en_zo.h | 4 ++-- 27 files changed, 97 insertions(+), 92 deletions(-) diff --git a/include/z64actor.h b/include/z64actor.h index 157648a42f..5b362c290f 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -14,6 +14,14 @@ #define MASS_IMMOVABLE 0xFF // Cannot be pushed by OC colliders #define MASS_HEAVY 0xFE // Can only be pushed by OC colliders from actors with IMMOVABLE or HEAVY mass. +// These constants are the [default] parameters for the ubiqutous "fidgeting" formulas. +// Some actors call `Actor_UpdateFidgetTables` function and cache their results in `fidgetTable*` fields. +// Others compute them on the fly. Both variants are applied inside `*_OverrideLimbDraw` as input angles. +#define FIDGET_ADD_Y 0x814 +#define FIDGET_ADD_Z 0x940 +#define FIDGET_MUL_I 0x32 +#define FIDGET_SCALE 200.0f + struct Actor; struct ActorEntry; struct CollisionPoly; @@ -917,7 +925,7 @@ void func_80034BA0(struct PlayState* play, SkelAnime* skelAnime, OverrideLimbDra void func_80034CC4(struct PlayState* play, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s16 alpha); s16 func_80034DD4(Actor* actor, struct PlayState* play, s16 arg2, f32 arg3); -void UpdateLimbOverrides(struct PlayState* play, s16* tableY, s16* tableZ, s32 count); +void Actor_UpdateFidgetTables(struct PlayState* play, s16* fidgetTableY, s16* fidgetTableZ, s32 tableLen); void Actor_Noop(Actor* actor, struct PlayState* play); void Gfx_DrawDListOpa(struct PlayState* play, Gfx* dlist); diff --git a/include/z64animation.h b/include/z64animation.h index 5474d96841..17b42e1a0f 100644 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -16,13 +16,6 @@ struct SkelAnime; #define LIMB_DONE 0xFF -// These constants are ubiqutous limb override formulas parameters. -// Some actors call `UpdateLimbOverrides` function and cache their results in `limbOverrides*` tables. -// Others compute them on the fly. Both variants are applied inside `*_OverrideLimbDraw` as input angles. -#define LIMB_OVERRIDE_BASE_Y 0x814 -#define LIMB_OVERRIDE_BASE_Z 0x940 -#define LIMB_OVERRIDE_PER_I 0x32 - typedef struct StandardLimb { /* 0x00 */ Vec3s jointPos; // Root is position in model space, children are relative to parent /* 0x06 */ u8 child; diff --git a/src/code/z_actor.c b/src/code/z_actor.c index c5f7868a23..b1b277d7aa 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -4432,16 +4432,26 @@ void Animation_ChangeByInfo(SkelAnime* skelAnime, AnimationInfo* animationInfo, frameCount, animationInfo->mode, animationInfo->morphFrames); } -/* - * computes `.limbOverrides` values for `*_OverrideLimbDraw` functions +/** + * 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. + * + * Note: MM gets this function unused in favor of `SubS_UpdateFidgetTables` @ `z_sub_s.c`. */ -void UpdateLimbOverrides(PlayState* play, s16* tableY, s16* tableZ, s32 count) { +void Actor_UpdateFidgetTables(PlayState* play, s16* fidgetTableY, s16* fidgetTableZ, s32 tableLen) { u32 frames = play->gameplayFrames; s32 i; - for (i = 0; i < count; i++) { - tableY[i] = (LIMB_OVERRIDE_BASE_Y + LIMB_OVERRIDE_PER_I * i) * frames; - tableZ[i] = (LIMB_OVERRIDE_BASE_Z + LIMB_OVERRIDE_PER_I * i) * frames; + for (i = 0; i < tableLen; i++) { + fidgetTableY[i] = (FIDGET_ADD_Y + FIDGET_MUL_I * i) * frames; + fidgetTableZ[i] = (FIDGET_ADD_Z + FIDGET_MUL_I * i) * frames; } } diff --git a/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c b/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c index 7f7be172a9..1d41acb1a9 100644 --- a/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c +++ b/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c @@ -561,9 +561,8 @@ s32 EnDivingGame_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, V } if (this->notPlayingMinigame && (limbIndex == 8 || limbIndex == 9 || limbIndex == 12)) { - // pad = limbIndex * LIMB_OVERRIDE_PER_I; // likely - rot->y += Math_SinS((play->state.frames * (limbIndex * LIMB_OVERRIDE_PER_I + LIMB_OVERRIDE_BASE_Y))) * 200.0f; - rot->z += Math_CosS((play->state.frames * (limbIndex * LIMB_OVERRIDE_PER_I + LIMB_OVERRIDE_BASE_Z))) * 200.0f; + rot->y += Math_SinS((play->state.frames * (limbIndex * FIDGET_MUL_I + FIDGET_ADD_Y))) * FIDGET_SCALE; + rot->z += Math_CosS((play->state.frames * (limbIndex * FIDGET_MUL_I + FIDGET_ADD_Z))) * FIDGET_SCALE; } return 0; diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index d63f115130..b1dcabeb27 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -278,9 +278,8 @@ s32 EnFu_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po } if (limbIndex == FU_LIMB_CHEST_MUSIC_BOX) { - // pad = limbIndex * LIMB_OVERRIDE_PER_I; // likely - rot->y += Math_SinS((play->state.frames * (limbIndex * LIMB_OVERRIDE_PER_I + LIMB_OVERRIDE_BASE_Y))) * 200.0f; - rot->z += Math_CosS((play->state.frames * (limbIndex * LIMB_OVERRIDE_PER_I + LIMB_OVERRIDE_BASE_Z))) * 200.0f; + rot->y += Math_SinS((play->state.frames * (limbIndex * FIDGET_MUL_I + FIDGET_ADD_Y))) * FIDGET_SCALE; + rot->z += Math_CosS((play->state.frames * (limbIndex * FIDGET_MUL_I + FIDGET_ADD_Z))) * FIDGET_SCALE; } return false; } diff --git a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c index 16dd02585f..4eddf236ea 100644 --- a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c +++ b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c @@ -777,9 +777,8 @@ s32 EnGe1_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p // The purpose of the state flag GE1_STATE_STOP_FIDGET is to skip this code, which this actor has in lieu of an idle // animation. if ((limbIndex == GE1_LIMB_TORSO) || (limbIndex == GE1_LIMB_L_FOREARM) || (limbIndex == GE1_LIMB_R_FOREARM)) { - // pad = limbIndex * LIMB_OVERRIDE_PER_I; // likely - rot->y += Math_SinS(play->state.frames * (limbIndex * LIMB_OVERRIDE_PER_I + LIMB_OVERRIDE_BASE_Y)) * 200.0f; - rot->z += Math_CosS(play->state.frames * (limbIndex * LIMB_OVERRIDE_PER_I + LIMB_OVERRIDE_BASE_Z)) * 200.0f; + rot->y += Math_SinS(play->state.frames * (limbIndex * FIDGET_MUL_I + FIDGET_ADD_Y)) * FIDGET_SCALE; + rot->z += Math_CosS(play->state.frames * (limbIndex * FIDGET_MUL_I + FIDGET_ADD_Z)) * FIDGET_SCALE; } return 0; } diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.c b/src/overlays/actors/ovl_En_Go/z_en_go.c index ce3891a6c3..5d245f2d83 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -1033,7 +1033,7 @@ void EnGo_Update(Actor* thisx, PlayState* play) { if (this->actionFunc == EnGo_BiggoronActionFunc || this->actionFunc == EnGo_FireGenericActionFunc || this->actionFunc == func_80A40B1C) { - UpdateLimbOverrides(play, this->limbOverridesY, this->limbOverridesZ, GORON_LIMB_MAX); + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, GORON_LIMB_MAX); } EnGo_UpdateShadow(this); @@ -1103,8 +1103,8 @@ s32 EnGo_OverrideLimbDraw(PlayState* play, s32 limb, Gfx** dList, Vec3f* pos, Ve } if ((limb == 10) || (limb == 11) || (limb == 14)) { - rot->y += Math_SinS(this->limbOverridesY[limb]) * 200.0f; - rot->z += Math_CosS(this->limbOverridesZ[limb]) * 200.0f; + rot->y += Math_SinS(this->fidgetTableY[limb]) * FIDGET_SCALE; + rot->z += Math_CosS(this->fidgetTableZ[limb]) * FIDGET_SCALE; } return 0; diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.h b/src/overlays/actors/ovl_En_Go/z_en_go.h index 9fef27ace4..815a2999bd 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.h +++ b/src/overlays/actors/ovl_En_Go/z_en_go.h @@ -56,8 +56,8 @@ typedef struct EnGo { /* 0x021A */ s16 unk_21A; /* 0x021C */ s16 unk_21C; /* 0x021E */ s16 unk_21E; - /* 0x0220 */ s16 limbOverridesY[GORON_LIMB_MAX]; - /* 0x0244 */ s16 limbOverridesZ[GORON_LIMB_MAX]; + /* 0x0220 */ s16 fidgetTableY[GORON_LIMB_MAX]; + /* 0x0244 */ s16 fidgetTableZ[GORON_LIMB_MAX]; /* 0x0268 */ EnGoEffect effects[EN_GO_EFFECT_COUNT]; } EnGo; // size = 0x06C8 diff --git a/src/overlays/actors/ovl_En_Go2/z_en_go2.c b/src/overlays/actors/ovl_En_Go2/z_en_go2.c index acd05a3db4..ee645b353c 100644 --- a/src/overlays/actors/ovl_En_Go2/z_en_go2.c +++ b/src/overlays/actors/ovl_En_Go2/z_en_go2.c @@ -1995,7 +1995,7 @@ void EnGo2_Update(Actor* thisx, PlayState* play) { #endif this->actionFunc(this, play); if (this->unk_211 == true) { - UpdateLimbOverrides(play, this->limbOverridesY, this->limbOverridesZ, GORON2_LIMB_MAX); + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, GORON2_LIMB_MAX); } func_80A45288(this, play); EnGo2_EyeMouthTexState(this); @@ -2048,8 +2048,8 @@ s32 EnGo2_OverrideLimbDraw(PlayState* play, s32 limb, Gfx** dList, Vec3f* pos, V Matrix_RotateX(BINANG_TO_RAD_ALT(limbRot.x), MTXMODE_APPLY); } if ((limb == 10) || (limb == 11) || (limb == 14)) { - rot->y += Math_SinS(this->limbOverridesY[limb]) * 200.0f; - rot->z += Math_CosS(this->limbOverridesZ[limb]) * 200.0f; + rot->y += Math_SinS(this->fidgetTableY[limb]) * FIDGET_SCALE; + rot->z += Math_CosS(this->fidgetTableZ[limb]) * FIDGET_SCALE; } return 0; } diff --git a/src/overlays/actors/ovl_En_Go2/z_en_go2.h b/src/overlays/actors/ovl_En_Go2/z_en_go2.h index 0eef6a3980..2549d3c9b5 100644 --- a/src/overlays/actors/ovl_En_Go2/z_en_go2.h +++ b/src/overlays/actors/ovl_En_Go2/z_en_go2.h @@ -94,8 +94,8 @@ typedef struct EnGo2 { /* 0x021C */ char unk_21C[0x04]; /* 0x0220 */ f32 alpha; // Set to 0, used by func_80A45360, smoothed to this->actor.shape.shadowAlpha from either 0 or 255.0f /* 0x0224 */ s16 blinkTimer; - /* 0x0226 */ s16 limbOverridesY[GORON2_LIMB_MAX]; - /* 0x024A */ s16 limbOverridesZ[GORON2_LIMB_MAX]; + /* 0x0226 */ s16 fidgetTableY[GORON2_LIMB_MAX]; + /* 0x024A */ s16 fidgetTableZ[GORON2_LIMB_MAX]; /* 0x026E */ u16 trackingMode; /* 0x0270 */ EnGoEffect effects[EN_GO2_EFFECT_COUNT]; /* 0x04A0 */ Vec3f subCamEye; diff --git a/src/overlays/actors/ovl_En_Guest/z_en_guest.c b/src/overlays/actors/ovl_En_Guest/z_en_guest.c index 98be425618..1f61c4301b 100644 --- a/src/overlays/actors/ovl_En_Guest/z_en_guest.c +++ b/src/overlays/actors/ovl_En_Guest/z_en_guest.c @@ -157,7 +157,7 @@ void func_80A505CC(Actor* thisx, PlayState* play) { } Npc_TrackPoint(&this->actor, &this->interactInfo, 6, NPC_TRACKING_HEAD_AND_TORSO); - UpdateLimbOverrides(play, this->limbOverridesY, this->limbOverridesZ, GUEST_LIMB_MAX); + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, GUEST_LIMB_MAX); gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[this->osAnimeObjectSlot].segment); @@ -200,8 +200,8 @@ s32 EnGuest_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* } if (limbIndex == 8 || limbIndex == 9 || limbIndex == 12) { - rot->y += Math_SinS(this->limbOverridesY[limbIndex]) * 200.0f; - rot->z += Math_CosS(this->limbOverridesZ[limbIndex]) * 200.0f; + rot->y += Math_SinS(this->fidgetTableY[limbIndex]) * FIDGET_SCALE; + rot->z += Math_CosS(this->fidgetTableZ[limbIndex]) * FIDGET_SCALE; } CLOSE_DISPS(play->state.gfxCtx, "../z_en_guest.c", 388); diff --git a/src/overlays/actors/ovl_En_Guest/z_en_guest.h b/src/overlays/actors/ovl_En_Guest/z_en_guest.h index 8ce55dab4f..e8592f7f89 100644 --- a/src/overlays/actors/ovl_En_Guest/z_en_guest.h +++ b/src/overlays/actors/ovl_En_Guest/z_en_guest.h @@ -20,8 +20,8 @@ typedef struct EnGuest { /* 0x02A0 */ NpcInteractInfo interactInfo; /* 0x02C8 */ s16 unk_2C8; /* 0x02CA */ s16 unk_2CA; - /* 0x02CC */ s16 limbOverridesY[GUEST_LIMB_MAX]; - /* 0x02EC */ s16 limbOverridesZ[GUEST_LIMB_MAX]; + /* 0x02CC */ s16 fidgetTableY[GUEST_LIMB_MAX]; + /* 0x02EC */ s16 fidgetTableZ[GUEST_LIMB_MAX]; /* 0x030C */ s8 osAnimeObjectSlot; /* 0x030D */ u8 unk_30D; /* 0x030E */ u8 unk_30E; diff --git a/src/overlays/actors/ovl_En_Hy/z_en_hy.c b/src/overlays/actors/ovl_En_Hy/z_en_hy.c index 86ad6ed7ca..4cbe010cbe 100644 --- a/src/overlays/actors/ovl_En_Hy/z_en_hy.c +++ b/src/overlays/actors/ovl_En_Hy/z_en_hy.c @@ -1252,7 +1252,7 @@ void EnHy_Walk(EnHy* this, PlayState* play) { } void EnHy_Fidget(EnHy* this, PlayState* play) { - UpdateLimbOverrides(play, this->limbOverridesY, this->limbOverridesZ, ENHY_LIMB_MAX); + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, ENHY_LIMB_MAX); } void EnHy_DoNothing(EnHy* this, PlayState* play) { @@ -1265,7 +1265,7 @@ void EnHy_SetupPace(EnHy* this, PlayState* play) { this->actionFunc = EnHy_Pace; } - UpdateLimbOverrides(play, this->limbOverridesY, this->limbOverridesZ, ENHY_LIMB_MAX); + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, ENHY_LIMB_MAX); } void EnHy_Pace(EnHy* this, PlayState* play) { @@ -1390,8 +1390,8 @@ s32 EnHy_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po if ((limbIndex == ENHY_LIMB_TORSO) || (limbIndex == ENHY_LIMB_LEFT_UPPER_ARM) || (limbIndex == ENHY_LIMB_RIGHT_UPPER_ARM)) { - rot->y += Math_SinS(this->limbOverridesY[limbIndex]) * 200.0f; - rot->z += Math_CosS(this->limbOverridesZ[limbIndex]) * 200.0f; + rot->y += Math_SinS(this->fidgetTableY[limbIndex]) * FIDGET_SCALE; + rot->z += Math_CosS(this->fidgetTableZ[limbIndex]) * FIDGET_SCALE; } CLOSE_DISPS(play->state.gfxCtx, "../z_en_hy.c", 2228); diff --git a/src/overlays/actors/ovl_En_Hy/z_en_hy.h b/src/overlays/actors/ovl_En_Hy/z_en_hy.h index d83b1858a6..a5c04ed3ab 100644 --- a/src/overlays/actors/ovl_En_Hy/z_en_hy.h +++ b/src/overlays/actors/ovl_En_Hy/z_en_hy.h @@ -74,8 +74,8 @@ typedef struct EnHy { /* 0x0216 */ char unk_216[2]; // unused /* 0x0218 */ s16 curEyeIndex; /* 0x021A */ s16 nextEyeIndexTimer; - /* 0x021C */ s16 limbOverridesY[ENHY_LIMB_MAX]; - /* 0x023C */ s16 limbOverridesZ[ENHY_LIMB_MAX]; + /* 0x021C */ s16 fidgetTableY[ENHY_LIMB_MAX]; + /* 0x023C */ s16 fidgetTableZ[ENHY_LIMB_MAX]; /* 0x025C */ f32 interactRange; /* 0x0260 */ s32 getItemId; /* 0x0264 */ Vec3f modelOffset; diff --git a/src/overlays/actors/ovl_En_Ko/z_en_ko.c b/src/overlays/actors/ovl_En_Ko/z_en_ko.c index da0c4080da..26f873c89e 100644 --- a/src/overlays/actors/ovl_En_Ko/z_en_ko.c +++ b/src/overlays/actors/ovl_En_Ko/z_en_ko.c @@ -709,7 +709,7 @@ s32 func_80A97D68(EnKo* this, PlayState* play) { s32 func_80A97E18(EnKo* this, PlayState* play) { s16 trackingMode; - UpdateLimbOverrides(play, this->limbOverridesY, this->limbOverridesZ, KOKIRI_LIMB_MAX); + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, KOKIRI_LIMB_MAX); if (EnKo_IsWithinTalkAngle(this) == true) { trackingMode = NPC_TRACKING_HEAD_AND_TORSO; } else { @@ -728,7 +728,7 @@ s32 func_80A97EB0(EnKo* this, PlayState* play) { s16 trackingMode; s32 result; - UpdateLimbOverrides(play, this->limbOverridesY, this->limbOverridesZ, KOKIRI_LIMB_MAX); + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, KOKIRI_LIMB_MAX); result = EnKo_IsWithinTalkAngle(this); trackingMode = (result == true) ? NPC_TRACKING_HEAD_AND_TORSO : NPC_TRACKING_NONE; Npc_TrackPoint(&this->actor, &this->interactInfo, 2, trackingMode); @@ -736,7 +736,7 @@ s32 func_80A97EB0(EnKo* this, PlayState* play) { } s32 func_80A97F20(EnKo* this, PlayState* play) { - UpdateLimbOverrides(play, this->limbOverridesY, this->limbOverridesZ, KOKIRI_LIMB_MAX); + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, KOKIRI_LIMB_MAX); Npc_TrackPoint(&this->actor, &this->interactInfo, 2, NPC_TRACKING_FULL_BODY); return 1; } @@ -748,7 +748,7 @@ s32 func_80A97F70(EnKo* this, PlayState* play) { if ((this->skelAnime.animation == &gKokiriBlockingAnim) == false) { Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENKO_ANIM_BLOCKING_STATIC); } - UpdateLimbOverrides(play, this->limbOverridesY, this->limbOverridesZ, KOKIRI_LIMB_MAX); + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, KOKIRI_LIMB_MAX); trackingMode = NPC_TRACKING_HEAD_AND_TORSO; } else { if ((this->skelAnime.animation == &gKokiriCuttingGrassAnim) == false) { @@ -768,7 +768,7 @@ s32 func_80A98034(EnKo* this, PlayState* play) { if ((this->skelAnime.animation == &gKokiriBlockingAnim) == false) { Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENKO_ANIM_BLOCKING_STATIC); } - UpdateLimbOverrides(play, this->limbOverridesY, this->limbOverridesZ, KOKIRI_LIMB_MAX); + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, KOKIRI_LIMB_MAX); result = EnKo_IsWithinTalkAngle(this); trackingMode = (result == true) ? NPC_TRACKING_HEAD_AND_TORSO : NPC_TRACKING_NONE; } else { @@ -784,7 +784,7 @@ s32 func_80A98034(EnKo* this, PlayState* play) { // Same as func_80A97F20 s32 func_80A98124(EnKo* this, PlayState* play) { - UpdateLimbOverrides(play, this->limbOverridesY, this->limbOverridesZ, KOKIRI_LIMB_MAX); + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, KOKIRI_LIMB_MAX); Npc_TrackPoint(&this->actor, &this->interactInfo, 2, NPC_TRACKING_FULL_BODY); return 1; } @@ -798,7 +798,7 @@ s32 func_80A98174(EnKo* this, PlayState* play) { this->skelAnime.playSpeed = 1.0f; } if (this->skelAnime.playSpeed == 0.0f) { - UpdateLimbOverrides(play, this->limbOverridesY, this->limbOverridesZ, KOKIRI_LIMB_MAX); + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, KOKIRI_LIMB_MAX); } Npc_TrackPoint(&this->actor, &this->interactInfo, 2, (this->skelAnime.playSpeed == 0.0f) ? NPC_TRACKING_HEAD_AND_TORSO : NPC_TRACKING_NONE); @@ -1335,8 +1335,8 @@ s32 EnKo_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po Matrix_Translate(-1200.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == 8 || limbIndex == 9 || limbIndex == 12) { - rot->y += Math_SinS(this->limbOverridesY[limbIndex]) * 200.0f; - rot->z += Math_CosS(this->limbOverridesZ[limbIndex]) * 200.0f; + rot->y += Math_SinS(this->fidgetTableY[limbIndex]) * FIDGET_SCALE; + rot->z += Math_CosS(this->fidgetTableZ[limbIndex]) * FIDGET_SCALE; } return false; } diff --git a/src/overlays/actors/ovl_En_Ko/z_en_ko.h b/src/overlays/actors/ovl_En_Ko/z_en_ko.h index 4e00f3e7ac..8b8fb27c28 100644 --- a/src/overlays/actors/ovl_En_Ko/z_en_ko.h +++ b/src/overlays/actors/ovl_En_Ko/z_en_ko.h @@ -30,8 +30,8 @@ typedef struct EnKo { /* 0x0220 */ f32 modelAlpha; /* 0x0224 */ Vec3s jointTable[KOKIRI_LIMB_MAX]; /* 0x0284 */ Vec3s morphTable[KOKIRI_LIMB_MAX]; - /* 0x02E4 */ s16 limbOverridesY[KOKIRI_LIMB_MAX]; - /* 0x0304 */ s16 limbOverridesZ[KOKIRI_LIMB_MAX]; + /* 0x02E4 */ s16 fidgetTableY[KOKIRI_LIMB_MAX]; + /* 0x0304 */ s16 fidgetTableZ[KOKIRI_LIMB_MAX]; } EnKo; // size = 0x0324 typedef enum KokiriChildren { diff --git a/src/overlays/actors/ovl_En_Kz/z_en_kz.c b/src/overlays/actors/ovl_En_Kz/z_en_kz.c index d798fcb38b..b19296a46c 100644 --- a/src/overlays/actors/ovl_En_Kz/z_en_kz.c +++ b/src/overlays/actors/ovl_En_Kz/z_en_kz.c @@ -416,7 +416,7 @@ void EnKz_PreMweepWait(EnKz* this, PlayState* play) { this->interactInfo.talkState = NPC_TALK_STATE_IDLE; this->actionFunc = EnKz_SetupMweep; } else { - UpdateLimbOverrides(play, this->limbOverridesY, this->limbOverridesZ, KINGZORA_LIMB_MAX); + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, KINGZORA_LIMB_MAX); } } @@ -479,7 +479,7 @@ void EnKz_Wait(EnKz* this, PlayState* play) { this->actionFunc = EnKz_SetupGetItem; EnKz_SetupGetItem(this, play); } else { - UpdateLimbOverrides(play, this->limbOverridesY, this->limbOverridesZ, KINGZORA_LIMB_MAX); + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, KINGZORA_LIMB_MAX); } } @@ -546,8 +546,8 @@ s32 EnKz_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po EnKz* this = (EnKz*)thisx; if (limbIndex == 8 || limbIndex == 9 || limbIndex == 10) { - rot->y += Math_SinS(this->limbOverridesY[limbIndex]) * 200.0f; - rot->z += Math_CosS(this->limbOverridesZ[limbIndex]) * 200.0f; + rot->y += Math_SinS(this->fidgetTableY[limbIndex]) * FIDGET_SCALE; + rot->z += Math_CosS(this->fidgetTableZ[limbIndex]) * FIDGET_SCALE; } if (limbIndex) {} return false; diff --git a/src/overlays/actors/ovl_En_Kz/z_en_kz.h b/src/overlays/actors/ovl_En_Kz/z_en_kz.h index 9496890e77..7cccfd0c9b 100644 --- a/src/overlays/actors/ovl_En_Kz/z_en_kz.h +++ b/src/overlays/actors/ovl_En_Kz/z_en_kz.h @@ -26,8 +26,8 @@ typedef struct EnKz { /* 0x0214 */ s16 returnToCamId; /* 0x0216 */ Vec3s jointTable[KINGZORA_LIMB_MAX]; /* 0x025E */ Vec3s morphTable[KINGZORA_LIMB_MAX]; - /* 0x02A6 */ s16 limbOverridesY[KINGZORA_LIMB_MAX]; - /* 0x02BE */ s16 limbOverridesZ[KINGZORA_LIMB_MAX]; + /* 0x02A6 */ s16 fidgetTableY[KINGZORA_LIMB_MAX]; + /* 0x02BE */ s16 fidgetTableZ[KINGZORA_LIMB_MAX]; } EnKz; // size = 0x02D8 #endif diff --git a/src/overlays/actors/ovl_En_Md/z_en_md.c b/src/overlays/actors/ovl_En_Md/z_en_md.c index c8c6789b0e..864b44f11e 100644 --- a/src/overlays/actors/ovl_En_Md/z_en_md.c +++ b/src/overlays/actors/ovl_En_Md/z_en_md.c @@ -695,7 +695,7 @@ void EnMd_Destroy(Actor* thisx, PlayState* play) { void func_80AAB874(EnMd* this, PlayState* play) { if (this->skelAnime.animation == &gMidoHandsOnHipsIdleAnim) { - UpdateLimbOverrides(play, this->limbOverridesY, this->limbOverridesZ, ENMD_LIMB_MAX); + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, ENMD_LIMB_MAX); } else if ((this->interactInfo.talkState == NPC_TALK_STATE_IDLE) && (this->unk_20B != 7)) { func_80AAA92C(this, 7); } @@ -705,7 +705,7 @@ void func_80AAB874(EnMd* this, PlayState* play) { void func_80AAB8F8(EnMd* this, PlayState* play) { if (this->skelAnime.animation == &gMidoHandsOnHipsIdleAnim) { - UpdateLimbOverrides(play, this->limbOverridesY, this->limbOverridesZ, ENMD_LIMB_MAX); + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, ENMD_LIMB_MAX); } func_80AAA93C(this); } @@ -757,7 +757,7 @@ void func_80AAB948(EnMd* this, PlayState* play) { } if (this->skelAnime.animation == &gMidoHandsOnHipsIdleAnim) { - UpdateLimbOverrides(play, this->limbOverridesY, this->limbOverridesZ, ENMD_LIMB_MAX); + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, ENMD_LIMB_MAX); } if ((this->interactInfo.talkState == NPC_TALK_STATE_IDLE) && (play->sceneId == SCENE_LOST_WOODS)) { @@ -795,7 +795,7 @@ void func_80AABC10(EnMd* this, PlayState* play) { } void func_80AABD0C(EnMd* this, PlayState* play) { - UpdateLimbOverrides(play, this->limbOverridesY, this->limbOverridesZ, ENMD_LIMB_MAX); + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, ENMD_LIMB_MAX); func_80AAA93C(this); if (!(EnMd_FollowPath(this, play)) || (this->waypoint != 0)) { @@ -853,8 +853,8 @@ s32 EnMd_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po if (((limbIndex == ENMD_LIMB_TORSO) || (limbIndex == ENMD_LIMB_LEFT_UPPER_ARM)) || (limbIndex == ENMD_LIMB_RIGHT_UPPER_ARM)) { - rot->y += Math_SinS(this->limbOverridesY[limbIndex]) * 200.0f; - rot->z += Math_CosS(this->limbOverridesZ[limbIndex]) * 200.0f; + rot->y += Math_SinS(this->fidgetTableY[limbIndex]) * FIDGET_SCALE; + rot->z += Math_CosS(this->fidgetTableZ[limbIndex]) * FIDGET_SCALE; } return false; diff --git a/src/overlays/actors/ovl_En_Md/z_en_md.h b/src/overlays/actors/ovl_En_Md/z_en_md.h index afba531347..a30ebe047a 100644 --- a/src/overlays/actors/ovl_En_Md/z_en_md.h +++ b/src/overlays/actors/ovl_En_Md/z_en_md.h @@ -43,8 +43,8 @@ typedef struct EnMd { /* 0x020E */ s16 eyeIdx; /* 0x0210 */ s16 alpha; /* 0x0212 */ s16 waypoint; - /* 0x0214 */ s16 limbOverridesY[ENMD_LIMB_MAX]; - /* 0x0236 */ s16 limbOverridesZ[ENMD_LIMB_MAX]; + /* 0x0214 */ s16 fidgetTableY[ENMD_LIMB_MAX]; + /* 0x0236 */ s16 fidgetTableZ[ENMD_LIMB_MAX]; /* 0x0258 */ Vec3s jointTable[ENMD_LIMB_MAX]; /* 0x02BE */ Vec3s morphTable[ENMD_LIMB_MAX]; } EnMd; // size = 0x0324 diff --git a/src/overlays/actors/ovl_En_Mu/z_en_mu.c b/src/overlays/actors/ovl_En_Mu/z_en_mu.c index 230e952f52..92c9c37530 100644 --- a/src/overlays/actors/ovl_En_Mu/z_en_mu.c +++ b/src/overlays/actors/ovl_En_Mu/z_en_mu.c @@ -152,7 +152,7 @@ void EnMu_Destroy(Actor* thisx, PlayState* play) { } void EnMu_Pose(EnMu* this, PlayState* play) { - UpdateLimbOverrides(play, this->limbOverridesY, this->limbOverridesZ, MU_LIMB_MAX); + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, MU_LIMB_MAX); } void EnMu_Update(Actor* thisx, PlayState* play) { @@ -183,8 +183,8 @@ s32 EnMu_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po if ((limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 11) || (limbIndex == 12) || (limbIndex == 13) || (limbIndex == 14)) { - rot->y += Math_SinS(this->limbOverridesY[limbIndex]) * 200.0f; - rot->z += Math_CosS(this->limbOverridesZ[limbIndex]) * 200.0f; + rot->y += Math_SinS(this->fidgetTableY[limbIndex]) * FIDGET_SCALE; + rot->z += Math_CosS(this->fidgetTableZ[limbIndex]) * FIDGET_SCALE; } return false; } diff --git a/src/overlays/actors/ovl_En_Mu/z_en_mu.h b/src/overlays/actors/ovl_En_Mu/z_en_mu.h index faca5d7f8f..34dd20e984 100644 --- a/src/overlays/actors/ovl_En_Mu/z_en_mu.h +++ b/src/overlays/actors/ovl_En_Mu/z_en_mu.h @@ -8,7 +8,7 @@ struct EnMu; typedef void (*EnMuActionFunc)(struct EnMu*, struct PlayState*); -#define MU_LIMB_MAX 16 // @note: correct, because `UpdateLimbOverrides` uses it +#define MU_LIMB_MAX 16 // @note: correct, because `Actor_UpdateFidgetTables` uses it #define MU_LIMB_MAX_BUG 17 // @bug: should be the same value typedef struct EnMu { @@ -18,8 +18,8 @@ typedef struct EnMu { /* 0x0194 */ ColliderCylinder collider; /* 0x01E0 */ NpcInteractInfo npcInfo; /* 0x0208 */ u16 defaultTextId; - /* 0x020A */ s16 limbOverridesY[MU_LIMB_MAX]; - /* 0x022A */ s16 limbOverridesZ[MU_LIMB_MAX_BUG]; + /* 0x020A */ s16 fidgetTableY[MU_LIMB_MAX]; + /* 0x022A */ s16 fidgetTableZ[MU_LIMB_MAX_BUG]; } EnMu; // size = 0x024C #endif diff --git a/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c b/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c index c1faa659c0..d26f38d352 100644 --- a/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c +++ b/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c @@ -578,11 +578,8 @@ s32 EnNiwLady_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3 } if (this->unk_275 != 0) { if ((limbIndex == 8) || (limbIndex == 10) || (limbIndex == 13)) { - // pad = limbIndex * LIMB_OVERRIDE_PER_I; // likely - rot->y += - Math_SinS((play->state.frames * (limbIndex * LIMB_OVERRIDE_PER_I + LIMB_OVERRIDE_BASE_Y))) * 200.0f; - rot->z += - Math_CosS((play->state.frames * (limbIndex * LIMB_OVERRIDE_PER_I + LIMB_OVERRIDE_BASE_Z))) * 200.0f; + rot->y += Math_SinS((play->state.frames * (limbIndex * FIDGET_MUL_I + FIDGET_ADD_Y))) * FIDGET_SCALE; + rot->z += Math_CosS((play->state.frames * (limbIndex * FIDGET_MUL_I + FIDGET_ADD_Z))) * FIDGET_SCALE; } } return false; diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/src/overlays/actors/ovl_En_Sth/z_en_sth.c index 003f3d3b58..cd832985a5 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -350,9 +350,9 @@ s32 EnSth_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p } if ((limbIndex == 8) || (limbIndex == 10) || (limbIndex == 13)) { - overridePerLimb = limbIndex * LIMB_OVERRIDE_PER_I; - rot->y += Math_SinS(play->state.frames * (overridePerLimb + LIMB_OVERRIDE_BASE_Y)) * 200.0f; - rot->z += Math_CosS(play->state.frames * (overridePerLimb + LIMB_OVERRIDE_BASE_Z)) * 200.0f; + overridePerLimb = limbIndex * FIDGET_MUL_I; + rot->y += Math_SinS(play->state.frames * (overridePerLimb + FIDGET_ADD_Y)) * FIDGET_SCALE; + rot->z += Math_CosS(play->state.frames * (overridePerLimb + FIDGET_ADD_Z)) * FIDGET_SCALE; } return 0; } diff --git a/src/overlays/actors/ovl_En_Ta/z_en_ta.c b/src/overlays/actors/ovl_En_Ta/z_en_ta.c index 3f90df4a8e..7be366360d 100644 --- a/src/overlays/actors/ovl_En_Ta/z_en_ta.c +++ b/src/overlays/actors/ovl_En_Ta/z_en_ta.c @@ -1282,10 +1282,10 @@ s32 EnTa_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po this->stateFlags &= ~TALON_STATE_FLAG_SUPPRESS_ROCKING_ANIM; } else if ((limbIndex == ENTA_LIMB_CHEST) || (limbIndex == ENTA_LIMB_LEFT_ARM) || (limbIndex == ENTA_LIMB_RIGHT_ARM)) { - s32 overridePerLimb = limbIndex * LIMB_OVERRIDE_PER_I; + s32 overridePerLimb = limbIndex * FIDGET_MUL_I; - rot->y += Math_SinS(play->state.frames * (overridePerLimb + LIMB_OVERRIDE_BASE_Y)) * 200.0f; - rot->z += Math_CosS(play->state.frames * (overridePerLimb + LIMB_OVERRIDE_BASE_Z)) * 200.0f; + rot->y += Math_SinS(play->state.frames * (overridePerLimb + FIDGET_ADD_Y)) * FIDGET_SCALE; + rot->z += Math_CosS(play->state.frames * (overridePerLimb + FIDGET_ADD_Z)) * FIDGET_SCALE; } return false; diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 643b425ee8..29b7a79f30 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -612,7 +612,7 @@ void EnZo_Destroy(Actor* thisx, PlayState* play) { void EnZo_Standing(EnZo* this, PlayState* play) { s16 angle; - UpdateLimbOverrides(play, this->limbOverridesY, this->limbOverridesZ, ZORA_LIMB_MAX); + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, ZORA_LIMB_MAX); EnZo_SetAnimation(this); if (this->interactInfo.talkState != NPC_TALK_STATE_IDLE) { this->trackingMode = NPC_TRACKING_FULL_BODY; @@ -654,7 +654,7 @@ void EnZo_Surface(EnZo* this, PlayState* play) { } void EnZo_TreadWater(EnZo* this, PlayState* play) { - UpdateLimbOverrides(play, this->limbOverridesY, this->limbOverridesZ, ZORA_LIMB_MAX); + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, ZORA_LIMB_MAX); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->canSpeak = true; this->trackingMode = NPC_TRACKING_FULL_BODY; @@ -770,8 +770,8 @@ s32 EnZo_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po } if ((limbIndex == 8) || (limbIndex == 9) || (limbIndex == 12)) { - rot->y += (Math_SinS(this->limbOverridesY[limbIndex]) * 200.0f); - rot->z += (Math_CosS(this->limbOverridesZ[limbIndex]) * 200.0f); + rot->y += Math_SinS(this->fidgetTableY[limbIndex]) * FIDGET_SCALE; + rot->z += Math_CosS(this->fidgetTableZ[limbIndex]) * FIDGET_SCALE; } return 0; diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.h b/src/overlays/actors/ovl_En_Zo/z_en_zo.h index 65f09882ea..9713b0abd6 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.h +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.h @@ -40,8 +40,8 @@ typedef struct EnZo { /* 0x0650 */ s16 timeToDive; /* 0x0652 */ s16 blinkTimer; /* 0x0654 */ s16 eyeTexture; - /* 0x0656 */ s16 limbOverridesY[ZORA_LIMB_MAX]; - /* 0x067E */ s16 limbOverridesZ[ZORA_LIMB_MAX]; + /* 0x0656 */ s16 fidgetTableY[ZORA_LIMB_MAX]; + /* 0x067E */ s16 fidgetTableZ[ZORA_LIMB_MAX]; } EnZo; // size = 0x06A8 #endif