Player doc: anim wrappers (#1434)

* player cs docs setup

* more docs

* more docs

* missed enums

* more docs, but broken. Need to fix sPlayerCsModeAnimFuncs

* fix

* rm enum

* more minor docs

* PR suggestion

* typo

* csActionFunc

* PR Suggestion

* player animation

* cleanup

* cleanup

* comments

* macro

* fix bss

* another comment

* better macro

* move macro

* fix bss

* adjust names

* simplify enum

* missed flags

* PR Review

* adjust comment

* missed defines
This commit is contained in:
engineer124
2023-11-18 23:55:04 +11:00
committed by GitHub
parent dbb6410ba3
commit faba61d9b8
14 changed files with 630 additions and 601 deletions
+2 -2
View File
@@ -187,8 +187,8 @@ void func_800F0BB4(EnHy* enHy, PlayState* play, EnDoor* door, s16 arg3, s16 arg4
phi_f0 = (offset.z >= 0.0f) ? 1.0f : -1.0f;
animIndex = ((s8)phi_f0 < 0) ? 0 : 2;
EnHy_ChangeObjectAndAnim(enHy, play, (animIndex == 0) ? arg3 : arg4);
enHy->skelAnime.baseTransl = *enHy->skelAnime.jointTable;
enHy->skelAnime.prevTransl = *enHy->skelAnime.jointTable;
enHy->skelAnime.baseTransl = enHy->skelAnime.jointTable[LIMB_ROOT_POS];
enHy->skelAnime.prevTransl = enHy->skelAnime.jointTable[LIMB_ROOT_POS];
enHy->skelAnime.moveFlags |= (ANIM_FLAG_UPDATE_Y | ANIM_FLAG_1);
AnimationContext_SetMoveActor(play, &enHy->actor, &enHy->skelAnime, 1.0f);
door->knobDoor.playOpenAnim = true;
+44 -44
View File
@@ -100,11 +100,11 @@ void SkelAnime_DrawLod(PlayState* play, void** skeleton, Vec3s* jointTable, Over
Matrix_Push();
rootLimb = Lib_SegmentedToVirtual(skeleton[0]);
pos.x = jointTable[0].x;
pos.y = jointTable[0].y;
pos.z = jointTable[0].z;
pos.x = jointTable[LIMB_ROOT_POS].x;
pos.y = jointTable[LIMB_ROOT_POS].y;
pos.z = jointTable[LIMB_ROOT_POS].z;
rot = jointTable[1];
rot = jointTable[LIMB_ROOT_ROT];
dList = rootLimb->dLists[lod];
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &dList, &pos, &rot, actor)) {
@@ -219,11 +219,11 @@ void SkelAnime_DrawFlexLod(PlayState* play, void** skeleton, Vec3s* jointTable,
Matrix_Push();
rootLimb = Lib_SegmentedToVirtual(skeleton[0]);
pos.x = jointTable[0].x;
pos.y = jointTable[0].y;
pos.z = jointTable[0].z;
pos.x = jointTable[LIMB_ROOT_POS].x;
pos.y = jointTable[LIMB_ROOT_POS].y;
pos.z = jointTable[LIMB_ROOT_POS].z;
rot = jointTable[1];
rot = jointTable[LIMB_ROOT_ROT];
newDList = limbDList = rootLimb->dLists[lod];
@@ -326,11 +326,11 @@ void SkelAnime_DrawOpa(PlayState* play, void** skeleton, Vec3s* jointTable, Over
Matrix_Push();
rootLimb = Lib_SegmentedToVirtual(skeleton[0]);
pos.x = jointTable[0].x;
pos.y = jointTable[0].y;
pos.z = jointTable[0].z;
pos.x = jointTable[LIMB_ROOT_POS].x;
pos.y = jointTable[LIMB_ROOT_POS].y;
pos.z = jointTable[LIMB_ROOT_POS].z;
rot = jointTable[1];
rot = jointTable[LIMB_ROOT_ROT];
dList = rootLimb->dList;
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &dList, &pos, &rot, actor)) {
@@ -439,10 +439,10 @@ void SkelAnime_DrawFlexOpa(PlayState* play, void** skeleton, Vec3s* jointTable,
rootLimb = Lib_SegmentedToVirtual(skeleton[0]);
pos.x = jointTable[0].x;
pos.y = jointTable[0].y;
pos.z = jointTable[0].z;
rot = jointTable[1];
pos.x = jointTable[LIMB_ROOT_POS].x;
pos.y = jointTable[LIMB_ROOT_POS].y;
pos.z = jointTable[LIMB_ROOT_POS].z;
rot = jointTable[LIMB_ROOT_ROT];
newDList = limbDList = rootLimb->dList;
@@ -575,10 +575,10 @@ void SkelAnime_DrawTransformFlexOpa(PlayState* play, void** skeleton, Vec3s* joi
rootLimb = Lib_SegmentedToVirtual(skeleton[0]);
pos.x = jointTable[0].x;
pos.y = jointTable[0].y;
pos.z = jointTable[0].z;
rot = jointTable[1];
pos.x = jointTable[LIMB_ROOT_POS].x;
pos.y = jointTable[LIMB_ROOT_POS].y;
pos.z = jointTable[LIMB_ROOT_POS].z;
rot = jointTable[LIMB_ROOT_ROT];
newDList = limbDList = rootLimb->dList;
@@ -722,11 +722,11 @@ Gfx* SkelAnime_Draw(PlayState* play, void** skeleton, Vec3s* jointTable, Overrid
rootLimb = Lib_SegmentedToVirtual(skeleton[0]);
pos.x = jointTable[0].x;
pos.y = jointTable[0].y;
pos.z = jointTable[0].z;
pos.x = jointTable[LIMB_ROOT_POS].x;
pos.y = jointTable[LIMB_ROOT_POS].y;
pos.z = jointTable[LIMB_ROOT_POS].z;
rot = jointTable[1];
rot = jointTable[LIMB_ROOT_ROT];
dList = rootLimb->dList;
@@ -838,11 +838,11 @@ Gfx* SkelAnime_DrawFlex(PlayState* play, void** skeleton, Vec3s* jointTable, s32
rootLimb = Lib_SegmentedToVirtual(skeleton[0]);
pos.x = jointTable[0].x;
pos.y = jointTable[0].y;
pos.z = jointTable[0].z;
pos.x = jointTable[LIMB_ROOT_POS].x;
pos.y = jointTable[LIMB_ROOT_POS].y;
pos.z = jointTable[LIMB_ROOT_POS].z;
rot = jointTable[1];
rot = jointTable[LIMB_ROOT_ROT];
newDList = limbDList = rootLimb->dList;
@@ -1236,7 +1236,7 @@ void SkelAnime_InitPlayer(PlayState* play, SkelAnime* skelAnime, FlexSkeletonHea
skelAnime->morphTable = (void*)ALIGN16((uintptr_t)morphTableBuffer);
}
PlayerAnimation_Change(play, skelAnime, animation, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f);
PlayerAnimation_Change(play, skelAnime, animation, PLAYER_ANIM_NORMAL_SPEED, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f);
}
/**
@@ -1386,8 +1386,8 @@ void PlayerAnimation_Change(PlayState* play, SkelAnime* skelAnime, PlayerAnimati
* Immediately changes to a Player animation that plays once at the default speed.
*/
void PlayerAnimation_PlayOnce(PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation) {
PlayerAnimation_Change(play, skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(&animation->common),
ANIMMODE_ONCE, 0.0f);
PlayerAnimation_Change(play, skelAnime, animation, PLAYER_ANIM_NORMAL_SPEED, 0.0f,
Animation_GetLastFrame(&animation->common), ANIMMODE_ONCE, 0.0f);
}
/**
@@ -1403,8 +1403,8 @@ void PlayerAnimation_PlayOnceSetSpeed(PlayState* play, SkelAnime* skelAnime, Pla
* Immediately changes to a Player animation that loops at the default speed.
*/
void PlayerAnimation_PlayLoop(PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation) {
PlayerAnimation_Change(play, skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(&animation->common),
ANIMMODE_LOOP, 0.0f);
PlayerAnimation_Change(play, skelAnime, animation, PLAYER_ANIM_NORMAL_SPEED, 0.0f,
Animation_GetLastFrame(&animation->common), ANIMMODE_LOOP, 0.0f);
}
/**
@@ -1564,7 +1564,6 @@ void SkelAnime_InitFlex(PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeade
if (jointTable == NULL) {
skelAnime->jointTable = ZeldaArena_Malloc(sizeof(*skelAnime->jointTable) * skelAnime->limbCount);
skelAnime->morphTable = ZeldaArena_Malloc(sizeof(*skelAnime->morphTable) * skelAnime->limbCount);
} else {
skelAnime->jointTable = jointTable;
@@ -1932,29 +1931,30 @@ void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* diff, s16 angle) {
diff->x = 0.0f;
} else {
// `angle` rotation around y axis.
x = skelAnime->jointTable->x - skelAnime->prevTransl.x;
z = skelAnime->jointTable->z - skelAnime->prevTransl.z;
x = skelAnime->jointTable[LIMB_ROOT_POS].x - skelAnime->prevTransl.x;
z = skelAnime->jointTable[LIMB_ROOT_POS].z - skelAnime->prevTransl.z;
sin = Math_SinS(angle);
cos = Math_CosS(angle);
diff->x = x * cos + z * sin;
diff->z = z * cos - x * sin;
}
skelAnime->prevTransl.x = skelAnime->jointTable->x;
skelAnime->jointTable->x = skelAnime->baseTransl.x;
skelAnime->prevTransl.z = skelAnime->jointTable->z;
skelAnime->jointTable->z = skelAnime->baseTransl.z;
skelAnime->prevTransl.x = skelAnime->jointTable[LIMB_ROOT_POS].x;
skelAnime->jointTable[LIMB_ROOT_POS].x = skelAnime->baseTransl.x;
skelAnime->prevTransl.z = skelAnime->jointTable[LIMB_ROOT_POS].z;
skelAnime->jointTable[LIMB_ROOT_POS].z = skelAnime->baseTransl.z;
if (skelAnime->moveFlags & ANIM_FLAG_UPDATE_Y) {
if (skelAnime->moveFlags & ANIM_FLAG_NOMOVE) {
diff->y = 0.0f;
} else {
diff->y = skelAnime->jointTable->y - skelAnime->prevTransl.y;
diff->y = skelAnime->jointTable[LIMB_ROOT_POS].y - skelAnime->prevTransl.y;
}
skelAnime->prevTransl.y = skelAnime->jointTable->y;
skelAnime->jointTable->y = skelAnime->baseTransl.y;
skelAnime->prevTransl.y = skelAnime->jointTable[LIMB_ROOT_POS].y;
skelAnime->jointTable[LIMB_ROOT_POS].y = skelAnime->baseTransl.y;
} else {
diff->y = 0.0f;
skelAnime->prevTransl.y = skelAnime->jointTable->y;
skelAnime->prevTransl.y = skelAnime->jointTable[LIMB_ROOT_POS].y;
}
skelAnime->moveFlags &= ~ANIM_FLAG_NOMOVE;
}
+4 -4
View File
@@ -121,10 +121,10 @@ Gfx* SubS_DrawTransformFlex(PlayState* play, void** skeleton, Vec3s* jointTable,
gSPSegment(gfx++, 0x0D, mtx);
Matrix_Push();
rootLimb = Lib_SegmentedToVirtual(skeleton[0]);
pos.x = jointTable->x;
pos.y = jointTable->y;
pos.z = jointTable->z;
rot = jointTable[1];
pos.x = jointTable[LIMB_ROOT_POS].x;
pos.y = jointTable[LIMB_ROOT_POS].y;
pos.z = jointTable[LIMB_ROOT_POS].z;
rot = jointTable[LIMB_ROOT_ROT];
newDlist = rootLimb->dList;
limbDList = rootLimb->dList;
@@ -285,7 +285,7 @@ s32 DemoEffect_OverrideLimbDrawTimewarp(PlayState* play, SkelCurve* skelCurve, s
CLOSE_DISPS(play->state.gfxCtx);
if (limbIndex == 0) {
s16* transform = skelCurve->jointTable[0];
s16* transform = skelCurve->jointTable[LIMB_ROOT_POS];
transform[2] = transform[0] = 1024;
transform[1] = 1024;
+15 -15
View File
@@ -1432,7 +1432,7 @@ void EnHorse_JumpLanding(EnHorse* this, PlayState* play) {
this->animIndex = ENHORSE_ANIM_GALLOP;
Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex]);
jointTable = this->skin.skelAnime.jointTable;
y = jointTable->y;
y = jointTable[LIMB_ROOT_POS].y;
this->riderPos.y += y * 0.01f * this->unk_528 * 0.01f;
this->postDrawFunc = NULL;
}
@@ -1721,7 +1721,7 @@ void EnHorse_StartLowJump(EnHorse* this, PlayState* play) {
this->actor.velocity.y = 0.0f;
jointTable = this->skin.skelAnime.jointTable;
y = jointTable->y;
y = jointTable[LIMB_ROOT_POS].y;
this->riderPos.y -= ((y * 0.01f) * this->unk_528) * 0.01f;
if (this->type == HORSE_TYPE_2) {
@@ -1775,7 +1775,7 @@ void EnHorse_LowJump(EnHorse* this, PlayState* play) {
}
} else {
jointTable = this->skin.skelAnime.jointTable;
temp_f0 = jointTable->y;
temp_f0 = jointTable[LIMB_ROOT_POS].y;
this->actor.world.pos.y = this->jumpStartY + (temp_f0 * 0.01f * this->unk_528 * 0.01f);
}
@@ -1818,7 +1818,7 @@ void EnHorse_StartHighJump(EnHorse* this, PlayState* play) {
this->actor.velocity.y = 0.0f;
jointTable = this->skin.skelAnime.jointTable;
y = jointTable->y;
y = jointTable[LIMB_ROOT_POS].y;
this->riderPos.y -= ((y * 0.01f) * this->unk_528) * 0.01f;
this->stateFlags |= ENHORSE_CALC_RIDER_POS;
@@ -1873,7 +1873,7 @@ void EnHorse_HighJump(EnHorse* this, PlayState* play) {
}
} else {
jointTable = this->skin.skelAnime.jointTable;
temp_f0 = jointTable->y;
temp_f0 = jointTable[LIMB_ROOT_POS].y;
this->actor.world.pos.y = this->jumpStartY + (temp_f0 * 0.01f * this->unk_528 * 0.01f);
}
@@ -2334,7 +2334,7 @@ void func_80881398(EnHorse* this, PlayState* play) {
}
} else {
jointTable = this->skin.skelAnime.jointTable;
y = jointTable->y;
y = jointTable[LIMB_ROOT_POS].y;
this->actor.world.pos.y = this->jumpStartY + (y * 0.01f * this->unk_528 * 0.01f);
}
@@ -2363,7 +2363,7 @@ void func_8088159C(EnHorse* this, PlayState* play) {
this->animIndex = ENHORSE_ANIM_GALLOP;
Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex]);
jointTable = this->skin.skelAnime.jointTable;
y = jointTable->y;
y = jointTable[LIMB_ROOT_POS].y;
this->riderPos.y += y * 0.01f * this->unk_528 * 0.01f;
this->postDrawFunc = NULL;
}
@@ -2551,7 +2551,7 @@ void EnHorse_CsPlayHighJumpAnim(EnHorse* this, PlayState* play) {
this->actor.velocity.y = 0.0f;
jointTable = this->skin.skelAnime.jointTable;
y = jointTable->y;
y = jointTable[LIMB_ROOT_POS].y;
this->riderPos.y -= y * 0.01f * this->unk_528 * 0.01f;
this->stateFlags |= ENHORSE_ANIM_HIGH_JUMP;
@@ -2596,7 +2596,7 @@ void EnHorse_CsJump(EnHorse* this, PlayState* play, CsCmdActorCue* cue) {
}
} else {
jointTable = this->skin.skelAnime.jointTable;
y = jointTable->y;
y = jointTable[LIMB_ROOT_POS].y;
this->actor.world.pos.y = this->jumpStartY + (y * 0.01f * this->unk_528 * 0.01f);
}
@@ -2621,7 +2621,7 @@ void EnHorse_CsJump(EnHorse* this, PlayState* play, CsCmdActorCue* cue) {
sPlaybackSpeeds[6]);
jointTable = this->skin.skelAnime.jointTable;
y = jointTable->y;
y = jointTable[LIMB_ROOT_POS].y;
this->riderPos.y += y * 0.01f * this->unk_528 * 0.01f;
this->postDrawFunc = NULL;
@@ -4231,7 +4231,7 @@ void EnHorse_Update(Actor* thisx, PlayState* play2) {
this->stateFlags &= ~ENHORSE_OBSTACLE;
this->unk_3EC = thisx->world.rot.y;
if ((this->animIndex == ENHORSE_ANIM_STOPPING) || (this->animIndex == ENHORSE_ANIM_REARING)) {
this->skin.skelAnime.jointTable[0].y += 0x154;
this->skin.skelAnime.jointTable[LIMB_ROOT_POS].y += 0x154;
}
this->curFrame = this->skin.skelAnime.curFrame;
@@ -4265,7 +4265,7 @@ void EnHorse_Update(Actor* thisx, PlayState* play2) {
this->rider->actor.shape.rot.y = thisx->shape.rot.y;
} else if (this->action == ENHORSE_ACTION_6) {
EnIn* in = this->rider;
s16 jnt = in->jointTable[0].y;
s16 jnt = in->jointTable[LIMB_ROOT_POS].y;
in->actor.world.pos.x = this->riderPos.x;
in->actor.world.pos.y = this->riderPos.y - (jnt * 0.01f * this->unk_528 * 0.01f);
@@ -4712,9 +4712,9 @@ void EnHorse_Draw(Actor* thisx, PlayState* play) {
}
} else {
if (this->stateFlags & ENHORSE_JUMPING) {
this->skin.skelAnime.jointTable->x = 0;
this->skin.skelAnime.jointTable->y = 0;
this->skin.skelAnime.jointTable->z = 0;
this->skin.skelAnime.jointTable[LIMB_ROOT_POS].x = 0;
this->skin.skelAnime.jointTable[LIMB_ROOT_POS].y = 0;
this->skin.skelAnime.jointTable[LIMB_ROOT_POS].z = 0;
}
SkelAnime_DrawFlexOpa(play, this->skin.skelAnime.skeleton, this->skin.skelAnime.jointTable,
this->skin.skelAnime.dListCount, func_80888D18, NULL, &this->actor);
+4 -4
View File
@@ -223,12 +223,12 @@ void EnRz_ChangeAnim(PlayState* play, EnRz* this, s16 animIndex, u8 animMode, f3
endFrame = Animation_GetLastFrame(sPlayerAnimations[animIndex - ARRAY_COUNT(sJudoAnimations)]);
if (animMode == ANIMMODE_LOOP) {
PlayerAnimation_Change(play, &this->skelAnime,
sPlayerAnimations[animIndex - ARRAY_COUNT(sJudoAnimations)], 2.0f / 3.0f, 0.0f,
endFrame, ANIMMODE_LOOP, morphFrames);
sPlayerAnimations[animIndex - ARRAY_COUNT(sJudoAnimations)],
PLAYER_ANIM_ADJUSTED_SPEED, 0.0f, endFrame, ANIMMODE_LOOP, morphFrames);
} else {
PlayerAnimation_Change(play, &this->skelAnime,
sPlayerAnimations[animIndex - ARRAY_COUNT(sJudoAnimations)], 2.0f / 3.0f, 0.0f,
endFrame, ANIMMODE_LOOP, morphFrames);
sPlayerAnimations[animIndex - ARRAY_COUNT(sJudoAnimations)],
PLAYER_ANIM_ADJUSTED_SPEED, 0.0f, endFrame, ANIMMODE_LOOP, morphFrames);
}
} else {
Animation_Change(&this->skelAnime, animationPtr[animIndex], 1.0f, 0.0f,
@@ -370,7 +370,7 @@ void EnSyatekiOkuta_UpdateCollision(EnSyatekiOkuta* this, PlayState* play) {
}
this->collider.dim.pos.x = this->actor.world.pos.x;
// jointTable->y is the y-translation of the skeleton root
// jointTable->y is the y-translation of the skeleton root, see `LIMB_ROOT_POS`
this->collider.dim.pos.y = this->actor.world.pos.y + (this->skelAnime.jointTable->y * this->actor.scale.y);
this->collider.dim.pos.z = this->actor.world.pos.z;
CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base);
@@ -320,7 +320,8 @@ s32 func_80A3E898(EnTest3* this, PlayState* play) {
Message_ContinueTextbox(play, textId);
}
if (textId == 0x296B) {
PlayerAnimation_PlayOnceSetSpeed(play, &this->player.skelAnime, &gPlayerAnim_al_yareyare, 2.0f / 3.0f);
PlayerAnimation_PlayOnceSetSpeed(play, &this->player.skelAnime, &gPlayerAnim_al_yareyare,
PLAYER_ANIM_ADJUSTED_SPEED);
}
return false;
}
File diff suppressed because it is too large Load Diff