@@ -32,9 +32,10 @@ void CCamera::Pan(float XAmount, float YAmount)
3232 mViewDirty = true ;
3333 mFrustumPlanesDirty = true ;
3434 }
35-
3635 else
36+ {
3737 Rotate (-XAmount * 0 .3f , YAmount * 0 .3f );
38+ }
3839}
3940
4041void CCamera::Rotate (float XAmount, float YAmount)
@@ -51,8 +52,9 @@ void CCamera::Rotate(float XAmount, float YAmount)
5152void CCamera::Zoom (float Amount)
5253{
5354 if (mMode == ECameraMoveMode::Free)
55+ {
5456 mPosition += mDirection * (Amount * mMoveSpeed );
55-
57+ }
5658 else
5759 {
5860 mOrbitDistance -= Amount * mMoveSpeed ;
@@ -83,32 +85,36 @@ void CCamera::ProcessKeyInput(FKeyInputs KeyFlags, double DeltaTime)
8385 const auto is_shift_pressed = (KeyFlags & EKeyInput::Shift) != 0 ;
8486 mMoveSpeed = is_shift_pressed ? 2 .0f : default_move_speed;
8587
86- if (KeyFlags & EKeyInput::W) Zoom (FDeltaTime * 25 .f );
87- if (KeyFlags & EKeyInput::S) Zoom (-FDeltaTime * 25 .f );
88- if (KeyFlags & EKeyInput::Q) Pan (0 , -FDeltaTime * 25 .f );
89- if (KeyFlags & EKeyInput::E) Pan (0 , FDeltaTime * 25 .f );
90- if (KeyFlags & EKeyInput::A) Pan (-FDeltaTime * 25 .f , 0 );
91- if (KeyFlags & EKeyInput::D) Pan (FDeltaTime * 25 .f , 0 );
88+ if (( KeyFlags & EKeyInput::W) != 0 ) Zoom (FDeltaTime * 25 .f );
89+ if (( KeyFlags & EKeyInput::S) != 0 ) Zoom (-FDeltaTime * 25 .f );
90+ if (( KeyFlags & EKeyInput::Q) != 0 ) Pan (0 , -FDeltaTime * 25 .f );
91+ if (( KeyFlags & EKeyInput::E) != 0 ) Pan (0 , FDeltaTime * 25 .f );
92+ if (( KeyFlags & EKeyInput::A) != 0 ) Pan (-FDeltaTime * 25 .f , 0 );
93+ if (( KeyFlags & EKeyInput::D) != 0 ) Pan (FDeltaTime * 25 .f , 0 );
9294}
9395
9496void CCamera::ProcessMouseInput (FKeyInputs KeyFlags, FMouseInputs MouseFlags, float XMovement, float YMovement)
9597{
9698 // Free Camera
9799 if (mMode == ECameraMoveMode::Free)
98100 {
99- if (MouseFlags & EMouseInput::MiddleButton)
101+ if (( MouseFlags & EMouseInput::MiddleButton) != 0 )
100102 {
101- if (KeyFlags & EKeyInput::Ctrl) Zoom (-YMovement * 0 .2f );
102- else Pan (-XMovement, YMovement);
103+ if ((KeyFlags & EKeyInput::Ctrl) != 0 )
104+ Zoom (-YMovement * 0 .2f );
105+ else
106+ Pan (-XMovement, YMovement);
107+ }
108+ else if ((MouseFlags & EMouseInput::RightButton) != 0 )
109+ {
110+ Rotate (XMovement, YMovement);
103111 }
104-
105- else if (MouseFlags & EMouseInput::RightButton) Rotate (XMovement, YMovement);
106112 }
107-
108- // Orbit Camera
109113 else if (mMode == ECameraMoveMode::Orbit)
110114 {
111- if ((MouseFlags & EMouseInput::MiddleButton) || (MouseFlags & EMouseInput::RightButton))
115+ // Orbit Camera
116+
117+ if ((MouseFlags & EMouseInput::MiddleButton) != 0 || (MouseFlags & EMouseInput::RightButton) != 0 )
112118 Pan (-XMovement, YMovement);
113119 }
114120}
0 commit comments