From f80927177a5a32b12ae5aed021f6d3bd86d8af36 Mon Sep 17 00:00:00 2001 From: robojumper Date: Thu, 13 Jun 2024 18:18:40 +0200 Subject: [PATCH] Maybe --- config/SOUE01/symbols.txt | 2 +- include/m/m_mtx.h | 2 +- include/toBeSorted/actor_on_rail.h | 2 ++ src/REL/d/t/d_t_sound_area.cpp | 44 ++++++++++++++++++++++++++++-- 4 files changed, 45 insertions(+), 5 deletions(-) diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 75db02dc..7d2fa499 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -3677,7 +3677,7 @@ __dt__11ActorOnRailFv = .text:0x800A66D0; // type:function size:0x40 fn_800A6710 = .text:0x800A6710; // type:function size:0x18 fn_800A6730 = .text:0x800A6730; // type:function size:0xBC fn_800A67F0 = .text:0x800A67F0; // type:function size:0xBC -fn_800A68B0 = .text:0x800A68B0; // type:function size:0x58 +getPntPosForIndex__11ActorOnRailFi = .text:0x800A68B0; // type:function size:0x58 fn_800A6910 = .text:0x800A6910; // type:function size:0x2B4 fn_800A6BD0 = .text:0x800A6BD0; // type:function size:0x74 fn_800A6C50 = .text:0x800A6C50; // type:function size:0x110 diff --git a/include/m/m_mtx.h b/include/m/m_mtx.h index f7095930..f68c58ab 100644 --- a/include/m/m_mtx.h +++ b/include/m/m_mtx.h @@ -17,7 +17,7 @@ public: /* 802f16b0 */ void XrotS(mAng angle); ///< Generates a rotation matrix for the X axis with the given angle. /* 802f1770 */ void XrotM(mAng angle); ///< Rotates the matrix on the X axis by the given angle. /* 802f17c0 */ void YrotS(mAng angle); ///< Generates a rotation matrix for the Y axis with the given angle. - /* 802f1880 */ void YrotM(s16 &angle); ///< Rotates the matrix on the Y axis by the given angle. + /* 802f1880 */ void YrotM(s16 &angle); ///< Rotates the matrix on the Y axis by the given angle. /* 802f18d0 */ void ZrotS(mAng angle); ///< Generates a rotation matrix for the Z axis with the given angle. /* 802f1990 */ void ZrotM(mAng angle); ///< Rotates the matrix on the Z axis by the given angle. diff --git a/include/toBeSorted/actor_on_rail.h b/include/toBeSorted/actor_on_rail.h index 47f8460d..a57d2753 100644 --- a/include/toBeSorted/actor_on_rail.h +++ b/include/toBeSorted/actor_on_rail.h @@ -17,6 +17,8 @@ public: /* 800A6D90 */ bool init(int pathIndex, int roomId, int pathSubtype); + /* 800A68B0 */ + mVec3_c *getPntPosForIndex(int index); }; #endif diff --git a/src/REL/d/t/d_t_sound_area.cpp b/src/REL/d/t/d_t_sound_area.cpp index 1f1f9cd6..63611a2f 100644 --- a/src/REL/d/t/d_t_sound_area.cpp +++ b/src/REL/d/t/d_t_sound_area.cpp @@ -65,7 +65,6 @@ int dTgSndAr_c::actorExecute() { link->setBit_field_0xE8(params & 0xFF); } if (lbl_80575D58 != nullptr) { - // Halp mVec3_c pos = lbl_80575D58->v; if (checkPosInArea(pos) && lbl_805756EC != nullptr) { lbl_805756EC->bgmFlags |= 1 << (params & 0xFF); @@ -96,6 +95,7 @@ bool dTgSndAr_c::checkPosInArea(mVec3_c &pos) { inline bool inRange(f32 val, f32 tolerance) { return (-tolerance <= val && val <= tolerance); } + // Box bool dTgSndAr_c::checkAlg0(const mVec3_c &pos) { mVec3_c c2 = pos; @@ -129,8 +129,46 @@ bool dTgSndAr_c::checkAlg2(const mVec3_c &pos) { 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; + return diff.x * diff.x + diff.y * diff.y <= diff.z * diff.z; } +struct UnkStruct { + /* 0x00 */ mVec3_c vec; + /* 0x0C */ mVec3_c vec2; + /* 0x18 */ u32 unk; + /* 0x1C */ f32 field_0x1C; + /* 0x20 */ u8 field_0x20; + /* 0x24 */ u32 field_0x24; +}; + +extern "C" void fn_80337EA0(UnkStruct *); +extern "C" void fn_80337EF0(UnkStruct *, mVec3_c&, mVec3_c&, f32); +extern "C" int fn_8032BFB0(UnkStruct *, mVec3_c&, f32*, f32&, int); + // ??? -bool dTgSndAr_c::checkAlg3(const mVec3_c &pos) {} +bool dTgSndAr_c::checkAlg3(const mVec3_c &pos) { + f32 q[4]; + UnkStruct unk; + + f32 radius = scale.x * 100.0f; + radius = radius * radius; + mVec3_c a = pos; + fn_80337EA0(&unk); + + mVec3_c b = *mRail.getPntPosForIndex(0); + mVec3_c c = *mRail.getPntPosForIndex(1); + + fn_80337EF0(&unk, b, c, scale.x * 100.0f); + f32 d; + if (fn_8032BFB0(&unk, a, q, d, 0)) { + return d < radius; + } else { + f32 distSq = PSVECSquareDistance(unk.vec, pos); + if (distSq < radius) { + return true; + } else { + distSq = PSVECSquareDistance(unk.vec2, pos); + return distSq < radius; + } + } +}