From df1b69b9544e7640023d140e861609e45c3bade8 Mon Sep 17 00:00:00 2001 From: robojumper Date: Mon, 2 Jun 2025 21:24:00 +0200 Subject: [PATCH] A bit more --- config/SOUE01/splits.txt | 8 ++++- config/SOUE01/symbols.txt | 12 +++---- configure.py | 2 ++ include/d/snd/d_snd_3d_actor.h | 12 +++++-- include/d/snd/d_snd_3d_manager.h | 8 +++++ include/toBeSorted/music_mgrs.h | 1 - src/d/snd/d_snd_3d_actor.cpp | 62 ++++++++++++++++++++++++++++++-- 7 files changed, 92 insertions(+), 13 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index f08cfacf..020d2582 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2407,7 +2407,13 @@ d/snd/mgr/d_snd_mgr_effect.cpp: .text start:0x8036C6B0 end:0x8037F8B4 align:16 d/snd/mgr/d_snd_mgr_unk_5.cpp: - .text start:0x8037F8C0 end:0x803864C8 align:16 + .text start:0x8037F8C0 end:0x80382150 align:16 + +d/snd/d_snd_anim_sound.cpp: + .text start:0x80382150 end:0x8038240C align:16 + +d/snd/mgr/d_snd_mgr_unk_14.cpp: + .text start:0x80382410 end:0x803864C8 align:16 .ctors start:0x804DB91C end:0x804DB920 d/snd/mgr/d_snd_mgr_unk_13.cpp: diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 948f6ada..dd464e13 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -19840,16 +19840,16 @@ __cl__22SoundPropertiesCheckerFRQ34nw4r3snd11SoundHandle = .text:0x8035A600; // __dt__11dSndActor_cFv = .text:0x8035A840; // type:function size:0x58 scope:weak __ct__13dSnd3DActor_cFPvUc = .text:0x8035A8A0; // type:function size:0xE8 d_vt_0x34__13dSnd3DActor_cFRCQ34nw4r4math4VEC3 = .text:0x8035A990; // type:function size:0x40 -fn_8035A9D0 = .text:0x8035A9D0; // type:function size:0x2C +resetCachedRelativePositions__13dSnd3DActor_cFv = .text:0x8035A9D0; // type:function size:0x2C fn_8035AA00 = .text:0x8035AA00; // type:function size:0x30 updatePositionRelativeToListener__13dSnd3DActor_cFv = .text:0x8035AA30; // type:function size:0x44 calculatePositionRelativeToListener__13dSnd3DActor_cFv = .text:0x8035AA80; // type:function size:0x28 updateDistanceToListener__13dSnd3DActor_cFv = .text:0x8035AAB0; // type:function size:0x50 -fn_8035AB00 = .text:0x8035AB00; // type:function size:0x54 -fn_8035AB60 = .text:0x8035AB60; // type:function size:0x78 -fn_8035ABE0 = .text:0x8035ABE0; // type:function size:0x44 -fn_8035AC30 = .text:0x8035AC30; // type:function size:0x28 -fn_8035AC60 = .text:0x8035AC60; // type:function size:0x50 +updatePositionTransformedByListener__13dSnd3DActor_cFv = .text:0x8035AB00; // type:function size:0x54 +updateCameraDirectionDot__13dSnd3DActor_cFv = .text:0x8035AB60; // type:function size:0x78 +updatePositionRelativeToCameraTarget__13dSnd3DActor_cFv = .text:0x8035ABE0; // type:function size:0x44 +calculatePositionRelativeToCameraTarget__13dSnd3DActor_cFv = .text:0x8035AC30; // type:function size:0x28 +updateDistanceToCameraTarget__13dSnd3DActor_cFv = .text:0x8035AC60; // type:function size:0x50 updatePositionRelativeToPlayer__13dSnd3DActor_cFv = .text:0x8035ACB0; // type:function size:0xBC getPositionRelativeToPlayer__13dSnd3DActor_cFv = .text:0x8035AD70; // type:function size:0x3C updateDistanceToPlayer__13dSnd3DActor_cFv = .text:0x8035ADB0; // type:function size:0xFC diff --git a/configure.py b/configure.py index 7c231437..ed3cbdfc 100644 --- a/configure.py +++ b/configure.py @@ -717,6 +717,8 @@ config.libs = [ Object(Matching, "d/snd/d_snd_control_player.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_effect.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_5.cpp"), + Object(NonMatching, "d/snd/d_snd_anim_sound.cpp"), + Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_14.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_13.cpp"), Object(NonMatching, "d/snd/d_snd_source.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_7.cpp"), diff --git a/include/d/snd/d_snd_3d_actor.h b/include/d/snd/d_snd_3d_actor.h index 5136d7be..dd33d42d 100644 --- a/include/d/snd/d_snd_3d_actor.h +++ b/include/d/snd/d_snd_3d_actor.h @@ -41,6 +41,13 @@ public: virtual void d_vt_0x58() = 0; virtual void d_vt_0x5C() = 0; + void resetCachedRelativePositions(); + + void updatePositionTransformedByListener(); + void updateCameraDirectionDot(); + void updatePositionRelativeToCameraTarget(); + void calculatePositionRelativeToCameraTarget(); + void updateDistanceToCameraTarget(); void calculatePositionRelativeToListener(); void updatePositionRelativeToListener(); void updateDistanceToListener(); @@ -72,11 +79,12 @@ protected: /* 0x8C */ f32 a_field_0x8C; /* 0x90 */ f32 a_field_0x90; /* 0x94 */ f32 mDistanceToListener; - /* 0x98 */ f32 a_field_0x98; + /* 0x98 */ f32 mCameraDirectionDot; /* 0x9C */ f32 a_field_0x9C; /* 0xA0 */ nw4r::math::VEC3 mPositionRelativeToListener; /* 0xAC */ nw4r::math::VEC3 mPositionTransformedByListener; - /* 0xB8 */ u8 a_0xB8[0xC8 - 0xB8]; + /* 0xB8 */ f32 mDistanceToCameraTarget; + /* 0xBC */ nw4r::math::VEC3 mPositionRelativeToCameraTarget; /* 0xC8 */ UNKTYPE *a_field_0xC8; /* 0xCC */ u16 mFlags; /* 0xD0 */ nw4r::math::VEC3 mPositionRelativeToPlayer; diff --git a/include/d/snd/d_snd_3d_manager.h b/include/d/snd/d_snd_3d_manager.h index eb09988b..09b127fb 100644 --- a/include/d/snd/d_snd_3d_manager.h +++ b/include/d/snd/d_snd_3d_manager.h @@ -46,10 +46,18 @@ public: return mCameraTargetPosition; } + const mVec3_c &getNrmCameraDirection() const { + return mCameraDirectionNormalized; + } + const nw4r::math::VEC3 &getSndListenerPos() const { return mListener.GetPosition(); } + const nw4r::math::MTX34 &getSndListenerMatrix() const { + return mListener.GetMatrix(); + } + private: void updateListenerPos(f32); diff --git a/include/toBeSorted/music_mgrs.h b/include/toBeSorted/music_mgrs.h index 4a38e498..b394ceaa 100644 --- a/include/toBeSorted/music_mgrs.h +++ b/include/toBeSorted/music_mgrs.h @@ -16,7 +16,6 @@ extern "C" void fn_8035E310(dSndPlayerMgr_c *); extern "C" void fn_8035E820(dSndPlayerMgr_c *); extern "C" void fn_8035E880(dSndPlayerMgr_c *); extern "C" void fn_8035E790(dSndPlayerMgr_c *, UNKWORD, void *); -extern "C" bool fn_8035ED90(dSndPlayerMgr_c *, u8); extern "C" void *ENEMY_SOUND_MGR; extern "C" void fn_80362150(void *, u16); diff --git a/src/d/snd/d_snd_3d_actor.cpp b/src/d/snd/d_snd_3d_actor.cpp index b96ad650..3ece873a 100644 --- a/src/d/snd/d_snd_3d_actor.cpp +++ b/src/d/snd/d_snd_3d_actor.cpp @@ -3,8 +3,8 @@ #include "common.h" #include "d/a/d_a_player.h" #include "d/snd/d_snd_3d_manager.h" +#include "d/snd/d_snd_player_mgr.h" #include "nw4r/math/math_types.h" -#include "toBeSorted/music_mgrs.h" #include @@ -21,7 +21,7 @@ dSnd3DActor_c::dSnd3DActor_c(UNKTYPE *a1, u8 a2) a_field_0x8C(0.0f), a_field_0x90(INFINITY), mDistanceToListener(INFINITY), - a_field_0x98(0.0f), + mCameraDirectionDot(0.0f), a_field_0x9C(0.0f), a_field_0xC8(a1), mFlags(0), @@ -30,7 +30,7 @@ dSnd3DActor_c::dSnd3DActor_c(UNKTYPE *a1, u8 a2) resetFloats(); // Portability hazard SetUserParam(reinterpret_cast(this)); - if (fn_8035ED90(BGM_MGR, a2)) { + if (dSndPlayerMgr_c::GetInstance()->canUseThisPlayer(a2)) { a_field_0x7F = 1; } } @@ -48,6 +48,20 @@ void dSnd3DActor_c::updatePositionRelativeToListener() { } } +void dSnd3DActor_c::resetCachedRelativePositions() { + mPositionRelativeToPlayer.x = INFINITY; + mPositionRelativeToPlayer.y = INFINITY; + mPositionRelativeToPlayer.z = INFINITY; + + mPositionRelativeToListener.x = INFINITY; + mPositionRelativeToListener.y = INFINITY; + mPositionRelativeToListener.z = INFINITY; + + mPositionTransformedByListener.x = INFINITY; + mPositionTransformedByListener.y = INFINITY; + mPositionTransformedByListener.z = INFINITY; +} + void dSnd3DActor_c::calculatePositionRelativeToListener() { nw4r::math::VEC3Sub( &mPositionRelativeToListener, &GetPosition(), &dSnd3DManager_c::GetInstance()->getSndListenerPos() @@ -62,6 +76,46 @@ void dSnd3DActor_c::updateDistanceToListener() { } } +void dSnd3DActor_c::updatePositionTransformedByListener() { + if (!checkFlag(0x10)) { + MTXMultVec( + dSnd3DManager_c::GetInstance()->getSndListenerMatrix(), GetPosition(), mPositionTransformedByListener + ); + setFlag(0x10); + } +} + +void dSnd3DActor_c::updateCameraDirectionDot() { + if (!checkFlag(0x20)) { + updatePositionRelativeToListener(); + nw4r::math::VEC3 norm; + VECNormalize(mPositionRelativeToListener, norm); + mCameraDirectionDot = nw4r::math::VEC3Dot(&norm, dSnd3DManager_c::GetInstance()->getNrmCameraDirection()); + setFlag(0x20); + } +} + +void dSnd3DActor_c::updatePositionRelativeToCameraTarget() { + if (!checkFlag(0x4)) { + calculatePositionRelativeToCameraTarget(); + setFlag(0x4); + } +} + +void dSnd3DActor_c::calculatePositionRelativeToCameraTarget() { + nw4r::math::VEC3Sub( + &mPositionRelativeToCameraTarget, &GetPosition(), dSnd3DManager_c::GetInstance()->getCameraTargetPos() + ); +} + +void dSnd3DActor_c::updateDistanceToCameraTarget() { + if (!checkFlag(8)) { + updatePositionRelativeToCameraTarget(); + mDistanceToCameraTarget = VEC3Len(&mPositionRelativeToCameraTarget); + setFlag(8); + } +} + void dSnd3DActor_c::updatePositionRelativeToPlayer() { if (!checkFlag(0x40)) { nw4r::math::VEC3 linkTranslation = dAcPy_c::GetLink()->getCenterTranslation(); @@ -98,6 +152,8 @@ f32 dSnd3DActor_c::getDistanceToPlayer() { return mDistanceToPlayer; } +// here are functions that are probably in part copied from nw4r::snd::Sound3DCalculator + bool dSnd3DActor_c::hasPlayingSounds() const { for (int i = 0; i < ACTOR_PLAYER_COUNT; i++) { if (GetPlayingSoundCount(i) > 0) {