+// 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)
+//
+//
-//
-// 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)
-//
-//
-// 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/Code/Tools/AssetBundler/source/utils/GUIApplicationManager.cpp b/Code/Tools/AssetBundler/source/utils/GUIApplicationManager.cpp
index b17832526f..17e621f7d6 100644
--- a/Code/Tools/AssetBundler/source/utils/GUIApplicationManager.cpp
+++ b/Code/Tools/AssetBundler/source/utils/GUIApplicationManager.cpp
@@ -346,9 +346,7 @@ namespace AssetBundler
}
// Determine the enabled platforms
- const char* appRoot = nullptr;
- AzFramework::ApplicationRequests::Bus::BroadcastResult(appRoot, &AzFramework::ApplicationRequests::GetAppRoot);
- m_enabledPlatforms = GetEnabledPlatformFlags(GetEngineRoot(), appRoot, AZ::Utils::GetProjectPath().c_str());
+ m_enabledPlatforms = GetEnabledPlatformFlags(GetEngineRoot(), AZStd::string_view(AZ::Utils::GetProjectPath()));
// Determine which Gems are enabled for the current project
if (!AzFramework::GetGemsInfo(m_gemInfoList, *m_settingsRegistry))
diff --git a/Code/Tools/AssetBundler/source/utils/applicationManager.cpp b/Code/Tools/AssetBundler/source/utils/applicationManager.cpp
index 0388570fdd..2df9e64ac5 100644
--- a/Code/Tools/AssetBundler/source/utils/applicationManager.cpp
+++ b/Code/Tools/AssetBundler/source/utils/applicationManager.cpp
@@ -1401,7 +1401,6 @@ namespace AssetBundler
// If no platform was specified, defaulting to platforms specified in the asset processor config files
AzFramework::PlatformFlags platformFlags = GetEnabledPlatformFlags(
- AZStd::string_view{ AZ::Utils::GetEnginePath() },
AZStd::string_view{ AZ::Utils::GetEnginePath() },
AZStd::string_view{ AZ::Utils::GetProjectPath() });
[[maybe_unused]] auto platformsString = AzFramework::PlatformHelper::GetCommaSeparatedPlatformList(platformFlags);
diff --git a/Code/Tools/AssetBundler/source/utils/utils.cpp b/Code/Tools/AssetBundler/source/utils/utils.cpp
index 6daf3c571b..7e56f5450e 100644
--- a/Code/Tools/AssetBundler/source/utils/utils.cpp
+++ b/Code/Tools/AssetBundler/source/utils/utils.cpp
@@ -377,7 +377,6 @@ namespace AssetBundler
AzFramework::PlatformFlags GetEnabledPlatformFlags(
AZStd::string_view engineRoot,
- AZStd::string_view assetRoot,
AZStd::string_view projectPath)
{
auto settingsRegistry = AZ::SettingsRegistry::Get();
@@ -387,7 +386,7 @@ namespace AssetBundler
return AzFramework::PlatformFlags::Platform_NONE;
}
- auto configFiles = AzToolsFramework::AssetUtils::GetConfigFiles(engineRoot, assetRoot, projectPath, true, true, settingsRegistry);
+ auto configFiles = AzToolsFramework::AssetUtils::GetConfigFiles(engineRoot, projectPath, true, true, settingsRegistry);
auto enabledPlatformList = AzToolsFramework::AssetUtils::GetEnabledPlatforms(*settingsRegistry, configFiles);
AzFramework::PlatformFlags platformFlags = AzFramework::PlatformFlags::Platform_NONE;
for (const auto& enabledPlatform : enabledPlatformList)
diff --git a/Code/Tools/AssetBundler/source/utils/utils.h b/Code/Tools/AssetBundler/source/utils/utils.h
index bfdf252014..0986d70ca8 100644
--- a/Code/Tools/AssetBundler/source/utils/utils.h
+++ b/Code/Tools/AssetBundler/source/utils/utils.h
@@ -221,7 +221,6 @@ namespace AssetBundler
//! Please note that the game project could be in a different location to the engine therefore we need the assetRoot param.
AzFramework::PlatformFlags GetEnabledPlatformFlags(
AZStd::string_view enginePath,
- AZStd::string_view assetRoot,
AZStd::string_view projectPath);
QJsonObject ReadJson(const AZStd::string& filePath);
diff --git a/Code/Tools/AssetBundler/tests/UtilsTests.cpp b/Code/Tools/AssetBundler/tests/UtilsTests.cpp
index 560d399613..60fc79579b 100644
--- a/Code/Tools/AssetBundler/tests/UtilsTests.cpp
+++ b/Code/Tools/AssetBundler/tests/UtilsTests.cpp
@@ -67,7 +67,7 @@ namespace AssetBundler
void NormalizePathKeepCase(AZStd::string& /*path*/) override {}
void CalculateBranchTokenForEngineRoot(AZStd::string& /*token*/) const override {}
- const char* GetEngineRoot() const override
+ const char* GetTempDir() const
{
return m_tempDir->GetDirectory();
}
@@ -83,7 +83,7 @@ namespace AssetBundler
TEST_F(MockUtilsTest, DISABLED_TestFilePath_StartsWithAFileSeparator_Valid)
{
AZ::IO::Path relFilePath = "Foo/foo.xml";
- AZ::IO::Path absoluteFilePath = AZ::IO::PathView(GetEngineRoot()).RootPath();
+ AZ::IO::Path absoluteFilePath = AZ::IO::PathView(GetTempDir()).RootPath();
absoluteFilePath /= relFilePath;
absoluteFilePath = absoluteFilePath.LexicallyNormal();
@@ -95,7 +95,7 @@ namespace AssetBundler
TEST_F(MockUtilsTest, TestFilePath_RelativePath_Valid)
{
AZ::IO::Path relFilePath = "Foo\\foo.xml";
- AZ::IO::Path absoluteFilePath = (AZ::IO::Path(GetEngineRoot()) / relFilePath).LexicallyNormal();
+ AZ::IO::Path absoluteFilePath = (AZ::IO::Path(GetTempDir()) / relFilePath).LexicallyNormal();
FilePath filePath(relFilePath.Native());
EXPECT_EQ(AZ::IO::PathView{ filePath.AbsolutePath() }, absoluteFilePath);
}
@@ -107,8 +107,8 @@ namespace AssetBundler
AZ::IO::Path relFilePath = "Foo\\Foo.xml";
AZ::IO::Path wrongCaseRelFilePath = "Foo\\foo.xml";
- AZ::IO::Path correctAbsoluteFilePath = (AZ::IO::Path(GetEngineRoot()) / relFilePath).LexicallyNormal();
- AZ::IO::Path wrongCaseAbsoluteFilePath = (AZ::IO::Path(GetEngineRoot()) / wrongCaseRelFilePath).LexicallyNormal();
+ AZ::IO::Path correctAbsoluteFilePath = (AZ::IO::Path(GetTempDir()) / relFilePath).LexicallyNormal();
+ AZ::IO::Path wrongCaseAbsoluteFilePath = (AZ::IO::Path(GetTempDir()) / wrongCaseRelFilePath).LexicallyNormal();
AZ::IO::HandleType fileHandle = AZ::IO::InvalidHandle;
AZ::IO::FileIOBase::GetInstance()->Open(correctAbsoluteFilePath.c_str(), AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeCreatePath, fileHandle);
@@ -121,7 +121,7 @@ namespace AssetBundler
TEST_F(MockUtilsTest, TestFilePath_NoFileExists_NoError_valid)
{
AZ::IO::Path relFilePath = "Foo\\Foo.xml";
- AZ::IO::Path absoluteFilePath = (AZ::IO::Path(GetEngineRoot()) / relFilePath).LexicallyNormal();
+ AZ::IO::Path absoluteFilePath = (AZ::IO::Path(GetTempDir()) / relFilePath).LexicallyNormal();
FilePath filePath(absoluteFilePath.Native(), true, false);
EXPECT_TRUE(filePath.IsValid());
@@ -132,8 +132,8 @@ namespace AssetBundler
{
AZStd::string relFilePath = "Foo\\Foo.xml";
AZStd::string wrongCaseRelFilePath = "Foo\\foo.xml";
- AZ::IO::Path correctAbsoluteFilePath = (AZ::IO::Path(GetEngineRoot()) / relFilePath).LexicallyNormal();
- AZ::IO::Path wrongCaseAbsoluteFilePath = (AZ::IO::Path(GetEngineRoot()) / wrongCaseRelFilePath).LexicallyNormal();
+ AZ::IO::Path correctAbsoluteFilePath = (AZ::IO::Path(GetTempDir()) / relFilePath).LexicallyNormal();
+ AZ::IO::Path wrongCaseAbsoluteFilePath = (AZ::IO::Path(GetTempDir()) / wrongCaseRelFilePath).LexicallyNormal();
AZ::IO::HandleType fileHandle = AZ::IO::InvalidHandle;
AZ::IO::FileIOBase::GetInstance()->Open(correctAbsoluteFilePath.c_str(), AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeCreatePath, fileHandle);
diff --git a/Code/Tools/AssetBundler/tests/applicationManagerTests.cpp b/Code/Tools/AssetBundler/tests/applicationManagerTests.cpp
index 07eae67a81..fd587195af 100644
--- a/Code/Tools/AssetBundler/tests/applicationManagerTests.cpp
+++ b/Code/Tools/AssetBundler/tests/applicationManagerTests.cpp
@@ -16,6 +16,7 @@
#include
#include
#include
+#include
#include
#include
@@ -84,10 +85,9 @@ namespace AssetBundler
// in the unit tests.
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
- const char* engineRoot = nullptr;
- AzFramework::ApplicationRequests::Bus::BroadcastResult(engineRoot, &AzFramework::ApplicationRequests::GetEngineRoot);
- ASSERT_TRUE(engineRoot) << "Unable to locate engine root.\n";
- AzFramework::StringFunc::Path::Join(engineRoot, RelativeTestFolder, m_data->m_testEngineRoot);
+ AZ::IO::FixedMaxPath engineRoot = AZ::Utils::GetEnginePath();
+ ASSERT_TRUE(!engineRoot.empty()) << "Unable to locate engine root.\n";
+ m_data->m_testEngineRoot = (engineRoot / RelativeTestFolder).String();
m_data->m_localFileIO = aznew AZ::IO::LocalFileIO();
m_data->m_priorFileIO = AZ::IO::FileIOBase::GetInstance();
@@ -150,7 +150,8 @@ namespace AssetBundler
EXPECT_EQ(0, gemsNameMap.size());
- AzFramework::PlatformFlags platformFlags = GetEnabledPlatformFlags(m_data->m_testEngineRoot.c_str(), m_data->m_testEngineRoot.c_str(), DummyProjectName);
+ const auto testProjectPath = AZ::IO::Path(m_data->m_testEngineRoot) / DummyProjectName;
+ AzFramework::PlatformFlags platformFlags = GetEnabledPlatformFlags(m_data->m_testEngineRoot, testProjectPath.Native());
AzFramework::PlatformFlags hostPlatformFlag = AzFramework::PlatformHelper::GetPlatformFlag(AzToolsFramework::AssetSystem::GetHostAssetPlatform());
AzFramework::PlatformFlags expectedFlags = AzFramework::PlatformFlags::Platform_ANDROID | AzFramework::PlatformFlags::Platform_IOS | AzFramework::PlatformFlags::Platform_PROVO | hostPlatformFlag;
ASSERT_EQ(platformFlags, expectedFlags);
diff --git a/Code/Tools/AssetProcessor/AssetBuilderSDK/AssetBuilderSDK/AssetBuilderSDK.cpp b/Code/Tools/AssetProcessor/AssetBuilderSDK/AssetBuilderSDK/AssetBuilderSDK.cpp
index 62b063c83b..a02eef8b75 100644
--- a/Code/Tools/AssetProcessor/AssetBuilderSDK/AssetBuilderSDK/AssetBuilderSDK.cpp
+++ b/Code/Tools/AssetProcessor/AssetBuilderSDK/AssetBuilderSDK/AssetBuilderSDK.cpp
@@ -699,7 +699,6 @@ namespace AssetBuilderSDK
// XML files may contain generic data (avoid this in new builders - use a custom extension!)
static const char* xmlExtensions = ".xml";
- static const char* geomCacheExtensions = ".cax";
static const char* skeletonExtensions = ".chr";
static AZ::Data::AssetType unknownAssetType = AZ::Data::AssetType::CreateNull();
@@ -710,7 +709,6 @@ namespace AssetBuilderSDK
static AZ::Data::AssetType textureMipsAssetType("{3918728C-D3CA-4D9E-813E-A5ED20C6821E}");
static AZ::Data::AssetType skinnedMeshLodsAssetType("{58E5824F-C27B-46FD-AD48-865BA41B7A51}");
static AZ::Data::AssetType staticMeshLodsAssetType("{9AAE4926-CB6A-4C60-9948-A1A22F51DB23}");
- static AZ::Data::AssetType geomCacheAssetType("{EBC96071-E960-41B6-B3E3-328F515AE5DA}");
static AZ::Data::AssetType skeletonAssetType("{60161B46-21F0-4396-A4F0-F2CCF0664CDE}");
static AZ::Data::AssetType entityIconAssetType("{3436C30E-E2C5-4C3B-A7B9-66C94A28701B}");
@@ -822,11 +820,6 @@ namespace AssetBuilderSDK
return skinnedMeshAssetType;
}
- if (AzFramework::StringFunc::Find(geomCacheExtensions, extension.c_str()) != AZStd::string::npos)
- {
- return geomCacheAssetType;
- }
-
if (AzFramework::StringFunc::Find(skeletonExtensions, extension.c_str()) != AZStd::string::npos)
{
return skeletonAssetType;
diff --git a/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp b/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp
index 6fd05fa948..624fa3d06b 100644
--- a/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp
+++ b/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp
@@ -52,11 +52,12 @@ TEST_F(PlatformConfigurationUnitTests, TestFailReadConfigFile_BadPlatform)
using namespace AssetProcessor;
const auto testExeFolder = AZ::IO::FileIOBase::GetInstance()->ResolvePath(TestAppRoot);
+ const AZ::IO::FixedMaxPath projectPath = (*testExeFolder) / EmptyDummyProjectName;
auto configRoot = AZ::IO::FileIOBase::GetInstance()->ResolvePath("@exefolder@/testdata/config_broken_badplatform");
ASSERT_TRUE(configRoot);
UnitTestPlatformConfiguration config;
m_absorber.Clear();
- ASSERT_FALSE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), EmptyDummyProjectName, false, false));
+ ASSERT_FALSE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), projectPath.c_str(), false, false));
ASSERT_GT(m_absorber.m_numErrorsAbsorbed, 0);
}
@@ -67,11 +68,12 @@ TEST_F(PlatformConfigurationUnitTests, TestFailReadConfigFile_NoPlatform)
using namespace AssetProcessor;
const auto testExeFolder = AZ::IO::FileIOBase::GetInstance()->ResolvePath(TestAppRoot);
+ const AZ::IO::FixedMaxPath projectPath = (*testExeFolder) / EmptyDummyProjectName;
auto configRoot = AZ::IO::FileIOBase::GetInstance()->ResolvePath("@exefolder@/testdata/config_broken_noplatform");
ASSERT_TRUE(configRoot);
UnitTestPlatformConfiguration config;
m_absorber.Clear();
- ASSERT_FALSE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), EmptyDummyProjectName, false, false));
+ ASSERT_FALSE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), projectPath.c_str(), false, false));
ASSERT_GT(m_absorber.m_numErrorsAbsorbed, 0);
}
@@ -81,11 +83,12 @@ TEST_F(PlatformConfigurationUnitTests, TestFailReadConfigFile_NoScanFolders)
using namespace AssetProcessor;
const auto testExeFolder = AZ::IO::FileIOBase::GetInstance()->ResolvePath(TestAppRoot);
+ const AZ::IO::FixedMaxPath projectPath = (*testExeFolder) / EmptyDummyProjectName;
auto configRoot = AZ::IO::FileIOBase::GetInstance()->ResolvePath("@exefolder@/testdata/config_broken_noscans");
ASSERT_TRUE(configRoot);
UnitTestPlatformConfiguration config;
m_absorber.Clear();
- ASSERT_FALSE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), EmptyDummyProjectName, false, false));
+ ASSERT_FALSE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), projectPath.c_str(), false, false));
ASSERT_GT(m_absorber.m_numErrorsAbsorbed, 0);
}
@@ -95,11 +98,12 @@ TEST_F(PlatformConfigurationUnitTests, TestFailReadConfigFile_BrokenRecognizers)
using namespace AssetProcessor;
const auto testExeFolder = AZ::IO::FileIOBase::GetInstance()->ResolvePath(TestAppRoot);
+ const AZ::IO::FixedMaxPath projectPath = (*testExeFolder) / EmptyDummyProjectName;
auto configRoot = AZ::IO::FileIOBase::GetInstance()->ResolvePath("@exefolder@/testdata/config_broken_recognizers");
ASSERT_TRUE(configRoot);
UnitTestPlatformConfiguration config;
m_absorber.Clear();
- ASSERT_FALSE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), EmptyDummyProjectName, false, false));
+ ASSERT_FALSE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), projectPath.c_str(), false, false));
ASSERT_GT(m_absorber.m_numErrorsAbsorbed, 0);
}
@@ -109,11 +113,12 @@ TEST_F(PlatformConfigurationUnitTests, TestFailReadConfigFile_Regular_Platforms)
using namespace AssetProcessor;
const auto testExeFolder = AZ::IO::FileIOBase::GetInstance()->ResolvePath(TestAppRoot);
+ const AZ::IO::FixedMaxPath projectPath = (*testExeFolder) / EmptyDummyProjectName;
auto configRoot = AZ::IO::FileIOBase::GetInstance()->ResolvePath("@exefolder@/testdata/config_regular");
ASSERT_TRUE(configRoot);
UnitTestPlatformConfiguration config;
m_absorber.Clear();
- ASSERT_TRUE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), EmptyDummyProjectName, false, false));
+ ASSERT_TRUE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), projectPath.c_str(), false, false));
ASSERT_EQ(m_absorber.m_numErrorsAbsorbed, 0);
// verify the data.
@@ -322,12 +327,13 @@ TEST_F(PlatformConfigurationUnitTests, TestFailReadConfigFile_RegularScanfolder)
using namespace AssetProcessor;
const auto testExeFolder = AZ::IO::FileIOBase::GetInstance()->ResolvePath(TestAppRoot);
+ const AZ::IO::FixedMaxPath projectPath = (*testExeFolder) / EmptyDummyProjectName;
auto configRoot = AZ::IO::FileIOBase::GetInstance()->ResolvePath("@exefolder@/testdata/config_regular");
ASSERT_TRUE(configRoot);
UnitTestPlatformConfiguration config;
m_absorber.Clear();
AssetUtilities::ComputeProjectName(EmptyDummyProjectName, true);
- ASSERT_TRUE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), EmptyDummyProjectName, false, false));
+ ASSERT_TRUE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), projectPath.c_str(), false, false));
ASSERT_EQ(m_absorber.m_numErrorsAbsorbed, 0);
ASSERT_EQ(config.GetScanFolderCount(), 3); // the two, and then the one that has the same data as prior but different identifier.
@@ -356,11 +362,12 @@ TEST_F(PlatformConfigurationUnitTests, TestFailReadConfigFile_RegularScanfolderP
using namespace AssetProcessor;
const auto testExeFolder = AZ::IO::FileIOBase::GetInstance()->ResolvePath(TestAppRoot);
+ const AZ::IO::FixedMaxPath projectPath = (*testExeFolder) / EmptyDummyProjectName;
auto configRoot = AZ::IO::FileIOBase::GetInstance()->ResolvePath("@exefolder@/testdata/config_regular_platform_scanfolder");
ASSERT_TRUE(configRoot);
UnitTestPlatformConfiguration config;
m_absorber.Clear();
- ASSERT_TRUE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), EmptyDummyProjectName, false, false));
+ ASSERT_TRUE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), projectPath.c_str(), false, false));
ASSERT_EQ(m_absorber.m_numErrorsAbsorbed, 0);
ASSERT_EQ(config.GetScanFolderCount(), 5);
@@ -402,13 +409,14 @@ TEST_F(PlatformConfigurationUnitTests, TestFailReadConfigFile_RegularExcludes)
using namespace AssetProcessor;
const auto testExeFolder = AZ::IO::FileIOBase::GetInstance()->ResolvePath(TestAppRoot);
+ const AZ::IO::FixedMaxPath projectPath = (*testExeFolder) / EmptyDummyProjectName;
auto configRoot = AZ::IO::FileIOBase::GetInstance()->ResolvePath("@exefolder@/testdata/config_regular");
ASSERT_TRUE(configRoot);
UnitTestPlatformConfiguration config;
config.AddScanFolder(ScanFolderInfo("blahblah", "Blah ScanFolder", "sf2", true, true), true);
m_absorber.Clear();
- ASSERT_TRUE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), EmptyDummyProjectName, false, false));
+ ASSERT_TRUE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), projectPath.c_str(), false, false));
ASSERT_EQ(m_absorber.m_numErrorsAbsorbed, 0);
ASSERT_TRUE(config.IsFileExcluded("blahblah/$tmp_01.test"));
@@ -429,11 +437,12 @@ TEST_F(PlatformConfigurationUnitTests, TestFailReadConfigFile_Recognizers)
#endif
const auto testExeFolder = AZ::IO::FileIOBase::GetInstance()->ResolvePath(TestAppRoot);
+ const AZ::IO::FixedMaxPath projectPath = (*testExeFolder) / EmptyDummyProjectName;
auto configRoot = AZ::IO::FileIOBase::GetInstance()->ResolvePath("@exefolder@/testdata/config_regular");
ASSERT_TRUE(configRoot);
UnitTestPlatformConfiguration config;
m_absorber.Clear();
- ASSERT_TRUE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), EmptyDummyProjectName, false, false));
+ ASSERT_TRUE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), projectPath.c_str(), false, false));
ASSERT_EQ(m_absorber.m_numErrorsAbsorbed, 0);
const AssetProcessor::RecognizerContainer& recogs = config.GetAssetRecognizerContainer();
@@ -520,12 +529,13 @@ TEST_F(PlatformConfigurationUnitTests, TestFailReadConfigFile_Overrides)
using namespace AzToolsFramework::AssetSystem;
using namespace AssetProcessor;
const auto testExeFolder = AZ::IO::FileIOBase::GetInstance()->ResolvePath(TestAppRoot);
+ const AZ::IO::FixedMaxPath projectPath = (*testExeFolder) / DummyProjectName;
auto configRoot = AZ::IO::FileIOBase::GetInstance()->ResolvePath("@exefolder@/testdata/config_regular");
ASSERT_TRUE(configRoot);
UnitTestPlatformConfiguration config;
m_absorber.Clear();
- ASSERT_TRUE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), DummyProjectName, false, false));
+ ASSERT_TRUE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), projectPath.c_str(), false, false));
ASSERT_EQ(m_absorber.m_numErrorsAbsorbed, 0);
const AssetProcessor::RecognizerContainer& recogs = config.GetAssetRecognizerContainer();
@@ -627,11 +637,12 @@ TEST_F(PlatformConfigurationUnitTests, ReadCheckServer_FromConfig_Valid)
using namespace AssetProcessor;
const auto testExeFolder = AZ::IO::FileIOBase::GetInstance()->ResolvePath(TestAppRoot);
+ const AZ::IO::FixedMaxPath projectPath = (*testExeFolder) / EmptyDummyProjectName;
auto configRoot = AZ::IO::FileIOBase::GetInstance()->ResolvePath("@exefolder@/testdata/config_regular");
ASSERT_TRUE(configRoot);
UnitTestPlatformConfiguration config;
m_absorber.Clear();
- ASSERT_TRUE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), EmptyDummyProjectName, false, false));
+ ASSERT_TRUE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), projectPath.c_str(), false, false));
ASSERT_EQ(m_absorber.m_numErrorsAbsorbed, 0);
const AssetProcessor::RecognizerContainer& recogs = config.GetAssetRecognizerContainer();
@@ -676,11 +687,12 @@ TEST_F(PlatformConfigurationUnitTests, Test_MetaFileTypes_AssetImporterExtension
using namespace AssetProcessor;
const auto testExeFolder = AZ::IO::FileIOBase::GetInstance()->ResolvePath(TestAppRoot);
+ const AZ::IO::FixedMaxPath projectPath = (*testExeFolder) / EmptyDummyProjectName;
auto configRoot = AZ::IO::FileIOBase::GetInstance()->ResolvePath("@exefolder@/testdata/config_metadata");
ASSERT_TRUE(configRoot);
UnitTestPlatformConfiguration config;
m_absorber.Clear();
- ASSERT_FALSE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), EmptyDummyProjectName, false, false));
+ ASSERT_FALSE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), projectPath.c_str(), false, false));
ASSERT_GT(m_absorber.m_numErrorsAbsorbed, 0);
ASSERT_TRUE(config.MetaDataFileTypesCount() == 2);
diff --git a/Code/Tools/AssetProcessor/native/utilities/PlatformConfiguration.cpp b/Code/Tools/AssetProcessor/native/utilities/PlatformConfiguration.cpp
index bcadd0f103..bc516d5da6 100644
--- a/Code/Tools/AssetProcessor/native/utilities/PlatformConfiguration.cpp
+++ b/Code/Tools/AssetProcessor/native/utilities/PlatformConfiguration.cpp
@@ -749,7 +749,7 @@ namespace AssetProcessor
}
AZStd::vector configFiles = AzToolsFramework::AssetUtils::GetConfigFiles(absoluteSystemRoot.toUtf8().constData(),
- absoluteAssetRoot.toUtf8().constData(), projectPath.toUtf8().constData(),
+ projectPath.toUtf8().constData(),
addPlatformConfigs, addGemsConfigs && !noGemScanFolders, settingsRegistry);
// First Merge all Engine, Gem and Project specific AssetProcessor*Config.setreg/.inifiles
diff --git a/Code/Tools/ProjectManager/Source/DownloadController.cpp b/Code/Tools/ProjectManager/Source/DownloadController.cpp
index d30e1bbc7c..6326b2fc11 100644
--- a/Code/Tools/ProjectManager/Source/DownloadController.cpp
+++ b/Code/Tools/ProjectManager/Source/DownloadController.cpp
@@ -41,9 +41,11 @@ namespace O3DE::ProjectManager
void DownloadController::AddGemDownload(const QString& gemName)
{
m_gemNames.push_back(gemName);
+ emit GemDownloadAdded(gemName);
+
if (m_gemNames.size() == 1)
{
- m_worker->SetGemToDownload(m_gemNames[0], false);
+ m_worker->SetGemToDownload(m_gemNames.front(), false);
m_workerThread.start();
}
}
@@ -62,6 +64,7 @@ namespace O3DE::ProjectManager
else
{
m_gemNames.erase(findResult);
+ emit GemDownloadRemoved(gemName);
}
}
}
@@ -69,7 +72,7 @@ namespace O3DE::ProjectManager
void DownloadController::UpdateUIProgress(int progress)
{
m_lastProgress = progress;
- emit GemDownloadProgress(progress);
+ emit GemDownloadProgress(m_gemNames.front(), progress);
}
void DownloadController::HandleResults(const QString& result)
diff --git a/Code/Tools/ProjectManager/Source/DownloadController.h b/Code/Tools/ProjectManager/Source/DownloadController.h
index 5b2d230379..0bf0ae473c 100644
--- a/Code/Tools/ProjectManager/Source/DownloadController.h
+++ b/Code/Tools/ProjectManager/Source/DownloadController.h
@@ -59,7 +59,9 @@ namespace O3DE::ProjectManager
signals:
void StartGemDownload(const QString& gemName);
void Done(const QString& gemName, bool success = true);
- void GemDownloadProgress(int percentage);
+ void GemDownloadAdded(const QString& gemName);
+ void GemDownloadRemoved(const QString& gemName);
+ void GemDownloadProgress(const QString& gemName, int percentage);
private:
DownloadWorker* m_worker;
diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogHeaderWidget.cpp b/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogHeaderWidget.cpp
index 8c875e4846..bd0a6e9bc3 100644
--- a/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogHeaderWidget.cpp
+++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogHeaderWidget.cpp
@@ -30,6 +30,7 @@ namespace O3DE::ProjectManager
m_layout->setMargin(5);
m_layout->setAlignment(Qt::AlignTop);
setLayout(m_layout);
+ setMinimumHeight(400);
QHBoxLayout* hLayout = new QHBoxLayout();
@@ -119,6 +120,12 @@ namespace O3DE::ProjectManager
setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
}
+ CartOverlayWidget::~CartOverlayWidget()
+ {
+ // disconnect from all download controller signals
+ disconnect(m_downloadController, nullptr, this, nullptr);
+ }
+
void CartOverlayWidget::CreateGemSection(const QString& singularTitle, const QString& pluralTitle, GetTagIndicesCallback getTagIndices)
{
QWidget* widget = new QWidget();
@@ -162,13 +169,13 @@ namespace O3DE::ProjectManager
void CartOverlayWidget::CreateDownloadSection()
{
- QWidget* widget = new QWidget();
- widget->setFixedWidth(s_width);
- m_layout->addWidget(widget);
+ m_downloadSectionWidget = new QWidget();
+ m_downloadSectionWidget->setFixedWidth(s_width);
+ m_layout->addWidget(m_downloadSectionWidget);
QVBoxLayout* layout = new QVBoxLayout();
layout->setAlignment(Qt::AlignTop);
- widget->setLayout(layout);
+ m_downloadSectionWidget->setLayout(layout);
QLabel* titleLabel = new QLabel();
titleLabel->setObjectName("GemCatalogCartOverlaySectionLabel");
@@ -187,88 +194,121 @@ namespace O3DE::ProjectManager
QLabel* processingQueueLabel = new QLabel("Processing Queue");
gemDownloadLayout->addWidget(processingQueueLabel);
- QWidget* downloadingItemWidget = new QWidget();
- downloadingItemWidget->setObjectName("GemCatalogCartOverlayGemDownloadBG");
- gemDownloadLayout->addWidget(downloadingItemWidget);
+ m_downloadingListWidget = new QWidget();
+ m_downloadingListWidget->setObjectName("GemCatalogCartOverlayGemDownloadBG");
+ gemDownloadLayout->addWidget(m_downloadingListWidget);
QVBoxLayout* downloadingItemLayout = new QVBoxLayout();
downloadingItemLayout->setAlignment(Qt::AlignTop);
- downloadingItemWidget->setLayout(downloadingItemLayout);
+ m_downloadingListWidget->setLayout(downloadingItemLayout);
- auto update = [=](int downloadProgress)
+ QLabel* downloadsInProgessLabel = new QLabel("");
+ downloadsInProgessLabel->setObjectName("NumDownloadsInProgressLabel");
+ downloadingItemLayout->addWidget(downloadsInProgessLabel);
+
+ if (m_downloadController->IsDownloadQueueEmpty())
{
- if (m_downloadController->IsDownloadQueueEmpty())
- {
- widget->hide();
- }
- else
- {
- widget->setUpdatesEnabled(false);
- // remove items
- QLayoutItem* layoutItem = nullptr;
- while ((layoutItem = downloadingItemLayout->takeAt(0)) != nullptr)
- {
- if (layoutItem->layout())
- {
- // Gem info row
- QLayoutItem* rowLayoutItem = nullptr;
- while ((rowLayoutItem = layoutItem->layout()->takeAt(0)) != nullptr)
- {
- rowLayoutItem->widget()->deleteLater();
- }
- layoutItem->layout()->deleteLater();
- }
- if (layoutItem->widget())
- {
- layoutItem->widget()->deleteLater();
- }
- }
-
- // Setup gem download rows
- const AZStd::vector& downloadQueue = m_downloadController->GetDownloadQueue();
-
- QLabel* downloadsInProgessLabel = new QLabel("");
- downloadsInProgessLabel->setText(
- QString("%1 %2").arg(downloadQueue.size()).arg(downloadQueue.size() == 1 ? tr("download in progress...") : tr("downloads in progress...")));
- downloadingItemLayout->addWidget(downloadsInProgessLabel);
-
- for (int downloadingGemNumber = 0; downloadingGemNumber < downloadQueue.size(); ++downloadingGemNumber)
- {
- QHBoxLayout* nameProgressLayout = new QHBoxLayout();
-
- const QString& gemName = downloadQueue[downloadingGemNumber];
- TagWidget* newTag = new TagWidget({gemName, gemName});
- nameProgressLayout->addWidget(newTag);
-
- QLabel* progress = new QLabel(downloadingGemNumber == 0? QString("%1%").arg(downloadProgress) : tr("Queued"));
- nameProgressLayout->addWidget(progress);
-
- QSpacerItem* spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
- nameProgressLayout->addSpacerItem(spacer);
-
- QLabel* cancelText = new QLabel(QString("