| 81 | } |
| 82 | |
| 83 | void GameSound::play(float x, float y, float z) |
| 84 | { |
| 85 | // Check whether the sound is spatial |
| 86 | if (mSound->getAttenuation() > 0.0f) |
| 87 | { |
| 88 | // Check the distance against the listener height and cull the sound accordingly. |
| 89 | // This permits to hear only the sound of the area seen in game, |
| 90 | // and avoid glitches in heard sounds. |
| 91 | sf::Vector3f lis = sf::Listener::getPosition(); |
| 92 | float distance2 = (lis.x - x) * (lis.x - x) + (lis.y - y) * (lis.y - y); |
| 93 | double height2 = (lis.z * lis.z) + (lis.z * lis.z); |
| 94 | |
| 95 | if (distance2 > height2) |
| 96 | return; |
| 97 | } |
| 98 | |
| 99 | mSound->setPosition(x, y, z); |
| 100 | mSound->play(); |
| 101 | } |
| 102 | |
| 103 | // SoundEffectsManager class |
| 104 | template<> SoundEffectsManager* Ogre::Singleton<SoundEffectsManager>::msSingleton = nullptr; |
no test coverage detected