Remove the legacy ViewSystem and some other tangentially related legacy code. (#5558)

Signed-off-by: bosnichd <bosnichd@amazon.com>
This commit is contained in:
bosnichd
2021-11-11 13:29:51 -07:00
committed by GitHub
parent 9e2a3226fd
commit 19acf94606
49 changed files with 73 additions and 3504 deletions
-1
View File
@@ -64,7 +64,6 @@ public:
// ovverided from CViewport.
float GetScreenScaleFactor(const Vec3& worldPoint) const override;
float GetScreenScaleFactor([[maybe_unused]] const CCamera& camera, [[maybe_unused]] const Vec3& object_position) override { return 1; } //Eric@conffx
// Overrided from CViewport.
void OnDragSelectRectangle(const QRect &rect, bool bNormalizeRect = false) override;
-31
View File
@@ -53,7 +53,6 @@
#include <AtomToolsFramework/Viewport/RenderViewportWidget.h>
// CryCommon
#include <CryCommon/HMDBus.h>
#include <CryCommon/IRenderAuxGeom.h>
// AzFramework
@@ -556,22 +555,6 @@ void EditorViewportWidget::OnEditorNotifyEvent(EEditorNotifyEvent event)
// this should only occur for the main viewport and no others.
ShowCursor();
// If the user has selected game mode, enable outputting to any attached HMD and properly size the context
// to the resolution specified by the VR device.
if (gSettings.bEnableGameModeVR)
{
const AZ::VR::HMDDeviceInfo* deviceInfo = nullptr;
EBUS_EVENT_RESULT(deviceInfo, AZ::VR::HMDDeviceRequestBus, GetDeviceInfo);
AZ_Warning("Render Viewport", deviceInfo, "No VR device detected");
if (deviceInfo)
{
// Note: This may also need to adjust the viewport size
SetActiveWindow();
SetFocus();
SetSelected(true);
}
}
SetCurrentCursor(STD_CURSOR_GAME);
if (ShouldPreviewFullscreen())
@@ -1815,13 +1798,6 @@ float EditorViewportWidget::GetScreenScaleFactor([[maybe_unused]] const Vec3& wo
AZ_Error("CryLegacy", false, "EditorViewportWidget::GetScreenScaleFactor not implemented");
return 1.f;
}
//////////////////////////////////////////////////////////////////////////
float EditorViewportWidget::GetScreenScaleFactor(const CCamera& camera, const Vec3& object_position)
{
Vec3 camPos = camera.GetPosition();
float dist = camPos.GetDistance(object_position);
return dist;
}
//////////////////////////////////////////////////////////////////////////
bool EditorViewportWidget::CheckRespondToInput() const
@@ -1842,7 +1818,6 @@ bool EditorViewportWidget::CheckRespondToInput() const
//////////////////////////////////////////////////////////////////////////
bool EditorViewportWidget::HitTest(const QPoint& point, HitContext& hitInfo)
{
hitInfo.camera = nullptr;
hitInfo.pExcludedObject = GetCameraObject();
return QtViewport::HitTest(point, hitInfo);
}
@@ -2547,12 +2522,6 @@ bool EditorViewportWidget::ShouldPreviewFullscreen() const
return false;
}
// Not supported in VR
if (gSettings.bEnableGameModeVR)
{
return false;
}
// If level not loaded, don't preview in fullscreen (preview shouldn't work at all without a level, but it does)
if (auto ge = GetIEditor()->GetGameEngine())
{
-2
View File
@@ -10,7 +10,6 @@
#pragma once
#if !defined(Q_MOC_RUN)
#include <Cry_Camera.h>
#include <QSet>
@@ -172,7 +171,6 @@ private:
void ViewToWorldRay(const QPoint& vp, Vec3& raySrc, Vec3& rayDir) const override;
Vec3 ViewToWorldNormal(const QPoint& vp, bool onlyTerrain, bool bTestRenderMesh = false) override;
float GetScreenScaleFactor(const Vec3& worldPoint) const override;
float GetScreenScaleFactor(const CCamera& camera, const Vec3& object_position) override;
float GetAspectRatio() const override;
bool HitTest(const QPoint& point, HitContext& hitInfo) override;
bool IsBoundsVisible(const AABB& box) const override;
-4
View File
@@ -19,7 +19,6 @@ class CBaseObject;
struct IDisplayViewport;
class CDeepSelection;
struct AABB;
class CCamera;
#include <QRect>
#include <platform.h>
@@ -68,8 +67,6 @@ struct HitContext
QRect rect;
//! Optional limiting bounding box for hit testing.
AABB* bounds;
//! Optional camera for culling perspective viewports.
CCamera* camera;
//! Testing performed in 2D viewport.
bool b2DViewport;
@@ -120,7 +117,6 @@ struct HitContext
rect = QRect();
b2DViewport = false;
view = 0;
camera = 0;
point2d = QPoint();
axis = 0;
distanceTolerance = 0;
-2
View File
@@ -14,7 +14,6 @@
struct DisplayContext;
class CBaseObjectsCache;
class QPoint;
class CCamera;
struct AABB;
class CViewport;
@@ -23,7 +22,6 @@ struct IDisplayViewport
{
virtual void Update() = 0;
virtual float GetScreenScaleFactor(const Vec3& position) const = 0;
virtual float GetScreenScaleFactor(const CCamera& camera, const Vec3& object_position) = 0;
virtual bool HitTestLine(const Vec3& lineP1, const Vec3& lineP2, const QPoint& hitpoint, int pixelRadius, float* pToCameraDistance = 0) const = 0;
/**
+2 -42
View File
@@ -953,14 +953,8 @@ void CBaseObject::DrawTextureIcon(DisplayContext& dc, [[maybe_unused]] const Vec
}
//////////////////////////////////////////////////////////////////////////
void CBaseObject::DrawWarningIcons(DisplayContext& dc, const Vec3& pos)
void CBaseObject::DrawWarningIcons(DisplayContext& dc, const Vec3&)
{
// Don't draw warning icons if they are beyond draw distance
if ((dc.camera->GetPosition() - pos).GetLength() > gSettings.viewports.fWarningIconsDrawDistance)
{
return;
}
if (gSettings.viewports.bShowIcons || gSettings.viewports.bShowSizeBasedIcons)
{
const int warningIconSizeX = OBJECT_TEXTURE_ICON_SIZEX / 2;
@@ -1010,11 +1004,8 @@ void CBaseObject::DrawLabel(DisplayContext& dc, const Vec3& pos, const QColor& l
labelColor = QColor(0, 0, 0);
}
float camDist = dc.camera->GetPosition().GetDistance(pos);
float maxDist = dc.settings->GetLabelsDistance();
if (camDist < dc.settings->GetLabelsDistance() || (dc.flags & DISPLAY_SELECTION_HELPERS))
if (dc.flags & DISPLAY_SELECTION_HELPERS)
{
float range = maxDist / 2.0f;
Vec3 c(static_cast<f32>(labelColor.redF()), static_cast<f32>(labelColor.greenF()), static_cast<f32>(labelColor.redF()));
if (IsSelected())
{
@@ -1032,10 +1023,6 @@ void CBaseObject::DrawLabel(DisplayContext& dc, const Vec3& pos, const QColor& l
col[1] = c.y;
col[2] = c.z;
}
else if (camDist > range)
{
col[3] = col[3] * (1.0f - (camDist - range) / range);
}
dc.SetColor(col[0], col[1], col[2], col[3] * alpha);
dc.DrawTextLabel(pos, size, GetName().toUtf8().data());
@@ -1196,33 +1183,6 @@ bool CBaseObject::CanBeDrawn(const DisplayContext& dc, bool& outDisplaySelection
return bResult;
}
//////////////////////////////////////////////////////////////////////////
bool CBaseObject::IsInCameraView(const CCamera& camera)
{
AABB bbox;
GetBoundBox(bbox);
return (camera.IsAABBVisible_F(AABB(bbox.min, bbox.max)));
}
//////////////////////////////////////////////////////////////////////////
float CBaseObject::GetCameraVisRatio(const CCamera& camera)
{
AABB bbox;
GetBoundBox(bbox);
static const float defaultVisRatio = 1000.0f;
const float objectHeightSq = max(1.0f, (bbox.max - bbox.min).GetLengthSquared());
const float camdistSq = (bbox.min - camera.GetPosition()).GetLengthSquared();
float visRatio = defaultVisRatio;
if (camdistSq > FLT_EPSILON)
{
visRatio = objectHeightSq / camdistSq;
}
return visRatio;
}
//////////////////////////////////////////////////////////////////////////
int CBaseObject::MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags)
{
-5
View File
@@ -674,11 +674,6 @@ protected:
//! Returns if the object can be drawn, and if its selection helper should also be drawn.
bool CanBeDrawn(const DisplayContext& dc, bool& outDisplaySelectionHelper) const;
//! Returns if object is in the camera view.
virtual bool IsInCameraView(const CCamera& camera);
//! Returns vis ratio of object in camera
virtual float GetCameraVisRatio(const CCamera& camera);
// Do basic intersection tests
virtual bool IntersectRectBounds(const AABB& bbox);
virtual bool IntersectRayBounds(const Ray& ray);
-2
View File
@@ -31,7 +31,6 @@ struct IRenderer;
struct IRenderAuxGeom;
struct IIconManager;
class CDisplaySettings;
class CCamera;
class QPoint;
enum DisplayFlags
@@ -66,7 +65,6 @@ struct SANDBOX_API DisplayContext
IDisplayViewport* view;
IRenderAuxGeom* pRenderAuxGeom;
IIconManager* pIconManager;
CCamera* camera;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
AABB box; // Bounding box of volume that need to be repainted.
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
@@ -1138,10 +1138,6 @@ bool DisplayContext::IsVisible(const AABB& bounds)
return true;
}
}
else
{
return camera->IsAABBVisible_F(AABB(bounds.min, bounds.max));
}
return false;
}
-8
View File
@@ -98,16 +98,8 @@ void CLineGizmo::Display(DisplayContext& dc)
Vec3 pos = 0.5f * (m_point[0] + m_point[1]);
//dc.renderer->DrawLabelEx( p3+Vec3(0,0,0.3f),1.2f,col,true,true,m_name );
float camDist = dc.camera->GetPosition().GetDistance(pos);
float maxDist = dc.settings->GetLabelsDistance();
if (camDist < dc.settings->GetLabelsDistance())
{
float range = maxDist / 2.0f;
float col[4] = { m_color[0].r, m_color[0].g, m_color[0].b, m_color[0].a };
if (camDist > range)
{
col[3] = col[3] * (1.0f - (camDist - range) / range);
}
dc.SetColor(col[0], col[1], col[2], col[3]);
dc.DrawTextLabel(pos + Vec3(0, 0, 0.2f), 1.2f, m_name.toUtf8().data());
}
+1 -5
View File
@@ -1488,11 +1488,7 @@ bool CObjectManager::HitTestObject(CBaseObject* obj, HitContext& hc)
if (!bSelectionHelperHit)
{
// Fast checking.
if (hc.camera && !obj->IsInCameraView(*hc.camera))
{
return false;
}
else if (hc.bounds && !obj->IntersectRectBounds(*hc.bounds))
if (hc.bounds && !obj->IntersectRectBounds(*hc.bounds))
{
return false;
}
-2
View File
@@ -112,8 +112,6 @@ SEditorSettings::SEditorSettings()
m_showCircularDependencyError = true;
bAutoloadLastLevelAtStartup = false;
bMuteAudio = false;
bEnableGameModeVR = false;
objectHideMask = 0;
objectSelectMask = 0xFFFFFFFF; // Initially all selectable.
-1
View File
@@ -305,7 +305,6 @@ AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
bool m_showCircularDependencyError;
bool bAutoloadLastLevelAtStartup;
bool bMuteAudio;
bool bEnableGameModeVR;
//! Speed of camera movement.
float cameraMoveSpeed;
+65 -2
View File
@@ -1407,6 +1407,69 @@ void QtViewport::ProcessRenderLisneters(DisplayContext& rstDisplayContext)
}
//////////////////////////////////////////////////////////////////////////
#if defined(AZ_PLATFORM_WINDOWS)
// Note: Both CreateAnglesYPR and CreateOrientationYPR were copied verbatim from Cry_Camera.h which has been removed.
//
// Description
// <PRE>
// x-YAW
// y-PITCH (negative=looking down / positive=looking up)
// z-ROLL
// </PRE>
// Note: If we are looking along the z-axis, its not possible to specify the x and z-angle
inline Ang3 CreateAnglesYPR(const Matrix33& m)
{
assert(m.IsOrthonormal());
float l = Vec3(m.m01, m.m11, 0.0f).GetLength();
if (l > 0.0001)
{
return Ang3(atan2f(-m.m01 / l, m.m11 / l), atan2f(m.m21, l), atan2f(-m.m20 / l, m.m22 / l));
}
else
{
return Ang3(0, atan2f(m.m21, l), 0);
}
}
// Description
// This function builds a 3x3 orientation matrix using YPR-angles
// Rotation order for the orientation-matrix is Z-X-Y. (Zaxis=YAW / Xaxis=PITCH / Yaxis=ROLL)
//
// <PRE>
// COORDINATE-SYSTEM
//
// z-axis
// ^
// |
// | y-axis
// | /
// | /
// |/
// +---------------> x-axis
// </PRE>
//
// Example:
// Matrix33 orientation=CreateOrientationYPR( Ang3(1,2,3) );
inline Matrix33 CreateOrientationYPR(const Ang3& ypr)
{
f32 sz, cz;
sincos_tpl(ypr.x, &sz, &cz); //Zaxis = YAW
f32 sx, cx;
sincos_tpl(ypr.y, &sx, &cx); //Xaxis = PITCH
f32 sy, cy;
sincos_tpl(ypr.z, &sy, &cy); //Yaxis = ROLL
Matrix33 c;
c.m00 = cy * cz - sy * sz * sx;
c.m01 = -sz * cx;
c.m02 = sy * cz + cy * sz * sx;
c.m10 = cy * sz + sy * sx * cz;
c.m11 = cz * cx;
c.m12 = sy * sz - cy * sx * cz;
c.m20 = -sy * cx;
c.m21 = sx;
c.m22 = cy * cx;
return c;
}
void QtViewport::OnRawInput([[maybe_unused]] UINT wParam, HRAWINPUT lParam)
{
static C3DConnexionDriver* p3DConnexionDriver = 0;
@@ -1450,12 +1513,12 @@ void QtViewport::OnRawInput([[maybe_unused]] UINT wParam, HRAWINPUT lParam)
t *= sys_scale3DMouseTranslation->GetFVal();
float as = 0.001f * gSettings.cameraMoveSpeed;
Ang3 ypr = CCamera::CreateAnglesYPR(Matrix33(viewTM));
Ang3 ypr = CreateAnglesYPR(Matrix33(viewTM));
ypr.x += -all6DOFs[5] * as * fScaleYPR;
ypr.y = AZStd::clamp(ypr.y + all6DOFs[3] * as * fScaleYPR, -1.5f, 1.5f); // to keep rotation in reasonable range
ypr.z = 0; // to have camera always upward
viewTM = Matrix34(CCamera::CreateOrientationYPR(ypr), viewTM.GetTranslation());
viewTM = Matrix34(CreateOrientationYPR(ypr), viewTM.GetTranslation());
viewTM = viewTM * Matrix34::CreateTranslationMat(t);
SetViewTM(viewTM);
-34
View File
@@ -138,14 +138,11 @@ CViewportTitleDlg::CViewportTitleDlg(QWidget* pParent)
connect(this, &CViewportTitleDlg::ActionTriggered, MainWindow::instance()->GetActionManager(), &ActionManager::ActionTriggered);
AZ::VR::VREventBus::Handler::BusConnect();
OnInitDialog();
}
CViewportTitleDlg::~CViewportTitleDlg()
{
AZ::VR::VREventBus::Handler::BusDisconnect();
GetISystem()->GetISystemEventDispatcher()->RemoveListener(this);
GetIEditor()->UnregisterNotifyListener(this);
@@ -236,10 +233,6 @@ void CViewportTitleDlg::SetupOverflowMenu()
connect(m_audioMuteAction, &QAction::triggered, this, &CViewportTitleDlg::OnBnClickedMuteAudio);
overFlowMenu->addAction(m_audioMuteAction);
m_enableVRAction = new QAction("Enable VR Preview", overFlowMenu);
connect(m_enableVRAction, &QAction::triggered, this, &CViewportTitleDlg::OnBnClickedEnableVR);
overFlowMenu->addAction(m_enableVRAction);
overFlowMenu->addSeparator();
m_enableGridSnappingAction = new QAction("Enable Grid Snapping", overFlowMenu);
@@ -305,16 +298,6 @@ void CViewportTitleDlg::OnInitDialog()
connect(displayInfoHelper, &CViewportTitleDlgDisplayInfoHelper::ViewportInfoStatusUpdated, this, &CViewportTitleDlg::UpdateDisplayInfo);
UpdateDisplayInfo();
// This is here just in case this class hasn't been created before
// a VR headset was initialized
m_enableVRAction->setEnabled(false);
if (AZ::VR::HMDDeviceRequestBus::GetTotalNumOfEventHandlers() != 0)
{
m_enableVRAction->setEnabled(true);
}
AZ::VR::VREventBus::Handler::BusConnect();
QFontMetrics metrics({});
int width = static_cast<int>(metrics.boundingRect("-9999.99").width() * m_fieldWidthMultiplier);
@@ -931,23 +914,6 @@ void CViewportTitleDlg::UpdateMuteActionText()
}
}
void CViewportTitleDlg::OnHMDInitialized()
{
m_enableVRAction->setEnabled(true);
}
void CViewportTitleDlg::OnHMDShutdown()
{
m_enableVRAction->setEnabled(false);
}
void CViewportTitleDlg::OnBnClickedEnableVR()
{
gSettings.bEnableGameModeVR = !gSettings.bEnableGameModeVR;
m_enableVRAction->setText(gSettings.bEnableGameModeVR ? tr("Disable VR Preview") : tr("Enable VR Preview"));
}
inline double Round(double fVal, double fStep)
{
if (fStep > 0.f)
-11
View File
@@ -22,7 +22,6 @@
#include <AzToolsFramework/UI/Prefab/PrefabViewportFocusPathHandler.h>
#include <AzQtComponents/Components/Widgets/SpinBox.h>
#include <HMDBus.h>
#endif
// CViewportTitleDlg dialog
@@ -44,7 +43,6 @@ class CViewportTitleDlg
: public QWidget
, public IEditorNotifyListener
, public ISystemEventListener
, public AZ::VR::VREventBus::Handler
{
Q_OBJECT
public:
@@ -85,13 +83,6 @@ protected:
void OnToggleHelpers();
void UpdateDisplayInfo();
//////////////////////////////////////////////////////////////////////////
/// VR Event Bus Implementation
//////////////////////////////////////////////////////////////////////////
void OnHMDInitialized() override;
void OnHMDShutdown() override;
//////////////////////////////////////////////////////////////////////////
void SetupCameraDropdownMenu();
void SetupResolutionDropdownMenu();
void SetupViewportInformationMenu();
@@ -140,7 +131,6 @@ protected:
void OnBnClickedGotoPosition();
void OnBnClickedMuteAudio();
void OnBnClickedEnableVR();
void UpdateMuteActionText();
@@ -168,7 +158,6 @@ protected:
QAction* m_fullInformationAction = nullptr;
QAction* m_compactInformationAction = nullptr;
QAction* m_audioMuteAction = nullptr;
QAction* m_enableVRAction = nullptr;
QAction* m_enableGridSnappingAction = nullptr;
QAction* m_enableAngleSnappingAction = nullptr;
QComboBox* m_cameraSpeed = nullptr;