summaryrefslogtreecommitdiff
path: root/src/engine/objects
diff options
context:
space:
mode:
authorMegaMech <MegaMech@users.noreply.github.com>2025-11-22 18:13:33 -0700
committerGitHub <noreply@github.com>2025-11-22 18:13:33 -0700
commit5f60e30b59497d54b23097f8dbe5009faa43504d (patch)
tree3ddd0e64f452843e67774b040a207de84dca852d /src/engine/objects
parentfffd3f7fe92c6eb45b68c0ca522066bf9c54abb2 (diff)
Fix Moles and some UI Interpolation bugs (#565)
* Update render_objects.c * Update FrameInterpolation.h * Update render_objects.c * Fix mac compile probably * Fix Mole Dirt Particles * Fix Mole Duplication Bug, probably * Fix drawing using wrong camera bug
Diffstat (limited to 'src/engine/objects')
-rw-r--r--src/engine/objects/Mole.cpp17
-rw-r--r--src/engine/objects/MoleGroup.cpp29
-rw-r--r--src/engine/objects/MoleGroup.h5
3 files changed, 37 insertions, 14 deletions
diff --git a/src/engine/objects/Mole.cpp b/src/engine/objects/Mole.cpp
index 9ee4db7e7..9bc470f90 100644
--- a/src/engine/objects/Mole.cpp
+++ b/src/engine/objects/Mole.cpp
@@ -51,15 +51,12 @@ OMole::OMole(FVector pos, OMoleGroup* group) {
_count++;
}
+/**
+ * Moles are ticked from OMoleGroup
+ * OMoleTick is func_800821AC
+ * Dirt particle tick is func_80081790
+ */
void OMole::Tick() {
- if (_idx == 0) {
- for (size_t i = 0; i < gObjectParticle2_SIZE; i++) {
- s32 objectIndex = gObjectParticle2[i];
- if (gObjectList[objectIndex].state != 0) {
- OMole::func_80081790(objectIndex);
- }
- }
- }
}
void OMole::Draw(s32 cameraId) {
@@ -184,9 +181,9 @@ void OMole::func_8008153C(s32 objectIndex) {
gObjectList[loopObjectIndex].activeTLUT = d_course_moo_moo_farm_mole_dirt;
gObjectList[loopObjectIndex].tlutList = mole;
gObjectList[loopObjectIndex].sizeScaling = 0.15f;
- gObjectList[loopObjectIndex].velocity[1] = random_int(0x000AU);
+ gObjectList[loopObjectIndex].velocity[1] = random_int(10);
gObjectList[loopObjectIndex].velocity[1] = (gObjectList[loopObjectIndex].velocity[1] * 0.1) + 4.8;
- gObjectList[loopObjectIndex].unk_034 = random_int(5U);
+ gObjectList[loopObjectIndex].unk_034 = random_int(5);
gObjectList[loopObjectIndex].unk_034 = (gObjectList[loopObjectIndex].unk_034 * 0.01) + 0.8;
gObjectList[loopObjectIndex].orientation[1] = (0x10000 / sp70) * var_s1;
gObjectList[loopObjectIndex].origin_pos[0] = gObjectList[objectIndex].origin_pos[0];
diff --git a/src/engine/objects/MoleGroup.cpp b/src/engine/objects/MoleGroup.cpp
index 6e98edbbb..af936ed3f 100644
--- a/src/engine/objects/MoleGroup.cpp
+++ b/src/engine/objects/MoleGroup.cpp
@@ -8,12 +8,17 @@ extern "C" {
#include "math_util_2.h"
}
-OMoleGroup::OMoleGroup(std::vector<FVector> spawns) {
+size_t OMoleGroup::_count = 0;
+
+OMoleGroup::OMoleGroup(std::vector<FVector>& spawns) {
+ _idx = _count;
for (auto& pos : spawns) {
pos.x * xOrientation;
OMole* ptr = reinterpret_cast<OMole*>(gWorldInstance.AddObject(new OMole(pos, this)));
_moles.push_back({ptr, pos, false});
}
+
+ _count += 1;
}
void OMoleGroup::Tick() {
@@ -24,14 +29,32 @@ void OMoleGroup::Tick() {
mole.Mole->func_800821AC(mole.Mole->_objectIndex, 1);
}
}
+
+ /**
+ * This ticks the mole dirt particles. It must be ran *after* MoleGroup is done ticking. Otherwise, the dirt particle directions will not randomize
+ * The best solution would be for particles to be its own class. But that takes effort
+ * Instead, we wait until the last MoleGroup has ticked, then we tick the particles one time.
+ *
+ * Warning: Calling this more than one time per frame, will result in doubling the speed
+ */
+ if (_idx == _count - 1) {
+ for (size_t i = 0; i < gObjectParticle2_SIZE; i++) {
+ s32 objectIndex = gObjectParticle2[i];
+ if (gObjectList[objectIndex].state != 0) {
+ if (nullptr != _moles[0].Mole) {
+ _moles[0].Mole->func_80081790(objectIndex);
+ }
+ }
+ }
+ }
}
void OMoleGroup::func_80081FF4(s32 objectIndex) {
init_object(objectIndex, 0);
gObjectList[objectIndex].unk_04C = random_int(30) + 5;
- s16 mole = random_int(_moles.size() - 1);
- for (size_t i = 0; i < _moles.size() - 1; i++) {
+ s16 mole = random_int(_moles.size());
+ for (size_t i = 0; i < _moles.size(); i++) {
if (_moles[mole].Active == true) {
mole++;
if (mole == _moles.size()) {
diff --git a/src/engine/objects/MoleGroup.h b/src/engine/objects/MoleGroup.h
index dfb920985..db14432cd 100644
--- a/src/engine/objects/MoleGroup.h
+++ b/src/engine/objects/MoleGroup.h
@@ -16,7 +16,7 @@ public:
bool Active;
};
- explicit OMoleGroup(std::vector<FVector> moles);
+ explicit OMoleGroup(std::vector<FVector>& moles);
virtual void Tick() override;
@@ -24,4 +24,7 @@ public:
std::vector<MoleEntry> _moles;
+private:
+ static size_t _count;
+ size_t _idx;
};