sys_matrix OK, documented, rename some other mathematics functions (#787)

* Import data and bss, add some name options

* Decomp rest of stack functions,
remove RSPMatrix,
split header

* sys_matrix OK (thanks Tharo)

Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com>

* pragma weaks in sinf and cosf, change documentation
change mcros to use 0x8000

* Rename sinf and cosf

* Correct initialisation of sMtxFClear

* More minor cleanup

* Rename stack functions

* Matrix_InsertMatrix -> Matrix_Mult

* The big transpose rename

* Fix MirRay_DrawReflectedBeam

* Matrix_InsertTranslation -> Matrix_Translate

* Matrix_Insert.Rotation_s -> Matrix_Rotate$1S
+ RotateY -> RotateYS

* Matrix_Insert(.)Rotation_f -> Matrix_Rotate$1F

* Matrix_RotateStateAroundXAxis -> Matrix_RotateXFApply
Matrix_SetStateXRotation -> Matrix_RotateXFNew

* Matrix_MultiplyVector3fByState -> Matrix_MultVec3f

* Matrix_MultiplyVector3fXZByCurrentState -> Matrix_MultVec3fXZ

* Matrix_GetStateTranslation -> Matrix_MultZero

* Matrix_GetStateTranslationAndScaled(.) -> Matrix_MultVec$1

* Matrix_FromRSPMatrix -> Matrix_MtxToMtxF

* Matrix_MultiplyVector3fByMatrix -> Matrix_MultVec3fExt

* Matrix_TransposeXYZ -> Matrix_Transpose

* Matrix_ToRSPMatrix -> Matrix_MtxFToMtx

* Matrix_AppendToPolyOpaDisp -> Matrix_MtxFToNewMtx
and document the conversion functions

* Matrix_NormalizeXYZ -> Matrix_ReplaceRotation

* Matrix_InsertRotationAroundUnitVector_f -> Matrix_RotateAxisF and S

* Matrix_InsertRotation -> Matrix_RotateZYX

* Document the last functions

* Small cleanup

* Matrix_JointPosition -> Matrix_TranslateRotateZYX

* Matrix_SetStateRotationAndTranslation -> Matrix_SetTranslateRotateYXZ

* func_8018219C -> Matrix_MtxFToYXZRot

* func_801822C4 -> Matrix_MtxFToZYXRot

* Fix files

* Format

* Review 1

* Renames

* Fix warning in EnDragon

* Format

* Convert `mode` to an actual enum

* Add enums, typedefs, externs to sys_matrix header

* Review

* One more

* More review

* Fix function names

* Format

* Fix names

* Format

* Review

* engineer's review

* Fix build

* Format

* Fix again

Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com>
This commit is contained in:
EllipticEllipsis
2022-05-25 23:24:39 -04:00
committed by GitHub
co-authored by Tharo
parent e1477702ca
commit 8049dec339
303 changed files with 5474 additions and 3324 deletions
+4 -4
View File
@@ -235,8 +235,8 @@ void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *thisx) {
EnRecepgirl* this = THIS;
if (limbIndex == 5) {
Matrix_RotateY(0x400 - this->unk_2AE.x, MTXMODE_APPLY);
Matrix_GetStateTranslationAndScaledX(500.0f, &this->actor.focus.pos);
Matrix_RotateYS(0x400 - this->unk_2AE.x, MTXMODE_APPLY);
Matrix_MultVecX(500.0f, &this->actor.focus.pos);
}
}
@@ -426,8 +426,8 @@ void EnRecepgirl_UnkLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi
EnRecepgirl* this = THIS;
if (limbIndex == 5) {
Matrix_RotateY(0x400 - this->unk_2AE.x, MTXMODE_APPLY);
Matrix_GetStateTranslationAndScaledX(500.0f, &this->actor.focus.pos);
Matrix_RotateYS(0x400 - this->unk_2AE.x, MTXMODE_APPLY);
Matrix_MultVecX(500.0f, &this->actor.focus.pos);
}
}
```
+7 -7
View File
@@ -163,22 +163,22 @@ As for the TransformLimbDraw, it has a much simpler prototype. mips2c gives
```C
void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *actor) {
if (limbIndex == 5) {
Matrix_RotateY((s16) (0x400 - actor->unk2AE), 1);
Matrix_GetStateTranslationAndScaledX(500.0f, (Vec3f *) &actor->focus);
Matrix_RotateYS((s16) (0x400 - actor->unk2AE), 1);
Matrix_MultVecX(500.0f, (Vec3f *) &actor->focus);
}
}
```
There is only minor cleanup needed here:
- recasting the last argument,
- replacing the last argument of `Matrix_RotateY` by the enum `MTXMODE_APPLY` (which means "use the current matrix instead of starting from a new identity matrix"), and the first argument by `0x400 - this->unk_2AE.x`.
- replacing the last argument of `Matrix_RotateYS` by the enum `MTXMODE_APPLY` (which means "use the current matrix instead of starting from a new identity matrix"), and the first argument by `0x400 - this->unk_2AE.x`.
- `(Vec3f *) &actor->focus` to `&actor->focus.pos` (this is the same issue as `(Actor*)this`, where mips2c doesn't climb deep enough into the struct).
```C
void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *thisx) {
EnRecepgirl* this = THIS;
if (limbIndex == 5) {
Matrix_RotateY(0x400 - this->unk_2AE.x, MTXMODE_APPLY);
Matrix_GetStateTranslationAndScaledX(500.0f, &this->actor.focus.pos);
Matrix_RotateYS(0x400 - this->unk_2AE.x, MTXMODE_APPLY);
Matrix_MultVecX(500.0f, &this->actor.focus.pos);
}
}
```
@@ -213,7 +213,7 @@ void ObjTree_Draw(Actor *thisx, GlobalContext *globalCtx) {
temp_s0->polyOpa.p = temp_v0_2 + 8;
temp_v0_2->words.w1 = (u32) &D_06000680;
temp_v0_2->words.w0 = 0xDE000000;
Matrix_InsertRotation(sp36, 0, sp34, 1);
Matrix_RotateZYX(sp36, 0, sp34, 1);
temp_v0_3 = temp_s0->polyOpa.p;
temp_s0->polyOpa.p = temp_v0_3 + 8;
temp_v0_3->words.w0 = 0xDA380003;
@@ -286,7 +286,7 @@ void ObjTree_Draw(Actor* thisx, GlobalContext* globalCtx) {
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, D_06000680);
Matrix_InsertRotation(sp36, 0, sp34, MTXMODE_APPLY);
Matrix_RotateZYX(sp36, 0, sp34, MTXMODE_APPLY);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, D_060007C8);
+317 -48
View File
@@ -1347,60 +1347,329 @@ typedef union {
long int force_structure_alignment[4];
} Hilite;
#define gdSPDefLights0(ar,ag,ab) \
{ {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \
{{{ { 0, 0, 0},0,{ 0, 0, 0},0,{ 0, 0, 0},0}}} }
#define gdSPDefLights1(ar,ag,ab,r1,g1,b1,x1,y1,z1) \
{ {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \
{{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}} }
#define gdSPDefLights2(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2) \
{ {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \
{{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \
{{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}} }
#define gdSPDefLights3(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3) \
{ {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \
{{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \
{{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \
{{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}} }
#define gdSPDefLights4(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4) \
{ {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \
{{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \
{{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \
{{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \
{{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}} }
#define gdSPDefLights5(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4,r5,g5,b5,x5,y5,z5) \
{ {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \
{{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \
{{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \
{{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \
{{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}, \
{{ {r5,g5,b5},0,{r5,g5,b5},0,{x5,y5,z5},0}}} }
#define gdSPDefLights0(ar,ag,ab) \
{ \
{{ \
{ ar, ag, ab }, 0, \
{ ar, ag, ab }, 0 \
}}, \
{ \
{{ \
{ 0, 0, 0 }, 0, \
{ 0, 0, 0 }, 0, \
{ 0, 0, 0 }, 0 \
}} \
} \
}
#define gdSPDefLights1(ar,ag,ab, \
r1,g1,b1, \
x1,y1,z1) \
{ \
{{ \
{ ar, ag, ab }, 0, \
{ ar, ag, ab }, 0 \
}}, \
{ \
{{ \
{ r1, g1, b1 }, 0, \
{ r1, g1, b1 }, 0, \
{ x1, y1, z1 }, 0 \
}} \
} \
}
#define gdSPDefLights6(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4,r5,g5,b5,x5,y5,z5,r6,g6,b6,x6,y6,z6) \
{ {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \
{{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \
{{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \
{{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \
{{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}, \
{{ {r5,g5,b5},0,{r5,g5,b5},0,{x5,y5,z5},0}}, \
{{ {r6,g6,b6},0,{r6,g6,b6},0,{x6,y6,z6},0}}} }
#define gdSPDefLights2(ar,ag,ab, \
r1,g1,b1, \
x1,y1,z1, \
r2,g2,b2, \
x2,y2,z2) \
{ \
{{ \
{ ar, ag, ab }, 0, \
{ ar, ag, ab }, 0 \
}}, \
{ \
{{ \
{ r1, g1, b1 }, 0, \
{ r1, g1, b1 }, 0, \
{ x1, y1, z1 }, 0 \
}}, \
{{ \
{ r2, g2, b2 }, 0, \
{ r2, g2, b2 }, 0, \
{ x2, y2, z2 }, 0 \
}} \
} \
}
#define gdSPDefLights3(ar,ag,ab, \
r1,g1,b1, \
x1,y1,z1, \
r2,g2,b2, \
x2,y2,z2, \
r3,g3,b3, \
x3,y3,z3) \
{ \
{{ \
{ ar, ag, ab }, 0, \
{ ar, ag, ab }, 0 \
}}, \
{ \
{{ \
{ r1, g1, b1 }, 0, \
{ r1, g1, b1 }, 0, \
{ x1, y1, z1 }, 0 \
}}, \
{{ \
{ r2, g2, b2 }, 0, \
{ r2, g2, b2 }, 0, \
{ x2, y2, z2 }, 0 \
}}, \
{{ \
{ r3, g3, b3 }, 0, \
{ r3, g3, b3 }, 0, \
{ x3, y3, z3 }, 0 \
}} \
} \
}
#define gdSPDefLights7(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4,r5,g5,b5,x5,y5,z5,r6,g6,b6,x6,y6,z6,r7,g7,b7,x7,y7,z7) \
{ {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \
{{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \
{{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \
{{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \
{{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}, \
{{ {r5,g5,b5},0,{r5,g5,b5},0,{x5,y5,z5},0}}, \
{{ {r6,g6,b6},0,{r6,g6,b6},0,{x6,y6,z6},0}}, \
{{ {r7,g7,b7},0,{r7,g7,b7},0,{x7,y7,z7},0}}} }
#define gdSPDefLights4(ar,ag,ab, \
r1,g1,b1, \
x1,y1,z1, \
r2,g2,b2, \
x2,y2,z2, \
r3,g3,b3, \
x3,y3,z3, \
r4,g4,b4, \
x4,y4,z4) \
{ \
{{ \
{ ar, ag, ab }, 0, \
{ ar, ag, ab }, 0 \
}}, \
{ \
{{ \
{ r1, g1, b1 }, 0, \
{ r1, g1, b1 }, 0, \
{ x1, y1, z1 }, 0 \
}}, \
{{ \
{ r2, g2, b2 }, 0, \
{ r2, g2, b2 }, 0, \
{ x2, y2, z2 }, 0 \
}}, \
{{ \
{ r3, g3, b3 }, 0, \
{ r3, g3, b3 }, 0, \
{ x3, y3, z3 }, 0 \
}}, \
{{ \
{ r4, g4, b4 }, 0, \
{ r4, g4, b4 }, 0, \
{ x4, y4, z4 }, 0 \
}} \
} \
}
#define gdSPDefLights5(ar,ag,ab, \
r1,g1,b1, \
x1,y1,z1, \
r2,g2,b2, \
x2,y2,z2, \
r3,g3,b3, \
x3,y3,z3, \
r4,g4,b4, \
x4,y4,z4, \
r5,g5,b5, \
x5,y5,z5) \
{ \
{{ \
{ ar, ag, ab }, 0, \
{ ar, ag, ab }, 0 \
}}, \
{ \
{{ \
{ r1, g1, b1 }, 0, \
{ r1, g1, b1 }, 0, \
{ x1, y1, z1 }, 0 \
}}, \
{{ \
{ r2, g2, b2 }, 0, \
{ r2, g2, b2 }, 0, \
{ x2, y2, z2 }, 0 \
}}, \
{{ \
{ r3, g3, b3 }, 0, \
{ r3, g3, b3 }, 0, \
{ x3, y3, z3 }, 0 \
}}, \
{{ \
{ r4, g4, b4 }, 0, \
{ r4, g4, b4 }, 0, \
{ x4, y4, z4 }, 0 \
}}, \
{{ \
{ r5, g5, b5 }, 0, \
{ r5, g5, b5 }, 0, \
{ x5, y5, z5 }, 0 \
}} \
} \
}
#define gdSPDefLookAt(rightx,righty,rightz,upx,upy,upz) \
{ {{ {{0,0,0},0,{0,0,0},0,{rightx,righty,rightz},0}}, \
{ {{0,0x80,0},0,{0,0x80,0},0,{upx,upy,upz},0}}} }
#define gdSPDefLights6(ar,ag,ab, \
r1,g1,b1, \
x1,y1,z1, \
r2,g2,b2, \
x2,y2,z2, \
r3,g3,b3, \
x3,y3,z3, \
r4,g4,b4, \
x4,y4,z4, \
r5,g5,b5, \
x5,y5,z5, \
r6,g6,b6, \
x6,y6,z6) \
{ \
{{ \
{ ar, ag, ab }, 0, \
{ ar, ag, ab }, 0 \
}}, \
{ \
{{ \
{ r1, g1, b1 }, 0, \
{ r1, g1, b1 }, 0, \
{ x1, y1, z1 }, 0 \
}}, \
{{ \
{ r2, g2, b2 }, 0, \
{ r2, g2, b2 }, 0, \
{ x2, y2, z2 }, 0 \
}}, \
{{ \
{ r3, g3, b3 }, 0, \
{ r3, g3, b3 }, 0, \
{ x3, y3, z3 }, 0 \
}}, \
{{ \
{ r4, g4, b4 }, 0, \
{ r4, g4, b4 }, 0, \
{ x4, y4, z4 }, 0 \
}}, \
{{ \
{ r5, g5, b5 }, 0, \
{ r5, g5, b5 }, 0, \
{ x5, y5, z5 }, 0 \
}}, \
{{ \
{ r6, g6, b6 }, 0, \
{ r6, g6, b6 }, 0, \
{ x6, y6, z6 }, 0 \
}} \
} \
}
#define gdSPDefLights7(ar,ag,ab, \
r1,g1,b1, \
x1,y1,z1, \
r2,g2,b2, \
x2,y2,z2, \
r3,g3,b3, \
x3,y3,z3, \
r4,g4,b4, \
x4,y4,z4, \
r5,g5,b5, \
x5,y5,z5, \
r6,g6,b6, \
x6,y6,z6, \
r7,g7,b7, \
x7,y7,z7) \
{ \
{{ \
{ ar, ag, ab }, 0, \
{ ar, ag, ab }, 0 \
}}, \
{ \
{{ \
{ r1, g1, b1 }, 0, \
{ r1, g1, b1 }, 0, \
{ x1, y1, z1 }, 0 \
}}, \
{{ \
{ r2, g2, b2 }, 0, \
{ r2, g2, b2 }, 0, \
{ x2, y2, z2 }, 0 \
}}, \
{{ \
{ r3, g3, b3 }, 0, \
{ r3, g3, b3 }, 0, \
{ x3, y3, z3 }, 0 \
}}, \
{{ \
{ r4, g4, b4 }, 0, \
{ r4, g4, b4 }, 0, \
{ x4, y4, z4 }, 0 \
}}, \
{{ \
{ r5, g5, b5 }, 0, \
{ r5, g5, b5 }, 0, \
{ x5, y5, z5 }, 0 \
}}, \
{{ \
{ r6, g6, b6 }, 0, \
{ r6, g6, b6 }, 0, \
{ x6, y6, z6 }, 0 \
}}, \
{{ \
{ r7, g7, b7 }, 0, \
{ r7, g7, b7 }, 0, \
{ x7, y7, z7 }, 0 \
}} \
} \
}
#define gdSPDefLookAt(rightx,righty,rightz,upx,upy,upz) \
{{ \
{{ \
{ 0, 0, 0 }, 0, \
{ 0, 0, 0 }, 0, \
{ rightx, righty, rightz }, 0 \
}}, \
{{ \
{ 0, 0x80, 0 }, 0, \
{ 0, 0x80, 0 }, 0, \
{ upx, upy, upz }, 0 \
}} \
}}
#define qs1616(e) ((s32)((e) * 0x00010000))
#define IPART(x) ((qs1616(x) >> 16) & 0xFFFF)
#define FPART(x) (qs1616(x) & 0xFFFF)
#define gdSPDefMtx( \
xx, yx, zx, wx, \
xy, yy, zy, wy, \
xz, yz, zz, wz, \
xw, yw, zw, ww) \
{{ \
(IPART(xx) << 0x10) | IPART(xy), \
(IPART(xz) << 0x10) | IPART(xw), \
(IPART(yx) << 0x10) | IPART(yy), \
(IPART(yz) << 0x10) | IPART(yw), \
(IPART(zx) << 0x10) | IPART(zy), \
(IPART(zz) << 0x10) | IPART(zw), \
(IPART(wx) << 0x10) | IPART(wy), \
(IPART(wz) << 0x10) | IPART(ww), \
(FPART(xx) << 0x10) | FPART(xy), \
(FPART(xz) << 0x10) | FPART(xw), \
(FPART(yx) << 0x10) | FPART(yy), \
(FPART(yz) << 0x10) | FPART(yw), \
(FPART(zx) << 0x10) | FPART(zy), \
(FPART(zz) << 0x10) | FPART(zw), \
(FPART(wx) << 0x10) | FPART(wy), \
(FPART(wz) << 0x10) | FPART(ww), \
}}
/*
* Graphics DMA Packet
+8 -4
View File
@@ -27,6 +27,10 @@ typedef void* TexturePtr;
typedef long int Mtx_t[4][4];
typedef union {
Mtx_t m;
struct {
u16 intPart[4][4];
u16 fracPart[4][4];
};
long long int forc_structure_alignment;
} Mtx; // size = 0x40
@@ -34,10 +38,10 @@ typedef float MtxF_t[4][4];
typedef union {
MtxF_t mf;
struct {
float xx, xy, xz, xw,
yx, yy, yz, yw,
zx, zy, zz, zw,
wx, wy, wz, ww;
float xx, yx, zx, wx,
xy, yy, zy, wy,
xz, yz, zz, wz,
xw, yw, zw, ww;
};
} MtxF; // size = 0x40
+5 -46
View File
@@ -148,8 +148,8 @@ void GfxPrint_Open(GfxPrint* printer, Gfx* dList);
Gfx* GfxPrint_Close(GfxPrint* printer);
s32 GfxPrint_VPrintf(GfxPrint* printer, const char* fmt, va_list args);
s32 GfxPrint_Printf(GfxPrint* printer, const char* fmt, ...);
void MtxConv_F2L(MatrixInternal* m1, MtxF* m2);
void MtxConv_L2F(MtxF* m1, MatrixInternal* m2);
void MtxConv_F2L(Mtx* m1, MtxF* m2);
void MtxConv_L2F(MtxF* m1, Mtx* m2);
void __assert(const char* file, u32 lineNum);
// void func_800862B4(void);
void* SystemArena_MallocMin1(u32 size);
@@ -220,7 +220,7 @@ OSIntMask osSetIntMask(OSIntMask im);
// OSIntMask osGetIntMask(void);
// void osVoiceSetWord(void);
// void guScale(void);
f32 __sinf(f32 __x);
f32 sinf(f32 __x);
s16 sins(u16 x);
OSTask* _VirtualToPhysicalTask(OSTask* intp);
void osSpTaskLoad(OSTask* intp);
@@ -377,7 +377,7 @@ void __osRestoreInt(OSIntMask im);
void __osViInit(void);
void __osViSwapContext(void);
OSMesgQueue* osPiGetCmdQueue(void);
f32 __cosf(f32 __x);
f32 cosf(f32 __x);
s32 osEPiReadIo(OSPiHandle* pihandle, u32 devAddr, u32* data);
void osViSetSpecialFeatures(u32 func);
s16 coss(u16 x);
@@ -3072,53 +3072,12 @@ s32 Math3D_XYInSphere(Sphere16* sphere, f32 x, f32 y);
s32 Math3D_YZInSphere(Sphere16* sphere, f32 y, f32 z);
// void func_8017FB1C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11);
// void func_8017FD44(void);
u16 Math_GetAtan2Tbl(f32 opposite, f32 adjacent);
s16 Math_Atan2S(f32 opposite, f32 adjacent);
f32 Math_Atan2F(f32 opposite, f32 adjacent);
s16 Math_FAtan2F(f32 adjacent, f32 opposite);
f32 Math_Acot2F(f32 adjacent, f32 opposite);
void Matrix_StateAlloc(GameState* gameState);
void Matrix_StatePush(void);
void Matrix_StatePop(void);
void Matrix_CopyCurrentState(MtxF* matrix);
void Matrix_SetCurrentState(MtxF* matrix);
MtxF* Matrix_GetCurrentState(void);
void Matrix_InsertMatrix(MtxF* matrix, s32 appendToState);
void Matrix_InsertTranslation(f32 x, f32 y, f32 z, s32 appendToState);
void Matrix_Scale(f32 xScale, f32 yScale, f32 zScale, s32 appendToState);
void Matrix_InsertXRotation_s(s16 rotation, s32 appendToState);
void Matrix_InsertXRotation_f(f32 rotation, s32 appendToState);
void Matrix_RotateStateAroundXAxis(f32 rotation);
void Matrix_SetStateXRotation(f32 rotation);
void Matrix_RotateY(s16 rotation, s32 appendToState);
void Matrix_InsertYRotation_f(f32 rotation, s32 appendToState);
void Matrix_InsertZRotation_s(s16 rotation, s32 appendToState);
void Matrix_InsertZRotation_f(f32 rotation, s32 appendToState);
void Matrix_InsertRotation(s16 xRotation, s16 yRotation, s16 zRotation, s32 appendToState);
void Matrix_JointPosition(Vec3f* position, Vec3s* rotation);
void Matrix_RotateAndTranslateState(Vec3f* translation, Vec3s* rotation);
void Matrix_SetStateRotationAndTranslation(f32 x, f32 y, f32 z, Vec3s* rotation);
RSPMatrix* Matrix_ToRSPMatrix(MtxF* src, RSPMatrix* dst);
Mtx* Matrix_ToMtx(Mtx* dest);
RSPMatrix* Matrix_GetStateAsRSPMatrix(RSPMatrix* matrix);
Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx);
RSPMatrix* Matrix_AppendStateToPolyOpaDisp(GraphicsContext* gfxCtx);
void Matrix_AppendToPolyOpaDisp(MtxF* mtx, GraphicsContext* gfxCtx);
void Matrix_MultiplyVector3fByState(Vec3f* src, Vec3f* dst);
void Matrix_GetStateTranslation(Vec3f* dst);
void Matrix_GetStateTranslationAndScaledX(f32 scale, Vec3f* dst);
void Matrix_GetStateTranslationAndScaledY(f32 scale, Vec3f* dst);
void Matrix_GetStateTranslationAndScaledZ(f32 scale, Vec3f* dst);
void Matrix_MultiplyVector3fXZByCurrentState(Vec3f* src, Vec3f* dst);
void Matrix_MtxFCopy(MtxF* dst, MtxF* src);
void Matrix_FromRSPMatrix(Mtx* src, MtxF* dst);
void Matrix_MultiplyVector3fByMatrix(Vec3f* src, Vec3f* dst, MtxF* matrix);
void Matrix_TransposeXYZ(MtxF* matrix);
void Matrix_NormalizeXYZ(MtxF* matrix);
void func_8018219C(MtxF* pfParm1, Vec3s* psParm2, s32 iParm3);
// void func_801822C4(void);
void Matrix_InsertRotationAroundUnitVector_f(f32 rotation, Vec3f* vector, s32 appendToState);
void Matrix_InsertRotationAroundUnitVector_s(s16 rotation, Vec3f* vector, s32 appendToState);
u64* SysUcode_GetUCodeBoot(void);
size_t SysUcode_GetUCodeBootSize(void);
+81
View File
@@ -0,0 +1,81 @@
#ifndef SYS_MATRIX_H
#define SYS_MATRIX_H
#include "z64math.h"
struct GraphicsContext;
struct GameState;
typedef enum {
/* 0 */ MTXMODE_NEW, // generates a new matrix
/* 1 */ MTXMODE_APPLY // applies transformation to the current matrix
} MatrixMode;
extern Mtx gIdentityMtx;
extern MtxF gIdentityMtxF;
/* Stack operations */
void Matrix_Init(struct GameState* gameState);
void Matrix_Push(void);
void Matrix_Pop(void);
void Matrix_Get(MtxF* dest);
void Matrix_Put(MtxF* src);
MtxF* Matrix_GetCurrent(void);
/* Basic operations */
void Matrix_Mult(MtxF* matrix, MatrixMode mode);
void Matrix_Translate(f32 x, f32 y, f32 z, MatrixMode mode);
void Matrix_Scale(f32 x, f32 y, f32 z, MatrixMode mode);
void Matrix_RotateXS(s16 x, MatrixMode mode);
void Matrix_RotateXF(f32 x, MatrixMode mode);
void Matrix_RotateXFApply(f32 x);
void Matrix_RotateXFNew(f32 x);
void Matrix_RotateYS(s16 y, MatrixMode mode);
void Matrix_RotateYF(f32 y, MatrixMode mode);
void Matrix_RotateZS(s16 z, MatrixMode mode);
void Matrix_RotateZF(f32 z, MatrixMode mode);
/* Compound operations */
void Matrix_RotateZYX(s16 x, s16 y, s16 z, MatrixMode mode);
void Matrix_TranslateRotateZYX(Vec3f* translation, Vec3s* rot);
void Matrix_SetTranslateRotateYXZ(f32 x, f32 y, f32 z, Vec3s* rot);
/* Conversion and allocation operations */
Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest);
Mtx* Matrix_ToMtx(Mtx* dest);
Mtx* Matrix_NewMtx(struct GraphicsContext* gfxCtx);
Mtx* Matrix_MtxFToNewMtx(MtxF* src, struct GraphicsContext* gfxCtx);
/* Vector operations */
void Matrix_MultVec3f(Vec3f* src, Vec3f* dest);
void Matrix_MultZero(Vec3f* dest);
void Matrix_MultVecX(f32 x, Vec3f* dest);
void Matrix_MultVecY(f32 y, Vec3f* dest);
void Matrix_MultVecZ(f32 z, Vec3f* dest);
void Matrix_MultVec3fXZ(Vec3f* src, Vec3f* dest);
/* Copy and another conversion */
void Matrix_MtxFCopy(MtxF* dest, MtxF* src);
void Matrix_MtxToMtxF(Mtx* src, MtxF* dest);
/* Miscellaneous */
void Matrix_MultVec3fExt(Vec3f* src, Vec3f* dest, MtxF* mf);
void Matrix_Transpose(MtxF* mf);
void Matrix_ReplaceRotation(MtxF* mf);
void Matrix_MtxFToYXZRot(MtxF* src, Vec3s* dest, s32 nonUniformScale);
void Matrix_MtxFToZYXRot(MtxF* src, Vec3s* dest, s32 nonUniformScale);
void Matrix_RotateAxisF(f32 angle, Vec3f* axis, MatrixMode mode);
void Matrix_RotateAxisS(s16 angle, Vec3f* axis, MatrixMode mode);
#endif
-2
View File
@@ -1574,8 +1574,6 @@ extern UNK_PTR D_801D1540;
// extern f32 sFactorialTbl[13];
extern Vec3f gZeroVec3f;
extern Vec3s gZeroVec3s;
extern Mtx gIdentityMtx;
extern MtxF gIdentityMtxF;
// extern UNK_TYPE1 D_801D1E70;
extern s16 gLowPassFilterData[];
extern s16 gHighPassFilterData[];
+1 -22
View File
@@ -23,6 +23,7 @@
#include "sfx.h"
#include "message_data_static.h"
#include "sys_matrix.h"
#include "z64actor.h"
#include "z64animation.h"
#include "z64audio.h"
@@ -304,11 +305,6 @@ typedef struct {
/* 0x10 */ OSTime resetTime;
} NmiBuff; // size >= 0x18
typedef struct {
/* 0x00 */ s16 intPart[16];
/* 0x20 */ u16 fracPart[16];
} RSPMatrix; // size = 0x40
typedef struct {
/* 0x0 */ s8 letterboxTarget;
/* 0x1 */ s8 letterboxMagnitude;
@@ -383,13 +379,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 union {
F3DVertexColor color;
F3DVertexNormal normal;
@@ -1421,16 +1410,6 @@ typedef struct {
/* 0x14 */ Gfx* monoDl;
} VisMono; // size = 0x18
typedef enum {
MTXMODE_NEW, // generates a new matrix
MTXMODE_APPLY // applies transformation to the current matrix
} MatrixMode;
typedef struct {
/* 0x00 */ u16 intPart[4][4];
/* 0x20 */ u16 fracPart[4][4];
} MatrixInternal; // size = 0x40
typedef struct DebugDispObject {
/* 0x00 */ Vec3f pos;
/* 0x0C */ Vec3s rot;
+4 -4
View File
@@ -1,5 +1,5 @@
#ifndef _Z64MATH_H_
#define _Z64MATH_H_
#ifndef Z64MATH_H
#define Z64MATH_H
#include "ultra64.h"
@@ -111,7 +111,7 @@ typedef struct {
// Trig macros
#define DEGF_TO_BINANG(degreesf) (s16)(degreesf * 182.04167f + .5f)
#define RADF_TO_BINANG(radf) (s16)(radf * (32768.0f / M_PI))
#define RADF_TO_BINANG(radf) (s16)(radf * (0x8000 / M_PI))
#define RADF_TO_DEGF(radf) (radf * (180.0f / M_PI))
#define DEGF_TO_RADF(degf) (degf * (M_PI / 180.0f))
#define BINANG_ROT180(angle) ((s16)(angle + 0x8000))
@@ -119,7 +119,7 @@ typedef struct {
#define BINANG_ADD(a, b) ((s16)(a + b))
#define DEG_TO_RAD(degrees) ((degrees) * (M_PI / 180.0f))
#define BINANG_TO_DEGF(binang) ((f32)binang * (360.0001525f / 65535.0f))
#define BINANG_TO_RAD(binang) (((f32)binang / 32768.0f) * M_PI)
#define BINANG_TO_RAD(binang) (((f32)binang / 0x8000) * M_PI)
// Vector macros
#define SQXZ(vec) ((vec.x) * (vec.x) + (vec.z) * (vec.z))
-2
View File
@@ -598,8 +598,6 @@ beginseg
include "build/data/code/code_801D15B0.data.o"
include "build/src/code/sys_math_atan.o"
include "build/src/code/sys_matrix.o"
include "build/data/code/sys_matrix.data.o"
include "build/data/code/sys_matrix.bss.o"
include "build/src/code/sys_ucode.o"
include "build/src/code/code_80182CE0.o"
include "build/data/code/code_801D1E70.data.o"
+2 -2
View File
@@ -14,11 +14,11 @@ extern f32 func_80086D18(f32 x);
s32 gUseAtanContFrac;
/**
* Tangent function computed using libultra __sinf and __cosf
* Tangent function computed using libultra sinf and cosf
*/
// Math_FTanF
f32 func_80086760(f32 x) {
return __sinf(x) / __cosf(x);
return sinf(x) / cosf(x);
}
// Unused
+7 -6
View File
@@ -1,18 +1,19 @@
#include "global.h"
void MtxConv_F2L(MatrixInternal* m1, MtxF* m2) {
void MtxConv_F2L(Mtx* mtx, MtxF* mf) {
s32 i;
s32 j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
s32 value = (m2->mf[i][j] * 0x10000);
m1->intPart[i][j] = value >> 16;
m1->fracPart[i][j] = value;
s32 value = (mf->mf[i][j] * 0x10000);
mtx->intPart[i][j] = value >> 16;
mtx->fracPart[i][j] = value;
}
}
}
void MtxConv_L2F(MtxF* m1, MatrixInternal* m2) {
guMtxL2F(m1, (Mtx*)m2);
void MtxConv_L2F(MtxF* mtx, Mtx* mf) {
guMtxL2F(mtx, mf);
}
+1895 -40
View File
File diff suppressed because it is too large Load Diff
+46 -47
View File
@@ -92,10 +92,10 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gf
}
func_800C0094(actor->floorPoly, actor->world.pos.x, actor->floorHeight, actor->world.pos.z, &mtx);
Matrix_SetCurrentState(&mtx);
Matrix_Put(&mtx);
if ((dlist != gCircleShadowDL) || (actor->scale.x != actor->scale.z)) {
Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY);
Matrix_RotateYS(actor->shape.rot.y, MTXMODE_APPLY);
}
shadowScale *= actor->shape.shadowScale;
@@ -151,8 +151,8 @@ void ActorShadow_DrawFoot(GlobalContext* globalCtx, Light* light, MtxF* arg2, s3
sp58 = Math_FAtan2F(dir2, dir0);
shadowScaleZ *= (4.5f - (light->l.dir[1] * 0.035f));
shadowScaleZ = CLAMP_MIN(shadowScaleZ, 1.0f);
Matrix_SetCurrentState(arg2);
Matrix_RotateY(sp58, MTXMODE_APPLY);
Matrix_Put(arg2);
Matrix_RotateYS(sp58, MTXMODE_APPLY);
Matrix_Scale(shadowScaleX, 1.0f, shadowScaleX * shadowScaleZ, MTXMODE_APPLY);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
@@ -301,9 +301,9 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx
void Actor_SetFeetPos(Actor* actor, s32 limbIndex, s32 leftFootIndex, Vec3f* leftFootPos, s32 rightFootIndex,
Vec3f* rightFootPos) {
if (limbIndex == leftFootIndex) {
Matrix_MultiplyVector3fByState(leftFootPos, &actor->shape.feetPos[FOOT_LEFT]);
Matrix_MultVec3f(leftFootPos, &actor->shape.feetPos[FOOT_LEFT]);
} else if (limbIndex == rightFootIndex) {
Matrix_MultiplyVector3fByState(rightFootPos, &actor->shape.feetPos[FOOT_RIGHT]);
Matrix_MultVec3f(rightFootPos, &actor->shape.feetPos[FOOT_RIGHT]);
}
}
@@ -533,22 +533,22 @@ void Actor_DrawZTarget(TargetContext* targetCtx, GlobalContext* globalCtx) {
var2 = ((entry->unkC - 120.0f) * 0.001f) + 0.15f;
}
Matrix_InsertTranslation(entry->pos.x, entry->pos.y, 0.0f, MTXMODE_NEW);
Matrix_Translate(entry->pos.x, entry->pos.y, 0.0f, MTXMODE_NEW);
Matrix_Scale(var2, 0.15f, 1.0f, MTXMODE_APPLY);
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, entry->color.r, entry->color.g, entry->color.b,
(u8)alpha);
Matrix_InsertZRotation_s((targetCtx->unk4B * 512), MTXMODE_APPLY);
Matrix_RotateZS((targetCtx->unk4B * 512), MTXMODE_APPLY);
for (i = 0; i < 4; i++) {
Matrix_InsertZRotation_s(0x4000, MTXMODE_APPLY);
Matrix_StatePush();
Matrix_InsertTranslation(entry->unkC, entry->unkC, 0.0f, MTXMODE_APPLY);
Matrix_RotateZS(0x4000, MTXMODE_APPLY);
Matrix_Push();
Matrix_Translate(entry->unkC, entry->unkC, 0.0f, MTXMODE_APPLY);
gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(OVERLAY_DISP++, gZTargetLockOnTriangleDL);
Matrix_StatePop();
Matrix_Pop();
}
}
@@ -566,10 +566,10 @@ void Actor_DrawZTarget(TargetContext* targetCtx, GlobalContext* globalCtx) {
POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x07);
Matrix_InsertTranslation(actor->focus.pos.x,
actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y) + 17.0f,
actor->focus.pos.z, MTXMODE_NEW);
Matrix_RotateY((globalCtx->gameplayFrames * 3000), MTXMODE_APPLY);
Matrix_Translate(actor->focus.pos.x,
actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y) + 17.0f,
actor->focus.pos.z, MTXMODE_NEW);
Matrix_RotateYS((globalCtx->gameplayFrames * 3000), MTXMODE_APPLY);
Matrix_Scale((iREG(27) + 35) / 1000.0f, (iREG(28) + 60) / 1000.0f, (iREG(29) + 50) / 1000.0f,
MTXMODE_APPLY);
@@ -2511,14 +2511,13 @@ void Actor_Draw(GlobalContext* globalCtx, Actor* actor) {
Lights_Draw(light, globalCtx->state.gfxCtx);
if (actor->flags & ACTOR_FLAG_1000) {
Matrix_SetStateRotationAndTranslation(
Matrix_SetTranslateRotateYXZ(
actor->world.pos.x + globalCtx->mainCamera.skyboxOffset.x,
actor->world.pos.y + ((actor->shape.yOffset * actor->scale.y) + globalCtx->mainCamera.skyboxOffset.y),
actor->world.pos.z + globalCtx->mainCamera.skyboxOffset.z, &actor->shape.rot);
} else {
Matrix_SetStateRotationAndTranslation(actor->world.pos.x,
actor->world.pos.y + (actor->shape.yOffset * actor->scale.y),
actor->world.pos.z, &actor->shape.rot);
Matrix_SetTranslateRotateYXZ(actor->world.pos.x, actor->world.pos.y + (actor->shape.yOffset * actor->scale.y),
actor->world.pos.z, &actor->shape.rot);
}
Matrix_Scale(actor->scale.x, actor->scale.y, actor->scale.z, MTXMODE_APPLY);
@@ -3543,14 +3542,14 @@ void Actor_SpawnBodyParts(Actor* actor, GlobalContext* globalCtx, s32 arg2, Gfx*
MtxF* currentMatrix;
if (*dList != NULL) {
currentMatrix = Matrix_GetCurrentState();
currentMatrix = Matrix_GetCurrent();
spawnedPart =
Actor_SpawnAsChild(&globalCtx->actorCtx, actor, globalCtx, ACTOR_EN_PART, currentMatrix->mf[3][0],
currentMatrix->mf[3][1], currentMatrix->mf[3][2], 0, 0, actor->objBankIndex, arg2);
if (spawnedPart != NULL) {
part = (EnPart*)spawnedPart;
func_8018219C(currentMatrix, &part->actor.shape.rot, 0);
Matrix_MtxFToYXZRot(currentMatrix, &part->actor.shape.rot, false);
part->unk_150 = *dList;
Math_Vec3f_Copy(&part->actor.scale, &actor->scale);
}
@@ -3772,9 +3771,9 @@ void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx)
sp54 = BgCheck_EntityRaycastFloor2(globalCtx, &globalCtx->colCtx, &sp44, &sp48);
if (sp44 != NULL) {
func_800C0094(sp44, arg0->x, sp54, arg0->z, &sp58);
Matrix_SetCurrentState(&sp58);
Matrix_Put(&sp58);
} else {
Matrix_InsertTranslation(arg0->x, arg0->y, arg0->z, MTXMODE_NEW);
Matrix_Translate(arg0->x, arg0->y, arg0->z, MTXMODE_NEW);
}
Matrix_Scale(arg1->x, 1.0f, arg1->z, MTXMODE_APPLY);
@@ -3841,16 +3840,16 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) {
OPEN_DISPS(globalCtx->state.gfxCtx);
Matrix_InsertTranslation(0.0f, entry->yShift, 500.0f, MTXMODE_APPLY);
Matrix_CopyCurrentState(&baseMtxF);
Matrix_Translate(0.0f, entry->yShift, 500.0f, MTXMODE_APPLY);
Matrix_Get(&baseMtxF);
chainsTranslateX = __sinf(entry->chainAngle - chainRotZ) * -(10 - frame) * 0.1f * entry->chainLength;
chainsTranslateY = __cosf(entry->chainAngle - chainRotZ) * (10 - frame) * 0.1f * entry->chainLength;
chainsTranslateX = sinf(entry->chainAngle - chainRotZ) * -(10 - frame) * 0.1f * entry->chainLength;
chainsTranslateY = cosf(entry->chainAngle - chainRotZ) * (10 - frame) * 0.1f * entry->chainLength;
for (i = 0; i < 4; i++) {
Matrix_SetCurrentState(&baseMtxF);
Matrix_InsertZRotation_f(chainRotZ, MTXMODE_APPLY);
Matrix_InsertTranslation(chainsTranslateX, chainsTranslateY, 0.0f, MTXMODE_APPLY);
Matrix_Put(&baseMtxF);
Matrix_RotateZF(chainRotZ, MTXMODE_APPLY);
Matrix_Translate(chainsTranslateX, chainsTranslateY, 0.0f, MTXMODE_APPLY);
if (entry->chainsScale != 1.0f) {
Matrix_Scale(entry->chainsScale, entry->chainsScale, entry->chainsScale, MTXMODE_APPLY);
}
@@ -3867,7 +3866,7 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) {
chainRotZ += rotZStep;
}
Matrix_SetCurrentState(&baseMtxF);
Matrix_Put(&baseMtxF);
Matrix_Scale(frame * 0.1f, frame * 0.1f, frame * 0.1f, MTXMODE_APPLY);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
@@ -4516,7 +4515,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
u32 gameplayFrames = globalCtx->gameplayFrames;
f32 effectAlphaScaled;
currentMatrix = Matrix_GetCurrentState();
currentMatrix = Matrix_GetCurrent();
// Apply sfx along with damage effect
if ((actor != NULL) && (effectAlpha > 0.05f) && (globalCtx->gameOverCtx.state == 0)) {
@@ -4565,15 +4564,15 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
gDPSetEnvColor(POLY_XLU_DISP++, KREG(20) + 200, KREG(21) + 200, KREG(22) + 255, (u8)alpha);
Matrix_InsertTranslation(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW);
Matrix_Translate(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW);
Matrix_Scale(frozenScale, frozenScale, frozenScale, MTXMODE_APPLY);
if (limbIndex & 1) {
Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY);
Matrix_RotateYF(M_PI, MTXMODE_APPLY);
}
if (limbIndex & 2) {
Matrix_InsertZRotation_f(M_PI, MTXMODE_APPLY);
Matrix_RotateZF(M_PI, MTXMODE_APPLY);
}
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
@@ -4604,8 +4603,8 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, twoTexScrollParam * 3,
twoTexScrollParam * -12, 32, 64, 1, 0, 0, 32, 32));
Matrix_InsertTranslation(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW);
Matrix_NormalizeXYZ(&globalCtx->billboardMtxF);
Matrix_Translate(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW);
Matrix_ReplaceRotation(&globalCtx->billboardMtxF);
Matrix_Scale(steamScale, steamScale, 1.0f, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
@@ -4625,7 +4624,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
type = 255;
}
Matrix_SetCurrentState(&globalCtx->billboardMtxF);
Matrix_Put(&globalCtx->billboardMtxF);
Matrix_Scale((effectScale * 0.005f) * 1.35f, (effectScale * 0.005f), (effectScale * 0.005f) * 1.35f,
MTXMODE_APPLY);
@@ -4651,7 +4650,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0,
((limbIndex * 10 + gameplayFrames) * -20) & 0x1FF, 32, 128));
Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY);
Matrix_RotateYF(M_PI, MTXMODE_APPLY);
currentMatrix->mf[3][0] = limbPos->x;
currentMatrix->mf[3][1] = limbPos->y;
currentMatrix->mf[3][2] = limbPos->z;
@@ -4688,12 +4687,12 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 100, 128);
}
Matrix_SetCurrentState(&globalCtx->billboardMtxF);
Matrix_Put(&globalCtx->billboardMtxF);
Matrix_Scale(lightOrbsScale, lightOrbsScale, 1.0f, MTXMODE_APPLY);
// Apply and draw a light orb over each limb of frozen actor
for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) {
Matrix_InsertZRotation_f(randPlusMinusPoint5Scaled(2 * M_PI), MTXMODE_APPLY);
Matrix_RotateZF(randPlusMinusPoint5Scaled(2 * M_PI), MTXMODE_APPLY);
currentMatrix->mf[3][0] = limbPos->x;
currentMatrix->mf[3][1] = limbPos->y;
currentMatrix->mf[3][2] = limbPos->z;
@@ -4726,14 +4725,14 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
gDPSetEnvColor(POLY_XLU_DISP++, (u8)(sREG(20) + 255), (u8)(sREG(21) + 255), (u8)sREG(22), (u8)sREG(23));
Matrix_SetCurrentState(&globalCtx->billboardMtxF);
Matrix_Put(&globalCtx->billboardMtxF);
Matrix_Scale(electricSparksScale, electricSparksScale, electricSparksScale, MTXMODE_APPLY);
// Every limb draws two electric sparks at random orientations
for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) {
// first electric spark
Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI));
Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY);
Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI));
Matrix_RotateZF(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY);
currentMatrix->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x;
currentMatrix->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y;
currentMatrix->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z;
@@ -4744,8 +4743,8 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
gSPDisplayList(POLY_XLU_DISP++, gElectricSparkVtxDL);
// second electric spark
Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI));
Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY);
Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI));
Matrix_RotateZF(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY);
currentMatrix->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x;
currentMatrix->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y;
currentMatrix->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z;
+12 -12
View File
@@ -248,20 +248,20 @@ void func_800C0094(CollisionPoly* poly, f32 tx, f32 ty, f32 tz, MtxF* dest) {
phi_f12 = 0.0f;
}
dest->xx = z_f14;
dest->xy = (-nx) * phi_f14;
dest->xz = (-nx) * phi_f12;
dest->yx = nx;
dest->yx = (-nx) * phi_f14;
dest->zx = (-nx) * phi_f12;
dest->xy = nx;
dest->yy = ny;
dest->yz = nz;
dest->zx = 0.0f;
dest->zy = -phi_f12;
dest->zy = nz;
dest->xz = 0.0f;
dest->yz = -phi_f12;
dest->zz = phi_f14;
dest->wx = tx;
dest->wy = ty;
dest->wz = tz;
dest->xw = 0.0f;
dest->yw = 0.0f;
dest->zw = 0.0f;
dest->xw = tx;
dest->yw = ty;
dest->zw = tz;
dest->wx = 0.0f;
dest->wy = 0.0f;
dest->wz = 0.0f;
dest->ww = 1.0f;
}
+2 -2
View File
@@ -3691,7 +3691,7 @@ void Collider_UpdateSpheres(s32 limb, ColliderJntSph* collider) {
D_801EE1C0.x = collider->elements[i].dim.modelSphere.center.x;
D_801EE1C0.y = collider->elements[i].dim.modelSphere.center.y;
D_801EE1C0.z = collider->elements[i].dim.modelSphere.center.z;
Matrix_MultiplyVector3fByState(&D_801EE1C0, &D_801EE1D0);
Matrix_MultVec3f(&D_801EE1C0, &D_801EE1D0);
collider->elements[i].dim.worldSphere.center.x = D_801EE1D0.x;
collider->elements[i].dim.worldSphere.center.y = D_801EE1D0.y;
collider->elements[i].dim.worldSphere.center.z = D_801EE1D0.z;
@@ -3733,7 +3733,7 @@ void Collider_UpdateSphere(s32 limb, ColliderSphere* collider) {
D_801EE1E0.x = collider->dim.modelSphere.center.x;
D_801EE1E0.y = collider->dim.modelSphere.center.y;
D_801EE1E0.z = collider->dim.modelSphere.center.z;
Matrix_MultiplyVector3fByState(&D_801EE1E0, &D_801EE1F0);
Matrix_MultVec3f(&D_801EE1E0, &D_801EE1F0);
collider->dim.worldSphere.center.x = D_801EE1F0.x;
collider->dim.worldSphere.center.y = D_801EE1F0.y;
collider->dim.worldSphere.center.z = D_801EE1F0.z;
+4 -4
View File
@@ -68,10 +68,10 @@ void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, GlobalCo
func_8012C6FC(globalCtx->state.gfxCtx);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, dispObj->color.r, dispObj->color.g, dispObj->color.b, dispObj->color.a);
Matrix_InsertTranslation(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, MTXMODE_NEW);
Matrix_Translate(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, MTXMODE_NEW);
Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, MTXMODE_APPLY);
Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY);
Matrix_InsertRotation(dispObj->rot.x, dispObj->rot.y, dispObj->rot.z, MTXMODE_APPLY);
Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY);
Matrix_RotateZYX(dispObj->rot.x, dispObj->rot.y, dispObj->rot.z, MTXMODE_APPLY);
gDPLoadTextureBlock(POLY_XLU_DISP++, texture, G_IM_FMT_I, G_IM_SIZ_8b, 16, 16, 0, G_TX_NOMIRROR | G_TX_WRAP,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
@@ -94,7 +94,7 @@ void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* arg1, GlobalContex
gSPSetLights1(POLY_XLU_DISP++, sDebugDisplayLight1);
Matrix_SetStateRotationAndTranslation(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, &dispObj->rot);
Matrix_SetTranslateRotateYXZ(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, &dispObj->rot);
Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+1 -1
View File
@@ -106,7 +106,7 @@ void EffFootmark_Draw(GlobalContext* globalCtx) {
for (footmark = globalCtx->footprintInfo, i = 0; i < 100; i++, footmark++) {
if (footmark->actor != NULL) {
Matrix_SetCurrentState(&footmark->displayMatrix);
Matrix_Put(&footmark->displayMatrix);
Matrix_Scale(footmark->size * (1.0f / 0x100) * 0.7f, 1, footmark->size * (1.0f / 0x100), MTXMODE_APPLY);
gSPMatrix(gfxCtx->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD);
+3 -3
View File
@@ -104,7 +104,7 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve*
OPEN_DISPS(globalCtx->state.gfxCtx);
Matrix_StatePush();
Matrix_Push();
if (overrideLimbDraw == NULL ||
(overrideLimbDraw != NULL && overrideLimbDraw(globalCtx, skelCurve, limbIndex, thisx))) {
@@ -126,7 +126,7 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve*
pos.y = transform->y;
pos.z = transform->z;
Matrix_JointPosition(&pos, &rot);
Matrix_TranslateRotateZYX(&pos, &rot);
Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY);
if (lod == 0) {
@@ -164,7 +164,7 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve*
SkelCurve_DrawLimb(globalCtx, limb->firstChildIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx);
}
Matrix_StatePop();
Matrix_Pop();
if (limb->nextLimbIdx != LIMB_DONE) {
SkelCurve_DrawLimb(globalCtx, limb->nextLimbIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx);
+1 -1
View File
@@ -159,7 +159,7 @@ void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) {
vec.x = 0;
vec.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000;
vec.z = 0;
Matrix_SetStateRotationAndTranslation(fire->position.x, fire->position.y, fire->position.z, &vec);
Matrix_SetTranslateRotateYXZ(fire->position.x, fire->position.y, fire->position.z, &vec);
Matrix_Scale(fire->xScale, fire->yScale, 1.0f, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);

Some files were not shown because too many files have changed in this diff Show More