diff --git a/Code/Editor/2DViewport.h b/Code/Editor/2DViewport.h index 007c1a47d3..cee07ca6cd 100644 --- a/Code/Editor/2DViewport.h +++ b/Code/Editor/2DViewport.h @@ -64,7 +64,6 @@ public: // ovverided from CViewport. float GetScreenScaleFactor(const Vec3& worldPoint) const override; - float GetScreenScaleFactor([[maybe_unused]] const CCamera& camera, [[maybe_unused]] const Vec3& object_position) override { return 1; } //Eric@conffx // Overrided from CViewport. void OnDragSelectRectangle(const QRect &rect, bool bNormalizeRect = false) override; diff --git a/Code/Editor/EditorViewportWidget.cpp b/Code/Editor/EditorViewportWidget.cpp index 290f0fd17f..3a2053f328 100644 --- a/Code/Editor/EditorViewportWidget.cpp +++ b/Code/Editor/EditorViewportWidget.cpp @@ -53,7 +53,6 @@ #include // CryCommon -#include #include // AzFramework @@ -556,22 +555,6 @@ void EditorViewportWidget::OnEditorNotifyEvent(EEditorNotifyEvent event) // this should only occur for the main viewport and no others. ShowCursor(); - // If the user has selected game mode, enable outputting to any attached HMD and properly size the context - // to the resolution specified by the VR device. - if (gSettings.bEnableGameModeVR) - { - const AZ::VR::HMDDeviceInfo* deviceInfo = nullptr; - EBUS_EVENT_RESULT(deviceInfo, AZ::VR::HMDDeviceRequestBus, GetDeviceInfo); - AZ_Warning("Render Viewport", deviceInfo, "No VR device detected"); - - if (deviceInfo) - { - // Note: This may also need to adjust the viewport size - SetActiveWindow(); - SetFocus(); - SetSelected(true); - } - } SetCurrentCursor(STD_CURSOR_GAME); if (ShouldPreviewFullscreen()) @@ -1815,13 +1798,6 @@ float EditorViewportWidget::GetScreenScaleFactor([[maybe_unused]] const Vec3& wo AZ_Error("CryLegacy", false, "EditorViewportWidget::GetScreenScaleFactor not implemented"); return 1.f; } -////////////////////////////////////////////////////////////////////////// -float EditorViewportWidget::GetScreenScaleFactor(const CCamera& camera, const Vec3& object_position) -{ - Vec3 camPos = camera.GetPosition(); - float dist = camPos.GetDistance(object_position); - return dist; -} ////////////////////////////////////////////////////////////////////////// bool EditorViewportWidget::CheckRespondToInput() const @@ -1842,7 +1818,6 @@ bool EditorViewportWidget::CheckRespondToInput() const ////////////////////////////////////////////////////////////////////////// bool EditorViewportWidget::HitTest(const QPoint& point, HitContext& hitInfo) { - hitInfo.camera = nullptr; hitInfo.pExcludedObject = GetCameraObject(); return QtViewport::HitTest(point, hitInfo); } @@ -2547,12 +2522,6 @@ bool EditorViewportWidget::ShouldPreviewFullscreen() const return false; } - // Not supported in VR - if (gSettings.bEnableGameModeVR) - { - return false; - } - // If level not loaded, don't preview in fullscreen (preview shouldn't work at all without a level, but it does) if (auto ge = GetIEditor()->GetGameEngine()) { diff --git a/Code/Editor/EditorViewportWidget.h b/Code/Editor/EditorViewportWidget.h index 01f6068d56..b63eb66de2 100644 --- a/Code/Editor/EditorViewportWidget.h +++ b/Code/Editor/EditorViewportWidget.h @@ -10,7 +10,6 @@ #pragma once #if !defined(Q_MOC_RUN) -#include #include @@ -172,7 +171,6 @@ private: void ViewToWorldRay(const QPoint& vp, Vec3& raySrc, Vec3& rayDir) const override; Vec3 ViewToWorldNormal(const QPoint& vp, bool onlyTerrain, bool bTestRenderMesh = false) override; float GetScreenScaleFactor(const Vec3& worldPoint) const override; - float GetScreenScaleFactor(const CCamera& camera, const Vec3& object_position) override; float GetAspectRatio() const override; bool HitTest(const QPoint& point, HitContext& hitInfo) override; bool IsBoundsVisible(const AABB& box) const override; diff --git a/Code/Editor/Include/HitContext.h b/Code/Editor/Include/HitContext.h index 186124555f..ceff0adb22 100644 --- a/Code/Editor/Include/HitContext.h +++ b/Code/Editor/Include/HitContext.h @@ -19,7 +19,6 @@ class CBaseObject; struct IDisplayViewport; class CDeepSelection; struct AABB; -class CCamera; #include #include @@ -68,8 +67,6 @@ struct HitContext QRect rect; //! Optional limiting bounding box for hit testing. AABB* bounds; - //! Optional camera for culling perspective viewports. - CCamera* camera; //! Testing performed in 2D viewport. bool b2DViewport; @@ -120,7 +117,6 @@ struct HitContext rect = QRect(); b2DViewport = false; view = 0; - camera = 0; point2d = QPoint(); axis = 0; distanceTolerance = 0; diff --git a/Code/Editor/Include/IDisplayViewport.h b/Code/Editor/Include/IDisplayViewport.h index c7dff33e50..df17c9cb13 100644 --- a/Code/Editor/Include/IDisplayViewport.h +++ b/Code/Editor/Include/IDisplayViewport.h @@ -14,7 +14,6 @@ struct DisplayContext; class CBaseObjectsCache; class QPoint; -class CCamera; struct AABB; class CViewport; @@ -23,7 +22,6 @@ struct IDisplayViewport { virtual void Update() = 0; virtual float GetScreenScaleFactor(const Vec3& position) const = 0; - virtual float GetScreenScaleFactor(const CCamera& camera, const Vec3& object_position) = 0; virtual bool HitTestLine(const Vec3& lineP1, const Vec3& lineP2, const QPoint& hitpoint, int pixelRadius, float* pToCameraDistance = 0) const = 0; /** diff --git a/Code/Editor/Objects/BaseObject.cpp b/Code/Editor/Objects/BaseObject.cpp index 4ae01faddf..e5f121694a 100644 --- a/Code/Editor/Objects/BaseObject.cpp +++ b/Code/Editor/Objects/BaseObject.cpp @@ -953,14 +953,8 @@ void CBaseObject::DrawTextureIcon(DisplayContext& dc, [[maybe_unused]] const Vec } ////////////////////////////////////////////////////////////////////////// -void CBaseObject::DrawWarningIcons(DisplayContext& dc, const Vec3& pos) +void CBaseObject::DrawWarningIcons(DisplayContext& dc, const Vec3&) { - // Don't draw warning icons if they are beyond draw distance - if ((dc.camera->GetPosition() - pos).GetLength() > gSettings.viewports.fWarningIconsDrawDistance) - { - return; - } - if (gSettings.viewports.bShowIcons || gSettings.viewports.bShowSizeBasedIcons) { const int warningIconSizeX = OBJECT_TEXTURE_ICON_SIZEX / 2; @@ -1010,11 +1004,8 @@ void CBaseObject::DrawLabel(DisplayContext& dc, const Vec3& pos, const QColor& l labelColor = QColor(0, 0, 0); } - float camDist = dc.camera->GetPosition().GetDistance(pos); - float maxDist = dc.settings->GetLabelsDistance(); - if (camDist < dc.settings->GetLabelsDistance() || (dc.flags & DISPLAY_SELECTION_HELPERS)) + if (dc.flags & DISPLAY_SELECTION_HELPERS) { - float range = maxDist / 2.0f; Vec3 c(static_cast(labelColor.redF()), static_cast(labelColor.greenF()), static_cast(labelColor.redF())); if (IsSelected()) { @@ -1032,10 +1023,6 @@ void CBaseObject::DrawLabel(DisplayContext& dc, const Vec3& pos, const QColor& l col[1] = c.y; col[2] = c.z; } - else if (camDist > range) - { - col[3] = col[3] * (1.0f - (camDist - range) / range); - } dc.SetColor(col[0], col[1], col[2], col[3] * alpha); dc.DrawTextLabel(pos, size, GetName().toUtf8().data()); @@ -1196,33 +1183,6 @@ bool CBaseObject::CanBeDrawn(const DisplayContext& dc, bool& outDisplaySelection return bResult; } -////////////////////////////////////////////////////////////////////////// -bool CBaseObject::IsInCameraView(const CCamera& camera) -{ - AABB bbox; - GetBoundBox(bbox); - return (camera.IsAABBVisible_F(AABB(bbox.min, bbox.max))); -} - -////////////////////////////////////////////////////////////////////////// -float CBaseObject::GetCameraVisRatio(const CCamera& camera) -{ - AABB bbox; - GetBoundBox(bbox); - - static const float defaultVisRatio = 1000.0f; - - const float objectHeightSq = max(1.0f, (bbox.max - bbox.min).GetLengthSquared()); - const float camdistSq = (bbox.min - camera.GetPosition()).GetLengthSquared(); - float visRatio = defaultVisRatio; - if (camdistSq > FLT_EPSILON) - { - visRatio = objectHeightSq / camdistSq; - } - - return visRatio; -} - ////////////////////////////////////////////////////////////////////////// int CBaseObject::MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags) { diff --git a/Code/Editor/Objects/BaseObject.h b/Code/Editor/Objects/BaseObject.h index 3865696ecb..ab14437659 100644 --- a/Code/Editor/Objects/BaseObject.h +++ b/Code/Editor/Objects/BaseObject.h @@ -674,11 +674,6 @@ protected: //! Returns if the object can be drawn, and if its selection helper should also be drawn. bool CanBeDrawn(const DisplayContext& dc, bool& outDisplaySelectionHelper) const; - //! Returns if object is in the camera view. - virtual bool IsInCameraView(const CCamera& camera); - //! Returns vis ratio of object in camera - virtual float GetCameraVisRatio(const CCamera& camera); - // Do basic intersection tests virtual bool IntersectRectBounds(const AABB& bbox); virtual bool IntersectRayBounds(const Ray& ray); diff --git a/Code/Editor/Objects/DisplayContext.h b/Code/Editor/Objects/DisplayContext.h index 0f0f0e665a..f4df4f95c6 100644 --- a/Code/Editor/Objects/DisplayContext.h +++ b/Code/Editor/Objects/DisplayContext.h @@ -31,7 +31,6 @@ struct IRenderer; struct IRenderAuxGeom; struct IIconManager; class CDisplaySettings; -class CCamera; class QPoint; enum DisplayFlags @@ -66,7 +65,6 @@ struct SANDBOX_API DisplayContext IDisplayViewport* view; IRenderAuxGeom* pRenderAuxGeom; IIconManager* pIconManager; - CCamera* camera; AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING AABB box; // Bounding box of volume that need to be repainted. AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING diff --git a/Code/Editor/Objects/DisplayContextShared.inl b/Code/Editor/Objects/DisplayContextShared.inl index df0b1f82a1..e884f874e0 100644 --- a/Code/Editor/Objects/DisplayContextShared.inl +++ b/Code/Editor/Objects/DisplayContextShared.inl @@ -1138,10 +1138,6 @@ bool DisplayContext::IsVisible(const AABB& bounds) return true; } } - else - { - return camera->IsAABBVisible_F(AABB(bounds.min, bounds.max)); - } return false; } diff --git a/Code/Editor/Objects/LineGizmo.cpp b/Code/Editor/Objects/LineGizmo.cpp index 31ea341f5b..991f449cd6 100644 --- a/Code/Editor/Objects/LineGizmo.cpp +++ b/Code/Editor/Objects/LineGizmo.cpp @@ -98,16 +98,8 @@ void CLineGizmo::Display(DisplayContext& dc) Vec3 pos = 0.5f * (m_point[0] + m_point[1]); //dc.renderer->DrawLabelEx( p3+Vec3(0,0,0.3f),1.2f,col,true,true,m_name ); - float camDist = dc.camera->GetPosition().GetDistance(pos); - float maxDist = dc.settings->GetLabelsDistance(); - if (camDist < dc.settings->GetLabelsDistance()) { - float range = maxDist / 2.0f; float col[4] = { m_color[0].r, m_color[0].g, m_color[0].b, m_color[0].a }; - if (camDist > range) - { - col[3] = col[3] * (1.0f - (camDist - range) / range); - } dc.SetColor(col[0], col[1], col[2], col[3]); dc.DrawTextLabel(pos + Vec3(0, 0, 0.2f), 1.2f, m_name.toUtf8().data()); } diff --git a/Code/Editor/Objects/ObjectManager.cpp b/Code/Editor/Objects/ObjectManager.cpp index ee7e9a8e96..fc9696601d 100644 --- a/Code/Editor/Objects/ObjectManager.cpp +++ b/Code/Editor/Objects/ObjectManager.cpp @@ -1488,11 +1488,7 @@ bool CObjectManager::HitTestObject(CBaseObject* obj, HitContext& hc) if (!bSelectionHelperHit) { // Fast checking. - if (hc.camera && !obj->IsInCameraView(*hc.camera)) - { - return false; - } - else if (hc.bounds && !obj->IntersectRectBounds(*hc.bounds)) + if (hc.bounds && !obj->IntersectRectBounds(*hc.bounds)) { return false; } diff --git a/Code/Editor/Settings.cpp b/Code/Editor/Settings.cpp index d548cffb52..147ed0c0b8 100644 --- a/Code/Editor/Settings.cpp +++ b/Code/Editor/Settings.cpp @@ -112,8 +112,6 @@ SEditorSettings::SEditorSettings() m_showCircularDependencyError = true; bAutoloadLastLevelAtStartup = false; bMuteAudio = false; - bEnableGameModeVR = false; - objectHideMask = 0; objectSelectMask = 0xFFFFFFFF; // Initially all selectable. diff --git a/Code/Editor/Settings.h b/Code/Editor/Settings.h index 426d2300d3..f4a6dabde8 100644 --- a/Code/Editor/Settings.h +++ b/Code/Editor/Settings.h @@ -305,7 +305,6 @@ AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING bool m_showCircularDependencyError; bool bAutoloadLastLevelAtStartup; bool bMuteAudio; - bool bEnableGameModeVR; //! Speed of camera movement. float cameraMoveSpeed; diff --git a/Code/Editor/Viewport.cpp b/Code/Editor/Viewport.cpp index c8f2e268d9..37c46f07dd 100644 --- a/Code/Editor/Viewport.cpp +++ b/Code/Editor/Viewport.cpp @@ -1407,6 +1407,69 @@ void QtViewport::ProcessRenderLisneters(DisplayContext& rstDisplayContext) } ////////////////////////////////////////////////////////////////////////// #if defined(AZ_PLATFORM_WINDOWS) +// Note: Both CreateAnglesYPR and CreateOrientationYPR were copied verbatim from Cry_Camera.h which has been removed. +// +// Description +//
+//   x-YAW
+//   y-PITCH (negative=looking down / positive=looking up)
+//   z-ROLL
+//   
+// Note: If we are looking along the z-axis, its not possible to specify the x and z-angle +inline Ang3 CreateAnglesYPR(const Matrix33& m) +{ + assert(m.IsOrthonormal()); + float l = Vec3(m.m01, m.m11, 0.0f).GetLength(); + if (l > 0.0001) + { + return Ang3(atan2f(-m.m01 / l, m.m11 / l), atan2f(m.m21, l), atan2f(-m.m20 / l, m.m22 / l)); + } + else + { + return Ang3(0, atan2f(m.m21, l), 0); + } +} + +// Description +// This function builds a 3x3 orientation matrix using YPR-angles +// Rotation order for the orientation-matrix is Z-X-Y. (Zaxis=YAW / Xaxis=PITCH / Yaxis=ROLL) +// +//
+//  COORDINATE-SYSTEM
+//
+//  z-axis
+//    ^
+//    |
+//    |  y-axis
+//    |  /
+//    | /
+//    |/
+//    +--------------->   x-axis
+// 
+// +// Example: +// Matrix33 orientation=CreateOrientationYPR( Ang3(1,2,3) ); +inline Matrix33 CreateOrientationYPR(const Ang3& ypr) +{ + f32 sz, cz; + sincos_tpl(ypr.x, &sz, &cz); //Zaxis = YAW + f32 sx, cx; + sincos_tpl(ypr.y, &sx, &cx); //Xaxis = PITCH + f32 sy, cy; + sincos_tpl(ypr.z, &sy, &cy); //Yaxis = ROLL + Matrix33 c; + c.m00 = cy * cz - sy * sz * sx; + c.m01 = -sz * cx; + c.m02 = sy * cz + cy * sz * sx; + c.m10 = cy * sz + sy * sx * cz; + c.m11 = cz * cx; + c.m12 = sy * sz - cy * sx * cz; + c.m20 = -sy * cx; + c.m21 = sx; + c.m22 = cy * cx; + return c; +} + void QtViewport::OnRawInput([[maybe_unused]] UINT wParam, HRAWINPUT lParam) { static C3DConnexionDriver* p3DConnexionDriver = 0; @@ -1450,12 +1513,12 @@ void QtViewport::OnRawInput([[maybe_unused]] UINT wParam, HRAWINPUT lParam) t *= sys_scale3DMouseTranslation->GetFVal(); float as = 0.001f * gSettings.cameraMoveSpeed; - Ang3 ypr = CCamera::CreateAnglesYPR(Matrix33(viewTM)); + Ang3 ypr = CreateAnglesYPR(Matrix33(viewTM)); ypr.x += -all6DOFs[5] * as * fScaleYPR; ypr.y = AZStd::clamp(ypr.y + all6DOFs[3] * as * fScaleYPR, -1.5f, 1.5f); // to keep rotation in reasonable range ypr.z = 0; // to have camera always upward - viewTM = Matrix34(CCamera::CreateOrientationYPR(ypr), viewTM.GetTranslation()); + viewTM = Matrix34(CreateOrientationYPR(ypr), viewTM.GetTranslation()); viewTM = viewTM * Matrix34::CreateTranslationMat(t); SetViewTM(viewTM); diff --git a/Code/Editor/ViewportTitleDlg.cpp b/Code/Editor/ViewportTitleDlg.cpp index 75d16e9a40..49459fad0f 100644 --- a/Code/Editor/ViewportTitleDlg.cpp +++ b/Code/Editor/ViewportTitleDlg.cpp @@ -138,14 +138,11 @@ CViewportTitleDlg::CViewportTitleDlg(QWidget* pParent) connect(this, &CViewportTitleDlg::ActionTriggered, MainWindow::instance()->GetActionManager(), &ActionManager::ActionTriggered); - AZ::VR::VREventBus::Handler::BusConnect(); - OnInitDialog(); } CViewportTitleDlg::~CViewportTitleDlg() { - AZ::VR::VREventBus::Handler::BusDisconnect(); GetISystem()->GetISystemEventDispatcher()->RemoveListener(this); GetIEditor()->UnregisterNotifyListener(this); @@ -236,10 +233,6 @@ void CViewportTitleDlg::SetupOverflowMenu() connect(m_audioMuteAction, &QAction::triggered, this, &CViewportTitleDlg::OnBnClickedMuteAudio); overFlowMenu->addAction(m_audioMuteAction); - m_enableVRAction = new QAction("Enable VR Preview", overFlowMenu); - connect(m_enableVRAction, &QAction::triggered, this, &CViewportTitleDlg::OnBnClickedEnableVR); - overFlowMenu->addAction(m_enableVRAction); - overFlowMenu->addSeparator(); m_enableGridSnappingAction = new QAction("Enable Grid Snapping", overFlowMenu); @@ -305,16 +298,6 @@ void CViewportTitleDlg::OnInitDialog() connect(displayInfoHelper, &CViewportTitleDlgDisplayInfoHelper::ViewportInfoStatusUpdated, this, &CViewportTitleDlg::UpdateDisplayInfo); UpdateDisplayInfo(); - // This is here just in case this class hasn't been created before - // a VR headset was initialized - m_enableVRAction->setEnabled(false); - if (AZ::VR::HMDDeviceRequestBus::GetTotalNumOfEventHandlers() != 0) - { - m_enableVRAction->setEnabled(true); - } - - AZ::VR::VREventBus::Handler::BusConnect(); - QFontMetrics metrics({}); int width = static_cast(metrics.boundingRect("-9999.99").width() * m_fieldWidthMultiplier); @@ -931,23 +914,6 @@ void CViewportTitleDlg::UpdateMuteActionText() } } -void CViewportTitleDlg::OnHMDInitialized() -{ - m_enableVRAction->setEnabled(true); -} - -void CViewportTitleDlg::OnHMDShutdown() -{ - m_enableVRAction->setEnabled(false); -} - -void CViewportTitleDlg::OnBnClickedEnableVR() -{ - gSettings.bEnableGameModeVR = !gSettings.bEnableGameModeVR; - - m_enableVRAction->setText(gSettings.bEnableGameModeVR ? tr("Disable VR Preview") : tr("Enable VR Preview")); -} - inline double Round(double fVal, double fStep) { if (fStep > 0.f) diff --git a/Code/Editor/ViewportTitleDlg.h b/Code/Editor/ViewportTitleDlg.h index 6996fe7750..a3e19837b4 100644 --- a/Code/Editor/ViewportTitleDlg.h +++ b/Code/Editor/ViewportTitleDlg.h @@ -22,7 +22,6 @@ #include #include -#include #endif // CViewportTitleDlg dialog @@ -44,7 +43,6 @@ class CViewportTitleDlg : public QWidget , public IEditorNotifyListener , public ISystemEventListener - , public AZ::VR::VREventBus::Handler { Q_OBJECT public: @@ -85,13 +83,6 @@ protected: void OnToggleHelpers(); void UpdateDisplayInfo(); - ////////////////////////////////////////////////////////////////////////// - /// VR Event Bus Implementation - ////////////////////////////////////////////////////////////////////////// - void OnHMDInitialized() override; - void OnHMDShutdown() override; - ////////////////////////////////////////////////////////////////////////// - void SetupCameraDropdownMenu(); void SetupResolutionDropdownMenu(); void SetupViewportInformationMenu(); @@ -140,7 +131,6 @@ protected: void OnBnClickedGotoPosition(); void OnBnClickedMuteAudio(); - void OnBnClickedEnableVR(); void UpdateMuteActionText(); @@ -168,7 +158,6 @@ protected: QAction* m_fullInformationAction = nullptr; QAction* m_compactInformationAction = nullptr; QAction* m_audioMuteAction = nullptr; - QAction* m_enableVRAction = nullptr; QAction* m_enableGridSnappingAction = nullptr; QAction* m_enableAngleSnappingAction = nullptr; QComboBox* m_cameraSpeed = nullptr; diff --git a/Code/Framework/AzCore/Tests/Math/FrustumTests.cpp b/Code/Framework/AzCore/Tests/Math/FrustumTests.cpp index 294d622a92..31fa6b626f 100644 --- a/Code/Framework/AzCore/Tests/Math/FrustumTests.cpp +++ b/Code/Framework/AzCore/Tests/Math/FrustumTests.cpp @@ -552,7 +552,6 @@ namespace UnitTest box.testCaseName = "BoxShaped"; frustums.push_back(box); - // Default values in a CCamera from Cry_Camera.h FrustumTestCase defaultCameraFrustum; defaultCameraFrustum.nearTopLeft = AZ::Vector3(-0.204621f, 0.200000f, 0.153465f); defaultCameraFrustum.nearTopRight = AZ::Vector3(0.204621f, 0.200000f, 0.153465f); diff --git a/Code/Legacy/CryCommon/Cry_Camera.h b/Code/Legacy/CryCommon/Cry_Camera.h deleted file mode 100644 index 6ccae5bce1..0000000000 --- a/Code/Legacy/CryCommon/Cry_Camera.h +++ /dev/null @@ -1,448 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - - -// Description : Common Camera class implementation -#pragma once - - -//DOC-IGNORE-BEGIN -#include -#include -//DOC-IGNORE-END - -////////////////////////////////////////////////////////////////////// -#define CAMERA_MIN_NEAR 0.001f -#define DEFAULT_NEAR 0.2f -#define DEFAULT_FAR 1024.0f -#define DEFAULT_FOV (75.0f * gf_PI / 180.0f) -#define MIN_FOV 0.0000001f - -////////////////////////////////////////////////////////////////////// - -enum -{ - FR_PLANE_NEAR, - FR_PLANE_FAR, - FR_PLANE_RIGHT, - FR_PLANE_LEFT, - FR_PLANE_TOP, - FR_PLANE_BOTTOM, - FRUSTUM_PLANES -}; - -////////////////////////////////////////////////////////////////////// - -enum cull -{ - CULL_EXCLUSION, // The whole object is outside of frustum. - CULL_OVERLAP, // The object & frustum overlap. - CULL_INCLUSION // The whole object is inside frustum. -}; - -/////////////////////////////////////////////////////////////////////////////// -// Implements essential operations like calculation of a view-matrix and -// frustum-culling with simple geometric primitives (Point, Sphere, AABB, OBB). -// All calculation are based on the CryENGINE coordinate-system -// -// We are using a "right-handed" coordinate systems, where the positive X-Axis points -// to the right, the positive Y-Axis points away from the viewer and the positive -// Z-Axis points up. The following illustration shows our coordinate system. -// -//
-//  z-axis
-//    ^
-//    |
-//    |   y-axis
-//    |  /
-//    | /
-//    |/
-//    +---------------->   x-axis
-// 
-// -// This same system is also used in 3D-Studio-MAX. It is not unusual for 3D-APIs like D3D9 or -// OpenGL to use a different coordinate system. Currently in D3D9 we use a coordinate system -// in which the X-Axis points to the right, the Y-Axis points down and the Z-Axis points away -// from the viewer. To convert from the CryEngine system into D3D9 we are just doing a clockwise -// rotation of pi/2 about the X-Axis. This conversion happens in the renderer. -// -// The 6 DOFs (degrees-of-freedom) are stored in one single 3x4 matrix ("m_Matrix"). The 3 -// orientation-DOFs are stored in the 3x3 part and the 3 position-DOFs are stored in the translation- -// vector. You can use the member-functions "GetMatrix()" or "SetMatrix(Matrix34(orientation,positon))" -// to change or access the 6 DOFs. -// -// There are helper-function in Cry_Math.h to create the orientation: -// -// This function builds a 3x3 orientation matrix using a view-direction and a radiant to rotate about Y-axis. -// Matrix33 orientation=Matrix33::CreateOrientation( Vec3(0,1,0), 0 ); -// -// This function builds a 3x3 orientation matrix using Yaw-Pitch-Roll angles. -// Matrix33 orientation=CCamera::CreateOrientationYPR( Ang3(1.234f,0.342f,0) ); -// -/////////////////////////////////////////////////////////////////////////////// -class CCamera -{ -public: - ILINE static Matrix33 CreateOrientationYPR(const Ang3& ypr); - ILINE static Ang3 CreateAnglesYPR(const Matrix33& m); - ILINE static Ang3 CreateAnglesYPR(const Vec3& vdir, f32 r = 0); - - ILINE void SetMatrix(const Matrix34& mat) { assert(mat.IsOrthonormal()); m_Matrix = mat; UpdateFrustum(); }; - ILINE const Matrix34& GetMatrix() const { return m_Matrix; }; - ILINE Vec3 GetViewdir() const { return m_Matrix.GetColumn1(); }; - - ILINE Vec3 GetPosition() const { return m_Matrix.GetTranslation(); } - ILINE void SetPosition(const Vec3& p) { m_Matrix.SetTranslation(p); UpdateFrustum(); } - - //------------------------------------------------------------ - - void SetFrustum(int nWidth, int nHeight, f32 FOV = DEFAULT_FOV, f32 nearplane = DEFAULT_NEAR, f32 farplane = DEFAULT_FAR, f32 fPixelAspectRatio = 1.0f); - - ILINE int GetViewSurfaceZ() const { return m_Height; } - ILINE f32 GetFov() const { return m_fov; } - ILINE f32 GetPixelAspectRatio() const { return m_PixelAspectRatio; } - - ////////////////////////////////////////////////////////////////////////// - - //----------------------------------------------------------------------------------- - //-------- Frustum-Culling ---------------------------- - //----------------------------------------------------------------------------------- - - // AABB-frustum test - // Fast - bool IsAABBVisible_F(const ::AABB& aabb) const; - - //## constructor/destructor - CCamera() - { - m_Matrix.SetIdentity(); - m_asymRight = 0; - m_asymLeft = 0; - m_asymBottom = 0; - m_asymTop = 0; - SetFrustum(640, 480); - m_nPosX = m_nPosY = m_nSizeX = m_nSizeY = 0; - m_entityPos = Vec3(0, 0, 0); - } - ~CCamera() {} - - void SetJustActivated([[maybe_unused]] const bool justActivated) {} - - void UpdateFrustum(); - -private: - Matrix34 m_Matrix; // world space-matrix - - f32 m_fov; // vertical fov in radiants [0..1*PI[ - int m_Width; // surface width-resolution - int m_Height; // surface height-resolution - f32 m_PixelAspectRatio; // accounts for aspect ratio and non-square pixels - - Vec3 m_entityPos; //The position of this camera's entity (does not include HMD position or stereo offsets) - - Vec3 m_edge_nlt; // this is the left/upper vertex of the near-plane - Vec3 m_edge_plt; // this is the left/upper vertex of the projection-plane - Vec3 m_edge_flt; // this is the left/upper vertex of the far-clip-plane - - f32 m_asymLeft, m_asymRight, m_asymBottom, m_asymTop; // Shift to create asymmetric frustum (only used for GPU culling of tessellated objects) - f32 m_asymLeftProj, m_asymRightProj, m_asymBottomProj, m_asymTopProj; - f32 m_asymLeftFar, m_asymRightFar, m_asymBottomFar, m_asymTopFar; - - //usually we update these values every frame (they depend on m_Matrix) - Vec3 m_cltp, m_crtp, m_clbp, m_crbp; //this are the 4 vertices of the projection-plane in cam-space - Vec3 m_cltn, m_crtn, m_clbn, m_crbn; //this are the 4 vertices of the near-plane in cam-space - Vec3 m_cltf, m_crtf, m_clbf, m_crbf; //this are the 4 vertices of the farclip-plane in cam-space - - Plane_tpl m_fp [FRUSTUM_PLANES]; // - uint32 m_idx1[FRUSTUM_PLANES], m_idy1[FRUSTUM_PLANES], m_idz1[FRUSTUM_PLANES]; // - uint32 m_idx2[FRUSTUM_PLANES], m_idy2[FRUSTUM_PLANES], m_idz2[FRUSTUM_PLANES]; // - - int m_nPosX, m_nPosY, m_nSizeX, m_nSizeY; -}; - -// Description -// This function builds a 3x3 orientation matrix using YPR-angles -// Rotation order for the orientation-matrix is Z-X-Y. (Zaxis=YAW / Xaxis=PITCH / Yaxis=ROLL) -// -//
-//  COORDINATE-SYSTEM
-//
-//  z-axis
-//    ^
-//    |
-//    |  y-axis
-//    |  /
-//    | /
-//    |/
-//    +--------------->   x-axis
-// 
-// -// Example: -// Matrix33 orientation=CCamera::CreateOrientationYPR( Ang3(1,2,3) ); -inline Matrix33 CCamera::CreateOrientationYPR(const Ang3& ypr) -{ - f32 sz, cz; - sincos_tpl(ypr.x, &sz, &cz); //Zaxis = YAW - f32 sx, cx; - sincos_tpl(ypr.y, &sx, &cx); //Xaxis = PITCH - f32 sy, cy; - sincos_tpl(ypr.z, &sy, &cy); //Yaxis = ROLL - Matrix33 c; - c.m00 = cy * cz - sy * sz * sx; - c.m01 = -sz * cx; - c.m02 = sy * cz + cy * sz * sx; - c.m10 = cy * sz + sy * sx * cz; - c.m11 = cz * cx; - c.m12 = sy * sz - cy * sx * cz; - c.m20 = -sy * cx; - c.m21 = sx; - c.m22 = cy * cx; - return c; -} - -// Description -//
-//   x-YAW
-//   y-PITCH (negative=looking down / positive=looking up)
-//   z-ROLL
-//   
-// Note: If we are looking along the z-axis, its not possible to specify the x and z-angle -inline Ang3 CCamera::CreateAnglesYPR(const Matrix33& m) -{ - assert(m.IsOrthonormal()); - float l = Vec3(m.m01, m.m11, 0.0f).GetLength(); - if (l > 0.0001) - { - return Ang3(atan2f(-m.m01 / l, m.m11 / l), atan2f(m.m21, l), atan2f(-m.m20 / l, m.m22 / l)); - } - else - { - return Ang3(0, atan2f(m.m21, l), 0); - } -} - -// Description -//
-//x-YAW
-//y-PITCH (negative=looking down / positive=looking up)
-//z-ROLL (its not possile to extract a "roll" from a view-vector)
-// 
-// Note: if we are looking along the z-axis, its not possible to specify the rotation about the z-axis -ILINE Ang3 CCamera::CreateAnglesYPR(const Vec3& vdir, f32 r) -{ - assert((fabs_tpl(1 - (vdir | vdir))) < 0.001); //check if unit-vector - f32 l = Vec3(vdir.x, vdir.y, 0.0f).GetLength(); //check if not zero - if (l > 0.0001) - { - return Ang3(atan2f(-vdir.x / l, vdir.y / l), atan2f(vdir.z, l), r); - } - else - { - return Ang3(0, atan2f(vdir.z, l), r); - } -} - -//--------------------------------------------------------------------------- -//--------------------------------------------------------------------------- -//--------------------------------------------------------------------------- -//--------------------------------------------------------------------------- -inline void CCamera::SetFrustum(int nWidth, int nHeight, f32 FOV, f32 nearplane, f32 farplane, f32 fPixelAspectRatio) -{ - assert (nearplane >= CAMERA_MIN_NEAR); //check if near-plane is valid - assert (farplane >= 0.1f); //check if far-plane is valid - assert (farplane >= nearplane); //check if far-plane bigger then near-plane - assert (FOV >= MIN_FOV && FOV < gf_PI); //check if specified FOV is valid - - m_fov = FOV; - - m_Width = nWidth; //surface x-resolution - m_Height = nHeight; //surface z-resolution - - f32 fWidth = (((f32)nWidth) / fPixelAspectRatio); - f32 fHeight = (f32) nHeight; - - m_PixelAspectRatio = fPixelAspectRatio; - - //------------------------------------------------------------------------- - //--- calculate the Left/Top edge of the Projection-Plane in EYE-SPACE --- - //------------------------------------------------------------------------- - f32 projLeftTopX = -fWidth * 0.5f; - f32 projLeftTopY = static_cast((1.0f / tan_tpl(m_fov * 0.5f)) * (fHeight * 0.5f)); - f32 projLeftTopZ = fHeight * 0.5f; - - m_edge_plt.x = projLeftTopX; - m_edge_plt.y = projLeftTopY; - m_edge_plt.z = projLeftTopZ; - - float invProjLeftTopY = 1.0f / projLeftTopY; - - //Apply asym shift to the camera frustum - Necessary for properly culling tessellated objects in VR - //These are applied in UpdateFrustum to the camera space frustum planes - //Can't apply asym shift to frustum edges here. That would only apply to the top left corner - //rather than the whole frustum. It would also interfere with shadow map application - - //m_asym is at the near plane, we want it at the projection plane too - m_asymLeftProj = (m_asymLeft / nearplane) * projLeftTopY; - m_asymTopProj = (m_asymTop / nearplane) * projLeftTopY; - m_asymRightProj = (m_asymRight / nearplane) * projLeftTopY; - m_asymBottomProj = (m_asymBottom / nearplane) * projLeftTopY; - - //Also want m_asym at the far plane - m_asymLeftFar = m_asymLeftProj * (farplane * invProjLeftTopY); - m_asymTopFar = m_asymTopProj * (farplane * invProjLeftTopY); - m_asymRightFar = m_asymRightProj * (farplane * invProjLeftTopY); - m_asymBottomFar = m_asymBottomProj * (farplane * invProjLeftTopY); - - m_edge_nlt.x = nearplane * projLeftTopX * invProjLeftTopY; - m_edge_nlt.y = nearplane; - m_edge_nlt.z = nearplane * projLeftTopZ * invProjLeftTopY; - - //calculate the left/upper edge of the far-plane (=not rotated) - m_edge_flt.x = projLeftTopX * (farplane * invProjLeftTopY); - m_edge_flt.y = farplane; - m_edge_flt.z = projLeftTopZ * (farplane * invProjLeftTopY); - - UpdateFrustum(); -} - -/*! - * - * Updates all parameters required by the render-engine: - * - * 3d-view-frustum and all matrices - * - */ -inline void CCamera::UpdateFrustum() -{ - //------------------------------------------------------------------- - //--- calculate frustum-edges of projection-plane in CAMERA-SPACE --- - //------------------------------------------------------------------- - Matrix33 m33 = Matrix33(m_Matrix); - m_cltp = m33 * Vec3(+m_edge_plt.x + m_asymLeftProj, +m_edge_plt.y, +m_edge_plt.z + m_asymTopProj); - m_crtp = m33 * Vec3(-m_edge_plt.x + m_asymRightProj, +m_edge_plt.y, +m_edge_plt.z + m_asymTopProj); - m_clbp = m33 * Vec3(+m_edge_plt.x + m_asymLeftProj, +m_edge_plt.y, -m_edge_plt.z + m_asymBottomProj); - m_crbp = m33 * Vec3(-m_edge_plt.x + m_asymRightProj, +m_edge_plt.y, -m_edge_plt.z + m_asymBottomProj); - - m_cltn = m33 * Vec3(+m_edge_nlt.x + m_asymLeft, +m_edge_nlt.y, +m_edge_nlt.z + m_asymTop); - m_crtn = m33 * Vec3(-m_edge_nlt.x + m_asymRight, +m_edge_nlt.y, +m_edge_nlt.z + m_asymTop); - m_clbn = m33 * Vec3(+m_edge_nlt.x + m_asymLeft, +m_edge_nlt.y, -m_edge_nlt.z + m_asymBottom); - m_crbn = m33 * Vec3(-m_edge_nlt.x + m_asymRight, +m_edge_nlt.y, -m_edge_nlt.z + m_asymBottom); - - m_cltf = m33 * Vec3(+m_edge_flt.x + m_asymLeftFar, +m_edge_flt.y, +m_edge_flt.z + m_asymTopFar); - m_crtf = m33 * Vec3(-m_edge_flt.x + m_asymRightFar, +m_edge_flt.y, +m_edge_flt.z + m_asymTopFar); - m_clbf = m33 * Vec3(+m_edge_flt.x + m_asymLeftFar, +m_edge_flt.y, -m_edge_flt.z + m_asymBottomFar); - m_crbf = m33 * Vec3(-m_edge_flt.x + m_asymRightFar, +m_edge_flt.y, -m_edge_flt.z + m_asymBottomFar); - - //------------------------------------------------------------------------------- - //--- calculate the six frustum-planes using the frustum edges in world-space --- - //------------------------------------------------------------------------------- - m_fp[FR_PLANE_NEAR ] = Plane_tpl::CreatePlane(m_crtn + GetPosition(), m_cltn + GetPosition(), m_crbn + GetPosition()); - m_fp[FR_PLANE_RIGHT ] = Plane_tpl::CreatePlane(m_crbf + GetPosition(), m_crtf + GetPosition(), GetPosition()); - m_fp[FR_PLANE_LEFT ] = Plane_tpl::CreatePlane(m_cltf + GetPosition(), m_clbf + GetPosition(), GetPosition()); - m_fp[FR_PLANE_TOP ] = Plane_tpl::CreatePlane(m_crtf + GetPosition(), m_cltf + GetPosition(), GetPosition()); - m_fp[FR_PLANE_BOTTOM] = Plane_tpl::CreatePlane(m_clbf + GetPosition(), m_crbf + GetPosition(), GetPosition()); - m_fp[FR_PLANE_FAR ] = Plane_tpl::CreatePlane(m_crtf + GetPosition(), m_crbf + GetPosition(), m_cltf + GetPosition()); //clip-plane - - uint32 rh = m_Matrix.IsOrthonormalRH(); - if (rh == 0) - { - m_fp[FR_PLANE_NEAR ] = -m_fp[FR_PLANE_NEAR ]; - m_fp[FR_PLANE_RIGHT ] = -m_fp[FR_PLANE_RIGHT ]; - m_fp[FR_PLANE_LEFT ] = -m_fp[FR_PLANE_LEFT ]; - m_fp[FR_PLANE_TOP ] = -m_fp[FR_PLANE_TOP ]; - m_fp[FR_PLANE_BOTTOM] = -m_fp[FR_PLANE_BOTTOM]; - m_fp[FR_PLANE_FAR ] = -m_fp[FR_PLANE_FAR ]; //clip-plane - } - - union f32_u - { - float floatVal; - uint32 uintVal; - }; - - for (int i = 0; i < FRUSTUM_PLANES; i++) - { - f32_u ux; - ux.floatVal = m_fp[i].n.x; - f32_u uy; - uy.floatVal = m_fp[i].n.y; - f32_u uz; - uz.floatVal = m_fp[i].n.z; - uint32 bitX = ux.uintVal >> 31; - uint32 bitY = uy.uintVal >> 31; - uint32 bitZ = uz.uintVal >> 31; - m_idx1[i] = bitX * 3 + 0; - m_idx2[i] = (1 - bitX) * 3 + 0; - m_idy1[i] = bitY * 3 + 1; - m_idy2[i] = (1 - bitY) * 3 + 1; - m_idz1[i] = bitZ * 3 + 2; - m_idz2[i] = (1 - bitZ) * 3 + 2; - } -} - -// Description -// Simple approach to check if an AABB and the camera-frustum overlap. The AABB -// is assumed to be in world-space. This is a very fast method, just one single -// dot-product is necessary to check an AABB against a plane. Actually there -// is no significant speed-different between culling a sphere or an AABB. -// -// Example -// bool InOut=camera.IsAABBVisible_F(aabb); -// -// return values -// CULL_EXCLUSION = AABB outside of frustum (very fast rejection-test) -// CULL_OVERLAP = AABB either intersects the borders of the frustum or is totally inside - -inline bool CCamera::IsAABBVisible_F(const AABB& aabb) const -{ - const f32* p = &aabb.min.x; - uint32 x, y, z; - x = m_idx1[0]; - y = m_idy1[0]; - z = m_idz1[0]; - if ((m_fp[0] | Vec3(p[x], p[y], p[z])) > 0) - { - return CULL_EXCLUSION; - } - x = m_idx1[1]; - y = m_idy1[1]; - z = m_idz1[1]; - if ((m_fp[1] | Vec3(p[x], p[y], p[z])) > 0) - { - return CULL_EXCLUSION; - } - x = m_idx1[2]; - y = m_idy1[2]; - z = m_idz1[2]; - if ((m_fp[2] | Vec3(p[x], p[y], p[z])) > 0) - { - return CULL_EXCLUSION; - } - x = m_idx1[3]; - y = m_idy1[3]; - z = m_idz1[3]; - if ((m_fp[3] | Vec3(p[x], p[y], p[z])) > 0) - { - return CULL_EXCLUSION; - } - x = m_idx1[4]; - y = m_idy1[4]; - z = m_idz1[4]; - if ((m_fp[4] | Vec3(p[x], p[y], p[z])) > 0) - { - return CULL_EXCLUSION; - } - x = m_idx1[5]; - y = m_idy1[5]; - z = m_idz1[5]; - if ((m_fp[5] | Vec3(p[x], p[y], p[z])) > 0) - { - return CULL_EXCLUSION; - } - return CULL_OVERLAP; -} diff --git a/Code/Legacy/CryCommon/HMDBus.h b/Code/Legacy/CryCommon/HMDBus.h deleted file mode 100644 index dab4c28668..0000000000 --- a/Code/Legacy/CryCommon/HMDBus.h +++ /dev/null @@ -1,276 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - - -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -struct IRenderAuxGeom; - -namespace AZ -{ - namespace VR - { - /** - * Bus for reacting to events triggered by the VR systems - */ - class VREvents : public AZ::EBusTraits - { - public: - virtual ~VREvents() {} - - /** - * Event triggered when an HMD initializes successfully - */ - virtual void OnHMDInitialized() {} - - /** - * Event triggered when an HMD shuts down - */ - virtual void OnHMDShutdown() {} - }; - - using VREventBus = AZ::EBus; - - /// - /// Device initialization bus. Each HMD device SDK should connect to this bus during startup in order to be initialized by the LY engine. - /// Any devices that successfully initialize will be connected to the HMDDeviceBus for actual use in VR rendering. - /// - class HMDInitBus : public AZ::EBusTraits - { - public: - - virtual ~HMDInitBus() {} - - /// - /// Attempt to initialize this device. If initialization is initially successful (device exists and is able to startup) then this device should connect to the - /// HMDDeviceRequestBus in order to be used as an HMD from the main Open 3D Engine system. - /// - /// @return If true, initialization fully succeeded. - /// - virtual bool AttemptInit() = 0; - - /// - /// Shutdown this device and destroy any internal context/state information that it may contain. Once this function has returned, the device should be in a - /// totally clean state and able to re-initialized if necessary. - /// - virtual void Shutdown() = 0; - - /// - /// Priority values for the HMD to set. A higher priority value means that the HMD will be be initialized before - /// other HMDs with lower priority values. - /// - enum HMDInitPriority - { - kNullVR = -100, - kLowest = 0, - kMiddle = 50, - kHighest = 100 - }; - - /// - /// Specify the initialization priority for this HMD device. Typically SDKs that have only one device that they support (e.g. Oculus) should have the highest - /// priority so that other VR Gems don't take the device context. For example, OpenVR is capable of driving an Oculus Rift and if initialized first will control - /// the device as opposed to the Oculus runtime. - /// - virtual HMDInitPriority GetInitPriority() const = 0; - }; - - using HMDInitRequestBus = AZ::EBus; - - /// - /// HMD device bus used to communicate with the rest of the engine. Every device supported by the engine lives in its own GEM and supports this bus. A device - /// wraps the underlying SDK into a single object for easy use by the rest of the system. Every device created should register with the EBus in order to be picked up as - /// a usable device during initialization via the EBus function BusConnect(). - /// - class HMDDeviceBus - : public AZ::EBusTraits - { - public: - - ////////////////////////////////////////////////////////////////////////// - // EBus Traits - static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Multiple; - static const EBusAddressPolicy AddressPolicy = EBusAddressPolicy::Single; - using MutexType = AZStd::recursive_mutex; - ////////////////////////////////////////////////////////////////////////// - - virtual ~HMDDeviceBus() {} - - /// - /// Simple texture descriptor to pass to the device during render target creation. - /// - struct TextureDesc - { - uint32 width; - uint32 height; - }; - - /// - /// Update the HMD's internal state and handle events - /// This is NOT where tracking is updated. This is for game-time - /// events such as controllers connecting/disconnecting or - /// certain compositor events being triggered. - /// - virtual void UpdateInternalState() {} - - /// - /// Create the render targets for a rendering device. Note that this will create all necessary render targets but the render targets will be destroyed one at a time in DestroyRenderTargets. - /// - /// @param renderDevice The render device to use when creating the render target. - /// @param desc TextureDesc object denoting texture options to use during creation. - /// @param eyeCount The number of HMDRenderTargets to be created in this function. - /// @param renderTargets Array of pointers to HMDRenderTargets of size eyeCount created upon successful return of this function. See struct RenderTarget for more info. - /// - /// @returns If true, the render targets were successfully created. - /// - virtual bool CreateRenderTargets([[maybe_unused]] void* renderDevice, [[maybe_unused]] const TextureDesc& desc, [[maybe_unused]] size_t eyeCount, [[maybe_unused]] HMDRenderTarget* renderTargets[]) { return false; } - - /// - /// Destroy the passed-in render target. Any device-specific texture data will be cleaned up after this function has finished executing. - /// - virtual void DestroyRenderTarget([[maybe_unused]] HMDRenderTarget& renderTarget) {} - - /// - /// Take care of any frame preparations that may be necessary BEFORE rendering begins on either eye. This could be things like synchronization, - /// clearing old state, etc. - /// - virtual void PrepareFrame() {} - - /// - /// Retrieve the latest tracking state that was cached since the last call - /// to UpdateTrackingStates. - /// - /// TODO: Differentiate between tracking states viable for rendering and - /// tracking states viable for game simulation. - /// - virtual TrackingState* GetTrackingState() { return nullptr; } - - /// - /// Per-eye target to submit to the device for final composition and rendering. - /// - struct EyeTarget - { - void* renderTarget; ///< The device render target. - Vec2i viewportPosition; ///< Position of the viewport pertaining to this render target. - Vec2i viewportSize; ///< Size of the viewport pertaining to this render target. - }; - - /// - /// Submit a new frame to the HMD device. Each eye should be fully rendered by this point. The device will automatically correlate the proper - /// tracking information with this frame. - /// - /// @param left A reference to the left EyeTarget to present - /// @param right A reference to the right EyeTarget to present - /// - virtual void SubmitFrame([[maybe_unused]] const EyeTarget& left, [[maybe_unused]] const EyeTarget& right) {} - - /// - /// Recent the current pose for the HMD based on the current direction that the viewer is looking. - /// - virtual void RecenterPose() {} - - /// - /// Set the current tracking level of the HMD. Supported tracking levels are defined in struct TrackingLevel. - /// - /// @param level The tracking level we want to use with this HMD - /// - virtual void SetTrackingLevel([[maybe_unused]] const AZ::VR::HMDTrackingLevel level) {} - - /// - /// Write any HMD info to the console/log file(s). At a minimum this function should print the info contained in the HMDDeviceInfo object. - /// - virtual void OutputHMDInfo() {} - - /// - /// Enable/disable debugging for this device. The device can decide what the most appropriate debugging information is - /// displayed to the user (e.g. HMD position, performance info, latency timing, etc.). - /// - /// @param enable Set to true to enable debugging - /// - virtual void EnableDebugging([[maybe_unused]] bool enable) {} - - /// - /// Draw any custom debug info for this device. This function is invoked by the HMDDebugger. - /// - /// @param transform Local to world-space transform. - /// @param auxGeom A pointer to the auxiliary geometry renderer - /// - virtual void DrawDebugInfo([[maybe_unused]] const AZ::Transform& transform, [[maybe_unused]] IRenderAuxGeom* auxGeom) {} - - /// - /// Get the device info object for this particular HMD. See struct HMDDeviceInfo for more details. - /// - /// @return A pointer to this HMD's HMDDeviceInfo struct - /// - virtual HMDDeviceInfo* GetDeviceInfo() { return nullptr; } - - /// - /// Get whether or not the HMD has been initialized. The HMD has been initialized when it has fully established an interface - /// with its necessary SDK and is ready to be used. - /// - /// @return True if the device has been initialized and is usable - /// - virtual bool IsInitialized() { return false; } - - /// - /// Get the play space of the device, if exists - /// - /// @return True if the device has been initialized and is usable - /// - virtual const Playspace* GetPlayspace() { return nullptr; } - - /// - /// Ask the HMD to update its internal tracking state; must be called once per frame. - /// Must be called from the render thread (the same thread that the device submits on). - /// This will calculate the internal tracking states fit for rendering the upcoming frame. - /// - virtual void UpdateTrackingStates() {} - - protected: - }; - - using HMDDeviceRequestBus = AZ::EBus; - - /// - /// Bus to define HMD debugging. This includes visualization of any HMD-specific objects as well as any - /// VR performance metrics displayed in the HMD. - /// - class HMDDebuggerBus - : public AZ::EBusTraits - { - public: - - virtual ~HMDDebuggerBus() {} - - /// - /// Enable/disable the debugger. - /// - /// @param enable Pass in true to enable info debugging - /// - virtual void EnableInfo(bool enable) = 0; - - /// - /// Enable/disable the camera debugger. - /// - /// @param enable Pass in true to enable camera debugging - /// - virtual void EnableCamera(bool enable) = 0; - }; - - using HMDDebuggerRequestBus = AZ::EBus; - - } // namespace VR -} // namespace AZ diff --git a/Code/Legacy/CryCommon/IMovieSystem.h b/Code/Legacy/CryCommon/IMovieSystem.h index 4da08d3bbf..79c000bfca 100644 --- a/Code/Legacy/CryCommon/IMovieSystem.h +++ b/Code/Legacy/CryCommon/IMovieSystem.h @@ -18,7 +18,9 @@ #include #include #include -#include + +#define DEFAULT_NEAR 0.2f +#define DEFAULT_FOV (75.0f * gf_PI / 180.0f) // forward declaration. struct IAnimTrack; diff --git a/Code/Legacy/CryCommon/IRenderAuxGeom.h b/Code/Legacy/CryCommon/IRenderAuxGeom.h index 6627c41530..a07bba83e4 100644 --- a/Code/Legacy/CryCommon/IRenderAuxGeom.h +++ b/Code/Legacy/CryCommon/IRenderAuxGeom.h @@ -10,6 +10,8 @@ #include "Cry_Color.h" #include "IRenderer.h" +#include +#include struct SAuxGeomRenderFlags; diff --git a/Code/Legacy/CryCommon/IRenderer.h b/Code/Legacy/CryCommon/IRenderer.h index 495c885e44..d457b234e4 100644 --- a/Code/Legacy/CryCommon/IRenderer.h +++ b/Code/Legacy/CryCommon/IRenderer.h @@ -9,7 +9,6 @@ #pragma once -#include "Cry_Camera.h" #include "VertexFormats.h" #include diff --git a/Code/Legacy/CryCommon/IShader.h b/Code/Legacy/CryCommon/IShader.h index 208af79ece..c425bfecc0 100644 --- a/Code/Legacy/CryCommon/IShader.h +++ b/Code/Legacy/CryCommon/IShader.h @@ -52,7 +52,6 @@ enum EParamType }; struct IShader; -class CCamera; union UParamVal { @@ -64,7 +63,6 @@ union UParamVal char* m_String; float m_Color[4]; float m_Vector[3]; - CCamera* m_pCamera; }; struct SShaderParam diff --git a/Code/Legacy/CryCommon/ISystem.h b/Code/Legacy/CryCommon/ISystem.h index a243f00ea2..c286d4af6c 100644 --- a/Code/Legacy/CryCommon/ISystem.h +++ b/Code/Legacy/CryCommon/ISystem.h @@ -57,7 +57,6 @@ namespace Audio struct SFileVersion; struct INameTable; struct ILevelSystem; -struct IViewSystem; class IXMLBinarySerializer; struct IAVI_Reader; class CPNoise3; @@ -75,7 +74,6 @@ namespace AZ typedef void* WIN_HWND; -class CCamera; struct CLoadingTimeProfiler; class ICmdLine; @@ -823,8 +821,6 @@ struct ISystem // return the related subsystem interface - // - virtual IViewSystem* GetIViewSystem() = 0; virtual ILevelSystem* GetILevelSystem() = 0; virtual ICmdLine* GetICmdLine() = 0; virtual ILog* GetILog() = 0; diff --git a/Code/Legacy/CryCommon/IViewSystem.h b/Code/Legacy/CryCommon/IViewSystem.h deleted file mode 100644 index d8514aadf6..0000000000 --- a/Code/Legacy/CryCommon/IViewSystem.h +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - - -// Description : View System interfaces. - -#pragma once - -#include -#include - -// -#define VIEWID_NORMAL 0 -#define VIEWID_FOLLOWHEAD 1 -#define VIEWID_VEHICLE 2 -#define VIEWID_RAGDOLL 3 - -//Forward declaration of AZ::Entity -namespace AZ { - class Entity; -} - -enum EMotionBlurType -{ - eMBT_None = 0, - eMBT_Accumulation = 1, - eMBT_Velocity = 2 -}; - -struct SViewParams -{ - SViewParams() - : position(ZERO) - , rotation(IDENTITY) - , localRotationLast(IDENTITY) - , nearplane(0.0f) - , farplane(0.0f) - , fov(0.0f) - , viewID(0) - , groundOnly(false) - , shakingRatio(0.0f) - , currentShakeQuat(IDENTITY) - , currentShakeShift(ZERO) - , targetPos(ZERO) - , frameTime(0.0f) - , angleVel(0.0f) - , vel(0.0f) - , dist(0.0f) - , blend(true) - , blendPosSpeed(5.0f) - , blendRotSpeed(10.0f) - , blendFOVSpeed(5.0f) - , blendPosOffset(ZERO) - , blendRotOffset(IDENTITY) - , blendFOVOffset(0) - , justActivated(false) - , viewIDLast(0) - , positionLast(ZERO) - , rotationLast(IDENTITY) - , FOVLast(0) - { - } - - void SetViewID(uint8 id, bool shouldBlend = true) - { - viewID = id; - if (!shouldBlend) - { - viewIDLast = id; - } - } - - void UpdateBlending(float curFrameTime) - { - //if necessary blend the view - if (blend) - { - if (viewIDLast != viewID) - { - blendPosOffset = positionLast - position; - blendRotOffset = (rotationLast / rotation).GetNormalized(); - blendFOVOffset = FOVLast - fov; - } - else - { - blendPosOffset -= blendPosOffset * min(1.0f, blendPosSpeed * curFrameTime); - blendRotOffset = Quat::CreateSlerp(blendRotOffset, IDENTITY, min(1.0f, curFrameTime * blendRotSpeed)); - blendFOVOffset -= blendFOVOffset * min(1.0f, blendFOVSpeed * curFrameTime); - } - - position += blendPosOffset; - rotation *= blendRotOffset; - fov += blendFOVOffset; - } - else - { - blendPosOffset.zero(); - blendRotOffset.SetIdentity(); - blendFOVOffset = 0.0f; - } - - viewIDLast = viewID; - } - - void BlendFrom(const SViewParams& params) - { - positionLast = params.position; - rotationLast = params.rotation; - FOVLast = params.fov; - localRotationLast = params.localRotationLast; - blend = true; - viewIDLast = 0xff; - } - - void SaveLast() - { - if (viewIDLast != 0xff) - { - positionLast = position; - rotationLast = rotation; - FOVLast = fov; - } - else - { - viewIDLast = 0xfe; - } - } - - void ResetBlending() - { - blendPosOffset.zero(); - blendRotOffset.SetIdentity(); - } - - const Vec3& GetPositionLast() { return positionLast; } - const Quat& GetRotationLast() { return rotationLast; } - - // - Vec3 position;//view position - Quat rotation;//view orientation - Quat localRotationLast; - - float nearplane;//custom near clipping plane, 0 means use engine defaults - float farplane;//custom far clipping plane, 0 means use engine defaults - float fov; - - uint8 viewID; - - //view shake status - bool groundOnly; - float shakingRatio;//whats the ammount of shake, from 0.0 to 1.0 - Quat currentShakeQuat;//what the current angular shake - Vec3 currentShakeShift;//what is the current translational shake - - // For damping camera movement. - Vec3 targetPos; // Where the target was. - float frameTime; // current dt. - float angleVel; // previous rate of change of angle. - float vel; // previous rate of change of dist between target and camera. - float dist; // previous dist of cam from target - - //blending - bool blend; - float blendPosSpeed; - float blendRotSpeed; - float blendFOVSpeed; - Vec3 blendPosOffset; - Quat blendRotOffset; - float blendFOVOffset; - bool justActivated; - -private: - uint8 viewIDLast; - Vec3 positionLast;//last view position - Quat rotationLast;//last view orientation - float FOVLast; -}; - -struct IAnimSequence; -struct SCameraParams; - -struct IView -{ - virtual ~IView() {} - struct SShakeParams - { - Ang3 shakeAngle; - Vec3 shakeShift; - float sustainDuration; - float fadeInDuration; - float fadeOutDuration; - float frequency; - float randomness; - int shakeID; - bool bFlipVec; - bool bUpdateOnly; - bool bGroundOnly; - bool bPermanent; // if true, sustainDuration is ignored - bool isSmooth; - - SShakeParams() - : shakeAngle(0, 0, 0) - , shakeShift(0, 0, 0) - , sustainDuration(0) - , fadeInDuration(0) - , fadeOutDuration(2.f) - , frequency(0) - , randomness(0) - , shakeID(0) - , bFlipVec(true) - , bUpdateOnly(false) - , bGroundOnly(false) - , bPermanent(false) - , isSmooth(false) - { - } - }; - - virtual void Release() = 0; - virtual void Update(float frameTime, bool isActive) = 0; - virtual void LinkTo(AZ::Entity* follow) = 0; - virtual void Unlink() = 0; - virtual AZ::EntityId GetLinkedId() = 0; - virtual CCamera& GetCamera() = 0; - virtual const CCamera& GetCamera() const = 0; - - virtual void PostSerialize() = 0; - virtual void SetCurrentParams(SViewParams& params) = 0; - virtual const SViewParams* GetCurrentParams() = 0; - virtual void SetViewShake(Ang3 shakeAngle, Vec3 shakeShift, float duration, float frequency, float randomness, int shakeID, bool bFlipVec = true, bool bUpdateOnly = false, bool bGroundOnly = false) = 0; - virtual void SetViewShakeEx(const SShakeParams& params) = 0; - virtual void StopShake(int shakeID) = 0; - virtual void ResetShaking() = 0; - virtual void ResetBlending() = 0; - virtual void SetFrameAdditiveCameraAngles(const Ang3& addFrameAngles) = 0; - virtual void SetScale(const float scale) = 0; - virtual void SetZoomedScale(const float scale) = 0; - virtual void SetActive(const bool bActive) = 0; -}; - -struct IViewSystemListener -{ - virtual ~IViewSystemListener() {} - virtual bool OnBeginCutScene(IAnimSequence* pSeq, bool bResetFX) = 0; - virtual bool OnEndCutScene(IAnimSequence* pSeq) = 0; - virtual bool OnCameraChange(const SCameraParams& cameraParams) = 0; -}; - -struct IViewSystem -{ - virtual ~IViewSystem() {} - virtual void Release() = 0; - virtual void Update(float frameTime) = 0; - virtual IView* CreateView() = 0; - virtual unsigned int AddView(IView* pView) = 0; - virtual void RemoveView(IView* pView) = 0; - virtual void RemoveView(unsigned int viewId) = 0; - - virtual void SetActiveView(IView* pView) = 0; - virtual void SetActiveView(unsigned int viewId) = 0; - - //utility functions - virtual IView* GetView(unsigned int viewId) = 0; - virtual IView* GetActiveView() = 0; - - virtual unsigned int GetViewId(IView* pView) = 0; - virtual unsigned int GetActiveViewId() = 0; - - virtual IView* GetViewByEntityId(const AZ::EntityId& id, bool forceCreate = false) = 0; - - virtual bool AddListener(IViewSystemListener* pListener) = 0; - virtual bool RemoveListener(IViewSystemListener* pListener) = 0; - - virtual void PostSerialize() = 0; - - // Get default distance to near clipping plane. - virtual float GetDefaultZNear() = 0; - - virtual void SetBlendParams(float fBlendPosSpeed, float fBlendRotSpeed, bool performBlendOut) = 0; - - // Used by time demo playback. - virtual void SetOverrideCameraRotation(bool bOverride, Quat rotation) = 0; - - virtual bool IsPlayingCutScene() const = 0; - - virtual void SetDeferredViewSystemUpdate(bool const bDeferred) = 0; - virtual bool UseDeferredViewSystemUpdate() const = 0; - virtual void SetControlAudioListeners(bool const bActive) = 0; - virtual void ForceUpdate(float elapsed) = 0; -}; diff --git a/Code/Legacy/CryCommon/Mocks/IRemoteConsoleMock.h b/Code/Legacy/CryCommon/Mocks/IRemoteConsoleMock.h deleted file mode 100644 index 21786a322c..0000000000 --- a/Code/Legacy/CryCommon/Mocks/IRemoteConsoleMock.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#pragma once - -#include "IConsole.h" - -// Auto-generated by gmock_gen.py - -class IRemoteConsoleMock - : public IRemoteConsole -{ -public: - MOCK_METHOD0(RegisterConsoleVariables, void()); - MOCK_METHOD0(UnregisterConsoleVariables, void()); - MOCK_METHOD0(Start, void()); - MOCK_METHOD0(Stop, void()); - MOCK_CONST_METHOD0(IsStarted, bool()); - MOCK_METHOD1(AddLogMessage, void(const char* log)); - MOCK_METHOD1(AddLogWarning, void(const char* log)); - MOCK_METHOD1(AddLogError, void(const char* log)); - MOCK_METHOD0(Update, void()); - MOCK_METHOD2(RegisterListener, void(IRemoteConsoleListener* pListener, const char* name)); - MOCK_METHOD1(UnregisterListener, void(IRemoteConsoleListener* pListener)); -}; diff --git a/Code/Legacy/CryCommon/Mocks/ISystemMock.h b/Code/Legacy/CryCommon/Mocks/ISystemMock.h index a11b60fe68..d0f8dbd2e5 100644 --- a/Code/Legacy/CryCommon/Mocks/ISystemMock.h +++ b/Code/Legacy/CryCommon/Mocks/ISystemMock.h @@ -7,7 +7,6 @@ */ #pragma once #include -#include #ifdef GetUserName #undef GetUserName @@ -56,8 +55,6 @@ public: int(const char* text, const char* caption, unsigned int uType)); MOCK_METHOD1(CheckLogVerbosity, bool(int verbosity)); - MOCK_METHOD0(GetIViewSystem, - IViewSystem * ()); MOCK_METHOD0(GetILevelSystem, ILevelSystem * ()); MOCK_METHOD0(GetICmdLine, diff --git a/Code/Legacy/CryCommon/Mocks/ITextureMock.h b/Code/Legacy/CryCommon/Mocks/ITextureMock.h deleted file mode 100644 index 8dc657195c..0000000000 --- a/Code/Legacy/CryCommon/Mocks/ITextureMock.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#pragma once - -#include -#include - -class ITextureMock - : public ITexture -{ -public: - MOCK_METHOD0(AddRef, - int()); - MOCK_METHOD0(Release, - int()); - MOCK_METHOD0(ReleaseForce, - int()); - MOCK_CONST_METHOD0(GetName, - const char*()); -}; diff --git a/Code/Legacy/CryCommon/VRCommon.h b/Code/Legacy/CryCommon/VRCommon.h deleted file mode 100644 index 408da8453c..0000000000 --- a/Code/Legacy/CryCommon/VRCommon.h +++ /dev/null @@ -1,255 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#pragma once - -#include -#include -#include -#include -#include - -#include - -#include - -namespace AZ -{ - namespace VR - { - /// - /// Enum to describe the stereo layout of content - /// - enum class StereoLayout : AZ::u32 - { - TOP_BOTTOM = 0, //Top is Left, Bottom is Right - BOTTOM_TOP, //Bottom is Left, Top is Right - //TODO: Figure out how to support LEFT_RIGHT and RIGHT_LEFT - //TOP_BOTTOM is preferred because of the way that scan lines are ordered - //LEFT_RIGHT, //Left is Left, Right is Right - //RIGHT_LEFT, //Right is Left, Left is Right - UNKNOWN //This content is either not stereo or its stereo format cannot be determined - }; - - - /// - /// Eye-specific camera info. - /// - struct PerEyeCameraInfo - { - float fov; ///< Field-of-view of this eye. Note that each eye may have different fields-of-view. - float aspectRatio; ///< Aspect-ratio of this eye. Note that each eye may have different aspect ratios. - AZ::Vector3 eyeOffset; ///< Camera-space offset for this eye relative to the non-stereo view. - - struct AsymmetricFrustumPlane - { - float horizontalDistance; ///< Horizontal frustum shift relative to the non-stereo frustum. - float verticalDistance; ///< Vertical frustum shift relative to the non-stereo frustum. - - AsymmetricFrustumPlane() - : horizontalDistance(1.6f) - , verticalDistance(0.9f) - { - } - }; - - AsymmetricFrustumPlane frustumPlane; - - PerEyeCameraInfo() - : aspectRatio(16.0f / 9.0f) - , fov(DEG2RAD(1.5f)) - , eyeOffset(0.65f, 0.0f, 0.0f) - { - } - }; - - /// - /// Types of social screens supported by the engine. - /// - enum class HMDSocialScreen - { - Off = -1, - UndistortedLeftEye, - UndistortedRightEye, - }; - - /// - /// Supported tracking levels. - /// - enum class HMDTrackingLevel - { - kHead, ///< The sensor reads as if the player is standing. - kFloor, ///< Sensor reads as if the player is seated/on the floor. - kFixed ///< Translation information is ignored, the view appears at the HMD origin - }; - - /// - /// Human-readable info about the connected device. This info is printed to the screen when a new device is detected. - /// - struct HMDDeviceInfo - { - AZ_TYPE_INFO(HMDDeviceInfo, "{DB83AF23-CF4E-491D-A346-F5DC834D1C74}") - - static void Reflect(AZ::ReflectContext* context); - - const char* productName; - const char* manufacturer; - - // Rendering resolution is defined as containing just a single eye. - unsigned int renderWidth; - unsigned int renderHeight; - - // Field of view is defined as the total field of view of the device which includes both eyes. - float fovH; - float fovV; - - HMDDeviceInfo() - : productName(nullptr) - , manufacturer(nullptr) - , renderWidth(0) - , renderHeight(0) - , fovH(0.0f) - , fovV(0.0f) - { - } - }; - - enum HMDStatus - { - HMDStatus_OrientationTracked = BIT(1), - HMDStatus_PositionTracked = BIT(2), - HMDStatus_CameraPoseTracked = BIT(3), - HMDStatus_PositionConnected = BIT(4), - HMDStatus_HmdConnected = BIT(5), - - HMDStatus_IsUsable = HMDStatus_HmdConnected | HMDStatus_OrientationTracked, - HMDStatus_ControllerValid = HMDStatus_OrientationTracked | HMDStatus_PositionConnected, - }; - - /// - /// Single device render target created and managed by the device. The renderer should make use of this render target in order to properly display - /// the rendered content to this HMD. - /// - struct HMDRenderTarget - { - void* deviceSwapTextureSet; ///< Device-represented texture. These textures are created and maintained by the HMD's specific SDK. - uint32 numTextures; ///< Number of textures inside of the swap set. - void** textures; ///< Access to the internal device textures. This array is exactly numTextures long. - - HMDRenderTarget() - : deviceSwapTextureSet(nullptr) - , numTextures(0) - , textures(nullptr) - { - } - }; - - enum class ControllerIndex - : uint32_t - { - LeftHand = 0, - RightHand, - MaxNumControllers - }; - - /// - /// A specific pose of the HMD. Every HMD device has their own way of representing their - /// current pose in 3D space. This structure acts as a common data set between any connected - /// device and the rest of the system. - /// - struct PoseState - { - AZ_TYPE_INFO(PoseState, "{040F18D7-1163-477B-8908-47CC35737DCE}") - - static void Reflect(AZ::ReflectContext* context); - - AZ::Quaternion orientation; ///< The current orientation of the HMD. - AZ::Vector3 position; ///< The current position of the HMD in local space as an offset from the centered pose. - - PoseState() - : orientation(AZ::Quaternion::CreateIdentity()) - , position(AZ::Vector3::CreateZero()) - { - } - }; - - /// - /// Dynamics (accelerations and velocities) of the current HMD. Many HMDs have the ability to track the current movements - /// of the VR device(s) for prediction. Note that not all devices may support velocities/accelerations. - /// - struct DynamicsState - { - AZ_TYPE_INFO(DynamicsState, "{5C5E2249-8844-4790-9F7A-88703A9C18DD}") - - static void Reflect(AZ::ReflectContext* context); - - /// Angular velocity/acceleration reported in local space. - AZ::Vector3 angularVelocity; - AZ::Vector3 angularAcceleration; - - /// Linear velocity/acceleration reported in local space. - AZ::Vector3 linearVelocity; - AZ::Vector3 linearAcceleration; - - DynamicsState() - : angularVelocity(0) - , angularAcceleration(0) - , linearVelocity(0) - , linearAcceleration(0) - { - } - }; - - /// - /// While tracking the HMD, certain parts of the devices may go off/online. For example, - /// a controller may be disconnected or the HMD may lose rotational tracking temporarily. This - /// struct stores a tracked state meaning a pose as well as flags that denote what part of the pose - /// is currently valid. - /// - struct TrackingState - { - AZ_TYPE_INFO(TrackingState, "{E9CB08E8-9996-478B-AABB-EC8CCCF3B403}") - - typedef uint32 StatusFlags; - - bool CheckStatusFlags(StatusFlags flags) const - { - // Multiple flags can be checked simultaneously. - return (statusFlags & flags) == flags; - } - - static void Reflect(AZ::ReflectContext* context); - - PoseState pose; ///< Current pose relating to this tracked state. - DynamicsState dynamics; ///< Current state of the physics dynamics for this device. - StatusFlags statusFlags; ///< Bitfield denoting current tracking status. Flags defined in the enum HMDStatus. - - TrackingState() - : statusFlags(0) - { - } - }; - - /// - /// Rectangle storing the playspace defined by the user when - /// setting up VR device. - /// - struct Playspace - { - AZ_TYPE_INFO(Playspace, "{05934537-80AA-4ABA-AB2C-71096FA7DC74}") - AZ_CLASS_ALLOCATOR_DECL - - static void Reflect(AZ::ReflectContext* context); - - bool isValid = false; ///< The playspace data is valid (calibrated). - AZStd::array corners; ///< Playspace corners defined in device-local space. The center of the playspace is 0. - }; - - }//namespace VR - AZ_TYPE_INFO_SPECIALIZE(VR::ControllerIndex, "{90D4C80E-A1CC-4DBF-A131-0082C75835E8}"); -}//namespace AZ diff --git a/Code/Legacy/CryCommon/crycommon_files.cmake b/Code/Legacy/CryCommon/crycommon_files.cmake index b3db694ca1..d2c89fee84 100644 --- a/Code/Legacy/CryCommon/crycommon_files.cmake +++ b/Code/Legacy/CryCommon/crycommon_files.cmake @@ -36,12 +36,9 @@ set(FILES ITexture.h ITimer.h IValidator.h - IViewSystem.h IWindowMessageHandler.h IXml.h MicrophoneBus.h - HMDBus.h - VRCommon.h INavigationSystem.h IMNM.h SerializationTypes.h @@ -81,7 +78,6 @@ set(FILES Cry_Matrix34.h Cry_Matrix44.h Cry_Vector4.h - Cry_Camera.h Cry_Color.h Cry_Geo.h Cry_GeoDistance.h diff --git a/Code/Legacy/CryCommon/crycommon_testing_files.cmake b/Code/Legacy/CryCommon/crycommon_testing_files.cmake index 9c3427d529..a44d91dd74 100644 --- a/Code/Legacy/CryCommon/crycommon_testing_files.cmake +++ b/Code/Legacy/CryCommon/crycommon_testing_files.cmake @@ -14,6 +14,4 @@ set(FILES Mocks/ISystemMock.h Mocks/ITimerMock.h Mocks/ICVarMock.h - Mocks/ITextureMock.h - Mocks/IRemoteConsoleMock.h ) diff --git a/Code/Legacy/CrySystem/CrySystem_precompiled.h b/Code/Legacy/CrySystem/CrySystem_precompiled.h index 3ececa6514..27e41317a4 100644 --- a/Code/Legacy/CrySystem/CrySystem_precompiled.h +++ b/Code/Legacy/CrySystem/CrySystem_precompiled.h @@ -71,7 +71,6 @@ // CRY Stuff //////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// #include "Cry_Math.h" -#include #include #include #include diff --git a/Code/Legacy/CrySystem/System.cpp b/Code/Legacy/CrySystem/System.cpp index a6ffdec4e8..6d238c828f 100644 --- a/Code/Legacy/CrySystem/System.cpp +++ b/Code/Legacy/CrySystem/System.cpp @@ -128,7 +128,6 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) #include "LocalizedStringManager.h" #include "XML/XmlUtils.h" #include "SystemEventDispatcher.h" -#include "HMDBus.h" #include "RemoteConsole/RemoteConsole.h" @@ -153,8 +152,6 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) // Define global cvars. SSystemCVars g_cvars; -#include - #include #include #include "AZCoreLogSink.h" @@ -218,7 +215,6 @@ CSystem::CSystem(SharedEnvironmentInstance* pSharedEnvironment) m_pProcess = NULL; m_pCmdLine = NULL; m_pLevelSystem = NULL; - m_pViewSystem = NULL; m_pLocalizationManager = NULL; #if defined(AZ_RESTRICTED_PLATFORM) #define AZ_RESTRICTED_SECTION SYSTEM_CPP_SECTION_2 @@ -434,9 +430,6 @@ void CSystem::ShutDown() m_pSystemEventDispatcher->OnSystemEvent(ESYSTEM_EVENT_FULL_SHUTDOWN, 0, 0); } - // Shutdown any running VR devices. - EBUS_EVENT(AZ::VR::HMDInitRequestBus, Shutdown); - if (gEnv && gEnv->pLyShine) { gEnv->pLyShine->Release(); @@ -450,7 +443,6 @@ void CSystem::ShutDown() { ((CXConsole*)m_env.pConsole)->FreeRenderResources(); } - SAFE_RELEASE(m_pViewSystem); SAFE_RELEASE(m_pLevelSystem); if (m_env.pLog) @@ -1603,11 +1595,6 @@ std::shared_ptr CSystem::CreateLocalFileIO() return std::make_shared(); } -IViewSystem* CSystem::GetIViewSystem() -{ - return m_pViewSystem; -} - ILevelSystem* CSystem::GetILevelSystem() { return m_pLevelSystem; diff --git a/Code/Legacy/CrySystem/System.h b/Code/Legacy/CrySystem/System.h index fd5c917a94..d25e094692 100644 --- a/Code/Legacy/CrySystem/System.h +++ b/Code/Legacy/CrySystem/System.h @@ -234,7 +234,6 @@ public: ICryFont* GetICryFont() override{ return m_env.pCryFont; } ILog* GetILog() override{ return m_env.pLog; } ICmdLine* GetICmdLine() override{ return m_pCmdLine; } - IViewSystem* GetIViewSystem() override; ILevelSystem* GetILevelSystem() override; ISystemEventDispatcher* GetISystemEventDispatcher() override { return m_pSystemEventDispatcher; } ////////////////////////////////////////////////////////////////////////// @@ -405,10 +404,6 @@ private: // ------------------------------------------------------ //! current active process IProcess* m_pProcess; - CCamera m_PhysRendererCamera; - ICVar* m_p_draw_helpers_str; - int m_iJumpToPhysProfileEnt; - CTimeValue m_lastTickTime; //! system event dispatcher @@ -423,9 +418,6 @@ private: // ------------------------------------------------------ //! System to manage levels. ILevelSystem* m_pLevelSystem; - //! System to manage views. - IViewSystem* m_pViewSystem; - // XML Utils interface. class CXmlUtils* m_pXMLUtils; diff --git a/Code/Legacy/CrySystem/SystemInit.cpp b/Code/Legacy/CrySystem/SystemInit.cpp index cd46fc8a04..14d0635da7 100644 --- a/Code/Legacy/CrySystem/SystemInit.cpp +++ b/Code/Legacy/CrySystem/SystemInit.cpp @@ -78,7 +78,6 @@ #include #include #include -#include #include #include "XConsole.h" @@ -88,7 +87,6 @@ #include "SystemEventDispatcher.h" #include "LevelSystem/LevelSystem.h" #include "LevelSystem/SpawnableLevelSystem.h" -#include "ViewSystem/ViewSystem.h" #include #include #include @@ -1146,12 +1144,6 @@ AZ_POP_DISABLE_WARNING InlineInitializationProcessing("CSystem::Init Level System"); - ////////////////////////////////////////////////////////////////////////// - // VIEW SYSTEM (must be created after m_pLevelSystem) - m_pViewSystem = new LegacyViewSystem::CViewSystem(this); - - InlineInitializationProcessing("CSystem::Init View System"); - if (m_env.pLyShine) { m_env.pLyShine->PostInit(); diff --git a/Code/Legacy/CrySystem/ViewSystem/DebugCamera.cpp b/Code/Legacy/CrySystem/ViewSystem/DebugCamera.cpp deleted file mode 100644 index 6eab555ac4..0000000000 --- a/Code/Legacy/CrySystem/ViewSystem/DebugCamera.cpp +++ /dev/null @@ -1,333 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#include "CrySystem_precompiled.h" -#include "DebugCamera.h" -#include "ISystem.h" -#include "Cry_Camera.h" -#include "IViewSystem.h" - -#include -#include -#include - -using namespace AzFramework; - -namespace LegacyViewSystem -{ -const float g_moveScaleIncrement = 0.1f; -const float g_moveScaleMin = 0.01f; -const float g_moveScaleMax = 10.0f; -const float g_mouseMoveScale = 0.1f; -const float g_gamepadRotationSpeed = 5.0f; -const float g_mouseMaxRotationSpeed = 270.0f; -const float g_moveSpeed = 10.0f; -const float g_maxPitch = 85.0f; -const float g_boostMultiplier = 10.0f; -const float g_minRotationSpeed = 15.0f; -const float g_maxRotationSpeed = 70.0f; - -/////////////////////////////////////////////////////////////////////////////// -DebugCamera::DebugCamera() - : m_mouseMoveMode(0) - , m_isYInverted(0) - , m_cameraMode(DebugCamera::ModeOff) - , m_cameraYawInput(0.0f) - , m_cameraPitchInput(0.0f) - , m_cameraYaw(0.0f) - , m_cameraPitch(0.0f) - , m_moveInput(ZERO) - , m_moveScale(1.0f) - , m_oldMoveScale(1.0f) - , m_position(ZERO) - , m_view(IDENTITY) -{ - InputChannelEventListener::Connect(); -} - -/////////////////////////////////////////////////////////////////////////////// -DebugCamera::~DebugCamera() -{ - InputChannelEventListener::Disconnect(); -} - -/////////////////////////////////////////////////////////////////////////////// -void DebugCamera::OnEnable() -{ - m_position = Vec3_Zero; - m_moveInput = Vec3_Zero; - - Ang3 cameraAngles = Ang3(ZERO); - m_cameraYaw = RAD2DEG(cameraAngles.z); - m_cameraPitch = RAD2DEG(cameraAngles.x); - m_view = Matrix33(Ang3(DEG2RAD(m_cameraPitch), 0.0f, DEG2RAD(m_cameraYaw))); - - m_cameraYawInput = 0.0f; - m_cameraPitchInput = 0.0f; - - m_mouseMoveMode = 0; - m_cameraMode = DebugCamera::ModeFree; -} - -/////////////////////////////////////////////////////////////////////////////// -void DebugCamera::OnDisable() -{ - m_mouseMoveMode = 0; - m_cameraMode = DebugCamera::ModeOff; -} - -/////////////////////////////////////////////////////////////////////////////// -void DebugCamera::OnInvertY() -{ - m_isYInverted = !m_isYInverted; -} - -/////////////////////////////////////////////////////////////////////////////// -void DebugCamera::OnNextMode() -{ - if (m_cameraMode == DebugCamera::ModeFree) - { - m_cameraMode = DebugCamera::ModeFixed; - } - // ... - else if (m_cameraMode == DebugCamera::ModeFixed) - { - // this is the last mode, go to disabled. - OnDisable(); - } -} - -/////////////////////////////////////////////////////////////////////////////// -void DebugCamera::Update() -{ - if (m_cameraMode == DebugCamera::ModeOff) - { - return; - } - - float rotationSpeed = clamp_tpl(m_moveScale, g_minRotationSpeed, g_maxRotationSpeed); - UpdateYaw(m_cameraYawInput * rotationSpeed * gEnv->pTimer->GetFrameTime()); - UpdatePitch(m_cameraPitchInput * rotationSpeed * gEnv->pTimer->GetFrameTime()); - - m_view = Matrix33(Ang3(DEG2RAD(m_cameraPitch), 0.0f, DEG2RAD(m_cameraYaw))); - UpdatePosition(m_moveInput); -} - -/////////////////////////////////////////////////////////////////////////////// -void DebugCamera::PostUpdate() -{ -} - -/////////////////////////////////////////////////////////////////////////////// -bool DebugCamera::OnInputChannelEventFiltered(const InputChannel& inputChannel) -{ - if (!IsEnabled() || m_cameraMode == DebugCamera::ModeFixed || gEnv->pConsole->IsOpened()) - { - return false; - } - - const InputDeviceId& deviceId = inputChannel.GetInputDevice().GetInputDeviceId(); - const InputChannelId& channelId = inputChannel.GetInputChannelId(); - const float eventValue = inputChannel.GetValue(); - if (InputDeviceKeyboard::IsKeyboardDevice(deviceId)) - { - if (channelId == InputDeviceKeyboard::Key::AlphanumericW) - { - m_moveInput.y = eventValue; - } - else if (channelId == InputDeviceKeyboard::Key::AlphanumericS) - { - m_moveInput.y = -eventValue; - } - else if (channelId == InputDeviceKeyboard::Key::AlphanumericA) - { - m_moveInput.x = -eventValue; - } - else if (channelId == InputDeviceKeyboard::Key::AlphanumericD) - { - m_moveInput.x = eventValue; - } - else if (channelId == InputDeviceKeyboard::Key::ModifierShiftL) - { - if (inputChannel.IsStateEnded()) - { - m_moveScale = m_oldMoveScale; - } - else if (inputChannel.IsStateBegan()) - { - m_oldMoveScale = m_moveScale; - m_moveScale = clamp_tpl(m_moveScale * g_boostMultiplier, g_moveScaleMin, g_moveScaleMax); - } - } - } - else if (InputDeviceMouse::IsMouseDevice(deviceId)) - { - if (channelId == InputDeviceMouse::Movement::Z) - { - if (inputChannel.GetValue() > 0) - { - m_moveScale = clamp_tpl(m_moveScale + g_moveScaleIncrement, g_moveScaleMin, g_moveScaleMax); - } - else - { - m_moveScale = clamp_tpl(m_moveScale - g_moveScaleIncrement, g_moveScaleMin, g_moveScaleMax); - } - } - else if (channelId == InputDeviceMouse::Movement::X) - { - //KC: If both left and right mouse buttons are pressed then use - //the mouse movement for horizontal movement. - if (2 != m_mouseMoveMode) - { - UpdateYaw(fsgnf(-eventValue) * clamp_tpl(fabs_tpl(eventValue) * m_moveScale, 0.0f, g_mouseMaxRotationSpeed) * gEnv->pTimer->GetFrameTime()); - } - else - { - UpdatePosition(Vec3(eventValue * g_mouseMoveScale, 0.0f, 0.0f)); - } - } - else if (channelId == InputDeviceMouse::Movement::Y) - { - //KC: If both left and right mouse buttons are pressed then use - //the mouse movement for vertical movement. - if (2 != m_mouseMoveMode) - { - UpdatePitch(fsgnf(-eventValue) * clamp_tpl(fabs_tpl(eventValue) * m_moveScale, 0.0f, g_mouseMaxRotationSpeed) * gEnv->pTimer->GetFrameTime()); - } - else - { - UpdatePosition(Vec3(0.0f, 0.0f, -eventValue * g_mouseMoveScale)); - } - } - else if (channelId == InputDeviceMouse::Button::Left) - { - if (inputChannel.IsStateEnded()) - { - m_mouseMoveMode = clamp_tpl(m_mouseMoveMode - 1, 0, 2); - } - else - { - m_mouseMoveMode = clamp_tpl(m_mouseMoveMode + 1, 0, 2); - } - } - else if (channelId == InputDeviceMouse::Button::Right) - { - if (inputChannel.IsStateEnded()) - { - m_mouseMoveMode = clamp_tpl(m_mouseMoveMode - 1, 0, 2); - } - else - { - m_mouseMoveMode = clamp_tpl(m_mouseMoveMode + 1, 0, 2); - } - } - } - else if (InputDeviceGamepad::IsGamepadDevice(deviceId)) - { - if (channelId == InputDeviceGamepad::Button::DU) - { - m_moveScale = clamp_tpl(m_moveScale + g_moveScaleIncrement, g_moveScaleMin, g_moveScaleMax); - } - else if (channelId == InputDeviceGamepad::Button::DD) - { - m_moveScale = clamp_tpl(m_moveScale - g_moveScaleIncrement, g_moveScaleMin, g_moveScaleMax); - } - else if (channelId == InputDeviceGamepad::Trigger::L2) - { - m_moveInput.z = -eventValue; - } - else if (channelId == InputDeviceGamepad::Trigger::R2) - { - m_moveInput.z = eventValue; - } - else if (channelId == InputDeviceGamepad::ThumbStickAxis1D::LX) - { - m_moveInput.x = eventValue; - } - else if (channelId == InputDeviceGamepad::ThumbStickAxis1D::LY) - { - m_moveInput.y = eventValue; - } - else if (channelId == InputDeviceGamepad::ThumbStickAxis1D::RX) - { - m_cameraYawInput = -eventValue * g_gamepadRotationSpeed; - } - else if (channelId == InputDeviceGamepad::ThumbStickAxis1D::RY) - { - m_cameraPitchInput = eventValue * g_gamepadRotationSpeed; - } - //KC: Use the shoulder buttons to temporarily boost or reduce the scale. - else if (channelId == InputDeviceGamepad::Button::L1) - { - if (inputChannel.IsStateEnded()) - { - m_moveScale = m_oldMoveScale; - } - else if (inputChannel.IsStateBegan()) - { - m_oldMoveScale = m_moveScale; - m_moveScale = clamp_tpl(m_moveScale / g_boostMultiplier, g_moveScaleMin, g_moveScaleMax); - } - } - else if (channelId == InputDeviceGamepad::Button::R1) - { - if (inputChannel.IsStateEnded()) - { - m_moveScale = m_oldMoveScale; - } - else if (inputChannel.IsStateBegan()) - { - m_oldMoveScale = m_moveScale; - m_moveScale = clamp_tpl(m_moveScale * g_boostMultiplier, g_moveScaleMin, g_moveScaleMax); - } - } - } - - return false; -} - -/////////////////////////////////////////////////////////////////////////////// -void DebugCamera::UpdatePitch(float amount) -{ - if (m_isYInverted) - { - amount = -amount; - } - - m_cameraPitch += amount; - m_cameraPitch = clamp_tpl(m_cameraPitch, -g_maxPitch, g_maxPitch); -} - -/////////////////////////////////////////////////////////////////////////////// -void DebugCamera::UpdateYaw(float amount) -{ - m_cameraYaw += amount; - if (m_cameraYaw < 0.0f) - { - m_cameraYaw += 360.0f; - } - else if (m_cameraYaw >= 360.0f) - { - m_cameraYaw -= 360.0f; - } -} - -/////////////////////////////////////////////////////////////////////////////// -void DebugCamera::UpdatePosition(const Vec3& amount) -{ - Vec3 diff = amount * g_moveSpeed * m_moveScale * gEnv->pTimer->GetFrameTime(); - MovePosition(diff); -} - -void DebugCamera::MovePosition(const Vec3& offset) -{ - m_position += m_view.GetColumn0() * offset.x; - m_position += m_view.GetColumn1() * offset.y; - m_position += m_view.GetColumn2() * offset.z; -} - -} // namespace LegacyViewSystem diff --git a/Code/Legacy/CrySystem/ViewSystem/DebugCamera.h b/Code/Legacy/CrySystem/ViewSystem/DebugCamera.h deleted file mode 100644 index c170b73c96..0000000000 --- a/Code/Legacy/CrySystem/ViewSystem/DebugCamera.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#pragma once - -#include - -namespace LegacyViewSystem -{ -/////////////////////////////////////////////////////////////////////////////// -class DebugCamera - : public AzFramework::InputChannelEventListener -{ -public: - enum Mode - { - ModeOff, // no debug cam - ModeFree, // free-fly - ModeFixed, // fixed cam, control goes back to game - }; - - DebugCamera(); - ~DebugCamera() override; - - void Update(); - void PostUpdate(); - bool IsEnabled(); - bool IsFixed(); - bool IsFree(); - - // AzFramework::InputChannelEventListener - bool OnInputChannelEventFiltered(const AzFramework::InputChannel& inputChannel) override; - - void OnEnable(); - void OnDisable(); - void OnInvertY(); - void OnNextMode(); - void UpdatePitch(float amount); - void UpdateYaw(float amount); - void UpdatePosition(const Vec3& amount); - void MovePosition(const Vec3& offset); - -protected: - int m_mouseMoveMode; - int m_isYInverted; - int m_cameraMode; - float m_cameraYawInput; - float m_cameraPitchInput; - float m_cameraYaw; - float m_cameraPitch; - Vec3 m_moveInput; - - float m_moveScale; - float m_oldMoveScale; - Vec3 m_position; - Matrix33 m_view; -}; - - -inline bool DebugCamera::IsEnabled() -{ - return m_cameraMode != DebugCamera::ModeOff; -} - -inline bool DebugCamera::IsFixed() -{ - return m_cameraMode == DebugCamera::ModeFixed; -} - -inline bool DebugCamera::IsFree() -{ - return m_cameraMode == DebugCamera::ModeFree; -} - -} // namespace LegacyViewSystem diff --git a/Code/Legacy/CrySystem/ViewSystem/View.cpp b/Code/Legacy/CrySystem/ViewSystem/View.cpp deleted file mode 100644 index ca5ef3892b..0000000000 --- a/Code/Legacy/CrySystem/ViewSystem/View.cpp +++ /dev/null @@ -1,546 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - - -#include "CrySystem_precompiled.h" - -#include -#include -#include "View.h" -#include -#include -#include -#include -#include - -namespace LegacyViewSystem -{ - -static ICVar* pCamShakeMult = 0; -static ICVar* pHmdReferencePoint = 0; - -//------------------------------------------------------------------------ -CView::CView(ISystem* pSystem) - : m_pSystem(pSystem) - , m_linkedTo(0) - , m_frameAdditiveAngles(0.0f, 0.0f, 0.0f) - , m_scale(1.0f) - , m_zoomedScale(1.0f) -{ - if (!pCamShakeMult) - { - pCamShakeMult = gEnv->pConsole->GetCVar("c_shakeMult"); - } - if (!pHmdReferencePoint) - { - pHmdReferencePoint = gEnv->pConsole->GetCVar("hmd_reference_point"); - } -} - -//------------------------------------------------------------------------ -CView::~CView() -{ -} - -//----------------------------------------------------------------------- -void CView::Release() -{ - delete this; -} - -//------------------------------------------------------------------------ -void CView::Update([[maybe_unused]] float frameTime, [[maybe_unused]] bool isActive) -{ - AZ_ErrorOnce("CryLegacy", false, "CryLegacy view system no longer available (CView::Update)"); -} - -//----------------------------------------------------------------------- -void CView::ApplyFrameAdditiveAngles(Quat& cameraOrientation) -{ - if ((m_frameAdditiveAngles.x != 0.f) || (m_frameAdditiveAngles.y != 0.f) || (m_frameAdditiveAngles.z != 0.f)) - { - Ang3 cameraAngles(cameraOrientation); - cameraAngles += m_frameAdditiveAngles; - - cameraOrientation.SetRotationXYZ(cameraAngles); - - m_frameAdditiveAngles.Set(0.0f, 0.0f, 0.0f); - } -} - -//------------------------------------------------------------------------ -void CView::SetViewShake(Ang3 shakeAngle, Vec3 shakeShift, float duration, float frequency, float randomness, int shakeID, bool bFlipVec, bool bUpdateOnly, bool bGroundOnly) -{ - SShakeParams params; - params.shakeAngle = shakeAngle; - params.shakeShift = shakeShift; - params.frequency = frequency; - params.randomness = randomness; - params.shakeID = shakeID; - params.bFlipVec = bFlipVec; - params.bUpdateOnly = bUpdateOnly; - params.bGroundOnly = bGroundOnly; - params.fadeInDuration = 0; // - params.fadeOutDuration = duration; // originally it was faded out from start. that is why the values are set this way here, to preserve compatibility. - params.sustainDuration = 0; // - - SetViewShakeEx(params); -} - - -//------------------------------------------------------------------------ -void CView::SetViewShakeEx(const SShakeParams& params) -{ - float shakeMult = GetScale(); - if (shakeMult < 0.001f) - { - return; - } - - int shakes = static_cast(m_shakes.size()); - SShake* pSetShake(NULL); - - for (int i = 0; i < shakes; ++i) - { - SShake* pShake = &m_shakes[i]; - if (pShake->ID == params.shakeID) - { - pSetShake = pShake; - break; - } - } - - if (!pSetShake) - { - m_shakes.push_back(SShake(params.shakeID)); - pSetShake = &m_shakes.back(); - } - - if (pSetShake) - { - // this can be set dynamically - pSetShake->frequency = max(0.00001f, params.frequency); - - // the following are set on a 'new' shake as well - if (params.bUpdateOnly == false) - { - pSetShake->amount = params.shakeAngle * shakeMult; - pSetShake->amountVector = params.shakeShift * shakeMult; - pSetShake->randomness = params.randomness; - pSetShake->doFlip = params.bFlipVec; - pSetShake->groundOnly = params.bGroundOnly; - pSetShake->isSmooth = params.isSmooth; - pSetShake->permanent = params.bPermanent; - pSetShake->fadeInDuration = params.fadeInDuration; - pSetShake->sustainDuration = params.sustainDuration; - pSetShake->fadeOutDuration = params.fadeOutDuration; - pSetShake->timeDone = 0; - pSetShake->updating = true; - pSetShake->interrupted = false; - pSetShake->goalShake = Quat(ZERO); - pSetShake->goalShakeSpeed = Quat(ZERO); - pSetShake->goalShakeVector = Vec3(ZERO); - pSetShake->goalShakeVectorSpeed = Vec3(ZERO); - pSetShake->nextShake = 0.0f; - } - } -} - -//------------------------------------------------------------------------ -void CView::SetScale(const float scale) -{ - CRY_ASSERT_MESSAGE(scale == 1.0f || m_scale == 1.0f, "Attempting to CView::SetScale but has already been set!"); - m_scale = scale; -} - -void CView::SetZoomedScale(const float scale) -{ - CRY_ASSERT_MESSAGE(scale == 1.0f || m_zoomedScale == 1.0f, "Attempting to CView::SetZoomedScale but has already been set!"); - m_zoomedScale = scale; -} - -//------------------------------------------------------------------------ -const float CView::GetScale() -{ - float shakeMult(pCamShakeMult->GetFVal()); - return m_scale * shakeMult * m_zoomedScale; -} - -//------------------------------------------------------------------------ -void CView::ProcessShaking(float frameTime) -{ - m_viewParams.currentShakeQuat.SetIdentity(); - m_viewParams.currentShakeShift.zero(); - m_viewParams.shakingRatio = 0; - m_viewParams.groundOnly = false; - - int shakes = static_cast(m_shakes.size()); - for (int i = 0; i < shakes; ++i) - { - ProcessShake(&m_shakes[i], frameTime); - } -} - -//------------------------------------------------------------------------ -void CView::ProcessShake(SShake* pShake, float frameTime) -{ - if (!pShake->updating) - { - return; - } - - pShake->timeDone += frameTime; - - if (pShake->isSmooth) - { - ProcessShakeSmooth(pShake, frameTime); - } - else - { - ProcessShakeNormal(pShake, frameTime); - } -} - -//------------------------------------------------------------------------ -void CView::ProcessShakeNormal(SShake* pShake, float frameTime) -{ - float endSustain = pShake->fadeInDuration + pShake->sustainDuration; - float totalDuration = endSustain + pShake->fadeOutDuration; - - bool finalDamping = (!pShake->permanent && pShake->timeDone > totalDuration) || (pShake->interrupted && pShake->ratio < 0.05f); - - if (finalDamping) - { - ProcessShakeNormal_FinalDamping(pShake, frameTime); - } - else - { - ProcessShakeNormal_CalcRatio(pShake, frameTime, endSustain); - ProcessShakeNormal_DoShaking(pShake, frameTime); - - //for the global shaking ratio keep the biggest - if (pShake->groundOnly) - { - m_viewParams.groundOnly = true; - } - m_viewParams.shakingRatio = max(m_viewParams.shakingRatio, pShake->ratio); - m_viewParams.currentShakeQuat *= pShake->shakeQuat; - m_viewParams.currentShakeShift += pShake->shakeVector; - } -} - -////////////////////////////////////////////////////////////////////////// -void CView::ProcessShakeSmooth(SShake* pShake, float frameTime) -{ - assert(pShake->timeDone >= 0); - - float endTimeFadeIn = pShake->fadeInDuration; - float endTimeSustain = pShake->sustainDuration + endTimeFadeIn; - float totalTime = endTimeSustain + pShake->fadeOutDuration; - - if (pShake->interrupted && endTimeFadeIn <= pShake->timeDone && pShake->timeDone < endTimeSustain) - { - pShake->timeDone = endTimeSustain; - } - - float damping = 1.f; - if (pShake->timeDone < endTimeFadeIn) - { - damping = pShake->timeDone / endTimeFadeIn; - } - else if (endTimeSustain < pShake->timeDone && pShake->timeDone < totalTime) - { - damping = (totalTime - pShake->timeDone) / (totalTime - endTimeSustain); - } - else if (totalTime <= pShake->timeDone) - { - pShake->shakeQuat.SetIdentity(); - pShake->shakeVector.zero(); - pShake->ratio = 0.0f; - pShake->nextShake = 0.0f; - pShake->flip = false; - pShake->updating = false; - return; - } - - ProcessShakeSmooth_DoShaking(pShake, frameTime); - - if (pShake->groundOnly) - { - m_viewParams.groundOnly = true; - } - pShake->ratio = (3.f - 2.f * damping) * damping * damping; // smooth ration change - m_viewParams.shakingRatio = max(m_viewParams.shakingRatio, pShake->ratio); - m_viewParams.currentShakeQuat *= Quat::CreateSlerp(IDENTITY, pShake->shakeQuat, pShake->ratio); - m_viewParams.currentShakeShift += Vec3::CreateLerp(ZERO, pShake->shakeVector, pShake->ratio); -} - -////////////////////////////////////////////////////////////////////////// -void CView::GetRandomQuat(Quat& quat, SShake* pShake) -{ - quat.SetRotationXYZ(pShake->amount); - float randomAmt(pShake->randomness); - float len(fabs(pShake->amount.x) + fabs(pShake->amount.y) + fabs(pShake->amount.z)); - len /= 3.f; - float r = len * randomAmt; - quat *= Quat::CreateRotationXYZ(Ang3(cry_random(-r, r), cry_random(-r, r), cry_random(-r, r))); -} - -////////////////////////////////////////////////////////////////////////// -void CView::GetRandomVector(Vec3& vec, SShake* pShake) -{ - vec = pShake->amountVector; - float randomAmt(pShake->randomness); - float len = fabs(pShake->amountVector.x) + fabs(pShake->amountVector.y) + fabs(pShake->amountVector.z); - len /= 3.f; - float r = len * randomAmt; - vec += Vec3(cry_random(-r, r), cry_random(-r, r), cry_random(-r, r)); -} - -////////////////////////////////////////////////////////////////////////// -void CView::CubeInterpolateQuat(float t, SShake* pShake) -{ - Quat p0 = pShake->startShake; - Quat p1 = pShake->goalShake; - Quat v0 = pShake->startShakeSpeed * 0.5f; - Quat v1 = pShake->goalShakeSpeed * 0.5f; - - pShake->shakeQuat = (((p0 * 2.f + p1 * -2.f + v0 + v1) * t - + (p0 * -3.f + p1 * 3.f + v0 * -2.f - v1)) * t - + (v0)) * t - + p0; - - pShake->shakeQuat.Normalize(); -} - -////////////////////////////////////////////////////////////////////////// -void CView::CubeInterpolateVector(float t, SShake* pShake) -{ - Vec3 p0 = pShake->startShakeVector; - Vec3 p1 = pShake->goalShakeVector; - Vec3 v0 = pShake->startShakeVectorSpeed * 0.8f; - Vec3 v1 = pShake->goalShakeVectorSpeed * 0.8f; - - pShake->shakeVector = (((p0 * 2.f + p1 * -2.f + v0 + v1) * t - + (p0 * -3.f + p1 * 3.f + v0 * -2.f - v1)) * t - + (v0)) * t - + p0; -} - -////////////////////////////////////////////////////////////////////////// -void CView::ProcessShakeSmooth_DoShaking(SShake* pShake, float frameTime) -{ - if (pShake->nextShake <= 0.0f) - { - pShake->nextShake = pShake->frequency; - - pShake->startShake = pShake->goalShake; - pShake->startShakeSpeed = pShake->goalShakeSpeed; - pShake->startShakeVector = pShake->goalShakeVector; - pShake->startShakeVectorSpeed = pShake->goalShakeVectorSpeed; - - GetRandomQuat(pShake->goalShake, pShake); - GetRandomQuat(pShake->goalShakeSpeed, pShake); - GetRandomVector(pShake->goalShakeVector, pShake); - GetRandomVector(pShake->goalShakeVectorSpeed, pShake); - - if (pShake->flip) - { - pShake->goalShake.Invert(); - pShake->goalShakeSpeed.Invert(); - pShake->goalShakeVector = -pShake->goalShakeVector; - pShake->goalShakeVectorSpeed = -pShake->goalShakeVectorSpeed; - } - - if (pShake->doFlip) - { - pShake->flip = !pShake->flip; - } - } - - pShake->nextShake -= frameTime; - - float t = (pShake->frequency - pShake->nextShake) / pShake->frequency; - CubeInterpolateQuat(t, pShake); - CubeInterpolateVector(t, pShake); -} - -////////////////////////////////////////////////////////////////////////// -void CView::ProcessShakeNormal_FinalDamping(SShake* pShake, float frameTime) -{ - pShake->shakeQuat = Quat::CreateSlerp(pShake->shakeQuat, IDENTITY, frameTime * 5.0f); - m_viewParams.currentShakeQuat *= pShake->shakeQuat; - - pShake->shakeVector = Vec3::CreateLerp(pShake->shakeVector, ZERO, frameTime * 5.0f); - m_viewParams.currentShakeShift += pShake->shakeVector; - - float svlen2(pShake->shakeVector.len2()); - bool quatIsIdentity(Quat::IsEquivalent(IDENTITY, pShake->shakeQuat, 0.0001f)); - - if (quatIsIdentity && svlen2 < 0.01f) - { - pShake->shakeQuat.SetIdentity(); - pShake->shakeVector.zero(); - - pShake->ratio = 0.0f; - pShake->nextShake = 0.0f; - pShake->flip = false; - - pShake->updating = false; - } -} - - -// "ratio" is the amplitude of the shaking -void CView::ProcessShakeNormal_CalcRatio(SShake* pShake, float frameTime, float endSustain) -{ - const float FADEOUT_TIME_WHEN_INTERRUPTED = 0.5f; - - if (pShake->interrupted) - { - pShake->ratio = max(0.f, pShake->ratio - (frameTime / FADEOUT_TIME_WHEN_INTERRUPTED)); // fadeout after interrupted - } - else - if (pShake->timeDone >= endSustain && pShake->fadeOutDuration > 0) - { - float timeFading = pShake->timeDone - endSustain; - pShake->ratio = clamp_tpl(1.f - timeFading / pShake->fadeOutDuration, 0.f, 1.f); // fadeOut - } - else - if (pShake->timeDone >= pShake->fadeInDuration) - { - pShake->ratio = 1.f; // sustain - } - else - { - pShake->ratio = min(1.f, pShake->timeDone / pShake->fadeInDuration); // fadeIn - } - - if (pShake->permanent && pShake->timeDone >= pShake->fadeInDuration && !pShake->interrupted) - { - pShake->ratio = 1.f; // permanent standing - } -} - -////////////////////////////////////////////////////////////////////////// -void CView::ProcessShakeNormal_DoShaking(SShake* pShake, float frameTime) -{ - float t; - if (pShake->nextShake <= 0.0f) - { - //angular - pShake->goalShake.SetRotationXYZ(pShake->amount); - if (pShake->flip) - { - pShake->goalShake.Invert(); - } - - //translational - pShake->goalShakeVector = pShake->amountVector; - if (pShake->flip) - { - pShake->goalShakeVector = -pShake->goalShakeVector; - } - - if (pShake->doFlip) - { - pShake->flip = !pShake->flip; - } - - //randomize it a little - float randomAmt(pShake->randomness); - float len(fabs(pShake->amount.x) + fabs(pShake->amount.y) + fabs(pShake->amount.z)); - len /= 3.0f; - float r = len * randomAmt; - pShake->goalShake *= Quat::CreateRotationXYZ(Ang3(cry_random(-r, r), cry_random(-r, r), cry_random(-r, r))); - - //translational randomization - len = fabs(pShake->amountVector.x) + fabs(pShake->amountVector.y) + fabs(pShake->amountVector.z); - len /= 3.0f; - r = len * randomAmt; - pShake->goalShakeVector += Vec3(cry_random(-r, r), cry_random(-r, r), cry_random(-r, r)); - - //damp & bounce it in a non linear fashion - t = 1.0f - (pShake->ratio * pShake->ratio); - pShake->goalShake = Quat::CreateSlerp(pShake->goalShake, IDENTITY, t); - pShake->goalShakeVector = Vec3::CreateLerp(pShake->goalShakeVector, ZERO, t); - - pShake->nextShake = pShake->frequency; - } - - pShake->nextShake = max(0.0f, pShake->nextShake - frameTime); - - t = min(1.0f, frameTime * (1.0f / pShake->frequency)); - pShake->shakeQuat = Quat::CreateSlerp(pShake->shakeQuat, pShake->goalShake, t); - pShake->shakeQuat.Normalize(); - pShake->shakeVector = Vec3::CreateLerp(pShake->shakeVector, pShake->goalShakeVector, t); -} - - -//------------------------------------------------------------------------ -void CView::StopShake(int shakeID) -{ - uint32 num = static_cast(m_shakes.size()); - for (uint32 i = 0; i < num; ++i) - { - if (m_shakes[i].ID == shakeID && m_shakes[i].updating) - { - m_shakes[i].interrupted = true; - } - } -} - - -//------------------------------------------------------------------------ -void CView::ResetShaking() -{ - // disable shakes - std::vector::iterator iter = m_shakes.begin(); - std::vector::iterator iterEnd = m_shakes.end(); - while (iter != iterEnd) - { - SShake& shake = *iter; - shake.updating = false; - shake.timeDone = 0; - ++iter; - } -} - -//------------------------------------------------------------------------ -void CView::LinkTo(AZ::Entity* follow) -{ - CRY_ASSERT(follow); - m_azEntity = follow; - m_linkedTo = follow->GetId(); - m_viewParams.targetPos = Vec3();// This should be quickly overwritten by the camera's acutal position from its matrix -} - -//------------------------------------------------------------------------ -void CView::Unlink() -{ - m_azEntity = nullptr; - m_linkedTo.SetInvalid(); - m_viewParams.targetPos = Vec3(); -} - -//------------------------------------------------------------------------ -void CView::SetFrameAdditiveCameraAngles(const Ang3& addFrameAngles) -{ - m_frameAdditiveAngles = addFrameAngles; -} - -void CView::PostSerialize() -{ -} - -////////////////////////////////////////////////////////////////////////// -void CView::SetActive([[maybe_unused]] bool const bActive) -{ -} - -} // namespace LegacyViewSystem diff --git a/Code/Legacy/CrySystem/ViewSystem/View.h b/Code/Legacy/CrySystem/ViewSystem/View.h deleted file mode 100644 index 001bf694fd..0000000000 --- a/Code/Legacy/CrySystem/ViewSystem/View.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - - -// Description : View System interfaces. - -# pragma once - -#include "IViewSystem.h" -#include - -class CGameObject; -struct ISystem; - -namespace LegacyViewSystem -{ - -class CView - : public IView -{ -public: - - CView(ISystem* pSystem); - ~CView() override; - - //shaking - struct SShake - { - bool updating; - bool flip; - bool doFlip; - bool groundOnly; - bool permanent; - bool interrupted; // when forcefully stopped - bool isSmooth; - - int ID; - - float nextShake; - float timeDone; - float sustainDuration; - float fadeInDuration; - float fadeOutDuration; - - float frequency; - float ratio; - - float randomness; - - Quat startShake; - Quat startShakeSpeed; - Vec3 startShakeVector; - Vec3 startShakeVectorSpeed; - - Quat goalShake; - Quat goalShakeSpeed; - Vec3 goalShakeVector; - Vec3 goalShakeVectorSpeed; - - Ang3 amount; - Vec3 amountVector; - - Quat shakeQuat; - Vec3 shakeVector; - - SShake(int shakeID) - { - memset(this, 0, sizeof(SShake)); - - startShake.SetIdentity(); - startShakeSpeed.SetIdentity(); - goalShake.SetIdentity(); - shakeQuat.SetIdentity(); - - randomness = 0.5f; - - ID = shakeID; - } - }; - - - // IView - void Release() override; - void Update(float frameTime, bool isActive) override; - virtual void ProcessShaking(float frameTime); - virtual void ProcessShake(SShake* pShake, float frameTime); - void ResetShaking() override; - void ResetBlending() override { m_viewParams.ResetBlending(); } - void LinkTo(AZ::Entity* follow) override; - void Unlink() override; - AZ::EntityId GetLinkedId() override {return m_linkedTo; }; - void SetCurrentParams(SViewParams& params) override { m_viewParams = params; }; - const SViewParams* GetCurrentParams() override {return &m_viewParams; } - void SetViewShake(Ang3 shakeAngle, Vec3 shakeShift, float duration, float frequency, float randomness, int shakeID, bool bFlipVec = true, bool bUpdateOnly = false, bool bGroundOnly = false) override; - void SetViewShakeEx(const SShakeParams& params) override; - void StopShake(int shakeID) override; - void SetFrameAdditiveCameraAngles(const Ang3& addFrameAngles) override; - void SetScale(const float scale) override; - void SetZoomedScale(const float scale) override; - void SetActive(const bool bActive) override; - // ~IView - - void PostSerialize() override; - CCamera& GetCamera() override { return m_camera; } - const CCamera& GetCamera() const override { return m_camera; } - -protected: - - void ProcessShakeNormal(SShake* pShake, float frameTime); - void ProcessShakeNormal_FinalDamping(SShake* pShake, float frameTime); - void ProcessShakeNormal_CalcRatio(SShake* pShake, float frameTime, float endSustain); - void ProcessShakeNormal_DoShaking(SShake* pShake, float frameTime); - - void ProcessShakeSmooth(SShake* pShake, float frameTime); - void ProcessShakeSmooth_DoShaking(SShake* pShake, float frameTime); - - void ApplyFrameAdditiveAngles(Quat& cameraOrientation); - - const float GetScale(); - -private: - - void GetRandomQuat(Quat& quat, SShake* pShake); - void GetRandomVector(Vec3& vec3, SShake* pShake); - void CubeInterpolateQuat(float t, SShake* pShake); - void CubeInterpolateVector(float t, SShake* pShake); - -protected: - - bool m_active; - AZ::EntityId m_linkedTo; - AZ::Entity* m_azEntity = nullptr; - - SViewParams m_viewParams; - CCamera m_camera; - - ISystem* m_pSystem; - - std::vector m_shakes; - - Ang3 m_frameAdditiveAngles; // Used mainly for cinematics, where the game can slightly override camera orientation - - float m_scale; - float m_zoomedScale; -}; - -} // namespace LegacyViewSystem diff --git a/Code/Legacy/CrySystem/ViewSystem/ViewSystem.cpp b/Code/Legacy/CrySystem/ViewSystem/ViewSystem.cpp deleted file mode 100644 index d7e5c081c0..0000000000 --- a/Code/Legacy/CrySystem/ViewSystem/ViewSystem.cpp +++ /dev/null @@ -1,656 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - - -#include "CrySystem_precompiled.h" - -#include - -#include -#include -#include "ViewSystem.h" -#include "PNoise3.h" -#include "DebugCamera.h" -#include - -#include - -#define VS_CALL_LISTENERS(func) \ - { \ - size_t count = m_listeners.size(); \ - if (count > 0) \ - { \ - const size_t memSize = count * sizeof(IViewSystemListener*); \ - IViewSystemListener* *pArray = (IViewSystemListener**) alloca(memSize); \ - memcpy(pArray, &*m_listeners.begin(), memSize); \ - while (count--) \ - { \ - (*pArray)->func; ++pArray; \ - } \ - } \ - } - -namespace LegacyViewSystem -{ - -void ToggleDebugCamera([[maybe_unused]] IConsoleCmdArgs* pArgs) -{ -#if !defined(_RELEASE) - if (!gEnv->IsDedicated()) - { - DebugCamera* debugCamera = CViewSystem::s_debugCamera; - if (debugCamera) - { - if (!debugCamera->IsEnabled()) - { - debugCamera->OnEnable(); - } - else - { - debugCamera->OnNextMode(); - } - } - } -#endif -} - -void ToggleDebugCameraInvertY([[maybe_unused]] IConsoleCmdArgs* pArgs) -{ -#if !defined(_RELEASE) - if (!gEnv->IsDedicated()) - { - DebugCamera* debugCamera = CViewSystem::s_debugCamera; - if (debugCamera) - { - debugCamera->OnInvertY(); - } - } -#endif -} - -void DebugCameraMove([[maybe_unused]] IConsoleCmdArgs* pArgs) -{ -#if !defined(_RELEASE) - if (!gEnv->IsDedicated()) - { - if (pArgs->GetArgCount() != 4) - { - CryLogAlways("debugCameraMove requires 3 args, not %d.", pArgs->GetArgCount() - 1); - return; - } - - DebugCamera* debugCamera = CViewSystem::s_debugCamera; - if (debugCamera && debugCamera->IsFree()) - { - Vec3::value_type x = azlossy_cast(atof(pArgs->GetArg(1))); - Vec3::value_type y = azlossy_cast(atof(pArgs->GetArg(2))); - Vec3::value_type z = azlossy_cast(atof(pArgs->GetArg(3))); - Vec3 newPos(x, y, z); - debugCamera->MovePosition(newPos); - } - } -#endif -} - -DebugCamera* CViewSystem::s_debugCamera = nullptr; - -//------------------------------------------------------------------------ -CViewSystem::CViewSystem(ISystem* pSystem) - : m_pSystem(pSystem) - , m_activeViewId(0) - , m_nextViewIdToAssign(1000) - , m_preSequenceViewId(0) - , m_cutsceneViewId(0) - , m_cutsceneCount(0) - , m_bOverridenCameraRotation(false) - , m_bActiveViewFromSequence(false) - , m_fBlendInPosSpeed(0.0f) - , m_fBlendInRotSpeed(0.0f) - , m_bPerformBlendOut(false) - , m_useDeferredViewSystemUpdate(false) - , m_bControlsAudioListeners(true) -{ -#if !defined(_RELEASE) - if (!gEnv->IsDedicated()) - { - if (!s_debugCamera) - { - s_debugCamera = new DebugCamera; - } - - REGISTER_COMMAND("debugCameraToggle", ToggleDebugCamera, VF_DEV_ONLY, "Toggle the debug camera.\n"); - REGISTER_COMMAND("debugCameraInvertY", ToggleDebugCameraInvertY, VF_DEV_ONLY, "Toggle debug camera Y-axis inversion.\n"); - REGISTER_COMMAND("debugCameraMove", DebugCameraMove, VF_DEV_ONLY, "Move the debug camera the specified distance (x y z).\n"); - gEnv->pConsole->CreateKeyBind("ctrl_keyboard_key_punctuation_backslash", "debugCameraToggle"); - gEnv->pConsole->CreateKeyBind("alt_keyboard_key_punctuation_backslash", "debugCameraInvertY"); - } -#endif - - REGISTER_CVAR2("cl_camera_noise", &m_fCameraNoise, -1, 0, - "Adds hand-held like camera noise to the camera view. \n The higher the value, the higher the noise.\n A value <= 0 disables it."); - REGISTER_CVAR2("cl_camera_noise_freq", &m_fCameraNoiseFrequency, 2.5326173f, 0, - "Defines camera noise frequency for the camera view. \n The higher the value, the higher the noise."); - - REGISTER_CVAR2("cl_ViewSystemDebug", &m_nViewSystemDebug, 0, VF_CHEAT, - "Sets Debug information of the ViewSystem."); - - REGISTER_CVAR2("cl_DefaultNearPlane", &m_fDefaultCameraNearZ, DEFAULT_NEAR, VF_CHEAT, - "The default camera near plane. "); - - //Register as level system listener - if (m_pSystem->GetILevelSystem()) - { - m_pSystem->GetILevelSystem()->AddListener(this); - } - - Camera::CameraSystemRequestBus::Handler::BusConnect(); -} - -//------------------------------------------------------------------------ -CViewSystem::~CViewSystem() -{ - Camera::CameraSystemRequestBus::Handler::BusDisconnect(); - - ClearAllViews(); - - IConsole* pConsole = gEnv->pConsole; - CRY_ASSERT(pConsole); - pConsole->UnregisterVariable("cl_camera_noise", true); - pConsole->UnregisterVariable("cl_camera_noise_freq", true); - pConsole->UnregisterVariable("cl_ViewSystemDebug", true); - pConsole->UnregisterVariable("cl_DefaultNearPlane", true); - - //Remove as level system listener - if (m_pSystem->GetILevelSystem()) - { - m_pSystem->GetILevelSystem()->RemoveListener(this); - } - -#if !defined(_RELEASE) - if (!gEnv->IsDedicated()) - { - UNREGISTER_COMMAND("debugCameraToggle"); - UNREGISTER_COMMAND("debugCameraInvertY"); - UNREGISTER_COMMAND("debugCameraMove"); - - if (s_debugCamera) - { - delete s_debugCamera; - s_debugCamera = nullptr; - } - } -#endif -} - -//------------------------------------------------------------------------ -void CViewSystem::Update(float frameTime) -{ - if (gEnv->IsDedicated()) - { - return; - } - - if (s_debugCamera) - { - s_debugCamera->Update(); - } - - CView* const pActiveView = static_cast(GetActiveView()); - - TViewMap::const_iterator Iter(m_views.begin()); - TViewMap::const_iterator const IterEnd(m_views.end()); - - for (; Iter != IterEnd; ++Iter) - { - IView* const pView = Iter->second; - - bool const bIsActive = (pView == pActiveView); - - pView->Update(frameTime, bIsActive); - - if (bIsActive) - { - CCamera& rCamera = pView->GetCamera(); - if (const SViewParams* currentParams = pView->GetCurrentParams()) - { - SViewParams copyCurrentParams = *currentParams; - rCamera.SetJustActivated(copyCurrentParams.justActivated); - - copyCurrentParams.justActivated = false; - pView->SetCurrentParams(copyCurrentParams); - } - - if (m_bOverridenCameraRotation) - { - // When camera rotation is overridden. - Vec3 pos = rCamera.GetMatrix().GetTranslation(); - Matrix34 camTM(m_overridenCameraRotation); - camTM.SetTranslation(pos); - rCamera.SetMatrix(camTM); - } - else - { - // Normal setting of the camera - - if (m_fCameraNoise > 0) - { - Matrix33 m = Matrix33(rCamera.GetMatrix()); - m.OrthonormalizeFast(); - Ang3 aAng1 = Ang3::GetAnglesXYZ(m); - //Ang3 aAng2 = RAD2DEG(aAng1); - - Matrix34 camTM = rCamera.GetMatrix(); - Vec3 pos = camTM.GetTranslation(); - camTM.SetIdentity(); - - const float fScale = 0.1f; - CPNoise3* pNoise = m_pSystem->GetNoiseGen(); - float fRes = pNoise->Noise1D(gEnv->pTimer->GetCurrTime() * m_fCameraNoiseFrequency); - aAng1.x += fRes * m_fCameraNoise * fScale; - pos.z -= fRes * m_fCameraNoise * fScale; - fRes = pNoise->Noise1D(17 + gEnv->pTimer->GetCurrTime() * m_fCameraNoiseFrequency); - aAng1.y -= fRes * m_fCameraNoise * fScale; - - //aAng1.z+=fRes*0.025f; // left / right movement should be much less visible - - camTM.SetRotationXYZ(aAng1); - camTM.SetTranslation(pos); - rCamera.SetMatrix(camTM); - } - } - - AZ_ErrorOnce("CryLegacy", false, "CryLegacy view system no longer available (CViewSystem::Update)"); - } - } - - if (s_debugCamera) - { - s_debugCamera->PostUpdate(); - } - - // Display debug info on screen - if (m_nViewSystemDebug) - { - DebugDraw(); - } -} - -//------------------------------------------------------------------------ -IView* CViewSystem::CreateView() -{ - CView* newView = new CView(m_pSystem); - - if (newView) - { - AddView(newView); - } - - return newView; -} - -unsigned int CViewSystem::AddView(IView* pView) -{ - assert(pView); - - m_views.insert(TViewMap::value_type(m_nextViewIdToAssign, pView)); - return m_nextViewIdToAssign++; -} - -void CViewSystem::RemoveView(IView* pView) -{ - RemoveViewById(GetViewId(pView)); -} - -void CViewSystem::RemoveView(unsigned int viewId) -{ - RemoveViewById(viewId); -} - -void CViewSystem::RemoveViewById(unsigned int viewId) -{ - TViewMap::iterator iter = m_views.find(viewId); - - if (iter != m_views.end()) - { - if (viewId == m_activeViewId) - { - m_activeViewId = 0; - } - if (viewId == m_preSequenceViewId) - { - m_preSequenceViewId = 0; - } - SAFE_RELEASE(iter->second); - m_views.erase(iter); - } -} - -//------------------------------------------------------------------------ -void CViewSystem::SetActiveView(IView* pView) -{ - if (pView != NULL) - { - IView* const pPrevView = GetView(m_activeViewId); - - if (pPrevView != pView) - { - if (pPrevView != NULL) - { - pPrevView->SetActive(false); - } - - pView->SetActive(true); - m_activeViewId = GetViewId(pView); - } - } - else - { - m_activeViewId = ~0u; - } - - m_bActiveViewFromSequence = false; -} - -//------------------------------------------------------------------------ -void CViewSystem::SetActiveView(unsigned int viewId) -{ - IView* const pPrevView = GetView(m_activeViewId); - - if (pPrevView != NULL) - { - pPrevView->SetActive(false); - } - - IView* const pView = GetView(viewId); - - if (pView != NULL) - { - pView->SetActive(true); - m_activeViewId = viewId; - m_bActiveViewFromSequence = false; - } -} - -//------------------------------------------------------------------------ -IView* CViewSystem::GetView(unsigned int viewId) -{ - TViewMap::iterator it = m_views.find(viewId); - - if (it != m_views.end()) - { - return it->second; - } - - return NULL; -} - -//------------------------------------------------------------------------ -IView* CViewSystem::GetActiveView() -{ - return GetView(m_activeViewId); -} - -//------------------------------------------------------------------------ -unsigned int CViewSystem::GetViewId(IView* pView) -{ - for (TViewMap::iterator it = m_views.begin(); it != m_views.end(); ++it) - { - IView* tView = it->second; - - if (tView == pView) - { - return it->first; - } - } - - return 0; -} - -//------------------------------------------------------------------------ -unsigned int CViewSystem::GetActiveViewId() -{ - // cutscene can override the games id of the active view - if (m_cutsceneCount && m_cutsceneViewId) - { - return m_cutsceneViewId; - } - return m_activeViewId; -} - -//------------------------------------------------------------------------ -IView* CViewSystem::GetViewByEntityId(const AZ::EntityId& id, bool forceCreate) -{ - for (TViewMap::iterator it = m_views.begin(); it != m_views.end(); ++it) - { - IView* tView = it->second; - - if (tView && tView->GetLinkedId() == id) - { - return tView; - } - } - - if (forceCreate) - { - // Component Camera - AZ::Entity* entity = nullptr; - AZ::ComponentApplicationBus::BroadcastResult(entity, &AZ::ComponentApplicationBus::Events::FindEntity, id); - if (entity) - { - if (IView* pNew = CreateView()) - { - pNew->LinkTo(entity); - return pNew; - } - } - } - - return nullptr; -} - -//------------------------------------------------------------------------ -void CViewSystem::SetActiveCamera(const SCameraParams& params) -{ - IView* pView = NULL; - - if (params.cameraEntityId.IsValid()) - { - pView = GetViewByEntityId(params.cameraEntityId, true); - if (pView) - { - SViewParams viewParams = *pView->GetCurrentParams(); - viewParams.fov = params.fov; - viewParams.nearplane = params.nearZ; - - if (m_bActiveViewFromSequence == false && m_preSequenceViewId == 0) - { - m_preSequenceViewId = m_activeViewId; - IView* pPrevView = GetView(m_activeViewId); - if (pPrevView && m_fBlendInPosSpeed > 0.0f && m_fBlendInRotSpeed > 0.0f) - { - viewParams.blendPosSpeed = m_fBlendInPosSpeed; - viewParams.blendRotSpeed = m_fBlendInRotSpeed; - viewParams.BlendFrom(*pPrevView->GetCurrentParams()); - } - } - - if (m_activeViewId != GetViewId(pView) && params.justActivated) - { - viewParams.justActivated = true; - } - - pView->SetCurrentParams(viewParams); - // make this one the active view - SetActiveView(pView); - m_bActiveViewFromSequence = true; - } - } - else - { - if (m_preSequenceViewId != 0) - { - // Restore m_preSequenceViewId view - - IView* pActiveView = GetView(m_activeViewId); - IView* pNewView = GetView(m_preSequenceViewId); - if (pActiveView && pNewView && m_bPerformBlendOut) - { - SViewParams activeViewParams = *pActiveView->GetCurrentParams(); - SViewParams newViewParams = *pNewView->GetCurrentParams(); - newViewParams.BlendFrom(activeViewParams); - newViewParams.blendPosSpeed = activeViewParams.blendPosSpeed; - newViewParams.blendRotSpeed = activeViewParams.blendRotSpeed; - - if (m_activeViewId != m_preSequenceViewId && params.justActivated) - { - newViewParams.justActivated = true; - } - - pNewView->SetCurrentParams(newViewParams); - SetActiveView(m_preSequenceViewId); - } - else if (pActiveView && m_activeViewId != m_preSequenceViewId && params.justActivated) - { - SViewParams activeViewParams = *pActiveView->GetCurrentParams(); - activeViewParams.justActivated = true; - - if (pNewView) - { - pNewView->SetCurrentParams(activeViewParams); - SetActiveView(m_preSequenceViewId); - } - } - - m_preSequenceViewId = 0; - m_bActiveViewFromSequence = false; - } - } - m_cutsceneViewId = GetViewId(pView); - - VS_CALL_LISTENERS(OnCameraChange(params)); -} - -//------------------------------------------------------------------------ -void CViewSystem::BeginCutScene(IAnimSequence* pSeq, [[maybe_unused]] unsigned long dwFlags, bool bResetFX) -{ - m_cutsceneCount++; - - VS_CALL_LISTENERS(OnBeginCutScene(pSeq, bResetFX)); -} - -//------------------------------------------------------------------------ -void CViewSystem::EndCutScene(IAnimSequence* pSeq, [[maybe_unused]] unsigned long dwFlags) -{ - m_cutsceneCount -= (m_cutsceneCount > 0); - - ClearCutsceneViews(); - - VS_CALL_LISTENERS(OnEndCutScene(pSeq)); -} - -void CViewSystem::SendGlobalEvent([[maybe_unused]] const char* pszEvent) -{ - // TODO: broadcast to script system -} - -////////////////////////////////////////////////////////////////////////// -void CViewSystem::SetOverrideCameraRotation(bool bOverride, Quat rotation) -{ - m_bOverridenCameraRotation = bOverride; - m_overridenCameraRotation = rotation; -} - -////////////////////////////////////////////////////////////////// -void CViewSystem::OnLoadingStart([[maybe_unused]] const char* levelName) -{ - //If the level is being restarted (IsSerializingFile() == 1) - //views should not be cleared, because the main view (player one) won't be recreated in this case - //Views will only be cleared when loading a new map, or loading a saved game (IsSerizlizingFile() == 2) - bool shouldClearViews = gEnv->pSystem ? (gEnv->pSystem->IsSerializingFile() != 1) : false; - - if (shouldClearViews) - { - ClearAllViews(); - } -} - -///////////////////////////////////////////////////////////////////// -void CViewSystem::OnUnloadComplete([[maybe_unused]] const char* levelName) -{ - bool shouldClearViews = gEnv->pSystem ? (gEnv->pSystem->IsSerializingFile() != 1) : false; - - if (shouldClearViews) - { - ClearAllViews(); - } - - assert(m_listeners.empty()); - stl::free_container(m_listeners); -} - -///////////////////////////////////////////////////////////////////// -void CViewSystem::ClearCutsceneViews() -{ - //First switch to previous camera if available - //In practice, the camera should be already restored before reaching this point, but just in case. - if (m_preSequenceViewId != 0) - { - SCameraParams camParams; - camParams.cameraEntityId.SetInvalid(); //Setting to invalid will try to switch to previous camera - camParams.fov = 60.0f; - camParams.nearZ = DEFAULT_NEAR; - camParams.justActivated = true; - SetActiveCamera(camParams); - } -} - -/////////////////////////////////////////// -void CViewSystem::ClearAllViews() -{ - TViewMap::iterator end = m_views.end(); - for (TViewMap::iterator it = m_views.begin(); it != end; ++it) - { - SAFE_RELEASE(it->second); - } - stl::free_container(m_views); - m_preSequenceViewId = 0; - m_activeViewId = 0; -} - -//////////////////////////////////////////////////////////////////// -void CViewSystem::DebugDraw() -{ -} - -////////////////////////////////////////////////////////////////////////// -void CViewSystem::PostSerialize() -{ - TViewMap::iterator iter = m_views.begin(); - TViewMap::iterator iterEnd = m_views.end(); - while (iter != iterEnd) - { - iter->second->PostSerialize(); - ++iter; - } -} - -/////////////////////////////////////////////////////////////////////////// -void CViewSystem::SetControlAudioListeners(bool bActive) -{ - m_bControlsAudioListeners = bActive; - - TViewMap::const_iterator Iter(m_views.begin()); - TViewMap::const_iterator const IterEnd(m_views.end()); - - for (; Iter != IterEnd; ++Iter) - { - Iter->second->SetActive(bActive); - } -} - -} // namespace LegacyViewSystem diff --git a/Code/Legacy/CrySystem/ViewSystem/ViewSystem.h b/Code/Legacy/CrySystem/ViewSystem/ViewSystem.h deleted file mode 100644 index 80d1faed15..0000000000 --- a/Code/Legacy/CrySystem/ViewSystem/ViewSystem.h +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - - -// Description : View System interfaces. - -#pragma once - -#include "View.h" -#include "IMovieSystem.h" -#include -#include - -namespace LegacyViewSystem -{ - -class DebugCamera; - -class CViewSystem - : public IViewSystem - , public IMovieUser - , public ILevelSystemListener - , public Camera::CameraSystemRequestBus::Handler -{ -private: - - using TViewMap = std::map; - using TViewIdVector = std::vector; - -public: - - //IViewSystem - IView* CreateView() override; - unsigned int AddView(IView* pView) override; - void RemoveView(IView* pView) override; - void RemoveView(unsigned int viewId) override; - - void SetActiveView(IView* pView) override; - void SetActiveView(unsigned int viewId) override; - - //CameraSystemRequestBus - AZ::EntityId GetActiveCamera() override { return m_activeViewId ? GetActiveView()->GetLinkedId() : AZ::EntityId(); } - - //utility functions - IView* GetView(unsigned int viewId) override; - IView* GetActiveView() override; - - unsigned int GetViewId(IView* pView) override; - unsigned int GetActiveViewId() override; - - void PostSerialize() override; - - IView* GetViewByEntityId(const AZ::EntityId& id, bool forceCreate) override; - - float GetDefaultZNear() override { return m_fDefaultCameraNearZ; }; - void SetBlendParams(float fBlendPosSpeed, float fBlendRotSpeed, bool performBlendOut) override { m_fBlendInPosSpeed = fBlendPosSpeed; m_fBlendInRotSpeed = fBlendRotSpeed; m_bPerformBlendOut = performBlendOut; }; - void SetOverrideCameraRotation(bool bOverride, Quat rotation) override; - bool IsPlayingCutScene() const override - { - return m_cutsceneCount > 0; - } - void SetDeferredViewSystemUpdate(bool const bDeferred) override{ m_useDeferredViewSystemUpdate = bDeferred; } - bool UseDeferredViewSystemUpdate() const override { return m_useDeferredViewSystemUpdate; } - void SetControlAudioListeners(bool const bActive) override; - //~IViewSystem - - //IMovieUser - void SetActiveCamera(const SCameraParams& Params) override; - void BeginCutScene(IAnimSequence* pSeq, unsigned long dwFlags, bool bResetFX) override; - void EndCutScene(IAnimSequence* pSeq, unsigned long dwFlags) override; - void SendGlobalEvent(const char* pszEvent) override; - //~IMovieUser - - // ILevelSystemListener - void OnLevelNotFound([[maybe_unused]] const char* levelName) override {}; - void OnLoadingStart([[maybe_unused]] const char* levelName) override; - void OnLoadingComplete([[maybe_unused]] const char* levelName) override{}; - void OnLoadingError([[maybe_unused]] const char* levelName, [[maybe_unused]] const char* error) override{}; - void OnLoadingProgress([[maybe_unused]] const char* levelName, [[maybe_unused]] int progressAmount) override{}; - void OnUnloadComplete([[maybe_unused]] const char* levelName) override; - //~ILevelSystemListener - - CViewSystem(ISystem* pSystem); - ~CViewSystem(); - - void Release() override { delete this; }; - void Update(float frameTime) override; - - void ForceUpdate(float elapsed) override { Update(elapsed); } - - //void RegisterViewClass(const char *name, IView *(*func)()); - - bool AddListener(IViewSystemListener* pListener) override - { - return stl::push_back_unique(m_listeners, pListener); - } - - bool RemoveListener(IViewSystemListener* pListener) override - { - return stl::find_and_erase(m_listeners, pListener); - } - - void ClearAllViews(); - -private: - - void RemoveViewById(unsigned int viewId); - void ClearCutsceneViews(); - void DebugDraw(); - - ISystem* m_pSystem; - - //TViewClassMap m_viewClasses; - TViewMap m_views; - - // Listeners - std::vector m_listeners; - - unsigned int m_activeViewId; - unsigned int m_nextViewIdToAssign; // next id which will be assigned - unsigned int m_preSequenceViewId; // viewId before a movie cam dropped in - - unsigned int m_cutsceneViewId; - unsigned int m_cutsceneCount; - - bool m_bActiveViewFromSequence; - - bool m_bOverridenCameraRotation; - Quat m_overridenCameraRotation; - float m_fCameraNoise; - float m_fCameraNoiseFrequency; - - float m_fDefaultCameraNearZ; - float m_fBlendInPosSpeed; - float m_fBlendInRotSpeed; - bool m_bPerformBlendOut; - int m_nViewSystemDebug; - - bool m_useDeferredViewSystemUpdate; - bool m_bControlsAudioListeners; - -public: - static DebugCamera* s_debugCamera; -}; - -} // namespace LegacyViewSystem diff --git a/Code/Legacy/CrySystem/crysystem_files.cmake b/Code/Legacy/CrySystem/crysystem_files.cmake index fc923705f2..dcf08d5408 100644 --- a/Code/Legacy/CrySystem/crysystem_files.cmake +++ b/Code/Legacy/CrySystem/crysystem_files.cmake @@ -59,11 +59,5 @@ set(FILES LevelSystem/LevelSystem.h LevelSystem/SpawnableLevelSystem.cpp LevelSystem/SpawnableLevelSystem.h - ViewSystem/DebugCamera.cpp - ViewSystem/DebugCamera.h - ViewSystem/View.cpp - ViewSystem/View.h - ViewSystem/ViewSystem.cpp - ViewSystem/ViewSystem.h WindowsErrorReporting.cpp ) diff --git a/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYAssetExplorer.cpp b/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYAssetExplorer.cpp index 055537a8bb..6a4d4bc6f9 100644 --- a/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYAssetExplorer.cpp +++ b/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYAssetExplorer.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include "ImGuiColorDefines.h" diff --git a/Gems/LyShine/Code/Source/Animation/AzEntityNode.cpp b/Gems/LyShine/Code/Source/Animation/AzEntityNode.cpp index 2b31726d3e..48035af9cc 100644 --- a/Gems/LyShine/Code/Source/Animation/AzEntityNode.cpp +++ b/Gems/LyShine/Code/Source/Animation/AzEntityNode.cpp @@ -16,8 +16,6 @@ #include "PNoise3.h" #include "AnimSequence.h" -#include - #include #include #include diff --git a/Gems/LyShine/Code/Source/Animation/UiAnimationSystem.cpp b/Gems/LyShine/Code/Source/Animation/UiAnimationSystem.cpp index ab45042b4c..a333183cde 100644 --- a/Gems/LyShine/Code/Source/Animation/UiAnimationSystem.cpp +++ b/Gems/LyShine/Code/Source/Animation/UiAnimationSystem.cpp @@ -24,7 +24,6 @@ #include #include #include -#include ////////////////////////////////////////////////////////////////////////// namespace @@ -615,20 +614,6 @@ bool UiAnimationSystem::InternalStopSequence(IUiAnimSequence* pSequence, bool bA ////////////////////////////////////////////////////////////////////////// bool UiAnimationSystem::AbortSequence(IUiAnimSequence* pSequence, bool bLeaveTime) { - assert(pSequence); - - // to avoid any camera blending after aborting a cut scene - IViewSystem* pViewSystem = gEnv->pSystem->GetIViewSystem(); - if (pViewSystem) - { - pViewSystem->SetBlendParams(0, 0, 0); - IView* pView = pViewSystem->GetActiveView(); - if (pView) - { - pView->ResetBlending(); - } - } - return InternalStopSequence(pSequence, true, !bLeaveTime); } diff --git a/Gems/LyShine/Code/Tests/SpriteTest.cpp b/Gems/LyShine/Code/Tests/SpriteTest.cpp index ff9095a7d9..596cf43c2f 100644 --- a/Gems/LyShine/Code/Tests/SpriteTest.cpp +++ b/Gems/LyShine/Code/Tests/SpriteTest.cpp @@ -8,7 +8,6 @@ #include "LyShineTest.h" #include -#include #include namespace UnitTest diff --git a/Gems/Maestro/Code/Source/Cinematics/Movie.cpp b/Gems/Maestro/Code/Source/Cinematics/Movie.cpp index 2a9a231177..61b5405a2b 100644 --- a/Gems/Maestro/Code/Source/Cinematics/Movie.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/Movie.cpp @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -835,20 +834,6 @@ bool CMovieSystem::InternalStopSequence(IAnimSequence* sequence, bool bAbort, bo ////////////////////////////////////////////////////////////////////////// bool CMovieSystem::AbortSequence(IAnimSequence* sequence, bool bLeaveTime) { - assert(sequence); - - // to avoid any camera blending after aborting a cut scene - IViewSystem* pViewSystem = gEnv->pSystem->GetIViewSystem(); - if (pViewSystem) - { - pViewSystem->SetBlendParams(0, 0, 0); - IView* pView = pViewSystem->GetActiveView(); - if (pView) - { - pView->ResetBlending(); - } - } - return InternalStopSequence(sequence, true, !bLeaveTime); } diff --git a/Gems/Maestro/Code/Source/Cinematics/SceneNode.cpp b/Gems/Maestro/Code/Source/Cinematics/SceneNode.cpp index b93215d397..eb88e21932 100644 --- a/Gems/Maestro/Code/Source/Cinematics/SceneNode.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/SceneNode.cpp @@ -36,7 +36,6 @@ #include #include -#include #define s_nodeParamsInitialized s_nodeParamsInitializedScene #define s_nodeParams s_nodeParamsSene @@ -796,22 +795,9 @@ void CAnimSceneNode::ApplyCameraKey(ISelectKey& key, SAnimContext& ec) cameraParams.fov = 0; cameraParams.justActivated = true; - // Init the defaults with the current view settings. // With component entities, the fov and near plane may be animated on an // entity with a Camera component. Don't stomp the values if this update happens // after those properties are animated. - AZ_Assert(gEnv && gEnv->pSystem, "Expected valid gEnv->pSystem"); - IViewSystem* viewSystem = gEnv->pSystem->GetIViewSystem(); - if (viewSystem) - { - IView* view = viewSystem->GetActiveView(); - if (view) - { - SViewParams params = *view->GetCurrentParams(); - cameraParams.fov = params.fov; - cameraParams.nearZ = params.nearplane; - } - } /////////////////////////////////////////////////////////////////// // find the Scene Camera (Camera Component Camera) diff --git a/Gems/PhysXDebug/Code/Source/SystemComponent.h b/Gems/PhysXDebug/Code/Source/SystemComponent.h index 83756f20f9..34c8142bac 100644 --- a/Gems/PhysXDebug/Code/Source/SystemComponent.h +++ b/Gems/PhysXDebug/Code/Source/SystemComponent.h @@ -16,7 +16,6 @@ #include #include -#include #include #include