MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / play

Method play

source/sound/SoundEffectsManager.cpp:83–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83void 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
104template<> SoundEffectsManager* Ogre::Singleton<SoundEffectsManager>::msSingleton = nullptr;

Callers 3

updateListenerMethod · 0.45
playSpatialSoundMethod · 0.45
playRelativeSoundMethod · 0.45

Calls 1

setPositionMethod · 0.45

Tested by

no test coverage detected