Graphics/ViewerData: Add near and far plane

This commit is contained in:
SirLynix
2023-09-05 22:34:00 +02:00
committed by Jérôme Leclercq
parent 2a3da7384d
commit 929b599337
9 changed files with 39 additions and 3 deletions

View File

@@ -248,6 +248,8 @@ namespace Nz
m_viewerInstance.UpdateProjectionMatrix(Matrix4f::Perspective(m_fov, m_aspectRatio, m_zNear, m_zFar));
break;
}
m_viewerInstance.UpdateNearFarPlanes(m_zNear, m_zFar);
}
inline void Camera::UpdateViewport()

View File

@@ -30,9 +30,11 @@ namespace Nz
~ViewerInstance() = default;
inline const Vector3f& GetEyePosition() const;
inline float GetFarPlane() const;
inline const Matrix4f& GetInvProjectionMatrix() const;
inline const Matrix4f& GetInvViewMatrix() const;
inline const Matrix4f& GetInvViewProjMatrix() const;
inline float GetNearPlane() const;
inline const Matrix4f& GetProjectionMatrix() const;
inline const Vector2f& GetTargetSize() const;
inline const Matrix4f& GetViewMatrix() const;
@@ -43,6 +45,7 @@ namespace Nz
void OnTransfer(RenderFrame& renderFrame, CommandBufferBuilder& builder) override;
inline void UpdateEyePosition(const Vector3f& eyePosition);
inline void UpdateNearFarPlanes(float nearPlane, float farPlane);
inline void UpdateProjectionMatrix(const Matrix4f& projectionMatrix);
inline void UpdateProjectionMatrix(const Matrix4f& projectionMatrix, const Matrix4f& invProjectionMatrix);
inline void UpdateProjViewMatrices(const Matrix4f& projectionMatrix, const Matrix4f& viewMatrix);
@@ -68,6 +71,8 @@ namespace Nz
Vector2f m_targetSize;
Vector3f m_eyePosition;
bool m_dataInvalidated;
float m_farPlane;
float m_nearPlane;
};
}

View File

@@ -12,6 +12,11 @@ namespace Nz
return m_eyePosition;
}
inline float ViewerInstance::GetFarPlane() const
{
return m_farPlane;
}
inline const Matrix4f& ViewerInstance::GetInvProjectionMatrix() const
{
return m_invProjectionMatrix;
@@ -27,6 +32,11 @@ namespace Nz
return m_invViewProjMatrix;
}
inline float ViewerInstance::GetNearPlane() const
{
return m_nearPlane;
}
inline const Matrix4f& ViewerInstance::GetProjectionMatrix() const
{
return m_projectionMatrix;
@@ -64,6 +74,14 @@ namespace Nz
InvalidateData();
}
inline void ViewerInstance::UpdateNearFarPlanes(float nearPlane, float farPlane)
{
m_farPlane = farPlane;
m_nearPlane = nearPlane;
InvalidateData();
}
inline void ViewerInstance::UpdateProjectionMatrix(const Matrix4f& projectionMatrix)
{
m_projectionMatrix = projectionMatrix;