Update camera projection matrix handling
This commit is contained in:
@@ -97,9 +97,7 @@ namespace OpenVulkano::Scene
|
||||
|
||||
void UpdateViewProjectionMatrix()
|
||||
{
|
||||
//TODO this should be done based on the clipspace used by the rendering api
|
||||
// In vulkan the screen space is defined as y=0=top and y=1=bottom and thus the coordinate have to be flipped
|
||||
m_viewProjection = m_projection * Math::Matrix4f(1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1) * m_view;
|
||||
m_viewProjection = m_projection * m_view;
|
||||
}
|
||||
|
||||
void UpdateWorldMatrix(const Math::Matrix4f& parentWorldMat) override
|
||||
@@ -115,6 +113,14 @@ namespace OpenVulkano::Scene
|
||||
SetMatrix(Math::Utils::inverse(view));
|
||||
}
|
||||
|
||||
void SetProjectionMatrix(const Math::Matrix4f& projection)
|
||||
{
|
||||
//TODO this should be done based on the clipspace used by the rendering api
|
||||
// In vulkan the screen space is defined as y=0=top and y=1=bottom and thus the coordinate have to be flipped
|
||||
m_projection = projection * Math::Matrix4f(1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
|
||||
UpdateViewProjectionMatrix();
|
||||
}
|
||||
|
||||
[[nodiscard]] const Math::Matrix4f& GetViewProjectionMatrix() const
|
||||
{
|
||||
return m_viewProjection;
|
||||
@@ -251,8 +257,7 @@ namespace OpenVulkano::Scene
|
||||
|
||||
void UpdateProjectionMatrix() override
|
||||
{
|
||||
m_projection = Math::Utils::perspectiveRH_ZO(m_fov, m_aspect, m_nearPlane, m_farPlane);
|
||||
UpdateViewProjectionMatrix();
|
||||
SetProjectionMatrix(Math::Utils::perspectiveRH_ZO(m_fov, m_aspect, m_nearPlane, m_farPlane));
|
||||
}
|
||||
|
||||
[[nodiscard]] bool IsPerspective() const override { return true; }
|
||||
@@ -265,11 +270,9 @@ namespace OpenVulkano::Scene
|
||||
{
|
||||
const float scale = 0.5f * m_contentScaleFactor * m_zoom;
|
||||
const float widthHalf = m_width * scale, heightHalf = m_height * scale;
|
||||
m_projection = Math::Utils::orthoRH_ZO(-widthHalf, widthHalf, -heightHalf, heightHalf, m_nearPlane, m_farPlane);
|
||||
UpdateViewProjectionMatrix();
|
||||
SetProjectionMatrix(Math::Utils::orthoRH_ZO(-widthHalf, widthHalf, -heightHalf, heightHalf, m_nearPlane, m_farPlane));
|
||||
}
|
||||
|
||||
[[nodiscard]] bool IsOrtho() const override { return true; }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user