Allow orientation locking arch ball controller

This commit is contained in:
2024-07-02 12:44:26 +02:00
parent f797d6970b
commit 2adf8d7b8e
2 changed files with 12 additions and 2 deletions

View File

@@ -26,8 +26,8 @@ namespace OpenVulkano
{
if (!GetCamera()) return;
Input::InputManager* input = Input::InputManager::GetInstance();
float inYaw = input->GetAxis(m_actionLookSide);
float inPitch = input->GetAxis(m_actionLookUp);;
float inYaw = (lockYaw) ? 0 : input->GetAxis(m_actionLookSide);
float inPitch = (lockPitch) ? 0 : input->GetAxis(m_actionLookUp);
Math::Vector4f_SIMD position = GetCamera()->GetPosition();
bool updated = false;

View File

@@ -20,6 +20,7 @@ namespace OpenVulkano
{
Math::Vector4f_SIMD m_pivotPoint{ 0, 0, 0, 1 };
float yaw = 0, pitch = 0;
bool lockYaw = false, lockPitch = false;
Input::InputAction* m_actionForward = nullptr;
Input::InputAction* m_actionSide = nullptr;
@@ -45,5 +46,14 @@ namespace OpenVulkano
void SetDefaultKeybindings();
void Init(Scene::Camera *camera) override { CameraController::SetCamera(camera); SetActive(); }
void LockYaw(float value = INFINITY, bool locked = true) { lockYaw = locked; if (value != INFINITY) yaw = value; }
void LockPitch(float value = INFINITY, bool locked = true) { lockPitch = locked; if (value != INFINITY) pitch = value; }
[[nodiscard]] float GetYaw() const { return yaw; }
[[nodiscard]] float GetPitch() const { return pitch; }
void SetYaw(float y) { yaw = y; }
void SetPitch(float p) { pitch = p; }
};
}