Camera Component, Editor Viewport Widget refactoring.
- Handle changing of active camera entirely inside CameraComponentController - Remove a LOT of legacy Cry things related to cameras - Add a CameraSystemComponent to handle ActiveCameraRequestBus and CameraSystemRequestBus Signed-off-by: Yuriy Toporovskyy <toporovskyy.y@gmail.com>
This commit is contained in:
@@ -952,7 +952,7 @@ void Q2DViewport::DrawViewerMarker(DisplayContext& dc)
|
||||
dc.SetColor(QColor(0, 0, 255)); // blue
|
||||
dc.DrawWireBox(-dim * noScale, dim * noScale);
|
||||
|
||||
float fov = GetIEditor()->GetSystem()->GetViewCamera().GetFov();
|
||||
float fov = 60; // GetIEditor()->GetSystem()->GetViewCamera().GetFov();
|
||||
|
||||
Vec3 q[4];
|
||||
float dist = 30;
|
||||
|
||||
@@ -61,15 +61,6 @@ protected:
|
||||
{
|
||||
camObjId = pEditorEntity->GetId();
|
||||
}
|
||||
|
||||
CViewport* pViewport = GetIEditor()->GetViewManager()->GetSelectedViewport();
|
||||
if (CRenderViewport* rvp = viewport_cast<CRenderViewport*>(pViewport))
|
||||
{
|
||||
if (!rvp->IsSequenceCamera())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Switch camera in active rendering view.
|
||||
|
||||
+58
-57
@@ -3728,24 +3728,24 @@ void CCryEditApp::OnToolsPreferences()
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnSwitchToDefaultCamera()
|
||||
{
|
||||
CViewport* vp = GetIEditor()->GetViewManager()->GetSelectedViewport();
|
||||
if (CRenderViewport* rvp = viewport_cast<CRenderViewport*>(vp))
|
||||
{
|
||||
rvp->SetDefaultCamera();
|
||||
}
|
||||
//CViewport* vp = GetIEditor()->GetViewManager()->GetSelectedViewport();
|
||||
//if (CRenderViewport* rvp = viewport_cast<CRenderViewport*>(vp))
|
||||
//{
|
||||
// rvp->SetDefaultCamera();
|
||||
//}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnUpdateSwitchToDefaultCamera(QAction* action)
|
||||
void CCryEditApp::OnUpdateSwitchToDefaultCamera([[maybe_unused]] QAction* action)
|
||||
{
|
||||
Q_ASSERT(action->isCheckable());
|
||||
CViewport* pViewport = GetIEditor()->GetViewManager()->GetSelectedViewport();
|
||||
if (CRenderViewport* rvp = viewport_cast<CRenderViewport*>(pViewport))
|
||||
{
|
||||
action->setEnabled(true);
|
||||
action->setChecked(rvp->IsDefaultCamera());
|
||||
}
|
||||
else
|
||||
//CViewport* pViewport = GetIEditor()->GetViewManager()->GetSelectedViewport();
|
||||
//if (false) // (CRenderViewport* rvp = viewport_cast<CRenderViewport*>(pViewport))
|
||||
//{
|
||||
// action->setEnabled(true);
|
||||
// action->setChecked(rvp->IsDefaultCamera());
|
||||
//}
|
||||
//else
|
||||
{
|
||||
action->setEnabled(false);
|
||||
}
|
||||
@@ -3754,11 +3754,11 @@ void CCryEditApp::OnUpdateSwitchToDefaultCamera(QAction* action)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnSwitchToSequenceCamera()
|
||||
{
|
||||
CViewport* vp = GetIEditor()->GetViewManager()->GetSelectedViewport();
|
||||
if (CRenderViewport* rvp = viewport_cast<CRenderViewport*>(vp))
|
||||
{
|
||||
rvp->SetSequenceCamera();
|
||||
}
|
||||
//CViewport* vp = GetIEditor()->GetViewManager()->GetSelectedViewport();
|
||||
//if (CRenderViewport* rvp = viewport_cast<CRenderViewport*>(vp))
|
||||
//{
|
||||
// rvp->SetSequenceCamera();
|
||||
//}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -3766,27 +3766,27 @@ void CCryEditApp::OnUpdateSwitchToSequenceCamera(QAction* action)
|
||||
{
|
||||
Q_ASSERT(action->isCheckable());
|
||||
|
||||
CViewport* pViewport = GetIEditor()->GetViewManager()->GetSelectedViewport();
|
||||
//CViewport* pViewport = GetIEditor()->GetViewManager()->GetSelectedViewport();
|
||||
|
||||
if (CRenderViewport* rvp = viewport_cast<CRenderViewport*>(pViewport))
|
||||
{
|
||||
bool enableAction = false;
|
||||
//if (CRenderViewport* rvp = viewport_cast<CRenderViewport*>(pViewport))
|
||||
//{
|
||||
// bool enableAction = false;
|
||||
|
||||
// only enable if we're editing a sequence in Track View and have cameras in the level
|
||||
if (GetIEditor()->GetAnimation()->GetSequence())
|
||||
{
|
||||
// // only enable if we're editing a sequence in Track View and have cameras in the level
|
||||
// if (GetIEditor()->GetAnimation()->GetSequence())
|
||||
// {
|
||||
|
||||
AZ::EBusAggregateResults<AZ::EntityId> componentCameras;
|
||||
Camera::CameraBus::BroadcastResult(componentCameras, &Camera::CameraRequests::GetCameras);
|
||||
// AZ::EBusAggregateResults<AZ::EntityId> componentCameras;
|
||||
// Camera::CameraBus::BroadcastResult(componentCameras, &Camera::CameraRequests::GetCameras);
|
||||
|
||||
const int numCameras = componentCameras.values.size();
|
||||
enableAction = (numCameras > 0);
|
||||
}
|
||||
// const int numCameras = componentCameras.values.size();
|
||||
// enableAction = (numCameras > 0);
|
||||
// }
|
||||
|
||||
action->setEnabled(enableAction);
|
||||
action->setChecked(rvp->IsSequenceCamera());
|
||||
}
|
||||
else
|
||||
// action->setEnabled(enableAction);
|
||||
// action->setChecked(rvp->IsSequenceCamera());
|
||||
//}
|
||||
//else
|
||||
{
|
||||
action->setEnabled(false);
|
||||
}
|
||||
@@ -3795,31 +3795,32 @@ void CCryEditApp::OnUpdateSwitchToSequenceCamera(QAction* action)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnSwitchToSelectedcamera()
|
||||
{
|
||||
CViewport* vp = GetIEditor()->GetViewManager()->GetSelectedViewport();
|
||||
if (CRenderViewport* rvp = viewport_cast<CRenderViewport*>(vp))
|
||||
{
|
||||
rvp->SetSelectedCamera();
|
||||
}
|
||||
//CViewport* vp = GetIEditor()->GetViewManager()->GetSelectedViewport();
|
||||
//if (CRenderViewport* rvp = viewport_cast<CRenderViewport*>(vp))
|
||||
//{
|
||||
// rvp->SetSelectedCamera();
|
||||
//}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnUpdateSwitchToSelectedCamera(QAction* action)
|
||||
{
|
||||
Q_ASSERT(action->isCheckable());
|
||||
AzToolsFramework::EntityIdList selectedEntityList;
|
||||
AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult(selectedEntityList, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
|
||||
AZ::EBusAggregateResults<AZ::EntityId> cameras;
|
||||
Camera::CameraBus::BroadcastResult(cameras, &Camera::CameraRequests::GetCameras);
|
||||
bool isCameraComponentSelected = selectedEntityList.size() > 0 ? AZStd::find(cameras.values.begin(), cameras.values.end(), *selectedEntityList.begin()) != cameras.values.end() : false;
|
||||
(void)action;
|
||||
//AzToolsFramework::EntityIdList selectedEntityList;
|
||||
//AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult(selectedEntityList, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
|
||||
//AZ::EBusAggregateResults<AZ::EntityId> cameras;
|
||||
//Camera::CameraBus::BroadcastResult(cameras, &Camera::CameraRequests::GetCameras);
|
||||
//bool isCameraComponentSelected = selectedEntityList.size() > 0 ? AZStd::find(cameras.values.begin(), cameras.values.end(), *selectedEntityList.begin()) != cameras.values.end() : false;
|
||||
|
||||
CViewport* pViewport = GetIEditor()->GetViewManager()->GetSelectedViewport();
|
||||
CRenderViewport* rvp = viewport_cast<CRenderViewport*>(pViewport);
|
||||
if (isCameraComponentSelected && rvp)
|
||||
{
|
||||
action->setEnabled(true);
|
||||
action->setChecked(rvp->IsSelectedCamera());
|
||||
}
|
||||
else
|
||||
//CViewport* pViewport = GetIEditor()->GetViewManager()->GetSelectedViewport();
|
||||
//CRenderViewport* rvp = viewport_cast<CRenderViewport*>(pViewport);
|
||||
//if (isCameraComponentSelected && rvp)
|
||||
//{
|
||||
// action->setEnabled(true);
|
||||
// action->setChecked(rvp->IsSelectedCamera());
|
||||
//}
|
||||
//else
|
||||
{
|
||||
action->setEnabled(false);
|
||||
}
|
||||
@@ -3828,11 +3829,11 @@ void CCryEditApp::OnUpdateSwitchToSelectedCamera(QAction* action)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnSwitchcameraNext()
|
||||
{
|
||||
CViewport* vp = GetIEditor()->GetActiveView();
|
||||
if (CRenderViewport* rvp = viewport_cast<CRenderViewport*>(vp))
|
||||
{
|
||||
rvp->CycleCamera();
|
||||
}
|
||||
//CViewport* vp = GetIEditor()->GetActiveView();
|
||||
//if (CRenderViewport* rvp = viewport_cast<CRenderViewport*>(vp))
|
||||
//{
|
||||
// rvp->CycleCamera();
|
||||
//}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <AzCore/Asset/AssetManager.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <MathConversion.h>
|
||||
|
||||
// AzFramework
|
||||
#include <AzFramework/Archive/IArchive.h>
|
||||
@@ -53,6 +54,7 @@
|
||||
#include "MainWindow.h"
|
||||
#include "LevelFileDialog.h"
|
||||
#include "StatObjBus.h"
|
||||
#include "Undo/Undo.h"
|
||||
|
||||
#include <Atom/RPI.Public/ViewportContext.h>
|
||||
#include <Atom/RPI.Public/ViewportContextBus.h>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+202
-403
@@ -34,6 +34,7 @@
|
||||
#include <MathConversion.h>
|
||||
#include <Atom/RPI.Public/ViewportContext.h>
|
||||
#include <Atom/RPI.Public/SceneBus.h>
|
||||
#include <AzFramework/Components/CameraBus.h>
|
||||
#endif
|
||||
|
||||
#include <AzFramework/Windowing/WindowBus.h>
|
||||
@@ -65,130 +66,120 @@ namespace AzToolsFramework
|
||||
// EditorViewportWidget window
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
class SANDBOX_API EditorViewportWidget
|
||||
class SANDBOX_API EditorViewportWidget final
|
||||
: public QtViewport
|
||||
, public IEditorNotifyListener
|
||||
, public IUndoManagerListener
|
||||
, public Camera::EditorCameraRequestBus::Handler
|
||||
, public AzFramework::InputSystemCursorConstraintRequestBus::Handler
|
||||
, public AzToolsFramework::ViewportInteraction::ViewportFreezeRequestBus::Handler
|
||||
, public AzToolsFramework::ViewportInteraction::MainEditorViewportInteractionRequestBus::Handler
|
||||
, public AzFramework::AssetCatalogEventBus::Handler
|
||||
, public AZ::RPI::SceneNotificationBus::Handler
|
||||
, private IEditorNotifyListener
|
||||
, private IUndoManagerListener
|
||||
, private Camera::EditorCameraRequestBus::Handler
|
||||
, private Camera::CameraNotificationBus::Handler
|
||||
, private AzFramework::InputSystemCursorConstraintRequestBus::Handler
|
||||
, private AzToolsFramework::ViewportInteraction::ViewportFreezeRequestBus::Handler
|
||||
, private AzToolsFramework::ViewportInteraction::MainEditorViewportInteractionRequestBus::Handler
|
||||
, private AzFramework::AssetCatalogEventBus::Handler
|
||||
, private AZ::RPI::SceneNotificationBus::Handler
|
||||
{
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
Q_OBJECT
|
||||
public:
|
||||
struct SResolution
|
||||
{
|
||||
SResolution()
|
||||
: width(0)
|
||||
, height(0)
|
||||
{
|
||||
}
|
||||
|
||||
SResolution(int w, int h)
|
||||
: width(w)
|
||||
, height(h)
|
||||
{
|
||||
}
|
||||
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
||||
public:
|
||||
EditorViewportWidget(const QString& name, QWidget* parent = nullptr);
|
||||
~EditorViewportWidget() override;
|
||||
|
||||
static const GUID& GetClassID()
|
||||
{
|
||||
return QtViewport::GetClassID<EditorViewportWidget>();
|
||||
}
|
||||
|
||||
/** Get type of this viewport.
|
||||
*/
|
||||
virtual EViewportType GetType() const { return ET_ViewportCamera; }
|
||||
virtual void SetType([[maybe_unused]] EViewportType type) { assert(type == ET_ViewportCamera); };
|
||||
static EditorViewportWidget* GetPrimaryViewport();
|
||||
|
||||
virtual ~EditorViewportWidget();
|
||||
// Used by ViewPan in some circumstances
|
||||
void ConnectViewportInteractionRequestBus();
|
||||
void DisconnectViewportInteractionRequestBus();
|
||||
|
||||
Q_INVOKABLE void InjectFakeMouseMove(int deltaX, int deltaY, Qt::MouseButtons buttons);
|
||||
// QtViewport/IDisplayViewport/CViewport
|
||||
// These methods are made public in the derived class because they are called with an object whose static type is known to be this class type.
|
||||
void SetFOV(float fov) override;
|
||||
float GetFOV() const override;
|
||||
|
||||
// Replacement for still used CRenderer methods
|
||||
void UnProjectFromScreen(float sx, float sy, float sz, float* px, float* py, float* pz) const;
|
||||
void ProjectToScreen(float ptx, float pty, float ptz, float* sx, float* sy, float* sz) const;
|
||||
private:
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Private types ...
|
||||
|
||||
public:
|
||||
virtual void Update();
|
||||
|
||||
virtual void ResetContent();
|
||||
virtual void UpdateContent(int flags);
|
||||
|
||||
void OnTitleMenu(QMenu* menu) override;
|
||||
|
||||
void SetCamera(const CCamera& camera);
|
||||
const CCamera& GetCamera() const { return m_Camera; };
|
||||
virtual void SetViewTM(const Matrix34& tm)
|
||||
enum class ViewSourceType
|
||||
{
|
||||
if (m_viewSourceType == ViewSourceType::None)
|
||||
{
|
||||
m_defaultViewTM = tm;
|
||||
}
|
||||
SetViewTM(tm, false);
|
||||
}
|
||||
None,
|
||||
CameraComponent,
|
||||
ViewSourceTypesCount,
|
||||
};
|
||||
enum class PlayInEditorState
|
||||
{
|
||||
Editor, Starting, Started
|
||||
};
|
||||
enum class KeyPressedState
|
||||
{
|
||||
AllUp,
|
||||
PressedThisFrame,
|
||||
PressedInPreviousFrame,
|
||||
};
|
||||
|
||||
//! Map world space position to viewport position.
|
||||
virtual QPoint WorldToView(const Vec3& wp) const;
|
||||
virtual QPoint WorldToViewParticleEditor(const Vec3& wp, int width, int height) const;
|
||||
virtual Vec3 WorldToView3D(const Vec3& wp, int nFlags = 0) const;
|
||||
|
||||
//! Map viewport position to world space position.
|
||||
virtual Vec3 ViewToWorld(const QPoint& vp, bool* collideWithTerrain = nullptr, bool onlyTerrain = false, bool bSkipVegetation = false, bool bTestRenderMesh = false, bool* collideWithObject = nullptr) const override;
|
||||
virtual void ViewToWorldRay(const QPoint& vp, Vec3& raySrc, Vec3& rayDir) const override;
|
||||
virtual Vec3 ViewToWorldNormal(const QPoint& vp, bool onlyTerrain, bool bTestRenderMesh = false) override;
|
||||
virtual float GetScreenScaleFactor(const Vec3& worldPoint) const;
|
||||
virtual float GetScreenScaleFactor(const CCamera& camera, const Vec3& object_position);
|
||||
virtual float GetAspectRatio() const;
|
||||
virtual bool HitTest(const QPoint& point, HitContext& hitInfo);
|
||||
virtual bool IsBoundsVisible(const AABB& box) const;
|
||||
virtual void CenterOnSelection();
|
||||
virtual void CenterOnAABB(const AABB& aabb);
|
||||
void CenterOnSliceInstance() override;
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Method overrides ...
|
||||
|
||||
// QWidget
|
||||
void focusOutEvent(QFocusEvent* event) override;
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
bool event(QEvent* event) override;
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
|
||||
void SetFOV(float fov);
|
||||
float GetFOV() const;
|
||||
// QtViewport/IDisplayViewport/CViewport
|
||||
EViewportType GetType() const override { return ET_ViewportCamera; }
|
||||
void SetType([[maybe_unused]] EViewportType type) override { assert(type == ET_ViewportCamera); };
|
||||
AzToolsFramework::ViewportInteraction::MouseInteraction BuildMouseInteraction(
|
||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, const QPoint& point) override;
|
||||
void SetViewportId(int id) override;
|
||||
QPoint WorldToView(const Vec3& wp) const override;
|
||||
QPoint WorldToViewParticleEditor(const Vec3& wp, int width, int height) const override;
|
||||
Vec3 WorldToView3D(const Vec3& wp, int nFlags = 0) const override;
|
||||
Vec3 ViewToWorld(const QPoint& vp, bool* collideWithTerrain = nullptr, bool onlyTerrain = false, bool bSkipVegetation = false, bool bTestRenderMesh = false, bool* collideWithObject = nullptr) const override;
|
||||
void ViewToWorldRay(const QPoint& vp, Vec3& raySrc, Vec3& rayDir) const override;
|
||||
Vec3 ViewToWorldNormal(const QPoint& vp, bool onlyTerrain, bool bTestRenderMesh = false) override;
|
||||
float GetScreenScaleFactor(const Vec3& worldPoint) const override;
|
||||
float GetScreenScaleFactor(const CCamera& camera, const Vec3& object_position) override;
|
||||
float GetAspectRatio() const override;
|
||||
bool HitTest(const QPoint& point, HitContext& hitInfo) override;
|
||||
bool IsBoundsVisible(const AABB& box) const override;
|
||||
void CenterOnSelection() override;
|
||||
void CenterOnAABB(const AABB& aabb) override;
|
||||
void CenterOnSliceInstance() override;
|
||||
void OnTitleMenu(QMenu* menu) override;
|
||||
void SetViewTM(const Matrix34& tm) override;
|
||||
const Matrix34& GetViewTM() const override;
|
||||
void Update() override;
|
||||
void UpdateContent(int flags) override;
|
||||
|
||||
void SetDefaultCamera();
|
||||
bool IsDefaultCamera() const;
|
||||
void SetSequenceCamera();
|
||||
bool IsSequenceCamera() const { return m_viewSourceType == ViewSourceType::SequenceCamera; }
|
||||
void SetSelectedCamera();
|
||||
bool IsSelectedCamera() const;
|
||||
void SetComponentCamera(const AZ::EntityId& entityId);
|
||||
void SetEntityAsCamera(const AZ::EntityId& entityId, bool lockCameraMovement = false);
|
||||
void SetFirstComponentCamera();
|
||||
void SetViewEntity(const AZ::EntityId& cameraEntityId, bool lockCameraMovement = false);
|
||||
void PostCameraSet();
|
||||
// This switches the active camera to the next one in the list of (default, all custom cams).
|
||||
void CycleCamera();
|
||||
// SceneNotificationBus
|
||||
void OnBeginPrepareRender() override;
|
||||
|
||||
// Camera::EditorCameraRequestBus
|
||||
void SetViewFromEntityPerspective(const AZ::EntityId& entityId) override;
|
||||
void SetViewAndMovementLockFromEntityPerspective(const AZ::EntityId& entityId, bool lockCameraMovement) override;
|
||||
AZ::EntityId GetCurrentViewEntityId() override { return m_viewEntityId; }
|
||||
bool GetActiveCameraPosition(AZ::Vector3& cameraPos) override;
|
||||
bool GetActiveCameraState(AzFramework::CameraState& cameraState) override;
|
||||
// Camera::CameraNotificationBus
|
||||
void OnActiveViewChanged(const AZ::EntityId&) override;
|
||||
|
||||
// IEditorEventListener
|
||||
void OnEditorNotifyEvent(EEditorNotifyEvent event) override;
|
||||
|
||||
// AzToolsFramework::EditorEntityContextNotificationBus (handler moved to cpp to resolve link issues in unity builds)
|
||||
virtual void OnStartPlayInEditor();
|
||||
virtual void OnStopPlayInEditor();
|
||||
void OnStartPlayInEditor();
|
||||
void OnStopPlayInEditor();
|
||||
void OnStartPlayInEditorBegin();
|
||||
|
||||
AzFramework::CameraState GetCameraState();
|
||||
AzFramework::ScreenPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition);
|
||||
// IUndoManagerListener
|
||||
void BeginUndoTransaction() override;
|
||||
void EndUndoTransaction() override;
|
||||
|
||||
// AzFramework::InputSystemCursorConstraintRequestBus
|
||||
void* GetSystemCursorConstraintWindow() const override;
|
||||
|
||||
// AzToolsFramework::ViewportFreezeRequestBus
|
||||
bool IsViewportInputFrozen() override;
|
||||
@@ -204,142 +195,19 @@ public:
|
||||
void BeginWidgetContext() override;
|
||||
void EndWidgetContext() override;
|
||||
|
||||
// CViewport...
|
||||
void SetViewportId(int id) override;
|
||||
|
||||
void ConnectViewportInteractionRequestBus();
|
||||
void DisconnectViewportInteractionRequestBus();
|
||||
|
||||
void LockCameraMovement(bool bLock) { m_bLockCameraMovement = bLock; }
|
||||
bool IsCameraMovementLocked() const { return m_bLockCameraMovement; }
|
||||
|
||||
void EnableCameraObjectMove(bool bMove) { m_bMoveCameraObject = bMove; }
|
||||
bool IsCameraObjectMove() const { return m_bMoveCameraObject; }
|
||||
|
||||
void SetPlayerControl(uint32 i) { m_PlayerControl = i; };
|
||||
uint32 GetPlayerControl() { return m_PlayerControl; };
|
||||
|
||||
const DisplayContext& GetDisplayContext() const { return m_displayContext; }
|
||||
CBaseObject* GetCameraObject() const;
|
||||
|
||||
QPoint WidgetToViewport(const QPoint& point) const;
|
||||
QPoint ViewportToWidget(const QPoint& point) const;
|
||||
QSize WidgetToViewport(const QSize& size) const;
|
||||
|
||||
AzToolsFramework::ViewportInteraction::MouseInteraction BuildMouseInteraction(
|
||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, const QPoint& point) override;
|
||||
|
||||
void SetPlayerPos()
|
||||
{
|
||||
Matrix34 m = GetViewTM();
|
||||
m.SetTranslation(m.GetTranslation() - m_PhysicalLocation.t);
|
||||
SetViewTM(m);
|
||||
|
||||
m_AverageFrameTime = 0.14f;
|
||||
|
||||
m_PhysicalLocation.SetIdentity();
|
||||
|
||||
m_LocalEntityMat.SetIdentity();
|
||||
m_PrevLocalEntityMat.SetIdentity();
|
||||
|
||||
m_absCameraHigh = 2.0f;
|
||||
m_absCameraPos = Vec3(0, 3, 2);
|
||||
m_absCameraPosVP = Vec3(0, -3, 1.5);
|
||||
|
||||
m_absCurrentSlope = 0.0f;
|
||||
|
||||
m_absLookDirectionXY = Vec2(0, 1);
|
||||
|
||||
m_LookAt = Vec3(ZERO);
|
||||
m_LookAtRate = Vec3(ZERO);
|
||||
m_vCamPos = Vec3(ZERO);
|
||||
m_vCamPosRate = Vec3(ZERO);
|
||||
|
||||
m_relCameraRotX = 0;
|
||||
m_relCameraRotZ = 0;
|
||||
|
||||
uint32 numSample6 = m_arrAnimatedCharacterPath.size();
|
||||
for (uint32 i = 0; i < numSample6; i++)
|
||||
{
|
||||
m_arrAnimatedCharacterPath[i] = Vec3(ZERO);
|
||||
}
|
||||
|
||||
numSample6 = m_arrSmoothEntityPath.size();
|
||||
for (uint32 i = 0; i < numSample6; i++)
|
||||
{
|
||||
m_arrSmoothEntityPath[i] = Vec3(ZERO);
|
||||
}
|
||||
|
||||
uint32 numSample7 = m_arrRunStrafeSmoothing.size();
|
||||
for (uint32 i = 0; i < numSample7; i++)
|
||||
{
|
||||
m_arrRunStrafeSmoothing[i] = 0;
|
||||
}
|
||||
|
||||
m_vWorldDesiredBodyDirection = Vec2(0, 1);
|
||||
m_vWorldDesiredBodyDirectionSmooth = Vec2(0, 1);
|
||||
m_vWorldDesiredBodyDirectionSmoothRate = Vec2(0, 1);
|
||||
|
||||
m_vWorldDesiredBodyDirection2 = Vec2(0, 1);
|
||||
|
||||
m_vWorldDesiredMoveDirection = Vec2(0, 1);
|
||||
m_vWorldDesiredMoveDirectionSmooth = Vec2(0, 1);
|
||||
m_vWorldDesiredMoveDirectionSmoothRate = Vec2(0, 1);
|
||||
m_vLocalDesiredMoveDirection = Vec2(0, 1);
|
||||
m_vLocalDesiredMoveDirectionSmooth = Vec2(0, 1);
|
||||
m_vLocalDesiredMoveDirectionSmoothRate = Vec2(0, 1);
|
||||
|
||||
m_vWorldAimBodyDirection = Vec2(0, 1);
|
||||
|
||||
m_MoveSpeedMSec = 5.0f;
|
||||
m_key_W = 0;
|
||||
m_keyrcr_W = 0;
|
||||
m_key_S = 0;
|
||||
m_keyrcr_S = 0;
|
||||
m_key_A = 0;
|
||||
m_keyrcr_A = 0;
|
||||
m_key_D = 0;
|
||||
m_keyrcr_D = 0;
|
||||
m_key_SPACE = 0;
|
||||
m_keyrcr_SPACE = 0;
|
||||
m_ControllMode = 0;
|
||||
|
||||
m_State = -1;
|
||||
m_Stance = 1; //combat
|
||||
|
||||
m_udGround = 0.0f;
|
||||
m_lrGround = 0.0f;
|
||||
AABB aabb = AABB(Vec3(-40.0f, -40.0f, -0.25f), Vec3(+40.0f, +40.0f, +0.0f));
|
||||
m_GroundOBB = OBB::CreateOBBfromAABB(Matrix33(IDENTITY), aabb);
|
||||
m_GroundOBBPos = Vec3(0, 0, -0.01f);
|
||||
};
|
||||
|
||||
static EditorViewportWidget* GetPrimaryViewport();
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
CCamera m_Camera;
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
protected:
|
||||
struct SScopedCurrentContext;
|
||||
// Camera::EditorCameraRequestBus
|
||||
void SetViewFromEntityPerspective(const AZ::EntityId& entityId) override;
|
||||
void SetViewAndMovementLockFromEntityPerspective(const AZ::EntityId& entityId, bool lockCameraMovement) override;
|
||||
AZ::EntityId GetCurrentViewEntityId() override;
|
||||
bool GetActiveCameraPosition(AZ::Vector3& cameraPos) override;
|
||||
bool GetActiveCameraState(AzFramework::CameraState& cameraState) override;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Private helpers...
|
||||
void SetViewTM(const Matrix34& tm, bool bMoveOnly);
|
||||
|
||||
// Called to render stuff.
|
||||
virtual void OnRender();
|
||||
|
||||
virtual void OnEditorNotifyEvent(EEditorNotifyEvent event);
|
||||
|
||||
//! Get currently active camera object.
|
||||
void ToggleCameraObject();
|
||||
|
||||
void RenderConstructionPlane();
|
||||
void RenderSnapMarker();
|
||||
|
||||
void RenderAll();
|
||||
|
||||
void OnBeginPrepareRender() override;
|
||||
|
||||
// Update the safe frame, safe action, safe title, and borders rectangles based on
|
||||
// viewport size and target aspect ratio.
|
||||
void UpdateSafeFrame();
|
||||
@@ -353,193 +221,41 @@ protected:
|
||||
// Draw a selected region if it has been selected
|
||||
void RenderSelectedRegion();
|
||||
|
||||
virtual bool CreateRenderContext();
|
||||
virtual void DestroyRenderContext();
|
||||
|
||||
void OnMenuCommandChangeAspectRatio(unsigned int commandId);
|
||||
|
||||
bool AdjustObjectPosition(const ray_hit& hit, Vec3& outNormal, Vec3& outPos) const;
|
||||
bool RayRenderMeshIntersection(IRenderMesh* pRenderMesh, const Vec3& vInPos, const Vec3& vInDir, Vec3& vOutPos, Vec3& vOutNormal) const;
|
||||
|
||||
bool AddCameraMenuItems(QMenu* menu);
|
||||
void ResizeView(int width, int height);
|
||||
|
||||
void OnCameraFOVVariableChanged(IVariable* var);
|
||||
|
||||
void HideCursor();
|
||||
void ShowCursor();
|
||||
|
||||
bool IsKeyDown(Qt::Key key) const;
|
||||
double WidgetToViewportFactor() const;
|
||||
|
||||
enum class ViewSourceType
|
||||
{
|
||||
None,
|
||||
SequenceCamera,
|
||||
LegacyCamera,
|
||||
CameraComponent,
|
||||
AZ_Entity,
|
||||
ViewSourceTypesCount,
|
||||
};
|
||||
void ResetToViewSourceType(const ViewSourceType& viewSourType);
|
||||
|
||||
bool ShouldPreviewFullscreen() const;
|
||||
bool ShouldPreviewFullscreen();
|
||||
void StartFullscreenPreview();
|
||||
void StopFullscreenPreview();
|
||||
|
||||
bool m_inFullscreenPreview = false;
|
||||
bool m_bRenderContextCreated = false;
|
||||
bool m_bInRotateMode = false;
|
||||
bool m_bInMoveMode = false;
|
||||
bool m_bInOrbitMode = false;
|
||||
bool m_bInZoomMode = false;
|
||||
|
||||
QPoint m_mousePos = QPoint(0, 0);
|
||||
QPoint m_prevMousePos = QPoint(0, 0); // for tablets, you can't use SetCursorPos and need to remember the prior point and delta with that.
|
||||
|
||||
|
||||
float m_moveSpeed = 1;
|
||||
|
||||
float m_orbitDistance = 10.0f;
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
Vec3 m_orbitTarget;
|
||||
|
||||
//-------------------------------------------
|
||||
//--- player-control in CharEdit ---
|
||||
//-------------------------------------------
|
||||
f32 m_MoveSpeedMSec;
|
||||
|
||||
uint32 m_key_W, m_keyrcr_W;
|
||||
uint32 m_key_S, m_keyrcr_S;
|
||||
uint32 m_key_A, m_keyrcr_A;
|
||||
uint32 m_key_D, m_keyrcr_D;
|
||||
|
||||
uint32 m_key_SPACE, m_keyrcr_SPACE;
|
||||
uint32 m_ControllMode;
|
||||
|
||||
int32 m_Stance;
|
||||
int32 m_State;
|
||||
f32 m_AverageFrameTime;
|
||||
|
||||
uint32 m_PlayerControl = 0;
|
||||
|
||||
f32 m_absCameraHigh;
|
||||
Vec3 m_absCameraPos;
|
||||
Vec3 m_absCameraPosVP;
|
||||
|
||||
f32 m_absCurrentSlope; //in radiants
|
||||
|
||||
Vec2 m_absLookDirectionXY;
|
||||
|
||||
Vec3 m_LookAt;
|
||||
Vec3 m_LookAtRate;
|
||||
Vec3 m_vCamPos;
|
||||
Vec3 m_vCamPosRate;
|
||||
float m_camFOV;
|
||||
|
||||
f32 m_relCameraRotX;
|
||||
f32 m_relCameraRotZ;
|
||||
|
||||
QuatTS m_PhysicalLocation;
|
||||
|
||||
Matrix34 m_AnimatedCharacterMat;
|
||||
|
||||
Matrix34 m_LocalEntityMat; //this is used for data-driven animations where the character is running on the spot
|
||||
Matrix34 m_PrevLocalEntityMat;
|
||||
|
||||
std::vector<Vec3> m_arrVerticesHF;
|
||||
std::vector<vtx_idx> m_arrIndicesHF;
|
||||
|
||||
std::vector<Vec3> m_arrAnimatedCharacterPath;
|
||||
std::vector<Vec3> m_arrSmoothEntityPath;
|
||||
std::vector<f32> m_arrRunStrafeSmoothing;
|
||||
|
||||
Vec2 m_vWorldDesiredBodyDirection;
|
||||
Vec2 m_vWorldDesiredBodyDirectionSmooth;
|
||||
Vec2 m_vWorldDesiredBodyDirectionSmoothRate;
|
||||
|
||||
Vec2 m_vWorldDesiredBodyDirection2;
|
||||
|
||||
|
||||
Vec2 m_vWorldDesiredMoveDirection;
|
||||
Vec2 m_vWorldDesiredMoveDirectionSmooth;
|
||||
Vec2 m_vWorldDesiredMoveDirectionSmoothRate;
|
||||
Vec2 m_vLocalDesiredMoveDirection;
|
||||
Vec2 m_vLocalDesiredMoveDirectionSmooth;
|
||||
Vec2 m_vLocalDesiredMoveDirectionSmoothRate;
|
||||
Vec2 m_vWorldAimBodyDirection;
|
||||
|
||||
f32 m_udGround;
|
||||
f32 m_lrGround;
|
||||
OBB m_GroundOBB;
|
||||
Vec3 m_GroundOBBPos;
|
||||
|
||||
// Index of camera objects.
|
||||
mutable GUID m_cameraObjectId;
|
||||
mutable AZ::EntityId m_viewEntityId;
|
||||
mutable ViewSourceType m_viewSourceType = ViewSourceType::None;
|
||||
AZ::EntityId m_viewEntityIdCachedForEditMode;
|
||||
Matrix34 m_preGameModeViewTM;
|
||||
uint m_disableRenderingCount = 0;
|
||||
bool m_bLockCameraMovement;
|
||||
bool m_bUpdateViewport = false;
|
||||
bool m_bMoveCameraObject = true;
|
||||
|
||||
enum class KeyPressedState
|
||||
{
|
||||
AllUp,
|
||||
PressedThisFrame,
|
||||
PressedInPreviousFrame,
|
||||
};
|
||||
KeyPressedState m_pressedKeyState = KeyPressedState::AllUp;
|
||||
|
||||
Matrix34 m_defaultViewTM;
|
||||
const QString m_defaultViewName;
|
||||
|
||||
DisplayContext m_displayContext;
|
||||
|
||||
|
||||
bool m_isOnPaint = false;
|
||||
static EditorViewportWidget* m_pPrimaryViewport;
|
||||
|
||||
QRect m_safeFrame;
|
||||
QRect m_safeAction;
|
||||
QRect m_safeTitle;
|
||||
|
||||
CPredefinedAspectRatios m_predefinedAspectRatios;
|
||||
|
||||
bool m_bCursorHidden = false;
|
||||
|
||||
void OnMenuResolutionCustom();
|
||||
void OnMenuCreateCameraEntityFromCurrentView();
|
||||
void OnMenuSelectCurrentCamera();
|
||||
|
||||
int OnCreate();
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
|
||||
// From a series of input primitives, compose a complete mouse interaction.
|
||||
AzToolsFramework::ViewportInteraction::MouseInteraction BuildMouseInteractionInternal(
|
||||
AzToolsFramework::ViewportInteraction::MouseButtons buttons,
|
||||
AzToolsFramework::ViewportInteraction::KeyboardModifiers modifiers,
|
||||
const AzToolsFramework::ViewportInteraction::MousePick& mousePick) const;
|
||||
|
||||
// Given a point in the viewport, return the pick ray into the scene.
|
||||
// note: The argument passed to parameter **point**, originating
|
||||
// from a Qt event, must first be passed to WidgetToViewport before being
|
||||
// passed to BuildMousePick.
|
||||
AzToolsFramework::ViewportInteraction::MousePick BuildMousePick(const QPoint& point);
|
||||
|
||||
bool event(QEvent* event) override;
|
||||
void OnDestroy();
|
||||
|
||||
bool CheckRespondToInput() const;
|
||||
|
||||
// AzFramework::InputSystemCursorConstraintRequestBus
|
||||
void* GetSystemCursorConstraintWindow() const override;
|
||||
|
||||
void BuildDragDropContext(AzQtComponents::ViewportDragContext& context, const QPoint& pt) override;
|
||||
|
||||
private:
|
||||
void SetAsActiveViewport();
|
||||
void PushDisableRendering();
|
||||
void PopDisableRendering();
|
||||
@@ -547,48 +263,131 @@ private:
|
||||
AzToolsFramework::ViewportInteraction::MousePick BuildMousePickInternal(const QPoint& point) const;
|
||||
|
||||
void RestoreViewportAfterGameMode();
|
||||
void UpdateCameraFromViewportContext();
|
||||
|
||||
double WidgetToViewportFactor() const
|
||||
{
|
||||
#if defined(AZ_PLATFORM_WINDOWS)
|
||||
// Needed for high DPI mode on windows
|
||||
return devicePixelRatioF();
|
||||
#else
|
||||
return 1.0f;
|
||||
#endif
|
||||
}
|
||||
|
||||
void BeginUndoTransaction() override;
|
||||
void EndUndoTransaction() override;
|
||||
|
||||
void UpdateCurrentMousePos(const QPoint& newPosition);
|
||||
void UpdateScene();
|
||||
|
||||
void SetDefaultCamera();
|
||||
void SetSelectedCamera();
|
||||
bool IsSelectedCamera() const;
|
||||
void SetComponentCamera(const AZ::EntityId& entityId);
|
||||
void SetEntityAsCamera(const AZ::EntityId& entityId, bool lockCameraMovement = false);
|
||||
void SetFirstComponentCamera();
|
||||
void PostCameraSet();
|
||||
// This switches the active camera to the next one in the list of (default, all custom cams).
|
||||
void CycleCamera();
|
||||
|
||||
AzFramework::CameraState GetCameraState();
|
||||
AzFramework::ScreenPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition);
|
||||
|
||||
QPoint WidgetToViewport(const QPoint& point) const;
|
||||
QPoint ViewportToWidget(const QPoint& point) const;
|
||||
QSize WidgetToViewport(const QSize& size) const;
|
||||
|
||||
const DisplayContext& GetDisplayContext() const { return m_displayContext; }
|
||||
CBaseObject* GetCameraObject() const;
|
||||
|
||||
void UnProjectFromScreen(float sx, float sy, float sz, float* px, float* py, float* pz) const;
|
||||
void ProjectToScreen(float ptx, float pty, float ptz, float* sx, float* sy, float* sz) const;
|
||||
|
||||
AZ::RPI::ViewPtr GetCurrentAtomView() const;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Members ...
|
||||
friend class AZ::ViewportHelpers::EditorEntityNotifications;
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
// Singleton for the primary viewport
|
||||
static EditorViewportWidget* m_pPrimaryViewport;
|
||||
|
||||
// The simulation (play-game in editor) state
|
||||
PlayInEditorState m_playInEditorState = PlayInEditorState::Editor;
|
||||
|
||||
// Whether we are doing a full screen game preview (play-game in editor) or a regular one
|
||||
bool m_inFullscreenPreview = false;
|
||||
|
||||
// The entity ID of the current camera for this viewport, or invalid if the default editor camera
|
||||
AZ::EntityId m_viewEntityId;
|
||||
|
||||
// Determines also if the current camera for this viewport is default editor camera
|
||||
ViewSourceType m_viewSourceType = ViewSourceType::None;
|
||||
|
||||
// During play game in editor, holds the editor entity ID of the last
|
||||
AZ::EntityId m_viewEntityIdCachedForEditMode;
|
||||
|
||||
// The editor camera TM before switching to game mode
|
||||
Matrix34 m_preGameModeViewTM;
|
||||
|
||||
// Disables rendering during some periods of time, e.g. undo/redo, resize events
|
||||
uint m_disableRenderingCount = 0;
|
||||
|
||||
// Determines if the viewport needs updating (false when out of focus for example)
|
||||
bool m_bUpdateViewport = false;
|
||||
|
||||
// Avoid re-entering PostCameraSet->OnActiveViewChanged->PostCameraSet
|
||||
bool m_sendingOnActiveChanged = false;
|
||||
|
||||
// Legacy...
|
||||
KeyPressedState m_pressedKeyState = KeyPressedState::AllUp;
|
||||
|
||||
// The last camera matrix of the default editor camera, used when switching back to editor camera to restore the right TM
|
||||
Matrix34 m_defaultViewTM;
|
||||
|
||||
// The name to use for the default editor camera
|
||||
const QString m_defaultViewName;
|
||||
|
||||
// Note that any attempts to draw anything with this object will crash. Exists here for legacy "reasons"
|
||||
DisplayContext m_displayContext;
|
||||
|
||||
// Re-entrency guard for on paint events
|
||||
bool m_isOnPaint = false;
|
||||
|
||||
// Shapes of various safe frame helpers which can be displayed in the editor
|
||||
QRect m_safeFrame;
|
||||
QRect m_safeAction;
|
||||
QRect m_safeTitle;
|
||||
|
||||
// Aspect ratios available in the title bar
|
||||
CPredefinedAspectRatios m_predefinedAspectRatios;
|
||||
|
||||
// Is the cursor hidden or displayed?
|
||||
bool m_bCursorHidden = false;
|
||||
|
||||
// Shim for QtViewport, which used to be responsible for visibility queries in the editor,
|
||||
// these are now forwarded to EntityVisibilityQuery
|
||||
AzFramework::EntityVisibilityQuery m_entityVisibilityQuery;
|
||||
|
||||
// Handlers for grid snapping/editor event callbacks
|
||||
SandboxEditor::GridSnappingChangedEvent::Handler m_gridSnappingHandler;
|
||||
AZStd::unique_ptr<SandboxEditor::EditorViewportSettingsCallbacks> m_editorViewportSettingsCallbacks;
|
||||
|
||||
// Used for some legacy logic which lets the widget release a grabbed keyboard at the right times
|
||||
// Unclear if it's still necessary.
|
||||
QSet<int> m_keyDown;
|
||||
|
||||
// State for ViewportFreezeRequestBus, currently does nothing
|
||||
bool m_freezeViewportInput = false;
|
||||
|
||||
// This widget holds a reference to the manipulator manage because its responsible for drawing manipulators
|
||||
AZStd::shared_ptr<AzToolsFramework::ManipulatorManager> m_manipulatorManager;
|
||||
|
||||
// Used to prevent circular set camera events
|
||||
bool m_ignoreSetViewFromEntityPerspective = false;
|
||||
bool m_windowResizedEvent = false;
|
||||
|
||||
// Helper for getting EditorEntityNotificationBus events
|
||||
AZStd::unique_ptr<AZ::ViewportHelpers::EditorEntityNotifications> m_editorEntityNotifications;
|
||||
|
||||
// The widget to which Atom will actually render
|
||||
AtomToolsFramework::RenderViewportWidget* m_renderViewport = nullptr;
|
||||
|
||||
bool m_updateCameraPositionNextTick = false;
|
||||
AZ::RPI::ViewportContext::MatrixChangedEvent::Handler m_cameraViewMatrixChangeHandler;
|
||||
AZ::RPI::ViewportContext::MatrixChangedEvent::Handler m_cameraProjectionMatrixChangeHandler;
|
||||
// Atom debug display
|
||||
AzFramework::DebugDisplayRequests* m_debugDisplay = nullptr;
|
||||
|
||||
// The default view created for the viewport context, which is used as the "Editor Camera"
|
||||
AZ::RPI::ViewPtr m_defaultView;
|
||||
|
||||
// The name to set on the viewport context when this viewport widget is set as the active one
|
||||
AZ::Name m_defaultViewportContextName;
|
||||
|
||||
// DO NOT USE THIS! It exists only to satisfy the signature of the base class method GetViewTm
|
||||
mutable Matrix34 m_viewTmStorage;
|
||||
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
};
|
||||
|
||||
@@ -662,11 +662,11 @@ bool CExportManager::ProcessObjectsForExport()
|
||||
GetIEditor()->GetAnimation()->SetRecording(false);
|
||||
GetIEditor()->GetAnimation()->SetPlaying(false);
|
||||
|
||||
CViewport* vp = GetIEditor()->GetViewManager()->GetSelectedViewport();
|
||||
if (CRenderViewport* rvp = viewport_cast<CRenderViewport*>(vp))
|
||||
{
|
||||
rvp->SetSequenceCamera();
|
||||
}
|
||||
//CViewport* vp = GetIEditor()->GetViewManager()->GetSelectedViewport();
|
||||
//if (CRenderViewport* rvp = viewport_cast<CRenderViewport*>(vp))
|
||||
//{
|
||||
// rvp->SetSequenceCamera();
|
||||
//}
|
||||
|
||||
int startFrame = 0;
|
||||
timeValue = startFrame * fpsTimeInterval;
|
||||
|
||||
@@ -572,8 +572,6 @@ void CGameEngine::SwitchToInGame()
|
||||
m_pISystem->GetIMovieSystem()->EnablePhysicsEvents(true);
|
||||
m_bInGameMode = true;
|
||||
|
||||
gEnv->pSystem->GetViewCamera().SetMatrix(m_playerViewTM);
|
||||
|
||||
// Disable accelerators.
|
||||
GetIEditor()->EnableAcceleratos(false);
|
||||
//! Send event to switch into game.
|
||||
@@ -627,13 +625,6 @@ void CGameEngine::SwitchToInEditor()
|
||||
|
||||
m_bInGameMode = false;
|
||||
|
||||
// save the current gameView matrix for editor
|
||||
if (pGameViewport)
|
||||
{
|
||||
Matrix34 gameView = gEnv->pSystem->GetViewCamera().GetMatrix();
|
||||
pGameViewport->SetGameTM(gameView);
|
||||
}
|
||||
|
||||
// Out of game in Editor mode.
|
||||
if (pGameViewport)
|
||||
{
|
||||
|
||||
@@ -32,7 +32,11 @@
|
||||
#include <AzCore/Console/Console.h>
|
||||
|
||||
AZ_CVAR_EXTERNED(bool, ed_visibility_logTiming);
|
||||
AZ_CVAR_EXTERNED(bool, ed_visibility_use);
|
||||
|
||||
AZ_CVAR(
|
||||
bool, ed_visibility_use, true, nullptr, AZ::ConsoleFunctorFlags::Null,
|
||||
"Enable/disable using the new IVisibilitySystem for Entity visibility determination");
|
||||
|
||||
|
||||
/*!
|
||||
* Class Description used for object templates.
|
||||
@@ -1327,7 +1331,7 @@ void CObjectManager::FindDisplayableObjects(DisplayContext& dc, [[maybe_unused]]
|
||||
|
||||
pDispayedViewObjects->SetSerialNumber(m_visibilitySerialNumber); // update viewport to be latest serial number
|
||||
|
||||
const CCamera& camera = GetIEditor()->GetSystem()->GetViewCamera();
|
||||
//const CCamera& camera = GetIEditor()->GetSystem()->GetViewCamera();
|
||||
AABB bbox;
|
||||
bbox.min.zero();
|
||||
bbox.max.zero();
|
||||
@@ -1376,11 +1380,11 @@ void CObjectManager::FindDisplayableObjects(DisplayContext& dc, [[maybe_unused]]
|
||||
{
|
||||
CBaseObject* obj = m_visibleObjects[i];
|
||||
|
||||
if (obj && obj->IsInCameraView(camera))
|
||||
if (obj /* && obj->IsInCameraView(camera)*/)
|
||||
{
|
||||
// Check if object is too far.
|
||||
float visRatio = obj->GetCameraVisRatio(camera);
|
||||
if (visRatio > m_maxObjectViewDistRatio || (dc.flags & DISPLAY_SELECTION_HELPERS) || obj->IsSelected())
|
||||
// float visRatio = obj->GetCameraVisRatio(camera);
|
||||
if (/*visRatio > m_maxObjectViewDistRatio || */ (dc.flags & DISPLAY_SELECTION_HELPERS) || obj->IsSelected())
|
||||
{
|
||||
pDispayedViewObjects->AddObject(obj);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -51,599 +51,4 @@ namespace AzToolsFramework
|
||||
class ManipulatorManager;
|
||||
}
|
||||
|
||||
// CRenderViewport window
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
class SANDBOX_API CRenderViewport
|
||||
: public QtViewport
|
||||
, public IEditorNotifyListener
|
||||
, public IUndoManagerListener
|
||||
, public Camera::EditorCameraRequestBus::Handler
|
||||
, public AzFramework::InputSystemCursorConstraintRequestBus::Handler
|
||||
, public AzToolsFramework::ViewportInteraction::ViewportFreezeRequestBus::Handler
|
||||
, public AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Handler
|
||||
, public AzToolsFramework::ViewportInteraction::MainEditorViewportInteractionRequestBus::Handler
|
||||
, public AzFramework::WindowRequestBus::Handler
|
||||
{
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
Q_OBJECT
|
||||
public:
|
||||
struct SResolution
|
||||
{
|
||||
SResolution()
|
||||
: width(0)
|
||||
, height(0)
|
||||
{
|
||||
}
|
||||
|
||||
SResolution(int w, int h)
|
||||
: width(w)
|
||||
, height(h)
|
||||
{
|
||||
}
|
||||
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
||||
public:
|
||||
CRenderViewport(const QString& name, QWidget* parent = nullptr);
|
||||
|
||||
static const GUID& GetClassID()
|
||||
{
|
||||
return QtViewport::GetClassID<CRenderViewport>();
|
||||
}
|
||||
|
||||
/** Get type of this viewport.
|
||||
*/
|
||||
virtual EViewportType GetType() const { return ET_ViewportCamera; }
|
||||
virtual void SetType([[maybe_unused]] EViewportType type) { assert(type == ET_ViewportCamera); };
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CRenderViewport();
|
||||
|
||||
Q_INVOKABLE void InjectFakeMouseMove(int deltaX, int deltaY, Qt::MouseButtons buttons);
|
||||
|
||||
public:
|
||||
virtual void Update();
|
||||
|
||||
virtual void ResetContent();
|
||||
virtual void UpdateContent(int flags);
|
||||
|
||||
void OnTitleMenu(QMenu* menu) override;
|
||||
|
||||
void SetCamera(const CCamera& camera);
|
||||
const CCamera& GetCamera() const { return m_Camera; };
|
||||
virtual void SetViewTM(const Matrix34& tm)
|
||||
{
|
||||
if (m_viewSourceType == ViewSourceType::None)
|
||||
{
|
||||
m_defaultViewTM = tm;
|
||||
}
|
||||
SetViewTM(tm, false);
|
||||
}
|
||||
|
||||
//! Map world space position to viewport position.
|
||||
virtual QPoint WorldToView(const Vec3& wp) const;
|
||||
virtual QPoint WorldToViewParticleEditor(const Vec3& wp, int width, int height) const;
|
||||
virtual Vec3 WorldToView3D(const Vec3& wp, int nFlags = 0) const;
|
||||
|
||||
//! Map viewport position to world space position.
|
||||
virtual Vec3 ViewToWorld(const QPoint& vp, bool* collideWithTerrain = nullptr, bool onlyTerrain = false, bool bSkipVegetation = false, bool bTestRenderMesh = false, bool* collideWithObject = nullptr) const override;
|
||||
virtual void ViewToWorldRay(const QPoint& vp, Vec3& raySrc, Vec3& rayDir) const override;
|
||||
virtual Vec3 ViewToWorldNormal(const QPoint& vp, bool onlyTerrain, bool bTestRenderMesh = false) override;
|
||||
virtual float GetScreenScaleFactor(const Vec3& worldPoint) const;
|
||||
virtual float GetScreenScaleFactor(const CCamera& camera, const Vec3& object_position);
|
||||
virtual float GetAspectRatio() const;
|
||||
virtual bool HitTest(const QPoint& point, HitContext& hitInfo);
|
||||
virtual bool IsBoundsVisible(const AABB& box) const;
|
||||
virtual void CenterOnSelection();
|
||||
virtual void CenterOnAABB(const AABB& aabb);
|
||||
void CenterOnSliceInstance() override;
|
||||
|
||||
void focusOutEvent(QFocusEvent* event) override;
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
void keyReleaseEvent(QKeyEvent* event) override;
|
||||
|
||||
void SetFOV(float fov);
|
||||
float GetFOV() const;
|
||||
|
||||
void SetDefaultCamera();
|
||||
bool IsDefaultCamera() const;
|
||||
void SetSequenceCamera();
|
||||
bool IsSequenceCamera() const { return m_viewSourceType == ViewSourceType::SequenceCamera; }
|
||||
void SetSelectedCamera();
|
||||
bool IsSelectedCamera() const;
|
||||
void SetComponentCamera(const AZ::EntityId& entityId);
|
||||
void SetEntityAsCamera(const AZ::EntityId& entityId, bool lockCameraMovement = false);
|
||||
void SetFirstComponentCamera();
|
||||
void SetViewEntity(const AZ::EntityId& cameraEntityId, bool lockCameraMovement = false);
|
||||
void PostCameraSet();
|
||||
// This switches the active camera to the next one in the list of (default, all custom cams).
|
||||
void CycleCamera();
|
||||
|
||||
// Camera::EditorCameraRequestBus
|
||||
void SetViewFromEntityPerspective(const AZ::EntityId& entityId) override;
|
||||
void SetViewAndMovementLockFromEntityPerspective(const AZ::EntityId& entityId, bool lockCameraMovement) override;
|
||||
AZ::EntityId GetCurrentViewEntityId() override { return m_viewEntityId; }
|
||||
bool GetActiveCameraPosition(AZ::Vector3& cameraPos) override;
|
||||
bool GetActiveCameraState(AzFramework::CameraState& cameraState) override;
|
||||
|
||||
// AzToolsFramework::EditorEntityContextNotificationBus (handler moved to cpp to resolve link issues in unity builds)
|
||||
virtual void OnStartPlayInEditor();
|
||||
virtual void OnStopPlayInEditor();
|
||||
|
||||
// AzToolsFramework::EditorContextMenu::Bus (handler moved to cpp to resolve link issues in unity builds)
|
||||
// We use this to determine when the viewport context menu is being displayed so we can exit move mode
|
||||
void PopulateEditorGlobalContextMenu(QMenu* /*menu*/, const AZ::Vector2& /*point*/, int /*flags*/);
|
||||
|
||||
// AzToolsFramework::ViewportInteractionRequestBus
|
||||
AzFramework::CameraState GetCameraState() override;
|
||||
bool GridSnappingEnabled() override;
|
||||
float GridSize() override;
|
||||
bool ShowGrid() override;
|
||||
bool AngleSnappingEnabled() override;
|
||||
float AngleStep() override;
|
||||
AzFramework::ScreenPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition) override;
|
||||
AZStd::optional<AZ::Vector3> ViewportScreenToWorld(const AzFramework::ScreenPoint&, float) override
|
||||
{
|
||||
return {};
|
||||
}
|
||||
AZStd::optional<AzToolsFramework::ViewportInteraction::ProjectedViewportRay> ViewportScreenToWorldRay(
|
||||
const AzFramework::ScreenPoint&) override
|
||||
{
|
||||
return {};
|
||||
}
|
||||
float DeviceScalingFactor() override { return 1.0f; }
|
||||
|
||||
// AzToolsFramework::ViewportFreezeRequestBus
|
||||
bool IsViewportInputFrozen() override;
|
||||
void FreezeViewportInput(bool freeze) override;
|
||||
|
||||
// AzToolsFramework::MainEditorViewportInteractionRequestBus
|
||||
AZ::EntityId PickEntity(const AzFramework::ScreenPoint& point) override;
|
||||
AZ::Vector3 PickTerrain(const AzFramework::ScreenPoint& point) override;
|
||||
float TerrainHeight(const AZ::Vector2& position) override;
|
||||
void FindVisibleEntities(AZStd::vector<AZ::EntityId>& visibleEntitiesOut) override;
|
||||
bool ShowingWorldSpace() override;
|
||||
QWidget* GetWidgetForViewportContextMenu() override;
|
||||
void BeginWidgetContext() override;
|
||||
void EndWidgetContext() override;
|
||||
|
||||
// WindowRequestBus::Handler...
|
||||
void SetWindowTitle(const AZStd::string& title) override;
|
||||
AzFramework::WindowSize GetClientAreaSize() const override;
|
||||
void ResizeClientArea(AzFramework::WindowSize) override;
|
||||
bool GetFullScreenState() const override;
|
||||
void SetFullScreenState(bool fullScreenState) override;
|
||||
bool CanToggleFullScreenState() const override;
|
||||
void ToggleFullScreenState() override;
|
||||
float GetDpiScaleFactor() const override { return 1.0f; };
|
||||
|
||||
void ConnectViewportInteractionRequestBus();
|
||||
void DisconnectViewportInteractionRequestBus();
|
||||
|
||||
void ActivateWindowAndSetFocus();
|
||||
|
||||
void LockCameraMovement(bool bLock) { m_bLockCameraMovement = bLock; }
|
||||
bool IsCameraMovementLocked() const { return m_bLockCameraMovement; }
|
||||
|
||||
void EnableCameraObjectMove(bool bMove) { m_bMoveCameraObject = bMove; }
|
||||
bool IsCameraObjectMove() const { return m_bMoveCameraObject; }
|
||||
|
||||
void SetPlayerControl(uint32 i) { m_PlayerControl = i; };
|
||||
uint32 GetPlayerControl() { return m_PlayerControl; };
|
||||
|
||||
const DisplayContext& GetDisplayContext() const { return m_displayContext; }
|
||||
CBaseObject* GetCameraObject() const;
|
||||
|
||||
QPoint WidgetToViewport(const QPoint& point) const;
|
||||
QPoint ViewportToWidget(const QPoint& point) const;
|
||||
QSize WidgetToViewport(const QSize& size) const;
|
||||
|
||||
AzToolsFramework::ViewportInteraction::MouseInteraction BuildMouseInteraction(
|
||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, const QPoint& point) override;
|
||||
|
||||
void SetPlayerPos()
|
||||
{
|
||||
Matrix34 m = GetViewTM();
|
||||
m.SetTranslation(m.GetTranslation() - m_PhysicalLocation.t);
|
||||
SetViewTM(m);
|
||||
|
||||
m_AverageFrameTime = 0.14f;
|
||||
|
||||
m_PhysicalLocation.SetIdentity();
|
||||
|
||||
m_LocalEntityMat.SetIdentity();
|
||||
m_PrevLocalEntityMat.SetIdentity();
|
||||
|
||||
m_absCameraHigh = 2.0f;
|
||||
m_absCameraPos = Vec3(0, 3, 2);
|
||||
m_absCameraPosVP = Vec3(0, -3, 1.5);
|
||||
|
||||
m_absCurrentSlope = 0.0f;
|
||||
|
||||
m_absLookDirectionXY = Vec2(0, 1);
|
||||
|
||||
m_LookAt = Vec3(ZERO);
|
||||
m_LookAtRate = Vec3(ZERO);
|
||||
m_vCamPos = Vec3(ZERO);
|
||||
m_vCamPosRate = Vec3(ZERO);
|
||||
|
||||
m_relCameraRotX = 0;
|
||||
m_relCameraRotZ = 0;
|
||||
|
||||
uint32 numSample6 = m_arrAnimatedCharacterPath.size();
|
||||
for (uint32 i = 0; i < numSample6; i++)
|
||||
{
|
||||
m_arrAnimatedCharacterPath[i] = Vec3(ZERO);
|
||||
}
|
||||
|
||||
numSample6 = m_arrSmoothEntityPath.size();
|
||||
for (uint32 i = 0; i < numSample6; i++)
|
||||
{
|
||||
m_arrSmoothEntityPath[i] = Vec3(ZERO);
|
||||
}
|
||||
|
||||
uint32 numSample7 = m_arrRunStrafeSmoothing.size();
|
||||
for (uint32 i = 0; i < numSample7; i++)
|
||||
{
|
||||
m_arrRunStrafeSmoothing[i] = 0;
|
||||
}
|
||||
|
||||
m_vWorldDesiredBodyDirection = Vec2(0, 1);
|
||||
m_vWorldDesiredBodyDirectionSmooth = Vec2(0, 1);
|
||||
m_vWorldDesiredBodyDirectionSmoothRate = Vec2(0, 1);
|
||||
|
||||
m_vWorldDesiredBodyDirection2 = Vec2(0, 1);
|
||||
|
||||
m_vWorldDesiredMoveDirection = Vec2(0, 1);
|
||||
m_vWorldDesiredMoveDirectionSmooth = Vec2(0, 1);
|
||||
m_vWorldDesiredMoveDirectionSmoothRate = Vec2(0, 1);
|
||||
m_vLocalDesiredMoveDirection = Vec2(0, 1);
|
||||
m_vLocalDesiredMoveDirectionSmooth = Vec2(0, 1);
|
||||
m_vLocalDesiredMoveDirectionSmoothRate = Vec2(0, 1);
|
||||
|
||||
m_vWorldAimBodyDirection = Vec2(0, 1);
|
||||
|
||||
m_MoveSpeedMSec = 5.0f;
|
||||
m_key_W = 0;
|
||||
m_keyrcr_W = 0;
|
||||
m_key_S = 0;
|
||||
m_keyrcr_S = 0;
|
||||
m_key_A = 0;
|
||||
m_keyrcr_A = 0;
|
||||
m_key_D = 0;
|
||||
m_keyrcr_D = 0;
|
||||
m_key_SPACE = 0;
|
||||
m_keyrcr_SPACE = 0;
|
||||
m_ControllMode = 0;
|
||||
|
||||
m_State = -1;
|
||||
m_Stance = 1; //combat
|
||||
|
||||
m_udGround = 0.0f;
|
||||
m_lrGround = 0.0f;
|
||||
AABB aabb = AABB(Vec3(-40.0f, -40.0f, -0.25f), Vec3(+40.0f, +40.0f, +0.0f));
|
||||
m_GroundOBB = OBB::CreateOBBfromAABB(Matrix33(IDENTITY), aabb);
|
||||
m_GroundOBBPos = Vec3(0, 0, -0.01f);
|
||||
};
|
||||
|
||||
static CRenderViewport* GetPrimaryViewport();
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
CCamera m_Camera;
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
protected:
|
||||
struct SScopedCurrentContext;
|
||||
|
||||
void SetViewTM(const Matrix34& tm, bool bMoveOnly);
|
||||
|
||||
virtual float GetCameraMoveSpeed() const;
|
||||
virtual float GetCameraRotateSpeed() const;
|
||||
virtual bool GetCameraInvertYRotation() const;
|
||||
virtual float GetCameraInvertPan() const;
|
||||
|
||||
// Called to render stuff.
|
||||
virtual void OnRender();
|
||||
|
||||
virtual void OnEditorNotifyEvent(EEditorNotifyEvent event);
|
||||
|
||||
//! Get currently active camera object.
|
||||
void ToggleCameraObject();
|
||||
|
||||
void RenderConstructionPlane();
|
||||
void RenderSnapMarker();
|
||||
void RenderCursorString();
|
||||
void RenderSnappingGrid();
|
||||
void ProcessMouse();
|
||||
void ProcessKeys();
|
||||
|
||||
void RenderAll();
|
||||
void DrawAxis();
|
||||
void DrawBackground();
|
||||
void InitDisplayContext();
|
||||
void ResetCursor();
|
||||
|
||||
struct SPreviousContext
|
||||
{
|
||||
CCamera rendererCamera;
|
||||
HWND window;
|
||||
int width;
|
||||
int height;
|
||||
bool mainViewport;
|
||||
};
|
||||
|
||||
SPreviousContext m_preWidgetContext;
|
||||
|
||||
// Create an auto-sized render context that is sized based on the Editor's current
|
||||
// viewport.
|
||||
SPreviousContext SetCurrentContext() const;
|
||||
|
||||
SPreviousContext SetCurrentContext(int newWidth, int newHeight) const;
|
||||
void RestorePreviousContext(const SPreviousContext& x) const;
|
||||
|
||||
void PreWidgetRendering() override;
|
||||
void PostWidgetRendering() override;
|
||||
|
||||
// Update the safe frame, safe action, safe title, and borders rectangles based on
|
||||
// viewport size and target aspect ratio.
|
||||
void UpdateSafeFrame();
|
||||
|
||||
// Draw safe frame, safe action, safe title rectangles and borders.
|
||||
void RenderSafeFrame();
|
||||
|
||||
// Draw one of the safe frame rectangles with the desired color.
|
||||
void RenderSafeFrame(const QRect& frame, float r, float g, float b, float a);
|
||||
|
||||
// Draw the selection rectangle.
|
||||
void RenderSelectionRectangle();
|
||||
|
||||
// Draw a selected region if it has been selected
|
||||
void RenderSelectedRegion();
|
||||
|
||||
virtual bool CreateRenderContext();
|
||||
virtual void DestroyRenderContext();
|
||||
|
||||
void OnMenuCommandChangeAspectRatio(unsigned int commandId);
|
||||
|
||||
bool AdjustObjectPosition(const ray_hit& hit, Vec3& outNormal, Vec3& outPos) const;
|
||||
bool RayRenderMeshIntersection(IRenderMesh* pRenderMesh, const Vec3& vInPos, const Vec3& vInDir, Vec3& vOutPos, Vec3& vOutNormal) const;
|
||||
|
||||
bool AddCameraMenuItems(QMenu* menu);
|
||||
void ResizeView(int width, int height);
|
||||
|
||||
void OnCameraFOVVariableChanged(IVariable* var);
|
||||
|
||||
void HideCursor();
|
||||
void ShowCursor();
|
||||
|
||||
bool IsKeyDown(Qt::Key key) const;
|
||||
|
||||
enum class ViewSourceType
|
||||
{
|
||||
None,
|
||||
SequenceCamera,
|
||||
LegacyCamera,
|
||||
CameraComponent,
|
||||
AZ_Entity,
|
||||
ViewSourceTypesCount,
|
||||
};
|
||||
void ResetToViewSourceType(const ViewSourceType& viewSourType);
|
||||
|
||||
//! Assigned renderer.
|
||||
IRenderer* m_renderer = nullptr;
|
||||
bool m_bRenderContextCreated = false;
|
||||
bool m_bInRotateMode = false;
|
||||
bool m_bInMoveMode = false;
|
||||
bool m_bInOrbitMode = false;
|
||||
bool m_bInZoomMode = false;
|
||||
|
||||
QPoint m_mousePos = QPoint(0, 0);
|
||||
QPoint m_prevMousePos = QPoint(0, 0); // for tablets, you can't use SetCursorPos and need to remember the prior point and delta with that.
|
||||
|
||||
|
||||
float m_moveSpeed = 1;
|
||||
|
||||
float m_orbitDistance = 10.0f;
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
Vec3 m_orbitTarget;
|
||||
|
||||
//-------------------------------------------
|
||||
//--- player-control in CharEdit ---
|
||||
//-------------------------------------------
|
||||
f32 m_MoveSpeedMSec;
|
||||
|
||||
uint32 m_key_W, m_keyrcr_W;
|
||||
uint32 m_key_S, m_keyrcr_S;
|
||||
uint32 m_key_A, m_keyrcr_A;
|
||||
uint32 m_key_D, m_keyrcr_D;
|
||||
|
||||
uint32 m_key_SPACE, m_keyrcr_SPACE;
|
||||
uint32 m_ControllMode;
|
||||
|
||||
int32 m_Stance;
|
||||
int32 m_State;
|
||||
f32 m_AverageFrameTime;
|
||||
|
||||
uint32 m_PlayerControl = 0;
|
||||
|
||||
f32 m_absCameraHigh;
|
||||
Vec3 m_absCameraPos;
|
||||
Vec3 m_absCameraPosVP;
|
||||
|
||||
f32 m_absCurrentSlope; //in radiants
|
||||
|
||||
Vec2 m_absLookDirectionXY;
|
||||
|
||||
Vec3 m_LookAt;
|
||||
Vec3 m_LookAtRate;
|
||||
Vec3 m_vCamPos;
|
||||
Vec3 m_vCamPosRate;
|
||||
float m_camFOV;
|
||||
|
||||
f32 m_relCameraRotX;
|
||||
f32 m_relCameraRotZ;
|
||||
|
||||
QuatTS m_PhysicalLocation;
|
||||
|
||||
Matrix34 m_AnimatedCharacterMat;
|
||||
|
||||
Matrix34 m_LocalEntityMat; //this is used for data-driven animations where the character is running on the spot
|
||||
Matrix34 m_PrevLocalEntityMat;
|
||||
|
||||
std::vector<Vec3> m_arrVerticesHF;
|
||||
std::vector<vtx_idx> m_arrIndicesHF;
|
||||
|
||||
std::vector<Vec3> m_arrAnimatedCharacterPath;
|
||||
std::vector<Vec3> m_arrSmoothEntityPath;
|
||||
std::vector<f32> m_arrRunStrafeSmoothing;
|
||||
|
||||
Vec2 m_vWorldDesiredBodyDirection;
|
||||
Vec2 m_vWorldDesiredBodyDirectionSmooth;
|
||||
Vec2 m_vWorldDesiredBodyDirectionSmoothRate;
|
||||
|
||||
Vec2 m_vWorldDesiredBodyDirection2;
|
||||
|
||||
|
||||
Vec2 m_vWorldDesiredMoveDirection;
|
||||
Vec2 m_vWorldDesiredMoveDirectionSmooth;
|
||||
Vec2 m_vWorldDesiredMoveDirectionSmoothRate;
|
||||
Vec2 m_vLocalDesiredMoveDirection;
|
||||
Vec2 m_vLocalDesiredMoveDirectionSmooth;
|
||||
Vec2 m_vLocalDesiredMoveDirectionSmoothRate;
|
||||
Vec2 m_vWorldAimBodyDirection;
|
||||
|
||||
f32 m_udGround;
|
||||
f32 m_lrGround;
|
||||
OBB m_GroundOBB;
|
||||
Vec3 m_GroundOBBPos;
|
||||
|
||||
// Index of camera objects.
|
||||
mutable GUID m_cameraObjectId = GUID_NULL;
|
||||
mutable AZ::EntityId m_viewEntityId;
|
||||
mutable ViewSourceType m_viewSourceType = ViewSourceType::None;
|
||||
AZ::EntityId m_viewEntityIdCachedForEditMode;
|
||||
Matrix34 m_preGameModeViewTM;
|
||||
uint m_disableRenderingCount = 0;
|
||||
bool m_bLockCameraMovement;
|
||||
bool m_bUpdateViewport = false;
|
||||
bool m_bMoveCameraObject = true;
|
||||
|
||||
enum class KeyPressedState
|
||||
{
|
||||
AllUp,
|
||||
PressedThisFrame,
|
||||
PressedInPreviousFrame,
|
||||
};
|
||||
KeyPressedState m_pressedKeyState = KeyPressedState::AllUp;
|
||||
|
||||
Matrix34 m_defaultViewTM;
|
||||
const QString m_defaultViewName;
|
||||
|
||||
DisplayContext m_displayContext;
|
||||
|
||||
|
||||
bool m_isOnPaint = false;
|
||||
static CRenderViewport* m_pPrimaryViewport;
|
||||
|
||||
QRect m_safeFrame;
|
||||
QRect m_safeAction;
|
||||
QRect m_safeTitle;
|
||||
|
||||
CPredefinedAspectRatios m_predefinedAspectRatios;
|
||||
|
||||
IVariable* m_pCameraFOVVariable = nullptr;
|
||||
bool m_bCursorHidden = false;
|
||||
|
||||
void OnMenuResolutionCustom();
|
||||
void OnMenuCreateCameraEntityFromCurrentView();
|
||||
void OnMenuSelectCurrentCamera();
|
||||
|
||||
int OnCreate();
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
void OnLButtonDown(Qt::KeyboardModifiers modifiers, const QPoint& point) override;
|
||||
void OnLButtonUp(Qt::KeyboardModifiers modifiers, const QPoint& point) override;
|
||||
void OnLButtonDblClk(Qt::KeyboardModifiers modifiers, const QPoint& point) override;
|
||||
void OnMButtonDown(Qt::KeyboardModifiers modifiers, const QPoint& point) override;
|
||||
void OnMButtonUp(Qt::KeyboardModifiers modifiers, const QPoint& point) override;
|
||||
void OnRButtonDown(Qt::KeyboardModifiers modifiers, const QPoint& point) override;
|
||||
void OnRButtonUp(Qt::KeyboardModifiers modifiers, const QPoint& point) override;
|
||||
void OnMouseMove(Qt::KeyboardModifiers modifiers, Qt::MouseButtons buttons, const QPoint& point) override;
|
||||
void OnMouseWheel(Qt::KeyboardModifiers modifiers, short zDelta, const QPoint& pt) override;
|
||||
|
||||
// From a series of input primitives, compose a complete mouse interaction.
|
||||
AzToolsFramework::ViewportInteraction::MouseInteraction BuildMouseInteractionInternal(
|
||||
AzToolsFramework::ViewportInteraction::MouseButtons buttons,
|
||||
AzToolsFramework::ViewportInteraction::KeyboardModifiers modifiers,
|
||||
const AzToolsFramework::ViewportInteraction::MousePick& mousePick) const;
|
||||
// Given a point in the viewport, return the pick ray into the scene.
|
||||
// note: The argument passed to parameter **point**, originating
|
||||
// from a Qt event, must first be passed to WidgetToViewport before being
|
||||
// passed to BuildMousePick.
|
||||
AzToolsFramework::ViewportInteraction::MousePick BuildMousePick(const QPoint& point);
|
||||
|
||||
bool event(QEvent* event) override;
|
||||
void OnDestroy();
|
||||
|
||||
bool CheckRespondToInput() const;
|
||||
|
||||
// AzFramework::InputSystemCursorConstraintRequestBus
|
||||
void* GetSystemCursorConstraintWindow() const override;
|
||||
|
||||
void BuildDragDropContext(AzQtComponents::ViewportDragContext& context, const QPoint& pt) override;
|
||||
|
||||
private:
|
||||
void ProcessKeyRelease(QKeyEvent* event);
|
||||
void PushDisableRendering();
|
||||
void PopDisableRendering();
|
||||
bool IsRenderingDisabled() const;
|
||||
AzToolsFramework::ViewportInteraction::MousePick BuildMousePickInternal(
|
||||
const QPoint& point) const;
|
||||
|
||||
void RestoreViewportAfterGameMode();
|
||||
|
||||
double WidgetToViewportFactor() const
|
||||
{
|
||||
#if defined(AZ_PLATFORM_WINDOWS)
|
||||
// Needed for high DPI mode on windows
|
||||
return devicePixelRatioF();
|
||||
#else
|
||||
return 1.0f;
|
||||
#endif
|
||||
}
|
||||
|
||||
void BeginUndoTransaction() override;
|
||||
void EndUndoTransaction() override;
|
||||
|
||||
void UpdateCurrentMousePos(const QPoint& newPosition);
|
||||
|
||||
AzFramework::EntityVisibilityQuery m_entityVisibilityQuery;
|
||||
|
||||
SPreviousContext m_previousContext;
|
||||
QSet<int> m_keyDown;
|
||||
|
||||
bool m_freezeViewportInput = false;
|
||||
|
||||
size_t m_cameraSetForWidgetRenderingCount = 0; ///< How many calls to PreWidgetRendering happened before
|
||||
///< subsequent calls to PostWidetRendering.
|
||||
AZStd::shared_ptr<AzToolsFramework::ManipulatorManager> m_manipulatorManager;
|
||||
|
||||
// Used to prevent circular set camera events
|
||||
bool m_ignoreSetViewFromEntityPerspective = false;
|
||||
bool m_windowResizedEvent = false;
|
||||
|
||||
// Cache hwnd value for teardown to avoid infinite loops in retrieving it from destroyed widgets.
|
||||
HWND m_hwnd;
|
||||
|
||||
AZStd::unique_ptr<EditorEntityNotifications> m_editorEntityNotifications;
|
||||
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_RENDERVIEWPORT_H
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
// AzFramework
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
|
||||
// AzToolsFramework
|
||||
#include <AzToolsFramework/SourceControl/SourceControlAPI.h>
|
||||
|
||||
@@ -161,16 +161,19 @@ void CCommentNodeAnimator::Render(CTrackViewAnimNode* pNode, [[maybe_unused]] co
|
||||
|
||||
Vec2 CCommentNodeAnimator::GetScreenPosFromNormalizedPos(const Vec2& unitPos)
|
||||
{
|
||||
const CCamera& cam = gEnv->pSystem->GetViewCamera();
|
||||
float width = (float)cam.GetViewSurfaceX();
|
||||
int height = cam.GetViewSurfaceZ();
|
||||
float fAspectRatio = gSettings.viewports.fDefaultAspectRatio;
|
||||
float camWidth = height * fAspectRatio;
|
||||
(void)unitPos;
|
||||
AZ_Error("CryLegacy", false, "CCommentNodeAnimator::GetScreenPosFromNormalizedPos not supported");
|
||||
return Vec2(0, 0);
|
||||
//const CCamera& cam = gEnv->pSystem->GetViewCamera();
|
||||
//float width = (float)cam.GetViewSurfaceX();
|
||||
//int height = cam.GetViewSurfaceZ();
|
||||
//float fAspectRatio = gSettings.viewports.fDefaultAspectRatio;
|
||||
//float camWidth = height * fAspectRatio;
|
||||
|
||||
float x = 0.5f * width + 0.5f * camWidth * unitPos.x;
|
||||
float y = 0.5f * height * (1.f - unitPos.y);
|
||||
//float x = 0.5f * width + 0.5f * camWidth * unitPos.x;
|
||||
//float y = 0.5f * height * (1.f - unitPos.y);
|
||||
|
||||
return Vec2(x, y);
|
||||
//return Vec2(x, y);
|
||||
}
|
||||
|
||||
void CCommentNodeAnimator::DrawText(const char* szFontName, float fSize, const Vec2& unitPos, const ColorF col, const char* szText, int align)
|
||||
|
||||
@@ -44,7 +44,12 @@ namespace
|
||||
{
|
||||
const int g_useActiveViewportResolution = -1; // reserved value to indicate the use of the active viewport resolution
|
||||
int resolutions[][2] = {
|
||||
{ 1280, 720 }, { 1920, 1080 }, { 1998, 1080 }, { 2048, 858 }, { 2560, 1440 },
|
||||
{1280, 720},
|
||||
{1920, 1080},
|
||||
{1998, 1080},
|
||||
{2048, 858},
|
||||
{2560, 1440},
|
||||
{3840, 2160},
|
||||
{ g_useActiveViewportResolution, g_useActiveViewportResolution } // active viewport res must be the last element of the resolution array
|
||||
};
|
||||
|
||||
@@ -1067,6 +1072,10 @@ void CSequenceBatchRenderDialog::OnUpdateEnd(IAnimSequence* sequence)
|
||||
{
|
||||
GetIEditor()->GetMovieSystem()->DisableFixedStepForCapture();
|
||||
|
||||
// Important: End batch render mode BEFORE leaving Game Mode.
|
||||
// Otherwise track view will set the active camera based on the directors in the current sequence while leaving game mode
|
||||
GetIEditor()->GetMovieSystem()->EnableBatchRenderMode(false);
|
||||
|
||||
GetIEditor()->GetMovieSystem()->RemoveMovieListener(sequence, this);
|
||||
GetIEditor()->SetInGameMode(false);
|
||||
GetIEditor()->GetGameEngine()->Update(); // Update is needed because SetInGameMode() queues game mode, Update() executes it.
|
||||
@@ -1186,7 +1195,6 @@ void CSequenceBatchRenderDialog::OnUpdateFinalize()
|
||||
|
||||
m_ui->m_pGoBtn->setText(tr("Start"));
|
||||
m_ui->m_pGoBtn->setIcon(QPixmap(":/Trackview/clapperboard_ready.png"));
|
||||
GetIEditor()->GetMovieSystem()->EnableBatchRenderMode(false);
|
||||
m_renderContext.currentItemIndex = -1;
|
||||
m_ui->BATCH_RENDER_PRESS_ESC_TO_CANCEL->setText(m_ffmpegPluginStatusMsg);
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <CryCommon/Maestro/Types/AnimNodeType.h>
|
||||
#include <CryCommon/Maestro/Types/AnimValueType.h>
|
||||
#include <CryCommon/Maestro/Types/AnimParamType.h>
|
||||
#include <CryCommon/MathConversion.h>
|
||||
|
||||
// Editor
|
||||
#include "AnimationContext.h"
|
||||
|
||||
@@ -17,10 +17,24 @@
|
||||
// Editor
|
||||
#include "ViewManager.h"
|
||||
|
||||
#include <AzCore/Math/Matrix3x3.h>
|
||||
#include <AzCore/Math/Matrix3x4.h>
|
||||
#include <AzFramework/Components/CameraBus.h>
|
||||
#include <MathConversion.h>
|
||||
|
||||
Ang3 CUndoViewRotation::GetActiveCameraRotation()
|
||||
{
|
||||
AZ::Transform activeCameraTm = AZ::Transform::CreateIdentity();
|
||||
EBUS_EVENT_RESULT(activeCameraTm, Camera::ActiveCameraRequestBus, GetActiveCameraTransform);
|
||||
const AZ::Matrix3x4 cameraMatrix = AZ::Matrix3x4::CreateFromTransform(activeCameraTm);
|
||||
const Matrix33 cameraMatrixCry = AZMatrix3x3ToLYMatrix3x3(AZ::Matrix3x3::CreateFromMatrix3x4(cameraMatrix));
|
||||
return RAD2DEG(Ang3::GetAnglesXYZ(cameraMatrixCry));
|
||||
}
|
||||
|
||||
CUndoViewRotation::CUndoViewRotation(const QString& pUndoDescription)
|
||||
{
|
||||
m_undoDescription = pUndoDescription;
|
||||
m_undo = RAD2DEG(Ang3::GetAnglesXYZ(Matrix33(GetIEditor()->GetSystem()->GetViewCamera().GetMatrix())));
|
||||
m_undo = GetActiveCameraRotation();
|
||||
}
|
||||
|
||||
int CUndoViewRotation::GetSize()
|
||||
@@ -40,7 +54,7 @@ void CUndoViewRotation::Undo(bool bUndo)
|
||||
{
|
||||
if (bUndo)
|
||||
{
|
||||
m_redo = RAD2DEG(Ang3::GetAnglesXYZ(Matrix33(GetIEditor()->GetSystem()->GetViewCamera().GetMatrix())));
|
||||
m_redo = GetActiveCameraRotation();
|
||||
}
|
||||
|
||||
Matrix34 tm = pRenderViewport->GetViewTM();
|
||||
|
||||
@@ -29,6 +29,8 @@ protected:
|
||||
void Redo();
|
||||
|
||||
private:
|
||||
static Ang3 GetActiveCameraRotation();
|
||||
|
||||
Ang3 m_undo;
|
||||
Ang3 m_redo;
|
||||
QString m_undoDescription;
|
||||
|
||||
@@ -80,7 +80,8 @@ CViewManager::CViewManager()
|
||||
}
|
||||
else
|
||||
{
|
||||
RegisterQtViewPaneWithName<CRenderViewport>(GetIEditor(), "Perspective", LyViewPane::CategoryViewport, viewportOptions);
|
||||
AZ_Assert(false, "Non-Atom viewport no longer supported");
|
||||
//RegisterQtViewPaneWithName<CRenderViewport>(GetIEditor(), "Perspective", LyViewPane::CategoryViewport, viewportOptions);
|
||||
}
|
||||
|
||||
viewportOptions.viewportType = ET_ViewportMap;
|
||||
@@ -251,10 +252,10 @@ void CViewManager::SelectViewport(CViewport* pViewport)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CViewport* CViewManager::GetGameViewport() const
|
||||
{
|
||||
if (CRenderViewport::GetPrimaryViewport())
|
||||
{
|
||||
return CRenderViewport::GetPrimaryViewport();
|
||||
}
|
||||
//if (CRenderViewport::GetPrimaryViewport())
|
||||
//{
|
||||
// return CRenderViewport::GetPrimaryViewport();
|
||||
//}
|
||||
|
||||
return GetViewport(ET_ViewportCamera);;
|
||||
}
|
||||
|
||||
@@ -305,10 +305,6 @@ void CLayoutViewPane::AttachViewport(QWidget* pViewport)
|
||||
{
|
||||
vp->SetViewportId(GetId());
|
||||
vp->SetViewPane(this);
|
||||
if (CRenderViewport* renderViewport = viewport_cast<CRenderViewport*>(vp))
|
||||
{
|
||||
renderViewport->ConnectViewportInteractionRequestBus();
|
||||
}
|
||||
if (EditorViewportWidget* renderViewport = viewport_cast<EditorViewportWidget*>(vp))
|
||||
{
|
||||
renderViewport->ConnectViewportInteractionRequestBus();
|
||||
@@ -356,10 +352,6 @@ void CLayoutViewPane::DisconnectRenderViewportInteractionRequestBus()
|
||||
{
|
||||
if (QtViewport* vp = qobject_cast<QtViewport*>(m_viewport))
|
||||
{
|
||||
if (CRenderViewport* renderViewport = viewport_cast<CRenderViewport*>(vp))
|
||||
{
|
||||
renderViewport->DisconnectViewportInteractionRequestBus();
|
||||
}
|
||||
if (EditorViewportWidget* renderViewport = viewport_cast<EditorViewportWidget*>(vp))
|
||||
{
|
||||
renderViewport->DisconnectViewportInteractionRequestBus();
|
||||
@@ -469,16 +461,6 @@ void CLayoutViewPane::SetAspectRatio(unsigned int x, unsigned int y)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CLayoutViewPane::SetViewportFOV(float fov)
|
||||
{
|
||||
if (CRenderViewport* pRenderViewport = qobject_cast<CRenderViewport*>(m_viewport))
|
||||
{
|
||||
pRenderViewport->SetFOV(DEG2RAD(fov));
|
||||
|
||||
// if viewport camera is active, make selected fov new default
|
||||
if (pRenderViewport->GetViewManager()->GetCameraObjectId() == GUID_NULL)
|
||||
{
|
||||
gSettings.viewports.fDefaultFov = DEG2RAD(fov);
|
||||
}
|
||||
}
|
||||
if (EditorViewportWidget* pRenderViewport = qobject_cast<EditorViewportWidget*>(m_viewport))
|
||||
{
|
||||
pRenderViewport->SetFOV(DEG2RAD(fov));
|
||||
|
||||
@@ -189,7 +189,6 @@ QtViewport::QtViewport(QWidget* parent)
|
||||
{
|
||||
m_constructionMatrix[i].SetIdentity();
|
||||
}
|
||||
m_viewTM.SetIdentity();
|
||||
m_screenTM.SetIdentity();
|
||||
|
||||
m_pMouseOverObject = 0;
|
||||
|
||||
+10
-4
@@ -165,11 +165,19 @@ public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Set current view matrix,
|
||||
//! This is a matrix that transforms from world to view space.
|
||||
virtual void SetViewTM(const Matrix34& tm) { m_viewTM = tm; };
|
||||
virtual void SetViewTM([[maybe_unused]] const Matrix34& tm)
|
||||
{
|
||||
AZ_Error("CryLegacy", false, "QtViewport::SetViewTM not implemented");
|
||||
}
|
||||
|
||||
//! Get current view matrix.
|
||||
//! This is a matrix that transforms from world space to view space.
|
||||
virtual const Matrix34& GetViewTM() const { return m_viewTM; };
|
||||
virtual const Matrix34& GetViewTM() const
|
||||
{
|
||||
AZ_Error("CryLegacy", false, "QtViewport::GetViewTM not implemented");
|
||||
static const Matrix34 m;
|
||||
return m;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Get current screen matrix.
|
||||
@@ -277,8 +285,6 @@ protected:
|
||||
CLayoutViewPane* m_viewPane = nullptr;
|
||||
CViewManager* m_viewManager;
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
// Viewport matrix.
|
||||
Matrix34 m_viewTM;
|
||||
// Screen Matrix
|
||||
Matrix34 m_screenTM;
|
||||
int m_nCurViewportID;
|
||||
|
||||
@@ -644,13 +644,31 @@ void CViewportTitleDlg::CreateViewportInformationMenu()
|
||||
|
||||
void CViewportTitleDlg::AddResolutionMenus(QMenu* menu, std::function<void(int, int)> callback, const QStringList& customPresets)
|
||||
{
|
||||
static const CRenderViewport::SResolution resolutions[] = {
|
||||
CRenderViewport::SResolution(1280, 720),
|
||||
CRenderViewport::SResolution(1920, 1080),
|
||||
CRenderViewport::SResolution(2560, 1440),
|
||||
CRenderViewport::SResolution(2048, 858),
|
||||
CRenderViewport::SResolution(1998, 1080),
|
||||
CRenderViewport::SResolution(3840, 2160)
|
||||
struct SResolution
|
||||
{
|
||||
SResolution()
|
||||
: width(0)
|
||||
, height(0)
|
||||
{
|
||||
}
|
||||
|
||||
SResolution(int w, int h)
|
||||
: width(w)
|
||||
, height(h)
|
||||
{
|
||||
}
|
||||
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
||||
static const SResolution resolutions[] = {
|
||||
SResolution(1280, 720),
|
||||
SResolution(1920, 1080),
|
||||
SResolution(2560, 1440),
|
||||
SResolution(2048, 858),
|
||||
SResolution(1998, 1080),
|
||||
SResolution(3840, 2160)
|
||||
};
|
||||
|
||||
static const size_t resolutionCount = sizeof(resolutions) / sizeof(resolutions[0]);
|
||||
|
||||
@@ -44,6 +44,22 @@ namespace AZ
|
||||
return &out;
|
||||
}
|
||||
|
||||
void SetPerspectiveMatrixFOV(Matrix4x4& out, float fovY, float aspectRatio)
|
||||
{
|
||||
float sinFov, cosFov;
|
||||
SinCos(0.5f * fovY, sinFov, cosFov);
|
||||
float yScale = cosFov / sinFov; //cot(fovY/2)
|
||||
float xScale = yScale / aspectRatio;
|
||||
|
||||
out.SetElement(0, 0, xScale);
|
||||
out.SetElement(1, 1, yScale);
|
||||
}
|
||||
|
||||
float GetPerspectiveMatrixFOV(const Matrix4x4& m)
|
||||
{
|
||||
return 2.0 * atan(1.0f / m.GetElement(1, 1));
|
||||
}
|
||||
|
||||
Matrix4x4* MakeFrustumMatrixRH(Matrix4x4& out, float left, float right, float bottom, float top, float nearDist, float farDist, bool reverseDepth)
|
||||
{
|
||||
AZ_Assert(right > left, "right should be greater than left");
|
||||
|
||||
@@ -64,4 +64,8 @@ namespace AZ
|
||||
//! Transforms a position by a matrix. This function can be used with any generic cases which include projection matrices.
|
||||
Vector3 MatrixTransformPosition(const Matrix4x4& matrix, const Vector3& inPosition);
|
||||
|
||||
|
||||
void SetPerspectiveMatrixFOV(Matrix4x4& out, float fovY, float aspectRatio);
|
||||
float GetPerspectiveMatrixFOV(const Matrix4x4& m);
|
||||
|
||||
} // namespace AZ
|
||||
|
||||
@@ -114,6 +114,9 @@ namespace Camera
|
||||
//! Makes the camera the active view
|
||||
virtual void MakeActiveView() = 0;
|
||||
|
||||
//! Check if this camera is the active render camera
|
||||
virtual bool IsActiveView() = 0;
|
||||
|
||||
//! Get the camera frustum's aggregate configuration
|
||||
virtual Configuration GetCameraConfiguration()
|
||||
{
|
||||
|
||||
@@ -900,9 +900,6 @@ struct ISystem
|
||||
// Retrieves access to XML utilities interface.
|
||||
virtual IXmlUtils* GetXmlUtils() = 0;
|
||||
|
||||
virtual void SetViewCamera(CCamera& Camera) = 0;
|
||||
virtual CCamera& GetViewCamera() = 0;
|
||||
|
||||
// Description:
|
||||
// When ignore update sets to true, system will ignore and updates and render calls.
|
||||
virtual void IgnoreUpdates(bool bIgnore) = 0;
|
||||
|
||||
@@ -620,9 +620,9 @@ ILevel* CLevelSystem::LoadLevelInternal(const char* _levelName)
|
||||
|
||||
// Reset the camera to (1,1,1) (not (0,0,0) which is the invalid/uninitialised state,
|
||||
// to avoid the hack in the renderer to not show anything if the camera is at the origin).
|
||||
CCamera defaultCam;
|
||||
defaultCam.SetPosition(Vec3(1.0f));
|
||||
m_pSystem->SetViewCamera(defaultCam);
|
||||
//CCamera defaultCam;
|
||||
//defaultCam.SetPosition(Vec3(1.0f));
|
||||
//m_pSystem->SetViewCamera(defaultCam);
|
||||
|
||||
m_pLoadingLevelInfo = pLevelInfo;
|
||||
OnLoadingStart(levelName);
|
||||
@@ -953,8 +953,8 @@ void CLevelSystem::UnloadLevel()
|
||||
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
|
||||
|
||||
// Reset the camera to (0,0,0) which is the invalid/uninitialised state
|
||||
CCamera defaultCam;
|
||||
m_pSystem->SetViewCamera(defaultCam);
|
||||
//CCamera defaultCam;
|
||||
//m_pSystem->SetViewCamera(defaultCam);
|
||||
|
||||
OnUnloadComplete(m_lastLevelName.c_str());
|
||||
|
||||
|
||||
@@ -272,7 +272,7 @@ namespace LegacyLevelSystem
|
||||
// to avoid the hack in the renderer to not show anything if the camera is at the origin).
|
||||
CCamera defaultCam;
|
||||
defaultCam.SetPosition(Vec3(1.0f));
|
||||
m_pSystem->SetViewCamera(defaultCam);
|
||||
//m_pSystem->SetViewCamera(defaultCam);
|
||||
|
||||
OnLoadingStart(levelName);
|
||||
|
||||
@@ -588,8 +588,8 @@ namespace LegacyLevelSystem
|
||||
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
|
||||
|
||||
// Reset the camera to (0,0,0) which is the invalid/uninitialised state
|
||||
CCamera defaultCam;
|
||||
m_pSystem->SetViewCamera(defaultCam);
|
||||
//CCamera defaultCam;
|
||||
//m_pSystem->SetViewCamera(defaultCam);
|
||||
|
||||
OnUnloadComplete(m_lastLevelName.c_str());
|
||||
|
||||
|
||||
@@ -353,9 +353,6 @@ public:
|
||||
virtual IXmlUtils* GetXmlUtils();
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SetViewCamera(CCamera& Camera){ m_ViewCamera = Camera; }
|
||||
CCamera& GetViewCamera() { return m_ViewCamera; }
|
||||
|
||||
void IgnoreUpdates(bool bIgnore) { m_bIgnoreUpdates = bIgnore; };
|
||||
|
||||
void SetIProcess(IProcess* process);
|
||||
@@ -494,7 +491,6 @@ private: // ------------------------------------------------------
|
||||
SSystemGlobalEnvironment m_env;
|
||||
|
||||
CTimer m_Time; //!<
|
||||
CCamera m_ViewCamera; //!<
|
||||
bool m_bInitializedSuccessfully; //!< true if the system completed all initialization steps
|
||||
bool m_bRelaunch; //!< relaunching the app or not (true beforerelaunch)
|
||||
int m_iLoadingMode; //!< Game is loading w/o changing context (0 not, 1 quickloading, 2 full loading)
|
||||
|
||||
@@ -58,10 +58,10 @@ DebugCamera::~DebugCamera()
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void DebugCamera::OnEnable()
|
||||
{
|
||||
m_position = gEnv->pSystem->GetViewCamera().GetPosition();
|
||||
m_position = Vec3_Zero; // gEnv->pSystem->GetViewCamera().GetPosition();
|
||||
m_moveInput = Vec3_Zero;
|
||||
|
||||
Ang3 cameraAngles = Ang3(gEnv->pSystem->GetViewCamera().GetMatrix());
|
||||
Ang3 cameraAngles = Ang3(ZERO); // Ang3(gEnv->pSystem->GetViewCamera().GetMatrix());
|
||||
m_cameraYaw = RAD2DEG(cameraAngles.z);
|
||||
m_cameraPitch = RAD2DEG(cameraAngles.x);
|
||||
m_view = Matrix33(Ang3(DEG2RAD(m_cameraPitch), 0.0f, DEG2RAD(m_cameraYaw)));
|
||||
@@ -126,13 +126,13 @@ void DebugCamera::Update()
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void DebugCamera::PostUpdate()
|
||||
{
|
||||
if (m_cameraMode == DebugCamera::ModeOff)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//if (m_cameraMode == DebugCamera::ModeOff)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
|
||||
CCamera& camera = gEnv->pSystem->GetViewCamera();
|
||||
camera.SetMatrix(Matrix34(m_view, m_position));
|
||||
//CCamera& camera = gEnv->pSystem->GetViewCamera();
|
||||
//camera.SetMatrix(Matrix34(m_view, m_position));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -57,77 +57,79 @@ void CView::Release()
|
||||
//------------------------------------------------------------------------
|
||||
void CView::Update(float frameTime, bool isActive)
|
||||
{
|
||||
//FIXME:some cameras may need to be updated always
|
||||
if (!isActive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
(void)(frameTime, isActive);
|
||||
AZ_ErrorOnce("CryLegacy", false, "CryLegacy view system no longer available (CView::Update)");
|
||||
////FIXME:some cameras may need to be updated always
|
||||
//if (!isActive)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
|
||||
if (m_azEntity)
|
||||
{
|
||||
m_viewParams.SaveLast();
|
||||
//if (m_azEntity)
|
||||
//{
|
||||
// m_viewParams.SaveLast();
|
||||
|
||||
CCamera* pSysCam = &m_pSystem->GetViewCamera();
|
||||
// CCamera* pSysCam = &m_pSystem->GetViewCamera();
|
||||
|
||||
//process screen shaking
|
||||
ProcessShaking(frameTime);
|
||||
// //process screen shaking
|
||||
// ProcessShaking(frameTime);
|
||||
|
||||
//FIXME:to let the updateView implementation use the correct shakeVector
|
||||
m_viewParams.currentShakeShift = m_viewParams.rotation * m_viewParams.currentShakeShift;
|
||||
// //FIXME:to let the updateView implementation use the correct shakeVector
|
||||
// m_viewParams.currentShakeShift = m_viewParams.rotation * m_viewParams.currentShakeShift;
|
||||
|
||||
m_viewParams.frameTime = frameTime;
|
||||
//update view position/rotation
|
||||
if (m_azEntity != nullptr)
|
||||
{
|
||||
auto entityTransform = m_azEntity->GetTransform();
|
||||
if (entityTransform != nullptr)
|
||||
{
|
||||
AZ::Transform transform = entityTransform->GetWorldTM();
|
||||
m_viewParams.position = AZVec3ToLYVec3(transform.GetTranslation());
|
||||
m_viewParams.rotation = AZQuaternionToLYQuaternion(transform.GetRotation());
|
||||
}
|
||||
}
|
||||
// m_viewParams.frameTime = frameTime;
|
||||
// //update view position/rotation
|
||||
// if (m_azEntity != nullptr)
|
||||
// {
|
||||
// auto entityTransform = m_azEntity->GetTransform();
|
||||
// if (entityTransform != nullptr)
|
||||
// {
|
||||
// AZ::Transform transform = entityTransform->GetWorldTM();
|
||||
// m_viewParams.position = AZVec3ToLYVec3(transform.GetTranslation());
|
||||
// m_viewParams.rotation = AZQuaternionToLYQuaternion(transform.GetRotation());
|
||||
// }
|
||||
// }
|
||||
|
||||
ApplyFrameAdditiveAngles(m_viewParams.rotation);
|
||||
// ApplyFrameAdditiveAngles(m_viewParams.rotation);
|
||||
|
||||
const float fNearZ = gEnv->pSystem->GetIViewSystem()->GetDefaultZNear();
|
||||
// const float fNearZ = gEnv->pSystem->GetIViewSystem()->GetDefaultZNear();
|
||||
|
||||
//see if the view have to use a custom near clipping plane
|
||||
const float nearPlane = (m_viewParams.nearplane >= CAMERA_MIN_NEAR) ? (m_viewParams.nearplane) : fNearZ;
|
||||
const float farPlane = (m_viewParams.farplane > 0.f) ? m_viewParams.farplane : DEFAULT_FAR;
|
||||
float fov = (m_viewParams.fov < 0.001f) ? DEFAULT_FOV : m_viewParams.fov;
|
||||
// //see if the view have to use a custom near clipping plane
|
||||
// const float nearPlane = (m_viewParams.nearplane >= CAMERA_MIN_NEAR) ? (m_viewParams.nearplane) : fNearZ;
|
||||
// const float farPlane = (m_viewParams.farplane > 0.f) ? m_viewParams.farplane : DEFAULT_FAR;
|
||||
// float fov = (m_viewParams.fov < 0.001f) ? DEFAULT_FOV : m_viewParams.fov;
|
||||
|
||||
m_camera.SetFrustum(pSysCam->GetViewSurfaceX(), pSysCam->GetViewSurfaceZ(), fov, nearPlane, farPlane, pSysCam->GetPixelAspectRatio());
|
||||
// m_camera.SetFrustum(pSysCam->GetViewSurfaceX(), pSysCam->GetViewSurfaceZ(), fov, nearPlane, farPlane, pSysCam->GetPixelAspectRatio());
|
||||
|
||||
//apply shake & set the view matrix
|
||||
m_viewParams.rotation *= m_viewParams.currentShakeQuat;
|
||||
m_viewParams.rotation.NormalizeSafe();
|
||||
m_viewParams.position += m_viewParams.currentShakeShift;
|
||||
// //apply shake & set the view matrix
|
||||
// m_viewParams.rotation *= m_viewParams.currentShakeQuat;
|
||||
// m_viewParams.rotation.NormalizeSafe();
|
||||
// m_viewParams.position += m_viewParams.currentShakeShift;
|
||||
|
||||
// Blending between cameras needs to happen after Camera space rendering calculations have been applied
|
||||
// so that the m_viewParams.position is in World Space again
|
||||
m_viewParams.UpdateBlending(frameTime);
|
||||
// // Blending between cameras needs to happen after Camera space rendering calculations have been applied
|
||||
// // so that the m_viewParams.position is in World Space again
|
||||
// m_viewParams.UpdateBlending(frameTime);
|
||||
|
||||
// [VR] specific
|
||||
// Add HMD's pose tracking on top of current camera pose
|
||||
// Each game-title can decide whether to keep this functionality here or (most likely)
|
||||
// move it somewhere else.
|
||||
// // [VR] specific
|
||||
// // Add HMD's pose tracking on top of current camera pose
|
||||
// // Each game-title can decide whether to keep this functionality here or (most likely)
|
||||
// // move it somewhere else.
|
||||
|
||||
Quat q = m_viewParams.rotation;
|
||||
Vec3 pos = m_viewParams.position;
|
||||
Vec3 p = Vec3(ZERO);
|
||||
// Quat q = m_viewParams.rotation;
|
||||
// Vec3 pos = m_viewParams.position;
|
||||
// Vec3 p = Vec3(ZERO);
|
||||
|
||||
Matrix34 viewMtx(q);
|
||||
viewMtx.SetTranslation(pos + p);
|
||||
m_camera.SetMatrix(viewMtx);
|
||||
// Matrix34 viewMtx(q);
|
||||
// viewMtx.SetTranslation(pos + p);
|
||||
// m_camera.SetMatrix(viewMtx);
|
||||
|
||||
m_camera.SetEntityRotation(m_viewParams.rotation);
|
||||
m_camera.SetEntityPos(pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_linkedTo = AZ::EntityId(0);
|
||||
}
|
||||
// m_camera.SetEntityRotation(m_viewParams.rotation);
|
||||
// m_camera.SetEntityPos(pos);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// m_linkedTo = AZ::EntityId(0);
|
||||
//}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@@ -253,7 +253,8 @@ void CViewSystem::Update(float frameTime)
|
||||
}
|
||||
}
|
||||
|
||||
m_pSystem->SetViewCamera(rCamera);
|
||||
AZ_ErrorOnce("CryLegacy", false, "CryLegacy view system no longer available (CViewSystem::Update)");
|
||||
//m_pSystem->SetViewCamera(rCamera);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -557,23 +558,25 @@ void CViewSystem::SetOverrideCameraRotation(bool bOverride, Quat rotation)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CViewSystem::UpdateSoundListeners()
|
||||
{
|
||||
assert(gEnv->IsEditor() && !gEnv->IsEditorGameMode());
|
||||
AZ_ErrorOnce("CryLegacy", false, "CryLegacy view system no longer available (CViewSystem::UpdateSoundListeners)");
|
||||
|
||||
// In Editor we may want to control global listeners outside of the game view.
|
||||
if (m_bControlsAudioListeners)
|
||||
{
|
||||
IView* const pActiveView = static_cast<IView*>(GetActiveView());
|
||||
TViewMap::const_iterator Iter(m_views.begin());
|
||||
TViewMap::const_iterator const IterEnd(m_views.end());
|
||||
//assert(gEnv->IsEditor() && !gEnv->IsEditorGameMode());
|
||||
|
||||
for (; Iter != IterEnd; ++Iter)
|
||||
{
|
||||
IView* const pView = Iter->second;
|
||||
bool const bIsActive = (pView == pActiveView);
|
||||
CCamera const& rCamera = bIsActive ? gEnv->pSystem->GetViewCamera() : pView->GetCamera();
|
||||
pView->UpdateAudioListener(rCamera.GetMatrix());
|
||||
}
|
||||
}
|
||||
//// In Editor we may want to control global listeners outside of the game view.
|
||||
//if (m_bControlsAudioListeners)
|
||||
//{
|
||||
// IView* const pActiveView = static_cast<IView*>(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);
|
||||
// CCamera const& rCamera = bIsActive ? gEnv->pSystem->GetViewCamera() : pView->GetCamera();
|
||||
// pView->UpdateAudioListener(rCamera.GetMatrix());
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
+1
@@ -103,6 +103,7 @@ namespace AZ
|
||||
void SetOrthographic(bool orthographic) override;
|
||||
void SetOrthographicHalfWidth(float halfWidth) override;
|
||||
void MakeActiveView() override;
|
||||
bool IsActiveView() override;
|
||||
|
||||
// RPI::WindowContextNotificationBus overrides...
|
||||
void OnViewportResized(uint32_t width, uint32_t height) override;
|
||||
|
||||
@@ -250,6 +250,11 @@ namespace AZ
|
||||
// do nothing
|
||||
}
|
||||
|
||||
bool CameraComponent::IsActiveView()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void CameraComponent::OnViewportResized(uint32_t width, uint32_t height)
|
||||
{
|
||||
AZ_UNUSED(width)
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include <MathConversion.h>
|
||||
#include <QtViewPaneManager.h>
|
||||
|
||||
#include <AzFramework/Components/CameraBus.h>
|
||||
|
||||
|
||||
using namespace AudioControls;
|
||||
|
||||
@@ -148,18 +150,21 @@ void CAudioControlsEditorPlugin::ExecuteTrigger(const AZStd::string_view sTrigge
|
||||
Audio::AudioSystemRequestBus::BroadcastResult(ms_nAudioTriggerID, &Audio::AudioSystemRequestBus::Events::GetAudioTriggerID, sTriggerName.data());
|
||||
if (ms_nAudioTriggerID != INVALID_AUDIO_CONTROL_ID)
|
||||
{
|
||||
AZ::Transform activeCameraTm = AZ::Transform::CreateIdentity();
|
||||
EBUS_EVENT_RESULT(activeCameraTm, Camera::ActiveCameraRequestBus, GetActiveCameraTransform);
|
||||
const AZ::Matrix3x4 cameraMatrix = AZ::Matrix3x4::CreateFromTransform(activeCameraTm);
|
||||
|
||||
Audio::SAudioRequest request;
|
||||
request.nFlags = Audio::eARF_PRIORITY_NORMAL;
|
||||
|
||||
const AZ::Matrix3x4 listenerTxfm = AZ::Matrix3x4::CreateIdentity();
|
||||
|
||||
Audio::SAudioListenerRequestData<Audio::eALRT_SET_POSITION> requestData(listenerTxfm);
|
||||
Audio::SAudioListenerRequestData<Audio::eALRT_SET_POSITION> requestData(cameraMatrix);
|
||||
requestData.oNewPosition.NormalizeForwardVec();
|
||||
requestData.oNewPosition.NormalizeUpVec();
|
||||
request.pData = &requestData;
|
||||
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequest, request);
|
||||
|
||||
ms_pIAudioProxy->SetPosition(listenerTxfm);
|
||||
ms_pIAudioProxy->SetPosition(cameraMatrix);
|
||||
ms_pIAudioProxy->ExecuteTrigger(ms_nAudioTriggerID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +103,7 @@ namespace Camera
|
||||
->Event("SetNearClipDistance", &CameraRequestBus::Events::SetNearClipDistance)
|
||||
->Event("SetFarClipDistance", &CameraRequestBus::Events::SetFarClipDistance)
|
||||
->Event("MakeActiveView", &CameraRequestBus::Events::MakeActiveView)
|
||||
->Event("IsActiveView", &CameraRequestBus::Events::IsActiveView)
|
||||
->Event("IsOrthographic", &CameraRequestBus::Events::IsOrthographic)
|
||||
->Event("SetOrthographic", &CameraRequestBus::Events::SetOrthographic)
|
||||
->Event("GetOrthographicHalfWidth", &CameraRequestBus::Events::GetOrthographicHalfWidth)
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Camera
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<CameraComponentConfig, AZ::ComponentConfig>()
|
||||
->Version(3)
|
||||
->Version(4)
|
||||
->Field("Orthographic", &CameraComponentConfig::m_orthographic)
|
||||
->Field("Orthographic Half Width", &CameraComponentConfig::m_orthographicHalfWidth)
|
||||
->Field("Field of View", &CameraComponentConfig::m_fov)
|
||||
@@ -51,6 +51,7 @@ namespace Camera
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, &CameraComponentConfig::GetOrthographicParameterVisibility)
|
||||
->Attribute(AZ::Edit::Attributes::Min, 0.001f)
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::ValuesOnly)
|
||||
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &CameraComponentConfig::m_fov, "Field of view", "Vertical field of view in degrees")
|
||||
->Attribute(AZ::Edit::Attributes::Min, MIN_FOV)
|
||||
->Attribute(AZ::Edit::Attributes::Suffix, " degrees")
|
||||
@@ -130,6 +131,11 @@ namespace Camera
|
||||
|
||||
void CameraComponentController::DeactivateAtomView()
|
||||
{
|
||||
if (!IsActiveView())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto atomViewportRequests = AZ::Interface<AZ::RPI::ViewportContextRequestsInterface>::Get();
|
||||
if (atomViewportRequests)
|
||||
{
|
||||
@@ -413,6 +419,11 @@ namespace Camera
|
||||
|
||||
void CameraComponentController::MakeActiveView()
|
||||
{
|
||||
if (IsActiveView())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Set Legacy Cry view, if it exists
|
||||
if (m_viewSystem)
|
||||
{
|
||||
@@ -433,6 +444,11 @@ namespace Camera
|
||||
CameraNotificationBus::Broadcast(&CameraNotificationBus::Events::OnActiveViewChanged, m_entityId);
|
||||
}
|
||||
|
||||
bool CameraComponentController::IsActiveView()
|
||||
{
|
||||
return AZ::RPI::ViewportContextNotificationBus::Handler::BusIsConnected();
|
||||
}
|
||||
|
||||
void CameraComponentController::OnTransformChanged([[maybe_unused]] const AZ::Transform& local, const AZ::Transform& world)
|
||||
{
|
||||
if (m_updatingTransformFromEntity)
|
||||
@@ -459,6 +475,17 @@ namespace Camera
|
||||
UpdateCamera();
|
||||
}
|
||||
|
||||
void CameraComponentController::OnViewportDefaultViewChanged(AZ::RPI::ViewPtr view)
|
||||
{
|
||||
if (m_atomCamera != view)
|
||||
{
|
||||
// Note that when disconnected from this bus, this signals that we are not the active view
|
||||
// There is nothing else to do here: leave our view on the viewport context stack, don't need
|
||||
// to update properties. The viewport context system should handle it all!
|
||||
AZ::RPI::ViewportContextNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
}
|
||||
|
||||
AZ::RPI::ViewPtr CameraComponentController::GetView() const
|
||||
{
|
||||
return m_atomCamera;
|
||||
|
||||
@@ -69,9 +69,6 @@ namespace Camera
|
||||
CameraComponentController() = default;
|
||||
explicit CameraComponentController(const CameraComponentConfig& config);
|
||||
|
||||
void ActivateAtomView();
|
||||
void DeactivateAtomView();
|
||||
|
||||
// Controller interface
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
|
||||
@@ -107,12 +104,14 @@ namespace Camera
|
||||
void SetOrthographicHalfWidth(float halfWidth) override;
|
||||
|
||||
void MakeActiveView() override;
|
||||
bool IsActiveView() override;
|
||||
|
||||
// AZ::TransformNotificationBus::Handler interface
|
||||
void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
|
||||
|
||||
// AZ::RPI::ViewportContextNotificationBus::Handler interface
|
||||
void OnViewportSizeChanged(AzFramework::WindowSize size) override;
|
||||
void OnViewportDefaultViewChanged(AZ::RPI::ViewPtr view) override;
|
||||
|
||||
// AZ::RPI::ViewProviderBus::Handler interface
|
||||
AZ::RPI::ViewPtr GetView() const override;
|
||||
@@ -120,6 +119,8 @@ namespace Camera
|
||||
private:
|
||||
AZ_DISABLE_COPY(CameraComponentController);
|
||||
|
||||
void ActivateAtomView();
|
||||
void DeactivateAtomView();
|
||||
void UpdateCamera();
|
||||
void SetupAtomAuxGeom(AZ::RPI::ViewportContextPtr viewportContext);
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <IGem.h>
|
||||
|
||||
#include "CameraComponent.h"
|
||||
#include "CameraSystemComponent.h"
|
||||
|
||||
#if defined(CAMERA_EDITOR)
|
||||
#include "CameraEditorSystemComponent.h"
|
||||
@@ -31,6 +32,7 @@ namespace Camera
|
||||
{
|
||||
m_descriptors.insert(m_descriptors.end(), {
|
||||
Camera::CameraComponent::CreateDescriptor(),
|
||||
Camera::CameraSystemComponent::CreateDescriptor(),
|
||||
|
||||
#if defined(CAMERA_EDITOR)
|
||||
CameraEditorSystemComponent::CreateDescriptor(),
|
||||
@@ -55,6 +57,7 @@ namespace Camera
|
||||
AZ::ComponentTypeList GetRequiredSystemComponents() const override
|
||||
{
|
||||
return AZ::ComponentTypeList {
|
||||
azrtti_typeid<Camera::CameraSystemComponent>(),
|
||||
#if defined(CAMERA_EDITOR)
|
||||
azrtti_typeid<CameraEditorSystemComponent>(),
|
||||
#endif // CAMERA_EDITOR
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* 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 "CameraSystemComponent.h"
|
||||
|
||||
#include <AzCore/Math/MatrixUtils.h>
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
|
||||
#include <Atom/RPI.Public/View.h>
|
||||
#include <Atom/RPI.Public/ViewportContextBus.h>
|
||||
|
||||
namespace Camera
|
||||
{
|
||||
void CameraSystemComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<CameraSystemComponent, AZ::Component>()
|
||||
->Version(1)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
void CameraSystemComponent::Activate()
|
||||
{
|
||||
CameraSystemRequestBus::Handler::BusConnect();
|
||||
ActiveCameraRequestBus::Handler::BusConnect();
|
||||
CameraNotificationBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void CameraSystemComponent::Deactivate()
|
||||
{
|
||||
CameraSystemRequestBus::Handler::BusDisconnect();
|
||||
ActiveCameraRequestBus::Handler::BusDisconnect();
|
||||
CameraNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
AZ::EntityId CameraSystemComponent::GetActiveCamera()
|
||||
{
|
||||
return m_activeView;
|
||||
}
|
||||
|
||||
const AZ::Transform& CameraSystemComponent::GetActiveCameraTransform()
|
||||
{
|
||||
if (m_activeView.IsValid())
|
||||
{
|
||||
AZ::TransformBus::EventResult(m_activeViewProperties.transform, m_activeView, &AZ::TransformBus::Events::GetWorldTM);
|
||||
}
|
||||
else
|
||||
{
|
||||
// In editor, invalid entity ID for the active view denotes the "default editor camera"
|
||||
// In game, this is an impossible state and if we reached here, we'll likely fail somehow...
|
||||
m_activeViewProperties.transform = AZ::Transform::CreateIdentity();
|
||||
|
||||
using namespace AZ::RPI;
|
||||
if (auto viewSystem = ViewportContextRequests::Get())
|
||||
{
|
||||
if (auto view = viewSystem->GetCurrentView(viewSystem->GetDefaultViewportContextName()))
|
||||
{
|
||||
m_activeViewProperties.transform = view->GetCameraTransform();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return m_activeViewProperties.transform;
|
||||
}
|
||||
|
||||
const Configuration& CameraSystemComponent::GetActiveCameraConfiguration()
|
||||
{
|
||||
if (m_activeView.IsValid())
|
||||
{
|
||||
CameraRequestBus::EventResult(m_activeViewProperties.configuration, m_activeView, &CameraRequestBus::Events::GetCameraConfiguration);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto& cfg = m_activeViewProperties.configuration;
|
||||
cfg = Configuration();
|
||||
|
||||
// In editor, invalid entity ID for the active view denotes the "default editor camera"
|
||||
// In game, this is an impossible state and if we reached here, we'll likely fail somehow...
|
||||
using namespace AZ::RPI;
|
||||
if (auto viewSystem = ViewportContextRequests::Get())
|
||||
{
|
||||
if (auto view = viewSystem->GetCurrentView(viewSystem->GetDefaultViewportContextName()))
|
||||
{
|
||||
const auto& viewToClip = view->GetViewToClipMatrix();
|
||||
cfg.m_fovRadians = AZ::GetPerspectiveMatrixFOV(viewToClip);
|
||||
|
||||
// A = f / (n - f)
|
||||
// B = n * f / (n - f)
|
||||
// Then...
|
||||
// B / A
|
||||
// = (n * f / (n - f)) / (f / (n - f))
|
||||
// = (n * f) / (f)
|
||||
// = n
|
||||
// and...
|
||||
// n * f / (n - f) = B
|
||||
// n * ((n - f) / f)^-1 = B
|
||||
// n * (n/f - 1)^-1 = B
|
||||
// (n/f - 1)^-1 = B/n
|
||||
// n/f - 1 = n/B
|
||||
// f = n/(n/B + 1)
|
||||
const float A = viewToClip.GetElement(2, 2);
|
||||
const float B = viewToClip.GetElement(2, 3);
|
||||
cfg.m_nearClipDistance = B / A;
|
||||
cfg.m_farClipDistance = cfg.m_nearClipDistance / (cfg.m_nearClipDistance / B + 1.f);
|
||||
|
||||
// NB: assumes reversed depth!
|
||||
AZStd::swap(cfg.m_farClipDistance, cfg.m_nearClipDistance);
|
||||
|
||||
// No idea what to do here. Seems to be unused?
|
||||
cfg.m_frustumWidth = cfg.m_frustumHeight = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return m_activeViewProperties.configuration;
|
||||
}
|
||||
|
||||
void CameraSystemComponent::OnActiveViewChanged(const AZ::EntityId& activeView)
|
||||
{
|
||||
m_activeView = activeView;
|
||||
}
|
||||
} // namespace Camera
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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 <AzCore/Component/Component.h>
|
||||
|
||||
#include <AzFramework/Components/CameraBus.h>
|
||||
|
||||
namespace Camera
|
||||
{
|
||||
class CameraSystemComponent
|
||||
: public AZ::Component
|
||||
, private CameraSystemRequestBus::Handler
|
||||
, private ActiveCameraRequestBus::Handler
|
||||
, private CameraNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(CameraSystemComponent, "{5DF8DB49-6430-4718-9417-85321596EDA5}");
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
CameraSystemComponent() = default;
|
||||
~CameraSystemComponent() override = default;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AZ::Component
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// CameraSystemRequestBus
|
||||
AZ::EntityId GetActiveCamera() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ActiveCameraRequestBus
|
||||
const AZ::Transform& GetActiveCameraTransform() override;
|
||||
const Configuration& GetActiveCameraConfiguration() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// CameraNotificationBus
|
||||
void OnActiveViewChanged(const AZ::EntityId&) override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct CameraProperties
|
||||
{
|
||||
AZ::Transform transform;
|
||||
Configuration configuration;
|
||||
};
|
||||
|
||||
AZ::EntityId m_activeView;
|
||||
CameraProperties m_activeViewProperties;
|
||||
};
|
||||
}
|
||||
@@ -38,40 +38,24 @@ namespace Camera
|
||||
EditorCameraComponentBase::Activate();
|
||||
|
||||
AzFramework::EntityDebugDisplayEventBus::Handler::BusConnect(GetEntityId());
|
||||
EditorCameraNotificationBus::Handler::BusConnect();
|
||||
EditorCameraViewRequestBus::Handler::BusConnect(GetEntityId());
|
||||
|
||||
AZ::EntityId currentViewEntity;
|
||||
EditorCameraRequests::Bus::BroadcastResult(currentViewEntity, &EditorCameraRequests::GetCurrentViewEntityId);
|
||||
if (currentViewEntity == GetEntityId())
|
||||
{
|
||||
m_controller.ActivateAtomView();
|
||||
m_isActiveEditorCamera = true;
|
||||
}
|
||||
}
|
||||
|
||||
void EditorCameraComponent::Deactivate()
|
||||
{
|
||||
if (m_isActiveEditorCamera)
|
||||
{
|
||||
m_controller.DeactivateAtomView();
|
||||
m_isActiveEditorCamera = false;
|
||||
}
|
||||
|
||||
EditorCameraViewRequestBus::Handler::BusDisconnect(GetEntityId());
|
||||
EditorCameraNotificationBus::Handler::BusDisconnect();
|
||||
AzFramework::EntityDebugDisplayEventBus::Handler::BusDisconnect();
|
||||
EditorCameraComponentBase::Deactivate();
|
||||
}
|
||||
|
||||
AZ::u32 EditorCameraComponent::OnConfigurationChanged()
|
||||
{
|
||||
bool isActiveEditorCamera = m_isActiveEditorCamera;
|
||||
bool isActiveEditorCamera = m_controller.IsActiveView();
|
||||
AZ::u32 configurationHash = EditorCameraComponentBase::OnConfigurationChanged();
|
||||
// If we were the active editor camera before, ensure we get reactivated after our controller gets disabled then re-enabled
|
||||
if (isActiveEditorCamera)
|
||||
{
|
||||
EditorCameraRequests::Bus::Broadcast(&EditorCameraRequests::SetViewFromEntityPerspective, GetEntityId());
|
||||
m_controller.MakeActiveView();
|
||||
}
|
||||
return configurationHash;
|
||||
}
|
||||
@@ -139,25 +123,6 @@ namespace Camera
|
||||
}
|
||||
}
|
||||
|
||||
void EditorCameraComponent::OnViewportViewEntityChanged([[maybe_unused]] const AZ::EntityId& newViewId)
|
||||
{
|
||||
if (newViewId == GetEntityId())
|
||||
{
|
||||
if (!m_isActiveEditorCamera)
|
||||
{
|
||||
m_controller.ActivateAtomView();
|
||||
m_isActiveEditorCamera = true;
|
||||
AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast(&AzToolsFramework::PropertyEditorGUIMessages::RequestRefresh, AzToolsFramework::PropertyModificationRefreshLevel::Refresh_AttributesAndValues);
|
||||
}
|
||||
}
|
||||
else if (m_isActiveEditorCamera)
|
||||
{
|
||||
m_controller.DeactivateAtomView();
|
||||
m_isActiveEditorCamera = false;
|
||||
AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast(&AzToolsFramework::PropertyEditorGUIMessages::RequestRefresh, AzToolsFramework::PropertyModificationRefreshLevel::Refresh_AttributesAndValues);
|
||||
}
|
||||
}
|
||||
|
||||
bool EditorCameraComponent::GetCameraState(AzFramework::CameraState& cameraState)
|
||||
{
|
||||
const CameraComponentConfig& config = m_controller.GetConfiguration();
|
||||
|
||||
@@ -37,7 +37,6 @@ namespace Camera
|
||||
: public EditorCameraComponentBase
|
||||
, public EditorCameraViewRequestBus::Handler
|
||||
, private AzFramework::EntityDebugDisplayEventBus::Handler
|
||||
, private EditorCameraNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_EDITOR_COMPONENT(EditorCameraComponent, EditorCameraComponentTypeId, AzToolsFramework::Components::EditorComponentBase);
|
||||
@@ -55,9 +54,6 @@ namespace Camera
|
||||
const AzFramework::ViewportInfo& viewportInfo,
|
||||
AzFramework::DebugDisplayRequests& debugDisplay) override;
|
||||
|
||||
/// EditorCameraNotificationBus::Handler interface
|
||||
void OnViewportViewEntityChanged(const AZ::EntityId& newViewId) override;
|
||||
|
||||
/// EditorCameraViewRequestBus::Handler interface
|
||||
void ToggleCameraAsActiveView() override { OnPossessCameraButtonClicked(); }
|
||||
bool GetCameraState(AzFramework::CameraState& cameraState) override;
|
||||
@@ -67,7 +63,6 @@ namespace Camera
|
||||
AZ::Crc32 OnPossessCameraButtonClicked();
|
||||
AZStd::string GetCameraViewButtonText() const;
|
||||
|
||||
bool m_isActiveEditorCamera = false;
|
||||
float m_frustumViewPercentLength = 1.f;
|
||||
AZ::Color m_frustumDrawColor = AzFramework::ViewportColors::HoverColor;
|
||||
};
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <ViewManager.h>
|
||||
#include <Maestro/Bus/EditorSequenceBus.h>
|
||||
#include <Maestro/Bus/SequenceComponentBus.h>
|
||||
#include <AzToolsFramework/API/EditorCameraBus.h>
|
||||
|
||||
namespace Qt
|
||||
{
|
||||
@@ -83,8 +84,8 @@ namespace Camera
|
||||
return m_cameraId < rhs.m_cameraId;
|
||||
}
|
||||
|
||||
CameraListModel::CameraListModel(QObject* myParent)
|
||||
: QAbstractListModel(myParent)
|
||||
CameraListModel::CameraListModel(ViewportCameraSelectorWindow* myParent)
|
||||
: QAbstractListModel(myParent), m_parent(myParent)
|
||||
{
|
||||
m_cameraItems.push_back(AZ::EntityId());
|
||||
CameraNotificationBus::Handler::BusConnect();
|
||||
@@ -120,6 +121,18 @@ namespace Camera
|
||||
|
||||
void CameraListModel::OnCameraAdded(const AZ::EntityId& cameraId)
|
||||
{
|
||||
// If the camera entity is not an editor camera entity, don't add it to the list.
|
||||
// This occurs when we're in simulation mode.
|
||||
bool isEditorEntity = false;
|
||||
AzToolsFramework::EditorEntityContextRequestBus::BroadcastResult(
|
||||
isEditorEntity,
|
||||
&AzToolsFramework::EditorEntityContextRequests::IsEditorEntity,
|
||||
cameraId);
|
||||
if (!isEditorEntity)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||
m_cameraItems.push_back(cameraId);
|
||||
endInsertRows();
|
||||
@@ -143,38 +156,38 @@ namespace Camera
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Maestro::EditorSequenceNotificationBus::Handler
|
||||
void CameraListModel::OnSequenceSelected(const AZ::EntityId& sequenceEntityId)
|
||||
void CameraListModel::OnSequenceSelected(const AZ::EntityId& )
|
||||
{
|
||||
// Add or Remove the Sequence Camera option if a valid
|
||||
// sequence is selected in Track View.
|
||||
|
||||
// Check to see if the Sequence Camera option is already present
|
||||
bool found = false;
|
||||
int index = 0;
|
||||
for (const CameraListItem& cameraItem : m_cameraItems)
|
||||
{
|
||||
if (cameraItem.m_cameraName == m_sequenceCameraName)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
//bool found = false;
|
||||
//int index = 0;
|
||||
//for (const CameraListItem& cameraItem : m_cameraItems)
|
||||
//{
|
||||
// if (cameraItem.m_cameraName == m_sequenceCameraName)
|
||||
// {
|
||||
// found = true;
|
||||
// break;
|
||||
// }
|
||||
// ++index;
|
||||
//}
|
||||
|
||||
// If it is present, but no sequence is selected, removed it.
|
||||
if (found && !sequenceEntityId.IsValid())
|
||||
{
|
||||
beginRemoveRows(QModelIndex(), index, index);
|
||||
m_cameraItems.erase(m_cameraItems.begin() + index);
|
||||
endRemoveRows();
|
||||
}
|
||||
// If it is not present, and there is a sequence selected show it.
|
||||
else if (!found && sequenceEntityId.IsValid())
|
||||
{
|
||||
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||
m_cameraItems.push_back(CameraListItem(m_sequenceCameraName, sequenceEntityId));
|
||||
endInsertRows();
|
||||
}
|
||||
//// If it is present, but no sequence is selected, removed it.
|
||||
//if (found && !sequenceEntityId.IsValid())
|
||||
//{
|
||||
// beginRemoveRows(QModelIndex(), index, index);
|
||||
// m_cameraItems.erase(m_cameraItems.begin() + index);
|
||||
// endRemoveRows();
|
||||
//}
|
||||
//// If it is not present, and there is a sequence selected show it.
|
||||
//else if (!found && sequenceEntityId.IsValid())
|
||||
//{
|
||||
// beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||
// m_cameraItems.push_back(CameraListItem(m_sequenceCameraName, sequenceEntityId));
|
||||
// endInsertRows();
|
||||
//}
|
||||
}
|
||||
|
||||
QModelIndex CameraListModel::GetIndexForEntityId(const AZ::EntityId entityId)
|
||||
@@ -191,7 +204,7 @@ namespace Camera
|
||||
return index(row, 0);
|
||||
}
|
||||
|
||||
const char* CameraListModel::m_sequenceCameraName = "Sequence camera";
|
||||
//const char* CameraListModel::m_sequenceCameraName = "Sequence camera";
|
||||
|
||||
ViewportCameraSelectorWindow::ViewportCameraSelectorWindow(QWidget* parent)
|
||||
: m_ignoreViewportViewEntityChanged(false)
|
||||
@@ -242,8 +255,9 @@ namespace Camera
|
||||
if (current.row() != previous.row())
|
||||
{
|
||||
// Lock camera editing when in sequence camera mode.
|
||||
const AZStd::string& selectedCameraName = selectionModel()->currentIndex().data(Qt::DisplayRole).toString().toUtf8().data();
|
||||
bool lockCameraMovement = (selectedCameraName == CameraListModel::m_sequenceCameraName);
|
||||
//const AZStd::string& selectedCameraName = selectionModel()->currentIndex().data(Qt::DisplayRole).toString().toUtf8().data();
|
||||
//bool lockCameraMovement = (selectedCameraName == CameraListModel::m_sequenceCameraName);
|
||||
bool lockCameraMovement = false;
|
||||
|
||||
QScopedValueRollback<bool> rb(m_ignoreViewportViewEntityChanged, true);
|
||||
AZ::EntityId entityId = selectionModel()->currentIndex().data(Qt::CameraIdRole).value<AZ::EntityId>();
|
||||
@@ -298,14 +312,15 @@ namespace Camera
|
||||
void ViewportCameraSelectorWindow::OnCameraChanged(const AZ::EntityId& oldCameraEntityId, const AZ::EntityId& newCameraEntityId)
|
||||
{
|
||||
AZ_UNUSED(oldCameraEntityId);
|
||||
AZ_UNUSED(newCameraEntityId);
|
||||
|
||||
// If the Sequence camera option is selected, respond to camera changes by selecting the camera used by the sequence.
|
||||
const AZStd::string& selectedCameraName = selectionModel()->currentIndex().data(Qt::DisplayRole).toString().toUtf8().data();
|
||||
if (selectedCameraName == CameraListModel::m_sequenceCameraName)
|
||||
{
|
||||
QScopedValueRollback<bool> rb(m_ignoreViewportViewEntityChanged, true);
|
||||
EditorCameraRequests::Bus::Broadcast(&EditorCameraRequests::SetViewAndMovementLockFromEntityPerspective, newCameraEntityId, true);
|
||||
}
|
||||
//// If the Sequence camera option is selected, respond to camera changes by selecting the camera used by the sequence.
|
||||
//const AZStd::string& selectedCameraName = selectionModel()->currentIndex().data(Qt::DisplayRole).toString().toUtf8().data();
|
||||
//if (selectedCameraName == CameraListModel::m_sequenceCameraName)
|
||||
//{
|
||||
// QScopedValueRollback<bool> rb(m_ignoreViewportViewEntityChanged, true);
|
||||
// EditorCameraRequests::Bus::Broadcast(&EditorCameraRequests::SetViewAndMovementLockFromEntityPerspective, newCameraEntityId, true);
|
||||
//}
|
||||
}
|
||||
|
||||
// swallow mouse move events so we can disable sloppy selection
|
||||
|
||||
@@ -46,6 +46,8 @@ namespace Camera
|
||||
AZ::EntityId m_sequenceId;
|
||||
};
|
||||
|
||||
struct ViewportCameraSelectorWindow;
|
||||
|
||||
// holds a list of camera items
|
||||
struct CameraListModel
|
||||
: public QAbstractListModel
|
||||
@@ -54,9 +56,9 @@ namespace Camera
|
||||
{
|
||||
public:
|
||||
|
||||
static const char* m_sequenceCameraName;
|
||||
//static const char* m_sequenceCameraName;
|
||||
|
||||
CameraListModel(QObject* myParent);
|
||||
CameraListModel(ViewportCameraSelectorWindow* myParent);
|
||||
~CameraListModel();
|
||||
|
||||
// QAbstractItemModel interface
|
||||
@@ -76,6 +78,7 @@ namespace Camera
|
||||
AZStd::vector<CameraListItem> m_cameraItems;
|
||||
AZ::EntityId m_sequenceCameraEntityId;
|
||||
bool m_sequenceCameraSelected;
|
||||
ViewportCameraSelectorWindow* m_parent;
|
||||
};
|
||||
|
||||
struct ViewportCameraSelectorWindow
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
#
|
||||
@@ -9,6 +8,8 @@
|
||||
set(FILES camera_files.cmake
|
||||
Source/CameraComponent.cpp
|
||||
Source/CameraComponent.h
|
||||
Source/CameraSystemComponent.cpp
|
||||
Source/CameraSystemComponent.h
|
||||
Source/CameraComponentConverter.cpp
|
||||
Source/CameraComponentController.cpp
|
||||
Source/CameraComponentController.h
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
#include <PhysX/UserDataTypes.h>
|
||||
#include <PhysX/Utils.h>
|
||||
#include <PhysX/PhysXLocks.h>
|
||||
#include <PhysX/Debug/PhysXDebugConfiguration.h>
|
||||
|
||||
#include <AzFramework/Physics/PhysicsScene.h>
|
||||
#include <AzFramework/Physics/PhysicsSystem.h>
|
||||
#include <AzFramework/Physics/Ragdoll.h>
|
||||
#include <AzFramework/Physics/SystemBus.h>
|
||||
#include <AzFramework/Physics/Utils.h>
|
||||
#include <AzFramework/Components/CameraBus.h>
|
||||
|
||||
#include <IRenderAuxGeom.h>
|
||||
#include <MathConversion.h>
|
||||
@@ -468,16 +468,25 @@ namespace PhysXDebug
|
||||
RenderBuffers();
|
||||
}
|
||||
|
||||
AZ::Vector3 GetViewCameraPosition()
|
||||
{
|
||||
using namespace Camera;
|
||||
|
||||
AZ::Transform tm = AZ::Transform::CreateIdentity();
|
||||
ActiveCameraRequestBus::BroadcastResult(tm, &ActiveCameraRequestBus::Events::GetActiveCameraTransform);
|
||||
return tm.GetTranslation();
|
||||
}
|
||||
|
||||
void SystemComponent::UpdateColliderVisualizationByProximity()
|
||||
{
|
||||
if (auto* debug = AZ::Interface<PhysX::Debug::PhysXDebugInterface>::Get();
|
||||
UseEditorPhysicsScene() && m_settings.m_visualizeCollidersByProximity
|
||||
&& debug != nullptr)
|
||||
{
|
||||
const CCamera& camera = gEnv->pSystem->GetViewCamera();
|
||||
const AZ::Vector3& viewPos = GetViewCameraPosition();
|
||||
const PhysX::Debug::ColliderProximityVisualization data(
|
||||
m_settings.m_visualizeCollidersByProximity,
|
||||
LYVec3ToAZVec3(camera.GetPosition()),
|
||||
viewPos,
|
||||
m_culling.m_boxSize * 0.5f);
|
||||
debug->UpdateColliderProximityVisualization(data);
|
||||
}
|
||||
@@ -663,8 +672,7 @@ namespace PhysXDebug
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Physics);
|
||||
|
||||
// Currently using the Cry view camera to support Editor, Game and Launcher modes. This will be updated in due course.
|
||||
const CCamera& camera = gEnv->pSystem->GetViewCamera();
|
||||
AZ::Vector3 cameraTranslation = LYVec3ToAZVec3(camera.GetPosition());
|
||||
const AZ::Vector3 cameraTranslation = GetViewCameraPosition();
|
||||
|
||||
if (!cameraTranslation.IsClose(AZ::Vector3::CreateZero()))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user