From 92510df37386a952a490f72d304dc8d0087a94e4 Mon Sep 17 00:00:00 2001 From: Alex Peterson <26804013+AMZN-alexpete@users.noreply.github.com> Date: Tue, 16 Nov 2021 16:34:43 -0800 Subject: [PATCH] Fix missing clip to world matrix data (#5677) Signed-off-by: Alex Peterson <26804013+AMZN-alexpete@users.noreply.github.com> --- Gems/Atom/RPI/Code/Include/Atom/RPI.Public/View.h | 2 ++ Gems/Atom/RPI/Code/Source/RPI.Public/View.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/View.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/View.h index cdaf59ff75..e5614161b2 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/View.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/View.h @@ -92,6 +92,8 @@ namespace AZ const AZ::Matrix4x4& GetViewToWorldMatrix() const; const AZ::Matrix4x4& GetViewToClipMatrix() const; const AZ::Matrix4x4& GetWorldToClipMatrix() const; + const AZ::Matrix4x4& GetClipToWorldMatrix() const; + //! Get the camera's world transform, converted from the viewToWorld matrix's native y-up to z-up AZ::Transform GetCameraTransform() const; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/View.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/View.cpp index 8c1e38ba58..4538cf83e4 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/View.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/View.cpp @@ -125,6 +125,7 @@ namespace AZ m_worldToViewMatrix = worldToView; m_worldToClipMatrix = m_viewToClipMatrix * m_worldToViewMatrix; + m_clipToWorldMatrix = m_worldToClipMatrix.GetInverseFull(); m_onWorldToViewMatrixChange.Signal(m_worldToViewMatrix); m_onWorldToClipMatrixChange.Signal(m_worldToClipMatrix); @@ -162,6 +163,7 @@ namespace AZ m_worldToViewMatrix = m_viewToWorldMatrix.GetInverseFast(); m_worldToClipMatrix = m_viewToClipMatrix * m_worldToViewMatrix; + m_clipToWorldMatrix = m_worldToClipMatrix.GetInverseFull(); // Only signal an update when there is a change, otherwise this might block // user input from changing the value. @@ -177,6 +179,7 @@ namespace AZ m_viewToClipMatrix = viewToClip; m_worldToClipMatrix = m_viewToClipMatrix * m_worldToViewMatrix; + m_clipToWorldMatrix = m_worldToClipMatrix.GetInverseFull(); // Update z depth constant simultaneously // zNear -> n, zFar -> f @@ -227,6 +230,11 @@ namespace AZ return m_worldToClipMatrix; } + const AZ::Matrix4x4& View::GetClipToWorldMatrix() const + { + return m_clipToWorldMatrix; + } + bool View::HasDrawListTag(RHI::DrawListTag drawListTag) { return drawListTag.IsValid() && m_drawListMask[drawListTag.GetIndex()];