Skip to content

Commit f82fb5e

Browse files
committed
Address review comments
1 parent d815113 commit f82fb5e

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

Core/GameEngine/Source/Common/Audio/GameAudio.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,15 @@ void AudioManager::reset()
282282
//-------------------------------------------------------------------------------------------------
283283
void 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

Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ void W3DView::updateCameraAreaConstraints()
504504
/*
505505
Note the following restrictions on camera constraints!
506506
507-
-- they assume that all maps are height 'm_groundLevel' at the edges.
507+
-- they assume that all maps are raised to the common ground level at the edges.
508508
(since you need to add some "buffer" around the edges of your map
509509
anyway, this shouldn't be an issue.)
510510
@@ -1864,9 +1864,7 @@ void W3DView::draw()
18641864
if( TheGlobalData->m_debugCamera )
18651865
{
18661866
UnsignedInt c = 0xaaffffff;
1867-
Coord3D worldPos;
1868-
worldPos.x = getPosition().x;
1869-
worldPos.y = getPosition().y;
1867+
Coord3D worldPos = getPosition();
18701868
worldPos.z = TheTerrainLogic->getGroundHeight(worldPos.x, worldPos.y);
18711869

18721870
Coord3D p1, p2;
@@ -3294,9 +3292,7 @@ void W3DView::moveAlongWaypointPath(Real milliseconds)
32943292
m_freezeTimeForCameraMovement = false;
32953293
View::setAngle(m_mcwpInfo.cameraAngle[m_mcwpInfo.numWaypoints]);
32963294

3297-
Coord3D pos;
3298-
pos.x = m_mcwpInfo.waypoints[m_mcwpInfo.numWaypoints].x;
3299-
pos.y = m_mcwpInfo.waypoints[m_mcwpInfo.numWaypoints].y;
3295+
Coord3D pos = m_mcwpInfo.waypoints[m_mcwpInfo.numWaypoints];
33003296
pos.z = m_mcwpInfo.groundHeight[m_mcwpInfo.numWaypoints];
33013297
setPosition(pos);
33023298
// Note - assuming that the scripter knows what he is doing, we adjust the constraints so that

0 commit comments

Comments
 (0)