Update camera projection matrix handling

This commit is contained in:
Georg Hagen
2024-07-20 19:30:28 +02:00
parent 22d6ea9d2e
commit bcad0116d4
3 changed files with 18 additions and 16 deletions

View File

@@ -22,21 +22,21 @@ namespace OpenVulkano::Scene
}
void MorphableCamera::UpdateProjectionMatrix()
{
PerspectiveCamera::UpdateProjectionMatrix();
if (m_morphState == 0) PerspectiveCamera::UpdateProjectionMatrix();
if (m_morphState != 0)
{
const float scale = 0.5f * m_contentScaleFactor * m_zoom;
const float widthHalf = m_width * scale, heightHalf = m_height * scale;
m_orthoMatrix = Math::Utils::orthoRH_ZO(-widthHalf, widthHalf, -heightHalf, heightHalf, m_nearPlane, m_farPlane);
Math::Matrix4f orthoMatrix = Math::Utils::orthoRH_ZO(-widthHalf, widthHalf, -heightHalf, heightHalf, m_nearPlane, m_farPlane);
if (m_morphState == 1)
{
m_projection = m_orthoMatrix;
SetProjectionMatrix(orthoMatrix);
}
else
{
m_projection = BlendMatrices(m_projection, m_orthoMatrix, m_morphState);
Math::Matrix4f projection = Math::Utils::perspectiveRH_ZO(m_fov, m_aspect, m_nearPlane, m_farPlane);
SetProjectionMatrix(BlendMatrices(projection, orthoMatrix, m_morphState));
}
UpdateViewProjectionMatrix();
}
}
}
}