better cam controls

This commit is contained in:
2023-06-07 12:33:10 +02:00
parent 148b5f397a
commit 368bc450ce
3 changed files with 8 additions and 7 deletions

View File

@@ -98,10 +98,11 @@ void Renderer::SetCamAngularMovement(const Vec2f& mov) {
SetCamLook(m_Camera.CamLook);
}
void Renderer::SetCamMovement(const Vec2f& mov) {
Vec2f cursor = { static_cast<float>(m_WindowSize.x) / 2.0f - mov.x, static_cast<float>(m_WindowSize.y) / 2.0f - mov.y };
Vec2f worldMovement = GetCursorWorldPos(cursor, m_WindowSize.x, m_WindowSize.y);
SetCamLook(worldMovement);
void Renderer::SetCamMovement(const Vec2f& lastCursorPos, const Vec2f& currentCursorPos) {
Vec2f worldLastCursorPos = GetCursorWorldPos(lastCursorPos, m_WindowSize.x, m_WindowSize.y);
Vec2f worldCurrentCursorPos = GetCursorWorldPos(currentCursorPos, m_WindowSize.x, m_WindowSize.y);
Vec2f movement = worldCurrentCursorPos - worldLastCursorPos;
SetCamLook(m_Camera.CamLook - movement);
}
void Renderer::SetCamPos(const Vec3f& newPos) {