summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfig02 <fig02srl@gmail.com>2024-07-21 19:27:25 -0400
committerGitHub <noreply@github.com>2024-07-21 19:27:25 -0400
commitab2ca85227bb4ed245d3a39faedc25f793a39a45 (patch)
treef09755bb09ec2966d0677a759894242127a4dbb7
parent2361a333078b2945a0f6a81025f1726f89ffdd43 (diff)
Rename `ANIM_FLAG_NO_MOVE` to `ANIM_FLAG_ADJUST_STARTING_POS` (#1981)
* rename flag and draft 1 of comment * draft 2 * tweak wording * format * format
-rw-r--r--include/z64animation.h22
-rw-r--r--src/code/z_skelanime.c6
-rw-r--r--src/overlays/actors/ovl_player_actor/z_player.c45
3 files changed, 47 insertions, 26 deletions
diff --git a/include/z64animation.h b/include/z64animation.h
index 2365db14b..782380ad2 100644
--- a/include/z64animation.h
+++ b/include/z64animation.h
@@ -112,8 +112,28 @@ typedef enum {
// (player-only) Call AnimTaskQueue_AddActorMove
#define ANIM_FLAG_PLAYER_SETMOVE (1 << 3)
+// When this flag is set, movement in all axes will not be applied for one frame. The flag
+// is unset automatically after one use, so movement can resume. The intent is for this flag to be used
+// when changing between two different animations.
+// In some contexts, disabling the first frame of movement is necessary for a seamless transition.
//
-#define ANIM_FLAG_NO_MOVE (1 << 4)
+// Depending on specific implementations, an actor may choose to reset `prevTransl` to `baseTransl` when
+// starting a new animation. This is helpful when an animation's translation data starts at the "origin"
+// (in this case, the origin refers to `baseTransl`, in model space).
+// Some animations have translation data that does not begin at the "origin". This is common when a
+// longer sequence of animation is broken up into different parts as seperate animations.
+// In this case, when one animation starts its translation at the same position where a different animation
+// left off, resetting `prevTransl` is not desireable. This will cause the actor's position to noticeably change
+// when the translation data from the first frame of the new animation is applied.
+//
+// When this flag is used during a transition between two animations, the first frame of movement is not applied.
+// This allows the actor's world postiion to stay at the same location as where the previous animation ended.
+// Because translations are calculated as a difference from the current and previous frame, all subsequent
+// frames have their translation occur relative to this new starting point.
+//
+// Note that for Player, this flag is only relevant when transitioning from an animation that was also using
+// animation translation. This is because of how `prevTransl` gets reset in `Player_AnimReplaceApplyFlags`.
+#define ANIM_FLAG_ADJUST_STARTING_POS (1 << 4)
// Disables "normal" movement from sources like speed/velocity and collisions, which allows the
// animation to have full control over the actor's movement.
diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c
index bef23de1e..c7ea06fd5 100644
--- a/src/code/z_skelanime.c
+++ b/src/code/z_skelanime.c
@@ -1839,7 +1839,7 @@ void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* diff, s16 angle) {
f32 cos;
// If `ANIM_FLAG_UPDATE_XZ` behaved as expected, it would also be checked here
- if (skelAnime->moveFlags & ANIM_FLAG_NO_MOVE) {
+ if (skelAnime->moveFlags & ANIM_FLAG_ADJUST_STARTING_POS) {
diff->x = diff->z = 0.0f;
} else {
x = skelAnime->jointTable[0].x;
@@ -1866,7 +1866,7 @@ void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* diff, s16 angle) {
skelAnime->jointTable[0].z = skelAnime->baseTransl.z;
if (skelAnime->moveFlags & ANIM_FLAG_UPDATE_Y) {
- if (skelAnime->moveFlags & ANIM_FLAG_NO_MOVE) {
+ if (skelAnime->moveFlags & ANIM_FLAG_ADJUST_STARTING_POS) {
diff->y = 0.0f;
} else {
diff->y = skelAnime->jointTable[0].y - skelAnime->prevTransl.y;
@@ -1879,7 +1879,7 @@ void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* diff, s16 angle) {
skelAnime->prevTransl.y = skelAnime->jointTable[0].y;
}
- skelAnime->moveFlags &= ~ANIM_FLAG_NO_MOVE;
+ skelAnime->moveFlags &= ~ANIM_FLAG_ADJUST_STARTING_POS;
}
/**
diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c
index c397d8ea5..9ac957cc0 100644
--- a/src/overlays/actors/ovl_player_actor/z_player.c
+++ b/src/overlays/actors/ovl_player_actor/z_player.c
@@ -2008,7 +2008,7 @@ void Player_AnimReplacePlayOnceAdjusted(PlayState* play, Player* this, LinkAnima
void Player_AnimReplaceNormalPlayOnceAdjusted(PlayState* play, Player* this, LinkAnimationHeader* anim) {
Player_AnimReplacePlayOnceAdjusted(play, this, anim,
- ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE);
+ ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_ADJUST_STARTING_POS);
}
void Player_AnimReplacePlayLoopSetSpeed(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags,
@@ -2027,7 +2027,7 @@ void Player_AnimReplacePlayLoopAdjusted(PlayState* play, Player* this, LinkAnima
void Player_AnimReplaceNormalPlayLoopAdjusted(PlayState* play, Player* this, LinkAnimationHeader* anim) {
Player_AnimReplacePlayLoopAdjusted(play, this, anim,
- ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE);
+ ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_ADJUST_STARTING_POS);
}
void Player_ProcessControlStick(PlayState* play, Player* this) {
@@ -3400,7 +3400,7 @@ s32 Player_UpdateUpperBody(Player* this, PlayState* play) {
Player_AnimPlayOnce(play, this, &gPlayerAnim_link_hook_fly_start);
Player_AnimReplaceApplyFlags(play, this,
ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_SETMOVE |
- ANIM_FLAG_NO_MOVE | ANIM_FLAG_OVERRIDE_MOVEMENT);
+ ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT);
func_80832224(this);
this->yaw = this->actor.shape.rot.y;
this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND;
@@ -5368,7 +5368,7 @@ s32 func_8083A6AC(Player* this, PlayState* play) {
this->stateFlags1 |= PLAYER_STATE1_21;
Player_AnimReplaceApplyFlags(play, this,
ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_2 |
- ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE |
+ ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_ADJUST_STARTING_POS |
ANIM_FLAG_OVERRIDE_MOVEMENT);
this->av2.actionVar2 = -1;
@@ -6724,7 +6724,7 @@ s32 Player_ActionChange_3(Player* this, PlayState* play) {
Player_AnimPlayOnce(play, this, D_80854578[temp].anim);
Player_AnimReplaceApplyFlags(play, this,
ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_SETMOVE |
- ANIM_FLAG_NO_MOVE | ANIM_FLAG_OVERRIDE_MOVEMENT);
+ ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT);
this->actor.parent = this->rideActor;
func_80832224(this);
@@ -7071,7 +7071,7 @@ s32 func_8083EC18(Player* this, PlayState* play, u32 wallFlags) {
Player_AnimPlayOnce(play, this, anim);
Player_AnimReplaceApplyFlags(play, this,
ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_2 |
- ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE |
+ ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_ADJUST_STARTING_POS |
ANIM_FLAG_OVERRIDE_MOVEMENT);
return true;
@@ -7153,7 +7153,7 @@ s32 Player_TryEnteringCrawlspace(Player* this, PlayState* play, u32 interactWall
Player_AnimPlayOnce(play, this, &gPlayerAnim_link_child_tunnel_start);
Player_AnimReplaceApplyFlags(play, this,
ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE |
- ANIM_FLAG_NO_MOVE | ANIM_FLAG_OVERRIDE_MOVEMENT);
+ ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT);
return true;
}
@@ -7243,7 +7243,7 @@ s32 Player_TryLeavingCrawlspace(Player* this, PlayState* play) {
Player_AnimPlayOnce(play, this, &gPlayerAnim_link_child_tunnel_end);
Player_AnimReplaceApplyFlags(play, this,
ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE |
- ANIM_FLAG_NO_MOVE | ANIM_FLAG_OVERRIDE_MOVEMENT);
+ ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT);
OnePointCutscene_Init(play, 9601, 999, NULL, CAM_ID_MAIN);
} else {
// Leaving a crawlspace backwards
@@ -7253,7 +7253,7 @@ s32 Player_TryLeavingCrawlspace(Player* this, PlayState* play) {
0.0f);
Player_AnimReplaceApplyFlags(play, this,
ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE |
- ANIM_FLAG_NO_MOVE | ANIM_FLAG_OVERRIDE_MOVEMENT);
+ ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT);
OnePointCutscene_Init(play, 9602, 999, NULL, CAM_ID_MAIN);
}
@@ -9983,7 +9983,7 @@ void func_808468A8(PlayState* play, Player* this) {
Player_SetupAction(play, this, Player_Action_8084F9A0, 0);
Player_AnimReplaceApplyFlags(play, this,
ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_SETMOVE |
- ANIM_FLAG_NO_MOVE | ANIM_FLAG_OVERRIDE_MOVEMENT);
+ ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT);
}
void func_808468E8(PlayState* play, Player* this) {
@@ -11139,7 +11139,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) {
Player_AnimPlayOnce(play, this, &gPlayerAnim_link_uma_wait_1);
Player_AnimReplaceApplyFlags(play, this,
ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_SETMOVE |
- ANIM_FLAG_NO_MOVE | ANIM_FLAG_OVERRIDE_MOVEMENT);
+ ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT);
this->av2.actionVar2 = 99;
}
@@ -14549,7 +14549,7 @@ void func_808510D4(PlayState* play, Player* this, void* anim) {
void func_808510F4(PlayState* play, Player* this, void* anim) {
Player_AnimReplacePlayOnce(play, this, anim,
- ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE |
+ ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_ADJUST_STARTING_POS |
ANIM_FLAG_OVERRIDE_MOVEMENT);
}
@@ -14559,7 +14559,7 @@ void func_80851114(PlayState* play, Player* this, void* anim) {
void func_80851134(PlayState* play, Player* this, void* anim) {
Player_AnimReplacePlayLoop(play, this, anim,
- ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE |
+ ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_ADJUST_STARTING_POS |
ANIM_FLAG_OVERRIDE_MOVEMENT);
}
@@ -14918,12 +14918,13 @@ void func_80851E28(PlayState* play, Player* this, CsCmdActorCue* cue) {
void func_80851E64(PlayState* play, Player* this, CsCmdActorCue* cue) {
Player_AnimReplacePlayOnceAdjusted(play, this, &gPlayerAnim_link_swimer_swim_get,
- ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_OVERRIDE_MOVEMENT);
+ ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_ADJUST_STARTING_POS |
+ ANIM_FLAG_OVERRIDE_MOVEMENT);
}
void func_80851E90(PlayState* play, Player* this, CsCmdActorCue* cue) {
Player_AnimReplacePlayOnce(play, this, &gPlayerAnim_clink_op3_negaeri,
- ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE |
+ ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_ADJUST_STARTING_POS |
ANIM_FLAG_OVERRIDE_MOVEMENT);
func_80832698(this, NA_SE_VO_LI_GROAN);
}
@@ -14931,7 +14932,7 @@ void func_80851E90(PlayState* play, Player* this, CsCmdActorCue* cue) {
void func_80851ECC(PlayState* play, Player* this, CsCmdActorCue* cue) {
if (LinkAnimation_Update(play, &this->skelAnime)) {
Player_AnimReplacePlayLoop(play, this, &gPlayerAnim_clink_op3_wait2,
- ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE |
+ ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_ADJUST_STARTING_POS |
ANIM_FLAG_OVERRIDE_MOVEMENT);
}
}
@@ -14959,7 +14960,7 @@ static AnimSfxEntry D_808551BC[] = {
void func_80851FB0(PlayState* play, Player* this, CsCmdActorCue* cue) {
if (LinkAnimation_Update(play, &this->skelAnime)) {
Player_AnimReplacePlayLoop(play, this, &gPlayerAnim_clink_op3_wait3,
- ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE |
+ ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_ADJUST_STARTING_POS |
ANIM_FLAG_OVERRIDE_MOVEMENT);
this->av2.actionVar2 = 1;
} else if (this->av2.actionVar2 == 0) {
@@ -14985,7 +14986,7 @@ void func_80852048(PlayState* play, Player* this, CsCmdActorCue* cue) {
void func_80852080(PlayState* play, Player* this, CsCmdActorCue* cue) {
Player_AnimReplacePlayOnceAdjusted(play, this, &gPlayerAnim_clink_demo_futtobi,
ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE |
- ANIM_FLAG_NO_MOVE | ANIM_FLAG_OVERRIDE_MOVEMENT);
+ ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT);
func_80832698(this, NA_SE_VO_LI_FALL_L);
}
@@ -15033,8 +15034,8 @@ void func_80852234(PlayState* play, Player* this, CsCmdActorCue* cue) {
}
void func_8085225C(PlayState* play, Player* this, CsCmdActorCue* cue) {
- Player_AnimReplaceApplyFlags(play, this,
- ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_OVERRIDE_MOVEMENT);
+ Player_AnimReplaceApplyFlags(
+ play, this, ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT);
}
void func_80852280(PlayState* play, Player* this, CsCmdActorCue* cue) {
@@ -15466,8 +15467,8 @@ void func_80853148(PlayState* play, Actor* actor) {
}
if (this->skelAnime.animation == &gPlayerAnim_link_normal_backspace) {
- Player_AnimReplaceApplyFlags(play, this,
- ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE);
+ Player_AnimReplaceApplyFlags(
+ play, this, ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_ADJUST_STARTING_POS);
}
func_80832224(this);