mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 09:19:01 +00:00
Changed: CListenerFMod inherits from NLMISC::CManualSingleton<CListenerFMod>
This commit is contained in:
parent
032a6d67bc
commit
8a5d3811ae
4 changed files with 23 additions and 42 deletions
|
@ -26,18 +26,10 @@ namespace NLSOUND
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
// ***************************************************************************
|
|
||||||
// The instance of the singleton
|
|
||||||
CListenerFMod *CListenerFMod::_Instance = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
CListenerFMod::CListenerFMod() //: IListener()
|
CListenerFMod::CListenerFMod() //: IListener()
|
||||||
: _Pos(CVector::Null), _Vel(CVector::Null), _Front(CVector::J), _Up(CVector::K)
|
: _Pos(CVector::Null), _Vel(CVector::Null), _Front(CVector::J), _Up(CVector::K)
|
||||||
{
|
{
|
||||||
if ( _Instance == NULL )
|
|
||||||
{
|
|
||||||
_Instance = this;
|
|
||||||
_RolloffFactor= 1.f;
|
_RolloffFactor= 1.f;
|
||||||
_Pos= CVector::Null;
|
_Pos= CVector::Null;
|
||||||
_Vel= CVector::Null;
|
_Vel= CVector::Null;
|
||||||
|
@ -52,11 +44,6 @@ CListenerFMod::CListenerFMod() //: IListener()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
//nlerror( "Listener singleton instanciated twice" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
@ -65,7 +52,6 @@ CListenerFMod::~CListenerFMod()
|
||||||
//nldebug("Destroying FMod listener");
|
//nldebug("Destroying FMod listener");
|
||||||
|
|
||||||
release();
|
release();
|
||||||
_Instance = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,11 @@
|
||||||
#ifndef NL_LISTENER_FMOD_H
|
#ifndef NL_LISTENER_FMOD_H
|
||||||
#define NL_LISTENER_FMOD_H
|
#define NL_LISTENER_FMOD_H
|
||||||
|
|
||||||
#include <nel/sound/driver/listener.h>
|
#include "nel/sound/driver/listener.h"
|
||||||
|
#include "nel/misc/singleton.h"
|
||||||
|
|
||||||
namespace NLSOUND {
|
namespace NLSOUND
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,7 +34,7 @@ namespace NLSOUND {
|
||||||
* \author Nevrax France
|
* \author Nevrax France
|
||||||
* \date 2002
|
* \date 2002
|
||||||
*/
|
*/
|
||||||
class CListenerFMod : public IListener
|
class CListenerFMod : public IListener, public NLMISC::CManualSingleton<CListenerFMod>
|
||||||
{
|
{
|
||||||
friend class CSoundDriverFMod;
|
friend class CSoundDriverFMod;
|
||||||
|
|
||||||
|
@ -44,9 +46,6 @@ public:
|
||||||
/// Deconstructor
|
/// Deconstructor
|
||||||
virtual ~CListenerFMod();
|
virtual ~CListenerFMod();
|
||||||
|
|
||||||
/// Return the instance of the singleton
|
|
||||||
static CListenerFMod* instance() { return _Instance; }
|
|
||||||
|
|
||||||
/// \name Listener properties
|
/// \name Listener properties
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
|
@ -109,9 +108,6 @@ private:
|
||||||
/// Release all DirectSound resources
|
/// Release all DirectSound resources
|
||||||
void release();
|
void release();
|
||||||
|
|
||||||
/// The instance of the singleton
|
|
||||||
static CListenerFMod *_Instance;
|
|
||||||
|
|
||||||
// Nel Basis
|
// Nel Basis
|
||||||
NLMISC::CVector _Pos;
|
NLMISC::CVector _Pos;
|
||||||
NLMISC::CVector _Vel;
|
NLMISC::CVector _Vel;
|
||||||
|
|
|
@ -149,9 +149,9 @@ CSoundDriverFMod::~CSoundDriverFMod()
|
||||||
|
|
||||||
|
|
||||||
// Assure that the listener has released all resources before closing down FMod
|
// Assure that the listener has released all resources before closing down FMod
|
||||||
if (CListenerFMod::instance() != 0)
|
if (CListenerFMod::getInstance() != 0)
|
||||||
{
|
{
|
||||||
CListenerFMod::instance()->release();
|
CListenerFMod::getInstance()->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close FMod
|
// Close FMod
|
||||||
|
@ -283,9 +283,9 @@ void CSoundDriverFMod::update()
|
||||||
IListener *CSoundDriverFMod::createListener()
|
IListener *CSoundDriverFMod::createListener()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (CListenerFMod::instance() != NULL)
|
if (CListenerFMod::isInitialized())
|
||||||
{
|
{
|
||||||
return CListenerFMod::instance();
|
return CListenerFMod::getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !_FModOk )
|
if ( !_FModOk )
|
||||||
|
@ -353,7 +353,7 @@ void CSoundDriverFMod::commit3DChanges()
|
||||||
// We handle the volume of the source according to the distance
|
// We handle the volume of the source according to the distance
|
||||||
// ourselves. Call updateVolume() to, well..., update the volume
|
// ourselves. Call updateVolume() to, well..., update the volume
|
||||||
// according to, euh ..., the new distance!
|
// according to, euh ..., the new distance!
|
||||||
CListenerFMod* listener = CListenerFMod::instance();
|
CListenerFMod* listener = CListenerFMod::getInstance();
|
||||||
if(listener)
|
if(listener)
|
||||||
{
|
{
|
||||||
const CVector &origin = listener->getPos();
|
const CVector &origin = listener->getPos();
|
||||||
|
|
|
@ -42,15 +42,14 @@ CSourceFMod::CSourceFMod( uint sourcename )
|
||||||
|
|
||||||
_PosRelative= false;
|
_PosRelative= false;
|
||||||
_Loop = false;
|
_Loop = false;
|
||||||
_Gain = 1.0f;
|
_Gain = NLSOUND_DEFAULT_GAIN;
|
||||||
_Alpha = 0.0;
|
_Alpha = 0.0;
|
||||||
_Pos= _Vel= CVector::Null;
|
_Pos= _Vel= CVector::Null;
|
||||||
_Front= CVector::J;
|
_Front= CVector::J;
|
||||||
_MinDist= 1.f;
|
_MinDist= 1.f;
|
||||||
_MaxDist= FLT_MAX;
|
_MaxDist= numeric_limits<float>::max();
|
||||||
_Pitch= 1.0f;
|
_Pitch= 1.0f;
|
||||||
|
|
||||||
|
|
||||||
_FModChannel= -1;
|
_FModChannel= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +179,7 @@ bool CSourceFMod::play()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// manual rolloff => recompute according to position
|
// manual rolloff => recompute according to position
|
||||||
CListenerFMod *listener = CListenerFMod::instance();
|
CListenerFMod *listener = CListenerFMod::getInstance();
|
||||||
if (listener) updateVolume(listener->getPos());
|
if (listener) updateVolume(listener->getPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,7 +509,7 @@ void CSourceFMod::updateFModPos()
|
||||||
// If relative, must transform to absolute
|
// If relative, must transform to absolute
|
||||||
if(_PosRelative)
|
if(_PosRelative)
|
||||||
{
|
{
|
||||||
CListenerFMod *lsr= CListenerFMod::instance();
|
CListenerFMod *lsr= CListenerFMod::getInstance();
|
||||||
if(lsr)
|
if(lsr)
|
||||||
{
|
{
|
||||||
wpos= lsr->getPosMatrix() * wpos;
|
wpos= lsr->getPosMatrix() * wpos;
|
||||||
|
|
Loading…
Reference in a new issue