summaryrefslogtreecommitdiff
path: root/src/engine/objects
diff options
context:
space:
mode:
authorMegaMech <MegaMech@users.noreply.github.com>2025-05-14 18:30:32 -0600
committerGitHub <noreply@github.com>2025-05-14 18:30:32 -0600
commit32632cacdb316d7f2d3b6ecdb634f0ef9aebadf0 (patch)
treed374a84675fc0f49100c275aa34828bc9db538f8 /src/engine/objects
parent70f049cb6c326dede27e0ba7e88ac0d67b7651a4 (diff)
Impl new intro (#193)
* Update menus * Update CMakeLists.txt * Add Ship * Impl hm ship actors * Update HM course * Impl new intro * Finish intro scene * Rename * Start Editor Work * raycast works * Fix ScreenRayTrace in widescreen * Basic Actor Picking * wip * Editor use vtx collision * gizmo work * otr works for object picking * Impl objects for editor * actor init * Update * Add all axis move (freemove) * Docking Windows works here * Setup imgui layout for editor * Editor Snap to Ground works * Basic Scene Explorer Works * Editor get actor names * Impl editor object names * impl Editor Play and Pause buttons * Editor translate works while paused * Fix freecam lighting * Added adjustable track properties to editor * Editor matrix, icons, rotation, impl light * Setup Track Properties 1 * Editor tooling wip * Load modded o2rs * Don't enable hud if editor is enabled * Updates * SceneManager nearly working * Fix mario kart 64 intro logo sizing * Fix Rotator * Finish new matrix translation code * Cleanup headers * Cleanup * Cleanup 2 * Cleanup 3 * Prevent divize by zero crash * Add visible circle for translate in all axis * Editor scaling/rot works properly now * Scale All_Axis evenly * Fixes to includes to work on Linux. * Removed overfilled arguments in gfx_create_framebuffer() * Added missing function definitions to Game.h * Editor sun face the camera * Add rotation model to gizmo * Add new handles * Failed attempt at transforming collision * Impl water volume * Import fast64 paths * water surface * Scene Setup 1 * Custom Track O2R almost working needs testing * Custom Track Load path O2r * Render custom track. Wip collision * Add missing function * Debug Spawning Custom O2R Track * Import courses working now * Fix memory leak * Remove New Track Button * Engine.cpp more consistent with sf64 * Fix Editor Enable Button * Editor Accurate mouse click drag objects * Editor selects closest object and cleanup * Gizmo rot and scale collision working * Remove constexpr from IRotator * Impl properties for location/rot/scale * Better Properties display, swap rot handles * Fix content browser dock and editor now disabled by default * Remove GameInfoWindow, Multiplayer Button, and FPS Slider * Disable Editor when its disabled * Add new logo to hm intro * Fix pause menu item box cursor * Remove minimap from Course::from_json and to_json * Impl Import Minimap * Fix custom minimap rendering * minimap uses extension .png * Refactor minimap * Freecam only for player 1 * GrandPrix Balloons work in custom track * Track Id is now std::string and outside of Props * Moved editor assets to be included in ship.o2r * Fixed GenerateO2R to package the correct folder and save to the correct filename * Linux specific changes. * Added "#include <stdio.h>" that required them * Changed how the "ship.o2r" file is loaded to allow it to load the file from within appimages. * Changed the Linuxdeploy version to avoid errors later when the Github Actions creates appimages(same fix applied to other ports.) * Revert "Moved editor assets to be included in ship.o2r" This reverts commit 05704c01f761baa67a83e357d9765f5c6b5e3fdb. * Added back files(this time without LUS changes) * Changed workflow file to use correct filename for assets file. * Missed a few spots in the workflow file. * Added .desktop file and made corrections to the main workflow. * Added the rest of upstream CMakeLists.txt * disabled USE_NETWORKING * New InverseMatrix * Renamed both .o2r files to be more accurate to its contents. * Reverted CmakeList.txt --------- Co-authored-by: MegaMech <7255464+MegaMech@users.noreply.github.com> Co-authored-by: sitton76 <58642183+sitton76@users.noreply.github.com>
Diffstat (limited to 'src/engine/objects')
-rw-r--r--src/engine/objects/Bat.cpp4
-rw-r--r--src/engine/objects/Bat.h6
-rw-r--r--src/engine/objects/BombKart.cpp39
-rw-r--r--src/engine/objects/BombKart.h3
-rw-r--r--src/engine/objects/Boos.cpp1
-rw-r--r--src/engine/objects/ChainChomp.cpp3
-rw-r--r--src/engine/objects/CheepCheep.cpp1
-rw-r--r--src/engine/objects/Crab.cpp1
-rw-r--r--src/engine/objects/Crab.h1
-rw-r--r--src/engine/objects/Flagpole.cpp1
-rw-r--r--src/engine/objects/Flagpole.h1
-rw-r--r--src/engine/objects/GrandPrixBalloons.cpp231
-rw-r--r--src/engine/objects/GrandPrixBalloons.h55
-rw-r--r--src/engine/objects/Hedgehog.cpp2
-rw-r--r--src/engine/objects/HotAirBalloon.cpp1
-rw-r--r--src/engine/objects/HotAirBalloon.h1
-rw-r--r--src/engine/objects/Lakitu.cpp1
-rw-r--r--src/engine/objects/Mole.cpp1
-rw-r--r--src/engine/objects/Mole.h1
-rw-r--r--src/engine/objects/Object.cpp2
-rw-r--r--src/engine/objects/Object.h4
-rw-r--r--src/engine/objects/Penguin.cpp9
-rw-r--r--src/engine/objects/Penguin.h3
-rw-r--r--src/engine/objects/Podium.cpp2
-rw-r--r--src/engine/objects/Seagull.cpp1
-rw-r--r--src/engine/objects/Seagull.h1
-rw-r--r--src/engine/objects/Snowman.cpp2
-rw-r--r--src/engine/objects/Snowman.h1
-rw-r--r--src/engine/objects/Thwomp.cpp1
-rw-r--r--src/engine/objects/Thwomp.h1
-rw-r--r--src/engine/objects/TrashBin.cpp3
-rw-r--r--src/engine/objects/TrashBin.h5
-rw-r--r--src/engine/objects/Trophy.cpp1
-rw-r--r--src/engine/objects/Trophy.h1
34 files changed, 342 insertions, 49 deletions
diff --git a/src/engine/objects/Bat.cpp b/src/engine/objects/Bat.cpp
index b90f7c857..764476064 100644
--- a/src/engine/objects/Bat.cpp
+++ b/src/engine/objects/Bat.cpp
@@ -18,8 +18,8 @@ const char* sBoardwalkTexList[] = { gTextureBat1, gTextureBat2, gTextureBat3, gT
size_t OBat::_count = 0;
-OBat::OBat(const FVector& pos, const FRotation& rot) {
-
+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,
diff --git a/src/engine/objects/Bat.h b/src/engine/objects/Bat.h
index f9e0df074..d6b7e8774 100644
--- a/src/engine/objects/Bat.h
+++ b/src/engine/objects/Bat.h
@@ -21,14 +21,14 @@ extern "C" {
/**
* OBat
*
- * FRotation does not appear to do anything.
+ * IRotator does not appear to do anything.
* Could not find where origin_pos was at.
* So pos does not work either
*
*/
class OBat : public OObject {
public:
- explicit OBat(const FVector& pos, const FRotation& rot);
+ explicit OBat(const FVector& pos, const IRotator& rot);
~OBat() {
_count--;
@@ -51,10 +51,8 @@ public:
void func_8007D794(s32 objectIndex);
void func_8007DA4C(s32 objectIndex);
-
private:
FVector _pos;
static size_t _count;
size_t _idx;
- s32 _objectIndex;
};
diff --git a/src/engine/objects/BombKart.cpp b/src/engine/objects/BombKart.cpp
index fc27103ed..53b4a4262 100644
--- a/src/engine/objects/BombKart.cpp
+++ b/src/engine/objects/BombKart.cpp
@@ -29,7 +29,8 @@ extern s8 gPlayerCount;
size_t OBombKart::_count = 0;
-OBombKart::OBombKart(Vec3f pos, TrackWaypoint* waypoint, uint16_t waypointIndex, uint16_t state, f32 unk_3C) {
+OBombKart::OBombKart(FVector pos, TrackWaypoint* waypoint, uint16_t waypointIndex, uint16_t state, f32 unk_3C) {
+ Name = "Bomb Kart";
_idx = _count;
Vec3f _pos = {0, 0, 0};
@@ -41,10 +42,10 @@ OBombKart::OBombKart(Vec3f pos, TrackWaypoint* waypoint, uint16_t waypointIndex,
// Set height to the default value of 2000.0f unless Pos[1] is higher.
// This allows placing these on very high surfaces.
- f32 height = (pos[1] > 2000.0f) ? pos[1] : 2000.0f;
- _pos[0] = pos[0];
- _pos[1] = spawn_actor_on_surface(pos[0], height, pos[2]);
- _pos[2] = pos[2];
+ f32 height = (pos.y > 2000.0f) ? pos.y : 2000.0f;
+ _pos[0] = pos.x;
+ _pos[1] = spawn_actor_on_surface(pos.x, height, pos.z);
+ _pos[2] = pos.z;
}
WaypointIndex = waypointIndex;
@@ -72,7 +73,7 @@ OBombKart::OBombKart(Vec3f pos, TrackWaypoint* waypoint, uint16_t waypointIndex,
WheelPos[3][2] = _pos[2];
check_bounding_collision(&_Collision, 2.0f, _pos[0], _pos[1], _pos[2]);
- find_unused_obj_index(&ObjectIndex);
+ find_unused_obj_index(&_objectIndex);
_count++;
}
@@ -329,7 +330,7 @@ void OBombKart::Tick() {
void OBombKart::Draw(s32 cameraId) {
if (gModeSelection == BATTLE) {
for (size_t playerId = 0; playerId < NUM_BOMB_KARTS_BATTLE; playerId++) {
- Object* object = &gObjectList[ObjectIndex];
+ Object* object = &gObjectList[_objectIndex];
if (object->state != 0) {
s32 primAlpha = object->primAlpha;
Player* player = &gPlayerOne[playerId];
@@ -337,9 +338,9 @@ void OBombKart::Draw(s32 cameraId) {
object->pos[1] = player->pos[1] - 2.0;
object->pos[2] = player->pos[2];
object->surfaceHeight = player->unk_074;
- func_800563DC(ObjectIndex, cameraId, primAlpha);
- func_8005669C(ObjectIndex, cameraId, primAlpha);
- func_800568A0(ObjectIndex, cameraId);
+ func_800563DC(_objectIndex, cameraId, primAlpha);
+ func_8005669C(_objectIndex, cameraId, primAlpha);
+ func_800568A0(_objectIndex, cameraId);
}
}
return;
@@ -358,27 +359,27 @@ void OBombKart::Draw(s32 cameraId) {
}
Camera* camera = &camera1[cameraId];
if (cameraId == PLAYER_ONE) {
- if (is_obj_flag_status_active(ObjectIndex, 0x00200000) != 0) {
+ if (is_obj_flag_status_active(_objectIndex, 0x00200000) != 0) {
Unk_4A = 0;
} else if (gGamestate != ENDING) {
Unk_4A = 1;
}
- clear_object_flag(ObjectIndex, 0x00200000);
+ clear_object_flag(_objectIndex, 0x00200000);
}
// huh???
s32 state = State;
if (State != States::DISABLED) {
- gObjectList[ObjectIndex].pos[0] = Pos[0];
- gObjectList[ObjectIndex].pos[1] = Pos[1];
- gObjectList[ObjectIndex].pos[2] = Pos[2];
- s32 temp_s4 = func_8008A364(ObjectIndex, cameraId, 0x31C4U, 0x000001F4);
- if (is_obj_flag_status_active(ObjectIndex, VISIBLE) != 0) {
- set_object_flag(ObjectIndex, 0x00200000);
+ gObjectList[_objectIndex].pos[0] = Pos[0];
+ gObjectList[_objectIndex].pos[1] = Pos[1];
+ gObjectList[_objectIndex].pos[2] = Pos[2];
+ s32 temp_s4 = func_8008A364(_objectIndex, cameraId, 0x31C4U, 0x000001F4);
+ if (is_obj_flag_status_active(_objectIndex, VISIBLE) != 0) {
+ set_object_flag(_objectIndex, 0x00200000);
D_80183E80[0] = 0;
D_80183E80[1] = func_800418AC(Pos[0], Pos[2], camera->pos);
D_80183E80[2] = 0x8000;
- func_800563DC(ObjectIndex, cameraId, 0x000000FF);
+ func_800563DC(_objectIndex, cameraId, 0x000000FF);
OBombKart::SomeRender(camera->pos);
if (((u32) temp_s4 < 0x4E21U) && (state != BOMB_STATE_EXPLODED)) {
OBombKart::LoadMtx();
diff --git a/src/engine/objects/BombKart.h b/src/engine/objects/BombKart.h
index 3663ee664..29069a00f 100644
--- a/src/engine/objects/BombKart.h
+++ b/src/engine/objects/BombKart.h
@@ -47,11 +47,10 @@ public:
u16 Unk_4A = 0;
s16 Unk_4C = 1;
f32 CenterY; // Center of the circle
- s32 ObjectIndex = 0; // Index into gObjectList
Collision _Collision;
// Set waypoint to NULL if using a spawn position and not a waypoint.
- explicit OBombKart(Vec3f pos, TrackWaypoint* waypoint, uint16_t waypointIndex, uint16_t state, f32 unk_3C);
+ explicit OBombKart(FVector pos, TrackWaypoint* waypoint, uint16_t waypointIndex, uint16_t state, f32 unk_3C);
~OBombKart() {
_count--;
diff --git a/src/engine/objects/Boos.cpp b/src/engine/objects/Boos.cpp
index f06abc8f7..5bdbd41cf 100644
--- a/src/engine/objects/Boos.cpp
+++ b/src/engine/objects/Boos.cpp
@@ -23,6 +23,7 @@ extern "C" {
size_t OBoos::_count = 0;
OBoos::OBoos(size_t numBoos, const IPathSpan& leftBoundary, const IPathSpan& active, const IPathSpan& rightBoundary) {
+ Name = "Boos";
// Max five boos allowed due to limited splines
// D_800E5D9C
if (numBoos > 10) {
diff --git a/src/engine/objects/ChainChomp.cpp b/src/engine/objects/ChainChomp.cpp
index 1008aab52..695df1e8a 100644
--- a/src/engine/objects/ChainChomp.cpp
+++ b/src/engine/objects/ChainChomp.cpp
@@ -17,9 +17,10 @@ extern "C" {
size_t OChainChomp::_count = 0;
OChainChomp::OChainChomp() {
+ Name = "Chain Chomp";
_idx = _count;
init_object(indexObjectList2[_count], 0);
-
+ _objectIndex = indexObjectList2[_count];
_count++;
}
diff --git a/src/engine/objects/CheepCheep.cpp b/src/engine/objects/CheepCheep.cpp
index 10cdf6602..5b4157c61 100644
--- a/src/engine/objects/CheepCheep.cpp
+++ b/src/engine/objects/CheepCheep.cpp
@@ -18,6 +18,7 @@ extern Lights1 D_800E45C0[];
}
OCheepCheep::OCheepCheep(const FVector& pos, CheepType type, IPathSpan span) {
+ Name = "Cheep Cheep";
_type = type;
_spawnPos = pos;
_span = span;
diff --git a/src/engine/objects/Crab.cpp b/src/engine/objects/Crab.cpp
index c722a9037..82d2b9330 100644
--- a/src/engine/objects/Crab.cpp
+++ b/src/engine/objects/Crab.cpp
@@ -28,6 +28,7 @@ extern "C" {
size_t OCrab::_count = 0;
OCrab::OCrab(const FVector2D& start, const FVector2D& end) {
+ Name = "Crab";
_idx = _count;
_start = start;
_end = end;
diff --git a/src/engine/objects/Crab.h b/src/engine/objects/Crab.h
index 2d1ef5e93..4cadd3b87 100644
--- a/src/engine/objects/Crab.h
+++ b/src/engine/objects/Crab.h
@@ -46,5 +46,4 @@ private:
FVector2D _end;
static size_t _count;
s32 _idx;
- s32 _objectIndex;
};
diff --git a/src/engine/objects/Flagpole.cpp b/src/engine/objects/Flagpole.cpp
index 7b5e5af20..acd74ba2b 100644
--- a/src/engine/objects/Flagpole.cpp
+++ b/src/engine/objects/Flagpole.cpp
@@ -16,6 +16,7 @@ extern "C" {
size_t OFlagpole::_count = 0;
OFlagpole::OFlagpole(const FVector& pos, s16 direction) {
+ Name = "Flagpole";
_idx = _count;
_pos = pos;
_direction = direction;
diff --git a/src/engine/objects/Flagpole.h b/src/engine/objects/Flagpole.h
index 034db865e..5824fcf18 100644
--- a/src/engine/objects/Flagpole.h
+++ b/src/engine/objects/Flagpole.h
@@ -42,5 +42,4 @@ private:
s16 _direction;
static size_t _count;
size_t _idx;
- s32 _objectIndex;
};
diff --git a/src/engine/objects/GrandPrixBalloons.cpp b/src/engine/objects/GrandPrixBalloons.cpp
new file mode 100644
index 000000000..819bde1c6
--- /dev/null
+++ b/src/engine/objects/GrandPrixBalloons.cpp
@@ -0,0 +1,231 @@
+#include "GrandPrixBalloons.h"
+
+#include "port/Game.h"
+#include "assets/other_textures.h"
+#include "assets/common_data.h"
+
+extern "C" {
+#include "update_objects.h"
+#include "render_objects.h"
+#include "code_80057C60.h"
+#include "code_80086E70.h"
+#include "math_util.h"
+#include "math_util_2.h"
+#include "menus.h"
+}
+
+size_t OGrandPrixBalloons::_count = 0;
+
+OGrandPrixBalloons::OGrandPrixBalloons(const FVector& pos) {
+ Pos = pos;
+
+ _active = 1;
+ if (gPlayerCount == 1) {
+ _numBalloons = 0x64;
+ _numBalloons2 = 0x3C;
+ _numBalloons3 = 0x1E;
+ } else {
+ _numBalloons = 0x32;
+ _numBalloons2 = 0x1E;
+ _numBalloons3 = 0xA;
+ }
+
+ for (size_t i = 0; i < _numBalloons; i++) {
+ find_unused_obj_index(&gObjectParticle3[i]);
+ init_object(gObjectParticle3[i], 0);
+ }
+}
+
+void OGrandPrixBalloons::Tick() {
+ s32 someIndex;
+ s32 objectIndex;
+ s32 someCount;
+ Object* object;
+
+ if (!_active) {
+ return;
+ }
+ someCount = 0;
+ for (someIndex = 0; someIndex < _numBalloons; someIndex++) {
+ objectIndex = gObjectParticle3[someIndex];
+ if (objectIndex != DELETED_OBJECT_ID) {
+ object = &gObjectList[objectIndex];
+ if (object->state != 0) {
+ OGrandPrixBalloons::func_80074E28(objectIndex);
+ OGrandPrixBalloons::func_80074D94(objectIndex);
+ if (object->state == 0) {
+ delete_object_wrapper(&gObjectParticle3[someIndex]);
+ this->Destroy();
+ }
+ someCount += 1;
+ }
+ }
+ }
+ if (someCount == 0) {
+ _active = 0;
+ }
+}
+
+void OGrandPrixBalloons::Draw(s32 cameraId) {
+ s32 var_s1;
+ s32 objectIndex;
+ if (!_active) {
+ return;
+ }
+
+ gSPDisplayList(gDisplayListHead++, (Gfx*)D_0D007E98);
+ gDPLoadTLUT_pal256(gDisplayListHead++, gTLUTOnomatopoeia);
+ func_8004B614(0, 0, 0, 0, 0, 0, 0);
+ gDPSetAlphaCompare(gDisplayListHead++, G_AC_THRESHOLD);
+ gDPSetRenderMode(gDisplayListHead++,
+ AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL |
+ GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA),
+ AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL |
+ GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA));
+ D_80183E80[0] = 0;
+ D_80183E80[1] = 0x8000;
+ rsp_load_texture((uint8_t*)gTextureBalloon1, 64, 32);
+ for (var_s1 = 0; var_s1 < _numBalloons; var_s1++) {
+ objectIndex = gObjectParticle3[var_s1];
+ if ((objectIndex != NULL_OBJECT_ID) && (gObjectList[objectIndex].state >= 2)) {
+ OGrandPrixBalloons::func_80053D74(objectIndex, cameraId, 0);
+ }
+ }
+ rsp_load_texture((uint8_t*)gTextureBalloon2, 64, 32);
+ for (var_s1 = 0; var_s1 < _numBalloons; var_s1++) {
+ objectIndex = gObjectParticle3[var_s1];
+ if ((objectIndex != NULL_OBJECT_ID) && (gObjectList[objectIndex].state >= 2)) {
+ OGrandPrixBalloons::func_80053D74(objectIndex, cameraId, 4);
+ }
+ }
+}
+
+void OGrandPrixBalloons::func_80053D74(s32 objectIndex, UNUSED s32 arg1, s32 vertexIndex) {
+ Object* object;
+
+ Vtx* vtx = (Vtx*) LOAD_ASSET_RAW(common_vtx_hedgehog);
+
+ if (gMatrixHudCount <= MTX_HUD_POOL_SIZE_MAX) {
+ object = &gObjectList[objectIndex];
+ D_80183E80[2] = (s16) (object->unk_084[6] + 0x8000);
+ rsp_set_matrix_transformation(object->pos, (u16*) D_80183E80, object->sizeScaling);
+ set_color_render((s32) object->unk_084[0], (s32) object->unk_084[1], (s32) object->unk_084[2],
+ (s32) object->unk_084[3], (s32) object->unk_084[4], (s32) object->unk_084[5],
+ (s32) object->primAlpha);
+ gSPVertex(gDisplayListHead++, (uintptr_t)&vtx[vertexIndex], 4, 0);
+ gSPDisplayList(gDisplayListHead++, (Gfx*)common_rectangle_display);
+ }
+}
+
+void OGrandPrixBalloons::func_80074924(s32 objectIndex) {
+ s32 sp2C = 0;
+ s32 sp28;
+ s32 sp24;
+ s32 sp20 = 0;
+ s32 temp_a0;
+ Object* object;
+
+ object = &gObjectList[objectIndex];
+ object->sizeScaling = 0.15f;
+
+ if (GetCourse() == GetMarioRaceway()) {
+ sp2C = random_int(0x00C8U);
+ sp28 = random_int(_numBalloons3);
+ sp24 = random_int(0x0096U);
+ sp20 = random_int(0x2000U);
+ object->origin_pos[0] = (f32) ((((f64) Pos.x + 100.0) - (f64) sp2C) * (f64) xOrientation);
+ object->origin_pos[1] = (f32) (Pos.y + sp28);
+ object->origin_pos[2] = (f32) (((f64) Pos.z + 200.0) - (f64) sp24);
+ } else if (GetCourse() == GetRoyalRaceway()) {
+ sp2C = random_int(0x0168U);
+ sp28 = random_int(_numBalloons3);
+ sp24 = random_int(0x00B4U);
+ sp20 = random_int(0x2000U);
+ object->origin_pos[0] = (f32) ((((f64) Pos.x + 180.0) - (f64) sp2C) * (f64) xOrientation);
+ object->origin_pos[1] = (f32) (Pos.y + sp28);
+ object->origin_pos[2] = (f32) (((f64) Pos.z + 200.0) - (f64) sp24);
+ } else if (GetCourse() == GetLuigiRaceway()) {
+ sp2C = random_int(0x012CU);
+ sp28 = random_int(_numBalloons3);
+ sp24 = random_int(0x0096U);
+ sp20 = random_int(0x2000U);
+ object->origin_pos[0] = (f32) ((((f64) Pos.x + 150.0) - (f64) sp2C) * (f64) xOrientation);
+ object->origin_pos[1] = (f32) (Pos.y + sp28);
+ object->origin_pos[2] = (f32) (((f64) Pos.z + 200.0) - (f64) sp24);
+ } else { // any track
+ sp2C = random_int(0x00C8U);
+ sp28 = random_int(_numBalloons3);
+ sp24 = random_int(0x0096U);
+ sp20 = random_int(0x2000U);
+ object->origin_pos[0] = (f32) ((((f64) Pos.x + 100.0) - (f64) sp2C) * (f64) xOrientation);
+ object->origin_pos[1] = (f32) (Pos.y + sp28);
+ object->origin_pos[2] = (f32) (((f64) Pos.z + 200.0) - (f64) sp24);
+ }
+
+ set_obj_origin_offset(objectIndex, 0, 0, 0);
+ if (gPlayerCount == 1) {
+ object->velocity[1] = (f32) (((f64) (f32) (sp2C % 4) * 0.25) + 0.8);
+ } else {
+ object->velocity[1] = (f32) (((f64) (f32) (sp2C % 3) * 0.2) + 0.4);
+ }
+ temp_a0 = sp2C % 8;
+ object->unk_084[0] = D_800E6F30[temp_a0][0];
+ object->unk_084[1] = D_800E6F30[temp_a0][1];
+ object->unk_084[2] = D_800E6F30[temp_a0][2];
+ object->unk_084[3] = D_800E6F48[temp_a0][0];
+ object->unk_084[4] = D_800E6F48[temp_a0][1];
+ object->unk_084[5] = D_800E6F48[temp_a0][2];
+ object->unk_084[6] = sp20 - 0x1000;
+ if (sp2C & 1) {
+ object->unk_084[7] = (sp20 / 32) + 0x100;
+ } else {
+ object->unk_084[7] = -0x100 - (sp20 / 32);
+ }
+ object->primAlpha = 0x00E6;
+ object_next_state(objectIndex);
+}
+
+void OGrandPrixBalloons::func_80074D94(s32 objectIndex) {
+ if (gObjectList[objectIndex].unk_0AE == 1) {
+ if ((_numBalloons2 <= gObjectList[objectIndex].offset[1]) &&
+ (s16_step_down_towards(&gObjectList[objectIndex].primAlpha, 0, 8) != 0)) {
+ func_80086F60(objectIndex);
+ }
+ object_add_velocity_offset_y(objectIndex);
+ }
+ object_calculate_new_pos_offset(objectIndex);
+}
+
+void OGrandPrixBalloons::func_80074E28(s32 objectIndex) {
+ switch (gObjectList[objectIndex].state) {
+ case 1:
+ OGrandPrixBalloons::func_80074924(objectIndex);
+ break;
+ case 2:
+ if (set_and_run_timer_object(objectIndex, 1) != false) {
+ func_80086E70(objectIndex);
+ break;
+ }
+ case 0:
+ break;
+ case 3:
+ OGrandPrixBalloons::func_80041480(&gObjectList[objectIndex].unk_084[6], -0x1000, 0x1000, &gObjectList[objectIndex].unk_084[7]);
+ if (gObjectList[objectIndex].unk_0AE == 0) {
+ func_80072428(objectIndex);
+ }
+ break;
+ }
+}
+
+void OGrandPrixBalloons::func_80041480(s16* arg0, s16 arg1, s16 arg2, s16* arg3) {
+ *arg0 += *arg3;
+ if (*arg3 >= 0) {
+ if (*arg0 >= arg2) {
+ *arg0 = arg2;
+ *arg3 = -*arg3;
+ }
+ } else if (arg1 >= *arg0) {
+ *arg0 = arg1;
+ *arg3 = -*arg3;
+ }
+} \ No newline at end of file
diff --git a/src/engine/objects/GrandPrixBalloons.h b/src/engine/objects/GrandPrixBalloons.h
new file mode 100644
index 000000000..93ec04479
--- /dev/null
+++ b/src/engine/objects/GrandPrixBalloons.h
@@ -0,0 +1,55 @@
+#pragma once
+
+#include <libultraship.h>
+#include <vector>
+
+#include "engine/World.h"
+#include "engine/objects/Object.h"
+
+extern "C" {
+#include "macros.h"
+#include "main.h"
+#include "vehicles.h"
+#include "waypoints.h"
+#include "common_structs.h"
+#include "objects.h"
+#include "camera.h"
+#include "some_data.h"
+}
+
+
+
+/**
+ * Grand Prix Balloons OObject
+ */
+class OGrandPrixBalloons : public OObject {
+public:
+
+ explicit OGrandPrixBalloons(const FVector& pos);
+
+ ~OGrandPrixBalloons() {
+ _count--;
+ }
+
+ static size_t GetCount() {
+ return _count;
+ }
+
+ virtual void Tick() override;
+ virtual void Draw(s32 cameraId) override;
+ void func_80053D74(s32 objectIndex, UNUSED s32 arg1, s32 vertexIndex);
+
+ void func_80074924(s32 objectIndex);
+ void func_80074D94(s32 objectIndex);
+ void func_80074E28(s32 objectIndex);
+ void func_80041480(s16* arg0, s16 arg1, s16 arg2, s16* arg3); // Some weird math function
+
+private:
+ static size_t _count;
+ s32 _idx;
+ FVector Pos;
+ bool _active;
+ size_t _numBalloons;
+ size_t _numBalloons2;
+ size_t _numBalloons3;
+};
diff --git a/src/engine/objects/Hedgehog.cpp b/src/engine/objects/Hedgehog.cpp
index 133a1f38d..ebc5b30bb 100644
--- a/src/engine/objects/Hedgehog.cpp
+++ b/src/engine/objects/Hedgehog.cpp
@@ -15,10 +15,12 @@ extern "C" {
size_t OHedgehog::_count = 0;
OHedgehog::OHedgehog(const FVector& pos, const FVector2D& patrolPoint, s16 unk) {
+ Name = "Hedgehog";
_idx = _count;
_pos = pos;
s32 objectId = indexObjectList2[_idx];
+ _objectIndex = objectId;
init_object(objectId, 0);
gObjectList[objectId].pos[0] = gObjectList[objectId].origin_pos[0] = pos.x * xOrientation;
gObjectList[objectId].pos[1] = gObjectList[objectId].surfaceHeight = pos.y + 6.0;
diff --git a/src/engine/objects/HotAirBalloon.cpp b/src/engine/objects/HotAirBalloon.cpp
index 917fd7354..4e337d98e 100644
--- a/src/engine/objects/HotAirBalloon.cpp
+++ b/src/engine/objects/HotAirBalloon.cpp
@@ -15,6 +15,7 @@ extern "C" {
}
OHotAirBalloon::OHotAirBalloon(const FVector& pos) {
+ Name = "Hot Air Balloon";
_pos = pos;
D_80165898 = 0;
diff --git a/src/engine/objects/HotAirBalloon.h b/src/engine/objects/HotAirBalloon.h
index 5dad406db..301e111c4 100644
--- a/src/engine/objects/HotAirBalloon.h
+++ b/src/engine/objects/HotAirBalloon.h
@@ -31,5 +31,4 @@ public:
private:
FVector _pos;
bool *_visible;
- s32 _objectIndex;
};
diff --git a/src/engine/objects/Lakitu.cpp b/src/engine/objects/Lakitu.cpp
index 93a87f5e1..12ca2d7db 100644
--- a/src/engine/objects/Lakitu.cpp
+++ b/src/engine/objects/Lakitu.cpp
@@ -37,6 +37,7 @@ extern s8 gPlayerCount;
}
OLakitu::OLakitu(s32 playerId, LakituType type) {
+ Name = "Lakitu";
_playerId = playerId;
init_object(gIndexLakituList[playerId], (s32)type);
diff --git a/src/engine/objects/Mole.cpp b/src/engine/objects/Mole.cpp
index fdf5e7b08..06bd5f56c 100644
--- a/src/engine/objects/Mole.cpp
+++ b/src/engine/objects/Mole.cpp
@@ -25,6 +25,7 @@ extern "C" {
size_t OMole::_count = 0;
OMole::OMole(FVector pos, OMoleGroup* group) {
+ Name = "Mole";
_idx = _count;
_group = group;
diff --git a/src/engine/objects/Mole.h b/src/engine/objects/Mole.h
index 7707b5383..1457c72cc 100644
--- a/src/engine/objects/Mole.h
+++ b/src/engine/objects/Mole.h
@@ -40,7 +40,6 @@ public:
void func_80081790(s32 objectIndex);
void func_8008153C(s32 objectIndex);
- s32 _objectIndex;
s32 _moleIndex;
private:
static size_t _count;
diff --git a/src/engine/objects/Object.cpp b/src/engine/objects/Object.cpp
index d532dd566..4e4fd6766 100644
--- a/src/engine/objects/Object.cpp
+++ b/src/engine/objects/Object.cpp
@@ -18,6 +18,6 @@ void OObject::Tick60fps() {}
void OObject::Draw(s32 cameraId) { }
void OObject::Expire() { }
void OObject::Destroy() {
- PendingDestroy = true;
+ bPendingDestroy = true;
}
void OObject::Reset() { }
diff --git a/src/engine/objects/Object.h b/src/engine/objects/Object.h
index b78b27240..9dd44397b 100644
--- a/src/engine/objects/Object.h
+++ b/src/engine/objects/Object.h
@@ -11,7 +11,9 @@ class OObject {
public:
uint8_t uuid[16];
Object o;
- bool PendingDestroy = false;
+ const char* Name = "";
+ bool bPendingDestroy = false;
+ s32 _objectIndex = -1;
virtual ~OObject() = default;
diff --git a/src/engine/objects/Penguin.cpp b/src/engine/objects/Penguin.cpp
index 1eeb00ff4..d283101b3 100644
--- a/src/engine/objects/Penguin.cpp
+++ b/src/engine/objects/Penguin.cpp
@@ -34,7 +34,8 @@ extern s8 gPlayerCount;
}
-OPenguin::OPenguin(Vec3f pos, u16 direction, PenguinType type, Behaviour behaviour) {
+OPenguin::OPenguin(FVector pos, u16 direction, PenguinType type, Behaviour behaviour) {
+ Name = "Penguin";
_type = type;
_bhv = behaviour;
@@ -43,9 +44,9 @@ OPenguin::OPenguin(Vec3f pos, u16 direction, PenguinType type, Behaviour behavio
init_object(_objectIndex, 0);
Object *object = &gObjectList[_objectIndex];
- object->origin_pos[0] = pos[0] * xOrientation;
- object->origin_pos[1] = pos[1];
- object->origin_pos[2] = pos[2];
+ object->origin_pos[0] = pos.x * xOrientation;
+ object->origin_pos[1] = pos.y;
+ object->origin_pos[2] = pos.z;
object->unk_0C6 = direction;
switch(type) {
diff --git a/src/engine/objects/Penguin.h b/src/engine/objects/Penguin.h
index 72ba16285..91d5687b9 100644
--- a/src/engine/objects/Penguin.h
+++ b/src/engine/objects/Penguin.h
@@ -38,7 +38,7 @@ public:
f32 Diameter = 0.0f; // Waddle in a circle around the spawn point at this diameter.
uint16_t MirrorModeAngleOffset;
- explicit OPenguin(Vec3f pos, u16 direction, PenguinType type, Behaviour behaviour);
+ explicit OPenguin(FVector pos, u16 direction, PenguinType type, Behaviour behaviour);
virtual void Tick() override;
virtual void Draw(s32 cameraId) override;
@@ -55,7 +55,6 @@ private:
void InitOtherPenguin(s32 objectIndex);
static bool _toggle;
- s32 _objectIndex;
PenguinType _type;
Behaviour _bhv;
};
diff --git a/src/engine/objects/Podium.cpp b/src/engine/objects/Podium.cpp
index d8f1e2ff2..ec396ca53 100644
--- a/src/engine/objects/Podium.cpp
+++ b/src/engine/objects/Podium.cpp
@@ -26,7 +26,7 @@ extern Vec3s D_800E634C[];
// };
OPodium::OPodium(const FVector& pos) {
-
+ Name = "Podium";
_pos = pos;
find_unused_obj_index(&_podium1Index);
diff --git a/src/engine/objects/Seagull.cpp b/src/engine/objects/Seagull.cpp
index 11043238f..17c35c07d 100644
--- a/src/engine/objects/Seagull.cpp
+++ b/src/engine/objects/Seagull.cpp
@@ -32,6 +32,7 @@ SplineData* D_800E633C[] = { &D_800E6034, &D_800E60F0, &D_800E61B4, &D_800E6280
size_t OSeagull::_count = 0;
OSeagull::OSeagull(FVector pos) {
+ Name = "Seagull";
_idx = _count;
_pos.x = pos.x;
_pos.y = pos.y;
diff --git a/src/engine/objects/Seagull.h b/src/engine/objects/Seagull.h
index a0e5cd233..42474159e 100644
--- a/src/engine/objects/Seagull.h
+++ b/src/engine/objects/Seagull.h
@@ -38,7 +38,6 @@ public:
void func_8008241C(s32 objectIndex, s32 arg1);
void func_80082714(s32 objectIndex, s32 arg1);
private:
- s32 _objectIndex;
FVector _pos;
static size_t _count;
s32 _idx;
diff --git a/src/engine/objects/Snowman.cpp b/src/engine/objects/Snowman.cpp
index 2052a8adb..12beb9e47 100644
--- a/src/engine/objects/Snowman.cpp
+++ b/src/engine/objects/Snowman.cpp
@@ -17,11 +17,13 @@ static const char* sSnowmanHeadList[] = { d_course_frappe_snowland_snowman_head
size_t OSnowman::_count = 0;
OSnowman::OSnowman(const FVector& pos) {
+ Name = "Snowman";
_idx = _count;
_pos = pos;
find_unused_obj_index(&_headIndex);
init_object(_headIndex, 0);
+ _objectIndex = _headIndex;
gObjectList[_headIndex].origin_pos[0] = pos.x * xOrientation;
gObjectList[_headIndex].origin_pos[1] = pos.y + 5.0 + 3.0;
gObjectList[_headIndex].origin_pos[2] = pos.z;
diff --git a/src/engine/objects/Snowman.h b/src/engine/objects/Snowman.h
index ffa927769..f33ee3b53 100644
--- a/src/engine/objects/Snowman.h
+++ b/src/engine/objects/Snowman.h
@@ -50,7 +50,6 @@ private:
FVector _pos;
static size_t _count;
size_t _idx;
- s32 _objectIndex;
s32 _headIndex;
s32 _bodyIndex;
};
diff --git a/src/engine/objects/Thwomp.cpp b/src/engine/objects/Thwomp.cpp
index 6a04f07bb..d3f99a8d9 100644
--- a/src/engine/objects/Thwomp.cpp
+++ b/src/engine/objects/Thwomp.cpp
@@ -47,6 +47,7 @@ s16 D_800E597C[] = { 0x0000, 0x0000, 0x4000, 0x8000, 0x8000, 0xc000 };
size_t OThwomp::_count = 0;
OThwomp::OThwomp(s16 x, s16 z, s16 direction, f32 scale, s16 behaviour, s16 primAlpha, u16 boundingBoxSize) {
+ Name = "Thwomp";
_idx = _count;
_faceDirection = direction;
_boundingBoxSize = boundingBoxSize;
diff --git a/src/engine/objects/Thwomp.h b/src/engine/objects/Thwomp.h
index 75aeaf1a0..22c674bb5 100644
--- a/src/engine/objects/Thwomp.h
+++ b/src/engine/objects/Thwomp.h
@@ -113,7 +113,6 @@ public:
private:
static size_t _count;
s32 _idx;
- s32 _objectIndex;
s16 _faceDirection;
//! @todo Write this better. This effects the squish size and the bounding box size.
// We should probably return to the programmer the pointer to the actor so they can do thwomp->squishSize = value.
diff --git a/src/engine/objects/TrashBin.cpp b/src/engine/objects/TrashBin.cpp
index 6aa556470..c94d0352f 100644
--- a/src/engine/objects/TrashBin.cpp
+++ b/src/engine/objects/TrashBin.cpp
@@ -20,7 +20,8 @@ extern "C" {
#define DEGREES_FLOAT_TO_SHORT(Degrees) ((s16)((Degrees) * (0x8000 / 180.0f)))
-OTrashBin::OTrashBin(const FVector& pos, const FRotation& rotation, f32 scale, OTrashBin::Behaviour bhv) {
+OTrashBin::OTrashBin(const FVector& pos, const IRotator& rotation, f32 scale, OTrashBin::Behaviour bhv) {
+ Name = "Trashbin";
_pos = pos;
_rot = rotation;
_scale = scale;
diff --git a/src/engine/objects/TrashBin.h b/src/engine/objects/TrashBin.h
index 2ebe13e87..3e878e1c0 100644
--- a/src/engine/objects/TrashBin.h
+++ b/src/engine/objects/TrashBin.h
@@ -24,7 +24,7 @@ public:
STATIC, // The lid stays shut
MUNCHING // The lid opens/closes in a scary munching manner
};
- explicit OTrashBin(const FVector& pos, const FRotation& rotation, f32 scale, OTrashBin::Behaviour bhv);
+ explicit OTrashBin(const FVector& pos, const IRotator& rotation, f32 scale, OTrashBin::Behaviour bhv);
virtual void Tick() override;
virtual void Draw(s32 cameraId) override;
@@ -38,9 +38,8 @@ private:
Behaviour _bhv;
FVector _pos;
- FRotation _rot;
+ IRotator _rot;
float _scale;
size_t _idx;
- s32 _objectIndex;
bool _drawBin = false;
};
diff --git a/src/engine/objects/Trophy.cpp b/src/engine/objects/Trophy.cpp
index 54bd70d3e..9f90b6be1 100644
--- a/src/engine/objects/Trophy.cpp
+++ b/src/engine/objects/Trophy.cpp
@@ -21,6 +21,7 @@ extern "C" {
}
OTrophy::OTrophy(const FVector& pos, TrophyType trophy, Behaviour bhv) {
+ Name = "Trophy";
_trophy = trophy;
_spawnPos = pos;
_spawnPos.y += 16.0f; // Adjust the height so the trophy sits on the surface when positioned to 0,0,0
diff --git a/src/engine/objects/Trophy.h b/src/engine/objects/Trophy.h
index c2bb937ab..89f130997 100644
--- a/src/engine/objects/Trophy.h
+++ b/src/engine/objects/Trophy.h
@@ -48,7 +48,6 @@ public:
private:
StarEmitter* _emitter;
- s32 _objectIndex;
TrophyType _trophy;
FVector _spawnPos;
Behaviour _bhv;