Integrate amuse listener and emitter

This commit is contained in:
Jack Andersen 2017-09-18 17:59:50 -10:00
parent 7d125e504a
commit 5797e0c773
4 changed files with 27 additions and 18 deletions

View File

@ -38,6 +38,7 @@ bool CSfxManager::m_auxProcessingEnabled = false;
float CSfxManager::m_reverbAmount = 1.f;
CSfxManager::EAuxEffect CSfxManager::m_activeEffect = CSfxManager::EAuxEffect::None;
CSfxManager::EAuxEffect CSfxManager::m_nextEffect = CSfxManager::EAuxEffect::None;
std::shared_ptr<amuse::Listener> CSfxManager::m_listener;
u16 CSfxManager::kMaxPriority;
u16 CSfxManager::kMedPriority;
@ -132,7 +133,7 @@ void CSfxManager::CSfxEmitterWrapper::Play()
x24_parmData.x0_pos.v, x24_parmData.xc_dir.v,
x24_parmData.x18_maxDist, x24_parmData.x1c_distComp,
x24_parmData.x24_sfxId, x24_parmData.x27_minVol,
x24_parmData.x26_maxVol);
x24_parmData.x26_maxVol, (x24_parmData.x20_flags & 0x8) != 0);
if (x50_emitterHandle)
SetPlaying(true);
@ -176,16 +177,14 @@ u16 CSfxManager::CSfxEmitterWrapper::GetSfxId() const
void CSfxManager::CSfxEmitterWrapper::UpdateEmitterSilent()
{
x50_emitterHandle->setPos(x24_parmData.x0_pos.v);
x50_emitterHandle->setDir(x24_parmData.xc_dir.v);
x50_emitterHandle->setVectors(x24_parmData.x0_pos.v, x24_parmData.xc_dir.v);
x50_emitterHandle->setMaxVol(1.f / 127.f);
x55_cachedMaxVol = x24_parmData.x26_maxVol;
}
void CSfxManager::CSfxEmitterWrapper::UpdateEmitter()
{
x50_emitterHandle->setPos(x24_parmData.x0_pos.v);
x50_emitterHandle->setDir(x24_parmData.xc_dir.v);
x50_emitterHandle->setVectors(x24_parmData.x0_pos.v, x24_parmData.xc_dir.v);
x50_emitterHandle->setMaxVol(x55_cachedMaxVol);
}
@ -264,17 +263,27 @@ void CSfxManager::TurnOffChannel(ESfxChannels chan)
}
}
void CSfxManager::AddListener(ESfxChannels,
const zeus::CVector3f& vec1, const zeus::CVector3f& vec2,
const zeus::CVector3f& right, const zeus::CVector3f& up,
float, float, float, u32, u8)
void CSfxManager::AddListener(ESfxChannels channel,
const zeus::CVector3f& pos, const zeus::CVector3f& dir,
const zeus::CVector3f& heading, const zeus::CVector3f& up,
float frontRadius, float surroundRadius, float soundSpeed,
u32 flags /* 0x1 for doppler */, float vol)
{
if (m_listener)
CAudioSys::GetAmuseEngine().removeListener(m_listener.get());
m_listener = CAudioSys::GetAmuseEngine().addListener(pos.v, dir.v, heading.v, up.v, frontRadius,
surroundRadius, soundSpeed, vol);
}
void CSfxManager::UpdateListener(const zeus::CVector3f& pos, const zeus::CVector3f& dir,
const zeus::CVector3f& heading, const zeus::CVector3f& up,
u8 vol)
float vol)
{
if (m_listener)
{
m_listener->setVectors(pos.v, dir.v, heading.v, up.v);
m_listener->setVolume(vol);
}
}
s16 CSfxManager::GetRank(CBaseSfxWrapper* sfx)
@ -418,8 +427,7 @@ void CSfxManager::UpdateEmitter(const CSfxHandle& handle, const zeus::CVector3f&
emitter.GetEmitterData().xc_dir = dir;
emitter.GetEmitterData().x26_maxVol = maxVol;
amuse::Emitter& h = *emitter.GetHandle();
h.setPos(pos.v);
h.setDir(dir.v);
h.setVectors(pos.v, dir.v);
h.setMaxVol(maxVol);
}

View File

@ -189,6 +189,7 @@ public:
static float m_reverbAmount;
static EAuxEffect m_activeEffect;
static EAuxEffect m_nextEffect;
static std::shared_ptr<amuse::Listener> m_listener;
static u16 kMaxPriority;
static u16 kMedPriority;
@ -202,14 +203,14 @@ public:
static void TurnOnChannel(ESfxChannels);
static void TurnOffChannel(ESfxChannels);
static ESfxChannels GetCurrentChannel() {return m_currentChannel;}
static void AddListener(ESfxChannels,
static void AddListener(ESfxChannels channel,
const zeus::CVector3f& pos, const zeus::CVector3f& dir,
const zeus::CVector3f& heading, const zeus::CVector3f& up,
float frontRadius, float surroundRadius, float soundSpeed,
u32 flags /* 0x1 for doppler */, u8 vol);
u32 flags /* 0x1 for doppler */, float vol);
static void UpdateListener(const zeus::CVector3f& pos, const zeus::CVector3f& dir,
const zeus::CVector3f& heading, const zeus::CVector3f& up,
u8 vol);
float vol);
static bool PlaySound(const CSfxHandle& handle);
static void StopSound(const CSfxHandle& handle);

View File

@ -29,7 +29,7 @@ float CCameraManager::sThirdPersonFOV = 60.f;
CCameraManager::CCameraManager(TUniqueId curCameraId) : x0_curCameraId(curCameraId)
{
CSfxManager::AddListener(CSfxManager::ESfxChannels::Game, zeus::CVector3f::skZero, zeus::CVector3f::skZero,
{1.f, 0.f, 0.f}, {0.f, 0.f, 1.f}, 50.f, 50.f, 1000.f, 1, 0x7f);
{1.f, 0.f, 0.f}, {0.f, 0.f, 1.f}, 50.f, 50.f, 1000.f, 1, 1.f);
sAspect = float(g_Viewport.x8_width / g_Viewport.xc_height);
sFirstPersonFOV = g_tweakGame->GetFirstPersonFOV();
}
@ -257,7 +257,7 @@ void CCameraManager::UpdateRumble(float, CStateManager&)
void CCameraManager::UpdateListener(CStateManager& mgr)
{
const zeus::CTransform xf = GetCurrentCameraTransform(mgr);
CSfxManager::UpdateListener(xf.origin, zeus::CVector3f::skZero, xf.frontVector(), xf.upVector(), 127);
CSfxManager::UpdateListener(xf.origin, zeus::CVector3f::skZero, xf.frontVector(), xf.upVector(), 1.f);
}
float CCameraManager::CalculateFogDensity(CStateManager& mgr, const CScriptWater* water)

2
amuse

@ -1 +1 @@
Subproject commit aef2b2a7074e0947771d92ac52069841dad69b20
Subproject commit c6781df90a88ffd30936a45b7336761d099d4de3