2020-10-03 15:22:44 +00:00
|
|
|
#include "global.h"
|
|
|
|
#include "vt.h"
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
s32 func_800A3D70(GlobalContext* globalCtx, SkelAnime* skelAnime);
|
|
|
|
s32 func_800A3E0C(GlobalContext* globalCtx, SkelAnime* skelAnime);
|
2020-03-20 21:12:26 +00:00
|
|
|
s32 func_800A4D9C(SkelAnime* skelAnime);
|
|
|
|
s32 func_800A4EE0(SkelAnime* skelAnime);
|
|
|
|
s32 func_800A4E38(SkelAnime* skelAnime);
|
2020-12-02 03:19:56 +00:00
|
|
|
|
2020-03-24 16:52:12 +00:00
|
|
|
void SkelAnime_CopyVec3s(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src);
|
2020-12-02 03:19:56 +00:00
|
|
|
|
|
|
|
static u32 D_8012A480 = 0;
|
|
|
|
static u32 D_801600B0;
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-03-30 22:53:26 +00:00
|
|
|
/*
|
2020-12-02 03:19:56 +00:00
|
|
|
* Draw a limb of type `LodLimb`
|
|
|
|
* Near or far display list is specified via `lod`
|
2020-04-01 01:19:21 +00:00
|
|
|
*/
|
2020-12-02 03:19:56 +00:00
|
|
|
void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* limbDrawTable,
|
|
|
|
OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg, s32 lod) {
|
|
|
|
LodLimb* limb;
|
2020-03-20 21:12:26 +00:00
|
|
|
Gfx* dList;
|
2020-03-21 02:51:12 +00:00
|
|
|
Vec3f pos;
|
|
|
|
Vec3s rot;
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 773);
|
|
|
|
|
2020-03-20 21:12:26 +00:00
|
|
|
Matrix_Push();
|
2020-12-02 03:19:56 +00:00
|
|
|
limb = (LodLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]);
|
2020-03-20 21:12:26 +00:00
|
|
|
limbIndex++;
|
2020-04-18 18:08:12 +00:00
|
|
|
rot = limbDrawTable[limbIndex];
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
pos.x = limb->jointPos.x;
|
|
|
|
pos.y = limb->jointPos.y;
|
|
|
|
pos.z = limb->jointPos.z;
|
|
|
|
|
|
|
|
dList = limb->dLists[lod];
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, arg)) {
|
2020-04-28 04:14:27 +00:00
|
|
|
Matrix_JointPosition(&pos, &rot);
|
2020-03-24 17:16:13 +00:00
|
|
|
if (dList != NULL) {
|
2020-11-19 21:49:08 +00:00
|
|
|
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 805), G_MTX_LOAD);
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPDisplayList(POLY_OPA_DISP++, dList);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
if (1) {}
|
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
if (postLimbDraw != NULL) {
|
2020-12-02 03:19:56 +00:00
|
|
|
postLimbDraw(globalCtx, limbIndex, &dList, &rot, arg);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if (limb->child != LIMB_DONE) {
|
|
|
|
SkelAnime_DrawLimbLod(globalCtx, limb->child, skeleton, limbDrawTable, overrideLimbDraw, postLimbDraw, arg,
|
|
|
|
lod);
|
2020-03-21 02:51:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Matrix_Pull();
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if (limb->sibling != LIMB_DONE) {
|
|
|
|
SkelAnime_DrawLimbLod(globalCtx, limb->sibling, skeleton, limbDrawTable, overrideLimbDraw, postLimbDraw, arg,
|
|
|
|
lod);
|
2020-03-21 02:51:12 +00:00
|
|
|
}
|
2020-03-24 16:52:12 +00:00
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 821);
|
2020-03-21 02:51:12 +00:00
|
|
|
}
|
|
|
|
|
2020-03-30 22:53:26 +00:00
|
|
|
/*
|
2020-12-02 03:19:56 +00:00
|
|
|
* Draw all limbs of type `LodLimb` in a given skeleton
|
|
|
|
* Near or far display list is specified via `lod`
|
2020-04-01 01:19:21 +00:00
|
|
|
*/
|
2020-12-02 03:19:56 +00:00
|
|
|
void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTable,
|
|
|
|
OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg, s32 lod) {
|
|
|
|
LodLimb* rootLimb;
|
|
|
|
s32 pad;
|
2020-03-21 02:51:12 +00:00
|
|
|
Gfx* dList;
|
|
|
|
Vec3f pos;
|
|
|
|
Vec3s rot;
|
|
|
|
|
2020-03-25 15:51:25 +00:00
|
|
|
if (skeleton == NULL) {
|
2020-03-24 18:06:15 +00:00
|
|
|
osSyncPrintf(VT_FGCOL(RED));
|
2020-04-01 01:19:21 +00:00
|
|
|
osSyncPrintf("Si2_Lod_draw():skelがNULLです。\n"); // Si2_Lod_draw (): skel is NULL.
|
2020-03-24 18:06:15 +00:00
|
|
|
osSyncPrintf(VT_RST);
|
2020-03-21 02:51:12 +00:00
|
|
|
return;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-08-29 23:00:17 +00:00
|
|
|
|
|
|
|
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 849);
|
|
|
|
|
2020-03-21 02:51:12 +00:00
|
|
|
Matrix_Push();
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
rootLimb = (LodLimb*)SEGMENTED_TO_VIRTUAL(skeleton[0]);
|
2020-04-18 18:08:12 +00:00
|
|
|
pos.x = limbDrawTable[0].x;
|
|
|
|
pos.y = limbDrawTable[0].y;
|
|
|
|
pos.z = limbDrawTable[0].z;
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
rot = limbDrawTable[1];
|
2020-12-02 03:19:56 +00:00
|
|
|
dList = rootLimb->dLists[lod];
|
2020-03-21 02:51:12 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, arg)) {
|
2020-04-28 04:14:27 +00:00
|
|
|
Matrix_JointPosition(&pos, &rot);
|
2020-03-24 17:16:13 +00:00
|
|
|
if (dList != NULL) {
|
2020-11-19 21:49:08 +00:00
|
|
|
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 881), G_MTX_LOAD);
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPDisplayList(POLY_OPA_DISP++, dList);
|
2020-03-21 02:51:12 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-18 18:08:12 +00:00
|
|
|
if (postLimbDraw != NULL) {
|
2020-12-02 03:19:56 +00:00
|
|
|
postLimbDraw(globalCtx, 1, &dList, &rot, arg);
|
2020-03-21 02:51:12 +00:00
|
|
|
}
|
2020-03-24 16:52:12 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if (rootLimb->child != LIMB_DONE) {
|
|
|
|
SkelAnime_DrawLimbLod(globalCtx, rootLimb->child, skeleton, limbDrawTable, overrideLimbDraw, postLimbDraw, arg,
|
|
|
|
lod);
|
2020-03-21 02:51:12 +00:00
|
|
|
}
|
2020-03-24 16:52:12 +00:00
|
|
|
|
2020-03-20 21:12:26 +00:00
|
|
|
Matrix_Pull();
|
2020-08-29 23:00:17 +00:00
|
|
|
|
|
|
|
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 894);
|
2020-03-21 02:51:12 +00:00
|
|
|
}
|
|
|
|
|
2020-03-30 22:53:26 +00:00
|
|
|
/*
|
2020-12-02 03:19:56 +00:00
|
|
|
* Draw a limb of type `LodLimb` contained within a flexible skeleton
|
|
|
|
* Near or far display list is specified via `lod`
|
2020-04-01 01:19:21 +00:00
|
|
|
*/
|
2020-12-02 03:19:56 +00:00
|
|
|
void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* limbDrawTable,
|
|
|
|
OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg, s32 lod,
|
|
|
|
Mtx** mtx) {
|
|
|
|
LodLimb* limb;
|
|
|
|
Gfx* newDList;
|
|
|
|
Gfx* limbDList;
|
2020-03-21 02:51:12 +00:00
|
|
|
Vec3f pos;
|
|
|
|
Vec3s rot;
|
|
|
|
|
|
|
|
Matrix_Push();
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
limb = (LodLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]);
|
2020-03-21 02:51:12 +00:00
|
|
|
limbIndex++;
|
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
rot = limbDrawTable[limbIndex];
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
pos.x = limb->jointPos.x;
|
|
|
|
pos.y = limb->jointPos.y;
|
|
|
|
pos.z = limb->jointPos.z;
|
|
|
|
|
|
|
|
newDList = limbDList = limb->dLists[lod];
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, arg)) {
|
2020-04-28 04:14:27 +00:00
|
|
|
Matrix_JointPosition(&pos, &rot);
|
2020-12-02 03:19:56 +00:00
|
|
|
if (newDList != NULL) {
|
2020-03-24 17:16:13 +00:00
|
|
|
Matrix_ToMtx(*mtx, "../z_skelanime.c", 945);
|
2020-12-02 03:19:56 +00:00
|
|
|
{
|
|
|
|
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 946);
|
|
|
|
gSPMatrix(POLY_OPA_DISP++, *mtx, G_MTX_LOAD);
|
|
|
|
gSPDisplayList(POLY_OPA_DISP++, newDList);
|
|
|
|
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 949);
|
|
|
|
}
|
2020-03-21 02:51:12 +00:00
|
|
|
(*mtx)++;
|
2020-12-02 03:19:56 +00:00
|
|
|
} else if (limbDList != NULL) {
|
2020-03-21 02:51:12 +00:00
|
|
|
Matrix_ToMtx(*mtx, "../z_skelanime.c", 954);
|
|
|
|
(*mtx)++;
|
|
|
|
}
|
|
|
|
}
|
2020-04-18 18:08:12 +00:00
|
|
|
if (postLimbDraw != NULL) {
|
2020-12-02 03:19:56 +00:00
|
|
|
postLimbDraw(globalCtx, limbIndex, &limbDList, &rot, arg);
|
2020-03-21 02:51:12 +00:00
|
|
|
}
|
2020-12-02 03:19:56 +00:00
|
|
|
if (limb->child != LIMB_DONE) {
|
|
|
|
SkelAnime_DrawFlexLimbLod(globalCtx, limb->child, skeleton, limbDrawTable, overrideLimbDraw, postLimbDraw, arg,
|
|
|
|
lod, mtx);
|
2020-03-21 02:51:12 +00:00
|
|
|
}
|
2020-03-18 03:15:19 +00:00
|
|
|
|
2020-03-21 02:51:12 +00:00
|
|
|
Matrix_Pull();
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if (limb->sibling != LIMB_DONE) {
|
|
|
|
SkelAnime_DrawFlexLimbLod(globalCtx, limb->sibling, skeleton, limbDrawTable, overrideLimbDraw, postLimbDraw,
|
|
|
|
arg, lod, mtx);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-30 22:53:26 +00:00
|
|
|
/*
|
2020-12-02 03:19:56 +00:00
|
|
|
* Draws all limbs of type `LodLimb` in a given flexible skeleton
|
|
|
|
* Limbs in a flexible skeleton have meshes that can stretch to line up with other limbs.
|
|
|
|
* An array of matrices is dynamically allocated so each limb can access any transform to ensure its meshes line up.
|
2020-04-01 01:19:21 +00:00
|
|
|
*/
|
2020-12-02 03:19:56 +00:00
|
|
|
void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTable, s32 dListCount,
|
|
|
|
OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg, s32 lod) {
|
|
|
|
LodLimb* rootLimb;
|
|
|
|
s32 pad;
|
|
|
|
Gfx* newDList;
|
|
|
|
Gfx* limbDList;
|
2020-03-21 02:51:12 +00:00
|
|
|
Vec3f pos;
|
|
|
|
Vec3s rot;
|
|
|
|
Mtx* mtx;
|
|
|
|
|
2020-03-30 22:53:26 +00:00
|
|
|
mtx = Graph_Alloc(globalCtx->state.gfxCtx, dListCount * sizeof(Mtx));
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-03-25 15:51:25 +00:00
|
|
|
if (skeleton == NULL) {
|
2020-03-24 18:06:15 +00:00
|
|
|
osSyncPrintf(VT_FGCOL(RED));
|
2020-04-01 01:19:21 +00:00
|
|
|
osSyncPrintf("Si2_Lod_draw_SV():skelがNULLです。\n"); // Si2_Lod_draw_SV (): skel is NULL.
|
2020-03-24 18:06:15 +00:00
|
|
|
osSyncPrintf(VT_RST);
|
2020-03-21 02:51:12 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-08-29 23:00:17 +00:00
|
|
|
|
|
|
|
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 1000);
|
|
|
|
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPSegment(POLY_OPA_DISP++, 0xD, mtx);
|
2020-03-21 02:51:12 +00:00
|
|
|
Matrix_Push();
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
rootLimb = (LodLimb*)SEGMENTED_TO_VIRTUAL(skeleton[0]);
|
2020-04-18 18:08:12 +00:00
|
|
|
pos.x = limbDrawTable[0].x;
|
|
|
|
pos.y = limbDrawTable[0].y;
|
|
|
|
pos.z = limbDrawTable[0].z;
|
2020-03-21 02:51:12 +00:00
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
rot = limbDrawTable[1];
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
newDList = limbDList = rootLimb->dLists[lod];
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if ((overrideLimbDraw == 0) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, arg)) {
|
2020-04-28 04:14:27 +00:00
|
|
|
Matrix_JointPosition(&pos, &rot);
|
2020-12-02 03:19:56 +00:00
|
|
|
if (newDList != NULL) {
|
2020-03-23 21:31:24 +00:00
|
|
|
Matrix_ToMtx(mtx, "../z_skelanime.c", 1033);
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_LOAD);
|
2020-12-02 03:19:56 +00:00
|
|
|
gSPDisplayList(POLY_OPA_DISP++, newDList);
|
2020-03-21 02:51:12 +00:00
|
|
|
mtx++;
|
2020-12-02 03:19:56 +00:00
|
|
|
} else if (limbDList != NULL) {
|
2020-03-25 15:51:25 +00:00
|
|
|
Matrix_ToMtx(mtx, "../z_skelanime.c", 1040);
|
|
|
|
mtx++;
|
2020-03-21 02:51:12 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
if (postLimbDraw != NULL) {
|
2020-12-02 03:19:56 +00:00
|
|
|
postLimbDraw(globalCtx, 1, &limbDList, &rot, arg);
|
2020-03-21 02:51:12 +00:00
|
|
|
}
|
2020-12-02 03:19:56 +00:00
|
|
|
if (rootLimb->child != LIMB_DONE) {
|
|
|
|
SkelAnime_DrawFlexLimbLod(globalCtx, rootLimb->child, skeleton, limbDrawTable, overrideLimbDraw, postLimbDraw,
|
|
|
|
arg, lod, &mtx);
|
2020-03-21 02:51:12 +00:00
|
|
|
}
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-03-21 02:51:12 +00:00
|
|
|
Matrix_Pull();
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 1053);
|
2020-03-21 02:51:12 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-30 22:53:26 +00:00
|
|
|
/*
|
2020-12-02 03:19:56 +00:00
|
|
|
* Draw a limb of type `StandardLimb` to the polyOpa buffer
|
2020-04-01 01:19:21 +00:00
|
|
|
*/
|
2020-12-02 03:19:56 +00:00
|
|
|
void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* limbDrawTable,
|
|
|
|
OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg) {
|
|
|
|
StandardLimb* limb;
|
2020-03-20 21:12:26 +00:00
|
|
|
Gfx* dList;
|
2020-03-23 21:31:24 +00:00
|
|
|
Vec3f pos;
|
|
|
|
Vec3s rot;
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 1076);
|
2020-03-20 21:12:26 +00:00
|
|
|
Matrix_Push();
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
limb = (StandardLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]);
|
2020-03-20 21:12:26 +00:00
|
|
|
limbIndex++;
|
2020-04-18 18:08:12 +00:00
|
|
|
rot = limbDrawTable[limbIndex];
|
2020-12-02 03:19:56 +00:00
|
|
|
pos.x = limb->jointPos.x;
|
|
|
|
pos.y = limb->jointPos.y;
|
|
|
|
pos.z = limb->jointPos.z;
|
|
|
|
dList = limb->dList;
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, arg)) {
|
2020-04-28 04:14:27 +00:00
|
|
|
Matrix_JointPosition(&pos, &rot);
|
2020-03-24 17:16:13 +00:00
|
|
|
if (dList != NULL) {
|
2020-11-19 21:49:08 +00:00
|
|
|
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 1103), G_MTX_LOAD);
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPDisplayList(POLY_OPA_DISP++, dList);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
if (1) {}
|
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
if (postLimbDraw != NULL) {
|
2020-12-02 03:19:56 +00:00
|
|
|
postLimbDraw(globalCtx, limbIndex, &dList, &rot, arg);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if (limb->child != LIMB_DONE) {
|
|
|
|
SkelAnime_DrawLimbOpa(globalCtx, limb->child, skeleton, limbDrawTable, overrideLimbDraw, postLimbDraw, arg);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Matrix_Pull();
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if (limb->sibling != LIMB_DONE) {
|
|
|
|
SkelAnime_DrawLimbOpa(globalCtx, limb->sibling, skeleton, limbDrawTable, overrideLimbDraw, postLimbDraw, arg);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-08-29 23:00:17 +00:00
|
|
|
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 1121);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
/*
|
|
|
|
* Draw all limbs of type `StandardLimb` in a given skeleton to the polyOpa buffer
|
|
|
|
*/
|
|
|
|
void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTable,
|
|
|
|
OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg) {
|
|
|
|
StandardLimb* rootLimb;
|
|
|
|
s32 pad;
|
2020-03-20 21:12:26 +00:00
|
|
|
Gfx* dList;
|
2020-03-23 21:31:24 +00:00
|
|
|
Vec3f pos;
|
|
|
|
Vec3s rot;
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-03-25 15:51:25 +00:00
|
|
|
if (skeleton == NULL) {
|
2020-03-24 18:06:15 +00:00
|
|
|
osSyncPrintf(VT_FGCOL(RED));
|
2020-03-20 21:12:26 +00:00
|
|
|
osSyncPrintf("Si2_draw():skelがNULLです。\n"); // Si2_draw (): skel is NULL.
|
2020-03-24 18:06:15 +00:00
|
|
|
osSyncPrintf(VT_RST);
|
2020-03-20 21:12:26 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 1148);
|
2020-03-20 21:12:26 +00:00
|
|
|
|
|
|
|
Matrix_Push();
|
2020-12-02 03:19:56 +00:00
|
|
|
rootLimb = (StandardLimb*)SEGMENTED_TO_VIRTUAL(skeleton[0]);
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
pos.x = limbDrawTable[0].x;
|
|
|
|
pos.y = limbDrawTable[0].y;
|
|
|
|
pos.z = limbDrawTable[0].z;
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
rot = limbDrawTable[1];
|
2020-12-02 03:19:56 +00:00
|
|
|
dList = rootLimb->dList;
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, arg)) {
|
2020-04-28 04:14:27 +00:00
|
|
|
Matrix_JointPosition(&pos, &rot);
|
2020-03-24 17:16:13 +00:00
|
|
|
if (dList != NULL) {
|
2020-11-19 21:49:08 +00:00
|
|
|
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 1176), G_MTX_LOAD);
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPDisplayList(POLY_OPA_DISP++, dList);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
if (postLimbDraw != NULL) {
|
2020-12-02 03:19:56 +00:00
|
|
|
postLimbDraw(globalCtx, 1, &dList, &rot, arg);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if (rootLimb->child != LIMB_DONE) {
|
|
|
|
SkelAnime_DrawLimbOpa(globalCtx, rootLimb->child, skeleton, limbDrawTable, overrideLimbDraw, postLimbDraw, arg);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Matrix_Pull();
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 1190);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
/*
|
|
|
|
* Draw a limb of type `StandardLimb` contained within a flexible skeleton to the polyOpa buffer
|
|
|
|
*/
|
|
|
|
void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* limbDrawTable,
|
|
|
|
OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg,
|
|
|
|
Mtx** limbMatricies) {
|
|
|
|
StandardLimb* limb;
|
|
|
|
Gfx* newDList;
|
|
|
|
Gfx* limbDList;
|
2020-03-25 15:51:25 +00:00
|
|
|
Vec3f pos;
|
|
|
|
Vec3s rot;
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 1214);
|
|
|
|
|
2020-03-20 21:12:26 +00:00
|
|
|
Matrix_Push();
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
limb = (StandardLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]);
|
2020-03-25 15:51:25 +00:00
|
|
|
limbIndex++;
|
2020-04-18 18:08:12 +00:00
|
|
|
rot = limbDrawTable[limbIndex];
|
2020-03-25 15:51:25 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
pos.x = limb->jointPos.x;
|
|
|
|
pos.y = limb->jointPos.y;
|
|
|
|
pos.z = limb->jointPos.z;
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
newDList = limbDList = limb->dList;
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, arg)) {
|
2020-04-28 04:14:27 +00:00
|
|
|
Matrix_JointPosition(&pos, &rot);
|
2020-12-02 03:19:56 +00:00
|
|
|
if (newDList != NULL) {
|
2020-03-24 18:06:15 +00:00
|
|
|
Matrix_ToMtx(*limbMatricies, "../z_skelanime.c", 1242);
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPMatrix(POLY_OPA_DISP++, *limbMatricies, G_MTX_LOAD);
|
2020-12-02 03:19:56 +00:00
|
|
|
gSPDisplayList(POLY_OPA_DISP++, newDList);
|
2020-03-25 15:51:25 +00:00
|
|
|
(*limbMatricies)++;
|
2020-12-02 03:19:56 +00:00
|
|
|
} else if (limbDList != NULL) {
|
2020-03-25 15:51:25 +00:00
|
|
|
Matrix_ToMtx(*limbMatricies, "../z_skelanime.c", 1249);
|
2020-03-20 21:12:26 +00:00
|
|
|
(*limbMatricies)++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
if (postLimbDraw != NULL) {
|
2020-12-02 03:19:56 +00:00
|
|
|
postLimbDraw(globalCtx, limbIndex, &limbDList, &rot, arg);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if (limb->child != LIMB_DONE) {
|
|
|
|
SkelAnime_DrawFlexLimbOpa(globalCtx, limb->child, skeleton, limbDrawTable, overrideLimbDraw, postLimbDraw, arg,
|
|
|
|
limbMatricies);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Matrix_Pull();
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if (limb->sibling != LIMB_DONE) {
|
|
|
|
SkelAnime_DrawFlexLimbOpa(globalCtx, limb->sibling, skeleton, limbDrawTable, overrideLimbDraw, postLimbDraw,
|
|
|
|
arg, limbMatricies);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-08-29 23:00:17 +00:00
|
|
|
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 1265);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
/*
|
|
|
|
* Draw all limbs of type `StandardLimb` in a given flexible skeleton to the polyOpa buffer
|
|
|
|
* Limbs in a flexible skeleton have meshes that can stretch to line up with other limbs.
|
|
|
|
* An array of matrices is dynamically allocated so each limb can access any transform to ensure its meshes line up.
|
|
|
|
*/
|
|
|
|
void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTable, s32 dListCount,
|
|
|
|
OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg) {
|
|
|
|
StandardLimb* rootLimb;
|
|
|
|
s32 pad;
|
|
|
|
Gfx* newDList;
|
|
|
|
Gfx* limbDList;
|
2020-03-20 21:12:26 +00:00
|
|
|
Vec3f pos;
|
|
|
|
Vec3s rot;
|
2020-03-25 15:51:25 +00:00
|
|
|
Mtx* mtx;
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-03-30 22:53:26 +00:00
|
|
|
mtx = Graph_Alloc(globalCtx->state.gfxCtx, dListCount * sizeof(Mtx));
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-03-25 15:51:25 +00:00
|
|
|
if (skeleton == NULL) {
|
2020-03-24 18:06:15 +00:00
|
|
|
osSyncPrintf(VT_FGCOL(RED));
|
2020-03-24 17:16:13 +00:00
|
|
|
osSyncPrintf("Si2_draw_SV():skelがNULLです。\n"); // Si2_draw_SV (): skel is NULL.
|
2020-03-24 18:06:15 +00:00
|
|
|
osSyncPrintf(VT_RST);
|
2020-03-20 21:12:26 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 1294);
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPSegment(POLY_OPA_DISP++, 0xD, mtx);
|
2020-03-25 15:51:25 +00:00
|
|
|
|
2020-03-20 21:12:26 +00:00
|
|
|
Matrix_Push();
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
rootLimb = SEGMENTED_TO_VIRTUAL(skeleton[0]);
|
2020-03-25 15:51:25 +00:00
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
pos.x = limbDrawTable[0].x;
|
|
|
|
pos.y = limbDrawTable[0].y;
|
|
|
|
pos.z = limbDrawTable[0].z;
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
rot = limbDrawTable[1];
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
newDList = limbDList = rootLimb->dList;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, arg)) {
|
2020-04-28 04:14:27 +00:00
|
|
|
Matrix_JointPosition(&pos, &rot);
|
2020-12-02 03:19:56 +00:00
|
|
|
if (newDList != NULL) {
|
2020-03-25 15:51:25 +00:00
|
|
|
Matrix_ToMtx(mtx, "../z_skelanime.c", 1327);
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_LOAD);
|
2020-12-02 03:19:56 +00:00
|
|
|
gSPDisplayList(POLY_OPA_DISP++, newDList);
|
|
|
|
mtx++;
|
|
|
|
} else if (limbDList != NULL) {
|
|
|
|
Matrix_ToMtx(mtx, "../z_skelanime.c", 1334);
|
2020-03-25 15:51:25 +00:00
|
|
|
mtx++;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
if (postLimbDraw != NULL) {
|
2020-12-02 03:19:56 +00:00
|
|
|
postLimbDraw(globalCtx, 1, &limbDList, &rot, arg);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if (rootLimb->child != LIMB_DONE) {
|
|
|
|
SkelAnime_DrawFlexLimbOpa(globalCtx, rootLimb->child, skeleton, limbDrawTable, overrideLimbDraw, postLimbDraw,
|
|
|
|
arg, &mtx);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Matrix_Pull();
|
2020-08-29 23:00:17 +00:00
|
|
|
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 1347);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-03-24 16:52:12 +00:00
|
|
|
/*
|
2020-03-23 01:24:00 +00:00
|
|
|
* Copies the rotation values from the rotation value table, indexed by the rotation index table
|
|
|
|
* When a rotation index is >= the animation limit, the output rotation value is copied from the frame's
|
|
|
|
* rotation value list, otherwise it is copied from the initial rotation value list
|
2020-03-24 17:16:13 +00:00
|
|
|
*/
|
2020-03-25 15:51:25 +00:00
|
|
|
void SkelAnime_AnimateFrame(AnimationHeader* animationSeg, s32 currentFrame, s32 limbCount, Vec3s* dst) {
|
2020-12-02 03:19:56 +00:00
|
|
|
AnimationHeader* animHeader = SEGMENTED_TO_VIRTUAL(animationSeg);
|
|
|
|
AnimationRotationIndex* index = SEGMENTED_TO_VIRTUAL(animHeader->rotationIndexSeg);
|
|
|
|
AnimationRotationValue* rotationValueTable = SEGMENTED_TO_VIRTUAL(animHeader->rotationValueSeg);
|
|
|
|
AnimationRotationValue* frameRotationValueTable = &rotationValueTable[currentFrame];
|
|
|
|
u16 limit = animHeader->limit;
|
2020-03-23 01:24:00 +00:00
|
|
|
s32 i;
|
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
for (i = 0; i < limbCount; i++, dst++, index++) {
|
|
|
|
if ((dst == NULL) || (index == NULL) || (frameRotationValueTable == NULL) || (rotationValueTable == NULL)) {
|
2020-04-04 17:28:53 +00:00
|
|
|
LOG_ADDRESS("out", dst, "../z_skelanime.c", 1392);
|
|
|
|
LOG_ADDRESS("ref_tbl", index, "../z_skelanime.c", 1393);
|
|
|
|
LOG_ADDRESS("frame_tbl", frameRotationValueTable, "../z_skelanime.c", 1394);
|
|
|
|
LOG_ADDRESS("tbl", rotationValueTable, "../z_skelanime.c", 1395);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-23 01:24:00 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
dst->x = (index->x >= limit) ? frameRotationValueTable[index->x] : rotationValueTable[index->x];
|
|
|
|
dst->y = (index->y >= limit) ? frameRotationValueTable[index->y] : rotationValueTable[index->y];
|
|
|
|
dst->z = (index->z >= limit) ? frameRotationValueTable[index->z] : rotationValueTable[index->z];
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
s16 SkelAnime_GetTotalFrames(void* animationSeg) {
|
2020-03-25 15:51:25 +00:00
|
|
|
GenericAnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg);
|
2020-12-02 03:19:56 +00:00
|
|
|
|
2020-03-24 16:52:12 +00:00
|
|
|
return animation->frameCount;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
s16 SkelAnime_GetFrameCount(void* animationSeg) {
|
2020-03-25 15:51:25 +00:00
|
|
|
GenericAnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg);
|
2020-03-30 22:53:26 +00:00
|
|
|
// Loads an unsigned half for some reason.
|
2020-03-25 15:51:25 +00:00
|
|
|
return (u16)animation->frameCount - 1;
|
2020-03-18 03:15:19 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-30 22:53:26 +00:00
|
|
|
/*
|
2020-12-02 03:19:56 +00:00
|
|
|
* Draw a limb of type `StandardLimb` to the specified display buffer
|
2020-04-01 01:19:21 +00:00
|
|
|
*/
|
2020-12-02 03:19:56 +00:00
|
|
|
Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* limbDrawTable,
|
|
|
|
OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, void* arg, Gfx* gfx) {
|
|
|
|
StandardLimb* limb;
|
2020-03-23 21:31:24 +00:00
|
|
|
Gfx* dList;
|
|
|
|
Vec3f pos;
|
|
|
|
Vec3s rot;
|
|
|
|
|
|
|
|
Matrix_Push();
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
limb = (StandardLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]);
|
2020-03-23 21:31:24 +00:00
|
|
|
limbIndex++;
|
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
rot = limbDrawTable[limbIndex];
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
pos.x = limb->jointPos.x;
|
|
|
|
pos.y = limb->jointPos.y;
|
|
|
|
pos.z = limb->jointPos.z;
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
dList = limb->dList;
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, arg, &gfx)) {
|
2020-04-28 04:14:27 +00:00
|
|
|
Matrix_JointPosition(&pos, &rot);
|
2020-03-24 17:16:13 +00:00
|
|
|
if (dList != NULL) {
|
2020-03-24 18:06:15 +00:00
|
|
|
gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 1489), G_MTX_LOAD);
|
2020-03-23 21:31:24 +00:00
|
|
|
gSPDisplayList(gfx++, dList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
if (postLimbDraw != NULL) {
|
2020-12-02 03:19:56 +00:00
|
|
|
postLimbDraw(globalCtx, limbIndex, &dList, &rot, arg, &gfx);
|
2020-03-23 21:31:24 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if (limb->child != LIMB_DONE) {
|
|
|
|
gfx = SkelAnime_DrawLimb(globalCtx, limb->child, skeleton, limbDrawTable, overrideLimbDraw, postLimbDraw, arg,
|
|
|
|
gfx);
|
2020-03-23 21:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Matrix_Pull();
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if (limb->sibling != LIMB_DONE) {
|
|
|
|
gfx = SkelAnime_DrawLimb(globalCtx, limb->sibling, skeleton, limbDrawTable, overrideLimbDraw, postLimbDraw, arg,
|
|
|
|
gfx);
|
2020-03-23 21:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return gfx;
|
|
|
|
}
|
|
|
|
|
2020-03-30 22:53:26 +00:00
|
|
|
/*
|
2020-12-02 03:19:56 +00:00
|
|
|
* Draw all limbs of type `StandardLimb` in a given skeleton to the specified display buffer
|
2020-04-01 01:19:21 +00:00
|
|
|
*/
|
2020-12-02 03:19:56 +00:00
|
|
|
Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTable, OverrideLimbDraw overrideLimbDraw,
|
|
|
|
PostLimbDraw postLimbDraw, void* arg, Gfx* gfx) {
|
|
|
|
StandardLimb* rootLimb;
|
|
|
|
s32 pad;
|
2020-03-25 15:51:25 +00:00
|
|
|
Gfx* dList;
|
2020-03-23 21:31:24 +00:00
|
|
|
Vec3f pos;
|
|
|
|
Vec3s rot;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-25 15:51:25 +00:00
|
|
|
if (skeleton == NULL) {
|
2020-03-24 18:06:15 +00:00
|
|
|
osSyncPrintf(VT_FGCOL(RED));
|
2020-04-01 01:19:21 +00:00
|
|
|
osSyncPrintf("Si2_draw2():skelがNULLです。NULLを返します。\n"); // Si2_draw2 (): skel is NULL. Returns NULL.
|
2020-03-24 18:06:15 +00:00
|
|
|
osSyncPrintf(VT_RST);
|
2020-03-23 21:31:24 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Matrix_Push();
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
rootLimb = (StandardLimb*)SEGMENTED_TO_VIRTUAL(skeleton[0]);
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
pos.x = limbDrawTable[0].x;
|
|
|
|
pos.y = limbDrawTable[0].y;
|
|
|
|
pos.z = limbDrawTable[0].z;
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
rot = limbDrawTable[1];
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
dList = rootLimb->dList;
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, arg, &gfx)) {
|
2020-04-28 04:14:27 +00:00
|
|
|
Matrix_JointPosition(&pos, &rot);
|
2020-03-24 17:16:13 +00:00
|
|
|
if (dList != NULL) {
|
2020-03-24 18:06:15 +00:00
|
|
|
gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 1558), G_MTX_LOAD);
|
2020-03-23 21:31:24 +00:00
|
|
|
gSPDisplayList(gfx++, dList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
if (postLimbDraw != NULL) {
|
2020-12-02 03:19:56 +00:00
|
|
|
postLimbDraw(globalCtx, 1, &dList, &rot, arg, &gfx);
|
2020-03-23 21:31:24 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if (rootLimb->child != LIMB_DONE) {
|
|
|
|
gfx = SkelAnime_DrawLimb(globalCtx, rootLimb->child, skeleton, limbDrawTable, overrideLimbDraw, postLimbDraw,
|
|
|
|
arg, gfx);
|
2020-03-23 21:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Matrix_Pull();
|
|
|
|
|
|
|
|
return gfx;
|
|
|
|
}
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
/*
|
|
|
|
* Draw a limb of type `StandardLimb` contained within a flexible skeleton to the specified display buffer
|
|
|
|
*/
|
|
|
|
Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* limbDrawTable,
|
|
|
|
OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, void* arg, Mtx** mtx,
|
|
|
|
Gfx* gfx) {
|
|
|
|
StandardLimb* limb;
|
|
|
|
Gfx* newDList;
|
|
|
|
Gfx* limbDList;
|
2020-03-23 21:31:24 +00:00
|
|
|
Vec3f pos;
|
|
|
|
Vec3s rot;
|
|
|
|
|
|
|
|
Matrix_Push();
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
limb = (StandardLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]);
|
2020-03-23 21:31:24 +00:00
|
|
|
limbIndex++;
|
2020-04-18 18:08:12 +00:00
|
|
|
rot = limbDrawTable[limbIndex];
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
pos.x = limb->jointPos.x;
|
|
|
|
pos.y = limb->jointPos.y;
|
|
|
|
pos.z = limb->jointPos.z;
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
newDList = limbDList = limb->dList;
|
|
|
|
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, arg, &gfx)) {
|
2020-04-28 04:14:27 +00:00
|
|
|
Matrix_JointPosition(&pos, &rot);
|
2020-12-02 03:19:56 +00:00
|
|
|
if (newDList != NULL) {
|
2020-03-24 18:06:15 +00:00
|
|
|
Matrix_ToMtx(*mtx, "../z_skelanime.c", 1623);
|
2020-03-23 21:31:24 +00:00
|
|
|
gSPMatrix(gfx++, *mtx, G_MTX_LOAD);
|
2020-12-02 03:19:56 +00:00
|
|
|
gSPDisplayList(gfx++, newDList);
|
|
|
|
(*mtx)++;
|
|
|
|
} else if (limbDList != NULL) {
|
|
|
|
Matrix_ToMtx(*mtx, "../z_skelanime.c", 1630);
|
2020-03-23 21:31:24 +00:00
|
|
|
(*mtx)++;
|
|
|
|
}
|
|
|
|
}
|
2020-04-18 18:08:12 +00:00
|
|
|
if (postLimbDraw != NULL) {
|
2020-12-02 03:19:56 +00:00
|
|
|
postLimbDraw(globalCtx, limbIndex, &limbDList, &rot, arg, &gfx);
|
2020-03-23 21:31:24 +00:00
|
|
|
}
|
2020-12-02 03:19:56 +00:00
|
|
|
if (limb->child != LIMB_DONE) {
|
|
|
|
gfx = SkelAnime_DrawFlexLimb(globalCtx, limb->child, skeleton, limbDrawTable, overrideLimbDraw, postLimbDraw,
|
|
|
|
arg, mtx, gfx);
|
2020-03-23 21:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Matrix_Pull();
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if (limb->sibling != LIMB_DONE) {
|
|
|
|
gfx = SkelAnime_DrawFlexLimb(globalCtx, limb->sibling, skeleton, limbDrawTable, overrideLimbDraw, postLimbDraw,
|
|
|
|
arg, mtx, gfx);
|
2020-03-23 21:31:24 +00:00
|
|
|
}
|
2020-03-24 16:52:12 +00:00
|
|
|
|
2020-03-23 21:31:24 +00:00
|
|
|
return gfx;
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-04-01 01:19:21 +00:00
|
|
|
/*
|
2020-12-02 03:19:56 +00:00
|
|
|
* Draw all limbs of type `StandardLimb` in a given flexible skeleton to the specified display buffer
|
|
|
|
* Limbs in a flexible skeleton have meshes that can stretch to line up with other limbs.
|
|
|
|
* An array of matrices is dynamically allocated so each limb can access any transform to ensure its meshes line up.
|
2020-04-01 01:19:21 +00:00
|
|
|
*/
|
2020-12-02 03:19:56 +00:00
|
|
|
Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTable, s32 dListCount,
|
|
|
|
OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, void* arg, Gfx* gfx) {
|
|
|
|
StandardLimb* rootLimb;
|
|
|
|
s32 pad;
|
|
|
|
Gfx* newDList;
|
|
|
|
Gfx* limbDList;
|
2020-03-23 01:24:00 +00:00
|
|
|
Vec3f pos;
|
|
|
|
Vec3s rot;
|
|
|
|
Mtx* mtx;
|
|
|
|
|
|
|
|
mtx = Graph_Alloc(globalCtx->state.gfxCtx, dListCount * sizeof(*mtx));
|
2020-03-25 15:51:25 +00:00
|
|
|
if (skeleton == NULL) {
|
2020-03-24 18:06:15 +00:00
|
|
|
osSyncPrintf(VT_FGCOL(RED));
|
2020-04-01 01:19:21 +00:00
|
|
|
osSyncPrintf(
|
|
|
|
"Si2_draw2_SV():skelがNULLです。NULLを返します。\n"); // Si2_draw2_SV (): skel is NULL. Returns NULL.
|
2020-03-24 18:06:15 +00:00
|
|
|
osSyncPrintf(VT_RST);
|
2020-03-23 01:24:00 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2020-03-24 16:52:12 +00:00
|
|
|
|
2020-03-23 01:24:00 +00:00
|
|
|
gSPSegment(gfx++, 0xD, mtx);
|
|
|
|
Matrix_Push();
|
2020-12-02 03:19:56 +00:00
|
|
|
rootLimb = (StandardLimb*)SEGMENTED_TO_VIRTUAL(skeleton[0]);
|
2020-03-23 01:24:00 +00:00
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
pos.x = limbDrawTable[0].x;
|
|
|
|
pos.y = limbDrawTable[0].y;
|
|
|
|
pos.z = limbDrawTable[0].z;
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
rot = limbDrawTable[1];
|
2020-03-23 01:24:00 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
newDList = limbDList = rootLimb->dList;
|
2020-03-23 01:24:00 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, arg, &gfx)) {
|
2020-04-28 04:14:27 +00:00
|
|
|
Matrix_JointPosition(&pos, &rot);
|
2020-12-02 03:19:56 +00:00
|
|
|
if (newDList != NULL) {
|
2020-03-24 18:06:15 +00:00
|
|
|
Matrix_ToMtx(mtx, "../z_skelanime.c", 1710);
|
2020-03-23 01:24:00 +00:00
|
|
|
gSPMatrix(gfx++, mtx, G_MTX_LOAD);
|
2020-12-02 03:19:56 +00:00
|
|
|
gSPDisplayList(gfx++, newDList);
|
|
|
|
mtx++;
|
|
|
|
} else if (limbDList != NULL) {
|
|
|
|
Matrix_ToMtx(mtx, "../z_skelanime.c", 1717);
|
2020-03-23 01:24:00 +00:00
|
|
|
mtx++;
|
|
|
|
}
|
|
|
|
}
|
2020-04-18 18:08:12 +00:00
|
|
|
if (postLimbDraw != NULL) {
|
2020-12-02 03:19:56 +00:00
|
|
|
postLimbDraw(globalCtx, 1, &limbDList, &rot, arg, &gfx);
|
2020-03-23 01:24:00 +00:00
|
|
|
}
|
2020-12-02 03:19:56 +00:00
|
|
|
if (rootLimb->child != LIMB_DONE) {
|
|
|
|
gfx = SkelAnime_DrawFlexLimb(globalCtx, rootLimb->child, skeleton, limbDrawTable, overrideLimbDraw,
|
|
|
|
postLimbDraw, arg, &mtx, gfx);
|
2020-03-23 01:24:00 +00:00
|
|
|
}
|
2020-03-24 16:52:12 +00:00
|
|
|
|
2020-03-23 01:24:00 +00:00
|
|
|
Matrix_Pull();
|
2020-03-24 16:52:12 +00:00
|
|
|
|
2020-03-23 01:24:00 +00:00
|
|
|
return gfx;
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
// unused
|
2020-04-01 01:19:21 +00:00
|
|
|
s32 func_800A29BC(s32 arg0, s32 arg1, Vec3s* arg2) {
|
2020-12-02 03:19:56 +00:00
|
|
|
AnimationHeader* temp_v0 = SEGMENTED_TO_VIRTUAL(arg0);
|
|
|
|
s32 t = temp_v0->genericHeader.unk_02;
|
|
|
|
s16* temp_a3 = SEGMENTED_TO_VIRTUAL(temp_v0->rotationIndexSeg);
|
|
|
|
s16* temp_t1 = SEGMENTED_TO_VIRTUAL(temp_v0->rotationValueSeg);
|
2020-03-31 23:29:09 +00:00
|
|
|
s32 phi_v0;
|
|
|
|
|
|
|
|
arg2->x = arg1 < temp_a3[0] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[1]] : temp_t1[temp_a3[1]];
|
|
|
|
arg2->y = arg1 < temp_a3[2] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[3]] : temp_t1[temp_a3[3]];
|
|
|
|
arg2->z = arg1 < temp_a3[4] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[5]] : temp_t1[temp_a3[5]];
|
|
|
|
|
|
|
|
phi_v0 = 1;
|
|
|
|
arg2++;
|
|
|
|
temp_a3 += 6;
|
|
|
|
|
2020-11-24 02:34:32 +00:00
|
|
|
if (t & 1) {}
|
|
|
|
|
2020-04-01 01:19:21 +00:00
|
|
|
if (t > 0) {
|
|
|
|
if (t & 1) {
|
2020-03-31 23:29:09 +00:00
|
|
|
phi_v0++;
|
|
|
|
arg2->x = arg1 < temp_a3[0] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[1]] : temp_t1[temp_a3[1]];
|
|
|
|
arg2->y = arg1 < temp_a3[2] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[3]] : temp_t1[temp_a3[3]];
|
|
|
|
arg2->z = arg1 < temp_a3[4] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[5]] : temp_t1[temp_a3[5]];
|
|
|
|
temp_a3 += 6;
|
|
|
|
arg2++;
|
2020-04-01 01:19:21 +00:00
|
|
|
if (t + 1 == phi_v0) {
|
2020-03-31 23:29:09 +00:00
|
|
|
goto ret;
|
|
|
|
}
|
|
|
|
}
|
2020-04-01 01:19:21 +00:00
|
|
|
do {
|
2020-03-31 23:29:09 +00:00
|
|
|
phi_v0 += 2;
|
|
|
|
arg2->x = arg1 < temp_a3[0] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[1]] : temp_t1[temp_a3[1]];
|
|
|
|
arg2->y = arg1 < temp_a3[2] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[3]] : temp_t1[temp_a3[3]];
|
|
|
|
arg2->z = arg1 < temp_a3[4] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[5]] : temp_t1[temp_a3[5]];
|
|
|
|
temp_a3 += 6;
|
|
|
|
arg2++;
|
|
|
|
arg2->x = arg1 < temp_a3[0] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[1]] : temp_t1[temp_a3[1]];
|
|
|
|
arg2->y = arg1 < temp_a3[2] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[3]] : temp_t1[temp_a3[3]];
|
|
|
|
arg2->z = arg1 < temp_a3[4] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[5]] : temp_t1[temp_a3[5]];
|
|
|
|
temp_a3 += 6;
|
|
|
|
arg2++;
|
2020-04-01 01:19:21 +00:00
|
|
|
} while (phi_v0 != t + 1);
|
2020-03-31 23:29:09 +00:00
|
|
|
}
|
|
|
|
ret:
|
|
|
|
return t;
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
// unused
|
|
|
|
s16 func_800A2DBC(void* animationSeg) {
|
2020-03-25 15:51:25 +00:00
|
|
|
GenericAnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg);
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-03-24 16:52:12 +00:00
|
|
|
return animation->unk_02;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-03-30 22:53:26 +00:00
|
|
|
/*
|
|
|
|
* Appears to be unused anywhere in the game. Appears to be a clone of
|
|
|
|
* SkelAnime_GetTotalFrames
|
2020-04-01 01:19:21 +00:00
|
|
|
*/
|
2020-12-02 03:19:56 +00:00
|
|
|
s16 SkelAnime_GetTotalFrames2(void* animationSeg) {
|
2020-03-25 15:51:25 +00:00
|
|
|
GenericAnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg);
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-03-24 16:52:12 +00:00
|
|
|
return animation->frameCount;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-30 22:53:26 +00:00
|
|
|
/*
|
|
|
|
* Appears to be unused anywhere in the game. Appears to be a clone of
|
|
|
|
* SkelAnime_GetFrameCount
|
2020-04-01 01:19:21 +00:00
|
|
|
*/
|
2020-12-02 03:19:56 +00:00
|
|
|
s16 SkelAnime_GetFrameCount2(void* animationSeg) {
|
2020-03-25 15:51:25 +00:00
|
|
|
GenericAnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-25 15:51:25 +00:00
|
|
|
return animation->frameCount - 1;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-04-01 01:19:21 +00:00
|
|
|
void SkelAnime_InterpolateVec3s(s32 limbCount, Vec3s* dst, Vec3s* vec2, Vec3s* vec3, f32 unkf) {
|
2020-03-30 22:53:26 +00:00
|
|
|
s32 i;
|
|
|
|
s16 dist;
|
|
|
|
s16 temp2;
|
|
|
|
|
2020-04-01 01:19:21 +00:00
|
|
|
if (unkf < 1.0f) {
|
|
|
|
for (i = 0; i < limbCount; i++, dst++, vec2++, vec3++) {
|
2020-03-30 22:53:26 +00:00
|
|
|
temp2 = vec2->x;
|
|
|
|
dist = vec3->x - temp2;
|
|
|
|
dst->x = (s16)(dist * unkf) + temp2;
|
|
|
|
temp2 = vec2->y;
|
|
|
|
dist = vec3->y - temp2;
|
|
|
|
dst->y = (s16)(dist * unkf) + temp2;
|
|
|
|
temp2 = vec2->z;
|
|
|
|
dist = vec3->z - temp2;
|
|
|
|
dst->z = (s16)(dist * unkf) + temp2;
|
2020-03-25 19:38:16 +00:00
|
|
|
}
|
2020-04-01 01:19:21 +00:00
|
|
|
} else {
|
|
|
|
for (i = 0; i < limbCount; i++, dst++, vec3++) {
|
2020-03-30 22:53:26 +00:00
|
|
|
dst->x = vec3->x;
|
|
|
|
dst->y = vec3->y;
|
|
|
|
dst->z = vec3->z;
|
2020-03-25 19:38:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-25 19:38:16 +00:00
|
|
|
void SkelAnime_AnimationCtxReset(AnimationContext* animationCtx) {
|
|
|
|
animationCtx->animationCount = 0;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-03-25 19:38:16 +00:00
|
|
|
void func_800A32F4(GlobalContext* globalCtx) {
|
|
|
|
D_801600B0 <<= 1;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-03-25 19:38:16 +00:00
|
|
|
void func_800A3310(GlobalContext* globalCtx) {
|
2020-12-02 03:19:56 +00:00
|
|
|
D_8012A480 |= D_801600B0;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
AnimationEntry* SkelAnime_AddEntry(AnimationContext* animationCtx, AnimationType type) {
|
2020-03-24 17:16:13 +00:00
|
|
|
AnimationEntry* entry;
|
2020-03-20 21:12:26 +00:00
|
|
|
s16 index = animationCtx->animationCount;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-25 15:51:25 +00:00
|
|
|
if (index >= ANIMATION_ENTRY_MAX) {
|
2020-03-20 21:12:26 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
animationCtx->animationCount = index + 1;
|
|
|
|
entry = &animationCtx->entries[index];
|
2020-03-23 01:24:00 +00:00
|
|
|
entry->type = type;
|
2020-03-20 21:12:26 +00:00
|
|
|
return entry;
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
// The next 6 functions are coordinate with the AnimationType enum
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
void SkelAnime_LoadLinkAnimation(GlobalContext* globalCtx, LinkAnimationHeader* segment, s32 frame, s32 limbCount,
|
|
|
|
Vec3s* drawTbl) {
|
|
|
|
AnimationEntry* entry = SkelAnime_AddEntry(&globalCtx->animationCtx, ANIMATION_LINK);
|
2020-03-24 16:52:12 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
if (entry != NULL) {
|
2020-12-02 03:19:56 +00:00
|
|
|
LinkAnimationHeader* linkAnimHeader = SEGMENTED_TO_VIRTUAL(segment);
|
|
|
|
u32 ram = drawTbl;
|
|
|
|
|
|
|
|
osCreateMesgQueue(&entry->data.type0.msgQueue, &entry->data.type0.msg, 1);
|
|
|
|
DmaMgr_SendRequest2(&entry->data.type0.req, ram,
|
|
|
|
LINK_ANIMATION_OFFSET(linkAnimHeader->segment, ((sizeof(Vec3s) * limbCount + 2) * frame)),
|
|
|
|
sizeof(Vec3s) * limbCount + 2, 0, &entry->data.type0.msgQueue, NULL, "../z_skelanime.c",
|
|
|
|
2004);
|
2020-03-23 01:24:00 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-24 16:52:12 +00:00
|
|
|
|
2020-03-25 15:51:25 +00:00
|
|
|
void SkelAnime_LoadAnimationType1(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src) {
|
2020-12-02 03:19:56 +00:00
|
|
|
AnimationEntry* entry = SkelAnime_AddEntry(&globalCtx->animationCtx, ANIMATION_TYPE1);
|
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
if (entry != NULL) {
|
2020-12-02 03:19:56 +00:00
|
|
|
entry->data.type1.unk_00 = D_801600B0;
|
|
|
|
entry->data.type1.vecCount = vecCount;
|
|
|
|
entry->data.type1.dst = dst;
|
|
|
|
entry->data.type1.src = src;
|
2020-03-23 01:24:00 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-24 16:52:12 +00:00
|
|
|
|
2020-03-25 15:51:25 +00:00
|
|
|
void SkelAnime_LoadAnimationType2(GlobalContext* globalCtx, s32 limbCount, Vec3s* arg2, Vec3s* arg3, f32 arg4) {
|
2020-12-02 03:19:56 +00:00
|
|
|
AnimationEntry* entry = SkelAnime_AddEntry(&globalCtx->animationCtx, ANIMATION_TYPE2);
|
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
if (entry != NULL) {
|
2020-12-02 03:19:56 +00:00
|
|
|
entry->data.type2.unk_00 = D_801600B0;
|
|
|
|
entry->data.type2.limbCount = limbCount;
|
|
|
|
entry->data.type2.unk_04 = arg2;
|
|
|
|
entry->data.type2.unk_08 = arg3;
|
|
|
|
entry->data.type2.unk_0C = arg4;
|
2020-03-23 01:24:00 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-24 16:52:12 +00:00
|
|
|
|
2020-03-25 15:51:25 +00:00
|
|
|
void SkelAnime_LoadAnimationType3(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index) {
|
2020-12-02 03:19:56 +00:00
|
|
|
AnimationEntry* entry = SkelAnime_AddEntry(&globalCtx->animationCtx, ANIMATION_TYPE3);
|
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
if (entry != NULL) {
|
2020-12-02 03:19:56 +00:00
|
|
|
entry->data.type3.unk_00 = D_801600B0;
|
|
|
|
entry->data.type3.vecCount = vecCount;
|
|
|
|
entry->data.type3.dst = dst;
|
|
|
|
entry->data.type3.src = src;
|
|
|
|
entry->data.type3.index = index;
|
2020-03-23 01:24:00 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-24 16:52:12 +00:00
|
|
|
|
2020-03-25 15:51:25 +00:00
|
|
|
void SkelAnime_LoadAnimationType4(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index) {
|
2020-12-02 03:19:56 +00:00
|
|
|
AnimationEntry* entry = SkelAnime_AddEntry(&globalCtx->animationCtx, ANIMATION_TYPE4);
|
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
if (entry != NULL) {
|
2020-12-02 03:19:56 +00:00
|
|
|
entry->data.type4.unk_00 = D_801600B0;
|
|
|
|
entry->data.type4.vecCount = vecCount;
|
|
|
|
entry->data.type4.dst = dst;
|
|
|
|
entry->data.type4.src = src;
|
|
|
|
entry->data.type4.index = index;
|
2020-03-23 01:24:00 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-24 16:52:12 +00:00
|
|
|
|
2020-03-25 15:51:25 +00:00
|
|
|
void SkelAnime_LoadAnimationType5(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 arg3) {
|
2020-12-02 03:19:56 +00:00
|
|
|
AnimationEntry* entry = SkelAnime_AddEntry(&globalCtx->animationCtx, ANIMATION_TYPE5);
|
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
if (entry != NULL) {
|
2020-12-02 03:19:56 +00:00
|
|
|
entry->data.type5.actor = actor;
|
|
|
|
entry->data.type5.skelAnime = skelAnime;
|
|
|
|
entry->data.type5.unk_08 = arg3;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
// The next functions are callbacks to loading animations
|
|
|
|
|
|
|
|
void SkelAnime_LinkAnimationLoaded(GlobalContext* globalCtx, AnimationEntryData* data) {
|
|
|
|
AnimationEntryType0* entry = &data->type0;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-23 01:24:00 +00:00
|
|
|
osRecvMesg(&entry->msgQueue, NULL, OS_MESG_BLOCK);
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
void SkelAnime_AnimationType1Loaded(GlobalContext* globalCtx, AnimationEntryData* data) {
|
|
|
|
AnimationEntryType1* entry = &data->type1;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if (!(entry->unk_00 & D_8012A480)) {
|
|
|
|
Vec3s* dst = entry->dst;
|
|
|
|
Vec3s* src = entry->src;
|
|
|
|
s32 i;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
for (i = 0; i < entry->vecCount; i++) {
|
|
|
|
*dst++ = *src++;
|
|
|
|
}
|
2020-03-23 01:24:00 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
void SkelAnime_AnimationType2Loaded(GlobalContext* globalCtx, AnimationEntryData* data) {
|
|
|
|
AnimationEntryType2* entry = &data->type2;
|
|
|
|
|
|
|
|
if (!(entry->unk_00 & D_8012A480)) {
|
2020-04-01 01:19:21 +00:00
|
|
|
SkelAnime_InterpolateVec3s(entry->limbCount, entry->unk_04, entry->unk_04, entry->unk_08, entry->unk_0C);
|
2020-03-23 01:24:00 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
void SkelAnime_AnimationType3Loaded(GlobalContext* globalCtx, AnimationEntryData* data) {
|
|
|
|
AnimationEntryType3* entry = &data->type3;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
if (!(entry->unk_00 & D_8012A480)) {
|
|
|
|
Vec3s* dst = entry->dst;
|
|
|
|
Vec3s* src = entry->src;
|
|
|
|
u8* index = entry->index;
|
|
|
|
s32 i;
|
|
|
|
|
|
|
|
for (i = 0; i < entry->vecCount; i++, dst++, src++) {
|
2020-03-24 17:16:13 +00:00
|
|
|
if (*index++) {
|
2020-03-23 01:24:00 +00:00
|
|
|
*dst = *src;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
void SkelAnime_AnimationType4Loaded(GlobalContext* globalCtx, AnimationEntryData* data) {
|
|
|
|
AnimationEntryType4* entry = &data->type4;
|
|
|
|
|
|
|
|
if (!(entry->unk_00 & D_8012A480)) {
|
|
|
|
Vec3s* dst = entry->dst;
|
|
|
|
Vec3s* src = entry->src;
|
|
|
|
u8* index = entry->index;
|
|
|
|
s32 i;
|
|
|
|
|
|
|
|
for (i = 0; i < entry->vecCount; i++, dst++, src++) {
|
|
|
|
if (!(*index++)) {
|
2020-03-23 01:24:00 +00:00
|
|
|
*dst = *src;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
void SkelAnime_AnimationType5Loaded(GlobalContext* globalCtx, AnimationEntryData* data) {
|
|
|
|
AnimationEntryType5* entry = &data->type5;
|
2020-03-23 01:24:00 +00:00
|
|
|
Actor* actor = entry->actor;
|
2020-03-18 03:15:19 +00:00
|
|
|
Vec3f pos;
|
|
|
|
|
2020-03-23 01:24:00 +00:00
|
|
|
func_800A54FC(entry->skelAnime, &pos, actor->shape.rot.y);
|
|
|
|
actor->posRot.pos.x += pos.x * actor->scale.x;
|
|
|
|
actor->posRot.pos.y += pos.y * actor->scale.y * entry->unk_08;
|
|
|
|
actor->posRot.pos.z += pos.z * actor->scale.z;
|
2020-03-18 03:15:19 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
void func_800A390C(GlobalContext* globalCtx, AnimationContext* animationCtx) {
|
2020-12-02 03:19:56 +00:00
|
|
|
static AnimationEntryCallback sAnimationLoadDone[] = {
|
|
|
|
SkelAnime_LinkAnimationLoaded, SkelAnime_AnimationType1Loaded, SkelAnime_AnimationType2Loaded,
|
|
|
|
SkelAnime_AnimationType3Loaded, SkelAnime_AnimationType4Loaded, SkelAnime_AnimationType5Loaded,
|
|
|
|
};
|
2020-03-20 21:12:26 +00:00
|
|
|
AnimationEntry* entry;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
for (entry = animationCtx->entries; animationCtx->animationCount != 0; entry++, animationCtx->animationCount--) {
|
2020-12-02 03:19:56 +00:00
|
|
|
sAnimationLoadDone[entry->type](globalCtx, &entry->data);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-20 21:12:26 +00:00
|
|
|
D_801600B0 = 1;
|
|
|
|
D_8012A480 = 0;
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
void SkelAnime_InitLinkAnimation(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg,
|
|
|
|
LinkAnimationHeader* segment, s32 flags, Vec3s* limbDrawTbl, Vec3s* transitionDrawTbl,
|
|
|
|
s32 limbBufCount) {
|
|
|
|
FlexSkeletonHeader* skeletonHeader = SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg);
|
|
|
|
s32 headerJointCount = skeletonHeader->sh.limbCount;
|
2020-03-23 21:31:24 +00:00
|
|
|
s32 limbCount;
|
2020-12-02 03:19:56 +00:00
|
|
|
size_t allocSize;
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->initFlags = flags;
|
2020-12-02 03:19:56 +00:00
|
|
|
limbCount = (flags & 2) ? headerJointCount : 1;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-24 19:01:00 +00:00
|
|
|
if (flags & 1) {
|
2020-12-02 03:19:56 +00:00
|
|
|
limbCount += headerJointCount;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-24 19:01:00 +00:00
|
|
|
if (flags & 4) {
|
2020-12-02 03:19:56 +00:00
|
|
|
limbCount += headerJointCount;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-25 15:51:25 +00:00
|
|
|
skelAnime->limbCount = limbCount;
|
|
|
|
skelAnime->dListCount = skeletonHeader->dListCount;
|
2020-03-23 21:31:24 +00:00
|
|
|
|
|
|
|
allocSize = limbCount * sizeof(Vec3s);
|
2020-12-02 03:19:56 +00:00
|
|
|
skelAnime->skeleton = SEGMENTED_TO_VIRTUAL(skeletonHeader->sh.segment);
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-03-24 19:01:00 +00:00
|
|
|
if (flags & 8) {
|
2020-03-23 21:31:24 +00:00
|
|
|
allocSize += 2;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
if (limbDrawTbl == NULL) {
|
|
|
|
skelAnime->limbDrawTbl = ZeldaArena_MallocDebug(allocSize, "../z_skelanime.c", 2364);
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->transitionDrawTbl = ZeldaArena_MallocDebug(allocSize, "../z_skelanime.c", 2365);
|
2020-03-24 17:16:13 +00:00
|
|
|
} else {
|
|
|
|
if (limbBufCount != limbCount) {
|
2020-03-20 21:12:26 +00:00
|
|
|
__assert("joint_buff_num == joint_num", "../z_skelanime.c", 2369);
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
skelAnime->limbDrawTbl = (Vec3s*)ALIGN16((u32)limbDrawTbl);
|
2020-04-01 01:53:53 +00:00
|
|
|
skelAnime->transitionDrawTbl = (Vec3s*)ALIGN16((u32)transitionDrawTbl);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
if ((skelAnime->limbDrawTbl == NULL) || (skelAnime->transitionDrawTbl == NULL)) {
|
2020-03-24 18:06:15 +00:00
|
|
|
osSyncPrintf(VT_FGCOL(RED));
|
2020-03-24 17:16:13 +00:00
|
|
|
osSyncPrintf(
|
|
|
|
"Skeleton_Info_Rom_SV_ct メモリアロケーションエラー\n"); // Skeleton_Info_Rom_SV_ct Memory allocation error
|
2020-03-24 18:06:15 +00:00
|
|
|
osSyncPrintf(VT_RST);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
SkelAnime_ChangeLinkAnim(globalCtx, skelAnime, segment, 1.0f, 0.0f, 0.0f, 0, 0.0f);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
void func_800A3B8C(SkelAnime* skelAnime) {
|
2020-03-31 01:12:49 +00:00
|
|
|
if (skelAnime->mode < 2) {
|
2020-12-02 03:19:56 +00:00
|
|
|
skelAnime->update = func_800A3D70;
|
2020-03-24 17:16:13 +00:00
|
|
|
} else {
|
2020-12-02 03:19:56 +00:00
|
|
|
skelAnime->update = func_800A3E0C;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->transCurrentFrame = 0.0f;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-31 23:29:09 +00:00
|
|
|
s32 func_800A3BC0(GlobalContext* globalCtx, SkelAnime* skelAnime) {
|
2020-12-02 03:19:56 +00:00
|
|
|
return skelAnime->update(globalCtx, skelAnime);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
s32 func_800A3BE4(GlobalContext* globalCtx, SkelAnime* skelAnime) {
|
2020-12-02 03:19:56 +00:00
|
|
|
f32 transPrevFRame = skelAnime->transCurrentFrame;
|
2020-03-23 21:31:24 +00:00
|
|
|
f32 updateRate = R_UPDATE_RATE * 0.5f;
|
|
|
|
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->transCurrentFrame -= skelAnime->transitionStep * updateRate;
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-03-26 03:01:24 +00:00
|
|
|
if (skelAnime->transCurrentFrame <= 0.0f) {
|
2020-03-20 21:12:26 +00:00
|
|
|
func_800A3B8C(skelAnime);
|
|
|
|
}
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->limbDrawTbl, skelAnime->transitionDrawTbl,
|
2020-12-02 03:19:56 +00:00
|
|
|
1.0f - (skelAnime->transCurrentFrame / transPrevFRame));
|
2020-03-20 21:12:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
void func_800A3C9C(GlobalContext* globalCtx, SkelAnime* skelAnime) {
|
2020-12-02 03:19:56 +00:00
|
|
|
SkelAnime_LoadLinkAnimation(globalCtx, skelAnime->animation, skelAnime->animCurrentFrame, skelAnime->limbCount,
|
|
|
|
skelAnime->limbDrawTbl);
|
2020-03-26 03:01:24 +00:00
|
|
|
if (skelAnime->transCurrentFrame != 0) {
|
2020-12-02 03:19:56 +00:00
|
|
|
f32 updateRate = R_UPDATE_RATE * 0.5f;
|
|
|
|
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->transCurrentFrame -= skelAnime->transitionStep * updateRate;
|
|
|
|
if (skelAnime->transCurrentFrame <= 0.0f) {
|
|
|
|
skelAnime->transCurrentFrame = 0.0f;
|
2020-12-02 03:19:56 +00:00
|
|
|
} else {
|
|
|
|
SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->limbDrawTbl,
|
|
|
|
skelAnime->transitionDrawTbl, skelAnime->transCurrentFrame);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
s32 func_800A3D70(GlobalContext* globalCtx, SkelAnime* skelAnime) {
|
2020-03-20 21:12:26 +00:00
|
|
|
f32 updateRate = R_UPDATE_RATE * 0.5f;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-20 21:12:26 +00:00
|
|
|
skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate;
|
2020-03-24 17:16:13 +00:00
|
|
|
if (skelAnime->animCurrentFrame < 0.0f) {
|
2020-03-30 22:53:26 +00:00
|
|
|
skelAnime->animCurrentFrame += skelAnime->totalFrames;
|
|
|
|
} else if (skelAnime->totalFrames <= skelAnime->animCurrentFrame) {
|
|
|
|
skelAnime->animCurrentFrame -= skelAnime->totalFrames;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
func_800A3C9C(globalCtx, skelAnime);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
s32 func_800A3E0C(GlobalContext* globalCtx, SkelAnime* skelAnime) {
|
2020-03-20 21:12:26 +00:00
|
|
|
f32 updateRate = R_UPDATE_RATE * 0.5f;
|
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
if (skelAnime->animCurrentFrame == skelAnime->animFrameCount) {
|
2020-03-20 21:12:26 +00:00
|
|
|
func_800A3C9C(globalCtx, skelAnime);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate;
|
2020-12-02 03:19:56 +00:00
|
|
|
if ((skelAnime->animCurrentFrame - skelAnime->animFrameCount) * skelAnime->animPlaybackSpeed > 0.0f) {
|
2020-03-20 21:12:26 +00:00
|
|
|
skelAnime->animCurrentFrame = skelAnime->animFrameCount;
|
2020-12-02 03:19:56 +00:00
|
|
|
} else if (skelAnime->animCurrentFrame < 0.0f) {
|
|
|
|
skelAnime->animCurrentFrame += skelAnime->totalFrames;
|
|
|
|
} else if (skelAnime->totalFrames <= skelAnime->animCurrentFrame) {
|
|
|
|
skelAnime->animCurrentFrame -= skelAnime->totalFrames;
|
2020-03-23 21:31:24 +00:00
|
|
|
}
|
2020-03-20 21:12:26 +00:00
|
|
|
func_800A3C9C(globalCtx, skelAnime);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-01 01:53:53 +00:00
|
|
|
void SkelAnime_SetTransition(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 transitionRate) {
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->transCurrentFrame = 1.0f;
|
|
|
|
skelAnime->transitionStep = 1.0f / transitionRate;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
void SkelAnime_ChangeLinkAnim(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* segment,
|
2020-04-02 17:44:19 +00:00
|
|
|
f32 playbackSpeed, f32 frame, f32 frameCount, u8 animationMode, f32 transitionRate) {
|
2020-03-31 01:12:49 +00:00
|
|
|
skelAnime->mode = animationMode;
|
2020-12-02 03:19:56 +00:00
|
|
|
if ((transitionRate != 0.0f) && ((segment != skelAnime->animation) || (frame != skelAnime->animCurrentFrame))) {
|
2020-03-30 22:53:26 +00:00
|
|
|
if (transitionRate < 0) {
|
2020-03-20 21:12:26 +00:00
|
|
|
func_800A3B8C(skelAnime);
|
2020-04-18 18:08:12 +00:00
|
|
|
SkelAnime_CopyVec3s(skelAnime, skelAnime->transitionDrawTbl, skelAnime->limbDrawTbl);
|
2020-03-26 03:01:24 +00:00
|
|
|
transitionRate = -transitionRate;
|
2020-03-24 17:16:13 +00:00
|
|
|
} else {
|
2020-12-02 03:19:56 +00:00
|
|
|
skelAnime->update = func_800A3BE4;
|
|
|
|
SkelAnime_LoadLinkAnimation(globalCtx, segment, (s32)frame, skelAnime->limbCount,
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->transitionDrawTbl);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->transCurrentFrame = 1.0f;
|
|
|
|
skelAnime->transitionStep = 1.0f / transitionRate;
|
2020-03-24 17:16:13 +00:00
|
|
|
} else {
|
2020-03-20 21:12:26 +00:00
|
|
|
func_800A3B8C(skelAnime);
|
2020-12-02 03:19:56 +00:00
|
|
|
SkelAnime_LoadLinkAnimation(globalCtx, segment, (s32)frame, skelAnime->limbCount, skelAnime->limbDrawTbl);
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->transCurrentFrame = 0.0f;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
skelAnime->animation = segment;
|
2020-03-23 21:31:24 +00:00
|
|
|
skelAnime->animCurrentFrame = 0.0f;
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->initialFrame = frame;
|
2020-03-25 15:51:25 +00:00
|
|
|
skelAnime->animCurrentFrame = frame;
|
2020-03-20 21:12:26 +00:00
|
|
|
skelAnime->animFrameCount = frameCount;
|
2020-12-02 03:19:56 +00:00
|
|
|
skelAnime->totalFrames = SkelAnime_GetTotalFrames(segment);
|
2020-03-20 21:12:26 +00:00
|
|
|
skelAnime->animPlaybackSpeed = playbackSpeed;
|
|
|
|
}
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
void SkelAnime_ChangeLinkAnimDefaultStop(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* segment) {
|
|
|
|
SkelAnime_ChangeLinkAnim(globalCtx, skelAnime, segment, 1.0f, 0.0f, SkelAnime_GetFrameCount(segment), 2, 0.0f);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
void SkelAnime_ChangeLinkAnimPlaybackStop(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* segment,
|
|
|
|
f32 playbackSpeed) {
|
|
|
|
SkelAnime_ChangeLinkAnim(globalCtx, skelAnime, segment, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(segment), 2,
|
|
|
|
0.0f);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-04-02 17:44:19 +00:00
|
|
|
void SkelAnime_ChangeLinkAnimDefaultRepeat(GlobalContext* globalCtx, SkelAnime* skelAnime,
|
2020-12-02 03:19:56 +00:00
|
|
|
LinkAnimationHeader* segment) {
|
|
|
|
SkelAnime_ChangeLinkAnim(globalCtx, skelAnime, segment, 1.0f, 0.0f, SkelAnime_GetFrameCount(segment), 0, 0.0f);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-04-02 17:44:19 +00:00
|
|
|
void SkelAnime_ChangeLinkAnimPlaybackRepeat(GlobalContext* globalCtx, SkelAnime* skelAnime,
|
2020-12-02 03:19:56 +00:00
|
|
|
LinkAnimationHeader* segment, f32 playbackSpeed) {
|
|
|
|
SkelAnime_ChangeLinkAnim(globalCtx, skelAnime, segment, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(segment), 0,
|
|
|
|
0.0f);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
void func_800A41FC(GlobalContext* globalCtx, SkelAnime* skelAnime) {
|
2020-04-18 18:08:12 +00:00
|
|
|
SkelAnime_LoadAnimationType1(globalCtx, skelAnime->limbCount, skelAnime->transitionDrawTbl, skelAnime->limbDrawTbl);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
// Unused
|
2020-03-24 17:16:13 +00:00
|
|
|
void func_800A422C(GlobalContext* globalCtx, SkelAnime* skelAnime) {
|
2020-04-18 18:08:12 +00:00
|
|
|
SkelAnime_LoadAnimationType1(globalCtx, skelAnime->limbCount, skelAnime->limbDrawTbl, skelAnime->transitionDrawTbl);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
void func_800A425C(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* segment, f32 frame) {
|
|
|
|
SkelAnime_LoadLinkAnimation(globalCtx, segment, (s32)frame, skelAnime->limbCount, skelAnime->transitionDrawTbl);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
void func_800A42A0(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* segment, f32 frame) {
|
|
|
|
SkelAnime_LoadLinkAnimation(globalCtx, segment, (s32)frame, skelAnime->limbCount, skelAnime->limbDrawTbl);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-04-01 01:53:53 +00:00
|
|
|
void func_800A42E4(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 frame) {
|
2020-04-18 18:08:12 +00:00
|
|
|
SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->limbDrawTbl, skelAnime->transitionDrawTbl,
|
2020-04-01 01:53:53 +00:00
|
|
|
frame);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
void func_800A431C(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* segment, f32 transitionFrame,
|
|
|
|
LinkAnimationHeader* linkAnimSeg2, f32 frame, f32 transitionRate, Vec3s* limbDrawTbl) {
|
2020-04-18 18:08:12 +00:00
|
|
|
Vec3s* alignedLimbDrawTbl;
|
2020-12-02 03:19:56 +00:00
|
|
|
|
|
|
|
SkelAnime_LoadLinkAnimation(globalCtx, segment, (s32)transitionFrame, skelAnime->limbCount, skelAnime->limbDrawTbl);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
alignedLimbDrawTbl = (Vec3s*)ALIGN16((u32)limbDrawTbl);
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
SkelAnime_LoadLinkAnimation(globalCtx, linkAnimSeg2, (s32)frame, skelAnime->limbCount, alignedLimbDrawTbl);
|
2020-04-18 18:08:12 +00:00
|
|
|
SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->limbDrawTbl, alignedLimbDrawTbl,
|
2020-04-01 01:53:53 +00:00
|
|
|
transitionRate);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
void func_800A43B8(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* segment, f32 transitionFrame,
|
|
|
|
LinkAnimationHeader* linkAnimSeg2, f32 frame, f32 transitionRate, Vec3s* limbDrawTbl) {
|
2020-04-18 18:08:12 +00:00
|
|
|
Vec3s* alignedLimbDrawTbl;
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
SkelAnime_LoadLinkAnimation(globalCtx, segment, (s32)transitionFrame, skelAnime->limbCount,
|
2020-04-01 01:19:21 +00:00
|
|
|
skelAnime->transitionDrawTbl);
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
alignedLimbDrawTbl = (Vec3s*)ALIGN16((u32)limbDrawTbl);
|
2020-03-23 21:31:24 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
SkelAnime_LoadLinkAnimation(globalCtx, linkAnimSeg2, (s32)frame, skelAnime->limbCount, alignedLimbDrawTbl);
|
2020-04-18 18:08:12 +00:00
|
|
|
SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->transitionDrawTbl, alignedLimbDrawTbl,
|
2020-04-01 01:53:53 +00:00
|
|
|
transitionRate);
|
2020-03-23 21:31:24 +00:00
|
|
|
}
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
// unused
|
2020-04-01 01:53:53 +00:00
|
|
|
void SkelAnime_SetModeStop(SkelAnime* skelAnime) {
|
2020-03-31 01:12:49 +00:00
|
|
|
skelAnime->mode = 2;
|
2020-03-20 21:12:26 +00:00
|
|
|
func_800A3B8C(skelAnime);
|
|
|
|
}
|
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
s32 func_800A4478(SkelAnime* skelAnime, f32 arg1, f32 updateRate) {
|
2020-12-02 03:19:56 +00:00
|
|
|
f32 updateSpeed = skelAnime->animPlaybackSpeed * updateRate;
|
|
|
|
f32 nextFrame = skelAnime->animCurrentFrame - updateSpeed;
|
2020-03-20 21:12:26 +00:00
|
|
|
f32 temp_f12;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
if (nextFrame < 0.0f) {
|
2020-03-30 22:53:26 +00:00
|
|
|
nextFrame += skelAnime->totalFrames;
|
2020-04-01 01:19:21 +00:00
|
|
|
} else if (skelAnime->totalFrames <= nextFrame) {
|
2020-03-31 23:29:09 +00:00
|
|
|
nextFrame -= skelAnime->totalFrames;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-31 23:29:09 +00:00
|
|
|
|
|
|
|
if ((arg1 == 0.0f) && (updateSpeed > 0.0f)) {
|
|
|
|
arg1 = skelAnime->totalFrames;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-31 23:29:09 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
temp_f12 = nextFrame + updateSpeed - arg1;
|
|
|
|
if ((temp_f12 * updateSpeed >= 0.0f) && (((temp_f12 - updateSpeed) * updateSpeed) < 0.0f)) {
|
2020-03-31 23:29:09 +00:00
|
|
|
return 1;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
s32 func_800A4530(SkelAnime* skelAnime, f32 arg1) {
|
2020-03-20 21:12:26 +00:00
|
|
|
f32 updateRate = R_UPDATE_RATE * 0.5f;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-20 21:12:26 +00:00
|
|
|
return func_800A4478(skelAnime, arg1, updateRate);
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-03 21:51:22 +00:00
|
|
|
s32 SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg,
|
|
|
|
AnimationHeader* animationSeg, Vec3s* limbDrawTbl, Vec3s* transitionDrawTable, s32 limbCount) {
|
2020-12-02 03:19:56 +00:00
|
|
|
SkeletonHeader* skeletonHeader = SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-25 15:51:25 +00:00
|
|
|
skelAnime->limbCount = skeletonHeader->limbCount + 1;
|
2020-12-02 03:19:56 +00:00
|
|
|
skelAnime->skeleton = SEGMENTED_TO_VIRTUAL(skeletonHeader->segment);
|
2020-04-18 18:08:12 +00:00
|
|
|
if (limbDrawTbl == NULL) {
|
|
|
|
skelAnime->limbDrawTbl =
|
|
|
|
ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->limbDrawTbl), "../z_skelanime.c", 2968);
|
2020-04-01 01:19:21 +00:00
|
|
|
skelAnime->transitionDrawTbl = ZeldaArena_MallocDebug(
|
|
|
|
skelAnime->limbCount * sizeof(*skelAnime->transitionDrawTbl), "../z_skelanime.c", 2969);
|
2020-03-24 17:16:13 +00:00
|
|
|
} else {
|
|
|
|
if (limbCount != skelAnime->limbCount) {
|
2020-03-20 21:12:26 +00:00
|
|
|
__assert("joint_buff_num == this->joint_num", "../z_skelanime.c", 2973);
|
|
|
|
}
|
2020-04-18 18:08:12 +00:00
|
|
|
skelAnime->limbDrawTbl = limbDrawTbl;
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->transitionDrawTbl = transitionDrawTable;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-04-18 18:08:12 +00:00
|
|
|
if ((skelAnime->limbDrawTbl == NULL) || (skelAnime->transitionDrawTbl == NULL)) {
|
2020-03-24 18:06:15 +00:00
|
|
|
osSyncPrintf(VT_FGCOL(RED));
|
2020-03-20 21:12:26 +00:00
|
|
|
osSyncPrintf("Skeleton_Info2_ct メモリアロケーションエラー\n"); // Skeleton_Info2_ct memory allocation error
|
2020-03-24 18:06:15 +00:00
|
|
|
osSyncPrintf(VT_RST);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-03-25 15:51:25 +00:00
|
|
|
if (animationSeg != NULL) {
|
2020-04-02 17:44:19 +00:00
|
|
|
SkelAnime_ChangeAnimDefaultRepeat(skelAnime, animationSeg);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-24 16:52:12 +00:00
|
|
|
|
Poe Actor Decomps (#463)
* Poe actors progress
* Some more progress, En_Poh almost matching
* Further progress
* Fix merge
* Decompile data
* Actor struct cleanups
* More functions OK
* Progress
* Last function decompiled, some nonmatchings left
* Few more OK, skelanime_init definition changes
* Progress
* Style improvements, OPEN/CLOSE_DISPS, few more OK
* Few more style improvements, function prototype additions/changes, another function OK
* Remove unused asm, begin documentation
* Use generated reloc
* Cleanup, format
* Remove a few no longer needed comments
* PR suggestions
* DISP macros
* Missed some FrameUpdateMatrix != 0 replacements
* EnPoField_InteractWithSoul -> EnPoField_SoulInteract, eyeImageIdx -> eyeTextureIdx
* Fix merge, reformat
* Review Suggestions
Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>
* Further review suggestions
* Ran formatter
* Less DECR usage
Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>
2020-12-05 00:34:27 +00:00
|
|
|
s32 SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg,
|
|
|
|
AnimationHeader* animationSeg, Vec3s* limbDrawTbl, Vec3s* transitionDrawTable, s32 limbCount) {
|
2020-12-02 03:19:56 +00:00
|
|
|
FlexSkeletonHeader* skeletonHeader = SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg);
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
skelAnime->limbCount = skeletonHeader->sh.limbCount + 1;
|
2020-03-25 15:51:25 +00:00
|
|
|
skelAnime->dListCount = skeletonHeader->dListCount;
|
2020-12-02 03:19:56 +00:00
|
|
|
skelAnime->skeleton = SEGMENTED_TO_VIRTUAL(skeletonHeader->sh.segment);
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-04-18 18:08:12 +00:00
|
|
|
if (limbDrawTbl == NULL) {
|
|
|
|
skelAnime->limbDrawTbl =
|
|
|
|
ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->limbDrawTbl), "../z_skelanime.c", 3047);
|
2020-03-24 16:52:12 +00:00
|
|
|
|
2020-04-01 01:19:21 +00:00
|
|
|
skelAnime->transitionDrawTbl = ZeldaArena_MallocDebug(
|
|
|
|
skelAnime->limbCount * sizeof(*skelAnime->transitionDrawTbl), "../z_skelanime.c", 3048);
|
2020-03-24 17:16:13 +00:00
|
|
|
} else {
|
|
|
|
if (limbCount != skelAnime->limbCount) {
|
2020-03-24 18:06:15 +00:00
|
|
|
__assert("joint_buff_num == this->joint_num", "../z_skelanime.c", 3052);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-04-18 18:08:12 +00:00
|
|
|
skelAnime->limbDrawTbl = limbDrawTbl;
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->transitionDrawTbl = transitionDrawTable;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-04-18 18:08:12 +00:00
|
|
|
if ((skelAnime->limbDrawTbl == NULL) || (skelAnime->transitionDrawTbl == NULL)) {
|
2020-03-24 18:06:15 +00:00
|
|
|
osSyncPrintf(VT_FGCOL(RED));
|
2020-03-24 17:16:13 +00:00
|
|
|
osSyncPrintf(
|
|
|
|
"Skeleton_Info_Rom_SV_ct メモリアロケーションエラー\n"); // Skeleton_Info_Rom_SV_ct Memory allocation error
|
2020-03-24 18:06:15 +00:00
|
|
|
osSyncPrintf(VT_RST);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-03-25 15:51:25 +00:00
|
|
|
if (animationSeg != NULL) {
|
2020-04-02 17:44:19 +00:00
|
|
|
SkelAnime_ChangeAnimDefaultRepeat(skelAnime, animationSeg);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-24 16:52:12 +00:00
|
|
|
|
2020-03-25 15:51:25 +00:00
|
|
|
void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg,
|
|
|
|
AnimationHeader* animationSeg) {
|
2020-12-02 03:19:56 +00:00
|
|
|
SkeletonHeader* skeletonHeader = SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg);
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-03-25 15:51:25 +00:00
|
|
|
skelAnime->limbCount = skeletonHeader->limbCount + 1;
|
2020-12-02 03:19:56 +00:00
|
|
|
skelAnime->skeleton = SEGMENTED_TO_VIRTUAL(skeletonHeader->segment);
|
2020-04-18 18:08:12 +00:00
|
|
|
skelAnime->limbDrawTbl =
|
|
|
|
ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->limbDrawTbl), "../z_skelanime.c", 3120);
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->transitionDrawTbl =
|
|
|
|
ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->transitionDrawTbl), "../z_skelanime.c", 3121);
|
2020-04-18 18:08:12 +00:00
|
|
|
if ((skelAnime->limbDrawTbl == NULL) || (skelAnime->transitionDrawTbl == NULL)) {
|
2020-03-24 18:06:15 +00:00
|
|
|
osSyncPrintf(VT_FGCOL(RED));
|
2020-03-24 17:16:13 +00:00
|
|
|
osSyncPrintf(
|
|
|
|
"Skeleton_Info2_skin2_ct メモリアロケーションエラー\n"); // Skeleton_Info2_skin2_ct Memory allocation error
|
2020-03-24 18:06:15 +00:00
|
|
|
osSyncPrintf(VT_RST);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-03-25 15:51:25 +00:00
|
|
|
if (animationSeg != NULL) {
|
2020-04-02 17:44:19 +00:00
|
|
|
SkelAnime_ChangeAnimDefaultRepeat(skelAnime, animationSeg);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
void func_800A49B0(SkelAnime* skelAnime) {
|
2020-03-31 01:12:49 +00:00
|
|
|
if (skelAnime->mode < 2) {
|
2020-12-02 03:19:56 +00:00
|
|
|
skelAnime->update = func_800A4D9C;
|
2020-03-31 01:12:49 +00:00
|
|
|
} else if (skelAnime->mode < 4) {
|
2020-12-02 03:19:56 +00:00
|
|
|
skelAnime->update = func_800A4EE0;
|
2020-03-24 19:01:00 +00:00
|
|
|
} else {
|
2020-12-02 03:19:56 +00:00
|
|
|
skelAnime->update = func_800A4E38;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
s32 SkelAnime_FrameUpdateMatrix(SkelAnime* skelAnime) {
|
2020-12-02 03:19:56 +00:00
|
|
|
return skelAnime->update(skelAnime);
|
2020-03-18 03:15:19 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
s32 func_800A4A20(SkelAnime* skelAnime) {
|
2020-12-02 03:19:56 +00:00
|
|
|
f32 transPrevFrame = skelAnime->transCurrentFrame;
|
|
|
|
f32 updateRate = R_UPDATE_RATE * (1.0f / 3.0f);
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->transCurrentFrame -= skelAnime->transitionStep * updateRate;
|
|
|
|
if (skelAnime->transCurrentFrame <= 0.0f) {
|
2020-03-20 21:12:26 +00:00
|
|
|
func_800A49B0(skelAnime);
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->transCurrentFrame = 0.0f;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-04-18 18:08:12 +00:00
|
|
|
SkelAnime_InterpolateVec3s(skelAnime->limbCount, skelAnime->limbDrawTbl, skelAnime->limbDrawTbl,
|
2020-12-02 03:19:56 +00:00
|
|
|
skelAnime->transitionDrawTbl, 1.0f - (skelAnime->transCurrentFrame / transPrevFrame));
|
2020-03-20 21:12:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
s32 func_800A4AD8(SkelAnime* skelAnime) {
|
2020-12-02 03:19:56 +00:00
|
|
|
s16 temp_a2 = skelAnime->transCurrentFrame * 0x4000;
|
2020-03-30 22:53:26 +00:00
|
|
|
s16 temp_a1;
|
2020-03-24 19:01:00 +00:00
|
|
|
f32 sp28;
|
2020-03-20 21:12:26 +00:00
|
|
|
f32 phi_f2;
|
2020-12-02 03:19:56 +00:00
|
|
|
f32 updateRate = R_UPDATE_RATE * (1.0f / 3.0f);
|
2020-03-20 21:12:26 +00:00
|
|
|
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->transCurrentFrame -= skelAnime->transitionStep * updateRate;
|
|
|
|
if (skelAnime->transCurrentFrame <= 0.0f) {
|
2020-03-20 21:12:26 +00:00
|
|
|
func_800A49B0(skelAnime);
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->transCurrentFrame = 0.0f;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-12-02 03:19:56 +00:00
|
|
|
temp_a1 = skelAnime->transCurrentFrame * 0x4000;
|
2020-03-24 17:16:13 +00:00
|
|
|
if (skelAnime->unk_03 < 0) {
|
2020-12-26 10:44:53 +00:00
|
|
|
sp28 = 1.0f - Math_CosS(temp_a2);
|
|
|
|
phi_f2 = 1.0f - Math_CosS(temp_a1);
|
2020-03-24 17:16:13 +00:00
|
|
|
} else {
|
2020-12-26 10:44:53 +00:00
|
|
|
sp28 = Math_SinS(temp_a2);
|
|
|
|
phi_f2 = Math_SinS(temp_a1);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-24 17:16:13 +00:00
|
|
|
if (phi_f2 != 0.0f) {
|
2020-03-20 21:12:26 +00:00
|
|
|
phi_f2 /= sp28;
|
2020-03-24 17:16:13 +00:00
|
|
|
} else {
|
2020-03-20 21:12:26 +00:00
|
|
|
phi_f2 = 0.0f;
|
|
|
|
}
|
2020-04-18 18:08:12 +00:00
|
|
|
SkelAnime_InterpolateVec3s(skelAnime->limbCount, skelAnime->limbDrawTbl, skelAnime->limbDrawTbl,
|
2020-04-01 01:19:21 +00:00
|
|
|
skelAnime->transitionDrawTbl, 1.0f - phi_f2);
|
2020-03-20 21:12:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
void func_800A4C58(SkelAnime* skelAnime) {
|
2020-12-02 03:19:56 +00:00
|
|
|
Vec3s sp38[100];
|
|
|
|
|
|
|
|
SkelAnime_AnimateFrame(skelAnime->animation, skelAnime->animCurrentFrame, skelAnime->limbCount,
|
2020-04-18 18:08:12 +00:00
|
|
|
skelAnime->limbDrawTbl);
|
2020-12-02 03:19:56 +00:00
|
|
|
if (skelAnime->mode & 1) {
|
|
|
|
s32 t = skelAnime->animCurrentFrame;
|
|
|
|
f32 sp30 = skelAnime->animCurrentFrame - t;
|
|
|
|
|
|
|
|
if (++t >= (s32)skelAnime->totalFrames) {
|
2020-03-31 23:29:09 +00:00
|
|
|
t = 0;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-12-02 03:19:56 +00:00
|
|
|
SkelAnime_AnimateFrame(skelAnime->animation, t, skelAnime->limbCount, sp38);
|
|
|
|
SkelAnime_InterpolateVec3s(skelAnime->limbCount, skelAnime->limbDrawTbl, skelAnime->limbDrawTbl, sp38, sp30);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-26 03:01:24 +00:00
|
|
|
if (skelAnime->transCurrentFrame != 0) {
|
2020-12-02 03:19:56 +00:00
|
|
|
f32 updateRate = R_UPDATE_RATE * (1.0f / 3.0f);
|
|
|
|
|
2020-03-31 23:29:09 +00:00
|
|
|
skelAnime->transCurrentFrame -= skelAnime->transitionStep * updateRate;
|
|
|
|
if (skelAnime->transCurrentFrame <= 0.0f) {
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->transCurrentFrame = 0.0f;
|
2020-12-02 03:19:56 +00:00
|
|
|
} else {
|
|
|
|
SkelAnime_InterpolateVec3s(skelAnime->limbCount, skelAnime->limbDrawTbl, skelAnime->limbDrawTbl,
|
|
|
|
skelAnime->transitionDrawTbl, skelAnime->transCurrentFrame);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
s32 func_800A4D9C(SkelAnime* skelAnime) {
|
2020-04-02 17:44:19 +00:00
|
|
|
f32 updateRate = R_UPDATE_RATE * (1.0f / 3.0f);
|
2020-12-02 03:19:56 +00:00
|
|
|
|
2020-03-25 15:51:25 +00:00
|
|
|
skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate;
|
2020-03-24 17:16:13 +00:00
|
|
|
if (skelAnime->animCurrentFrame < 0.0f) {
|
2020-03-30 22:53:26 +00:00
|
|
|
skelAnime->animCurrentFrame += skelAnime->totalFrames;
|
|
|
|
} else if (skelAnime->totalFrames <= skelAnime->animCurrentFrame) {
|
|
|
|
skelAnime->animCurrentFrame -= skelAnime->totalFrames;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
func_800A4C58(skelAnime);
|
|
|
|
return 0;
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
s32 func_800A4E38(SkelAnime* skelAnime) {
|
2020-04-02 17:44:19 +00:00
|
|
|
f32 updateRate = R_UPDATE_RATE * (1.0f / 3.0f);
|
2020-12-02 03:19:56 +00:00
|
|
|
|
2020-03-25 15:51:25 +00:00
|
|
|
skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate;
|
2020-03-26 03:01:24 +00:00
|
|
|
if (skelAnime->animCurrentFrame < skelAnime->initialFrame) {
|
2020-04-01 01:19:21 +00:00
|
|
|
skelAnime->animCurrentFrame =
|
|
|
|
(skelAnime->animCurrentFrame - skelAnime->initialFrame) + skelAnime->animFrameCount;
|
2020-03-25 15:51:25 +00:00
|
|
|
} else if (skelAnime->animFrameCount <= skelAnime->animCurrentFrame) {
|
2020-04-01 01:19:21 +00:00
|
|
|
skelAnime->animCurrentFrame =
|
|
|
|
(skelAnime->animCurrentFrame - skelAnime->animFrameCount) + skelAnime->initialFrame;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-25 15:51:25 +00:00
|
|
|
|
2020-03-20 21:12:26 +00:00
|
|
|
func_800A4C58(skelAnime);
|
|
|
|
return 0;
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
s32 func_800A4EE0(SkelAnime* skelAnime) {
|
2020-12-02 03:19:56 +00:00
|
|
|
f32 updateRate = R_UPDATE_RATE * (1.0f / 3.0f);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
if (skelAnime->animCurrentFrame == skelAnime->animFrameCount) {
|
2020-12-02 03:19:56 +00:00
|
|
|
SkelAnime_AnimateFrame(skelAnime->animation, (s32)skelAnime->animCurrentFrame, skelAnime->limbCount,
|
2020-04-18 18:08:12 +00:00
|
|
|
skelAnime->limbDrawTbl);
|
2020-03-20 21:12:26 +00:00
|
|
|
func_800A4C58(skelAnime);
|
|
|
|
return 1;
|
|
|
|
}
|
2020-12-02 03:19:56 +00:00
|
|
|
|
2020-04-01 01:19:21 +00:00
|
|
|
skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate;
|
2020-12-02 03:19:56 +00:00
|
|
|
|
|
|
|
if ((skelAnime->animCurrentFrame - skelAnime->animFrameCount) * skelAnime->animPlaybackSpeed > 0.0f) {
|
2020-03-20 21:12:26 +00:00
|
|
|
skelAnime->animCurrentFrame = skelAnime->animFrameCount;
|
2020-12-02 03:19:56 +00:00
|
|
|
} else if (skelAnime->animCurrentFrame < 0.0f) {
|
|
|
|
skelAnime->animCurrentFrame += skelAnime->totalFrames;
|
|
|
|
} else if (skelAnime->totalFrames <= skelAnime->animCurrentFrame) {
|
|
|
|
skelAnime->animCurrentFrame -= skelAnime->totalFrames;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
func_800A4C58(skelAnime);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-02 17:44:19 +00:00
|
|
|
void SkelAnime_ChangeAnimImpl(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed, f32 frame,
|
|
|
|
f32 frameCount, u8 animationType, f32 transitionRate, s8 unk2) {
|
2020-03-31 01:12:49 +00:00
|
|
|
skelAnime->mode = animationType;
|
2020-03-25 15:51:25 +00:00
|
|
|
if ((transitionRate != 0.0f) &&
|
2020-12-02 03:19:56 +00:00
|
|
|
((animationSeg != skelAnime->animation) || (frame != skelAnime->animCurrentFrame))) {
|
2020-03-25 15:51:25 +00:00
|
|
|
if (transitionRate < 0) {
|
2020-03-20 21:12:26 +00:00
|
|
|
func_800A49B0(skelAnime);
|
2020-04-18 18:08:12 +00:00
|
|
|
SkelAnime_CopyVec3s(skelAnime, skelAnime->transitionDrawTbl, skelAnime->limbDrawTbl);
|
2020-03-20 21:12:26 +00:00
|
|
|
transitionRate = -transitionRate;
|
2020-03-24 17:16:13 +00:00
|
|
|
} else {
|
|
|
|
if (unk2 != 0) {
|
2020-12-02 03:19:56 +00:00
|
|
|
skelAnime->update = func_800A4AD8;
|
2020-03-20 21:12:26 +00:00
|
|
|
skelAnime->unk_03 = unk2;
|
2020-03-24 17:16:13 +00:00
|
|
|
} else {
|
2020-12-02 03:19:56 +00:00
|
|
|
skelAnime->update = func_800A4A20;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-26 03:01:24 +00:00
|
|
|
SkelAnime_AnimateFrame(animationSeg, frame, skelAnime->limbCount, skelAnime->transitionDrawTbl);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->transCurrentFrame = 1.0f;
|
|
|
|
skelAnime->transitionStep = 1.0f / transitionRate;
|
2020-03-24 17:16:13 +00:00
|
|
|
} else {
|
2020-03-20 21:12:26 +00:00
|
|
|
func_800A49B0(skelAnime);
|
2020-04-18 18:08:12 +00:00
|
|
|
SkelAnime_AnimateFrame(animationSeg, frame, skelAnime->limbCount, skelAnime->limbDrawTbl);
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->transCurrentFrame = 0.0f;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
skelAnime->animation = animationSeg;
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->initialFrame = frame;
|
2020-03-20 21:12:26 +00:00
|
|
|
skelAnime->animFrameCount = frameCount;
|
2020-12-02 03:19:56 +00:00
|
|
|
skelAnime->totalFrames = SkelAnime_GetTotalFrames(animationSeg);
|
2020-03-31 01:12:49 +00:00
|
|
|
if (skelAnime->mode >= 4) {
|
2020-03-20 21:12:26 +00:00
|
|
|
skelAnime->animCurrentFrame = 0.0f;
|
2020-03-24 17:16:13 +00:00
|
|
|
} else {
|
2020-03-25 15:51:25 +00:00
|
|
|
skelAnime->animCurrentFrame = frame;
|
2020-12-02 03:19:56 +00:00
|
|
|
if (skelAnime->mode <= 1) {
|
2020-03-30 22:53:26 +00:00
|
|
|
skelAnime->animFrameCount = skelAnime->totalFrames - 1.0f;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
skelAnime->animPlaybackSpeed = playbackSpeed;
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-04-02 17:44:19 +00:00
|
|
|
void SkelAnime_ChangeAnim(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed, f32 frame,
|
|
|
|
f32 frameCount, u8 mode, f32 transitionRate) {
|
|
|
|
SkelAnime_ChangeAnimImpl(skelAnime, animationSeg, playbackSpeed, frame, frameCount, mode, transitionRate, 0);
|
2020-03-18 03:15:19 +00:00
|
|
|
}
|
2020-03-31 23:29:09 +00:00
|
|
|
|
2020-04-02 17:44:19 +00:00
|
|
|
void SkelAnime_ChangeAnimDefaultStop(SkelAnime* skelAnime, AnimationHeader* animationSeg) {
|
2020-12-02 03:19:56 +00:00
|
|
|
SkelAnime_ChangeAnim(skelAnime, animationSeg, 1.0f, 0.0f, SkelAnime_GetFrameCount(animationSeg), 2, 0.0f);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-04-02 17:44:19 +00:00
|
|
|
void SkelAnime_ChangeAnimTransitionStop(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 transitionRate) {
|
2020-12-02 03:19:56 +00:00
|
|
|
SkelAnime_ChangeAnim(skelAnime, animationSeg, 1.0f, 0, SkelAnime_GetFrameCount(animationSeg), 2, transitionRate);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-31 23:29:09 +00:00
|
|
|
|
2020-04-02 17:44:19 +00:00
|
|
|
void SkelAnime_ChangeAnimPlaybackStop(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed) {
|
2020-12-02 03:19:56 +00:00
|
|
|
SkelAnime_ChangeAnim(skelAnime, animationSeg, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(animationSeg), 2, 0.0f);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-04-02 17:44:19 +00:00
|
|
|
void SkelAnime_ChangeAnimDefaultRepeat(SkelAnime* skelAnime, AnimationHeader* animationSeg) {
|
2020-12-02 03:19:56 +00:00
|
|
|
SkelAnime_ChangeAnim(skelAnime, animationSeg, 1.0f, 0.0f, SkelAnime_GetFrameCount(animationSeg), 0, 0.0f);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-04-02 17:44:19 +00:00
|
|
|
void SkelAnime_ChangeAnimTransitionRepeat(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 transitionRate) {
|
|
|
|
SkelAnime_ChangeAnim(skelAnime, animationSeg, 1.0f, 0.0f, 0.0f, 0, transitionRate);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2020-04-02 17:44:19 +00:00
|
|
|
void SkelAnime_ChangeAnimPlaybackRepeat(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed) {
|
2020-12-02 03:19:56 +00:00
|
|
|
SkelAnime_ChangeAnim(skelAnime, animationSeg, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(animationSeg), 0, 0.0f);
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
// unused
|
2020-04-02 17:44:19 +00:00
|
|
|
void SkelAnime_AnimSetStop(SkelAnime* skelAnime) {
|
2020-03-31 01:12:49 +00:00
|
|
|
skelAnime->mode = 2;
|
2020-03-30 22:53:26 +00:00
|
|
|
skelAnime->animFrameCount = skelAnime->totalFrames;
|
2020-03-20 21:12:26 +00:00
|
|
|
func_800A49B0(skelAnime);
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-04-02 17:44:19 +00:00
|
|
|
void SkelAnime_AnimReverse(SkelAnime* skelAnime) {
|
2020-03-31 23:29:09 +00:00
|
|
|
f32 initialFrame = skelAnime->initialFrame;
|
|
|
|
|
|
|
|
skelAnime->initialFrame = skelAnime->animFrameCount;
|
2020-03-25 15:51:25 +00:00
|
|
|
skelAnime->animPlaybackSpeed = -skelAnime->animPlaybackSpeed;
|
2020-03-31 23:29:09 +00:00
|
|
|
skelAnime->animFrameCount = initialFrame;
|
2020-03-20 21:12:26 +00:00
|
|
|
}
|
2020-03-23 01:57:25 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
void func_800A5428(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* index) {
|
2020-03-23 01:57:25 +00:00
|
|
|
s32 i;
|
2020-12-02 03:19:56 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
for (i = 0; i < skelAnime->limbCount; i++, dst++, src++) {
|
|
|
|
if (*index++) {
|
2020-03-23 01:57:25 +00:00
|
|
|
*dst = *src;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-12-02 03:19:56 +00:00
|
|
|
// unused
|
2020-03-24 17:16:13 +00:00
|
|
|
void func_800A5490(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* arg3) {
|
2020-03-23 01:57:25 +00:00
|
|
|
s32 i;
|
2020-12-02 03:19:56 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
for (i = 0; i < skelAnime->limbCount; i++, dst++, src++) {
|
|
|
|
if (*arg3++ < 1U) {
|
2020-03-23 01:57:25 +00:00
|
|
|
*dst = *src;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-26 03:01:24 +00:00
|
|
|
/*
|
|
|
|
* Moves `pos` backwards on the xz plane from `angle`
|
2020-04-01 01:19:21 +00:00
|
|
|
*/
|
2020-03-24 17:16:13 +00:00
|
|
|
void func_800A54FC(SkelAnime* skelAnime, Vec3f* pos, s16 angle) {
|
2020-03-23 01:57:25 +00:00
|
|
|
f32 x;
|
|
|
|
f32 z;
|
|
|
|
f32 sin;
|
|
|
|
f32 cos;
|
2020-03-18 03:15:19 +00:00
|
|
|
|
2020-03-26 03:01:24 +00:00
|
|
|
if (skelAnime->flags & 0x10) {
|
2020-12-02 03:19:56 +00:00
|
|
|
pos->x = pos->z = 0.0f;
|
2020-03-24 17:16:13 +00:00
|
|
|
} else {
|
2020-03-26 03:01:24 +00:00
|
|
|
// `angle` rotation around y axis.
|
2020-12-02 03:19:56 +00:00
|
|
|
x = skelAnime->limbDrawTbl[0].x;
|
|
|
|
z = skelAnime->limbDrawTbl[0].z;
|
2020-12-26 10:44:53 +00:00
|
|
|
sin = Math_SinS(angle);
|
|
|
|
cos = Math_CosS(angle);
|
2020-03-23 01:57:25 +00:00
|
|
|
pos->x = x * cos + z * sin;
|
|
|
|
pos->z = z * cos - x * sin;
|
2020-03-26 03:01:24 +00:00
|
|
|
x = skelAnime->prevFramePos.x;
|
|
|
|
z = skelAnime->prevFramePos.z;
|
|
|
|
// `prevFrameRot` rotation around y axis.
|
2020-12-26 10:44:53 +00:00
|
|
|
sin = Math_SinS(skelAnime->prevFrameRot);
|
|
|
|
cos = Math_CosS(skelAnime->prevFrameRot);
|
2020-03-23 01:57:25 +00:00
|
|
|
pos->x -= x * cos + z * sin;
|
|
|
|
pos->z -= z * cos - x * sin;
|
|
|
|
}
|
|
|
|
|
2020-03-26 03:01:24 +00:00
|
|
|
skelAnime->prevFrameRot = angle;
|
2020-12-02 03:19:56 +00:00
|
|
|
skelAnime->prevFramePos.x = skelAnime->limbDrawTbl[0].x;
|
|
|
|
skelAnime->limbDrawTbl[0].x = skelAnime->unk_3E.x;
|
|
|
|
skelAnime->prevFramePos.z = skelAnime->limbDrawTbl[0].z;
|
|
|
|
skelAnime->limbDrawTbl[0].z = skelAnime->unk_3E.z;
|
2020-04-02 17:44:19 +00:00
|
|
|
if (skelAnime->flags & ANIM_FLAG_UPDATEXZ) {
|
|
|
|
if (skelAnime->flags & ANIM_FLAG_UPDATEY) {
|
2020-03-23 01:57:25 +00:00
|
|
|
pos->y = 0.0f;
|
2020-03-24 17:16:13 +00:00
|
|
|
} else {
|
2020-12-02 03:19:56 +00:00
|
|
|
pos->y = skelAnime->limbDrawTbl[0].y - skelAnime->prevFramePos.y;
|
2020-03-23 01:57:25 +00:00
|
|
|
}
|
2020-12-02 03:19:56 +00:00
|
|
|
skelAnime->prevFramePos.y = skelAnime->limbDrawTbl[0].y;
|
|
|
|
skelAnime->limbDrawTbl[0].y = skelAnime->unk_3E.y;
|
2020-03-24 17:16:13 +00:00
|
|
|
} else {
|
2020-03-23 01:57:25 +00:00
|
|
|
pos->y = 0.0f;
|
2020-12-02 03:19:56 +00:00
|
|
|
skelAnime->prevFramePos.y = skelAnime->limbDrawTbl[0].y;
|
2020-03-23 01:57:25 +00:00
|
|
|
}
|
2020-04-02 17:44:19 +00:00
|
|
|
skelAnime->flags &= ~ANIM_FLAG_UPDATEY;
|
2020-03-23 01:57:25 +00:00
|
|
|
}
|
2020-03-18 03:15:19 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
s32 func_800A56C8(SkelAnime* skelAnime, f32 arg1) {
|
2020-03-23 01:57:25 +00:00
|
|
|
return func_800A4478(skelAnime, arg1, 1.0f);
|
|
|
|
}
|
2020-03-18 03:15:19 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
void SkelAnime_Free(SkelAnime* skelAnime, GlobalContext* globalCtx) {
|
2020-04-18 18:08:12 +00:00
|
|
|
if (skelAnime->limbDrawTbl != NULL) {
|
|
|
|
ZeldaArena_FreeDebug(skelAnime->limbDrawTbl, "../z_skelanime.c", 3729);
|
2020-03-24 17:16:13 +00:00
|
|
|
} else {
|
2020-03-23 01:57:25 +00:00
|
|
|
osSyncPrintf("now_joint あきまへん!!\n"); // now_joint Akimane! !
|
|
|
|
}
|
2020-03-24 19:01:00 +00:00
|
|
|
|
2020-03-26 03:01:24 +00:00
|
|
|
if (skelAnime->transitionDrawTbl != NULL) {
|
|
|
|
ZeldaArena_FreeDebug(skelAnime->transitionDrawTbl, "../z_skelanime.c", 3731);
|
2020-03-24 19:01:00 +00:00
|
|
|
} else {
|
|
|
|
osSyncPrintf("morf_joint あきまへん!!\n"); // "morf_joint Akimane !!"
|
2020-03-23 01:57:25 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-18 03:15:19 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
void SkelAnime_CopyVec3s(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src) {
|
2020-03-23 01:57:25 +00:00
|
|
|
s32 i;
|
2020-12-02 03:19:56 +00:00
|
|
|
|
2020-03-24 17:16:13 +00:00
|
|
|
for (i = 0; i < skelAnime->limbCount; i++) {
|
2020-03-23 01:57:25 +00:00
|
|
|
*dst++ = *src++;
|
|
|
|
}
|
|
|
|
}
|