@@ -282,15 +282,15 @@ void AudioManager::reset()
282282// -------------------------------------------------------------------------------------------------
283283void AudioManager::update ()
284284{
285- Coord3D microphonePos;
286285 Coord3D cameraPivot = TheTacticalView->getPosition ();
287286 Real angle = TheTacticalView->getAngle ();
288287 Matrix3D rot = Matrix3D::Identity;
289288 rot.Rotate_Z ( angle );
290289 Vector3 forward ( 0 , 1 , 0 );
291290 rot.mulVector3 ( forward );
292291
293- const Real desiredHeight = m_audioSettings->m_microphoneDesiredHeightAboveTerrain + cameraPivot.z ;
292+ const Real desiredHeightRel = m_audioSettings->m_microphoneDesiredHeightAboveTerrain ;
293+ const Real desiredHeightAbs = desiredHeightRel + cameraPivot.z ;
294294 const Real maxPercentage = m_audioSettings->m_microphoneMaxPercentageBetweenGroundAndCamera ;
295295
296296 Coord3D lookTo;
@@ -306,15 +306,15 @@ void AudioManager::update()
306306 groundToCameraVector.sub ( &cameraPivot );
307307 Real bestScaleFactor;
308308
309- if ( cameraPos.z <= desiredHeight || groundToCameraVector.z <= 0 .0f )
309+ if ( cameraPos.z <= desiredHeightAbs || groundToCameraVector.z <= 0 .0f )
310310 {
311311 // Use the percentage calculation!
312312 bestScaleFactor = maxPercentage;
313313 }
314314 else
315315 {
316316 // Calculate the stopping position of the groundToCameraVector when we force z to be m_microphoneDesiredHeightAboveTerrain
317- Real zScale = desiredHeight / groundToCameraVector.z ;
317+ Real zScale = desiredHeightRel / groundToCameraVector.z ;
318318
319319 // Use the smallest of the two scale calculations
320320 bestScaleFactor = MIN ( maxPercentage, zScale );
@@ -324,6 +324,7 @@ void AudioManager::update()
324324 groundToCameraVector.scale ( bestScaleFactor );
325325
326326 // Set the microphone to be the ground position adjusted for terrain plus the vector we just calculated.
327+ Coord3D microphonePos;
327328 microphonePos.set ( &cameraPivot );
328329 microphonePos.add ( &groundToCameraVector );
329330
0 commit comments