Added: Log warnings when setting excessively high max distances on sound sources

--HG--
branch : sound_dev
This commit is contained in:
kaetemi 2012-04-09 20:00:53 +02:00
parent 87ba382ef5
commit f858bbfbe9
3 changed files with 23 additions and 1 deletions

View file

@ -413,6 +413,13 @@ bool CSourceFMod::getSourceRelativeMode() const
// ****************************************************************** // ******************************************************************
void CSourceFMod::setMinMaxDistances( float mindist, float maxdist, bool /* deferred */ ) void CSourceFMod::setMinMaxDistances( float mindist, float maxdist, bool /* deferred */ )
{ {
static float maxSqrt = sqrt(std::numeric_limits<float>::max());
if (maxdist >= maxSqrt)
{
nlwarning("SOUND_DEV (FMod): Ridiculously high max distance set on source");
maxdist = maxSqrt;
}
_MinDist= mindist; _MinDist= mindist;
_MaxDist= maxdist; _MaxDist= maxdist;
if(_FModChannel!=-1) if(_FModChannel!=-1)

View file

@ -500,6 +500,14 @@ bool CSourceAL::getSourceRelativeMode() const
void CSourceAL::setMinMaxDistances( float mindist, float maxdist, bool /* deferred */) void CSourceAL::setMinMaxDistances( float mindist, float maxdist, bool /* deferred */)
{ {
nlassert( (mindist >= 0.0f) && (maxdist >= 0.0f) ); nlassert( (mindist >= 0.0f) && (maxdist >= 0.0f) );
static float maxSqrt = sqrt(std::numeric_limits<float>::max());
if (maxdist >= maxSqrt)
{
nlwarning("SOUND_DEV (OpenAL): Ridiculously high max distance set on source");
maxdist = maxSqrt;
}
_MinDistance = mindist; _MinDistance = mindist;
_MaxDistance = maxdist; _MaxDistance = maxdist;

View file

@ -793,7 +793,14 @@ bool CSourceXAudio2::getSourceRelativeMode() const
void CSourceXAudio2::setMinMaxDistances(float mindist, float maxdist, bool /* deferred */) void CSourceXAudio2::setMinMaxDistances(float mindist, float maxdist, bool /* deferred */)
{ {
// nldebug(NLSOUND_XAUDIO2_PREFIX "setMinMaxDistances %f, %f", mindist, maxdist); // nldebug(NLSOUND_XAUDIO2_PREFIX "setMinMaxDistances %f, %f", mindist, maxdist);
static float maxSqrt = sqrt(std::numeric_limits<float>::max());
if (maxdist >= maxSqrt)
{
nlwarning("SOUND_DEV (XAudio2): Ridiculously high max distance set on source");
maxdist = maxSqrt;
}
_Emitter.InnerRadius = mindist; _Emitter.InnerRadius = mindist;
_MinDistance = mindist; _MinDistance = mindist;
_MaxDistance = maxdist; _MaxDistance = maxdist;