[SOLVED] Code error in _requestSoundSource


29-05-2014 19:14:44

Near the bottom of OgreOggSoundManager::_requestSoundSource() it is calculating the distance from the listener that the snd1 and sound variables are, but it looks like it is assigning the results incorrectly. The current code looks like this:

// Sort by distance
float d1 = 0.f,
d2 = 0.f;

// Sort list by distance

// Lists should be sorted: Active-->furthest to Nearest
// Reactivate-->Nearest to furthest
OgreOggISound* snd1 = mActiveSounds.front();

if ( snd1->isRelativeToListener() )
d1 = snd1->getPosition().length();
d1 = snd1->getPosition().distance(mListener->getPosition());

if ( sound->isRelativeToListener() )
d1 = sound->getPosition().length();
d1 = sound->getPosition().distance(mListener->getPosition());

// Needs swapping?
if ( d1>d2 )
// stuff here

It's assigning the results of both calculation to d1, which means d2 will always be 0.0. Is this what it's supposed to be doing? It seems to me that the second block calculating the distance for the sound variable should be setting d2, not d1.


04-06-2014 21:29:59

I think your right, corrected.