From 669b5459489a8ca562f1a341a3b0725f2adec746 Mon Sep 17 00:00:00 2001 From: Jed Grabman Date: Mon, 23 Jun 2025 12:39:33 -0400 Subject: [PATCH] Make format check Formatting updates suggested by make format --- src/actors/banana/render.inc.c | 4 +- src/actors/fake_item_box/render.inc.c | 2 +- src/actors/falling_rock/render.inc.c | 2 +- src/actors/item_box/render.inc.c | 2 +- src/actors/paddle_boat/render.inc.c | 4 +- src/actors/railroad_crossing/render.inc.c | 2 +- src/actors/tanker_truck/render.inc.c | 2 +- src/actors/train/render.inc.c | 6 +- src/actors/trees/render.inc.c | 4 +- src/actors/wario_sign/render.inc.c | 3 +- src/actors/yoshi_egg/render.inc.c | 2 +- src/racing/actors.c | 8 +- src/racing/math_util.c | 214 +++++++++++----------- src/racing/math_util.h | 8 +- src/racing/skybox_and_splitscreen.c | 6 +- 15 files changed, 133 insertions(+), 136 deletions(-) diff --git a/src/actors/banana/render.inc.c b/src/actors/banana/render.inc.c index f56e1e2da..ef8abb19a 100644 --- a/src/actors/banana/render.inc.c +++ b/src/actors/banana/render.inc.c @@ -15,8 +15,8 @@ void render_actor_banana(Camera* camera, UNUSED Mat4 arg1, struct BananaActor* b Vec3s sp7C; Mat4 sp3C; - f32 temp = render_distance_squared(camera->pos, banana->pos, camera->rot[1], 0, gCameraZoom[camera - camera1], - 490000.0f); + f32 temp = + render_distance_squared(camera->pos, banana->pos, camera->rot[1], 0, gCameraZoom[camera - camera1], 490000.0f); if (temp < 0.0f) { actor_not_rendered(camera, (struct Actor*) banana); return; diff --git a/src/actors/fake_item_box/render.inc.c b/src/actors/fake_item_box/render.inc.c index 7f0865c7b..15e8118c7 100644 --- a/src/actors/fake_item_box/render.inc.c +++ b/src/actors/fake_item_box/render.inc.c @@ -25,7 +25,7 @@ void render_actor_fake_item_box(Camera* camera, struct FakeItemBox* fakeItemBox) f32 someMultiplier; if (render_distance_squared(camera->pos, fakeItemBox->pos, camera->rot[1], 2500.0f, gCameraZoom[camera - camera1], - 1000000.0f) < 0) { + 1000000.0f) < 0) { actor_not_rendered(camera, (struct Actor*) fakeItemBox); return; } diff --git a/src/actors/falling_rock/render.inc.c b/src/actors/falling_rock/render.inc.c index b020207f6..ba94bb2e8 100644 --- a/src/actors/falling_rock/render.inc.c +++ b/src/actors/falling_rock/render.inc.c @@ -21,7 +21,7 @@ void render_actor_falling_rock(Camera* camera, struct FallingRock* rock) { } height = render_distance_squared(camera->pos, rock->pos, camera->rot[1], 400.0f, gCameraZoom[camera - camera1], - 4000000.0f); + 4000000.0f); if (height < 0.0f) { return; diff --git a/src/actors/item_box/render.inc.c b/src/actors/item_box/render.inc.c index dd387fa7b..17cbbcda0 100644 --- a/src/actors/item_box/render.inc.c +++ b/src/actors/item_box/render.inc.c @@ -27,7 +27,7 @@ void render_actor_item_box(Camera* camera, struct ItemBox* item_box) { f32 someMultiplier; temp_f0 = render_distance_squared(camera->pos, item_box->pos, camera->rot[1], 0.0f, gCameraZoom[camera - camera1], - 4000000.0f); + 4000000.0f); if (!(temp_f0 < 0.0f) && !(600000.0f < temp_f0)) { if ((item_box->state == 2) && (temp_f0 < 100000.0f)) { someRot[0] = 0; diff --git a/src/actors/paddle_boat/render.inc.c b/src/actors/paddle_boat/render.inc.c index dc36215eb..2eb0223b4 100644 --- a/src/actors/paddle_boat/render.inc.c +++ b/src/actors/paddle_boat/render.inc.c @@ -28,8 +28,8 @@ void render_actor_paddle_boat(Camera* arg0, struct PaddleWheelBoat* boat, UNUSED return; } - temp = render_distance_squared(arg0->pos, boat->pos, arg0->rot[1], 90000.0f, gCameraZoom[arg0 - camera1], - 9000000.0f); + temp = + render_distance_squared(arg0->pos, boat->pos, arg0->rot[1], 90000.0f, gCameraZoom[arg0 - camera1], 9000000.0f); if (temp < 0.0f) { return; diff --git a/src/actors/railroad_crossing/render.inc.c b/src/actors/railroad_crossing/render.inc.c index 4420dbe80..be0af549a 100644 --- a/src/actors/railroad_crossing/render.inc.c +++ b/src/actors/railroad_crossing/render.inc.c @@ -14,7 +14,7 @@ void render_actor_railroad_crossing(Camera* arg0, struct RailroadCrossing* rr_cr UNUSED Vec3s sp80 = { 0, 0, 0 }; Mat4 sp40; f32 unk = render_distance_squared(arg0->pos, rr_crossing->pos, arg0->rot[1], 0.0f, gCameraZoom[arg0 - camera1], - 4000000.0f); + 4000000.0f); if (!(unk < 0.0f)) { mtxf_rotation_zxy_translate(sp40, rr_crossing->pos, rr_crossing->rot); diff --git a/src/actors/tanker_truck/render.inc.c b/src/actors/tanker_truck/render.inc.c index 23c2639b1..c16564207 100644 --- a/src/actors/tanker_truck/render.inc.c +++ b/src/actors/tanker_truck/render.inc.c @@ -15,7 +15,7 @@ void render_actor_tanker_truck(Camera* camera, struct Actor* arg1) { Mat4 spC8; UNUSED s32 pad2[32]; f32 temp_f0 = render_distance_squared(camera->pos, arg1->pos, camera->rot[1], 2500.0f, - gCameraZoom[camera - camera1], 9000000.0f); + gCameraZoom[camera - camera1], 9000000.0f); if (!(temp_f0 < 0.0f)) { diff --git a/src/actors/train/render.inc.c b/src/actors/train/render.inc.c index 8cbc8d7d1..86f4a6ce2 100644 --- a/src/actors/train/render.inc.c +++ b/src/actors/train/render.inc.c @@ -20,7 +20,7 @@ void render_actor_train_engine(Camera* camera, struct TrainCar* actor) { Mat4 spA0; f32 distance = render_distance_squared(camera->pos, actor->pos, camera->rot[1], 2500.0f, - gCameraZoom[camera - camera1], 9000000.0f); + gCameraZoom[camera - camera1], 9000000.0f); if (distance < 0.0f) { return; @@ -167,7 +167,7 @@ void render_actor_train_tender(Camera* camera, struct TrainCar* actor) { Mat4 spA0; f32 temp_f0 = render_distance_squared(camera->pos, actor->pos, camera->rot[1], 625.0f, - gCameraZoom[camera - camera1], 9000000.0f); + gCameraZoom[camera - camera1], 9000000.0f); if (temp_f0 < 0.0f) { return; @@ -252,7 +252,7 @@ void render_actor_train_passenger_car(Camera* camera, struct TrainCar* actor) { Mat4 spA0; f32 temp_f0 = render_distance_squared(camera->pos, actor->pos, camera->rot[1], 2025.0f, - gCameraZoom[camera - camera1], 9000000.0f); + gCameraZoom[camera - camera1], 9000000.0f); if (temp_f0 < 0.0f) { return; diff --git a/src/actors/trees/render.inc.c b/src/actors/trees/render.inc.c index 223fc2439..28b6ac7da 100644 --- a/src/actors/trees/render.inc.c +++ b/src/actors/trees/render.inc.c @@ -19,8 +19,8 @@ void render_actor_tree_mario_raceway(Camera* camera, Mat4 arg1, struct Actor* ar return; } - temp_f0 = render_distance_squared(camera->pos, arg2->pos, camera->rot[1], 0, gCameraZoom[camera - camera1], - 16000000.0f); + temp_f0 = + render_distance_squared(camera->pos, arg2->pos, camera->rot[1], 0, gCameraZoom[camera - camera1], 16000000.0f); if (temp_f0 < 0.0f) { return; diff --git a/src/actors/wario_sign/render.inc.c b/src/actors/wario_sign/render.inc.c index 78fc246d0..1a9c37295 100644 --- a/src/actors/wario_sign/render.inc.c +++ b/src/actors/wario_sign/render.inc.c @@ -12,8 +12,7 @@ */ void render_actor_wario_sign(Camera* arg0, struct Actor* arg1) { Mat4 sp38; - f32 unk = - render_distance_squared(arg0->pos, arg1->pos, arg0->rot[1], 0, gCameraZoom[arg0 - camera1], 16000000.0f); + f32 unk = render_distance_squared(arg0->pos, arg1->pos, arg0->rot[1], 0, gCameraZoom[arg0 - camera1], 16000000.0f); if (!(unk < 0.0f)) { gSPSetGeometryMode(gDisplayListHead++, G_SHADING_SMOOTH); diff --git a/src/actors/yoshi_egg/render.inc.c b/src/actors/yoshi_egg/render.inc.c index e07cae885..b7acefb1b 100644 --- a/src/actors/yoshi_egg/render.inc.c +++ b/src/actors/yoshi_egg/render.inc.c @@ -21,7 +21,7 @@ void render_actor_yoshi_egg(Camera* arg0, Mat4 arg1, struct YoshiValleyEgg* egg, if (gGamestate != CREDITS_SEQUENCE) { temp_f0 = render_distance_squared(arg0->pos, egg->pos, arg0->rot[1], 200.0f, gCameraZoom[arg0 - camera1], - 16000000.0f); + 16000000.0f); if (temp_f0 < 0.0f) { return; } diff --git a/src/racing/actors.c b/src/racing/actors.c index 360e7e26b..2dcf614b4 100644 --- a/src/racing/actors.c +++ b/src/racing/actors.c @@ -489,8 +489,8 @@ void render_cows(Camera* camera, Mat4 arg1, UNUSED struct Actor* actor) { sp88[0] = var_s1->pos[0] * gCourseDirection; sp88[1] = var_s1->pos[1]; sp88[2] = var_s1->pos[2]; - temp_f0 = render_distance_squared(camera->pos, sp88, camera->rot[1], 0.0f, gCameraZoom[camera - camera1], - 4000000.0f); + temp_f0 = + render_distance_squared(camera->pos, sp88, camera->rot[1], 0.0f, gCameraZoom[camera - camera1], 4000000.0f); if (temp_f0 > 0.0f) { if (temp_f0 < D_8015F704) { D_8015F704 = temp_f0; @@ -755,8 +755,8 @@ UNUSED void func_8029ABD4(f32* pos, s16 state) { } void func_8029AC18(Camera* camera, Mat4 arg1, struct Actor* arg2) { - if (render_distance_squared(camera->pos, arg2->pos, camera->rot[1], 0, gCameraZoom[camera - camera1], - 4000000.0f) < 0) { + if (render_distance_squared(camera->pos, arg2->pos, camera->rot[1], 0, gCameraZoom[camera - camera1], 4000000.0f) < + 0) { return; } diff --git a/src/racing/math_util.c b/src/racing/math_util.c index 616a6d5df..b9d004403 100644 --- a/src/racing/math_util.c +++ b/src/racing/math_util.c @@ -71,11 +71,11 @@ s32 render_set_position(Mat4 mtx, s32 mode) { } /* -* @brief Finds the squared distance between two points, but contains a bug when handling the z-axis -* @param from A point in 3D space -* @param to A point in 3D space -* @return Roughly the squared distance between from and to. (x**2 + y**2 + 2*z) instead of (x**2 + y**2 + z**2) -*/ + * @brief Finds the squared distance between two points, but contains a bug when handling the z-axis + * @param from A point in 3D space + * @param to A point in 3D space + * @return Roughly the squared distance between from and to. (x**2 + y**2 + 2*z) instead of (x**2 + y**2 + z**2) + */ f32 dist_squared_bugged(Vec3f from, Vec3f to) { f32 deltaY; f32 deltaZ; @@ -89,11 +89,11 @@ f32 dist_squared_bugged(Vec3f from, Vec3f to) { } /* -* @brief Finds the angle within the XZ-plane between two points (while ignoring any difference in Y) -* @param pointFrom A point in 3D space -* @param pointTo A point in 3D space -* @return Angle (N64-units) in XZ-plane between pointFrom and pointTo -*/ + * @brief Finds the angle within the XZ-plane between two points (while ignoring any difference in Y) + * @param pointFrom A point in 3D space + * @param pointTo A point in 3D space + * @return Angle (N64-units) in XZ-plane between pointFrom and pointTo + */ s32 get_xz_angle_between_points(Vec3f pointFrom, Vec3f pointTo) { f32 deltaX; f32 deltaZ; @@ -114,12 +114,12 @@ UNUSED u32 func_802B5258(Vec3f arg0, Vec3s arg1) { } /* -* @brief sets a vector to the given coordinates -* @param dest The vector to be overriden -* @param coordX The X coordinate of the desired vector -* @param coordY The Y coordinate of the desired vector -* @param coordZ The Z coordinate of the desired vector -*/ + * @brief sets a vector to the given coordinates + * @param dest The vector to be overriden + * @param coordX The X coordinate of the desired vector + * @param coordY The Y coordinate of the desired vector + * @param coordZ The Z coordinate of the desired vector + */ void vec3f_set(Vec3f dest, f32 coordX, f32 coordY, f32 coordZ) { dest[0] = coordX; dest[1] = coordY; @@ -127,12 +127,12 @@ void vec3f_set(Vec3f dest, f32 coordX, f32 coordY, f32 coordZ) { } /* -* @brief sets a vector to the given coordinates -* @param dest The vector to be overriden -* @param coordX The X coordinate of the desired vector -* @param coordY The Y coordinate of the desired vector -* @param coordZ The Z coordinate of the desired vector -*/ + * @brief sets a vector to the given coordinates + * @param dest The vector to be overriden + * @param coordX The X coordinate of the desired vector + * @param coordY The Y coordinate of the desired vector + * @param coordZ The Z coordinate of the desired vector + */ void vec3s_set(Vec3s dest, s16 coordX, s16 coordY, s16 coordZ) { dest[0] = coordX; dest[1] = coordY; @@ -152,11 +152,11 @@ void vec3s_set(Vec3s dest, s16 coordX, s16 coordY, s16 coordZ) { #endif /* -* @brief Copies the coordinates of a vector to another vector -* @param dest The vector to be overriden -* @param src The vector to be copied -* @return local address of destination vector -*/ + * @brief Copies the coordinates of a vector to another vector + * @param dest The vector to be overriden + * @param src The vector to be copied + * @return local address of destination vector + */ void* vec3f_copy_return(Vec3f dest, Vec3f src) { dest[0] = src[0]; dest[1] = src[1]; @@ -166,10 +166,10 @@ void* vec3f_copy_return(Vec3f dest, Vec3f src) { } /* -* @brief copies the coordinates of a vector to another vector -* @param dest The vector to be overriden -* @param src The vector to be copied -*/ + * @brief copies the coordinates of a vector to another vector + * @param dest The vector to be overriden + * @param src The vector to be copied + */ void vec3s_copy(Vec3s dest, Vec3s src) { dest[0] = src[0]; dest[1] = src[1]; @@ -184,10 +184,10 @@ UNUSED void* vec3f_set_return(Vec3f dest, f32 x, f32 y, f32 z) { } /* -* @brief copies the values of a matrix to another matrix -* @param src The matrix to be copied -* @param dest The matrix to be overriden -*/ + * @brief copies the values of a matrix to another matrix + * @param src The matrix to be copied + * @param dest The matrix to be overriden + */ void mtxf_copy(Mat4 src, Mat4 dest) { s32 row; s32 column; @@ -200,21 +200,21 @@ void mtxf_copy(Mat4 src, Mat4 dest) { } /* -* @brief copies the first n values of a matrix to another matrix -* @param dest The matrix to be overriden -* @param src The matrix to be copied -* @param n The number of values to be copied -*/ + * @brief copies the first n values of a matrix to another matrix + * @param dest The matrix to be overriden + * @param src The matrix to be copied + * @param n The number of values to be copied + */ void mtxf_copy_n_element(s32* dest, s32* src, s32 n) { while (n-- > 0) { *dest++ = *src++; } } -/* -* @brief Transform a matrix to an identity matrix -* @param Matrix The matrix to be changed to an identity matrix -*/ +/* + * @brief Transform a matrix to an identity matrix + * @param Matrix The matrix to be changed to an identity matrix + */ void mtxf_identity(Mat4 mtx) { register s32 row; register s32 col; @@ -227,11 +227,11 @@ void mtxf_identity(Mat4 mtx) { } /* -* @brief Add a translation vector to a matrix -* @param scr The matrix to be copied -* @param dest The matrix to be overriden with the result -* @param vecTrans The translation vector to be added -*/ + * @brief Add a translation vector to a matrix + * @param scr The matrix to be copied + * @param dest The matrix to be overriden with the result + * @param vecTrans The translation vector to be added + */ void add_translate_mat4_vec3f(Mat4 src, Mat4 dest, Vec3f vecTrans) { dest[3][0] = src[3][0] + vecTrans[0]; dest[3][1] = src[3][1] + vecTrans[1]; @@ -266,10 +266,10 @@ UNUSED void add_translate_mat4_vec3f_lite(Mat4 mat, Mat4 dest, Vec3f pos) { } /* -* @brief Creates a translation matrix -* @param dest The matrix to be overriden with the translation matrix -* @param vecTrans The translation vector to be added -*/ + * @brief Creates a translation matrix + * @param dest The matrix to be overriden with the translation matrix + * @param vecTrans The translation vector to be added + */ void mtxf_translate(Mat4 dest, Vec3f vecTrans) { mtxf_identity(dest); dest[3][0] = vecTrans[0]; @@ -292,8 +292,7 @@ void mtxf_translate(Mat4 dest, Vec3f vecTrans) { * @param homogeneousScale Scaling factor for homogeneous coordinates. Always 1.0 in game * Note the use of `2` which generates diff asm than just using floats (2.0f). */ -void mtxf_projection(Mat4 projMtx, u16* arg1, f32 vertFov, f32 aspectRatio, f32 near, f32 far, - f32 homogeneousScale) { +void mtxf_projection(Mat4 projMtx, u16* arg1, f32 vertFov, f32 aspectRatio, f32 near, f32 far, f32 homogeneousScale) { f32 halfCot; s32 rowIdx, colIdx; mtxf_identity(projMtx); @@ -406,7 +405,6 @@ void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to) { mtx[3][3] = 1.0f; } - /* * @brief Create a rotation matrix for rotating about the X axis * @param mtx Dummy matrix overwritten with x-axis rotation matrix @@ -509,7 +507,7 @@ UNUSED void func_802B5B14(Vec3f b, Vec3s rotate) { b[2] = copy[0] * mtx[2][0] + copy[1] * mtx[2][1] + copy[1] * mtx[2][2]; } - // rotates (0, 0, -1) about the x and y axis, in that order +// rotates (0, 0, -1) about the x and y axis, in that order void vec_unit_z_rotX_rotY(s16 rotY, s16 rotX, Vec3f arg2) { f32 sinX = sins(rotX); f32 cosX = coss(rotX); @@ -520,7 +518,6 @@ void vec_unit_z_rotX_rotY(s16 rotY, s16 rotX, Vec3f arg2) { arg2[1] = sinX; arg2[2] = -(cosX * cosY); // (0, 0, -1) -> (0, sinX, -cosX) -> (cosX * sinY, sinX, -(cosX * cosY)) - } UNUSED void func_802B5D30(s16 arg0, s16 arg1, s32 arg2) { @@ -602,7 +599,7 @@ void mtxf_rotation_zxy_translate(Mat4 dest, Vec3f vecTrans, Vec3s orientation) { cosY = coss(orientation[1]); sinZ = sins(orientation[2]); cosZ = coss(orientation[2]); - dest[0][0] = (cosY * cosZ) + ((sinX * sinY) * sinZ); + dest[0][0] = (cosY * cosZ) + ((sinX * sinY) * sinZ); dest[1][0] = (-cosY * sinZ) + ((sinX * sinY) * cosZ); dest[2][0] = cosX * sinY; dest[3][0] = vecTrans[0]; @@ -611,7 +608,7 @@ void mtxf_rotation_zxy_translate(Mat4 dest, Vec3f vecTrans, Vec3s orientation) { dest[2][1] = -sinX; dest[3][1] = vecTrans[1]; dest[0][2] = (-sinY * cosZ) + ((sinX * cosY) * sinZ); - dest[1][2] = (sinY * sinZ) + ((sinX * cosY) * cosZ); + dest[1][2] = (sinY * sinZ) + ((sinX * cosY) * cosZ); dest[2][2] = cosX * cosY; dest[3][2] = vecTrans[2]; dest[0][3] = 0.0f; @@ -619,7 +616,7 @@ void mtxf_rotation_zxy_translate(Mat4 dest, Vec3f vecTrans, Vec3s orientation) { dest[2][3] = 0.0f; dest[3][3] = 1.0f; } -//Product of Z, X and Y rotation matrices and a translation matrix +// Product of Z, X and Y rotation matrices and a translation matrix /* | Cz Sz 0 0|| 1 0 0 0|| Cy 0 -Sy 0|| 1 0 0 0| |-Sz Cz 0 0|| 0 Cx Sx 0|| 0 1 0 0|| 0 1 0 0| | 0 0 1 0|| 0 -Sx Cx 0|| Sy 0 Cy 0|| 0 0 1 0| @@ -745,7 +742,7 @@ UNUSED void func_802B64B0(UNUSED s32 arg0, UNUSED s32 arg1, UNUSED s32 arg2, UNU /* * @brief rotates a given vector about the Y axis by amount specified * @param vec Vector to rotate - * @param angle + * @param angle */ void vec3f_rotate_y(Vec3f vec, s16 rotAngleY) { f32 sinAngleY = sins(rotAngleY); @@ -760,13 +757,13 @@ void vec3f_rotate_y(Vec3f vec, s16 rotAngleY) { vec[2] = sinAngleY * vecX + (cosAngleY * vecZ); } // Standard Y-axis rotation matrix multiplication -/* |Cy 0 -Sy||Vx| +/* |Cy 0 -Sy||Vx| * | 0 1 0||Vy| = |CyVx - SyVz, Vy, SyVx + CyVz| * |Sy 0 Cy||Vz| */ /* If cosAxisY is 1, this is just rotating around the Y axis, like in mtxf_rotate_y. Otherwise, - it intends to rotate about any axis by composing with a rotation matrix for an XZ axis rotation. + it intends to rotate about any axis by composing with a rotation matrix for an XZ axis rotation. However, if Y is not 1 or -1, angle calculations break. It looks like cosAxisY might always be 1, but that is not completely confirmed. */ @@ -822,14 +819,15 @@ void calculate_orientation_matrix(Mat3 dest, f32 axisZ, f32 cosAxisY, f32 axisX, } else { /* This looks like it is meant to convert from radians to degrees, but acos1f returns N64-units, not radians - suggesting this is never used because it would give wildly incorrect values. Not sure this ever actually gets + suggesting this is never used because it would give wildly incorrect values. Not sure this ever actually gets called because cosAxisY is usually 1*/ a = (f32) - (360.0 - ((f64) (acos1f(cosAxisY) * 180.0f) / M_PI)); axisNormedX = -axisX / sqrtf((axisZ * axisZ) + (axisX * axisX)); axisNormedZ = axisZ / sqrtf((axisZ * axisZ) + (axisX * axisX)); - calculate_rotation_matrix(mtxRotXZ, a, axisNormedX, 0, axisNormedZ); // rotates around something in the x-z plane + calculate_rotation_matrix(mtxRotXZ, a, axisNormedX, 0, + axisNormedZ); // rotates around something in the x-z plane } - //mtxRotY * matrixRotXZ + // mtxRotY * matrixRotXZ dest[0][0] = (mtxRotY[0][0] * mtxRotXZ[0][0]) + (mtxRotY[0][1] * mtxRotXZ[1][0]) + (mtxRotY[0][2] * mtxRotXZ[2][0]); dest[1][0] = (mtxRotY[1][0] * mtxRotXZ[0][0]) + (mtxRotY[1][1] * mtxRotXZ[1][0]) + (mtxRotY[1][2] * mtxRotXZ[2][0]); dest[2][0] = (mtxRotY[2][0] * mtxRotXZ[0][0]) + (mtxRotY[2][1] * mtxRotXZ[1][0]) + (mtxRotY[2][2] * mtxRotXZ[2][0]); @@ -882,7 +880,7 @@ UNUSED void func_802B68F8(Mat3 matrix, f32 arg1, f32 arg2, f32 arg3) { * @param axisY The Y component of the axis to rotate around * @param axisZ The Z component of the axis to rotate around */ - // Standard algorithm, but unintuitive. "Rotation matrix from axis and angle" brings up info online +// Standard algorithm, but unintuitive. "Rotation matrix from axis and angle" brings up info online void calculate_rotation_matrix(Mat3 destMatrix, s16 rotationAngle, f32 axisX, f32 axisY, f32 axisZ) { f32 sinValue; f32 cosValue; @@ -995,38 +993,38 @@ UNUSED void func_802B6D58(Mat4 arg0, Vec3f arg1, Vec3f arg2) { */ void mtxf_multiplication(Mat4 dest, Mat4 mtxLeft, Mat4 mtxRight) { Mat4 product; - product[0][0] = - (mtxLeft[0][0] * mtxRight[0][0]) + (mtxLeft[0][1] * mtxRight[1][0]) + (mtxLeft[0][2] * mtxRight[2][0]) + (mtxLeft[0][3] * mtxRight[3][0]); - product[0][1] = - (mtxLeft[0][0] * mtxRight[0][1]) + (mtxLeft[0][1] * mtxRight[1][1]) + (mtxLeft[0][2] * mtxRight[2][1]) + (mtxLeft[0][3] * mtxRight[3][1]); - product[0][2] = - (mtxLeft[0][0] * mtxRight[0][2]) + (mtxLeft[0][1] * mtxRight[1][2]) + (mtxLeft[0][2] * mtxRight[2][2]) + (mtxLeft[0][3] * mtxRight[3][2]); - product[0][3] = - (mtxLeft[0][0] * mtxRight[0][3]) + (mtxLeft[0][1] * mtxRight[1][3]) + (mtxLeft[0][2] * mtxRight[2][3]) + (mtxLeft[0][3] * mtxRight[3][3]); - product[1][0] = - (mtxLeft[1][0] * mtxRight[0][0]) + (mtxLeft[1][1] * mtxRight[1][0]) + (mtxLeft[1][2] * mtxRight[2][0]) + (mtxLeft[1][3] * mtxRight[3][0]); - product[1][1] = - (mtxLeft[1][0] * mtxRight[0][1]) + (mtxLeft[1][1] * mtxRight[1][1]) + (mtxLeft[1][2] * mtxRight[2][1]) + (mtxLeft[1][3] * mtxRight[3][1]); - product[1][2] = - (mtxLeft[1][0] * mtxRight[0][2]) + (mtxLeft[1][1] * mtxRight[1][2]) + (mtxLeft[1][2] * mtxRight[2][2]) + (mtxLeft[1][3] * mtxRight[3][2]); - product[1][3] = - (mtxLeft[1][0] * mtxRight[0][3]) + (mtxLeft[1][1] * mtxRight[1][3]) + (mtxLeft[1][2] * mtxRight[2][3]) + (mtxLeft[1][3] * mtxRight[3][3]); - product[2][0] = - (mtxLeft[2][0] * mtxRight[0][0]) + (mtxLeft[2][1] * mtxRight[1][0]) + (mtxLeft[2][2] * mtxRight[2][0]) + (mtxLeft[2][3] * mtxRight[3][0]); - product[2][1] = - (mtxLeft[2][0] * mtxRight[0][1]) + (mtxLeft[2][1] * mtxRight[1][1]) + (mtxLeft[2][2] * mtxRight[2][1]) + (mtxLeft[2][3] * mtxRight[3][1]); - product[2][2] = - (mtxLeft[2][0] * mtxRight[0][2]) + (mtxLeft[2][1] * mtxRight[1][2]) + (mtxLeft[2][2] * mtxRight[2][2]) + (mtxLeft[2][3] * mtxRight[3][2]); - product[2][3] = - (mtxLeft[2][0] * mtxRight[0][3]) + (mtxLeft[2][1] * mtxRight[1][3]) + (mtxLeft[2][2] * mtxRight[2][3]) + (mtxLeft[2][3] * mtxRight[3][3]); - product[3][0] = - (mtxLeft[3][0] * mtxRight[0][0]) + (mtxLeft[3][1] * mtxRight[1][0]) + (mtxLeft[3][2] * mtxRight[2][0]) + (mtxLeft[3][3] * mtxRight[3][0]); - product[3][1] = - (mtxLeft[3][0] * mtxRight[0][1]) + (mtxLeft[3][1] * mtxRight[1][1]) + (mtxLeft[3][2] * mtxRight[2][1]) + (mtxLeft[3][3] * mtxRight[3][1]); - product[3][2] = - (mtxLeft[3][0] * mtxRight[0][2]) + (mtxLeft[3][1] * mtxRight[1][2]) + (mtxLeft[3][2] * mtxRight[2][2]) + (mtxLeft[3][3] * mtxRight[3][2]); - product[3][3] = - (mtxLeft[3][0] * mtxRight[0][3]) + (mtxLeft[3][1] * mtxRight[1][3]) + (mtxLeft[3][2] * mtxRight[2][3]) + (mtxLeft[3][3] * mtxRight[3][3]); + product[0][0] = (mtxLeft[0][0] * mtxRight[0][0]) + (mtxLeft[0][1] * mtxRight[1][0]) + + (mtxLeft[0][2] * mtxRight[2][0]) + (mtxLeft[0][3] * mtxRight[3][0]); + product[0][1] = (mtxLeft[0][0] * mtxRight[0][1]) + (mtxLeft[0][1] * mtxRight[1][1]) + + (mtxLeft[0][2] * mtxRight[2][1]) + (mtxLeft[0][3] * mtxRight[3][1]); + product[0][2] = (mtxLeft[0][0] * mtxRight[0][2]) + (mtxLeft[0][1] * mtxRight[1][2]) + + (mtxLeft[0][2] * mtxRight[2][2]) + (mtxLeft[0][3] * mtxRight[3][2]); + product[0][3] = (mtxLeft[0][0] * mtxRight[0][3]) + (mtxLeft[0][1] * mtxRight[1][3]) + + (mtxLeft[0][2] * mtxRight[2][3]) + (mtxLeft[0][3] * mtxRight[3][3]); + product[1][0] = (mtxLeft[1][0] * mtxRight[0][0]) + (mtxLeft[1][1] * mtxRight[1][0]) + + (mtxLeft[1][2] * mtxRight[2][0]) + (mtxLeft[1][3] * mtxRight[3][0]); + product[1][1] = (mtxLeft[1][0] * mtxRight[0][1]) + (mtxLeft[1][1] * mtxRight[1][1]) + + (mtxLeft[1][2] * mtxRight[2][1]) + (mtxLeft[1][3] * mtxRight[3][1]); + product[1][2] = (mtxLeft[1][0] * mtxRight[0][2]) + (mtxLeft[1][1] * mtxRight[1][2]) + + (mtxLeft[1][2] * mtxRight[2][2]) + (mtxLeft[1][3] * mtxRight[3][2]); + product[1][3] = (mtxLeft[1][0] * mtxRight[0][3]) + (mtxLeft[1][1] * mtxRight[1][3]) + + (mtxLeft[1][2] * mtxRight[2][3]) + (mtxLeft[1][3] * mtxRight[3][3]); + product[2][0] = (mtxLeft[2][0] * mtxRight[0][0]) + (mtxLeft[2][1] * mtxRight[1][0]) + + (mtxLeft[2][2] * mtxRight[2][0]) + (mtxLeft[2][3] * mtxRight[3][0]); + product[2][1] = (mtxLeft[2][0] * mtxRight[0][1]) + (mtxLeft[2][1] * mtxRight[1][1]) + + (mtxLeft[2][2] * mtxRight[2][1]) + (mtxLeft[2][3] * mtxRight[3][1]); + product[2][2] = (mtxLeft[2][0] * mtxRight[0][2]) + (mtxLeft[2][1] * mtxRight[1][2]) + + (mtxLeft[2][2] * mtxRight[2][2]) + (mtxLeft[2][3] * mtxRight[3][2]); + product[2][3] = (mtxLeft[2][0] * mtxRight[0][3]) + (mtxLeft[2][1] * mtxRight[1][3]) + + (mtxLeft[2][2] * mtxRight[2][3]) + (mtxLeft[2][3] * mtxRight[3][3]); + product[3][0] = (mtxLeft[3][0] * mtxRight[0][0]) + (mtxLeft[3][1] * mtxRight[1][0]) + + (mtxLeft[3][2] * mtxRight[2][0]) + (mtxLeft[3][3] * mtxRight[3][0]); + product[3][1] = (mtxLeft[3][0] * mtxRight[0][1]) + (mtxLeft[3][1] * mtxRight[1][1]) + + (mtxLeft[3][2] * mtxRight[2][1]) + (mtxLeft[3][3] * mtxRight[3][1]); + product[3][2] = (mtxLeft[3][0] * mtxRight[0][2]) + (mtxLeft[3][1] * mtxRight[1][2]) + + (mtxLeft[3][2] * mtxRight[2][2]) + (mtxLeft[3][3] * mtxRight[3][2]); + product[3][3] = (mtxLeft[3][0] * mtxRight[0][3]) + (mtxLeft[3][1] * mtxRight[1][3]) + + (mtxLeft[3][2] * mtxRight[2][3]) + (mtxLeft[3][3] * mtxRight[3][3]); mtxf_copy_n_element((s32*) dest, (s32*) product, 16); } @@ -1214,10 +1212,10 @@ UNUSED void func_802B7C6C(f32 arg0) { s16 asin1s(f32 value) { return atan2s(value, sqrtf(1.0 - (value * value))); /* if value = sin(Angle), we have - = asin(sin(Angle) / sqrt(1 - sin**2(Angle))) - = atan(sin(Angle) / sqrt(cos**2(Angle))) - = atan(sin(Angle) / cos(Angle)) - = atan(tan(Angle)) + = asin(sin(Angle) / sqrt(1 - sin**2(Angle))) + = atan(sin(Angle) / sqrt(cos**2(Angle))) + = atan(sin(Angle) / cos(Angle)) + = atan(tan(Angle)) = Angle */ } @@ -1359,8 +1357,8 @@ s32 is_between_angle(u16 angleCCW, u16 angleCW, u16 angleToCheck) { * camera's vision, or -1.0f if it exceeds the render distance. */ -f32 render_distance_squared(Vec3f cameraPos, Vec3f objectPos, u16 orientationY, f32 preloadDistanceSquared, f32 fovDegrees, - f32 maxDistanceSquared) { +f32 render_distance_squared(Vec3f cameraPos, Vec3f objectPos, u16 orientationY, f32 preloadDistanceSquared, + f32 fovDegrees, f32 maxDistanceSquared) { u16 angleObject; UNUSED u16 pad; u16 preloadAngle; @@ -1371,7 +1369,7 @@ f32 render_distance_squared(Vec3f cameraPos, Vec3f objectPos, u16 orientationY, s32 minusFovAngle; u16 adjustedAngle; UNUSED s32 pad2[3]; - u16 fovUnits = ((u16) fovDegrees * 182); //degrees to angle units (182 * 360 ~= 2**16) + u16 fovUnits = ((u16) fovDegrees * 182); // degrees to angle units (182 * 360 ~= 2**16) distanceXSquared = objectPos[0] - cameraPos[0]; distanceXSquared = distanceXSquared * distanceXSquared; @@ -1409,7 +1407,7 @@ f32 render_distance_squared(Vec3f cameraPos, Vec3f objectPos, u16 orientationY, return distanceSquared; } - /* This is bugged. This gives asin((sin(theta)**2) instead of asin(sin(theta)) = theta. + /* This is bugged. This gives asin((sin(theta)**2) instead of asin(sin(theta)) = theta. Probably unnoticed because it only deals with objects not on screen*/ preloadAngle = asin1s(preloadDistanceSquared / distanceSquared); adjustedAngle = angleObject + preloadAngle; diff --git a/src/racing/math_util.h b/src/racing/math_util.h index bbef3eb3f..a4e052547 100644 --- a/src/racing/math_util.h +++ b/src/racing/math_util.h @@ -14,7 +14,7 @@ // Here to appease the pragma gods double fabs(double x); -void func_802B5794(Mat4, Vec3f, Vec3f); // Unused +void func_802B5794(Mat4, Vec3f, Vec3f); // Unused s32 func_802B4F60(s32, Vec3f, s32, f32, f32); // Unused s32 render_set_position(Mat4, s32); f32 dist_squared_bugged(Vec3f, Vec3f); @@ -37,8 +37,8 @@ void mtxf_rotate_x(Mat4, s16); void mtxf_rotate_y(Mat4, s16); void mtxf_s16_rotate_z(Mat4, s16); void func_802B5B14(Vec3f b, Vec3s rotate); // Unused -void func_802B5CAC(s16, s16, Vec3f); // Unused -void func_802B5D30(s16, s16, s32); // Unused +void func_802B5CAC(s16, s16, Vec3f); // Unused +void func_802B5D30(s16, s16, s32); // Unused void set_course_lighting(Lights1*, s16, s16, s32); void mtxf_scale(Mat4, f32); void mtxf_rotation_zxy_translate(Mat4, Vec3f, Vec3s); @@ -48,7 +48,7 @@ void vec3f_rotate_y(Vec3f, s16); void calculate_orientation_matrix(Mat3, f32, f32, f32, s16); void calculate_rotation_matrix(Mat3, s16, f32, f32, f32); void func_802B6BC0(Mat4, s16, f32, f32, f32); // Unused -void func_802B6D58(Mat4, Vec3f, Vec3f); // Unused +void func_802B6D58(Mat4, Vec3f, Vec3f); // Unused void mtxf_multiplication(Mat4, Mat4, Mat4); void mtxf_to_mtx(Mtx*, Mat4); u16 atan2_lookup(f32, f32); diff --git a/src/racing/skybox_and_splitscreen.c b/src/racing/skybox_and_splitscreen.c index 630a126ee..29ce4c478 100644 --- a/src/racing/skybox_and_splitscreen.c +++ b/src/racing/skybox_and_splitscreen.c @@ -463,15 +463,15 @@ void func_802A487C(Vtx* arg0, UNUSED struct UnkStruct_800DC5EC* arg1, UNUSED s32 } /** - * @brief Sets skybox horizon. Some coordinate transformations which can affect game physics and display of player sprite + * @brief Sets skybox horizon. Some coordinate transformations which can affect game physics and display of player + * sprite * @param skybox player skybox * @param arg1 something camera related * @param arg2 unused * @param arg3 unused * @parma arg4 unused */ -void render_skybox(Vtx* skybox, struct UnkStruct_800DC5EC* arg1, UNUSED s32 arg2, UNUSED s32 arg3, - UNUSED f32* arg4) { +void render_skybox(Vtx* skybox, struct UnkStruct_800DC5EC* arg1, UNUSED s32 arg2, UNUSED s32 arg3, UNUSED f32* arg4) { Camera* camera = arg1->camera; s16 horizonRow; f32 homogFactor;