Skip to content

Commit d22d72b

Browse files
xezonChapter5780
authored andcommitted
refactor(view): Simplify Clip Planes related code in W3DView::setCameraTransform() (TheSuperHackers#2232)
1 parent 9001a6d commit d22d72b

File tree

1 file changed

+6
-8
lines changed
  • Core/GameEngineDevice/Source/W3DDevice/GameClient

1 file changed

+6
-8
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898

9999
#include "W3DDevice/GameClient/CameraShakeSystem.h"
100100

101+
constexpr const Real NearZ = MAP_XY_FACTOR; ///< Set the near to MAP_XY_FACTOR. Improves z buffer resolution.
101102

102103
// 30 fps
103104
Real TheW3DFrameLengthInMsec = MSEC_PER_LOGICFRAME_REAL; // default is 33msec/frame == 30fps. but we may change it depending on sys config.
@@ -519,13 +520,9 @@ void W3DView::setCameraTransform( void )
519520
return;
520521

521522
m_cameraHasMovedSinceRequest = true;
522-
Matrix3D cameraTransform( 1 );
523+
Matrix3D cameraTransform;
523524

524-
Real nearZ, farZ;
525-
// m_3DCamera->Get_Clip_Planes(nearZ, farZ);
526-
// Set the near to MAP_XY_FACTOR. Improves zbuffer resolution.
527-
nearZ = MAP_XY_FACTOR;
528-
farZ = 1200.0f;
525+
Real farZ = 1200.0f;
529526

530527
if (m_useRealZoomCam) //WST 10.19.2002
531528
{
@@ -536,13 +533,12 @@ void W3DView::setCameraTransform( void )
536533
}
537534
else
538535
{
539-
if ((TheGlobalData && TheGlobalData->m_drawEntireTerrain) || (m_FXPitch<0.95f || m_zoom>1.05))
536+
if ((TheGlobalData->m_drawEntireTerrain) || (m_FXPitch<0.95f || m_zoom>1.05))
540537
{ //need to extend far clip plane so entire terrain can be visible
541538
farZ *= MAP_XY_FACTOR;
542539
}
543540
}
544541

545-
m_3DCamera->Set_Clip_Planes(nearZ, farZ);
546542
#if defined(RTS_DEBUG)
547543
if (TheGlobalData->m_useCameraConstraints)
548544
#endif
@@ -566,6 +562,8 @@ void W3DView::setCameraTransform( void )
566562
}
567563
}
568564

565+
m_3DCamera->Set_Clip_Planes(NearZ, farZ);
566+
569567
#if defined(RTS_DEBUG)
570568
m_3DCamera->Set_View_Plane( m_FOV, -1 );
571569
#endif

0 commit comments

Comments
 (0)