From e7a7f794d44a6533afcacc95ff99783691419964 Mon Sep 17 00:00:00 2001 From: elijah-thomas774 Date: Sun, 9 Jun 2024 23:46:43 -0400 Subject: [PATCH] Progress --- .../SOUE01/rels/d_t_sound_areaNP/symbols.txt | 8 ++-- include/d/tg/d_t_sound_area.h | 11 +++-- include/egg/math/eggVector.h | 2 +- include/m/m_vec.h | 9 +--- src/REL/d/t/d_t_sound_area.cpp | 46 +++++++++++-------- 5 files changed, 40 insertions(+), 36 deletions(-) diff --git a/config/SOUE01/rels/d_t_sound_areaNP/symbols.txt b/config/SOUE01/rels/d_t_sound_areaNP/symbols.txt index 78bf8f1e..cdc4ffe7 100644 --- a/config/SOUE01/rels/d_t_sound_areaNP/symbols.txt +++ b/config/SOUE01/rels/d_t_sound_areaNP/symbols.txt @@ -7,10 +7,10 @@ doDelete__10dTgSndAr_cFv = .text:0x00000220; // type:function size:0x8 actorExecute__10dTgSndAr_cFv = .text:0x00000230; // type:function size:0xCC draw__10dTgSndAr_cFv = .text:0x00000300; // type:function size:0x8 checkPosInArea__10dTgSndAr_cFR7mVec3_c = .text:0x00000310; // type:function size:0x40 -checkAlg0__10dTgSndAr_cFR7mVec3_c = .text:0x00000350; // type:function size:0xF0 -checkAlg1__10dTgSndAr_cFR7mVec3_c = .text:0x00000440; // type:function size:0x54 -checkAlg2__10dTgSndAr_cFR7mVec3_c = .text:0x000004A0; // type:function size:0x98 -checkAlg3__10dTgSndAr_cFR7mVec3_c = .text:0x00000540; // type:function size:0x14C +checkAlg0__10dTgSndAr_cFRC7mVec3_c = .text:0x00000350; // type:function size:0xF0 +checkAlg1__10dTgSndAr_cFRC7mVec3_c = .text:0x00000440; // type:function size:0x54 +checkAlg2__10dTgSndAr_cFRC7mVec3_c = .text:0x000004A0; // type:function size:0x98 +checkAlg3__10dTgSndAr_cFRC7mVec3_c = .text:0x00000540; // type:function size:0x14C __dt__10dTgSndAr_cFv = .text:0x00000690; // type:function size:0x70 _ctors = .ctors:0x00000000; // type:label scope:global _dtors = .dtors:0x00000000; // type:label scope:global diff --git a/include/d/tg/d_t_sound_area.h b/include/d/tg/d_t_sound_area.h index 949249c7..67c6fbfd 100644 --- a/include/d/tg/d_t_sound_area.h +++ b/include/d/tg/d_t_sound_area.h @@ -2,10 +2,11 @@ #define D_T_SOUND_AREA_H #include -#include #include +#include #include + class dTgSndAr_c : public dTg_c { public: dTgSndAr_c() {} @@ -21,10 +22,10 @@ private: } bool checkPosInArea(mVec3_c &pos); - bool checkAlg0(mVec3_c &pos); - bool checkAlg1(mVec3_c &pos); - bool checkAlg2(mVec3_c &pos); - bool checkAlg3(mVec3_c &pos); + bool checkAlg0(const mVec3_c &pos); + bool checkAlg1(const mVec3_c &pos); + bool checkAlg2(const mVec3_c &pos); + bool checkAlg3(const mVec3_c &pos); mMtx_c mtx; ActorOnRail mRail; diff --git a/include/egg/math/eggVector.h b/include/egg/math/eggVector.h index 2090b5b7..9aa50ae8 100644 --- a/include/egg/math/eggVector.h +++ b/include/egg/math/eggVector.h @@ -111,7 +111,7 @@ struct Vector3f : public nw4r::math::VEC3 { struct Vector2f : nw4r::math::VEC2 { inline Vector2f() {} Vector2f(f32 fx, f32 fy) : VEC2(fx, fy) {} - inline ~Vector2f() {} + inline ~Vector2f() {} public: /* 805767c0 */ static const Vector2f zero; diff --git a/include/m/m_vec.h b/include/m/m_vec.h index 2f0e6c78..d58a0ab8 100644 --- a/include/m/m_vec.h +++ b/include/m/m_vec.h @@ -19,16 +19,11 @@ public: } mVec3_c(const mVec3_c &other) { - x = other.x; - y = other.y; - z = other.z; + set(other.x, other.y, other.z); } - /// @brief Constructs a vector from three floating point values. mVec3_c(f32 fx, f32 fy, f32 fz) { - x = fx; - y = fy; - z = fz; + set(fx, fy, fz); } mVec3_c &operator=(const mVec3_c &r) { diff --git a/src/REL/d/t/d_t_sound_area.cpp b/src/REL/d/t/d_t_sound_area.cpp index fd625825..1f1f9cd6 100644 --- a/src/REL/d/t/d_t_sound_area.cpp +++ b/src/REL/d/t/d_t_sound_area.cpp @@ -5,6 +5,11 @@ SPECIAL_ACTOR_PROFILE(TAG_SOUND_AREA, dTgSndAr_c, fProfile::TAG_SOUND_AREA, 0x0146, 0, 0); +void float_ordering() { + f32 arr[6] = {0, 100, 100, 100, 100, 100}; + 0.01f; +} + struct SoundAreaManager { u8 unk[0xFC]; u32 bgmFlags; @@ -49,9 +54,7 @@ int dTgSndAr_c::doDelete() { struct Unk { u8 unk[0x144]; - f32 x; - f32 y; - f32 z; + mVec3_c v; }; extern Unk *lbl_80575D58; @@ -63,7 +66,7 @@ int dTgSndAr_c::actorExecute() { } if (lbl_80575D58 != nullptr) { // Halp - mVec3_c pos(lbl_80575D58->x, lbl_80575D58->y, lbl_80575D58->z); + mVec3_c pos = lbl_80575D58->v; if (checkPosInArea(pos) && lbl_805756EC != nullptr) { lbl_805756EC->bgmFlags |= 1 << (params & 0xFF); } @@ -90,39 +93,44 @@ bool dTgSndAr_c::checkPosInArea(mVec3_c &pos) { return false; } +inline bool inRange(f32 val, f32 tolerance) { + return (-tolerance <= val && val <= tolerance); +} // Box -bool dTgSndAr_c::checkAlg0(mVec3_c &pos) { +bool dTgSndAr_c::checkAlg0(const mVec3_c &pos) { mVec3_c c2 = pos; PSMTXMultVec(mtx.m, c2, c2); - f32 scaleX = scale.x; - f32 scaleZ = scale.z; - if (c2.x >= scaleX * -50.0f && c2.x <= scaleX * 50.0f && c2.y >= 0.0f && c2.y <= scale.y * 100.0f && - c2.z >= scaleZ * -50.0f && c2.z <= scaleZ * 50.0f) { + f32 sxLower = -50.0f * scale.x; + f32 sxUpper = 50.0f * scale.x; + f32 syLower = 0.0f; + f32 syUpper = 100.0f * scale.y; + f32 szLower = -50.0f * scale.z; + f32 szUpper = 50.0f * scale.z; + + if (sxLower <= c2.x && c2.x <= sxUpper && syLower <= c2.y && c2.y <= syUpper && szLower <= c2.z && + c2.z <= szUpper) { return true; } - return false; } // Sphere -bool dTgSndAr_c::checkAlg1(mVec3_c &pos) { +bool dTgSndAr_c::checkAlg1(const mVec3_c &pos) { f32 tgtDist = scale.x * 100.0f; f32 tgtDist2 = tgtDist * tgtDist; return PSVECSquareDistance(position, pos) < tgtDist2; } // Cylinder -bool dTgSndAr_c::checkAlg2(mVec3_c &pos) { - f32 f3 = position.x; - if (pos.y < f3 || (f3 + scale.y * 100.0f < pos.y)) { +bool dTgSndAr_c::checkAlg2(const mVec3_c &pos) { + if (pos.y < position.y || pos.y > (position.y + 100.0f * scale.y)) { return false; } - f32 f1 = position.z; - f32 f2 = position.x; - f3 = scale.x * 100.0f; - return f2 * f2 + f1 * f1 <= f3 * f3; + mVec3_c diff(pos.x - position.x, pos.z - position.z, scale.x * 100.0f); + + return diff.x * diff.x + diff.y * diff.y <= diff.x * diff.z; } // ??? -bool dTgSndAr_c::checkAlg3(mVec3_c &pos) {} +bool dTgSndAr_c::checkAlg3(const mVec3_c &pos) {}