summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorDerek Hensley <hensley.derek58@gmail.com>2023-07-06 14:54:43 -0700
committerGitHub <noreply@github.com>2023-07-07 07:54:43 +1000
commita506e8620ae8f428ae625644aa5b8d540867641f (patch)
tree3cd80c563bea5818d6dcfae2c979b143656bd367 /src/code
parent3bb9b365fcb312862e9c713cf44b28403a7edb94 (diff)
Fidget Tables Docs (#1316)
* Docs for SubS_FillLimbRotTables and Actor_FillLimbRotTables * Fidget * Format * /// * UpdateFidgetTables * Clarify comment * Adjust comments slightly * Update src/code/z_actor.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sub_s.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> --------- Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>
Diffstat (limited to 'src/code')
-rw-r--r--src/code/z_actor.c22
-rw-r--r--src/code/z_sub_s.c21
2 files changed, 33 insertions, 10 deletions
diff --git a/src/code/z_actor.c b/src/code/z_actor.c
index 7e6ea1662..094b36787 100644
--- a/src/code/z_actor.c
+++ b/src/code/z_actor.c
@@ -4464,14 +4464,26 @@ void Actor_ChangeAnimationByInfo(SkelAnime* skelAnime, AnimationInfo* animationI
frameCount, animationInfo->mode, animationInfo->morphFrames);
}
-// Unused
-void func_800BDCF4(PlayState* play, s16* arg1, s16* arg2, s32 size) {
+/**
+ * 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: This function goes unused in favor of `SubS_UpdateFidgetTables`.
+ */
+void Actor_UpdateFidgetTables(PlayState* play, s16* fidgetTableY, s16* fidgetTableZ, s32 tableLen) {
s32 frames = play->gameplayFrames;
s32 i;
- for (i = 0; i < size; i++) {
- arg1[i] = (0x814 + 50 * i) * frames;
- arg2[i] = (0x940 + 50 * i) * frames;
+ for (i = 0; i < tableLen; i++) {
+ fidgetTableY[i] = (i * 50 + 0x814) * frames;
+ fidgetTableZ[i] = (i * 50 + 0x940) * frames;
}
}
diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c
index 1c3f1ae3a..0f09f5912 100644
--- a/src/code/z_sub_s.c
+++ b/src/code/z_sub_s.c
@@ -1186,13 +1186,24 @@ Actor* SubS_FindActor(PlayState* play, Actor* actorListStart, u8 actorCategory,
return actor;
}
-s32 SubS_FillLimbRotTables(PlayState* play, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs) {
- s32 i;
+/**
+ * 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.
+ */
+s32 SubS_UpdateFidgetTables(PlayState* play, s16* fidgetTableY, s16* fidgetTableZ, s32 tableLen) {
u32 frames = play->gameplayFrames;
+ s32 i;
- for (i = 0; i < numLimbs; i++) {
- limbRotTableY[i] = (i * 50 + 0x814) * frames;
- limbRotTableZ[i] = (i * 50 + 0x940) * frames;
+ for (i = 0; i < tableLen; i++) {
+ fidgetTableY[i] = (i * 50 + 0x814) * frames;
+ fidgetTableZ[i] = (i * 50 + 0x940) * frames;
}
return true;