From 27a421bbab2f40cf581dba5a75ca7a8a32d5f011 Mon Sep 17 00:00:00 2001 From: Lywx Date: Thu, 15 May 2025 22:12:56 -0600 Subject: [PATCH 1/6] Fixed macos --- src/engine/editor/EditorMath.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/editor/EditorMath.cpp b/src/engine/editor/EditorMath.cpp index 44923e08e1..92d7d2a381 100644 --- a/src/engine/editor/EditorMath.cpp +++ b/src/engine/editor/EditorMath.cpp @@ -352,8 +352,8 @@ bool IntersectRaySphere(const Ray& ray, const FVector& sphereCenter, float radiu // Transform a matrix to a matrix identity void Editor_MatrixIdentity(Mat4 mtx) { - register s32 i; - register s32 k; + s32 i; + s32 k; for (i = 0; i < 4; i++) { for (k = 0; k < 4; k++) { From 987573949ff56fea175cf1785494dde7f2262045 Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Thu, 15 May 2025 22:45:37 -0600 Subject: [PATCH 2/6] More stupid fixes --- src/port/SpaghettiGui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/port/SpaghettiGui.cpp b/src/port/SpaghettiGui.cpp index 09ac63234d..6c703456d4 100644 --- a/src/port/SpaghettiGui.cpp +++ b/src/port/SpaghettiGui.cpp @@ -12,7 +12,7 @@ #include #include -#include "graphic/Fast3D/gfx_metal.h" +#include "graphic/Fast3D/backends/gfx_metal.h" #include #include #else From f5f7c01c3be725d26714ff8b09fd997a5c721ebe Mon Sep 17 00:00:00 2001 From: wowjinxy <1340990+wowjinxy@users.noreply.github.com> Date: Sat, 17 May 2025 13:43:00 -0500 Subject: [PATCH 3/6] Removed Jumbotron triggers on Luigi Raceway --- src/engine/courses/LuigiRaceway.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/courses/LuigiRaceway.cpp b/src/engine/courses/LuigiRaceway.cpp index e4ee857a39..2cd51d7c2f 100644 --- a/src/engine/courses/LuigiRaceway.cpp +++ b/src/engine/courses/LuigiRaceway.cpp @@ -397,7 +397,7 @@ void LuigiRaceway::Render(struct UnkStruct_800DC5EC* arg0) { D_800DC5E0 = 72; // Render only the first player camera onto the television billboard. Screen agnostic screens of other players). - if ((gActiveScreenMode == SCREEN_MODE_1P) && (sp22 >= 10) && (sp22 < 17)) { + if (gActiveScreenMode == SCREEN_MODE_1P) { prevFrame = (s16) sRenderedFramebuffer - 1; From a67fbb6442d76016397c67f2cb7831687cdda91a Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Tue, 20 May 2025 13:15:36 -0400 Subject: [PATCH 4/6] bump lus (#203) --- libultraship | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libultraship b/libultraship index d4a22ea7f7..6a3f6cd327 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit d4a22ea7f78eb275b462ce542815d8368849d526 +Subproject commit 6a3f6cd327b99f617b623e5b9a3afeae460aac2b From 7bc6de5861c469f28439fdf5f2d76388a2961e4c Mon Sep 17 00:00:00 2001 From: coco875 Date: Sun, 25 May 2025 04:21:15 +0200 Subject: [PATCH 5/6] start migrate vec3 to cglm --- CMakeLists.txt | 10 +++ src/actors/banana/update.inc.c | 8 +-- src/actors/falling_rock/update.inc.c | 4 +- src/actors/paddle_boat/render.inc.c | 4 +- src/actors/train/render.inc.c | 41 ++++++------ src/code_800029B0.c | 18 +++--- src/ending/ceremony_and_credits.c | 85 +++++++------------------ src/ending/ceremony_and_credits.h | 7 -- src/engine/courses/ChocoMountain.cpp | 3 +- src/engine/courses/DKJungle.cpp | 3 +- src/engine/courses/KalimariDesert.cpp | 9 +-- src/engine/courses/KoopaTroopaBeach.cpp | 3 +- src/engine/courses/LuigiRaceway.cpp | 4 +- src/engine/courses/MarioRaceway.cpp | 7 +- src/engine/courses/TestCourse.cpp | 3 +- src/engine/courses/WarioStadium.cpp | 15 +++-- src/engine/courses/YoshiValley.cpp | 7 +- src/engine/objects/ChainChomp.cpp | 4 +- src/engine/objects/Seagull.cpp | 3 +- src/math_util_2.c | 24 ++----- src/math_util_2.h | 2 - src/racing/actors.c | 38 +++++------ src/racing/actors_extended.c | 10 +-- src/racing/collision.c | 7 +- src/racing/math_util.c | 50 --------------- src/racing/math_util.h | 4 -- 26 files changed, 140 insertions(+), 233 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 34b110bc7e..9a2f13b65f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -255,6 +255,16 @@ file(DOWNLOAD "https://raw.githubusercontent.com/DLTcollab/sse2neon/refs/heads/m include_directories(${SSE2NEON_DIR}) +#==================== CGLM =================== +FetchContent_Declare( + cglm + GIT_REPOSITORY https://github.com/recp/cglm.git + GIT_TAG v0.9.6 +) +FetchContent_MakeAvailable(cglm) + +include_directories(${cglm_SOURCE_DIR}/include) + #=================== DRLibs =================== FetchContent_Declare( dr_libs diff --git a/src/actors/banana/update.inc.c b/src/actors/banana/update.inc.c index cd7b700785..a715186bd0 100644 --- a/src/actors/banana/update.inc.c +++ b/src/actors/banana/update.inc.c @@ -2,6 +2,7 @@ #include #include #include +#include /** * @brief Update the banana actor @@ -14,7 +15,6 @@ void update_actor_banana(struct BananaActor* banana) { struct BananaActor* elderBanana; struct Controller* controller; Vec3f someOtherVelocity; - Vec3f someVelocity; f32 temp_f0; UNUSED f32 var_f8; UNUSED f32 pad2; @@ -71,7 +71,7 @@ void update_actor_banana(struct BananaActor* banana) { } else { temp_f0 = (player->unk_094 * 0.75f) + 3.5f + pad3; } - vec3f_set(someVelocity, 0, pad3, temp_f0); + Vec3f someVelocity = {0, pad3, temp_f0}; func_802B64C4(someVelocity, player->rotation[1] + player->unk_0C0); banana->velocity[0] = someVelocity[0]; banana->velocity[1] = someVelocity[1]; @@ -118,9 +118,7 @@ void update_actor_banana(struct BananaActor* banana) { } break; case FIRST_BANANA_BUNCH_BANANA: - someVelocity[0] = 0.0f; - someVelocity[1] = 0.0f; - someVelocity[2] = -5.0f; + Vec3f someVelocity = {0, 0, -5.0f}; func_802B64C4(someVelocity, player->rotation[1] + player->unk_0C0); unkX = player->pos[0] + someVelocity[0]; unkY = player->pos[1] + someVelocity[1]; diff --git a/src/actors/falling_rock/update.inc.c b/src/actors/falling_rock/update.inc.c index b700a4226e..7e0d6468d8 100644 --- a/src/actors/falling_rock/update.inc.c +++ b/src/actors/falling_rock/update.inc.c @@ -19,7 +19,7 @@ void func_8029CF0C(struct ActorSpawnData* spawnData, struct FallingRock* rock) { rock->pos[0] = (f32) temp_v0[rock->unk_06].pos[0] * gCourseDirection; rock->pos[1] = (f32) temp_v0[rock->unk_06].pos[1] + 10.0f; rock->pos[2] = (f32) temp_v0[rock->unk_06].pos[2]; - vec3f_set(rock->velocity, 0, 0, 0); + glm_vec3_zero(rock->velocity); vec3s_set(rock->rot, 0, 0, 0); } @@ -50,7 +50,7 @@ void spawn_falling_rocks(struct ActorSpawnData* spawnData) { startingPos[0] = temp_s0->pos[0] * gCourseDirection; startingPos[1] = temp_s0->pos[1] + 10.0f; startingPos[2] = temp_s0->pos[2]; - vec3f_set(startingVelocity, 0, 0, 0); + glm_vec3_zero(startingVelocity); vec3s_set(startingRot, 0, 0, 0); temp = add_actor_to_empty_slot(startingPos, startingRot, startingVelocity, ACTOR_FALLING_ROCK); temp_v1 = (struct FallingRock*) GET_ACTOR(temp); diff --git a/src/actors/paddle_boat/render.inc.c b/src/actors/paddle_boat/render.inc.c index 26d65f1604..03e4866875 100644 --- a/src/actors/paddle_boat/render.inc.c +++ b/src/actors/paddle_boat/render.inc.c @@ -7,6 +7,7 @@ #include "courses/all_course_data.h" #include #include +#include /** * @brief Renders the paddle boat actor. @@ -19,7 +20,6 @@ */ void render_actor_paddle_boat(Camera* arg0, struct PaddleWheelBoat* boat, UNUSED Mat4 arg2, u16 pathCounter) { UNUSED s32 pad[3]; - Vec3f sp120; Mat4 spE0; Mat4 spA0; Mat4 sp60; @@ -51,7 +51,7 @@ void render_actor_paddle_boat(Camera* arg0, struct PaddleWheelBoat* boat, UNUSED gSPDisplayList(gDisplayListHead++, &d_course_dks_jungle_parkway_railings_dl); mtxf_rotate_x(spE0, boat->wheelRot); - vec3f_set(sp120, 0, 16.0f, -255.0f); + Vec3f sp120 = {0.0f, 16.0f, -255.0f}; mtxf_translate(spA0, sp120); mtxf_multiplication(sp60, spE0, spA0); if (render_set_position(sp60, 3) != 0) { diff --git a/src/actors/train/render.inc.c b/src/actors/train/render.inc.c index 825aa4cd9f..12a1eeb4d5 100644 --- a/src/actors/train/render.inc.c +++ b/src/actors/train/render.inc.c @@ -2,6 +2,7 @@ #include #include #include +#include /** * @brief Renders the train engine actor. @@ -63,7 +64,7 @@ void render_actor_train_engine(Camera* camera, struct TrainCar* actor) { gSPDisplayList(gDisplayListHead++, d_course_kalimari_desert_dl_22D28); mtxf_rotate_x(mainMtx, actor->wheelRot); - vec3f_set(sp160, 17.0f, 6.0f, 32.0f); + glm_vec3_copy((vec3) {17.0f, 6.0f, 32.0f}, sp160); mtxf_translate(objectMtx, sp160); mtxf_multiplication(resultMtx, mainMtx, objectMtx); @@ -76,7 +77,7 @@ void render_actor_train_engine(Camera* camera, struct TrainCar* actor) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); mtxf_rotate_x(mainMtx, actor->wheelRot); - vec3f_set(sp160, -17.0, 6.0f, 32.0f); + glm_vec3_copy((vec3) {-17.0f, 6.0f, 32.0f}, sp160); mtxf_translate(objectMtx, sp160); mtxf_multiplication(resultMtx, mainMtx, objectMtx); @@ -89,7 +90,7 @@ void render_actor_train_engine(Camera* camera, struct TrainCar* actor) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); mtxf_rotate_x(mainMtx, (s16) (actor->wheelRot + 0x16C)); - vec3f_set(sp160, 17.0f, 6.0f, 16.0f); + glm_vec3_copy((vec3) {17.0f, 6.0f, 16.0f}, sp160); mtxf_translate(objectMtx, sp160); mtxf_multiplication(resultMtx, mainMtx, objectMtx); @@ -102,7 +103,7 @@ void render_actor_train_engine(Camera* camera, struct TrainCar* actor) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); mtxf_rotate_x(mainMtx, (s16) (actor->wheelRot + 0x16C)); - vec3f_set(sp160, -17.0f, 6.0f, 16.0f); + glm_vec3_copy((vec3) {-17.0f, 6.0f, 16.0f}, sp160); mtxf_translate(objectMtx, sp160); mtxf_multiplication(resultMtx, mainMtx, objectMtx); @@ -115,7 +116,7 @@ void render_actor_train_engine(Camera* camera, struct TrainCar* actor) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); mtxf_rotate_x(mainMtx, (s16) (actor->wheelRot + 0x444)); - vec3f_set(sp160, 17.0f, 12.0f, -12.0f); + glm_vec3_copy((vec3) {17.0f, 12.0f, -12.0f}, sp160); mtxf_translate(objectMtx, sp160); mtxf_multiplication(resultMtx, mainMtx, objectMtx); @@ -128,7 +129,7 @@ void render_actor_train_engine(Camera* camera, struct TrainCar* actor) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); mtxf_rotate_x(mainMtx, (s16) (actor->wheelRot + 0x444)); - vec3f_set(sp160, -17.0f, 12.0f, -12.0f); + glm_vec3_copy((vec3) {-17.0f, 12.0f, -12.0f}, sp160); mtxf_translate(objectMtx, sp160); mtxf_multiplication(resultMtx, mainMtx, objectMtx); @@ -141,7 +142,7 @@ void render_actor_train_engine(Camera* camera, struct TrainCar* actor) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); mtxf_rotate_x(mainMtx, (s16) (actor->wheelRot + 0x2D8)); - vec3f_set(sp160, 17.0f, 12.0f, -34.0f); + glm_vec3_copy((vec3) {17.0f, 12.0f, -34.0f}, sp160); mtxf_translate(objectMtx, sp160); mtxf_multiplication(resultMtx, mainMtx, objectMtx); @@ -154,7 +155,7 @@ void render_actor_train_engine(Camera* camera, struct TrainCar* actor) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); mtxf_rotate_x(mainMtx, (s16) (actor->wheelRot + 0x2D8)); - vec3f_set(sp160, -17.0f, 12.0f, -34.0f); + glm_vec3_copy((vec3) {-17.0f, 12.0f, -34.0f}, sp160); mtxf_translate(objectMtx, sp160); mtxf_multiplication(resultMtx, mainMtx, objectMtx); @@ -213,7 +214,7 @@ void render_actor_train_tender(Camera* camera, struct TrainCar* actor) { gSPDisplayList(gDisplayListHead++, d_course_kalimari_desert_dl_22D28); mtxf_rotate_x(sp120, actor->wheelRot); - vec3f_set(sp160, 17.0f, 6.0f, 8.0f); + glm_vec3_copy((vec3) {17.0f, 6.0f, 8.0f}, sp160); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -225,7 +226,7 @@ void render_actor_train_tender(Camera* camera, struct TrainCar* actor) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); mtxf_rotate_x(sp120, actor->wheelRot); - vec3f_set(sp160, -17.0, 6.0f, 8.0f); + glm_vec3_copy((vec3) {-17.0f, 6.0f, 8.0f}, sp160); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -237,7 +238,7 @@ void render_actor_train_tender(Camera* camera, struct TrainCar* actor) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x444)); - vec3f_set(sp160, 17.0f, 6.0f, -8.0f); + glm_vec3_copy((vec3) {17.0f, 6.0f, -8.0f}, sp160); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -249,7 +250,7 @@ void render_actor_train_tender(Camera* camera, struct TrainCar* actor) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x444)); - vec3f_set(sp160, -17.0f, 6.0f, -8.0f); + glm_vec3_copy((vec3) {-17.0f, 6.0f, -8.0f}, sp160); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -311,7 +312,7 @@ void render_actor_train_passenger_car(Camera* camera, struct TrainCar* actor) { gSPDisplayList(gDisplayListHead++, d_course_kalimari_desert_dl_22D28); mtxf_rotate_x(sp120, actor->wheelRot); - vec3f_set(sp160, 17.0f, 6.0f, 28.0f); + glm_vec3_copy((vec3) {17.0f, 6.0f, 28.0f}, sp160); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -323,7 +324,7 @@ void render_actor_train_passenger_car(Camera* camera, struct TrainCar* actor) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); mtxf_rotate_x(sp120, actor->wheelRot); - vec3f_set(sp160, -17.0, 6.0f, 28.0f); + glm_vec3_copy((vec3) {-17.0, 6.0f, 28.0f}, sp160); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -335,7 +336,7 @@ void render_actor_train_passenger_car(Camera* camera, struct TrainCar* actor) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x222)); - vec3f_set(sp160, 17.0f, 6.0f, 12.0f); + glm_vec3_copy((vec3) {17.0f, 6.0f, 12.0f}, sp160); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -347,7 +348,7 @@ void render_actor_train_passenger_car(Camera* camera, struct TrainCar* actor) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x222)); - vec3f_set(sp160, -17.0f, 6.0f, 12.0f); + glm_vec3_copy((vec3) {-17.0f, 6.0f, 12.0f}, sp160); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -359,7 +360,7 @@ void render_actor_train_passenger_car(Camera* camera, struct TrainCar* actor) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x5B0)); - vec3f_set(sp160, 17.0f, 6.0f, -8.0f); + glm_vec3_copy((vec3) {17.0f, 6.0f, -8.0f}, sp160); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -371,7 +372,7 @@ void render_actor_train_passenger_car(Camera* camera, struct TrainCar* actor) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x5B0)); - vec3f_set(sp160, -17.0f, 6.0f, -8.0f); + glm_vec3_copy((vec3) {-17.0f, 6.0f, -8.0f}, sp160); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -383,7 +384,7 @@ void render_actor_train_passenger_car(Camera* camera, struct TrainCar* actor) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x16C)); - vec3f_set(sp160, 17.0f, 6.0f, -24.0f); + glm_vec3_copy((vec3) {17.0f, 6.0f, -24.0f}, sp160); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -395,7 +396,7 @@ void render_actor_train_passenger_car(Camera* camera, struct TrainCar* actor) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x16C)); - vec3f_set(sp160, -17.0f, 6.0f, -24.0f); + glm_vec3_copy((vec3) {-17.0f, 6.0f, -24.0f}, sp160); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); diff --git a/src/code_800029B0.c b/src/code_800029B0.c index beba2e490b..0003e9b533 100644 --- a/src/code_800029B0.c +++ b/src/code_800029B0.c @@ -265,33 +265,33 @@ void func_80002DAC(void) { // switch (gCurrentCourseId) { // case COURSE_MARIO_RACEWAY: - // // vec3f_set(D_8015F748, -223.0f, 94.0f, -155.0f); + // // glm_vec3_copy((vec3) {-223.0f, 94.0f, -155.0f}, D_8015F748); // // func_800C9D80(D_8015F748, D_802B91C8, 0x5103700B); // break; // case COURSE_ROYAL_RACEWAY: - // vec3f_set(D_8015F748, 177.0f, 87.0f, -393.0f); + // glm_vec3_copy((vec3) {177.0f, 87.0f, -393.0f}, D_8015F748); // func_800C9D80(D_8015F748, D_802B91C8, 0x5103700B); // break; // case COURSE_LUIGI_RACEWAY: - // vec3f_set(D_8015F748, 85.0f, 21.0f, -219.0f); + // glm_vec3_copy((vec3) {85.0f, 21.0f, -219.0f}, D_8015F748); // func_800C9D80(D_8015F748, D_802B91C8, 0x5103700B); // break; // case COURSE_WARIO_STADIUM: - // vec3f_set(D_8015F748, 298.0f, 202.0f, -850.0f); + // glm_vec3_copy((vec3) {298.0f, 202.0f, -850.0f}, D_8015F748); // func_800C9D80(D_8015F748, D_802B91C8, 0x5103700B); - // vec3f_set(D_8015F758, -1600.0f, 202.0f, -2430.0f); + // glm_vec3_copy((vec3) {-1600.0f, 202.0f, -2430.0f}, D_8015F758); // func_800C9D80(D_8015F758, D_802B91C8, 0x5103700B); - // vec3f_set(D_8015F768, -2708.0f, 202.0f, 1762.0f); + // glm_vec3_copy((vec3) {-2708.0f, 202.0f, 1762.0f}, D_8015F768); // func_800C9D80(D_8015F768, D_802B91C8, 0x5103700B); - // vec3f_set(D_8015F778, -775.0f, 202.0f, 1930.0f); + // glm_vec3_copy((vec3) {-775.0f, 202.0f, 1930.0f}, D_8015F778); // func_800C9D80(D_8015F778, D_802B91C8, 0x5103700B); // break; // case COURSE_KOOPA_BEACH: - // vec3f_set(D_8015F738, 153.0f, 0.0f, 2319.0f); + // glm_vec3_copy((vec3) {153.0f, 0.0f, 2319.0f}, D_8015F738); // func_800C9D80(D_8015F738, D_802B91C8, 0x51028001); // break; // case COURSE_DK_JUNGLE: - // vec3f_set(D_8015F738, -790.0f, -255.0f, -447.0f); + // glm_vec3_copy((vec3) {-790.0f, -255.0f, -447.0f}, D_8015F738); // func_800C9D80(D_8015F738, D_802B91C8, 0x51028001); // break; // default: diff --git a/src/ending/ceremony_and_credits.c b/src/ending/ceremony_and_credits.c index fd8b2405ca..631fd0468c 100644 --- a/src/ending/ceremony_and_credits.c +++ b/src/ending/ceremony_and_credits.c @@ -24,6 +24,7 @@ #include "port/Engine.h" #include "port/Game.h" +#include f32 D_802856B0 = 98.0f; f32 D_802856B4 = 12.0f; @@ -49,62 +50,22 @@ s16 sCutsceneSplineSegment; s16 D_80287B1E; s8 D_80287B20; -void vec3f_set_dupe(Vec3f dest, f32 arg1, f32 arg2, f32 arg3) { - dest[0] = arg1; - dest[1] = arg2; - dest[2] = arg3; -} - void vec3s_set_dupe(Vec3s dest, s16 arg1, s16 arg2, s16 arg3) { dest[0] = arg1; dest[1] = arg2; dest[2] = arg3; } -void vec3f_clear(Vec3f arg0) { - arg0[0] = arg0[1] = arg0[2] = 0.0f; -} - void vec3s_clear(Vec3s arg0) { arg0[0] = arg0[1] = arg0[2] = 0; } -void vec3f_copy_return_dupe(Vec3f dest, Vec3f src) { - dest[0] = src[0]; - dest[1] = src[1]; - dest[2] = src[2]; -} - void vec3s_copy_dupe(Vec3s dest, Vec3s src) { dest[0] = src[0]; dest[1] = src[1]; dest[2] = src[2]; } -void func_80282040(void) { -} - -void func_80282048(void) { -} - -UNUSED void rotate_y_vec3f(Vec3f dest, Vec3f src, s16 angle) { - Vec3f sp2C; - - vec3f_copy_return_dupe(sp2C, src); - dest[0] = (sp2C[2] * sins(angle)) + (sp2C[0] * coss(angle)); - dest[1] = sp2C[1]; - dest[2] = (sp2C[2] * coss(angle)) - (sp2C[0] * sins(angle)); -} - -UNUSED void rotate_x_vec3f(Vec3f dest, Vec3f src, s16 angle) { - Vec3f sp2C; - - vec3f_copy_return_dupe(sp2C, src); - dest[2] = (sp2C[2] * coss(angle)) - (sp2C[1] * sins(angle)); - dest[1] = (sp2C[2] * sins(angle)) + (sp2C[1] * coss(angle)); - dest[0] = sp2C[0]; -} - /** * Target f32 at given rate. * Used for targeting playerTwo and playerThree. @@ -234,7 +195,7 @@ UNUSED void aborting_cinematic_function(Vec3f arg0, Vec3f arg1, Vec3f arg2, Vec3 Vec3f sp30; // What's up with this? Why do we copy arg1 to an unused local variable? - vec3f_copy_return_dupe(sp3C, arg1); + glm_vec3_copy(arg1, sp3C); sp30[2] = -((arg2[2] * coss(arg3[0])) - (arg2[1] * sins(arg3[0]))); sp30[1] = (arg2[2] * sins(arg3[0])) + (arg2[1] * coss(arg3[0])); sp30[0] = arg2[0]; @@ -427,8 +388,8 @@ void func_80282F44(s32 arg0, CinematicCamera* arg1, Camera* camera) { Vec3f pos; Vec3f lookat; - vec3f_set_dupe(pos, camera->pos[0], camera->pos[1], camera->pos[2]); - vec3f_set_dupe(lookat, camera->lookAt[0], camera->lookAt[1], camera->lookAt[2]); + glm_vec3_copy(camera->pos, pos); + glm_vec3_copy(camera->lookAt, lookat); if ((arg0 == 0) || (arg0 == 1)) { if ((arg1->unk48[0] != 0) || (arg1->unk48[1] != 0)) { calculate_distance_angle_y_and_angle_y_to_xz(pos, lookat, &distance, &angleCam[0], &angleCam[1]); @@ -532,11 +493,11 @@ void init_cinematic_camera(void) { D_802876D8 = 0; camera->cutscene = 0; D_802856C4 = (s32) D_800DC5E4; - vec3f_clear(camera->lookAt); - vec3f_set_dupe(camera->pos, 0.0f, 0.0f, 500.0f); - vec3f_clear(camera->unk30); - vec3f_set_dupe(camera->unk24, 0.0f, 0.0f, 500.0f); - vec3f_set_dupe(camera->unk3C, 0.0f, 1.0f, 0.0f); + glm_vec3_zero(camera->lookAt); + glm_vec3_copy((vec3) {0.0f, 0.0f, 500.0f}, camera->pos); + glm_vec3_zero(camera->unk30); + glm_vec3_copy((vec3) {0.0f, 0.0f, 500.0f}, camera->unk24); + glm_vec3_copy((vec3) {0.0f, 1.0f, 0.0f}, camera->unk3C); camera->unk18 = 0.0f; vec3s_clear(camera->unk48); vec3s_clear(camera->unk4E); @@ -559,7 +520,7 @@ void init_cinematic_camera(void) { } for (i = 0; i < 10; i++) { - vec3f_clear(D_80287750[i].unk0); + glm_vec3_zero(D_80287750[i].unk0); vec3s_clear(D_80287750[i].unkC); } @@ -588,13 +549,13 @@ s32 func_80283648(Camera* camera) { CinematicCamera* cinematicCamera = &D_802876E0; cinematic_stub(); - vec3f_copy_return_dupe(pos, camera->pos); - vec3f_copy_return_dupe(lookAt, camera->lookAt); - vec3f_copy_return_dupe(up, camera->up); + glm_vec3_copy(camera->pos, pos); + glm_vec3_copy(camera->lookAt, lookAt); + glm_vec3_copy(camera->up, up); cinematicCamera->cutscene = func_8028336C(cinematicCamera, camera); if (cinematicCamera->cutscene != 0) { - vec3f_copy_return_dupe(cinematicCamera->lookAt, camera->pos); - vec3f_copy_return_dupe(cinematicCamera->pos, camera->lookAt); + glm_vec3_copy(camera->pos, cinematicCamera->pos); + glm_vec3_copy(camera->lookAt, cinematicCamera->lookAt); play_cutscene(cinematicCamera); calculate_distance_angle_y_and_angle_y_to_xz(cinematicCamera->lookAt, cinematicCamera->pos, &distance, &angleYToXZ, &angleY); @@ -624,8 +585,8 @@ s32 func_80283648(Camera* camera) { camera->up[0] = sins(var_f2) * coss(angleY); camera->up[1] = coss(var_f2); camera->up[2] = -sins(var_f2) * sins(angleY); - vec3f_copy_return_dupe(camera->pos, cinematicCamera->lookAt); - vec3f_copy_return_dupe(camera->lookAt, cinematicCamera->pos); + glm_vec3_copy(cinematicCamera->lookAt, camera->lookAt); + glm_vec3_copy(cinematicCamera->pos, camera->pos); if ((gGamestate == CREDITS_SEQUENCE) && (gIsMirrorMode != 0)) { camera->pos[0] = -camera->pos[0]; camera->lookAt[0] = -camera->lookAt[0]; @@ -634,9 +595,9 @@ s32 func_80283648(Camera* camera) { func_80282F44(0, cinematicCamera, camera); func_80282F44(1, cinematicCamera, camera); func_80283100(cinematicCamera, gCameraZoom); - vec3f_copy_return_dupe(cinematicCamera->unk30, camera->pos); - vec3f_copy_return_dupe(cinematicCamera->unk24, camera->lookAt); - vec3f_copy_return_dupe(cinematicCamera->unk3C, camera->up); + glm_vec3_copy(camera->pos, cinematicCamera->unk30); + glm_vec3_copy(camera->lookAt, cinematicCamera->unk24); + glm_vec3_copy(camera->up, cinematicCamera->unk3C); return D_802876D8; } @@ -943,7 +904,7 @@ void func_80283EA0(CinematicCamera* camera) { } void copy_player_two_in_camera(CinematicCamera* camera) { - vec3f_copy_return_dupe(camera->pos, gPlayerTwo->pos); + glm_vec3_copy(gPlayerTwo->pos, camera->pos); } void lerp_player_two_in_camera(CinematicCamera* camera) { @@ -959,7 +920,7 @@ void func_80283F6C(CinematicCamera* camera) { } void copy_player_three_in_camera(CinematicCamera* camera) { - vec3f_copy_return_dupe(camera->pos, gPlayerThree->pos); + glm_vec3_copy(gPlayerThree->pos, camera->pos); } void lerp_player_three_in_camera(CinematicCamera* camera) { @@ -1006,7 +967,7 @@ void func_80284184(CinematicCamera* camera) { void func_802841E8(CinematicCamera* camera) { func_80282E58(camera, (struct struct_80282C40*) D_80285940, 0); - vec3f_set_dupe(camera->pos, -3202.0f, 90.0f, -478.0f); + glm_vec3_copy((vec3) {-3202.0f, 90.0f, -478.0f}, camera->pos); } void func_8028422C(CinematicCamera* camera) { diff --git a/src/ending/ceremony_and_credits.h b/src/ending/ceremony_and_credits.h index c84d33691d..4ae9e4e6af 100644 --- a/src/ending/ceremony_and_credits.h +++ b/src/ending/ceremony_and_credits.h @@ -111,16 +111,9 @@ typedef CameraEvent CutsceneShot; void init_cinematic_camera(void); s32 func_80283648(Camera*); -void vec3f_set_dupe(Vec3f, f32, f32, f32); void vec3s_set_dupe(Vec3s, s16, s16, s16); -void vec3f_clear(Vec3f); void vec3s_clear(Vec3s); -void vec3f_copy_return_dupe(Vec3f, Vec3f); void vec3s_copy_dupe(Vec3s, Vec3s); -void func_80282040(void); -void func_80282048(void); -void rotate_y_vec3f(Vec3f, Vec3f, s16); -void rotate_x_vec3f(Vec3f, Vec3f, s16); s32 f32_lerp(f32*, f32, f32); bool ease_out_transition(s16*, s16, s16); bool adjust_f32_value_transition(f32*, f32, f32); diff --git a/src/engine/courses/ChocoMountain.cpp b/src/engine/courses/ChocoMountain.cpp index be5dcb0b1b..ea06db84c9 100644 --- a/src/engine/courses/ChocoMountain.cpp +++ b/src/engine/courses/ChocoMountain.cpp @@ -33,6 +33,7 @@ extern "C" { #include "course_offsets.h" #include "course.h" extern const char *choco_mountain_dls[]; + #include } const course_texture choco_mountain_textures[] = { @@ -201,7 +202,7 @@ void ChocoMountain::InitCourseObjects() { } void ChocoMountain::SomeSounds() { - vec3f_set(D_8015F748, -223.0f, 94.0f, -155.0f); + glm_vec3_copy((vec3) {-223.0f, 94.0f, -155.0f}, D_8015F748); func_800C9D80(D_8015F748, D_802B91C8, 0x5103700B); } diff --git a/src/engine/courses/DKJungle.cpp b/src/engine/courses/DKJungle.cpp index bbb6025842..ee2eb6acb9 100644 --- a/src/engine/courses/DKJungle.cpp +++ b/src/engine/courses/DKJungle.cpp @@ -38,6 +38,7 @@ extern "C" { #include "course.h" extern const char *d_course_dks_jungle_parkway_unknown_dl_list[]; extern s16 currentScreenSection; + #include } const course_texture dks_jungle_parkway_textures[] = { @@ -236,7 +237,7 @@ void DKJungle::RenderCourseObjects(s32 cameraId) { } void DKJungle::SomeSounds() { - vec3f_set(D_8015F738, -790.0f, -255.0f, -447.0f); + glm_vec3_copy((vec3) {-790.0f, -255.0f, -447.0f}, D_8015F738); func_800C9D80(D_8015F738, D_802B91C8, 0x51028001); } diff --git a/src/engine/courses/KalimariDesert.cpp b/src/engine/courses/KalimariDesert.cpp index 8f4c3e8932..0d55e0ab45 100644 --- a/src/engine/courses/KalimariDesert.cpp +++ b/src/engine/courses/KalimariDesert.cpp @@ -34,6 +34,7 @@ extern "C" { #include "memory.h" #include "course.h" extern const char *kalimari_desert_dls[]; + #include } const course_texture kalimari_desert_textures[] = { @@ -159,12 +160,12 @@ void KalimariDesert::BeginPlay() { uintptr_t* crossing1 = (uintptr_t*) gWorldInstance.AddCrossing(crossingPos, 306, 310, 900.0f, 650.0f); uintptr_t* crossing2 = (uintptr_t*) gWorldInstance.AddCrossing(crossingPos2, 176, 182, 900.0f, 650.0f); - vec3f_set(position, -1680.0f, 2.0f, 35.0f); + glm_vec3_copy((vec3) {-1680.0f, 2.0f, 35.0f}, position); position[0] *= gCourseDirection; rrxing = (struct RailroadCrossing*) GET_ACTOR(add_actor_to_empty_slot(position, rotation, velocity, ACTOR_RAILROAD_CROSSING)); rrxing->crossingTrigger = crossing2; - vec3f_set(position, -1600.0f, 2.0f, 35.0f); + glm_vec3_copy((vec3) {-1600.0f, 2.0f, 35.0f}, position); position[0] *= gCourseDirection; rrxing = (struct RailroadCrossing*) GET_ACTOR(add_actor_to_empty_slot(position, rotation, velocity, ACTOR_RAILROAD_CROSSING)); @@ -172,12 +173,12 @@ void KalimariDesert::BeginPlay() { // Original game forgot to put gCourseDirection to face the crossing the right direction in extra mode vec3s_set(rotation, 0, -0x2000 * gCourseDirection, 0); - vec3f_set(position, -2459.0f, 2.0f, 2263.0f); + glm_vec3_copy((vec3) {-2459.0f, 2.0f, 2263.0f}, position); position[0] *= gCourseDirection; rrxing = (struct RailroadCrossing*) GET_ACTOR(add_actor_to_empty_slot(position, rotation, velocity, ACTOR_RAILROAD_CROSSING)); rrxing->crossingTrigger = crossing1; - vec3f_set(position, -2467.0f, 2.0f, 2375.0f); + glm_vec3_copy((vec3) {-2467.0f, 2.0f, 2375.0f}, position); position[0] *= gCourseDirection; rrxing = (struct RailroadCrossing*) GET_ACTOR(add_actor_to_empty_slot(position, rotation, velocity, ACTOR_RAILROAD_CROSSING)); diff --git a/src/engine/courses/KoopaTroopaBeach.cpp b/src/engine/courses/KoopaTroopaBeach.cpp index fff1b7b555..f3bc2fa611 100644 --- a/src/engine/courses/KoopaTroopaBeach.cpp +++ b/src/engine/courses/KoopaTroopaBeach.cpp @@ -35,6 +35,7 @@ extern "C" { #include "course.h" extern const char *koopa_troopa_beach_dls[]; extern s8 gPlayerCount; + #include } const course_texture koopa_troopa_beach_textures[] = { @@ -223,7 +224,7 @@ void KoopaTroopaBeach::RenderCourseObjects(s32 cameraId) { } void KoopaTroopaBeach::SomeSounds() { - vec3f_set(D_8015F738, 153.0f, 0.0f, 2319.0f); + glm_vec3_copy((vec3) {153.0f, 0.0f, 2319.0f}, D_8015F738); func_800C9D80(D_8015F738, D_802B91C8, 0x51028001); } diff --git a/src/engine/courses/LuigiRaceway.cpp b/src/engine/courses/LuigiRaceway.cpp index 2cd51d7c2f..b7859faed3 100644 --- a/src/engine/courses/LuigiRaceway.cpp +++ b/src/engine/courses/LuigiRaceway.cpp @@ -38,6 +38,8 @@ extern "C" { #include "course.h" extern const char* luigi_raceway_dls[]; extern s16 currentScreenSection; + +#include } const course_texture luigi_raceway_textures[] = { @@ -207,7 +209,7 @@ void LuigiRaceway::InitCourseObjects() { } void LuigiRaceway::SomeSounds() { - vec3f_set(D_8015F748, 85.0f, 21.0f, -219.0f); + glm_vec3_copy((vec3) {85.0f, 21.0f, -219.0f}, D_8015F748); func_800C9D80(D_8015F748, D_802B91C8, 0x5103700B); } diff --git a/src/engine/courses/MarioRaceway.cpp b/src/engine/courses/MarioRaceway.cpp index 50af0d890f..5e0b2bbaa2 100644 --- a/src/engine/courses/MarioRaceway.cpp +++ b/src/engine/courses/MarioRaceway.cpp @@ -34,6 +34,7 @@ extern "C" { #include "courses/staff_ghost_data.h" #include "course.h" extern const char *mario_raceway_dls[]; + #include } const course_texture mario_raceway_textures[] = { @@ -193,10 +194,10 @@ void MarioRaceway::BeginPlay() { spawn_foliage((struct ActorSpawnData*)LOAD_ASSET_RAW(d_course_mario_raceway_tree_spawns)); spawn_piranha_plants((struct ActorSpawnData*)LOAD_ASSET_RAW(d_course_mario_raceway_piranha_plant_spawns)); spawn_all_item_boxes((struct ActorSpawnData*)LOAD_ASSET_RAW(d_course_mario_raceway_item_box_spawns)); - vec3f_set(position, 150.0f, 40.0f, -1300.0f); + glm_vec3_copy((vec3) {150.0f, 40.0f, -1300.0f}, position); position[0] *= gCourseDirection; add_actor_to_empty_slot(position, rotation, velocity, ACTOR_MARIO_SIGN); - vec3f_set(position, 2520.0f, 0.0f, 1240.0f); + glm_vec3_copy((vec3) {2520.0f, 0.0f, 1240.0f}, position); position[0] *= gCourseDirection; add_actor_to_empty_slot(position, rotation, velocity, ACTOR_MARIO_SIGN); @@ -225,7 +226,7 @@ void MarioRaceway::InitCourseObjects() { } void MarioRaceway::SomeSounds() { - vec3f_set(D_8015F748, -223.0f, 94.0f, -155.0f); + glm_vec3_copy((vec3) {-223.0f, 94.0f, -155.0f}, D_8015F748); func_800C9D80(D_8015F748, D_802B91C8, 0x5103700B); } diff --git a/src/engine/courses/TestCourse.cpp b/src/engine/courses/TestCourse.cpp index eebaee17a1..e25897557e 100644 --- a/src/engine/courses/TestCourse.cpp +++ b/src/engine/courses/TestCourse.cpp @@ -56,6 +56,7 @@ extern "C" { extern Gfx mario_Plane_001_mesh[]; extern TrackWaypoint test_course_path[]; extern TrackSections test_course_addr[]; + #include } TestCourse::TestCourse() { @@ -251,7 +252,7 @@ void TestCourse::BeginPlay() { Vec3f position; Vec3f velocity = { 0.0f, 0.0f, 0.0f }; Vec3s rotation = { 0, 0, 0 }; - vec3f_set(position, 50.0f, 2.0f, 50.0f); + glm_vec3_copy((vec3) {50.0f, 2.0f, 50.0f}, position); Vec3f crossingPos = {0, 2, 0}; uintptr_t* crossing1 = (uintptr_t*) gWorldInstance.AddCrossing(crossingPos, 0, 2, 900.0f, 650.0f); diff --git a/src/engine/courses/WarioStadium.cpp b/src/engine/courses/WarioStadium.cpp index 4cd4bbf47e..9e2234d018 100644 --- a/src/engine/courses/WarioStadium.cpp +++ b/src/engine/courses/WarioStadium.cpp @@ -35,6 +35,7 @@ extern "C" { #include "course.h" extern const char* wario_stadium_dls[]; extern s16 currentScreenSection; +#include } const course_texture wario_stadium_textures[] = { @@ -209,13 +210,13 @@ void WarioStadium::InitCourseObjects() { } void WarioStadium::SomeSounds() { - vec3f_set(D_8015F748, 298.0f, 202.0f, -850.0f); + glm_vec3_copy((vec3) {298.0f, 202.0f, -850.0f}, D_8015F748); func_800C9D80(D_8015F748, D_802B91C8, 0x5103700B); - vec3f_set(D_8015F758, -1600.0f, 202.0f, -2430.0f); + glm_vec3_copy((vec3) {-1600.0f, 202.0f, -2430.0f}, D_8015F758); func_800C9D80(D_8015F758, D_802B91C8, 0x5103700B); - vec3f_set(D_8015F768, -2708.0f, 202.0f, 1762.0f); + glm_vec3_copy((vec3) {-2708.0f, 202.0f, 1762.0f}, D_8015F768); func_800C9D80(D_8015F768, D_802B91C8, 0x5103700B); - vec3f_set(D_8015F778, -775.0f, 202.0f, 1930.0f); + glm_vec3_copy((vec3) {-775.0f, 202.0f, 1930.0f}, D_8015F778); func_800C9D80(D_8015F778, D_802B91C8, 0x5103700B); } @@ -394,11 +395,11 @@ void WarioStadium::CreditsSpawnActors() { Vec3f velocity = { 0, 0, 0 }; Vec3s rotation = { 0, 0, 0 }; - vec3f_set(position, -131.0f, 83.0f, 286.0f); + glm_vec3_copy((vec3) {-131.0f, 83.0f, 286.0f}, position); add_actor_to_empty_slot(position, rotation, velocity, ACTOR_WARIO_SIGN); - vec3f_set(position, -2353.0f, 72.0f, -1608.0f); + glm_vec3_copy((vec3) {-2353.0f, 72.0f, -1608.0f}, position); add_actor_to_empty_slot(position, rotation, velocity, ACTOR_WARIO_SIGN); - vec3f_set(position, -2622.0f, 79.0f, 739.0f); + glm_vec3_copy((vec3) {-2622.0f, 79.0f, 739.0f}, position); add_actor_to_empty_slot(position, rotation, velocity, ACTOR_WARIO_SIGN); // d_course_wario_stadium_packed_dl_C50 find_vtx_and_set_colours(segmented_gfx_to_virtual((void*) 0x07000C50), 0x64, 0xFF, 0xFF, 0xFF); diff --git a/src/engine/courses/YoshiValley.cpp b/src/engine/courses/YoshiValley.cpp index 5fbcbea69d..203867e446 100644 --- a/src/engine/courses/YoshiValley.cpp +++ b/src/engine/courses/YoshiValley.cpp @@ -35,6 +35,7 @@ extern "C" { #include "memory.h" #include "course.h" extern const char *d_course_yoshi_valley_dl_list[]; + #include } const course_texture yoshi_valley_textures[] = { @@ -144,13 +145,12 @@ void YoshiValley::LoadTextures() { } void YoshiValley::BeginPlay() { - Vec3f position; + Vec3f position = {-2300.0f, 0.0f, 634.0f}; Vec3f velocity = { 0.0f, 0.0f, 0.0f }; Vec3s rotation = { 0, 0, 0 }; spawn_foliage((struct ActorSpawnData*)LOAD_ASSET_RAW(d_course_yoshi_valley_tree_spawn)); spawn_all_item_boxes((struct ActorSpawnData*)LOAD_ASSET_RAW(d_course_yoshi_valley_item_box_spawns)); - vec3f_set(position, -2300.0f, 0.0f, 634.0f); position[0] *= gCourseDirection; add_actor_to_empty_slot(position, rotation, velocity, ACTOR_YOSHI_EGG); @@ -236,11 +236,10 @@ void YoshiValley::Waypoints(Player* player, int8_t playerId) { void YoshiValley::ScrollingTextures() {} void YoshiValley::CreditsSpawnActors() { - Vec3f position; + Vec3f position = {-2300.0f, 0.0f, 634.0f}; Vec3f velocity = { 0, 0, 0 }; Vec3s rotation = { 0, 0, 0 }; - vec3f_set(position, -2300.0f, 0.0f, 634.0f); position[0] *= gCourseDirection; add_actor_to_empty_slot(position, rotation, velocity, ACTOR_YOSHI_EGG); } diff --git a/src/engine/objects/ChainChomp.cpp b/src/engine/objects/ChainChomp.cpp index 695df1e8ab..cf4faad3df 100644 --- a/src/engine/objects/ChainChomp.cpp +++ b/src/engine/objects/ChainChomp.cpp @@ -12,6 +12,8 @@ extern "C" { #include "code_80057C60.h" #include "code_80005FD0.h" #include "external.h" + +#include } size_t OChainChomp::_count = 0; @@ -33,7 +35,7 @@ void OChainChomp::Tick() { object = &gObjectList[objectIndex]; if (object->state != 0) { OChainChomp::func_800859C8(objectIndex, _idx); - vec3f_copy(object->unk_01C, object->offset); + glm_vec3_copy(object->offset, object->unk_01C); // This should be spawn pos or follow path func_8000D940(object->offset, &object->unk_084[8], object->unk_034, object->surfaceHeight, 0); object->direction_angle[1] = get_angle_between_two_vectors(object->unk_01C, object->offset); diff --git a/src/engine/objects/Seagull.cpp b/src/engine/objects/Seagull.cpp index 17c35c07d7..577d3fb47f 100644 --- a/src/engine/objects/Seagull.cpp +++ b/src/engine/objects/Seagull.cpp @@ -25,6 +25,7 @@ extern SplineData D_800E6034; extern SplineData D_800E60F0; extern SplineData D_800E61B4; extern SplineData D_800E6280; +#include } SplineData* D_800E633C[] = { &D_800E6034, &D_800E60F0, &D_800E61B4, &D_800E6280 }; @@ -143,7 +144,7 @@ void OSeagull::func_8008275C(s32 objectIndex) { break; case 2: func_8008B78C(objectIndex); - vec3f_copy(gObjectList[objectIndex].unk_01C, gObjectList[objectIndex].pos); + glm_vec3_copy(gObjectList[objectIndex].pos, gObjectList[objectIndex].unk_01C); func_8000D940(gObjectList[objectIndex].origin_pos, (s16*) &gObjectList[objectIndex].unk_0C6, gObjectList[objectIndex].unk_034, 0.0f, 0); gObjectList[objectIndex].offset[0] *= 2.0; diff --git a/src/math_util_2.c b/src/math_util_2.c index b113c6a5d8..dea1691b8f 100644 --- a/src/math_util_2.c +++ b/src/math_util_2.c @@ -16,6 +16,7 @@ #include "port/Engine.h" #include "engine/Matrix.h" #include "port/interpolation/FrameInterpolation.h" +#include #pragma intrinsic(sqrtf) @@ -54,12 +55,6 @@ UNUSED s32 func_80040EA4(s32* arg0, s32 arg1) { return phi_v1; } -void vec3f_copy(Vec3f dest, Vec3f arg1) { - dest[0] = arg1[0]; - dest[1] = arg1[1]; - dest[2] = arg1[2]; -} - s32 f32_step_up_towards(f32* value, f32 target, f32 step) { s32 targetReached = 0; @@ -332,13 +327,6 @@ s32 f32_step_towards(f32* value, f32 target, f32 step) { return targetReached; } -Vec3f* vec3f_set_xyz(Vec3f arg0, f32 arg1, f32 arg2, f32 arg3) { - arg0[0] = arg1; - arg0[1] = arg2; - arg0[2] = arg3; - return (Vec3f*) &arg0; -} - Vec3f* vec3f_normalize(Vec3f dest) { f32 invsqrt = 1.0f / sqrtf(dest[0] * dest[0] + dest[1] * dest[1] + dest[2] * dest[2]); @@ -943,17 +931,17 @@ UNUSED void mtxf_mult_third_column(Mat4 arg0, f32 arg1) { void set_transform_matrix(Mat4 dest, Vec3f orientationVector, Vec3f positionVector, u16 rotationAngle, f32 scaleFactor) { - Vec3f sp44; - Vec3f sp38; - Vec3f sp2C; - + Vec3f sp44 = {sins(rotationAngle), 0.0f, coss(rotationAngle)}; + FrameInterpolation_RecordSetTransformMatrix(dest, orientationVector, positionVector, rotationAngle, scaleFactor); - vec3f_set_xyz(sp44, sins(rotationAngle), 0.0f, coss(rotationAngle)); vec3f_normalize(orientationVector); + Vec3f sp38; vec3f_cross_product(sp38, orientationVector, sp44); vec3f_normalize(sp38); + Vec3f sp2C; vec3f_cross_product(sp2C, sp38, orientationVector); vec3f_normalize(sp2C); + dest[0][0] = sp38[0] * scaleFactor; dest[0][1] = sp38[1] * scaleFactor; dest[0][2] = sp38[2] * scaleFactor; diff --git a/src/math_util_2.h b/src/math_util_2.h index 52b4363011..4059e715e4 100644 --- a/src/math_util_2.h +++ b/src/math_util_2.h @@ -38,7 +38,6 @@ void mtxf_mult_third_column(Mat4, f32); void vec3f_rotate(Vec3f, Vec3f, Vec3s); void rsp_set_matrix_diff_translation_scale(Vec3f, Vec3f, f32); -void vec3f_copy(Vec3f, Vec3f); s32 f32_step_up_towards(f32*, f32, f32); s32 f32_step_down_towards(f32*, f32, f32); s32 s32_step_up_towards(s32*, s32, s32); @@ -49,7 +48,6 @@ s32 s16_step_down_towards(s16*, s16, s16); s32 u16_step_down_towards(u16*, s32, s32); s32 s16_step_towards(s16*, s16, s16); s32 f32_step_towards(f32*, f32, f32); -Vec3f* vec3f_set_xyz(Vec3f, f32, f32, f32); Vec3f* vec3f_normalize(Vec3f dest); Vec3f* vec3f_cross_product(Vec3f, Vec3f, Vec3f); s32 func_80041658(f32, f32); diff --git a/src/racing/actors.c b/src/racing/actors.c index 137e3556ef..943222b419 100644 --- a/src/racing/actors.c +++ b/src/racing/actors.c @@ -35,6 +35,7 @@ #include #include "port/Game.h" #include "port/interpolation/FrameInterpolation.h" +#include // Appears to be textures // or tluts @@ -127,9 +128,9 @@ void cleanup_red_and_green_shells(struct ShellActor* shell) { // Sets introductory values for a new actor (ex. Banana). void actor_init(struct Actor* actor, Vec3f startingPos, Vec3s startingRot, Vec3f startingVelocity, s16 actorType) { - vec3f_copy_return(actor->pos, startingPos); + glm_vec3_copy(startingPos, actor->pos); vec3s_copy(actor->rot, startingRot); - vec3f_copy_return(actor->velocity, startingVelocity); + glm_vec3_copy(startingVelocity, actor->velocity); actor->type = actorType; actor->flags = -0x8000; actor->unk_04 = 0; @@ -870,8 +871,7 @@ void spawn_piranha_plants(struct ActorSpawnData* spawnData) { if (gGamestate == CREDITS_SEQUENCE) { return; } - - vec3f_set(startingVelocity, 0, 0, 0); + glm_vec3_zero(startingVelocity); vec3s_set(startingRot, 0, 0, 0); while (temp_s0->pos[0] != END_OF_SPAWN_DATA) { @@ -900,7 +900,7 @@ void spawn_palm_trees(struct ActorSpawnData* spawnData) { Vec3s startingRot; s32 temp; - vec3f_set(startingVelocity, 0, 0, 0); + glm_vec3_zero(startingVelocity); vec3s_set(startingRot, 0, 0, 0); while (temp_s0->pos[0] != END_OF_SPAWN_DATA) { @@ -930,7 +930,7 @@ void spawn_foliage(struct ActorSpawnData* actor) { s16 actorType = 0; struct Actor* temp_s0; struct ActorSpawnData* var_s3 = actor; - vec3f_set(velocity, 0.0f, 0.0f, 0.0f); + glm_vec3_zero(velocity); rotation[0] = 0x4000; rotation[1] = 0; rotation[2] = 0; @@ -1007,7 +1007,7 @@ void spawn_all_item_boxes(struct ActorSpawnData* spawnData) { return; } - vec3f_set(startingVelocity, 0, 0, 0); + glm_vec3_zero(startingVelocity); while (temp_s0->pos[0] != END_OF_SPAWN_DATA) { startingPos[0] = temp_s0->pos[0] * gCourseDirection; startingPos[1] = temp_s0->pos[1]; @@ -1095,10 +1095,10 @@ void spawn_course_actors(void) { // // spawn_foliage(d_course_mario_raceway_tree_spawns); // // spawn_piranha_plants(d_course_mario_raceway_piranha_plant_spawns); // // spawn_all_item_boxes(d_course_mario_raceway_item_box_spawns); - // // vec3f_set(position, 150.0f, 40.0f, -1300.0f); + // // glm_vec3_copy((vec3) {150.0f, 40.0f, -1300.0f}, position); // // position[0] *= gCourseDirection; // // add_actor_to_empty_slot(position, rotation, velocity, ACTOR_MARIO_SIGN); - // // vec3f_set(position, 2520.0f, 0.0f, 1240.0f); + // // glm_vec3_copy((vec3) {2520.0f, 0.0f, 1240.0f}, position); // // position[0] *= gCourseDirection; // // actor = GET_ACTOR(add_actor_to_empty_slot(position, rotation, velocity, ACTOR_MARIO_SIGN)); // // actor->flags |= 0x4000; @@ -1117,7 +1117,7 @@ void spawn_course_actors(void) { // case COURSE_YOSHI_VALLEY: // spawn_foliage(d_course_yoshi_valley_tree_spawn); // spawn_all_item_boxes(d_course_yoshi_valley_item_box_spawns); - // vec3f_set(position, -2300.0f, 0.0f, 634.0f); + // glm_vec3_copy((vec3) {-2300.0f, 0.0f, 634.0f}, position); // position[0] *= gCourseDirection; // add_actor_to_empty_slot(position, rotation, velocity, ACTOR_YOSHI_EGG); // break; @@ -1151,23 +1151,23 @@ void spawn_course_actors(void) { // case COURSE_KALIMARI_DESERT: // spawn_foliage(d_course_kalimari_desert_cactus_spawn); // spawn_all_item_boxes(d_course_kalimari_desert_item_box_spawns); - // vec3f_set(position, -1680.0f, 2.0f, 35.0f); + // glm_vec3_copy((vec3) {-1680.0f, 2.0f, 35.0f}, position); // position[0] *= gCourseDirection; // rrxing = (struct RailroadCrossing*) &gActorList[add_actor_to_empty_slot(position, rotation, velocity, // ACTOR_RAILROAD_CROSSING)]; // rrxing->crossingId = 1; - // vec3f_set(position, -1600.0f, 2.0f, 35.0f); + // glm_vec3_copy((vec3) {-1600.0f, 2.0f, 35.0f}, position); // position[0] *= gCourseDirection; // rrxing = (struct RailroadCrossing*) &gActorList[add_actor_to_empty_slot(position, rotation, velocity, // ACTOR_RAILROAD_CROSSING)]; // rrxing->crossingId = 1; // vec3s_set(rotation, 0, -0x2000, 0); - // vec3f_set(position, -2459.0f, 2.0f, 2263.0f); + // glm_vec3_copy((vec3) {-2459.0f, 2.0f, 2263.0f}, position); // position[0] *= gCourseDirection; // rrxing = (struct RailroadCrossing*) &gActorList[add_actor_to_empty_slot(position, rotation, velocity, // ACTOR_RAILROAD_CROSSING)]; // rrxing->crossingId = 0; - // vec3f_set(position, -2467.0f, 2.0f, 2375.0f); + // glm_vec3_copy((vec3) {-2467.0f, 2.0f, 2375.0f}, position); // position[0] *= gCourseDirection; // rrxing = (struct RailroadCrossing*) &gActorList[add_actor_to_empty_slot(position, rotation, velocity, // ACTOR_RAILROAD_CROSSING)]; @@ -1181,13 +1181,13 @@ void spawn_course_actors(void) { // break; // case COURSE_WARIO_STADIUM: // spawn_all_item_boxes(d_course_wario_stadium_item_box_spawns); - // vec3f_set(position, -131.0f, 83.0f, 286.0f); + // glm_vec3_copy((vec3) {-131.0f, 83.0f, 286.0f}, position); // position[0] *= gCourseDirection; // add_actor_to_empty_slot(position, rotation, velocity, ACTOR_WARIO_SIGN); - // vec3f_set(position, -2353.0f, 72.0f, -1608.0f); + // glm_vec3_copy((vec3) {-2353.0f, 72.0f, -1608.0f}, position); // position[0] *= gCourseDirection; // add_actor_to_empty_slot(position, rotation, velocity, ACTOR_WARIO_SIGN); - // vec3f_set(position, -2622.0f, 79.0f, 739.0f); + // glm_vec3_copy((vec3) {-2622.0f, 79.0f, 739.0f}, position); // position[0] *= gCourseDirection; // add_actor_to_empty_slot(position, rotation, velocity, ACTOR_WARIO_SIGN); // break; @@ -1439,7 +1439,7 @@ UNUSED s16 spawn_actor_at_pos(Vec3f pos, s16 actorType) { Vec3f vel; Vec3s rot; - vec3f_set(vel, 0.0f, 0.0f, 0.0f); + glm_vec3_zero(vel); vec3s_set(rot, 0, 0, 0); return add_actor_to_empty_slot(pos, rot, vel, actorType); } @@ -2370,7 +2370,7 @@ void init_actor_hot_air_balloon_item_box(f32 x, f32 y, f32 z) { } vec3s_set(rot, 0, 0, 0); - vec3f_set(velocity, 0, 0, 0); + glm_vec3_zero(velocity); pos[0] = x; pos[1] = y; pos[2] = z; diff --git a/src/racing/actors_extended.c b/src/racing/actors_extended.c index 5493a4efad..38b390a9cf 100644 --- a/src/racing/actors_extended.c +++ b/src/racing/actors_extended.c @@ -16,6 +16,7 @@ #include "effects.h" #include "sounds.h" #include "port/Game.h" +#include void copy_collision(Collision* src, Collision* dest) { dest->unk30 = src->unk30; @@ -28,9 +29,9 @@ void copy_collision(Collision* src, Collision* dest) { dest->surfaceDistance[1] = src->surfaceDistance[1]; dest->surfaceDistance[2] = src->surfaceDistance[2]; - vec3f_copy_return(dest->unk48, src->unk48); - vec3f_copy_return(dest->unk54, src->unk54); - vec3f_copy_return(dest->orientationVector, src->orientationVector); + glm_vec3_copy(src->unk48, dest->unk48); + glm_vec3_copy(src->unk54, dest->unk54); + glm_vec3_copy(src->orientationVector, dest->orientationVector); } void triple_shell_actor_collide_with_player(struct ShellActor* shell, s32 shellType) { @@ -154,7 +155,6 @@ void func_802B0648(struct BananaBunchParent* banana_bunch) { // Drop a banana from a banana bunch and throw it forward? void func_802B0788(s16 rawStickY, struct BananaBunchParent* banana_bunch, Player* player) { - Vec3f velocity; struct BananaActor* banana; struct BananaActor* elderBanana; f32 var_f0; @@ -193,7 +193,7 @@ void func_802B0788(s16 rawStickY, struct BananaBunchParent* banana_bunch, Player var_f0 = ((rawStickY - 30.0f) / 20.0f) + 1.5f; var_f12 = (player->unk_094 * 0.75f) + 4.5f + var_f0; } - vec3f_set(velocity, 0.0f, var_f0, var_f12); + Vec3f velocity = {0.0f, var_f0, var_f12}; func_802B64C4(velocity, player->rotation[1] + player->unk_0C0); banana->velocity[0] = velocity[0]; banana->velocity[1] = velocity[1]; diff --git a/src/racing/collision.c b/src/racing/collision.c index a394f0080d..28e2d6ed19 100644 --- a/src/racing/collision.c +++ b/src/racing/collision.c @@ -12,6 +12,7 @@ #include #include "port/Game.h" #include +#include #pragma intrinsic(sqrtf) @@ -34,9 +35,9 @@ void func_802AAAAC(Collision* collision) { collision->surfaceDistance[0] = 0; collision->surfaceDistance[1] = 0; collision->surfaceDistance[2] = 0; - vec3f_set(collision->unk48, 0.0f, 0.0f, 1.0f); - vec3f_set(collision->unk54, 1.0f, 0.0f, 0.0f); - vec3f_set(collision->orientationVector, 0.0f, 1.0f, 0.0f); + glm_vec3_copy((vec3) {0.0f, 0.0f, 1.0f}, collision->unk48); + glm_vec3_copy((vec3) {1.0f, 0.0f, 0.0f}, collision->unk54); + glm_vec3_copy((vec3) {0.0f, 1.0f, 0.0f}, collision->orientationVector); } f32 get_water_level(Player* player) { diff --git a/src/racing/math_util.c b/src/racing/math_util.c index 1279617038..e358c760c6 100644 --- a/src/racing/math_util.c +++ b/src/racing/math_util.c @@ -17,35 +17,6 @@ s32 D_802B91C0[2] = { 13, 13 }; Vec3f D_802B91C8 = { 0.0f, 0.0f, 0.0f }; -// Mtx gIdentityMatrix = { -// toFixedPointMatrix(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0), -// }; - -// This functions looks similar to a segment of code from func_802A4A0C in skybox_and_splitscreen.c -UNUSED s32 func_802B4F60(UNUSED s32 arg0, Vec3f arg1, UNUSED s32 arg2, UNUSED f32 arg3, UNUSED f32 arg4) { - Mat4 sp30; - f32 sp2C; - f32 sp28; - Vec3f sp1C; - vec3f_copy_return(sp1C, arg1); - sp28 = sp1C[0]; - sp2C = sp1C[1]; - // wut? - if (sp2C && sp2C) {}; - sp2C = ((sp30[0][3] * sp28) + (sp30[1][3] * sp2C) + (sp30[2][3] * sp1C[2])) + sp30[3][3]; - // double wut? - if (sp28 && sp28) {}; - mtxf_translate_vec3f_mat4(sp1C, sp30); - if (0.0f >= sp2C) { - return 0; - } else { - return 1; - } -} - -UNUSED void func_802B4FF0() { -} - /** * Inserts matrix into the rsp. Position, rotation and mode of where to render the next object and check number of * object already render Note that gMatrixObjectCount gets reset at the beginning of the game loop. So no cleanup needs @@ -111,12 +82,6 @@ u32 func_802B5258(Vec3f arg0, Vec3s arg1) { return atan2s(temp_v1, temp_v2); } -void vec3f_set(Vec3f arg0, f32 arg1, f32 arg2, f32 arg3) { - arg0[0] = arg1; - arg0[1] = arg2; - arg0[2] = arg3; -} - void vec3s_set(Vec3s arg0, s16 arg1, s16 arg2, s16 arg3) { arg0[0] = arg1; arg0[1] = arg2; @@ -135,27 +100,12 @@ void vec3s_set(Vec3s arg0, s16 arg1, s16 arg2, s16 arg3) { #endif #endif -void* vec3f_copy_return(Vec3f dest, Vec3f src) { - dest[0] = src[0]; - dest[1] = src[1]; - dest[2] = src[2]; - //! @warning function returns address of local variable - return &dest; -} - void vec3s_copy(Vec3s dest, Vec3s src) { dest[0] = src[0]; dest[1] = src[1]; dest[2] = src[2]; } -UNUSED void* vec3f_set_return(Vec3f dest, f32 x, f32 y, f32 z) { - dest[0] = x; - dest[1] = y; - dest[2] = z; - return &dest; -} - // Copy mat1 to mat2 void mtxf_copy(Mat4 mat1, Mat4 mat2) { s32 row; diff --git a/src/racing/math_util.h b/src/racing/math_util.h index 7c230ca87c..35947068fd 100644 --- a/src/racing/math_util.h +++ b/src/racing/math_util.h @@ -20,17 +20,13 @@ extern "C" { double fabs(double x); void func_802B5794(Mat4, Vec3f, Vec3f); -s32 func_802B4F60(s32, Vec3f, s32, f32, f32); s32 render_set_position(Mat4, s32); f32 func_802B51E8(Vec3f, Vec3f); s32 get_angle_between_two_vectors(Vec3f, Vec3f); u32 func_802B5258(Vec3f, Vec3s); void func_802B5794(Mat4, Vec3f, Vec3f); -void vec3f_set(Vec3f, f32, f32, f32); void vec3s_set(Vec3s, s16, s16, s16); -void* vec3f_copy_return(Vec3f, Vec3f); void vec3s_copy(Vec3s, Vec3s); -void* vec3f_set_return(Vec3f, f32, f32, f32); void mtxf_copy(Mat4, Mat4); void mtxf_copy_n_element(s32*, s32*, s32); void mtxf_identity(Mat4); From d880de6ba691924c8313bc17fde14736dbb7a12a Mon Sep 17 00:00:00 2001 From: coco875 Date: Sun, 25 May 2025 18:35:18 +0200 Subject: [PATCH 6/6] finish clean some vec3 --- include/convert_angle.h | 59 ++++++++++++++++++ src/actors/blue_and_red_shells/update.inc.c | 4 +- src/math_util_2.c | 67 ++------------------- src/math_util_2.h | 3 - src/racing/math_util.c | 58 ++++-------------- src/racing/math_util.h | 8 +-- 6 files changed, 80 insertions(+), 119 deletions(-) create mode 100644 include/convert_angle.h diff --git a/include/convert_angle.h b/include/convert_angle.h new file mode 100644 index 0000000000..cc68e36b03 --- /dev/null +++ b/include/convert_angle.h @@ -0,0 +1,59 @@ +#ifndef CONVERT_ANGLE_H +#define CONVERT_ANGLE_H + +#include // For M_PI and other mathematical functions if necessary + +// Ensure s16 is defined. This often comes from or a common types file. +// If not, you might need something like: +// #include // For int16_t +// typedef int16_t s16; + +// Basic constants for conversions +#define N64_ANGLE_UNITS_PER_CIRCLE 65536.0f +#define DEGREES_PER_CIRCLE 360.0f +#define RADIANS_PER_CIRCLE (2.0f * M_PI) + +// --- Conversion from N64 angle units (0-65535 for a full circle) --- + +/** + * Converts an N64 angle value to radians. + * N64 angles are often s16 or u16 where 65535 equals 2*PI radians. + */ +#define N64_ANGLE_TO_RADIANS(n64_angle) \ + (((float)(n64_angle) / N64_ANGLE_UNITS_PER_CIRCLE) * RADIANS_PER_CIRCLE) + +/** + * Converts an N64 angle value to degrees. + */ +#define N64_ANGLE_TO_DEGREES(n64_angle) \ + (((float)(n64_angle) / N64_ANGLE_UNITS_PER_CIRCLE) * DEGREES_PER_CIRCLE) + +// --- Conversion from Radians --- + +/** + * Converts an angle value in radians to N64 angle units (typically s16). + */ +#define RADIANS_TO_N64_ANGLE(rad_angle) \ + ((s16)(((rad_angle) / RADIANS_PER_CIRCLE) * N64_ANGLE_UNITS_PER_CIRCLE)) + +/** + * Converts an angle value in radians to degrees. + */ +#define RADIANS_TO_DEGREES(rad_angle) \ + ((rad_angle) * (DEGREES_PER_CIRCLE / RADIANS_PER_CIRCLE)) // Equivalent to (rad_angle) * (180.0f / M_PI) + +// --- Conversion from Degrees --- + +/** + * Converts an angle value in degrees to N64 angle units (typically s16). + */ +#define DEGREES_TO_N64_ANGLE(deg_angle) \ + ((s16)(((deg_angle) / DEGREES_PER_CIRCLE) * N64_ANGLE_UNITS_PER_CIRCLE)) + +/** + * Converts an angle value in degrees to radians. + */ +#define DEGREES_TO_RADIANS(deg_angle) \ + ((deg_angle) * (RADIANS_PER_CIRCLE / DEGREES_PER_CIRCLE)) // Equivalent to (deg_angle) * (M_PI / 180.0f) + +#endif // CONVERT_ANGLE_H \ No newline at end of file diff --git a/src/actors/blue_and_red_shells/update.inc.c b/src/actors/blue_and_red_shells/update.inc.c index 277ec20752..b5990af0bf 100644 --- a/src/actors/blue_and_red_shells/update.inc.c +++ b/src/actors/blue_and_red_shells/update.inc.c @@ -173,9 +173,9 @@ s16 func_802B3FD0(Player* owner, struct ShellActor* shell) { if (gPlayerBalloonCount[playerIndex] < 0) { continue; } - // func_802B51E8 is not quite a 3D distance function, it doubles (rather than squares) the Z difference of the + // calc_sq_xy_diff_plus_2_z_diff is not quite a 3D distance function, it doubles (rather than squares) the Z difference of the // positions - playerToShellDistance = func_802B51E8(player->pos, shell->pos); + playerToShellDistance = calc_sq_xy_diff_plus_2_z_diff(player->pos, shell->pos); if (playerToShellDistance < smallestDistance) { smallestDistance = playerToShellDistance; playerId = player - gPlayerOne; diff --git a/src/math_util_2.c b/src/math_util_2.c index dea1691b8f..585c1e36e6 100644 --- a/src/math_util_2.c +++ b/src/math_util_2.c @@ -327,24 +327,6 @@ s32 f32_step_towards(f32* value, f32 target, f32 step) { return targetReached; } -Vec3f* vec3f_normalize(Vec3f dest) { - f32 invsqrt = 1.0f / sqrtf(dest[0] * dest[0] + dest[1] * dest[1] + dest[2] * dest[2]); - - dest[0] = dest[0] * invsqrt; - dest[1] = dest[1] * invsqrt; - dest[2] = dest[2] * invsqrt; - return (Vec3f*) &dest; -} - -Vec3f* vec3f_cross_product(Vec3f dest, Vec3f arg1, Vec3f arg2) { - - dest[0] = (arg1[1] * arg2[2]) - (arg2[1] * arg1[2]); - dest[1] = (arg1[2] * arg2[0]) - (arg2[2] * arg1[0]); - dest[2] = (arg1[0] * arg2[1]) - (arg2[0] * arg1[1]); - - return (Vec3f*) &dest; -} - UNUSED s32 is_within_distance_2d(f32 x1, f32 y1, f32 x2, f32 y2, f32 distance) { f32 x; f32 y; @@ -934,13 +916,13 @@ void set_transform_matrix(Mat4 dest, Vec3f orientationVector, Vec3f positionVect Vec3f sp44 = {sins(rotationAngle), 0.0f, coss(rotationAngle)}; FrameInterpolation_RecordSetTransformMatrix(dest, orientationVector, positionVector, rotationAngle, scaleFactor); - vec3f_normalize(orientationVector); + glm_vec3_normalize(orientationVector); Vec3f sp38; - vec3f_cross_product(sp38, orientationVector, sp44); - vec3f_normalize(sp38); + glm_vec3_cross(orientationVector, sp44, sp38); + glm_vec3_normalize(sp38); Vec3f sp2C; - vec3f_cross_product(sp2C, sp38, orientationVector); - vec3f_normalize(sp2C); + glm_vec3_cross(sp38, orientationVector, sp2C); + glm_vec3_normalize(sp2C); dest[0][0] = sp38[0] * scaleFactor; dest[0][1] = sp38[1] * scaleFactor; @@ -960,45 +942,6 @@ void set_transform_matrix(Mat4 dest, Vec3f orientationVector, Vec3f positionVect dest[3][3] = 1.0f; } -// aplly to position a rotation and put in dest -UNUSED void vec3f_rotate(Vec3f dest, Vec3f pos, Vec3s rot) { - f32 sp74; - f32 sp70; - f32 sp6C; - f32 temp_f4; - f32 sp64; - f32 sp60; - f32 temp_f8; - f32 sp58; - f32 sp54; - f32 sine1; - f32 cosine1; - f32 sine2; - f32 cosine2; - f32 sine3; - f32 cosine3; - - sine1 = sins(rot[0]); - cosine1 = coss(rot[0]); - sine2 = sins(rot[1]); - cosine2 = coss(rot[1]); - sine3 = sins(rot[2]); - cosine3 = coss(rot[2]); - // it's a matrix multiplication - sp74 = pos[0] * ((cosine2 * cosine3) + ((sine1 * sine2) * sine3)); - temp_f4 = pos[1] * ((-cosine2 * sine3) + ((sine1 * sine2) * cosine3)); - temp_f8 = pos[2] * (cosine1 * sine2); - sp70 = pos[0] * (cosine1 * sine3); - sp64 = pos[1] * (cosine1 * cosine3); - sp58 = pos[2] * -sine1; - sp6C = pos[0] * ((-sine2 * cosine3) + ((sine1 * cosine2) * sine3)); - sp60 = pos[1] * ((sine2 * sine3) + ((sine1 * cosine2) * cosine3)); - sp54 = pos[2] * (cosine1 * cosine2); - dest[0] = sp74 + temp_f4 + temp_f8; - dest[1] = sp70 + sp64 + sp58; - dest[2] = sp6C + sp60 + sp54; -} - // apply to position a rotation x y only and put in dest void vec3f_rotate_x_y(Vec3f dest, Vec3f pos, Vec3s rot) { f32 sp2C; diff --git a/src/math_util_2.h b/src/math_util_2.h index 4059e715e4..336d9b094d 100644 --- a/src/math_util_2.h +++ b/src/math_util_2.h @@ -35,7 +35,6 @@ void func_8004252C(Mat4, u16, u16); void mtxf_mult_first_column(Mat4, f32); void mtxf_mult_second_column(Mat4, f32); void mtxf_mult_third_column(Mat4, f32); -void vec3f_rotate(Vec3f, Vec3f, Vec3s); void rsp_set_matrix_diff_translation_scale(Vec3f, Vec3f, f32); s32 f32_step_up_towards(f32*, f32, f32); @@ -48,8 +47,6 @@ s32 s16_step_down_towards(s16*, s16, s16); s32 u16_step_down_towards(u16*, s32, s32); s32 s16_step_towards(s16*, s16, s16); s32 f32_step_towards(f32*, f32, f32); -Vec3f* vec3f_normalize(Vec3f dest); -Vec3f* vec3f_cross_product(Vec3f, Vec3f, Vec3f); s32 func_80041658(f32, f32); f32 func_800416D8(f32 x, f32 z, u16 angle); f32 func_80041724(f32, f32, u16); diff --git a/src/racing/math_util.c b/src/racing/math_util.c index e358c760c6..453d571e21 100644 --- a/src/racing/math_util.c +++ b/src/racing/math_util.c @@ -12,6 +12,8 @@ #include "port/Game.h" #include #include +#include +#include "convert_angle.h" #pragma intrinsic(sqrtf, fabs) s32 D_802B91C0[2] = { 13, 13 }; @@ -52,28 +54,18 @@ s32 render_set_position(Mat4 mtx, s32 arg1) { return 1; } -f32 func_802B51E8(Vec3f arg0, Vec3f arg1) { - f32 sub_y; - f32 sub_z; - f32 sub_x; +f32 calc_sq_xy_diff_plus_2_z_diff(vec3 v1, vec3 v0) { + vec3 sub; + // Calculate the difference v1 - v0 + glm_vec3_sub(v1, v0, sub); - sub_x = arg1[0] - arg0[0]; - sub_y = arg1[1] - arg0[1]; - sub_z = arg1[2] - arg0[2]; - return (sub_x * sub_x) + (sub_y * sub_y) + sub_z + sub_z; -} + f32 sub_x_sq = sub[0] * sub[0]; + f32 sub_y_sq = sub[1] * sub[1]; -s32 get_angle_between_two_vectors(Vec3f arg0, Vec3f arg1) { - f32 temp_v1; - f32 temp_v2; - temp_v1 = arg1[0] - arg0[0]; - temp_v2 = arg1[2] - arg0[2]; - - return atan2s(temp_v1, temp_v2); + return sub_x_sq + sub_y_sq + (2.0f * sub[2]); } -// get_angle_between_two_vectors -u32 func_802B5258(Vec3f arg0, Vec3s arg1) { +s32 get_angle_between_two_vectors(Vec3f arg0, Vec3f arg1) { f32 temp_v1; f32 temp_v2; temp_v1 = arg1[0] - arg0[0]; @@ -106,25 +98,6 @@ void vec3s_copy(Vec3s dest, Vec3s src) { dest[2] = src[2]; } -// Copy mat1 to mat2 -void mtxf_copy(Mat4 mat1, Mat4 mat2) { - s32 row; - s32 column; - - for (row = 0; row < 4; row++) { - for (column = 0; column < 4; column++) { - mat2[row][column] = mat1[row][column]; - } - } -} - -// mtxf_copy -void mtxf_copy_n_element(s32* dest, s32* src, s32 n) { - while (n-- > 0) { - *dest++ = *src++; - } -} - // Transform a matrix to a matrix identity void mtxf_identity(Mat4 mtx) { register s32 i; @@ -166,13 +139,6 @@ void add_translate_mat4_vec3f(Mat4 mat, Mat4 dest, Vec3f pos) { */ } -// Light version of add_translate_mat4_vec3f -UNUSED void add_translate_mat4_vec3f_lite(Mat4 mat, Mat4 dest, Vec3f pos) { - dest[3][0] = mat[3][0] + pos[0]; - dest[3][1] = mat[3][1] + pos[1]; - dest[3][2] = mat[3][2] + pos[2]; -} - // create a translation matrix void mtxf_translate(Mat4 dest, Vec3f b) { FrameInterpolation_RecordMatrixTranslate(dest, b); @@ -1011,11 +977,11 @@ void func_802B7F7C(Vec3f arg0, Vec3f arg1, Vec3s dest) { } f32 sins(u16 arg0) { - return gSineTable[arg0 >> 4]; + return sinf(N64_ANGLE_TO_RADIANS(arg0)); } f32 coss(u16 arg0) { - return gCosineTable[arg0 >> 4]; + return cosf(N64_ANGLE_TO_RADIANS(arg0)); } s32 is_visible_between_angle(u16 arg0, u16 arg1, u16 arg2) { diff --git a/src/racing/math_util.h b/src/racing/math_util.h index 35947068fd..810653130b 100644 --- a/src/racing/math_util.h +++ b/src/racing/math_util.h @@ -21,17 +21,13 @@ double fabs(double x); void func_802B5794(Mat4, Vec3f, Vec3f); s32 render_set_position(Mat4, s32); -f32 func_802B51E8(Vec3f, Vec3f); +f32 calc_sq_xy_diff_plus_2_z_diff(Vec3f, Vec3f); s32 get_angle_between_two_vectors(Vec3f, Vec3f); -u32 func_802B5258(Vec3f, Vec3s); void func_802B5794(Mat4, Vec3f, Vec3f); void vec3s_set(Vec3s, s16, s16, s16); void vec3s_copy(Vec3s, Vec3s); -void mtxf_copy(Mat4, Mat4); -void mtxf_copy_n_element(s32*, s32*, s32); void mtxf_identity(Mat4); void add_translate_mat4_vec3f(Mat4, Mat4, Vec3f); -void add_translate_mat4_vec3f_lite(Mat4, Mat4, Vec3f); void mtxf_translate(Mat4, Vec3f); void func_802B5564(Mat4, u16*, f32, f32, f32, f32, f32); void func_802B5794(Mat4, Vec3f, Vec3f); @@ -69,7 +65,7 @@ f32 is_within_render_distance(Vec3f, Vec3f, u16, f32, f32, f32); extern s32 D_802B91C0[]; extern Vec3f D_802B91C8; -//extern Mtx gIdentityMatrix; +// extern Mtx gIdentityMatrix; #ifdef __cplusplus }