diff options
| -rw-r--r-- | src/game/client/components/camera.cpp | 10 | ||||
| -rw-r--r-- | src/game/client/components/camera.h | 1 | ||||
| -rw-r--r-- | src/game/client/components/controls.cpp | 9 | ||||
| -rw-r--r-- | src/game/client/components/controls.h | 1 |
4 files changed, 18 insertions, 3 deletions
diff --git a/src/game/client/components/camera.cpp b/src/game/client/components/camera.cpp index 96baf459..185f02c5 100644 --- a/src/game/client/components/camera.cpp +++ b/src/game/client/components/camera.cpp @@ -10,6 +10,7 @@ CCamera::CCamera() { + m_WasSpectator = false; } void CCamera::OnRender() @@ -19,10 +20,17 @@ void CCamera::OnRender() // update camera center if(m_pClient->m_Snap.m_Spectate) + { m_Center = m_pClient->m_pControls->m_MousePos; + m_WasSpectator = true; + } else { - + if(m_WasSpectator) + { + m_pClient->m_pControls->ClampMousePos(); + m_WasSpectator = false; + } float l = length(m_pClient->m_pControls->m_MousePos); float DeadZone = g_Config.m_ClMouseDeadzone; float FollowFactor = g_Config.m_ClMouseFollowfactor/100.0f; diff --git a/src/game/client/components/camera.h b/src/game/client/components/camera.h index 9654bdf6..9b865885 100644 --- a/src/game/client/components/camera.h +++ b/src/game/client/components/camera.h @@ -8,6 +8,7 @@ class CCamera : public CComponent public: vec2 m_Center; float m_Zoom; + bool m_WasSpectator; CCamera(); virtual void OnRender(); diff --git a/src/game/client/components/controls.cpp b/src/game/client/components/controls.cpp index 859bb471..1863e97c 100644 --- a/src/game/client/components/controls.cpp +++ b/src/game/client/components/controls.cpp @@ -199,6 +199,13 @@ bool CControls::OnMouseMove(float x, float y) return false; m_MousePos += vec2(x, y); // TODO: ugly + ClampMousePos(); + + return true; +} + +void CControls::ClampMousePos() +{ // float CameraMaxDistance = 200.0f; float FollowFactor = g_Config.m_ClMouseFollowfactor/100.0f; @@ -230,6 +237,4 @@ bool CControls::OnMouseMove(float x, float y) //if(l > 0.0001f) // make sure that this isn't 0 //camera_offset = normalize(mouse_pos)*offset_amount; } - - return true; } diff --git a/src/game/client/components/controls.h b/src/game/client/components/controls.h index 092555d8..666d2915 100644 --- a/src/game/client/components/controls.h +++ b/src/game/client/components/controls.h @@ -24,5 +24,6 @@ public: virtual void OnPlayerDeath(); int SnapInput(int *pData); + void ClampMousePos(); }; #endif |