More lazy rendering stuff

This commit is contained in:
Georg Hagen
2024-07-01 21:54:35 +02:00
parent 142c683c7f
commit 9452d061b2
4 changed files with 35 additions and 17 deletions

View File

@@ -26,17 +26,23 @@ namespace OpenVulkano
{
if (!GetCamera()) return;
Input::InputManager* input = Input::InputManager::GetInstance();
float inYaw = input->GetAxis(m_actionLookSide);
float inPitch = input->GetAxis(m_actionLookUp);;
Math::Vector4f_SIMD position = GetCamera()->GetPosition();
yaw += input->GetAxis(m_actionLookSide);
pitch += input->GetAxis(m_actionLookUp);
bool updated = false;
pitch = std::min(1.5f, std::max(-1.5f, pitch));
if (inYaw != 0 || inPitch != 0)
{
yaw += inYaw;
pitch = std::min(1.5f, std::max(-1.5f, pitch + inPitch));
Math::Matrix4f rotateY = Math::Utils::rotate(yaw, Math::Vector3f_SIMD(0, 1, 0));
Math::Vector4f x = rotateY * Math::Vector4f(1, 0, 0, 0);
Math::Matrix4f rotateX = Math::Utils::rotate(pitch, Math::Vector3f_SIMD(x));
position = rotateX * rotateY * Math::Vector4f_SIMD(0, 0, 3, 0);
position += m_pivotPoint;
Math::Matrix4f rotateY = Math::Utils::rotate(yaw, Math::Vector3f_SIMD(0, 1, 0));
Math::Vector4f x = rotateY * Math::Vector4f(1, 0, 0, 0);
Math::Matrix4f rotateX = Math::Utils::rotate(pitch, Math::Vector3f_SIMD(x));
position = rotateX * rotateY * Math::Vector4f_SIMD(0, 0, 3, 0);
position += m_pivotPoint;
updated = true;
}
// Move the camera and the pivot point
Math::Vector3f_SIMD vec(input->GetAxis(m_actionSide), input->GetAxis(m_actionUp), -input->GetAxis(m_actionForward));
@@ -52,12 +58,17 @@ namespace OpenVulkano
const Math::Vector4f_SIMD movement(vec, 0);
position += movement;
m_pivotPoint += movement;
updated = true;
}
// Update the camera view
GetCamera()->SetViewMatrix(Math::Utils::lookAt(reinterpret_cast<Math::Vector3f_SIMD&>(position),
reinterpret_cast<Math::Vector3f_SIMD&>(m_pivotPoint),
Math::Vector3f_SIMD(0,1,0)));
if (updated)
{
// Update the camera view
GetCamera()->SetViewMatrix(Math::Utils::lookAt(reinterpret_cast<Math::Vector3f_SIMD&>(position),
reinterpret_cast<Math::Vector3f_SIMD&>(m_pivotPoint),
Math::Vector3f_SIMD(0, 1, 0)));
CURRENT_FRAME.needsRedraw = true;
}
}
void ArcballCameraController::SetActive()