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]);
|
||||
|
||||
Reference in New Issue
Block a user