Cache camera position
This commit is contained in:
@@ -15,6 +15,7 @@ namespace openVulkanoCpp::Scene
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
Math::Matrix4f m_viewProjection{1}, m_view{1}, m_projection{1};
|
Math::Matrix4f m_viewProjection{1}, m_view{1}, m_projection{1};
|
||||||
|
Math::Vector4f m_camPosition{};
|
||||||
float m_nearPlane, m_farPlane, m_width, m_height;
|
float m_nearPlane, m_farPlane, m_width, m_height;
|
||||||
|
|
||||||
Camera() : m_nearPlane(0), m_farPlane(0), m_width(0), m_height(0) {}
|
Camera() : m_nearPlane(0), m_farPlane(0), m_width(0), m_height(0) {}
|
||||||
@@ -78,6 +79,7 @@ namespace openVulkanoCpp::Scene
|
|||||||
void UpdateWorldMatrix(const Math::Matrix4f& parentWorldMat) override
|
void UpdateWorldMatrix(const Math::Matrix4f& parentWorldMat) override
|
||||||
{
|
{
|
||||||
Node::UpdateWorldMatrix(parentWorldMat);
|
Node::UpdateWorldMatrix(parentWorldMat);
|
||||||
|
m_camPosition = GetWorldMatrix()[3];
|
||||||
m_view = Math::Utils::inverse(GetWorldMatrix());
|
m_view = Math::Utils::inverse(GetWorldMatrix());
|
||||||
UpdateViewProjectionMatrix();
|
UpdateViewProjectionMatrix();
|
||||||
}
|
}
|
||||||
@@ -92,9 +94,9 @@ namespace openVulkanoCpp::Scene
|
|||||||
return m_viewProjection;
|
return m_viewProjection;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] Math::Vector4f GetPosition() const
|
[[nodiscard]] const Math::Vector4f& GetPosition() const
|
||||||
{
|
{
|
||||||
return GetWorldMatrix()[3];
|
return m_camPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] Math::Vector3f GetRightVector() const
|
[[nodiscard]] Math::Vector3f GetRightVector() const
|
||||||
|
|||||||
Reference in New Issue
Block a user