diff --git a/src/Core/Render/CCamera.cpp b/src/Core/Render/CCamera.cpp index aae5e445..9be7b547 100644 --- a/src/Core/Render/CCamera.cpp +++ b/src/Core/Render/CCamera.cpp @@ -3,6 +3,9 @@ #include #include +const float CCamera::default_move_speed = 1.0f; +const float CCamera::default_look_speed = 1.0f; + CCamera::CCamera() : mYaw(-Math::skHalfPi) { @@ -70,7 +73,13 @@ void CCamera::Snap(CVector3f Position) void CCamera::ProcessKeyInput(FKeyInputs KeyFlags, double DeltaTime) { - float FDeltaTime = (float) DeltaTime; + const auto FDeltaTime = static_cast(DeltaTime); + + // Generally the camera moves at a fixed rate without any modifier + // key held down. However in a lot of editors, it's a little more intuitive + // to allow holding down e.g. Shift for a toggleable speed. + const auto is_shift_pressed = (KeyFlags & EKeyInput::Shift) != 0; + mMoveSpeed = is_shift_pressed ? 2.0f : default_move_speed; if (KeyFlags & EKeyInput::W) Zoom(FDeltaTime * 25.f); if (KeyFlags & EKeyInput::S) Zoom(-FDeltaTime * 25.f); diff --git a/src/Core/Render/CCamera.h b/src/Core/Render/CCamera.h index 4fc995c3..438edee1 100644 --- a/src/Core/Render/CCamera.h +++ b/src/Core/Render/CCamera.h @@ -26,6 +26,9 @@ enum class ECameraMoveMode * const function). */ class CCamera { + static const float default_move_speed; + static const float default_look_speed; + ECameraMoveMode mMode{ECameraMoveMode::Free}; mutable CVector3f mPosition; mutable CVector3f mDirection; @@ -37,8 +40,8 @@ class CCamera float mPitch = 0.0f; CVector3f mOrbitTarget; mutable float mOrbitDistance = 0.0f; - float mMoveSpeed = 1.0f; - float mLookSpeed = 1.0f; + float mMoveSpeed = default_move_speed; + float mLookSpeed = default_look_speed; mutable CMatrix4f mViewMatrix; mutable CMatrix4f mProjectionMatrix;