Add an Orthogonal Projection option to the Camera Gem (#2414)

* Add an Orthogonal Projection option to the Camera Gem

This adds a check-box to opt into an ortho projection along with a half-width parameter to adjust the size of the visible area. Includes some light tweaks to ensure debug rendering looks OK and that we generate a correct camera state for these non-perspective views.

Known issue: while in "Be this camera" mode in the Editor using an ortho projection manipulators aren't working correctly. This appears to be a downstream issue with CameraState consumers not actually checking the ortho flag.

Signed-off-by: nvsickle <nvsickle@amazon.com>

* Fix some typos

Signed-off-by: nvsickle <nvsickle@amazon.com>

* Account for reversed depth buffer

Signed-off-by: nvsickle <nvsickle@amazon.com>

* Clarify depth reversal for MakeOrthographicMatrixRH

Signed-off-by: nvsickle <nvsickle@amazon.com>
This commit is contained in:
Nicholas Van Sickle
2021-07-26 13:58:50 -07:00
committed by GitHub
parent e81f59d1e1
commit 7f84a4318c
12 changed files with 232 additions and 33 deletions
+12 -1
View File
@@ -463,7 +463,7 @@ void EditorViewportWidget::Update()
if (m_updateCameraPositionNextTick)
{
auto cameraState = m_renderViewport->GetCameraState();
auto cameraState = GetCameraState();
AZ::Matrix3x4 matrix;
matrix.SetBasisAndTranslation(cameraState.m_side, cameraState.m_forward, cameraState.m_up, cameraState.m_position);
auto m = AZMatrix3x4ToLYMatrix3x4(matrix);
@@ -1138,6 +1138,17 @@ void EditorViewportWidget::OnMenuSelectCurrentCamera()
AzFramework::CameraState EditorViewportWidget::GetCameraState()
{
if (m_viewEntityId.IsValid())
{
bool cameraStateAcquired = false;
AzFramework::CameraState cameraState;
Camera::EditorCameraViewRequestBus::BroadcastResult(cameraStateAcquired,
&Camera::EditorCameraViewRequestBus::Events::GetCameraState, cameraState);
if (cameraStateAcquired)
{
return cameraState;
}
}
return m_renderViewport->GetCameraState();
}