summaryrefslogtreecommitdiff
path: root/src/racing/math_util.c
diff options
context:
space:
mode:
authorMatthew <25674682+spazzylemons@users.noreply.github.com>2024-03-04 13:03:41 -0500
committerGitHub <noreply@github.com>2024-03-04 11:03:41 -0700
commit0ac8284fb26ddafcff799fa1011d8b3a7bdeb558 (patch)
tree557b5d27f50366ec86c77b39637e3c6cf6e11461 /src/racing/math_util.c
parent18e7c8939b202006e054f25924524447896f61f3 (diff)
Match func_802B5B14 (#581)
* Match func_802B5B14
Diffstat (limited to 'src/racing/math_util.c')
-rw-r--r--src/racing/math_util.c85
1 files changed, 31 insertions, 54 deletions
diff --git a/src/racing/math_util.c b/src/racing/math_util.c
index c4b6e3169..aef024671 100644
--- a/src/racing/math_util.c
+++ b/src/racing/math_util.c
@@ -372,61 +372,38 @@ void mtxf_s16_rotate_z(Mat4 mat, s16 angle) {
*/
}
-#ifdef MIPS_TO_C
-//generated by m2c commit beb457dabfc7a01ec6540a5404a6a05097a13602 on Oct-29-2023
-void func_802B5B14(f32 *arg0, s16 *arg1) {
- f32 sp70;
- f32 sp6C;
- f32 sp68;
- f32 sp60;
- f32 sp5C;
- f32 sp58;
- f32 sp50;
- f32 sp4C;
- f32 sp48;
- f32 sp40;
- f32 sp3C;
- f32 sp38;
- f32 sp30;
- f32 sp2C;
- f32 sp28;
- f32 temp_f0;
- f32 temp_f10;
- f32 temp_f12;
- f32 temp_f18;
- f32 temp_f20;
- f32 temp_f4;
- f32 temp_f6;
-
- sp38 = sins((u16) arg1->unk0);
- temp_f20 = coss((u16) arg1->unk0);
- sp30 = sins(arg1->unk2);
- sp2C = coss(arg1->unk2);
- sp28 = sins(arg1->unk4);
- temp_f0 = coss(arg1->unk4);
- temp_f4 = arg0->unk0;
- temp_f12 = sp38 * sp30;
- sp3C = temp_f4;
- sp40 = arg0->unk4;
- temp_f6 = (sp2C * temp_f0) + (temp_f12 * sp28);
- sp48 = temp_f6;
- sp58 = (-sp2C * sp28) + (temp_f12 * temp_f0);
- sp68 = temp_f20 * sp30;
- sp4C = temp_f20 * sp28;
- temp_f18 = sp38 * sp2C;
- sp5C = temp_f20 * temp_f0;
- sp6C = -sp38;
- temp_f10 = (-sp30 * temp_f0) + (temp_f18 * sp28);
- sp50 = temp_f10;
- sp60 = (sp30 * sp28) + (temp_f18 * temp_f0);
- sp70 = temp_f20 * sp2C;
- arg0->unk0 = (temp_f10 * sp40) + ((temp_f4 * temp_f6) + (sp40 * sp4C));
- arg0->unk4 = (f32) ((sp60 * sp40) + ((temp_f4 * sp58) + (sp40 * sp5C)));
- arg0->unk8 = (f32) ((sp70 * sp40) + ((sp3C * sp68) + (sp40 * sp6C)));
+void func_802B5B14(Vec3f b, Vec3s rotate) {
+ Mat4 mtx;
+ Vec3f copy;
+
+ f32 sx = sins(rotate[0]);
+ f32 cx = coss(rotate[0]);
+
+ f32 sy = sins(rotate[1]);
+ f32 cy = coss(rotate[1]);
+
+ f32 sz = sins(rotate[2]);
+ f32 cz = coss(rotate[2]);
+
+ copy[0] = b[0];
+ copy[1] = b[1];
+
+ mtx[0][0] = cy * cz + sx * sy * sz;
+ mtx[1][0] = -cy * sz + sx * sy * cz;
+ mtx[2][0] = cx * sy;
+
+ mtx[0][1] = cx * sz;
+ mtx[1][1] = cx * cz;
+ mtx[2][1] = -sx;
+
+ mtx[0][2] = -sy * cz + sx * cy * sz;
+ mtx[1][2] = sy * sz + sx * cy * cz;
+ mtx[2][2] = cx * cy;
+
+ b[0] = copy[0] * mtx[0][0] + copy[1] * mtx[0][1] + copy[1] * mtx[0][2];
+ b[1] = copy[0] * mtx[1][0] + copy[1] * mtx[1][1] + copy[1] * mtx[1][2];
+ b[2] = copy[0] * mtx[2][0] + copy[1] * mtx[2][1] + copy[1] * mtx[2][2];
}
-#else
-GLOBAL_ASM("asm/non_matchings/racing/math_util/func_802B5B14.s")
-#endif
void func_802B5CAC(s16 arg0, s16 arg1, Vec3f arg2) {
f32 sp2C = sins(arg1);