From 45a18c652d88226bb23b7b29564819c0fc423a66 Mon Sep 17 00:00:00 2001 From: vladislavbelov Date: Tue, 1 Oct 2019 21:11:29 +0000 Subject: [PATCH] Removes unused methods and hides private member. Commented By: elexis Differential Revision: https://code.wildfiregames.com/D2342 This was SVN commit r23025. --- source/graphics/GameView.cpp | 48 +++++++++++++++++++++--------------- source/graphics/GameView.h | 2 -- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/source/graphics/GameView.cpp b/source/graphics/GameView.cpp index bed78b555f..ed2784735c 100644 --- a/source/graphics/GameView.cpp +++ b/source/graphics/GameView.cpp @@ -119,7 +119,7 @@ public: double delta = (m_Target - m_Current) * (1.0 - p); m_Current += delta; - return (float)delta; + return static_cast(delta); } void ClampSmoothly(float min, float max) @@ -139,9 +139,19 @@ public: m_Target = t; } - float m_Smoothness; + float GetSmoothness() const + { + return m_Smoothness; + } + + void SetSmoothness(float smoothness) + { + m_Smoothness = smoothness; + } private: + float m_Smoothness; + double m_Target; // the value which m_Current is tending towards double m_Current; // (We use double because the extra precision is worthwhile here) @@ -438,12 +448,20 @@ int CGameView::Initialize() CFG_GET_VAL("view.height.smoothness", m->HeightSmoothness); CFG_GET_VAL("view.height.min", m->HeightMin); - CFG_GET_VAL("view.pos.smoothness", m->PosX.m_Smoothness); - CFG_GET_VAL("view.pos.smoothness", m->PosY.m_Smoothness); - CFG_GET_VAL("view.pos.smoothness", m->PosZ.m_Smoothness); - CFG_GET_VAL("view.zoom.smoothness", m->Zoom.m_Smoothness); - CFG_GET_VAL("view.rotate.x.smoothness", m->RotateX.m_Smoothness); - CFG_GET_VAL("view.rotate.y.smoothness", m->RotateY.m_Smoothness); +#define SETUP_SMOOTHNESS(CFG_PREFIX, SMOOTHED_VALUE) \ + { \ + float smoothness = SMOOTHED_VALUE.GetSmoothness(); \ + CFG_GET_VAL(CFG_PREFIX ".smoothness", smoothness); \ + SMOOTHED_VALUE.SetSmoothness(smoothness); \ + } + + SETUP_SMOOTHNESS("view.pos", m->PosX); + SETUP_SMOOTHNESS("view.pos", m->PosY); + SETUP_SMOOTHNESS("view.pos", m->PosZ); + SETUP_SMOOTHNESS("view.zoom", m->Zoom); + SETUP_SMOOTHNESS("view.rotate.x", m->RotateX); + SETUP_SMOOTHNESS("view.rotate.y", m->RotateY); +#undef SETUP_SMOOTHNESS CFG_GET_VAL("view.near", m->ViewNear); CFG_GET_VAL("view.far", m->ViewFar); @@ -723,7 +741,7 @@ void CGameView::Update(const float deltaRealTime) cmpPosition->GetInterpolatedPosition2D(frameOffset, x, z, angle); float height = 4.f; m->ViewCamera.m_Orientation.SetIdentity(); - m->ViewCamera.m_Orientation.RotateX((float)M_PI/24.f); + m->ViewCamera.m_Orientation.RotateX(static_cast(M_PI) / 24.f); m->ViewCamera.m_Orientation.RotateY(angle); m->ViewCamera.m_Orientation.Translate(pos.X, pos.Y + height, pos.Z); @@ -881,7 +899,7 @@ void CGameView::Update(const float deltaRealTime) } */ - m->RotateY.Wrap(-(float)M_PI, (float)M_PI); + m->RotateY.Wrap(-static_cast(M_PI), static_cast(M_PI)); // Update the camera matrix SetCameraProjection(); @@ -1003,16 +1021,6 @@ entity_id_t CGameView::GetFollowedEntity() return m->FollowEntity; } -float CGameView::GetNear() const -{ - return m->ViewNear; -} - -float CGameView::GetFar() const -{ - return m->ViewFar; -} - void CGameView::SetCameraProjection() { m->ViewCamera.SetPerspectiveProjection(m->ViewNear, m->ViewFar, m->ViewFOV); diff --git a/source/graphics/GameView.h b/source/graphics/GameView.h index 2351ad9e89..8232b0ed0b 100644 --- a/source/graphics/GameView.h +++ b/source/graphics/GameView.h @@ -61,8 +61,6 @@ public: CVector3D GetCameraPosition() const; CVector3D GetCameraRotation() const; float GetCameraZoom() const; - float GetNear() const; - float GetFar() const; void SetCamera(const CVector3D& pos, float rotX, float rotY, float zoom); void MoveCameraTarget(const CVector3D& target);