mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-18 01:15:26 +00:00
CCamera: Allow toggleable camera movement speed
In a lot of 3D scene editors, it's quite common to have a default speed that the camera can move at, plus a quicker one when shift (or some other kind of keybind is held. We can replicate this here as a fixed increment, but in the future this could also potentially be a configurable UI setting. Just makes the viewport expectations a little more natural like Blender or 3DS Max.
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
#include <Common/Math/CQuaternion.h>
|
||||
#include <Common/Math/MathUtil.h>
|
||||
|
||||
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<float>(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);
|
||||
|
||||
Reference in New Issue
Block a user