diff options
| author | MegaMech <7255464+MegaMech@users.noreply.github.com> | 2025-05-23 16:50:26 -0600 |
|---|---|---|
| committer | MegaMech <7255464+MegaMech@users.noreply.github.com> | 2025-05-23 16:50:26 -0600 |
| commit | 25b68921ad4cece662b2d20885103d8cc998dac5 (patch) | |
| tree | bff02190a71052cfc9897444b3e3e0fc19e20718 /src/engine | |
| parent | c4721b2df546b77773e184c8c2ce3b3d83b17542 (diff) | |
| parent | c2ddd2c25626b2797b9f730d77118f0e96131108 (diff) | |
Merge branch 'transformsharedfromptr' of https://github.com/HarbourMasters/SpaghettiKart into transformsharedfromptr
Diffstat (limited to 'src/engine')
| -rw-r--r-- | src/engine/World.cpp | 7 | ||||
| -rw-r--r-- | src/engine/World.h | 2 | ||||
| -rw-r--r-- | src/engine/actors/Finishline.cpp | 8 | ||||
| -rw-r--r-- | src/engine/actors/Finishline.h | 1 | ||||
| -rw-r--r-- | src/engine/editor/Editor.cpp | 19 | ||||
| -rw-r--r-- | src/engine/editor/Editor.h | 1 | ||||
| -rw-r--r-- | src/engine/editor/EditorMath.cpp | 4 | ||||
| -rw-r--r-- | src/engine/objects/Bat.cpp | 55 | ||||
| -rw-r--r-- | src/engine/objects/Boos.cpp | 11 | ||||
| -rw-r--r-- | src/engine/objects/Mole.cpp | 4 | ||||
| -rw-r--r-- | src/engine/objects/TrashBin.cpp | 2 | ||||
| -rw-r--r-- | src/engine/particles/StarEmitter.cpp | 5 |
12 files changed, 82 insertions, 37 deletions
diff --git a/src/engine/World.cpp b/src/engine/World.cpp index 39c3802c2..88c6717c6 100644 --- a/src/engine/World.cpp +++ b/src/engine/World.cpp @@ -22,6 +22,9 @@ extern "C" { } World::World() {} +World::~World() { + CM_CleanWorld(); +} Course* CurrentCourse; Cup* CurrentCup; @@ -81,6 +84,10 @@ u32 World::PreviousCup() { return 0; } +void World::SetCupIndex(size_t index) { + CupIndex = index; +} + void World::SetCup(Cup* cup) { if (cup) { CurrentCup = cup; diff --git a/src/engine/World.h b/src/engine/World.h index 2255a3e6a..f32cf00ff 100644 --- a/src/engine/World.h +++ b/src/engine/World.h @@ -52,6 +52,7 @@ class World { public: explicit World(); + ~World(); Course* AddCourse(std::unique_ptr<Course> course); @@ -82,6 +83,7 @@ public: void AddCup(Cup*); void SetCup(Cup* cup); + void SetCupIndex(size_t index); const char* GetCupName(); u32 GetCupIndex(); u32 NextCup(); diff --git a/src/engine/actors/Finishline.cpp b/src/engine/actors/Finishline.cpp index 0680e60bd..fb408bd14 100644 --- a/src/engine/actors/Finishline.cpp +++ b/src/engine/actors/Finishline.cpp @@ -6,6 +6,8 @@ #include "engine/Actor.h" #include "World.h" #include "assets/common_data.h" +#include "src/port/Game.h" +#include "port/interpolation/FrameInterpolation.h" extern "C" { #include "macros.h" @@ -17,6 +19,8 @@ extern f32 gKartHopInitialVelocityTable[]; extern f32 gKartGravityTable[]; } +size_t AFinishline::_count = 0; + AFinishline::AFinishline(std::optional<FVector> pos) { Name = "Finishline"; @@ -53,6 +57,8 @@ void AFinishline::Draw(Camera *camera) { return; } + FrameInterpolation_RecordOpenChild("Finishline", _count); + mtxf_pos_rotation_xyz(mtx, Pos, Rot); maxObjectsReached = render_set_position(mtx, 0) == 0; @@ -74,6 +80,8 @@ void AFinishline::Draw(Camera *camera) { } else { gSPDisplayList(gDisplayListHead++, (Gfx*)D_0D001BD8); } + + FrameInterpolation_RecordCloseChild(); } void AFinishline::Collision(Player* player, AActor* actor) {} diff --git a/src/engine/actors/Finishline.h b/src/engine/actors/Finishline.h index 61b561a5e..3c0e84de8 100644 --- a/src/engine/actors/Finishline.h +++ b/src/engine/actors/Finishline.h @@ -27,6 +27,7 @@ public: virtual void Collision(Player* player, AActor* actor) override; virtual bool IsMod() override; + static size_t _count; bool PickedUp = false; uint32_t Timer = 0; diff --git a/src/engine/editor/Editor.cpp b/src/engine/editor/Editor.cpp index 446da7487..23a947a09 100644 --- a/src/engine/editor/Editor.cpp +++ b/src/engine/editor/Editor.cpp @@ -30,6 +30,11 @@ namespace Editor { Editor::Editor() { } + Editor::~Editor() { + ClearObjects(); + ClearMatrixPool(); + } + void Editor::Load() { printf("Editor: Loading Editor...\n"); eObjectPicker.Load(); @@ -58,10 +63,16 @@ namespace Editor { Ship::Coords mousePos = wnd->GetMousePos(); bool isMouseDown = wnd->GetMouseState(Ship::LUS_MOUSE_BTN_LEFT); - eGameObjects.erase( - std::remove_if(eGameObjects.begin(), eGameObjects.end(), - [](const auto& object) { return (*object->DespawnFlag) == object->DespawnValue; }), - eGameObjects.end()); + auto it = std::remove_if(eGameObjects.begin(), eGameObjects.end(), + [](auto& object) { + if (*object->DespawnFlag == object->DespawnValue) { + delete object; // Free the pointed-to memory + return true; // Remove the pointer from the vector + } + return false; + }); + + eGameObjects.erase(it, eGameObjects.end()); if (isMouseDown && !wasMouseDown) { // Mouse just pressed (Pressed state) diff --git a/src/engine/editor/Editor.h b/src/engine/editor/Editor.h index 759c59355..60e578b21 100644 --- a/src/engine/editor/Editor.h +++ b/src/engine/editor/Editor.h @@ -14,6 +14,7 @@ namespace Editor { class Editor { public: Editor(); + ~Editor(); ObjectPicker eObjectPicker; std::vector<GameObject*> eGameObjects; diff --git a/src/engine/editor/EditorMath.cpp b/src/engine/editor/EditorMath.cpp index 04a299563..f3833008b 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++) { diff --git a/src/engine/objects/Bat.cpp b/src/engine/objects/Bat.cpp index 2056a17f7..e4f3a2086 100644 --- a/src/engine/objects/Bat.cpp +++ b/src/engine/objects/Bat.cpp @@ -23,7 +23,7 @@ OBat::OBat(const FVector& pos, const IRotator& rot) { Name = "Bat"; find_unused_obj_index(&_objectIndex); - init_texture_object(_objectIndex, (uint8_t*)d_course_banshee_boardwalk_bat_tlut, sBoardwalkTexList, 0x20U, + init_texture_object(_objectIndex, (uint8_t*) d_course_banshee_boardwalk_bat_tlut, sBoardwalkTexList, 0x20U, (u16) 0x00000040); gObjectList[_objectIndex].orientation[0] = rot.pitch; gObjectList[_objectIndex].orientation[1] = rot.roll; @@ -102,59 +102,64 @@ void OBat::Tick() { } void OBat::Draw(s32 cameraId) { - s32 var_s2; - s32 objectIndex; - Camera* temp_s7; + s32 i; + s32 objectIndex = _objectIndex; + Camera* cam = &camera1[cameraId]; - objectIndex = _objectIndex; - temp_s7 = &camera1[cameraId]; - OBat::func_80046F60((u8*)gObjectList[objectIndex].activeTLUT, (u8*)gObjectList[objectIndex].activeTexture, 0x00000020, 0x00000040, - 5); + OBat::func_80046F60((u8*) gObjectList[objectIndex].activeTLUT, (u8*) gObjectList[objectIndex].activeTexture, + 0x00000020, 0x00000040, 5); D_80183E80[0] = gObjectList[objectIndex].orientation[0]; 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]; + for (i = 0; i < 40; i++) { + objectIndex = gObjectParticle2[i]; if (objectIndex == -1) { continue; } if ((gObjectList[objectIndex].state >= 2) && (gMatrixHudCount < 0x2EF)) { + // @port: Tag the transform. + FrameInterpolation_RecordOpenChild("Bat set 1", (uintptr_t) &gObjectList[objectIndex]); + D_80183E80[1] = - func_800418AC(gObjectList[objectIndex].pos[0], gObjectList[objectIndex].pos[2], temp_s7->pos); + func_800418AC(gObjectList[objectIndex].pos[0], gObjectList[objectIndex].pos[2], cam->pos); func_800431B0(gObjectList[objectIndex].pos, D_80183E80, gObjectList[objectIndex].sizeScaling, - (Vtx*)D_0D0062B0); + (Vtx*) D_0D0062B0); + + // @port Pop the transform id. + FrameInterpolation_RecordCloseChild(); } - // @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]; + for (i = 0; i < 30; i++) { + + objectIndex = gObjectParticle3[i]; if (objectIndex == -1) { continue; } if ((gObjectList[objectIndex].state >= 2) && (gMatrixHudCount < 0x2EF)) { + // @port: Tag the transform. + FrameInterpolation_RecordOpenChild("Bat set 2", (uintptr_t) &gObjectList[objectIndex]); + D_80183E80[1] = - func_800418AC(gObjectList[objectIndex].pos[0], gObjectList[objectIndex].pos[2], temp_s7->pos); + func_800418AC(gObjectList[objectIndex].pos[0], gObjectList[objectIndex].pos[2], cam->pos); func_800431B0(gObjectList[objectIndex].pos, D_80183E80, gObjectList[objectIndex].sizeScaling, - (Vtx*)D_0D0062B0); + (Vtx*) D_0D0062B0); + + // @port Pop the transform id. + FrameInterpolation_RecordCloseChild(); } - // @port Pop the transform id. - FrameInterpolation_RecordCloseChild(); } } gSPTexture(gDisplayListHead++, 0x0001, 0x0001, 0, G_TX_RENDERTILE, G_OFF); } void OBat::func_80046F60(u8* tlut, u8* arg1, s32 arg2, s32 arg3, s32 arg4) { - gSPDisplayList(gDisplayListHead++, (Gfx*)D_0D007D78); + gSPDisplayList(gDisplayListHead++, (Gfx*) D_0D007D78); gDPLoadTLUT_pal256(gDisplayListHead++, tlut); rsp_load_texture_mask(arg1, arg2, arg3, arg4); } diff --git a/src/engine/objects/Boos.cpp b/src/engine/objects/Boos.cpp index 69bb95072..5f02d7876 100644 --- a/src/engine/objects/Boos.cpp +++ b/src/engine/objects/Boos.cpp @@ -83,20 +83,23 @@ 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); if (CVarGetInteger("gNoCulling", 0) == 1) { temp_s2 = MIN(temp_s2, 0x15F91U); } + + // @port: Tag the transform. + FrameInterpolation_RecordOpenChild("Boo", (uintptr_t)&gObjectList[objectIndex]); + if (is_obj_flag_status_active(objectIndex, VISIBLE) != 0) { func_800523B8(objectIndex, cameraId, temp_s2); } + + // @port Pop the transform id. + FrameInterpolation_RecordCloseChild(); } - // @port Pop the transform id. - FrameInterpolation_RecordCloseChild(); } } diff --git a/src/engine/objects/Mole.cpp b/src/engine/objects/Mole.cpp index 91eeabebf..f623b1f52 100644 --- a/src/engine/objects/Mole.cpp +++ b/src/engine/objects/Mole.cpp @@ -323,6 +323,7 @@ void OMole::func_800821AC(s32 objectIndex, s32 arg1) { } } +// Holes void OMole::func_80054E10(s32 objectIndex) { if (gObjectList[objectIndex].state > 0) { if (is_obj_flag_status_active(objectIndex, 0x00800000) != 0) { @@ -362,7 +363,7 @@ void OMole::func_80054D00(s32 objectIndex, s32 cameraId) { if (is_obj_flag_status_active(objectIndex, VISIBLE) != 0) { // @port: Tag the transform. - FrameInterpolation_RecordOpenChild("func_80054D00", TAG_OBJECT(&gObjectList[objectIndex])); + FrameInterpolation_RecordOpenChild("func_80054D00", (uintptr_t)&gObjectList[objectIndex]); D_80183E80[0] = (s16) gObjectList[objectIndex].orientation[0]; D_80183E80[1] = @@ -378,6 +379,7 @@ void OMole::func_80054D00(s32 objectIndex, s32 cameraId) { } } +// Mole rocks void OMole::func_80054F04(s32 cameraId) { Camera* camera = &camera1[cameraId]; diff --git a/src/engine/objects/TrashBin.cpp b/src/engine/objects/TrashBin.cpp index dc62626dc..57c702275 100644 --- a/src/engine/objects/TrashBin.cpp +++ b/src/engine/objects/TrashBin.cpp @@ -65,7 +65,7 @@ void OTrashBin::Draw(s32 cameraId) { Vec3s Rot = { 0, 0x4000, 0 }; // @port: Tag the transform. - FrameInterpolation_RecordOpenChild("Bin", mtx); + FrameInterpolation_RecordOpenChild("OTrashBin", (uintptr_t) object); mtxf_pos_rotation_xyz(mtx, Pos, Rot); //mtxf_scale(mtx, 1.0f); diff --git a/src/engine/particles/StarEmitter.cpp b/src/engine/particles/StarEmitter.cpp index 242e1a75a..7cb9d9979 100644 --- a/src/engine/particles/StarEmitter.cpp +++ b/src/engine/particles/StarEmitter.cpp @@ -1,6 +1,7 @@ #include "StarEmitter.h" +#include "port/interpolation/FrameInterpolation.h" extern "C" { #include "render_objects.h" @@ -107,9 +108,13 @@ void StarEmitter::Draw(s32 cameraId) { // func_80054BE8 D_80183E80[0] = 0; for (var_s0 = 0; var_s0 < gObjectParticle3_SIZE; var_s0++) { temp_a0 = ObjectIndex[var_s0]; + // @port: Tag the transform. + FrameInterpolation_RecordOpenChild("Ceremony Stars", (uintptr_t) &ObjectIndex[var_s0]); if ((temp_a0 != -1) && (gObjectList[temp_a0].state >= 2)) { StarEmitter::func_80054AFC(temp_a0, camera->pos); } + // @port Pop the transform id. + FrameInterpolation_RecordCloseChild(); } } |
