From 84040f6ba694962295c4b3f5481661cbad977cea Mon Sep 17 00:00:00 2001 From: Rozelette Date: Mon, 12 Apr 2021 00:41:35 -0500 Subject: [PATCH] z_skin_matrix OK (#81) * Set up file * Rename * z_skin_matrix OK * Cleanup * /n nits --- include/functions.h | 80 +-- include/macros.h | 7 + include/variables.h | 10 +- include/z64.h | 13 +- linker_scripts/code_script.txt | 6 +- src/code/code_0x800CAAD0.c | 12 +- src/code/z_eff_footmark.c | 2 +- src/code/z_effect_soft_sprite_old_init.c | 4 +- src/code/z_skin_matrix.c | 807 +++++++++++++++++++++++ src/code/z_view.c | 2 +- tables/functions.txt | 40 +- tables/objects.txt | 6 +- tables/variables.txt | 8 +- 13 files changed, 902 insertions(+), 95 deletions(-) create mode 100644 src/code/z_skin_matrix.c diff --git a/include/functions.h b/include/functions.h index 17b8f5ef5f..63ad4e1c1c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1626,7 +1626,7 @@ void func_800EFAB8(GlobalContext* ctxt, s16 index); void func_800EFBFC(GlobalContext* ctxt, s16 index); void func_800EFD44(GlobalContext* ctxt, s16 index); void EffFootmark_Init(GlobalContext* ctxt); -void EffFootmark_Add(GlobalContext* ctxt, z_Matrix* displayMatrix, Actor* actor, u8 id, Vec3f* location, u16 size, u8 red, u8 green, u8 blue, u16 alpha, u16 alphaChange, u16 fadeoutDelay); +void EffFootmark_Add(GlobalContext* ctxt, MtxF* displayMatrix, Actor* actor, u8 id, Vec3f* location, u16 size, u8 red, u8 green, u8 blue, u16 alpha, u16 alphaChange, u16 fadeoutDelay); void EffFootmark_Update(GlobalContext* ctxt); void EffFootmark_Draw(GlobalContext* ctxt); void func_800F0390(GlobalContext* ctxt); @@ -2642,30 +2642,30 @@ void SkelAnime_CopyVec3s(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); // void func_80138700(void); // void func_801387D4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5); // void func_801388E4(void); -void Matrix_MultiplyByVectorXYZW(z_Matrix* matrix, Vec3f* vector, Vec3f* resultXYZ, f32* resultW); -void SkinMatrix_Vec3fMtxFMultXYZ(MtxF* matrix, Vec3f* vector, Vec3f* result); -void SkinMatrix_MtxFMtxFMult(MtxF* l, MtxF* r, MtxF* dst); -void Matrix_GetIdentity(z_Matrix** puParm1); -void Matrix_MakeIdentity(z_Matrix* matrix); -void Matrix_Copy(z_Matrix* src, z_Matrix* dst); -s32 Matrix_Invert(z_Matrix* matrix, z_Matrix* invert); -void Matrix_MakeScale(MtxF* matrix, f32 x, f32 y, f32 z); -void Matrix_MakeRotationZYX(z_Matrix* matrix, s16 xRotation, s16 yRotation, s16 zRotation); -void Matrix_MakeRotationYXZ(z_Matrix* matrix, s16 xRotation, s16 yRotation, s16 zRotation); -void SkinMatrix_SetTranslate(MtxF* matrix, f32 x, f32 y, f32 z); -void Matrix_MakeTranslationRotationZYXScale(z_Matrix* matrix, f32 xScale, f32 yScale, f32 zScale, s16 xRotation, s16 yRotation, s16 zRotation, f32 xTranslation, f32 yTranslation, f32 zTranslation); -void Matrix_MakeTranslationRotationYXZScale(z_Matrix* matrix, f32 xScale, f32 yScale, f32 zScale, s16 xRotation, s16 yRotation, s16 zRotation, f32 xTranslation, f32 yTranslation, f32 zTranslation); -void Matrix_MakeTranslationRotationZYX(z_Matrix* matrix, s16 xRotation, s16 yRotation, s16 zRotation, f32 xTranslation, f32 yTranslation, f32 zTranslation); -void Matrix_ToVec3s(Vec3f* vec3f, Vec3s* vec3s); -void Matrix_ToVec3f(Vec3s* vec3s, Vec3f* vec3f); -void Matrix_ToRSPMatrix(z_Matrix* src, RSPMatrix* dst); +void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDest); +void SkinMatrix_Vec3fMtxFMultXYZ(MtxF* mf, Vec3f* src, Vec3f* dest); +void SkinMatrix_MtxFMtxFMult(MtxF* mfB, MtxF* mfA, MtxF* dest); +void SkinMatrix_GetClear(MtxF** puParm1); +void SkinMatrix_GetClear(MtxF** mf); +void SkinMatrix_MtxFCopy(MtxF* src, MtxF* dest); +s32 SkinMatrix_Invert(MtxF* src, MtxF* dest); +void SkinMatrix_SetScale(MtxF* mf, f32 x, f32 y, f32 z); +void SkinMatrix_SetRotateRPY(MtxF* mf, s16 roll, s16 pitch, s16 yaw); +void SkinMatrix_SetRotateYRP(MtxF* mf, s16 yaw, s16 roll, s16 pitch); +void SkinMatrix_SetTranslate(MtxF* mf, f32 x, f32 y, f32 z); +void SkinMatrix_SetScaleRotateRPYTranslate(MtxF* mf, f32 scaleX, f32 scaleY, f32 scaleZ, s16 roll, s16 pitch, s16 yaw, f32 dx, f32 dy, f32 dz); +void SkinMatrix_SetScaleRotateYRPTranslate(MtxF* mf, f32 scaleX, f32 scaleY, f32 scaleZ, s16 yaw, s16 roll, s16 pitch, f32 dx, f32 dy, f32 dz); +void SkinMatrix_SetRotateRPYTranslate(MtxF* mf, s16 roll, s16 pitch, s16 yaw, f32 dx, f32 dy, f32 dz); +void SkinMatrix_Vec3fToVec3s(Vec3f* src, Vec3s* dest); +void SkinMatrix_Vec3sToVec3f(Vec3s* src, Vec3f* dest); +void SkinMatrix_MtxFToMtx(MtxF* src, Mtx* dest); Mtx* SkinMatrix_MtxFToNewMtx(GraphicsContext* gfxCtx, MtxF* src); -void Matrix_MakeRotationAroundUnitVector(MtxF* matrix, s16 rotation, f32 x, f32 y, f32 z); -void Matrix_MakeXRotation(z_Matrix* matrix, s16 rotation); -void Matrix_XRotation(z_Matrix* matrix, s16 rotation); -void Matrix_MakeYRotation(z_Matrix* matrix, s16 rotation); -void Matrix_YRotation(z_Matrix* matrix, s16 rotation); -void Matrix_MakeZRotation(z_Matrix* matrix, s16 rotation); +void SkinMatrix_SetRotateAroundVec(MtxF* mf, s16 a, f32 x, f32 y, f32 z); +void SkinMatrix_SetXRotation(MtxF* mf, s16 a); +void SkinMatrix_MulXRotation(MtxF* mf, s16 a); +void SkinMatrix_SetYRotation(MtxF* mf, s16 a); +void SkinMatrix_MulYRotation(MtxF* mf, s16 a); +void SkinMatrix_SetZRotation(MtxF* mf, s16 a); s32 func_8013A240(GlobalContext* ctxt); void func_8013A41C(s32 flag); void func_8013A46C(s32 flag); @@ -3368,13 +3368,13 @@ s16 atans(f32 opposite, f32 adjacent); f32 atan(f32 opposite, f32 adjacent); s16 Math_FAtan2F(f32 adjacent, f32 opposite); s16 atan_flip(f32 adjacent, f32 opposite); -void Matrix_Init(GameState* ctxt); -void Matrix_Push(void); -void Matrix_Pop(void); -void SysMatrix_CopyCurrentState(z_Matrix* matrix); -void Matrix_Put(MtxF* matrix); -// z_Matrix* SysMatrix_GetCurrentState(void); -void SysMatrix_InsertMatrix(z_Matrix* matrix, s32 appendToState); +void SysMatrix_StateAlloc(GameState* ctxt); +void SysMatrix_StatePush(void); +void SysMatrix_StatePop(void); +void SysMatrix_CopyCurrentState(MtxF* matrix); +void SysMatrix_SetCurrentState(MtxF* matrix); +// MtxF* SysMatrix_GetCurrentState(void); +void SysMatrix_InsertMatrix(MtxF* matrix, s32 appendToState); void SysMatrix_InsertTranslation(f32 x, f32 y, f32 z, s32 appendToState); void Matrix_Scale(f32 xScale, f32 yScale, f32 zScale, u8 appendToState); void SysMatrix_InsertXRotation_s(s16 rotation, s32 appendToState); @@ -3388,22 +3388,22 @@ void SysMatrix_InsertZRotation_f(f32 rotation, s32 appendToState); void SysMatrix_InsertRotation(s16 xRotation, s16 yRotation, s16 zRotation, s32 appendToState); void SysMatrix_RotateAndTranslateState(Vec3f* translation, Vec3s* rotation); void SysMatrix_SetStateRotationAndTranslation(f32 x, f32 y, f32 z, Vec3s* rotation); -RSPMatrix* SysMatrix_ToRSPMatrix(z_Matrix* src, RSPMatrix* dst); +RSPMatrix* SysMatrix_ToRSPMatrix(MtxF* src, RSPMatrix* dst); RSPMatrix* SysMatrix_GetStateAsRSPMatrix(RSPMatrix* matrix); -Mtx* Matrix_NewMtx(GraphicsContext* gCtxt); -void SysMatrix_AppendToPolyOpaDisp(z_Matrix* ctxt, GraphicsContext* gCtxt); +RSPMatrix* SysMatrix_AppendStateToPolyOpaDisp(GraphicsContext* gCtxt); +void SysMatrix_AppendToPolyOpaDisp(MtxF* ctxt, GraphicsContext* gCtxt); void SysMatrix_MultiplyVector3fByState(Vec3f* src, Vec3f* dst); void SysMatrix_GetStateTranslation(Vec3f* dst); void SysMatrix_GetStateTranslationAndScaledX(f32 scale, Vec3f* dst); void SysMatrix_GetStateTranslationAndScaledY(f32 scale, Vec3f* dst); void SysMatrix_GetStateTranslationAndScaledZ(f32 scale, Vec3f* dst); void SysMatrix_MultiplyVector3fXZByCurrentState(Vec3f* src, Vec3f* dst); -void Matrix_MtxFCopy(z_Matrix* dst, z_Matrix* src); -void SysMatrix_FromRSPMatrix(RSPMatrix* src, z_Matrix* dst); -void SysMatrix_MultiplyVector3fByMatrix(Vec3f* src, Vec3f* dst, z_Matrix* matrix); -void SysMatrix_TransposeXYZ(z_Matrix* matrix); -void SysMatrix_NormalizeXYZ(z_Matrix* matrix); -void func_8018219C(z_Matrix* pfParm1, Vec3s* psParm2, s32 iParm3); +void SysMatrix_Copy(MtxF* dst, MtxF* src); +void SysMatrix_FromRSPMatrix(RSPMatrix* src, MtxF* dst); +void SysMatrix_MultiplyVector3fByMatrix(Vec3f* src, Vec3f* dst, MtxF* matrix); +void SysMatrix_TransposeXYZ(MtxF* matrix); +void SysMatrix_NormalizeXYZ(MtxF* matrix); +void func_8018219C(MtxF* pfParm1, Vec3s* psParm2, s32 iParm3); // void func_801822C4(void); void SysMatrix_InsertRotationAroundUnitVector_f(f32 rotation, Vec3f* vector, s32 appendToState); void SysMatrix_InsertRotationAroundUnitVector_s(s16 rotation, Vec3f* vector, s32 appendToState); diff --git a/include/macros.h b/include/macros.h index 9bd1088f53..2896b50bd2 100644 --- a/include/macros.h +++ b/include/macros.h @@ -71,4 +71,11 @@ extern GraphicsContext* __gfxCtx; #define CLAMP_MAX(x, max) ((x) > (max) ? (max) : (x)) #define CLAMP_MIN(x, min) ((x) < (min) ? (min) : (x)) +#define SWAP(type, a, b) \ +{ \ + type _temp = (a); \ + (a) = (b); \ + (b) = _temp; \ +} + #endif // _MACROS_H_ diff --git a/include/variables.h b/include/variables.h index 359e77ee55..3c04b85c36 100644 --- a/include/variables.h +++ b/include/variables.h @@ -2081,7 +2081,7 @@ extern SceneEntranceTableEnty gSceneEntranceTable[110]; extern UNK_PTR D_801C5C50; // extern UNK_TYPE1 D_801C5C9C; extern UNK_PTR D_801C5CB0; -extern z_Matrix identityMatrix; +extern MtxF sMtxFClear; // extern UNK_TYPE1 D_801C5D10; // extern UNK_TYPE1 D_801C5D20; // extern UNK_TYPE1 D_801C5D60; @@ -2347,7 +2347,7 @@ extern Vec3f D_801D15B0; // extern UNK_TYPE4 D_801D15BC; extern s16 atan_first_8th_array[1025]; extern RSPMatrix D_801D1DE0; -extern z_Matrix D_801D1E20; +extern MtxF D_801D1E20; extern UNK_PTR D_801D1E60; extern UNK_PTR D_801D1E64; // extern UNK_TYPE1 D_801D1E70; @@ -3855,7 +3855,7 @@ extern Vec3f D_801EDA08; extern Vec3f D_801EDA18; extern Vec3f D_801EDA24; extern Vec3f D_801EDA30; -extern z_Matrix D_801EDA40; +extern MtxF D_801EDA40; extern Vec3f D_801EDA80; extern Vec3f D_801EDA8C; extern Vec3f D_801EDA98; @@ -4249,8 +4249,8 @@ extern Vec3f D_801FBDA4; // extern UNK_TYPE1 D_801FBDDC; // extern UNK_TYPE1 D_801FBDE0; extern Vec3f D_801FBDE8; -extern z_Matrix* sMatrixStack; -extern z_Matrix* sCurrentMatrix; +extern MtxF* sMatrixStack; +extern MtxF* sCurrentMatrix; // extern UNK_TYPE1 D_801FBE10; // extern UNK_TYPE1 D_801FBE28; // extern UNK_TYPE1 D_801FBE2C; diff --git a/include/z64.h b/include/z64.h index 8ff93be369..4c7de52280 100644 --- a/include/z64.h +++ b/include/z64.h @@ -517,13 +517,6 @@ typedef struct { /* 0x1A */ s16 unk1A; } s80874650; // size = 0x1C -typedef struct { - /* 0x00 */ f32 x[4]; - /* 0x10 */ f32 y[4]; - /* 0x20 */ f32 z[4]; - /* 0x30 */ f32 w[4]; -} z_Matrix; // size = 0x40 - typedef struct { /* 0x00 */ Vec3f scale; /* 0x0C */ Vec3s rotation; @@ -1528,7 +1521,7 @@ struct Camera { }; // size = 0x178 typedef struct { - /* 0x00 */ z_Matrix displayMatrix; + /* 0x00 */ MtxF displayMatrix; /* 0x40 */ Actor* actor; /* 0x44 */ Vec3f location; /* 0x50 */ u8 flags; // bit 0 - footmark fades out @@ -1672,9 +1665,9 @@ struct GlobalContext { /* 0x18761 */ UNK_TYPE1 pad18761[0x3]; /* 0x18764 */ TransitionActorEntry* transitionActorList; /* 0x18768 */ UNK_TYPE1 pad18768[0x48]; - /* 0x187B0 */ z_Matrix unk187B0; + /* 0x187B0 */ MtxF unk187B0; /* 0x187F0 */ UNK_TYPE1 pad187F0[0xC]; - /* 0x187FC */ MtxF mf_187FC; + /* 0x187FC */ MtxF unk187FC; /* 0x1883C */ UNK_TYPE1 pad1883C[0x4]; /* 0x18840 */ u32 unk18840; /* 0x18844 */ u8 unk18844; diff --git a/linker_scripts/code_script.txt b/linker_scripts/code_script.txt index 1e079687af..d884ea3340 100644 --- a/linker_scripts/code_script.txt +++ b/linker_scripts/code_script.txt @@ -387,7 +387,7 @@ SECTIONS build/src/code/z_skelanime.o(.text) build/asm/code/z_skin.o(.text) build/asm/code/z_skin_awb.o(.text) - build/asm/code/code_0x80138BA0.o(.text) + build/src/code/z_skin_matrix.o(.text) build/src/code/z_snap.o(.text) build/asm/code/z_sub_s.o(.text) build/asm/code/code_0x8013EC10.o(.text) @@ -505,7 +505,7 @@ SECTIONS build/asm/code/code_data_z_scene_table.o(.data) build/asm/code/code_data_0x801323D0.o(.data) build/src/code/z_skelanime.o(.data) - build/asm/code/code_data_0x80138BA0.o(.data) + build/src/code/z_skin_matrix.o(.data) build/asm/code/code_data_z_sub_s.o(.data) build/asm/code/code_data_z_vimode.o(.data) build/src/code/z_vr_box.o(.data) @@ -575,7 +575,7 @@ SECTIONS build/src/code/z_scene_proc.o(.rodata) build/asm/code/code_rodata_z_scene_table.o(.rodata) build/asm/code/code_rodata_z_skin.o(.rodata) - build/asm/code/code_rodata_0x80138BA0.o(.rodata) + build/src/code/z_skin_matrix.o(.rodata) build/asm/code/code_rodata_z_sub_s.o(.rodata) build/asm/code/code_rodata_0x8013EC10.o(.rodata) build/src/code/z_view.o(.rodata) diff --git a/src/code/code_0x800CAAD0.c b/src/code/code_0x800CAAD0.c index ab53cc9834..a910156c02 100644 --- a/src/code/code_0x800CAAD0.c +++ b/src/code/code_0x800CAAD0.c @@ -6,15 +6,15 @@ // The functions will use the BgCheck2 prefix for now. void BgCheck2_UpdateActorPosition(CollisionContext* bgCtxt, s32 index, Actor* actor) { - z_Matrix prevMatrix; - z_Matrix prevMatrixInv; - z_Matrix currMatrix; + MtxF prevMatrix; + MtxF prevMatrixInv; + MtxF currMatrix; Vec3f newPos; Vec3f posWithInv; if (BgCheck_IsActorMeshIndexValid(index) == 0) return; - Matrix_MakeTranslationRotationYXZScale(&prevMatrix, + SkinMatrix_SetScaleRotateYRPTranslate(&prevMatrix, bgCtxt->dyna.actorMeshArr[index].prevParams.scale.x, bgCtxt->dyna.actorMeshArr[index].prevParams.scale.y, bgCtxt->dyna.actorMeshArr[index].prevParams.scale.z, @@ -25,9 +25,9 @@ void BgCheck2_UpdateActorPosition(CollisionContext* bgCtxt, s32 index, Actor* ac bgCtxt->dyna.actorMeshArr[index].prevParams.pos.y, bgCtxt->dyna.actorMeshArr[index].prevParams.pos.z); - if (Matrix_Invert(&prevMatrix, &prevMatrixInv) == 2) return; + if (SkinMatrix_Invert(&prevMatrix, &prevMatrixInv) == 2) return; - Matrix_MakeTranslationRotationYXZScale(&currMatrix, + SkinMatrix_SetScaleRotateYRPTranslate(&currMatrix, bgCtxt->dyna.actorMeshArr[index].currParams.scale.x, bgCtxt->dyna.actorMeshArr[index].currParams.scale.y, bgCtxt->dyna.actorMeshArr[index].currParams.scale.z, diff --git a/src/code/z_eff_footmark.c b/src/code/z_eff_footmark.c index df1d91e21b..3b906c3713 100644 --- a/src/code/z_eff_footmark.c +++ b/src/code/z_eff_footmark.c @@ -17,7 +17,7 @@ void EffFootmark_Init(GlobalContext* ctxt) { } } -void EffFootmark_Add(GlobalContext* ctxt, z_Matrix* displayMatrix, Actor* actor, u8 id, Vec3f* location, u16 size, u8 red, u8 green, u8 blue, u16 alpha, u16 alphaChange, u16 fadeoutDelay) { +void EffFootmark_Add(GlobalContext* ctxt, MtxF* displayMatrix, Actor* actor, u8 id, Vec3f* location, u16 size, u8 red, u8 green, u8 blue, u16 alpha, u16 alphaChange, u16 fadeoutDelay) { s32 i; EffFootmark* footmark; EffFootmark* destination = NULL; diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index b0bbccfab0..79a9c50c34 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -16,8 +16,8 @@ void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* this, void* textur scale = this->rgScale * D_801DC100; SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); - Matrix_MakeScale(&mfScale, scale, scale, scale); - SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->mf_187FC, &mfTrans11DA0); + SkinMatrix_SetScale(&mfScale, scale, scale, scale); + SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->unk187FC, &mfTrans11DA0); SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); gSegments[6] = PHYSICAL_TO_VIRTUAL(object); gSPSegment(POLY_XLU_DISP++, 0x06, object); diff --git a/src/code/z_skin_matrix.c b/src/code/z_skin_matrix.c new file mode 100644 index 0000000000..94648a878c --- /dev/null +++ b/src/code/z_skin_matrix.c @@ -0,0 +1,807 @@ +#include +#include + +// clang-format off +MtxF sMtxFClear = { + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f, +}; +// clang-format on + +/** + * Multiplies a 4 component row vector [ src , 1 ] by the matrix mf and writes the resulting 4 components to xyzDest + * and wDest. + * + * \f[ [\texttt{xyzDest}, \texttt{wDest}] = [\texttt{src}, 1] \cdot [mf] \f] + */ +void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDest) { + xyzDest->x = mf->wx + ((src->x * mf->xx) + (src->y * mf->yx) + (src->z * mf->zx)); + xyzDest->y = mf->wy + ((src->x * mf->xy) + (src->y * mf->yy) + (src->z * mf->zy)); + xyzDest->z = mf->wz + ((src->x * mf->xz) + (src->y * mf->yz) + (src->z * mf->zz)); + *wDest = mf->ww + ((src->x * mf->xw) + (src->y * mf->yw) + (src->z * mf->zw)); +} + +/** + * Multiplies a 4 component row vector [ src , 1 ] by the matrix mf and writes the resulting xyz components to dest. + * + * \f[ [\texttt{dest}, -] = [\texttt{src}, 1] \cdot [mf] \f] + */ +void SkinMatrix_Vec3fMtxFMultXYZ(MtxF* mf, Vec3f* src, Vec3f* dest) { + f32 mx = mf->xx; + f32 my = mf->yx; + f32 mz = mf->zx; + f32 mw = mf->wx; + dest->x = mw + ((src->x * mx) + (src->y * my) + (src->z * mz)); + + mx = mf->xy; + my = mf->yy; + mz = mf->zy; + mw = mf->wy; + dest->y = mw + ((src->x * mx) + (src->y * my) + (src->z * mz)); + + mx = mf->xz; + my = mf->yz; + mz = mf->zz; + mw = mf->wz; + dest->z = mw + ((src->x * mx) + (src->y * my) + (src->z * mz)); +} + +/** + * Matrix multiplication, dest = mfA * mfB. + * mfA and dest should not be the same matrix. + */ +void SkinMatrix_MtxFMtxFMult(MtxF* mfB, MtxF* mfA, MtxF* dest) { + f32 rx; + f32 ry; + f32 rz; + f32 rw; + + //---COL1--- + f32 cx = mfB->xx; + f32 cy = mfB->yx; + f32 cz = mfB->zx; + f32 cw = mfB->wx; + //-------- + + rx = mfA->xx; + ry = mfA->xy; + rz = mfA->xz; + rw = mfA->xw; + dest->xx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->yx; + ry = mfA->yy; + rz = mfA->yz; + rw = mfA->yw; + dest->yx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->zx; + ry = mfA->zy; + rz = mfA->zz; + rw = mfA->zw; + dest->zx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->wx; + ry = mfA->wy; + rz = mfA->wz; + rw = mfA->ww; + dest->wx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + //---2Col--- + cx = mfB->xy; + cy = mfB->yy; + cz = mfB->zy; + cw = mfB->wy; + //-------- + rx = mfA->xx; + ry = mfA->xy; + rz = mfA->xz; + rw = mfA->xw; + dest->xy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->yx; + ry = mfA->yy; + rz = mfA->yz; + rw = mfA->yw; + dest->yy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->zx; + ry = mfA->zy; + rz = mfA->zz; + rw = mfA->zw; + dest->zy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->wx; + ry = mfA->wy; + rz = mfA->wz; + rw = mfA->ww; + dest->wy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + //---3Col--- + cx = mfB->xz; + cy = mfB->yz; + cz = mfB->zz; + cw = mfB->wz; + //-------- + rx = mfA->xx; + ry = mfA->xy; + rz = mfA->xz; + rw = mfA->xw; + dest->xz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->yx; + ry = mfA->yy; + rz = mfA->yz; + rw = mfA->yw; + dest->yz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->zx; + ry = mfA->zy; + rz = mfA->zz; + rw = mfA->zw; + dest->zz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->wx; + ry = mfA->wy; + rz = mfA->wz; + rw = mfA->ww; + dest->wz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + //---4Col--- + cx = mfB->xw; + cy = mfB->yw; + cz = mfB->zw; + cw = mfB->ww; + //-------- + rx = mfA->xx; + ry = mfA->xy; + rz = mfA->xz; + rw = mfA->xw; + dest->xw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->yx; + ry = mfA->yy; + rz = mfA->yz; + rw = mfA->yw; + dest->yw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->zx; + ry = mfA->zy; + rz = mfA->zz; + rw = mfA->zw; + dest->zw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->wx; + ry = mfA->wy; + rz = mfA->wz; + rw = mfA->ww; + dest->ww = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); +} + +/** + * "Clear" in this file means the identity matrix. + */ +void SkinMatrix_GetClear(MtxF** mfp) { + *mfp = &sMtxFClear; +} + +void SkinMatrix_Clear(MtxF* mf) { + mf->xx = 1.0f; + mf->xy = 0.0f; + mf->xz = 0.0f; + mf->xw = 0.0f; + mf->yx = 0.0f; + mf->yy = 1.0f; + mf->yz = 0.0f; + mf->yw = 0.0f; + mf->zx = 0.0f; + mf->zy = 0.0f; + mf->zz = 1.0f; + mf->zw = 0.0f; + mf->wx = 0.0f; + mf->wy = 0.0f; + mf->wz = 0.0f; + mf->ww = 1.0f; +} + +void SkinMatrix_MtxFCopy(MtxF* src, MtxF* dest) { + dest->xx = src->xx; + dest->xy = src->xy; + dest->xz = src->xz; + dest->xw = src->xw; + dest->yx = src->yx; + dest->yy = src->yy; + dest->yz = src->yz; + dest->yw = src->yw; + dest->zx = src->zx; + dest->zy = src->zy; + dest->zz = src->zz; + dest->zw = src->zw; + dest->wx = src->wx; + dest->wy = src->wy; + dest->wz = src->wz; + dest->ww = src->ww; +} + +/** + * Inverts a matrix using a slight modification of the Gauss-Jordan method + * (column operations instead of row operations). + * returns 0 if successfully inverted + * returns 2 if matrix non-invertible (0 determinant) + */ +s32 SkinMatrix_Invert(MtxF* src, MtxF* dest) { + MtxF mfCopy; + s32 i; + f32 temp2; + s32 thisRow; + s32 thisCol; + + SkinMatrix_MtxFCopy(src, &mfCopy); + SkinMatrix_Clear(dest); + + for (thisRow = 0; thisRow < 4; thisRow++) { + thisCol = thisRow; + while ((thisCol < 4) && (fabsf(mfCopy.mf[thisRow][thisCol]) < 0.0005f)) { + thisCol++; + } + if (thisCol == 4) { + // reaching col = 4 means the row is either all 0 or a duplicate row. + // therefore singular matrix (0 determinant). + return 2; + } + if (thisCol != thisRow) { // responsible for swapping columns if zero on diagonal + for (i = 0; i < 4; i++) { + SWAP(f32, mfCopy.mf[i][thisCol], mfCopy.mf[i][thisRow]); + SWAP(f32, dest->mf[i][thisCol], dest->mf[i][thisRow]); + } + } + + // Scale this whole column s.t. the diag element = 1 + temp2 = mfCopy.mf[thisRow][thisRow]; + for (i = 0; i < 4; i++) { + mfCopy.mf[i][thisRow] /= temp2; + dest->mf[i][thisRow] /= temp2; + } + + for (thisCol = 0; thisCol < 4; thisCol++) { + if (thisCol != thisRow) { + temp2 = mfCopy.mf[thisRow][thisCol]; + for (i = 0; i < 4; i++) { + mfCopy.mf[i][thisCol] -= mfCopy.mf[i][thisRow] * temp2; + dest->mf[i][thisCol] -= dest->mf[i][thisRow] * temp2; + } + } + } + } + + return 0; +} + +/** + * Produces a matrix which scales x,y,z components of vectors or x,y,z rows of matrices (when applied on LHS) + */ +void SkinMatrix_SetScale(MtxF* mf, f32 x, f32 y, f32 z) { + mf->xy = 0.0f; + mf->xz = 0.0f; + mf->xw = 0.0f; + mf->yx = 0.0f; + mf->yz = 0.0f; + mf->yw = 0.0f; + mf->zx = 0.0f; + mf->zy = 0.0f; + mf->zw = 0.0f; + mf->wx = 0.0f; + mf->wy = 0.0f; + mf->wz = 0.0f; + mf->ww = 1.0f; + mf->xx = x; + mf->yy = y; + mf->zz = z; +} + +/** + * Produces a rotation matrix = (roll rotation matrix) * (pitch rotation matrix) * (yaw rotation matrix) + */ +void SkinMatrix_SetRotateRPY(MtxF* mf, s16 roll, s16 pitch, s16 yaw) { + f32 cos2; + f32 sin = Math_SinS(yaw); + f32 cos = Math_CosS(yaw); + f32 yx; + f32 sin2; + f32 zx; + f32 yy; + f32 zy; + + mf->yy = cos; + mf->yx = -sin; + mf->xw = mf->yw = mf->zw = 0; + mf->wx = mf->wy = mf->wz = 0; + mf->ww = 1; + + if (pitch != 0) { + sin2 = Math_SinS(pitch); + cos2 = Math_CosS(pitch); + + mf->xx = cos * cos2; + mf->zx = cos * sin2; + + mf->xy = sin * cos2; + mf->zy = sin * sin2; + mf->xz = -sin2; + mf->zz = cos2; + } else { + mf->xx = cos; + if (1) {} + if (1) {} + zx = sin; // required to match + mf->xy = sin; + mf->xz = mf->zx = mf->zy = 0; + mf->zz = 1; + } + + if (roll != 0) { + sin2 = Math_SinS(roll); + cos2 = Math_CosS(roll); + + yx = mf->yx; + zx = mf->zx; + mf->yx = (yx * cos2) + (zx * sin2); + mf->zx = (zx * cos2) - (yx * sin2); + + if (1) {} + zy = mf->zy; + yy = mf->yy; + mf->yy = (yy * cos2) + (zy * sin2); + mf->zy = (zy * cos2) - (yy * sin2); + + if (cos2) {} + mf->yz = mf->zz * sin2; + mf->zz = mf->zz * cos2; + } else { + mf->yz = 0; + } +} + +/** + * Produces a rotation matrix = (yaw rotation matrix) * (roll rotation matrix) * (pitch rotation matrix) + */ +void SkinMatrix_SetRotateYRP(MtxF* mf, s16 yaw, s16 roll, s16 pitch) { + f32 cos2; + f32 sin; + f32 cos; + f32 xz; + f32 sin2; + f32 yz; + f32 xx; + f32 yx; + + sin = Math_SinS(roll); + cos = Math_CosS(roll); + + mf->xx = cos; + mf->xz = -sin; + mf->zw = 0; + mf->yw = 0; + mf->xw = 0; + mf->wz = 0; + mf->wy = 0; + mf->wx = 0; + mf->ww = 1; + + if (yaw != 0) { + sin2 = Math_SinS(yaw); + cos2 = Math_CosS(yaw); + + mf->zz = cos * cos2; + mf->yz = cos * sin2; + + mf->zx = sin * cos2; + mf->yx = sin * sin2; + mf->zy = -sin2; + mf->yy = cos2; + } else { + mf->zz = cos; + if (1) {} + if (1) {} + yx = sin; // required to match + mf->zx = sin; + mf->yx = mf->yz = mf->zy = 0; + mf->yy = 1; + } + + if (pitch != 0) { + sin2 = Math_SinS(pitch); + cos2 = Math_CosS(pitch); + xx = mf->xx; + yx = mf->yx; + mf->xx = (xx * cos2) + (yx * sin2); + mf->yx = yx * cos2 - (xx * sin2); + if (1) {} + yz = mf->yz; + xz = mf->xz; + mf->xz = (xz * cos2) + (yz * sin2); + mf->yz = (yz * cos2) - (xz * sin2); + if (cos2) {} + mf->xy = mf->yy * sin2; + mf->yy = mf->yy * cos2; + } else { + mf->xy = 0; + } +} + +/** + * Produces a matrix which translates a vector by amounts in the x, y and z directions + */ +void SkinMatrix_SetTranslate(MtxF* mf, f32 x, f32 y, f32 z) { + mf->xy = 0.0f; + mf->xz = 0.0f; + mf->xw = 0.0f; + mf->yx = 0.0f; + mf->yz = 0.0f; + mf->yw = 0.0f; + mf->zx = 0.0f; + mf->zy = 0.0f; + mf->zw = 0.0f; + mf->xx = 1.0f; + mf->yy = 1.0f; + mf->zz = 1.0f; + mf->ww = 1.0f; + mf->wx = x; + mf->wy = y; + mf->wz = z; +} + +/** + * Produces a matrix which scales, then rotates (RPY), then translates a vector + */ +void SkinMatrix_SetScaleRotateRPYTranslate(MtxF* mf, f32 scaleX, f32 scaleY, f32 scaleZ, s16 roll, s16 pitch, s16 yaw, + f32 dx, f32 dy, f32 dz) { + MtxF mft1; + MtxF mft2; + + SkinMatrix_SetTranslate(mf, dx, dy, dz); + SkinMatrix_SetRotateRPY(&mft1, roll, pitch, yaw); + SkinMatrix_MtxFMtxFMult(mf, &mft1, &mft2); + SkinMatrix_SetScale(&mft1, scaleX, scaleY, scaleZ); + SkinMatrix_MtxFMtxFMult(&mft2, &mft1, mf); +} + +/** + * Produces a matrix which scales, then rotates (YRP), then translates a vector + */ +void SkinMatrix_SetScaleRotateYRPTranslate(MtxF* mf, f32 scaleX, f32 scaleY, f32 scaleZ, s16 yaw, s16 roll, s16 pitch, + f32 dx, f32 dy, f32 dz) { + MtxF mft1; + MtxF mft2; + + SkinMatrix_SetTranslate(mf, dx, dy, dz); + SkinMatrix_SetRotateYRP(&mft1, yaw, roll, pitch); + SkinMatrix_MtxFMtxFMult(mf, &mft1, &mft2); + SkinMatrix_SetScale(&mft1, scaleX, scaleY, scaleZ); + SkinMatrix_MtxFMtxFMult(&mft2, &mft1, mf); +} + +/** + * Produces a matrix which rotates (RPY), then translates a vector + */ +void SkinMatrix_SetRotateRPYTranslate(MtxF* mf, s16 roll, s16 pitch, s16 yaw, f32 dx, f32 dy, f32 dz) { + MtxF mft1; + MtxF mft2; + + SkinMatrix_SetTranslate(&mft2, dx, dy, dz); + SkinMatrix_SetRotateRPY(&mft1, roll, pitch, yaw); + SkinMatrix_MtxFMtxFMult(&mft2, &mft1, mf); +} + +void SkinMatrix_Vec3fToVec3s(Vec3f* src, Vec3s* dest) { + dest->x = src->x; + dest->y = src->y; + dest->z = src->z; +} + +void SkinMatrix_Vec3sToVec3f(Vec3s* src, Vec3f* dest) { + dest->x = src->x; + dest->y = src->y; + dest->z = src->z; +} + +void SkinMatrix_MtxFToMtx(MtxF* src, Mtx* dest) { + s32 temp; + u16* m1 = (u16*)&dest->m[0][0]; + u16* m2 = (u16*)&dest->m[2][0]; + + temp = src->xx * 0x10000; + m1[0] = (temp >> 0x10); + m1[16 + 0] = temp & 0xFFFF; + + temp = src->xy * 0x10000; + m1[1] = (temp >> 0x10); + m1[16 + 1] = temp & 0xFFFF; + + temp = src->xz * 0x10000; + m1[2] = (temp >> 0x10); + m1[16 + 2] = temp & 0xFFFF; + + temp = src->xw * 0x10000; + m1[3] = (temp >> 0x10); + m1[16 + 3] = temp & 0xFFFF; + + temp = src->yx * 0x10000; + m1[4] = (temp >> 0x10); + m1[16 + 4] = temp & 0xFFFF; + + temp = src->yy * 0x10000; + m1[5] = (temp >> 0x10); + m1[16 + 5] = temp & 0xFFFF; + + temp = src->yz * 0x10000; + m1[6] = (temp >> 0x10); + m1[16 + 6] = temp & 0xFFFF; + + temp = src->yw * 0x10000; + m1[7] = (temp >> 0x10); + m1[16 + 7] = temp & 0xFFFF; + + temp = src->zx * 0x10000; + m1[8] = (temp >> 0x10); + m1[16 + 8] = temp & 0xFFFF; + + temp = src->zy * 0x10000; + m1[9] = (temp >> 0x10); + m2[9] = temp & 0xFFFF; + + temp = src->zz * 0x10000; + m1[10] = (temp >> 0x10); + m2[10] = temp & 0xFFFF; + + temp = src->zw * 0x10000; + m1[11] = (temp >> 0x10); + m2[11] = temp & 0xFFFF; + + temp = src->wx * 0x10000; + m1[12] = (temp >> 0x10); + m2[12] = temp & 0xFFFF; + + temp = src->wy * 0x10000; + m1[13] = (temp >> 0x10); + m2[13] = temp & 0xFFFF; + + temp = src->wz * 0x10000; + m1[14] = (temp >> 0x10); + m2[14] = temp & 0xFFFF; + + temp = src->ww * 0x10000; + m1[15] = (temp >> 0x10); + m2[15] = temp & 0xFFFF; +} + +Mtx* SkinMatrix_MtxFToNewMtx(GraphicsContext* gfxCtx, MtxF* src) { + s32 pad; + Mtx* mtx; + + // TODO allocation should be a macro + mtx = (Mtx*)((int)gfxCtx->polyOpa.d - sizeof(Mtx)); + gfxCtx->polyOpa.d = (void*)mtx; + + if (mtx == NULL) { + return NULL; + } + + SkinMatrix_MtxFToMtx(src, mtx); + return mtx; +} + +/** + * Produces a matrix which rotates vectors by angle a around a unit vector with components (x,y,z) + */ +void SkinMatrix_SetRotateAroundVec(MtxF* mf, s16 a, f32 x, f32 y, f32 z) { + f32 sinA; + f32 cosA; + f32 xx; + f32 yy; + f32 zz; + f32 xy; + f32 yz; + f32 xz; + f32 pad; + + sinA = Math_SinS(a); + cosA = Math_CosS(a); + + xx = x * x; + yy = y * y; + zz = z * z; + xy = x * y; + yz = y * z; + xz = x * z; + + mf->xx = (1.0f - xx) * cosA + xx; + mf->xy = (1.0f - cosA) * xy + z * sinA; + mf->xz = (1.0f - cosA) * xz - y * sinA; + mf->xw = 0.0f; + + mf->yx = (1.0f - cosA) * xy - z * sinA; + mf->yy = (1.0f - yy) * cosA + yy; + mf->yz = (1.0f - cosA) * yz + x * sinA; + mf->yw = 0.0f; + + mf->zx = (1.0f - cosA) * xz + y * sinA; + mf->zy = (1.0f - cosA) * yz - x * sinA; + mf->zz = (1.0f - zz) * cosA + zz; + mf->zw = 0.0f; + + mf->wx = mf->wy = mf->wz = 0.0f; + mf->ww = 1.0f; +} + +void SkinMatrix_SetXRotation(MtxF* mf, s16 a) { + f32 sinA; + f32 cosA; + + if (a != 0) { + sinA = Math_SinS(a); + cosA = Math_CosS(a); + } else { + sinA = 0.0f; + cosA = 1.0f; + } + + mf->xy = 0.0f; + mf->xz = 0.0f; + mf->xw = 0.0f; + + mf->yx = 0.0f; + mf->yw = 0.0f; + + mf->zx = 0.0f; + mf->zw = 0.0f; + + mf->wx = 0.0f; + mf->wy = 0.0f; + mf->wz = 0.0f; + + mf->xx = 1.0f; + mf->ww = 1.0f; + + mf->yy = cosA; + mf->zz = cosA; + mf->yz = sinA; + mf->zy = -sinA; +} + +void SkinMatrix_MulXRotation(MtxF* mf, s16 a) { + f32 sinA; + f32 cosA; + f32 ry; + f32 rz; + + if (a != 0) { + sinA = Math_SinS(a); + cosA = Math_CosS(a); + + ry = mf->yx; + rz = mf->zx; + mf->yx = ry * cosA + rz * sinA; + mf->zx = rz * cosA - ry * sinA; + + ry = mf->yy; + rz = mf->zy; + mf->yy = ry * cosA + rz * sinA; + mf->zy = rz * cosA - ry * sinA; + + ry = mf->yz; + rz = mf->zz; + mf->yz = ry * cosA + rz * sinA; + mf->zz = rz * cosA - ry * sinA; + + ry = mf->yw; + rz = mf->zw; + mf->yw = ry * cosA + rz * sinA; + mf->zw = rz * cosA - ry * sinA; + } +} + +void SkinMatrix_SetYRotation(MtxF* mf, s16 a) { + f32 sinA; + f32 cosA; + + if (a != 0) { + sinA = Math_SinS(a); + cosA = Math_CosS(a); + } else { + sinA = 0.0f; + cosA = 1.0f; + } + + mf->xy = 0.0f; + mf->xw = 0.0f; + + mf->yx = 0.0f; + mf->yz = 0.0f; + mf->yw = 0.0f; + + mf->zy = 0.0f; + mf->zw = 0.0f; + + mf->wx = 0.0f; + mf->wy = 0.0f; + mf->wz = 0.0f; + + mf->yy = 1.0f; + mf->ww = 1.0f; + + mf->xx = cosA; + mf->zz = cosA; + mf->xz = -sinA; + mf->zx = sinA; +} + +void SkinMatrix_MulYRotation(MtxF* mf, s16 a) { + f32 sinA; + f32 cosA; + f32 rx; + f32 rz; + + if (a != 0) { + sinA = Math_SinS(a); + cosA = Math_CosS(a); + + rx = mf->xx; + rz = mf->zx; + mf->xx = rx * cosA - rz * sinA; + mf->zx = rx * sinA + rz * cosA; + + rx = mf->xy; + rz = mf->zy; + mf->xy = rx * cosA - rz * sinA; + mf->zy = rx * sinA + rz * cosA; + + rx = mf->xz; + rz = mf->zz; + mf->xz = rx * cosA - rz * sinA; + mf->zz = rx * sinA + rz * cosA; + + rx = mf->xw; + rz = mf->zw; + mf->xw = rx * cosA - rz * sinA; + mf->zw = rx * sinA + rz * cosA; + } +} + +void SkinMatrix_SetZRotation(MtxF* mf, s16 a) { + f32 sinA; + f32 cosA; + + if (a != 0) { + sinA = Math_SinS(a); + cosA = Math_CosS(a); + } else { + sinA = 0.0f; + cosA = 1.0f; + } + + mf->xz = 0.0f; + mf->xw = 0.0f; + + mf->yz = 0.0f; + mf->yw = 0.0f; + + mf->zx = 0.0f; + mf->zy = 0.0f; + mf->zw = 0.0f; + + mf->wx = 0.0f; + mf->wy = 0.0f; + mf->wz = 0.0f; + + + mf->zz = 1.0f; + mf->ww = 1.0f; + + mf->xx = cosA; + mf->yy = cosA; + mf->xy = sinA; + mf->yx = -sinA; +} diff --git a/src/code/z_view.c b/src/code/z_view.c index 1ceb239b25..e970f7aec7 100644 --- a/src/code/z_view.c +++ b/src/code/z_view.c @@ -237,7 +237,7 @@ s32 View_SetQuake(View* view, Vec3f rot, Vec3f scale, f32 speed) { } s32 View_StepQuake(View* view, RSPMatrix* matrix) { - z_Matrix mf; + MtxF mf; if (view->quakeSpeed == 0.0f) { return 0; diff --git a/tables/functions.txt b/tables/functions.txt index e928e407e0..59f3011465 100644 --- a/tables/functions.txt +++ b/tables/functions.txt @@ -2634,30 +2634,30 @@ 0x80138700:("func_80138700",), 0x801387D4:("func_801387D4",), 0x801388E4:("func_801388E4",), - 0x80138BA0:("Matrix_MultiplyByVectorXYZW",), + 0x80138BA0:("SkinMatrix_Vec3fMtxFMultXYZW",), 0x80138C88:("SkinMatrix_Vec3fMtxFMultXYZ",), 0x80138D38:("SkinMatrix_MtxFMtxFMult",), - 0x80139094:("Matrix_GetIdentity",), - 0x801390A8:("Matrix_MakeIdentity",), - 0x80139100:("Matrix_Copy",), - 0x80139188:("Matrix_Invert",), - 0x80139428:("Matrix_MakeScale",), - 0x8013948C:("Matrix_MakeRotationZYX",), - 0x8013961C:("Matrix_MakeRotationYXZ",), + 0x80139094:("SkinMatrix_GetClear",), + 0x801390A8:("SkinMatrix_Clear",), + 0x80139100:("SkinMatrix_MtxFCopy",), + 0x80139188:("SkinMatrix_Invert",), + 0x80139428:("SkinMatrix_SetScale",), + 0x8013948C:("SkinMatrix_SetRotateRPY",), + 0x8013961C:("SkinMatrix_SetRotateYRP",), 0x801397AC:("SkinMatrix_SetTranslate",), - 0x80139810:("Matrix_MakeTranslationRotationZYXScale",), - 0x80139894:("Matrix_MakeTranslationRotationYXZScale",), - 0x80139918:("Matrix_MakeTranslationRotationZYX",), - 0x80139978:("Matrix_ToVec3s",), - 0x801399BC:("Matrix_ToVec3f",), - 0x80139A00:("Matrix_ToRSPMatrix",), + 0x80139810:("SkinMatrix_SetScaleRotateRPYTranslate",), + 0x80139894:("SkinMatrix_SetScaleRotateYRPTranslate",), + 0x80139918:("SkinMatrix_SetRotateRPYTranslate",), + 0x80139978:("SkinMatrix_Vec3fToVec3s",), + 0x801399BC:("SkinMatrix_Vec3sToVec3f",), + 0x80139A00:("SkinMatrix_MtxFToMtx",), 0x80139C18:("SkinMatrix_MtxFToNewMtx",), - 0x80139C60:("Matrix_MakeRotationAroundUnitVector",), - 0x80139DD0:("Matrix_MakeXRotation",), - 0x80139E98:("Matrix_XRotation",), - 0x80139FA0:("Matrix_MakeYRotation",), - 0x8013A068:("Matrix_YRotation",), - 0x8013A174:("Matrix_MakeZRotation",), + 0x80139C60:("SkinMatrix_SetRotateAroundVec",), + 0x80139DD0:("SkinMatrix_SetXRotation",), + 0x80139E98:("SkinMatrix_MulXRotation",), + 0x80139FA0:("SkinMatrix_SetYRotation",), + 0x8013A068:("SkinMatrix_MulYRotation",), + 0x8013A174:("SkinMatrix_SetZRotation",), 0x8013A240:("func_8013A240",), 0x8013A41C:("func_8013A41C",), 0x8013A46C:("func_8013A46C",), diff --git a/tables/objects.txt b/tables/objects.txt index 73262e19d7..708fa806c6 100644 --- a/tables/objects.txt +++ b/tables/objects.txt @@ -319,7 +319,7 @@ 0x801330E0:"z_skelanime", 0x80137970:"z_skin", 0x80138410:"z_skin_awb", - 0x80138BA0:"", + 0x80138BA0:"z_skin_matrix", 0x8013A240:"z_snap", 0x8013A7C0:"z_sub_s", 0x8013EC10:"", @@ -434,7 +434,7 @@ 0x801C3CA0:"code_data_z_scene_table", 0x801C5C50:"code_data_0x801323D0", 0x801C5CB0:"code_data_z_skelanime", - 0x801C5CD0:"code_data_0x80138BA0", + 0x801C5CD0:"code_data_z_skin_matrix", 0x801C5D10:"code_data_z_sub_s", 0x801C5DD0:"code_data_z_vimode", 0x801C5E30:"code_data_z_vr_box", @@ -501,7 +501,7 @@ 0x801DDFF0:"code_rodata_z_scene_proc", 0x801DE020:"code_rodata_z_scene_table", 0x801DE5C0:"code_rodata_z_skin", - 0x801DE5D0:"code_rodata_0x80138BA0", + 0x801DE5D0:"code_rodata_z_skin_matrix", 0x801DE5E0:"code_rodata_z_sub_s", 0x801DF090:"code_rodata_0x8013EC10", 0x801DF0A0:"code_rodata_z_view", diff --git a/tables/variables.txt b/tables/variables.txt index f6b846a036..c94cf8dab3 100644 --- a/tables/variables.txt +++ b/tables/variables.txt @@ -2075,7 +2075,7 @@ 0x801C5C50:("D_801C5C50","UNK_PTR","",0x4), 0x801C5C9C:("D_801C5C9C","UNK_TYPE1","",0x1), 0x801C5CB0:("D_801C5CB0","UNK_PTR","",0x4), - 0x801C5CD0:("identityMatrix","z_Matrix","",0x40), + 0x801C5CD0:("sMtxFClear","MtxF","",0x40), 0x801C5D10:("D_801C5D10","UNK_TYPE1","",0x1), 0x801C5D20:("D_801C5D20","UNK_TYPE1","",0x1), 0x801C5D60:("D_801C5D60","UNK_TYPE1","",0x1), @@ -2358,7 +2358,7 @@ 0x801D15BC:("D_801D15BC","UNK_TYPE4","",0x4), 0x801D15D0:("atan_first_8th_array","s16","[1025]",0x802), 0x801D1DE0:("D_801D1DE0","RSPMatrix","",0x40), - 0x801D1E20:("D_801D1E20","z_Matrix","",0x40), + 0x801D1E20:("D_801D1E20","MtxF","",0x40), 0x801D1E60:("D_801D1E60","UNK_PTR","",0x4), 0x801D1E64:("D_801D1E64","UNK_PTR","",0x4), 0x801D1E70:("D_801D1E70","UNK_TYPE1","",0x1), @@ -4025,7 +4025,7 @@ 0x801EDA18:("D_801EDA18","Vec3f","",0xc), 0x801EDA24:("D_801EDA24","Vec3f","",0xc), 0x801EDA30:("D_801EDA30","Vec3f","",0xc), - 0x801EDA40:("D_801EDA40","z_Matrix","",0x40), + 0x801EDA40:("D_801EDA40","MtxF","",0x40), 0x801EDA80:("D_801EDA80","Vec3f","",0xc), 0x801EDA8C:("D_801EDA8C","Vec3f","",0xc), 0x801EDA98:("D_801EDA98","Vec3f","",0xc), @@ -4430,7 +4430,7 @@ 0x801FBDE0:("D_801FBDE0","UNK_TYPE1","",0x1), 0x801FBDE8:("D_801FBDE8","Vec3f","",0xc), 0x801FBE00:("sMatrixStack","MtxF*","",0x4), - 0x801FBE04:("sCurrentMatrix","z_Matrix*","",0x4), + 0x801FBE04:("sCurrentMatrix","MtxF*","",0x4), 0x801FBE10:("D_801FBE10","UNK_TYPE1","",0x1), 0x801FBE28:("D_801FBE28","UNK_TYPE1","",0x1), 0x801FBE2C:("D_801FBE2C","UNK_TYPE1","",0x1),