@@ -166,6 +166,8 @@ W3DView::W3DView()
166166 m_shakerAngles.Y =0 .0f ;
167167 m_shakerAngles.Z =0 .0f ;
168168
169+ m_recalcCamera = true ;
170+
169171}
170172
171173// -------------------------------------------------------------------------------------------------
@@ -606,9 +608,6 @@ void W3DView::init( void )
606608 // create our 3D camera
607609 m_3DCamera = NEW_REF ( CameraClass, () );
608610
609-
610- setCameraTransform ();
611-
612611 // create our 2D camera for the GUI overlay
613612 m_2DCamera = NEW_REF ( CameraClass, () );
614613 m_2DCamera->Set_Position ( Vector3 ( 0 , 0 , 1 ) );
@@ -621,6 +620,7 @@ void W3DView::init( void )
621620
622621 m_scrollAmountCutoff = TheGlobalData->m_scrollAmountCutoff ;
623622
623+ m_recalcCamera = true ;
624624}
625625
626626// -------------------------------------------------------------------------------------------------
@@ -1072,7 +1072,6 @@ void W3DView::stepView()
10721072void W3DView::update (void )
10731073{
10741074 // USE_PERF_TIMER(W3DView_updateView)
1075- Bool recalcCamera = false ;
10761075 Bool didScriptedMovement = false ;
10771076#ifdef LOG_FRAME_TIMES
10781077 __int64 curTime64,freq64;
@@ -1174,8 +1173,6 @@ void W3DView::update(void)
11741173 Matrix3D camXForm;
11751174 camXForm.Look_At (camtran,objPos,0 );
11761175 m_3DCamera->Set_Transform (camXForm);
1177-
1178- recalcCamera = false ; // we already did it
11791176 }
11801177 }
11811178 }
@@ -1256,7 +1253,7 @@ void W3DView::update(void)
12561253
12571254 m_groundLevel = objpos.z ;
12581255 didScriptedMovement = true ;
1259- recalcCamera = true ;
1256+ m_recalcCamera = true ;
12601257 }
12611258 }
12621259 }
@@ -1265,7 +1262,7 @@ void W3DView::update(void)
12651262 // If we aren't frozen for debug, allow the camera to follow scripted movements.
12661263 if (updateCameraMovements ()) {
12671264 didScriptedMovement = true ;
1268- recalcCamera = true ;
1265+ m_recalcCamera = true ;
12691266 }
12701267 } else {
12711268 if (m_doingRotateCamera || m_doingMoveCameraOnWaypointPath || m_doingPitchCamera || m_doingZoomCamera || m_doingScriptedCameraLock) {
@@ -1277,13 +1274,13 @@ void W3DView::update(void)
12771274 //
12781275 if (m_shakeIntensity > 0 .01f )
12791276 {
1280- recalcCamera = true ;
1277+ m_recalcCamera = true ;
12811278 }
12821279
12831280 // Process New C3 Camera Shaker system
12841281 if (CameraShakerSystem.IsCameraShaking ())
12851282 {
1286- recalcCamera = true ;
1283+ m_recalcCamera = true ;
12871284 }
12881285
12891286 /*
@@ -1330,7 +1327,7 @@ void W3DView::update(void)
13301327 if (fabs (zoomAdj) >= 0 .0001f )
13311328 {
13321329 m_zoom += zoomAdj;
1333- recalcCamera = true ;
1330+ m_recalcCamera = true ;
13341331 }
13351332 }
13361333 }
@@ -1340,8 +1337,10 @@ void W3DView::update(void)
13401337 }
13411338
13421339 // (gth) C&C3 if m_isCameraSlaved then force the camera to update each frame
1343- if (recalcCamera || m_isCameraSlaved) {
1340+ if (m_recalcCamera || m_isCameraSlaved)
1341+ {
13441342 setCameraTransform ();
1343+ m_recalcCamera = false ;
13451344 }
13461345
13471346#ifdef DO_SEISMIC_SIMULATIONS
@@ -1797,9 +1796,7 @@ void W3DView::scrollBy( Coord2D *delta )
17971796 // m_cameraConstraintValid = false; // pos change does NOT invalidate cam constraints
17981797
17991798 m_doingRotateCamera = false ;
1800- // set new camera position
1801- setCameraTransform ();
1802-
1799+ m_recalcCamera = true ;
18031800 }
18041801
18051802}
@@ -1808,8 +1805,7 @@ void W3DView::scrollBy( Coord2D *delta )
18081805// -------------------------------------------------------------------------------------------------
18091806void W3DView::forceRedraw ()
18101807{
1811- // set the camera
1812- setCameraTransform ();
1808+ m_recalcCamera = true ;
18131809}
18141810
18151811// -------------------------------------------------------------------------------------------------
@@ -1826,8 +1822,7 @@ void W3DView::setAngle( Real radians )
18261822 m_doingPitchCamera = false ;
18271823 m_doingZoomCamera = false ;
18281824 m_doingScriptedCameraLock = false ;
1829- // set the camera
1830- setCameraTransform ();
1825+ m_recalcCamera = true ;
18311826}
18321827
18331828// -------------------------------------------------------------------------------------------------
@@ -1842,8 +1837,7 @@ void W3DView::setPitch( Real radians )
18421837 m_doingPitchCamera = false ;
18431838 m_doingZoomCamera = false ;
18441839 m_doingScriptedCameraLock = false ;
1845- // set the camera
1846- setCameraTransform ();
1840+ m_recalcCamera = true ;
18471841}
18481842
18491843// -------------------------------------------------------------------------------------------------
@@ -1853,7 +1847,7 @@ void W3DView::setAngleToDefault( void )
18531847{
18541848 View::setAngleToDefault ();
18551849
1856- setCameraTransform () ;
1850+ m_recalcCamera = true ;
18571851}
18581852
18591853// -------------------------------------------------------------------------------------------------
@@ -1865,7 +1859,7 @@ void W3DView::setPitchToDefault( void )
18651859
18661860 m_FXPitch = 1 .0f ;
18671861
1868- setCameraTransform () ;
1862+ m_recalcCamera = true ;
18691863}
18701864
18711865// -------------------------------------------------------------------------------------------------
@@ -1893,7 +1887,7 @@ void W3DView::setHeightAboveGround(Real z)
18931887 m_doingZoomCamera = false ;
18941888 m_doingScriptedCameraLock = false ;
18951889 m_cameraAreaConstraintsValid = false ;
1896- setCameraTransform () ;
1890+ m_recalcCamera = true ;
18971891}
18981892
18991893// -------------------------------------------------------------------------------------------------
@@ -1913,7 +1907,7 @@ void W3DView::setZoom(Real z)
19131907 m_doingZoomCamera = false ;
19141908 m_doingScriptedCameraLock = false ;
19151909 m_cameraAreaConstraintsValid = false ;
1916- setCameraTransform () ;
1910+ m_recalcCamera = true ;
19171911}
19181912
19191913// -------------------------------------------------------------------------------------------------
@@ -1941,7 +1935,7 @@ void W3DView::setZoomToDefault( void )
19411935 m_doingZoomCamera = false ;
19421936 m_doingScriptedCameraLock = false ;
19431937 m_cameraAreaConstraintsValid = false ;
1944- setCameraTransform () ;
1938+ m_recalcCamera = true ;
19451939}
19461940
19471941// -------------------------------------------------------------------------------------------------
@@ -1954,7 +1948,7 @@ void W3DView::setFieldOfView( Real angle )
19541948#if defined(RTS_DEBUG)
19551949 // this is only for testing, and recalculating the
19561950 // camera every frame is wasteful
1957- setCameraTransform () ;
1951+ m_recalcCamera = true ;
19581952#endif
19591953}
19601954
@@ -2297,8 +2291,7 @@ void W3DView::lookAt( const Coord3D *o )
22972291 m_CameraArrivedAtWaypointOnPathFlag = false ;
22982292 m_doingScriptedCameraLock = false ;
22992293
2300- setCameraTransform ();
2301-
2294+ m_recalcCamera = true ;
23022295}
23032296
23042297// -------------------------------------------------------------------------------------------------
@@ -2315,8 +2308,7 @@ void W3DView::initHeightForMap( void )
23152308 m_cameraOffset.y = -(m_cameraOffset.z / tan (TheGlobalData->m_cameraPitch * (PI / 180.0 )));
23162309 m_cameraOffset.x = -(m_cameraOffset.y * tan (TheGlobalData->m_cameraYaw * (PI / 180.0 )));
23172310 m_cameraAreaConstraintsValid = false ; // possible ground level change invalidates camera constraints
2318- setCameraTransform ();
2319-
2311+ m_recalcCamera = true ;
23202312}
23212313
23222314// -------------------------------------------------------------------------------------------------
@@ -3275,7 +3267,7 @@ void W3DView::cameraDisableRealZoomMode(void) //WST added 10/18/2002
32753267 m_FXPitch = 1 .0f ; // Reset to default
32763268 // m_zoom = 1.0f;
32773269 m_FOV = DEG_TO_RADF (50 .0f );
3278- setCameraTransform () ;
3270+ m_recalcCamera = true ;
32793271 updateView ();
32803272}
32813273
0 commit comments