From e0cb8db914e2dae4c944672a24c2f65648b271ff Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 9 Feb 2016 16:51:23 -0800 Subject: [PATCH] handle zero distance from listener to source --- assignment-client/src/audio/AudioMixer.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index 62d6689fe7..34f636a89e 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -169,8 +169,13 @@ float AudioMixer::azimuthForSource(const PositionalAudioStream& streamToAdd, con // project the rotated source position vector onto the XZ plane rotatedSourcePosition.y = 0.0f; - // produce an oriented angle about the y-axis - return glm::orientedAngle(glm::vec3(0.0f, 0.0f, -1.0f), glm::normalize(rotatedSourcePosition), glm::vec3(0.0f, -1.0f, 0.0f)); + if (rotatedSourcePosition != glm::vec3()) { + // produce an oriented angle about the y-axis + return glm::orientedAngle(glm::vec3(0.0f, 0.0f, -1.0f), glm::normalize(rotatedSourcePosition), glm::vec3(0.0f, -1.0f, 0.0f)); + } else { + // there is no distance between listener and source - return no azimuth + return 0; + } } void AudioMixer::addStreamToMixForListeningNodeWithStream(AudioMixerClientData& listenerNodeData,