let's go with the distant sound name for now

This commit is contained in:
robojumper
2025-06-13 16:20:06 +02:00
parent f9e95f9bb0
commit f56b72a2e0
15 changed files with 334 additions and 62 deletions
+8 -3
View File
@@ -16,9 +16,9 @@ public:
return true;
}
virtual void d_vt_0x34(const nw4r::math::VEC3 &);
virtual void setPosition(const nw4r::math::VEC3 &);
virtual void d_vt_0x38(bool flag, int fadeFrames) = 0;
virtual void setPause(bool flag, int fadeFrames) = 0;
virtual UNKWORD d_vt_0x3C() {
return 0;
@@ -63,6 +63,11 @@ public:
return mDistanceToListener;
}
const dSndSourceParam *getSourceParam() const {
return mpSourceParam;
}
void setSourceParam(const dSndSourceParam *param);
bool hasPlayingSounds() const;
bool isPlayingSound(u32 id);
@@ -74,7 +79,7 @@ protected:
/* 0x7D */ u8 a_field_0x7D;
/* 0x7E */ u8 a_field_0x7E;
/* 0x7F */ u8 a_field_0x7F;
/* 0x80 */ u8 a_field_0x80;
/* 0x80 */ u8 mIsPaused;
/* 0x84 */ f32 a_field_0x84;
/* 0x88 */ f32 a_field_0x88;
/* 0x8C */ f32 a_field_0x8C;
+53
View File
@@ -0,0 +1,53 @@
#ifndef D_SND_DISTANT_SOUND_ACTOR_H
#define D_SND_DISTANT_SOUND_ACTOR_H
#include "common.h"
#include "d/snd/d_snd_3d_actor.h"
#include "m/m_vec.h"
#include "nw4r/math/math_types.h"
#include "nw4r/snd/snd_SoundHandle.h"
#include "nw4r/ut/ut_list.h"
class dSoundSource_c;
/**
* A sound actor to be borrowed by sound sources when they want to play
* sounds at a specific position.
*
* Sound sources correspond to actors, but e.g. projectile hit effects, grass
* cutting sounds, sword hit effects, ... have to be played where the hit occurred.
* This pool allows sound sources to borrow sound actors for these purposes.
*/
class dSndDistantSoundActor_c : public dSnd3DActor_c {
public:
dSndDistantSoundActor_c();
virtual void setPause(bool flag, int fadeFrames) override;
virtual void d_vt_0x58() override;
virtual void d_vt_0x5C() override;
void initSource(dSoundSource_c *pSource);
void setSourceDirectly(dSoundSource_c *pSource);
void loadDefaultParam();
void detachFromSource();
void updatePosition();
bool startSound(u32 soundId, const nw4r::math::VEC3 &position, nw4r::snd::SoundHandle *pHandle);
bool holdSound(u32 soundId, const nw4r::math::VEC3 &position, nw4r::snd::SoundHandle *pHandle);
bool isAttachedSource(dSoundSource_c *source) const {
return mpSoundSource == source;
}
private:
/* 0x0E4 */ nw4r::ut::Node mDistantLink;
/* 0x0EC */ u8 _0x0EC[0x0F4 - 0x0EC];
/* 0x0F4 */ UNKWORD field_0x0F4;
/* 0x0F8 */ dSoundSource_c *mpSoundSource;
/* 0x0FC */ nw4r::snd::SoundHandle mSoundHandle;
/* 0x100 */ nw4r::snd::SoundHandle *mpSoundHandle;
/* 0x104 */ u8 field_0x104;
/* 0x105 */ bool mUseSourcePosition;
};
#endif
@@ -0,0 +1,35 @@
#ifndef D_SND_DISTANT_SOUND_ACTOR_POOL_H
#define D_SND_DISTANT_SOUND_ACTOR_POOL_H
#include "common.h"
#include "d/snd/d_snd_misc.h"
#include "d/snd/d_snd_util.h"
#include "d/snd/d_snd_distant_sound_actor.h"
#include "nw4r/ut/ut_list.h"
SND_DISPOSER_FORWARD_DECL(dSndDistantSoundActorPool_c);
/**
* A pool for distant sounds actors. Sound sources will borrow
* actors from this pool when they want to play a sound
* at a specific position.
*/
class dSndDistantSoundActorPool_c {
SND_DISPOSER_MEMBERS(dSndDistantSoundActorPool_c);
public:
dSndDistantSoundActorPool_c();
static dSndSourceParam& getSourceParam() {
return sParam;
}
private:
/* 0x0010 */ dSndDistantSoundActor_c mSounds[64];
/* 0x4210 */ UNKWORD field_0x4210;
/* 0x4214 */ nw4r::ut::List mList;
static dSndSourceParam sParam;
};
#endif
+2 -2
View File
@@ -11,12 +11,12 @@ struct dSndSourceParam {
reset();
}
void reset() {
void reset(f32 value_0x10 = 5000.0f) {
field_0x00 = 300.0;
field_0x04 = 1000.0f;
field_0x08 = 100.0f;
field_0x0C = 400.0f;
field_0x10 = 5000.0f;
field_0x10 = value_0x10;
}
/* 0x00 */ f32 field_0x00;
+10 -7
View File
@@ -9,6 +9,7 @@
#include <cstring>
class dSndSourceGroup_c;
class dSndDistantSoundActor_c;
/** Manages sound relating to a particular actor. */
/** Size: probably 0x15C */
@@ -46,15 +47,17 @@ public:
virtual void d_s_vt_0x1AC();
virtual void d_s_vt_0x1B0();
virtual void d_s_vt_0x1B4();
virtual void d_s_vt_0x1B8();
virtual void d_s_vt_0x1BC();
virtual void d_s_vt_0x1C0();
virtual void d_s_vt_0x1C4(bool flag, int fadeFrames);
virtual void attachDistantSound(dSndDistantSoundActor_c *);
virtual void detachDistantSound(dSndDistantSoundActor_c *);
virtual void detachAllDistantSounds();
virtual bool hasDistantSounds() const {
return nw4r::ut::List_GetFirstConst(&mDistantSoundList) != nullptr;
}
virtual void pauseAllDistantSounds(bool flag, int fadeFrames);
virtual void d_s_vt_0x1C8();
virtual void d_s_vt_0x1CC();
virtual void d_vt_0x38(bool flag, int fadeFrames) override;
virtual void setPause(bool flag, int fadeFrames) override;
virtual void d_s_vt_0x1D4();
virtual void d_s_vt_0x1D8();
@@ -101,7 +104,7 @@ private:
/* 0x104 */ UNKWORD field_0x104;
/* 0x108 */ UNKWORD field_0x108;
/* 0x10C */ UNKWORD field_0x10C;
/* 0x110 */ nw4r::ut::List field_0x110; // node offset 0xEC
/* 0x110 */ nw4r::ut::List mDistantSoundList; // node offset 0xEC -> dSndDistantSoundActor_c
/* 0x11C */ UNKWORD field_0x11C;
/* 0x120 */ nw4r::ut::List field_0x120; // node offset 0x4
/* 0x12C */ nw4r::ut::List field_0x12C; // node offset 0x4
+3
View File
@@ -58,6 +58,9 @@ enum SoundSourceType_e {
// 59: ? (9)
SND_SOURCE_59 = 59,
// dSndDistantSoundActor_c, not a real sound source type
SND_SOURCE_DISTANT = 61,
};
enum SoundSourceCategory_e {
+4
View File
@@ -40,6 +40,10 @@ public:
return field_0x11C;
}
f32 getField_0x49C() const {
return field_0x49C;
}
void resetStageName() {
field_0x098 = "EVENT_NONE";
}