SubS Animations and LimbRotTables (#624)

* Bring over the matching code, rename struct vars to be consistent, and move animation structs to z64animation.h

* Clean up function prototypes

* Format and some stack var renames

* Update tutorial

* Rename animation structs

* Rename SubS functions

* Rename Actor function

* Rename arg names

* Bring over code for func_8013D9C8

* Rename and cleanup

* Some more cleanup

* Small cleanup

* Animmode enum

* Adjust actorfixer

* More uses of animmode enum, as well as fixing typo

* Change hex 0xD to 13

* typo

* Fix merge

* Format

* Fix merge

* Actorfixer

* Format
This commit is contained in:
Derek Hensley
2022-02-13 18:10:56 -08:00
committed by GitHub
parent 01ca078226
commit 6e62ae4075
69 changed files with 1390 additions and 1058 deletions
+1 -1
View File
@@ -4252,7 +4252,7 @@ s16 func_800BDB6C(Actor* actor, GlobalContext* globalCtx, s16 arg2, f32 arg3) {
return arg2;
}
void Actor_ChangeAnimation(SkelAnime* skelAnime, ActorAnimationEntry* animation, s32 index) {
void Actor_ChangeAnimationByInfo(SkelAnime* skelAnime, AnimationInfo* animation, s32 index) {
f32 frameCount;
animation += index;
+5 -5
View File
@@ -11,7 +11,7 @@
#include "objects/object_boj/object_boj.h"
#include "objects/object_os_anime/object_os_anime.h"
ActorAnimationEntryS sAnimations[] = {
static AnimationInfoS sAnimations[] = {
{ &object_aob_Anim_00007C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 },
{ &object_boj_Anim_001494, 1.0f, 0, -1, ANIMMODE_LOOP, 0 },
{ &object_boj_Anim_001494, 1.0f, 0, -1, ANIMMODE_LOOP, -8 },
@@ -49,11 +49,11 @@ s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) {
isChanged = true;
frameCount = sAnimations[animIndex].frameCount;
if (frameCount < 0) {
frameCount = Animation_GetLastFrame(&sAnimations[animIndex].animationSeg->common);
frameCount = Animation_GetLastFrame(&sAnimations[animIndex].animation->common);
}
Animation_Change(skelAnime, sAnimations[animIndex].animationSeg, sAnimations[animIndex].playbackSpeed,
sAnimations[animIndex].frame, frameCount, sAnimations[animIndex].mode,
sAnimations[animIndex].transitionRate);
Animation_Change(skelAnime, sAnimations[animIndex].animation, sAnimations[animIndex].playSpeed,
sAnimations[animIndex].startFrame, frameCount, sAnimations[animIndex].mode,
sAnimations[animIndex].morphFrames);
}
return isChanged;
}
+10 -10
View File
@@ -8,10 +8,10 @@ s32 LinkAnimation_Once(GlobalContext* globalCtx, SkelAnime* skelAnime);
s32 SkelAnime_LoopFull(SkelAnime* skelAnime);
s32 SkelAnime_LoopPartial(SkelAnime* skelAnime);
s32 SkelAnime_Once(SkelAnime* skelAnime);
void Animation_PlayLoop(SkelAnime* skelAnime, AnimationHeader* animationSeg);
void Animation_PlayLoop(SkelAnime* skelAnime, AnimationHeader* animation);
void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* pos, s16 angle);
void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg,
f32 playbackSpeed, f32 frame, f32 frameCount, u8 animationMode, f32 transitionRate);
void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed,
f32 frame, f32 frameCount, u8 animationMode, f32 morphFrames);
void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src);
static AnimationEntryCallback sAnimationLoadDone[] = {
@@ -1074,13 +1074,13 @@ void AnimationContext_SetCopyFalse(GlobalContext* globalCtx, s32 vecCount, Vec3s
/**
* Requests moving an actor according to the translation of its root limb
*/
void AnimationContext_SetMoveActor(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 actor3) {
void AnimationContext_SetMoveActor(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 arg3) {
AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_MOVEACTOR);
if (entry != NULL) {
entry->data.move.actor = actor;
entry->data.move.skelAnime = skelAnime;
entry->data.move.unk08 = actor3;
entry->data.move.unk08 = arg3;
}
}
@@ -1829,8 +1829,8 @@ void Animation_PlayOnce(SkelAnime* skelAnime, AnimationHeader* animation) {
* animation. Negative morph frames start the new animation immediately, modified by the pose immediately before the
* animation change.
*/
void Animation_MorphToPlayOnce(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 morphFrames) {
Animation_Change(skelAnime, animationSeg, 1.0f, 0, Animation_GetLastFrame(&animationSeg->common), ANIMMODE_ONCE,
void Animation_MorphToPlayOnce(SkelAnime* skelAnime, AnimationHeader* animation, f32 morphFrames) {
Animation_Change(skelAnime, animation, 1.0f, 0, Animation_GetLastFrame(&animation->common), ANIMMODE_ONCE,
morphFrames);
}
@@ -1862,9 +1862,9 @@ void Animation_MorphToLoop(SkelAnime* skelAnime, AnimationHeader* animation, f32
/**
* Immediately changes to an animation that loops at the specified speed.
*/
void Animation_PlayLoopSetSpeed(SkelAnime* skelAnime, AnimationHeader* animation, f32 playbackSpeed) {
Animation_Change(skelAnime, animation, playbackSpeed, 0.0f, Animation_GetLastFrame(&animation->common),
ANIMMODE_LOOP, 0.0f);
void Animation_PlayLoopSetSpeed(SkelAnime* skelAnime, AnimationHeader* animation, f32 playSpeed) {
Animation_Change(skelAnime, animation, playSpeed, 0.0f, Animation_GetLastFrame(&animation->common), ANIMMODE_LOOP,
0.0f);
}
/**
+59 -3
View File
@@ -205,7 +205,26 @@ Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCat
return closestActor;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BC6C.s")
s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations, s32 index) {
s32 endFrame;
s32 startFrame;
animations += index;
endFrame = animations->frameCount;
if (animations->frameCount < 0) {
endFrame = Animation_GetLastFrame(&animations->animation->common);
}
startFrame = animations->startFrame;
if (startFrame >= endFrame || startFrame < 0) {
return false;
}
if (animations->playSpeed < 0.0f) {
SWAP(s32, endFrame, startFrame);
}
Animation_Change(skelAnime, animations->animation, animations->playSpeed, startFrame, endFrame, animations->mode,
animations->morphFrames);
return true;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BD40.s")
@@ -262,7 +281,17 @@ Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorC
return actor;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D9C8.s")
s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 limbRotTableLen) {
s32 i;
u32 frames = globalCtx->gameplayFrames;
for (i = 0; i < limbRotTableLen; i++) {
limbRotTableY[i] = (i * 50 + 0x814) * frames;
limbRotTableZ[i] = (i * 50 + 0x940) * frames;
}
return true;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DB90.s")
@@ -282,7 +311,34 @@ Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorC
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E0A4.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E1C8.s")
void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex,
s32* curIndex) {
AnimationSpeedInfo* animation = &animations[nextIndex];
f32 startFrame = skelAnime->curFrame;
f32 endFrame;
f32 morphFrames;
if ((*curIndex < 0) || (nextIndex == *curIndex)) {
morphFrames = 0.0f;
if (*curIndex < 0) {
startFrame = 0.0f;
}
} else {
morphFrames = animation->morphFrames;
if (nextIndex != *curIndex) {
startFrame = 0.0f;
}
}
if (animation->playSpeed >= 0.0f) {
endFrame = Animation_GetLastFrame(&animation->animation->common);
} else {
startFrame = Animation_GetLastFrame(&animation->animation->common);
endFrame = 0.0f;
}
Animation_Change(skelAnime, animation->animation, animation->playSpeed, startFrame, endFrame, animation->mode,
morphFrames);
*curIndex = nextIndex;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E2D4.s")