diff options
| author | Sonic Dreamcaster <alejandro.asenjo88@gmail.com> | 2025-05-20 21:51:19 -0300 |
|---|---|---|
| committer | Sonic Dreamcaster <alejandro.asenjo88@gmail.com> | 2025-05-20 21:51:19 -0300 |
| commit | 1812219588c5d81d6f34648d400bd124434e0916 (patch) | |
| tree | 20a64c5d2213c4793768e359b2f80cc36ac827e1 | |
| parent | a33f296e0f0b55106d5f4744798e00b2fffd7620 (diff) | |
| parent | c10361ea799c5e4ad3c00ebfe0c4d5aba2670dc1 (diff) | |
Merge branch 'transformfuncsforint' of https://github.com/HarbourMasters/SpaghettiKart into transformfuncsforint
| -rw-r--r-- | src/engine/editor/EditorMath.cpp | 8 | ||||
| -rw-r--r-- | src/engine/objects/Bat.cpp | 9 | ||||
| -rw-r--r-- | src/engine/objects/Boos.cpp | 5 | ||||
| -rw-r--r-- | src/engine/objects/TrashBin.cpp | 8 | ||||
| -rw-r--r-- | src/racing/skybox_and_splitscreen.c | 62 | ||||
| -rw-r--r-- | src/render_objects.c | 4 |
6 files changed, 51 insertions, 45 deletions
diff --git a/src/engine/editor/EditorMath.cpp b/src/engine/editor/EditorMath.cpp index 44923e08e..04a299563 100644 --- a/src/engine/editor/EditorMath.cpp +++ b/src/engine/editor/EditorMath.cpp @@ -31,9 +31,9 @@ bool IsInGameScreen() { // Define viewport boundaries auto gfx_current_game_window_viewport = GetInterpreter()->mGameWindowViewport; - int left = gfx_current_game_window_viewport.width; + int left = gfx_current_game_window_viewport.x; int right = left + OTRGetGameRenderWidth(); - int top = gfx_current_game_window_viewport.height; + int top = gfx_current_game_window_viewport.y; int bottom = top + OTRGetGameRenderHeight(); // Check if the mouse is within the game render area @@ -46,8 +46,8 @@ FVector ScreenRayTrace() { Ship::Coords mouse = wnd->GetMousePos(); auto gfx_current_game_window_viewport = GetInterpreter()->mGameWindowViewport; - mouse.x -= gfx_current_game_window_viewport.width; - mouse.y -= gfx_current_game_window_viewport.height; + mouse.x -= gfx_current_game_window_viewport.x; + mouse.y -= gfx_current_game_window_viewport.y; // Get screen dimensions uint32_t width = OTRGetGameViewportWidth(); uint32_t height = OTRGetGameViewportHeight(); diff --git a/src/engine/objects/Bat.cpp b/src/engine/objects/Bat.cpp index 764476064..2056a17f7 100644 --- a/src/engine/objects/Bat.cpp +++ b/src/engine/objects/Bat.cpp @@ -1,6 +1,7 @@ #include "Bat.h" #include "World.h" #include "CoreMath.h" +#include "port/interpolation/FrameInterpolation.h" extern "C" { #include "render_objects.h" @@ -113,6 +114,8 @@ void OBat::Draw(s32 cameraId) { D_80183E80[2] = gObjectList[objectIndex].orientation[2]; if ((D_8018CFB0 != 0) || (D_8018CFC8 != 0)) { for (var_s2 = 0; var_s2 < 40; var_s2++) { + // @port: Tag the transform. + FrameInterpolation_RecordOpenChild("Bat set 1", var_s2); objectIndex = gObjectParticle2[var_s2]; if (objectIndex == -1) { continue; @@ -124,10 +127,14 @@ void OBat::Draw(s32 cameraId) { func_800431B0(gObjectList[objectIndex].pos, D_80183E80, gObjectList[objectIndex].sizeScaling, (Vtx*)D_0D0062B0); } + // @port Pop the transform id. + FrameInterpolation_RecordCloseChild(); } } if ((D_8018CFE8 != 0) || (D_8018D000 != 0)) { for (var_s2 = 0; var_s2 < 30; var_s2++) { + // @port: Tag the transform. + FrameInterpolation_RecordOpenChild("Bat set 2", var_s2); objectIndex = gObjectParticle3[var_s2]; if (objectIndex == -1) { continue; @@ -139,6 +146,8 @@ void OBat::Draw(s32 cameraId) { func_800431B0(gObjectList[objectIndex].pos, D_80183E80, gObjectList[objectIndex].sizeScaling, (Vtx*)D_0D0062B0); } + // @port Pop the transform id. + FrameInterpolation_RecordCloseChild(); } } gSPTexture(gDisplayListHead++, 0x0001, 0x0001, 0, G_TX_RENDERTILE, G_OFF); diff --git a/src/engine/objects/Boos.cpp b/src/engine/objects/Boos.cpp index 5bdbd41cf..69bb95072 100644 --- a/src/engine/objects/Boos.cpp +++ b/src/engine/objects/Boos.cpp @@ -1,6 +1,7 @@ #include "Boos.h" #include "World.h" #include "CoreMath.h" +#include "port/interpolation/FrameInterpolation.h" extern "C" { #include "render_objects.h" @@ -82,6 +83,8 @@ void OBoos::Draw(s32 cameraId) { s32 objectIndex; for (size_t i = 0; i < _numBoos; i++) { + // @port: Tag the transform. + FrameInterpolation_RecordOpenChild("Boo", i); objectIndex = _indices[i]; //indexObjectList3[i]; if (gObjectList[objectIndex].state >= 2) { temp_s2 = func_8008A364(objectIndex, cameraId, 0x4000U, 0x00000320); @@ -92,6 +95,8 @@ void OBoos::Draw(s32 cameraId) { func_800523B8(objectIndex, cameraId, temp_s2); } } + // @port Pop the transform id. + FrameInterpolation_RecordCloseChild(); } } diff --git a/src/engine/objects/TrashBin.cpp b/src/engine/objects/TrashBin.cpp index c94d0352f..e721f299c 100644 --- a/src/engine/objects/TrashBin.cpp +++ b/src/engine/objects/TrashBin.cpp @@ -3,6 +3,7 @@ #include "TrashBin.h" #include "World.h" #include "port/Game.h" +#include "port/interpolation/FrameInterpolation.h" extern "C" { #include "main.h" @@ -62,11 +63,18 @@ void OTrashBin::Draw(s32 cameraId) { Mat4 mtx; Vec3f Pos = { _pos.x + 63, _pos.y + 12, _pos.z + 25 }; Vec3s Rot = { 0, 0x4000, 0 }; + + // @port: Tag the transform. + FrameInterpolation_RecordOpenChild("Bin", mtx); + mtxf_pos_rotation_xyz(mtx, Pos, Rot); //mtxf_scale(mtx, 1.0f); if (render_set_position(mtx, 0) != 0) { gSPDisplayList(gDisplayListHead++, BinMod); } + + // @port Pop the transform id. + FrameInterpolation_RecordCloseChild(); } } } diff --git a/src/racing/skybox_and_splitscreen.c b/src/racing/skybox_and_splitscreen.c index 87fa1390f..820d83ecb 100644 --- a/src/racing/skybox_and_splitscreen.c +++ b/src/racing/skybox_and_splitscreen.c @@ -756,6 +756,7 @@ void func_802A5760(void) { } } +// Setup the cameras perspective and lookAt (movement/rotation) void setup_camera(Camera* camera, s32 playerId, s32 cameraId, struct UnkStruct_800DC5EC* screen) { Mat4 matrix; u16 perspNorm; @@ -765,26 +766,19 @@ void setup_camera(Camera* camera, s32 playerId, s32 cameraId, struct UnkStruct_8 return; } - FrameInterpolation_RecordOpenChild("camerapersp", FrameInterpolation_GetCameraEpoch()); + // Setup perspective (camera movement) + FrameInterpolation_RecordOpenChild("camera", FrameInterpolation_GetCameraEpoch()); guPerspective(&gGfxPool->mtxPersp[cameraId], &perspNorm, gCameraZoom[cameraId], gScreenAspect, - CM_GetProps()->NearPersp, CM_GetProps()->FarPersp, 1.0f); - + CM_GetProps()->NearPersp, CM_GetProps()->FarPersp, 1.0f); gSPPerspNormalize(gDisplayListHead++, perspNorm); gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPersp[cameraId]), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + // Setup lookAt (camera rotation) guLookAt(&gGfxPool->mtxLookAt[cameraId], camera->pos[0], camera->pos[1], camera->pos[2], camera->lookAt[0], camera->lookAt[1], camera->lookAt[2], camera->up[0], camera->up[1], camera->up[2]); - if (D_800DC5C8 == 0) { - gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxLookAt[cameraId]), - G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION); - mtxf_identity(matrix); - render_set_position(matrix, 0); - } else { - gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxLookAt[cameraId]), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - } + gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxLookAt[cameraId]), + G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION); FrameInterpolation_RecordCloseChild(); } @@ -870,36 +864,22 @@ D_func_800652D4_counter = 0; func_802A3730(screen); gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); - //FrameInterpolation_RecordOpenChild("SCREENCAMERA", (playerId | cameraId) << 8); - - setup_camera(camera, playerId, cameraId, screen); // Setup camera perspective and lookAt -// render_course(screen); - -//FrameInterpolation_RecordOpenChild("track", 0); -//Mat4 trackMtx; -//mtxf_identity(trackMtx); -//AddObjectMatrix(trackMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); -render_course(screen); -//FrameInterpolation_RecordCloseChild(); - - - //Mat4 projectionF; - //Matrix_MtxToMtxF(&gGfxPool->mtxLookAt[cameraId], &projectionF); - // SkinMatrix_MtxFMtxFMult(&projectionF, &flipF, &projectionF); - // FrameInterpolation_RecordCloseChild(); - - - if (D_800DC5C8 == 1) { - //PushLookAtMtx(gGfxPool->mtxLookAt[cameraId], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION); - gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxLookAt[cameraId]), - G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION); - mtxf_identity(matrix); - render_set_position(matrix, 0); - } + // Setup camera perspective and lookAt + setup_camera(camera, playerId, cameraId, screen); + + // Create a matrix for the track and game objects + FrameInterpolation_RecordOpenChild("track", (playerId | cameraId) << 8); + Mat4 trackMatrix; + mtxf_identity(trackMatrix); + render_set_position(trackMatrix, 0); + + // Draw course and game objects + render_course(screen); render_course_actors(screen); CM_DrawStaticMeshActors(); render_object(mode); + switch (screenId) { case 0: render_players_on_screen_one(); @@ -946,7 +926,7 @@ render_course(screen); if (mode != RENDER_SCREEN_MODE_1P_PLAYER_ONE) { gNumScreens += 1; } - + FrameInterpolation_RecordCloseChild(); } void func_802A74BC(void) { diff --git a/src/render_objects.c b/src/render_objects.c index 0bfef1437..e97e9ea1c 100644 --- a/src/render_objects.c +++ b/src/render_objects.c @@ -2629,6 +2629,8 @@ void draw_simplified_lap_count(s32 playerId) { } void func_8004E800(s32 playerId) { + // @port: Tag the transform. + FrameInterpolation_RecordOpenChild("Player place HUD", playerId << 8); if (playerHUD[playerId].unk_81 != 0) { if (playerHUD[playerId].lapCount != 3) { func_8004A384(playerHUD[playerId].rankX + playerHUD[playerId].slideRankX, @@ -2644,6 +2646,8 @@ void func_8004E800(s32 playerId) { 0x00000040, 0x00000080, 0x00000040); } } + // @port Pop the transform id. + FrameInterpolation_RecordCloseChild(); } void func_8004E998(s32 playerId) { |
