diff options
| author | robojumper <robojumper@gmail.com> | 2025-06-14 21:45:38 +0200 |
|---|---|---|
| committer | robojumper <robojumper@gmail.com> | 2025-09-13 10:51:35 +0200 |
| commit | d3d5b5736339b5309d2ffec7f7af08ff4fb075e9 (patch) | |
| tree | 5ef672427a0177e6783ff561081d08d0d8bc37cf /src/d | |
| parent | b9ed6c26bda715f2bae11ce6c6e05165072728f8 (diff) | |
d_snd_distant_sound_actor_pool OK
Diffstat (limited to 'src/d')
| -rw-r--r-- | src/d/snd/d_snd_3d_actor.cpp | 2 | ||||
| -rw-r--r-- | src/d/snd/d_snd_distant_sound_actor.cpp | 4 | ||||
| -rw-r--r-- | src/d/snd/d_snd_distant_sound_actor_pool.cpp | 66 | ||||
| -rw-r--r-- | src/d/snd/d_snd_source.cpp | 2 |
4 files changed, 68 insertions, 6 deletions
diff --git a/src/d/snd/d_snd_3d_actor.cpp b/src/d/snd/d_snd_3d_actor.cpp index 51199b48..e55daee7 100644 --- a/src/d/snd/d_snd_3d_actor.cpp +++ b/src/d/snd/d_snd_3d_actor.cpp @@ -15,7 +15,7 @@ dSnd3DActor_c::dSnd3DActor_c(dSndSourceParam *pSourceParam, u8 sourceType) dSndPlayerMgr_c::GetInstance()->getSoundArchivePlayerForType(sourceType), dSnd3DManager_c::GetInstance()->getManager() ), a_field_0x7D(0), - a_field_0x7E(0), + mIsDisabled(false), a_field_0x7F(0), mIsPaused(0), a_field_0x84(0.0f), diff --git a/src/d/snd/d_snd_distant_sound_actor.cpp b/src/d/snd/d_snd_distant_sound_actor.cpp index 8f054e76..2a8196a2 100644 --- a/src/d/snd/d_snd_distant_sound_actor.cpp +++ b/src/d/snd/d_snd_distant_sound_actor.cpp @@ -54,7 +54,7 @@ void dSndDistantSoundActor_c::d_vt_0x5C(nw4r::snd::SoundHandle &handle, dSndSeSo bool dSndDistantSoundActor_c::startSound( u32 soundId, const nw4r::math::VEC3 &position, nw4r::snd::SoundHandle *pHandle ) { - if (a_field_0x7E) { + if (mIsDisabled) { return false; } @@ -72,7 +72,7 @@ bool dSndDistantSoundActor_c::startSound( bool dSndDistantSoundActor_c::holdSound( u32 soundId, const nw4r::math::VEC3 &position, nw4r::snd::SoundHandle *pHandle ) { - if (a_field_0x7E) { + if (mIsDisabled) { return false; } diff --git a/src/d/snd/d_snd_distant_sound_actor_pool.cpp b/src/d/snd/d_snd_distant_sound_actor_pool.cpp index 089e84a1..dc6adebf 100644 --- a/src/d/snd/d_snd_distant_sound_actor_pool.cpp +++ b/src/d/snd/d_snd_distant_sound_actor_pool.cpp @@ -3,7 +3,7 @@ #include "common.h" #include "d/snd/d_snd_distant_sound_actor.h" #include "d/snd/d_snd_source.h" -#include "m/m_vec.h" +#include "nw4r/math/math_types.h" #include "nw4r/ut/ut_list.h" #include <cmath> @@ -19,6 +19,31 @@ dSndDistantSoundActorPool_c::dSndDistantSoundActorPool_c() { sParam.reset(INFINITY); } +void dSndDistantSoundActorPool_c::initialize() { + field_0x4210 = 0; + for (int i = 0; i < POOL_SIZE; i++) { + mSounds[i].loadDefaultParam(); + mSounds[i].setSource(nullptr); + mSounds[i].initSource(nullptr); + } +} + +void dSndDistantSoundActorPool_c::calc() { + dSndDistantSoundActor_c *it, *next; + for (dSndDistantSoundActor_c *it = static_cast<dSndDistantSoundActor_c*>(nw4r::ut::List_GetFirst(&mActiveActors)); it != nullptr; it = next) { + next = static_cast<dSndDistantSoundActor_c*>(nw4r::ut::List_GetNext(&mActiveActors, it)); + if (it->hasPlayingSounds()) { + it->updatePosition(); + } else { + if (it->hasAttachedSource()) { + it->detachFromSource(); + } + it->resetHandle(); + removeFromActiveList(it); + } + } +} + dSndDistantSoundActor_c * dSndDistantSoundActorPool_c::acquireActor(u32 soundId, const nw4r::math::VEC3 *position, dSoundSource_c *source) { if (soundId == -1) { @@ -72,6 +97,25 @@ void dSndDistantSoundActorPool_c::addToActiveList(dSndDistantSoundActor_c *actor actor->setActive(true); } +void dSndDistantSoundActorPool_c::removeFromActiveList(dSndDistantSoundActor_c *actor) { + if (actor == nullptr) { + return; + } + if (!actor->isActive()) { + return; + } + nw4r::ut::List_Remove(&mActiveActors, actor); + actor->setActive(false); +} + +bool dSndDistantSoundActorPool_c::startSound(u32 soundId, const nw4r::math::VEC3 *position) { + dSndDistantSoundActor_c *ac = acquireActor(soundId, position, nullptr); + if (ac != nullptr) { + return ac->startSound(soundId, *position, nullptr); + } + return false; +} + dSndDistantSoundActor_c *dSndDistantSoundActorPool_c::findActiveActor(u32 soundId, dSoundSource_c *source) { for (dSndDistantSoundActor_c *it = static_cast<dSndDistantSoundActor_c*>(nw4r::ut::List_GetFirst(&mActiveActors)); it != nullptr; it = static_cast<dSndDistantSoundActor_c*>(nw4r::ut::List_GetNext(&mActiveActors, it))) { if (it->isAttachedSource(source) && it->isPlayingSound(soundId)) { @@ -97,8 +141,26 @@ bool dSndDistantSoundActorPool_c::holdSound(u32 soundId, const nw4r::math::VEC3 } +void dSndDistantSoundActorPool_c::setAllPause(bool flag, s32 fadeFrames) { + for (dSndDistantSoundActor_c *it = static_cast<dSndDistantSoundActor_c*>(nw4r::ut::List_GetFirst(&mActiveActors)); it != nullptr; it = static_cast<dSndDistantSoundActor_c*>(nw4r::ut::List_GetNext(&mActiveActors, it))) { + it->setPause(flag, fadeFrames); + } +} + +void dSndDistantSoundActorPool_c::disableAll() { + for (int i = 0; i < POOL_SIZE; i++) { + mSounds[i].setDisabled(true); + } +} + +void dSndDistantSoundActorPool_c::enableAll() { + for (int i = 0; i < POOL_SIZE; i++) { + mSounds[i].setDisabled(false); + } +} + void dSndDistantSoundActorPool_c::onChangeStage() { - mVec3_c v(INFINITY, INFINITY, INFINITY); + nw4r::math::VEC3 v(INFINITY, INFINITY, INFINITY); for (int i = 0; i < POOL_SIZE; i++) { mSounds[i].SetPosition(v); } diff --git a/src/d/snd/d_snd_source.cpp b/src/d/snd/d_snd_source.cpp index 9a021cc6..5bd17935 100644 --- a/src/d/snd/d_snd_source.cpp +++ b/src/d/snd/d_snd_source.cpp @@ -147,7 +147,7 @@ void dSoundSource_c::setPause(bool flag, int fadeFrames) { PauseAllSound(flag, fadeFrames); pauseAllDistantSounds(flag, fadeFrames); mIsPaused = 0; - } else if (a_field_0x7E == 0) { + } else if (!mIsDisabled) { PauseAllSound(flag, fadeFrames); pauseAllDistantSounds(flag, fadeFrames); mIsPaused = 1; |
