From b185a94519c22d9b91749e826d25e65a90f03b70 Mon Sep 17 00:00:00 2001 From: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> Date: Tue, 11 May 2021 14:09:09 +0100 Subject: [PATCH] Remove all references to old CGrid system (#672) * add overload to ActionManager to support capturing an AZStd::function * move snapping settings to new settings registry * remove unneeded reference in ViewportSettings * move viewport setting function implementations to .cpp file * add more sensible default values for snapping * fix variable name for angle snapping * remove const from function prototype value parameters * add import/export api for free functions * change from std::bind to a lambda * remove redundant const for constexpr string_view * add AZStd alias for std::abs * restore grid and angle snapping * add overload to ActionManager to support capturing an AZStd::function * remove old legacy CGrid code * fix build after merge * review feedback changes - remove 1.0f multiplies --- Code/Sandbox/Editor/2DViewport.cpp | 8 +- .../Editor/Core/LevelEditorMenuHandler.cpp | 3 - Code/Sandbox/Editor/CryEdit.cpp | 10 - Code/Sandbox/Editor/CryEdit.h | 1 - Code/Sandbox/Editor/CryEditDoc.cpp | 14 - Code/Sandbox/Editor/Grid.cpp | 150 ------ Code/Sandbox/Editor/Grid.h | 74 --- Code/Sandbox/Editor/GridSettingsDialog.cpp | 169 ------ Code/Sandbox/Editor/GridSettingsDialog.h | 65 --- Code/Sandbox/Editor/GridSettingsDialog.ui | 505 ------------------ Code/Sandbox/Editor/MainWindow.cpp | 59 +- Code/Sandbox/Editor/MainWindow.h | 2 - Code/Sandbox/Editor/Objects/AxisGizmo.cpp | 4 +- Code/Sandbox/Editor/Objects/BaseObject.cpp | 6 - .../Sandbox/Editor/Objects/SelectionGroup.cpp | 3 +- Code/Sandbox/Editor/RenderViewport.cpp | 96 +--- Code/Sandbox/Editor/Resource.h | 1 - Code/Sandbox/Editor/Settings.h | 5 - Code/Sandbox/Editor/ViewManager.cpp | 2 - Code/Sandbox/Editor/ViewManager.h | 6 - Code/Sandbox/Editor/Viewport.cpp | 4 +- Code/Sandbox/Editor/editor_lib_files.cmake | 5 - 22 files changed, 19 insertions(+), 1173 deletions(-) delete mode 100644 Code/Sandbox/Editor/Grid.cpp delete mode 100644 Code/Sandbox/Editor/Grid.h delete mode 100644 Code/Sandbox/Editor/GridSettingsDialog.cpp delete mode 100644 Code/Sandbox/Editor/GridSettingsDialog.h delete mode 100644 Code/Sandbox/Editor/GridSettingsDialog.ui diff --git a/Code/Sandbox/Editor/2DViewport.cpp b/Code/Sandbox/Editor/2DViewport.cpp index a511be0e2a..9eab4df16d 100644 --- a/Code/Sandbox/Editor/2DViewport.cpp +++ b/Code/Sandbox/Editor/2DViewport.cpp @@ -660,9 +660,7 @@ void Q2DViewport::Draw(DisplayContext& dc) ////////////////////////////////////////////////////////////////////////// void Q2DViewport::DrawGrid(DisplayContext& dc, bool bNoXNumbers) { - CGrid* pGrid = GetIEditor()->GetViewManager()->GetGrid(); - float gridSize = pGrid->size; - + float gridSize = 1.0f; if (gridSize < 0.00001f) { return; @@ -693,8 +691,6 @@ void Q2DViewport::DrawGrid(DisplayContext& dc, bool bNoXNumbers) pixelsPerGrid = gridSize * fScale; while (pixelsPerGrid <= 5 && griditers++ < 20) { - m_fGridZoom *= pGrid->majorLine; - gridSize = gridSize * pGrid->majorLine; pixelsPerGrid = gridSize * fScale; } } @@ -743,7 +739,7 @@ void Q2DViewport::DrawGrid(DisplayContext& dc, bool bNoXNumbers) ////////////////////////////////////////////////////////////////////////// // Draw Major grid lines. ////////////////////////////////////////////////////////////////////////// - gridSize = gridSize * pGrid->majorLine; + gridSize = gridSize * 1.0f; if (m_bAutoAdjustGrids) { diff --git a/Code/Sandbox/Editor/Core/LevelEditorMenuHandler.cpp b/Code/Sandbox/Editor/Core/LevelEditorMenuHandler.cpp index 1bb8dc37c7..0ce3fa55f5 100644 --- a/Code/Sandbox/Editor/Core/LevelEditorMenuHandler.cpp +++ b/Code/Sandbox/Editor/Core/LevelEditorMenuHandler.cpp @@ -729,9 +729,6 @@ QMenu* LevelEditorMenuHandler::CreateViewMenu() viewportViewsMenuWrapper.AddAction(ID_WIREFRAME); viewportViewsMenuWrapper.AddSeparator(); - viewportViewsMenuWrapper.AddAction(ID_VIEW_GRIDSETTINGS); - viewportViewsMenuWrapper.AddSeparator(); - if (CViewManager::IsMultiViewportEnabled()) { viewportViewsMenuWrapper.AddAction(ID_VIEW_CONFIGURELAYOUT); diff --git a/Code/Sandbox/Editor/CryEdit.cpp b/Code/Sandbox/Editor/CryEdit.cpp index c762244d38..6e33d32c6e 100644 --- a/Code/Sandbox/Editor/CryEdit.cpp +++ b/Code/Sandbox/Editor/CryEdit.cpp @@ -95,7 +95,6 @@ AZ_POP_DISABLE_WARNING #include "Core/QtEditorApplication.h" #include "StringDlg.h" #include "NewLevelDialog.h" -#include "GridSettingsDialog.h" #include "LayoutConfigDialog.h" #include "ViewManager.h" #include "FileTypeUtils.h" @@ -400,7 +399,6 @@ void CCryEditApp::RegisterActionHandlers() ON_COMMAND(ID_WIREFRAME, OnWireframe) - ON_COMMAND(ID_VIEW_GRIDSETTINGS, OnViewGridsettings) ON_COMMAND(ID_VIEW_CONFIGURELAYOUT, OnViewConfigureLayout) ON_COMMAND(IDC_SELECTION, OnDummyCommand) @@ -3459,14 +3457,6 @@ void CCryEditApp::OnUpdateWireframe(QAction* action) action->setChecked(nWireframe == R_WIREFRAME_MODE); } - -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnViewGridsettings() -{ - CGridSettingsDialog dlg; - dlg.exec(); -} - ////////////////////////////////////////////////////////////////////////// void CCryEditApp::OnViewConfigureLayout() { diff --git a/Code/Sandbox/Editor/CryEdit.h b/Code/Sandbox/Editor/CryEdit.h index 9599062d3f..2e71ca6a58 100644 --- a/Code/Sandbox/Editor/CryEdit.h +++ b/Code/Sandbox/Editor/CryEdit.h @@ -366,7 +366,6 @@ private: void OnWireframe(); void OnUpdateWireframe(QAction* action); - void OnViewGridsettings(); void OnViewConfigureLayout(); // Tag Locations. diff --git a/Code/Sandbox/Editor/CryEditDoc.cpp b/Code/Sandbox/Editor/CryEditDoc.cpp index 64c830474f..a6c5f73c7f 100644 --- a/Code/Sandbox/Editor/CryEditDoc.cpp +++ b/Code/Sandbox/Editor/CryEditDoc.cpp @@ -587,15 +587,6 @@ void CCryEditDoc::SerializeViewSettings(CXmlArchive& xmlAr) { viewportContext->SetCameraTransform(LYTransformToAZTransform(tm)); } - - // Load grid. - auto gridName = QString("Grid%1").arg(useOldViewFormat ? "" : QString::number(i)); - XmlNodeRef gridNode = xmlAr.root->newChild(gridName.toUtf8().constData()); - - if (gridNode) - { - GetIEditor()->GetViewManager()->GetGrid()->Serialize(gridNode, xmlAr.bLoading); - } } } else @@ -621,11 +612,6 @@ void CCryEditDoc::SerializeViewSettings(CXmlArchive& xmlAr) auto viewerAnglesName = QString("ViewerAngles%1").arg(i); view->setAttr(viewerAnglesName.toUtf8().constData(), angles); } - - // Save grid. - auto gridName = QString("Grid%1").arg(i); - XmlNodeRef gridNode = xmlAr.root->newChild(gridName.toUtf8().constData()); - GetIEditor()->GetViewManager()->GetGrid()->Serialize(gridNode, xmlAr.bLoading); } } } diff --git a/Code/Sandbox/Editor/Grid.cpp b/Code/Sandbox/Editor/Grid.cpp deleted file mode 100644 index 50702f8cb2..0000000000 --- a/Code/Sandbox/Editor/Grid.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "EditorDefs.h" - -#include "Grid.h" - -// Editor -#include "Settings.h" -#include "Objects/SelectionGroup.h" - -////////////////////////////////////////////////////////////////////////// -CGrid::CGrid() -{ - scale = 1; - size = 1; - majorLine = 16; - bEnabled = true; - rotationAngles = Ang3(0.0f, 0.0f, 0.0f); - translation = Vec3(0.0f, 0.0f, 0.0f); - - bAngleSnapEnabled = true; - angleSnap = 5; -} - -////////////////////////////////////////////////////////////////////////// -Vec3 CGrid::Snap(const Vec3& vec) const -{ - if (!bEnabled || size < 0.001) - { - return vec; - } - Vec3 snapped; - snapped.x = floor((vec.x / size) / scale + 0.5) * size * scale; - snapped.y = floor((vec.y / size) / scale + 0.5) * size * scale; - snapped.z = floor((vec.z / size) / scale + 0.5) * size * scale; - return snapped; -} - -////////////////////////////////////////////////////////////////////////// -Vec3 CGrid::Snap(const Vec3& vec, double fZoom) const -{ - if (!bEnabled || size < 0.001f) - { - return vec; - } - - Matrix34 tm = GetMatrix(); - - double zoomscale = scale * fZoom; - Vec3 snapped; - - Matrix34 invtm = tm.GetInverted(); - - snapped = invtm * vec; - - snapped.x = floor((snapped.x / size) / zoomscale + 0.5) * size * zoomscale; - snapped.y = floor((snapped.y / size) / zoomscale + 0.5) * size * zoomscale; - snapped.z = floor((snapped.z / size) / zoomscale + 0.5) * size * zoomscale; - - snapped = tm * snapped; - - return snapped; -} - -////////////////////////////////////////////////////////////////////////// -double CGrid::SnapAngle(double angle) const -{ - if (!bAngleSnapEnabled) - { - return angle; - } - return floor(angle / angleSnap + 0.5) * angleSnap; -} - -////////////////////////////////////////////////////////////////////////// -Ang3 CGrid::SnapAngle(const Ang3& vec) const -{ - if (!bAngleSnapEnabled) - { - return vec; - } - Ang3 snapped; - snapped.x = floor(vec.x / angleSnap + 0.5) * angleSnap; - snapped.y = floor(vec.y / angleSnap + 0.5) * angleSnap; - snapped.z = floor(vec.z / angleSnap + 0.5) * angleSnap; - return snapped; -} - -////////////////////////////////////////////////////////////////////////// -void CGrid::Serialize(XmlNodeRef& xmlNode, bool bLoading) -{ - if (bLoading) - { - // Loading. - xmlNode->getAttr("Size", size); - xmlNode->getAttr("Scale", scale); - xmlNode->getAttr("Enabled", bEnabled); - xmlNode->getAttr("MajorSize", majorLine); - xmlNode->getAttr("AngleSnap", angleSnap); - xmlNode->getAttr("AngleSnapEnabled", bAngleSnapEnabled); - if (size < 0.01) - { - size = 0.01; - } - } - else - { - // Saving. - xmlNode->setAttr("Size", size); - xmlNode->setAttr("Scale", scale); - xmlNode->setAttr("Enabled", bEnabled); - xmlNode->setAttr("MajorSize", majorLine); - xmlNode->setAttr("AngleSnap", angleSnap); - xmlNode->setAttr("AngleSnapEnabled", bAngleSnapEnabled); - } -} - -////////////////////////////////////////////////////////////////////////// -Matrix34 CGrid::GetMatrix() const -{ - Matrix34 tm; - - if (gSettings.snap.bGridUserDefined) - { - Ang3 angles = Ang3(rotationAngles.x * gf_PI / 180.0, rotationAngles.y * gf_PI / 180.0, rotationAngles.z * gf_PI / 180.0); - - tm = Matrix33::CreateRotationXYZ(angles); - } - else if (GetIEditor()->GetReferenceCoordSys() == COORDS_LOCAL) - { - tm.SetIdentity(); - } - else - { - tm.SetIdentity(); - } - - return tm; -} diff --git a/Code/Sandbox/Editor/Grid.h b/Code/Sandbox/Editor/Grid.h deleted file mode 100644 index dd761ad058..0000000000 --- a/Code/Sandbox/Editor/Grid.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#ifndef CRYINCLUDE_EDITOR_GRID_H -#define CRYINCLUDE_EDITOR_GRID_H - -#pragma once - -/** Definition of grid used in 2D viewports. -*/ -class SANDBOX_API CGrid -{ -public: - //! Resolution of grid, it must be multiply of 2. - double size; - //! Draw major lines every Nth grid line. - int majorLine; - //! True if grid enabled. - bool bEnabled; - //! Meters per grid unit. - double scale; - - AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING - Ang3 rotationAngles; - Vec3 translation; - AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING - - //! If snap to angle. - bool bAngleSnapEnabled; - double angleSnap; - - ////////////////////////////////////////////////////////////////////////// - CGrid(); - - //! Snap vector to this grid. - Vec3 Snap(const Vec3& vec) const; - Vec3 Snap(const Vec3& vec, double fZoom) const; - - //! Snap angle to current angle snapping value. - double SnapAngle(double angle) const; - //! Snap angle to current angle snapping value. - Ang3 SnapAngle(const Ang3& angle) const; - - //! Enable or disable grid. - void Enable(bool enable) { bEnabled = enable; } - //! Check if grid enabled. - bool IsEnabled() const { return bEnabled; } - - //! Enables or disable angle snapping. - void EnableAngleSnap(bool enable) { bAngleSnapEnabled = enable; }; - - //! Return if snapping of angle is enabled. - bool IsAngleSnapEnabled() const { return bAngleSnapEnabled; }; - //! Returns ammount of snapping for angle in degrees. - double GetAngleSnap() const { return angleSnap; }; - - void Serialize(XmlNodeRef& xmlNode, bool bLoading); - - //! Get transformation matrix of gird. - Matrix34 GetMatrix() const; -}; - - -#endif // CRYINCLUDE_EDITOR_GRID_H diff --git a/Code/Sandbox/Editor/GridSettingsDialog.cpp b/Code/Sandbox/Editor/GridSettingsDialog.cpp deleted file mode 100644 index ecabdc4e6a..0000000000 --- a/Code/Sandbox/Editor/GridSettingsDialog.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "EditorDefs.h" - -#include "GridSettingsDialog.h" - -// Editor -#include "Settings.h" -#include "Objects/SelectionGroup.h" -#include "ViewManager.h" - - -AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING -#include -AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING - -// CGridSettingsDialog dialog - -CGridSettingsDialog::CGridSettingsDialog(QWidget* pParent /*=NULL*/) - : QDialog(pParent) - , ui(new Ui::CGridSettingsDialog) -{ - ui->setupUi(this); - - setWindowTitle(tr("Grid/Snap Settings")); - - OnInitDialog(); - - connect(ui->m_userDefined, &QCheckBox::clicked, this, &CGridSettingsDialog::OnBnUserDefined); - connect(ui->m_getFromObject, &QCheckBox::clicked, this, &CGridSettingsDialog::OnBnGetFromObject); - - auto doubleSpinBoxValueChanged = static_cast(&QDoubleSpinBox::valueChanged); - - connect(ui->m_angleX, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate); - connect(ui->m_angleY, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate); - connect(ui->m_angleZ, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate); - - connect(ui->m_gridSize, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate); - connect(ui->m_gridScale, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate); - connect(ui->m_CPSize, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate); - - connect(ui->m_displayCP, &QCheckBox::clicked, this, &CGridSettingsDialog::OnValueUpdate); - connect(ui->m_getFromObject, &QCheckBox::clicked, this, &CGridSettingsDialog::OnValueUpdate); - - connect(ui->m_buttonBox, &QDialogButtonBox::accepted, this, &CGridSettingsDialog::accept); - connect(ui->m_buttonBox, &QDialogButtonBox::rejected, this, &CGridSettingsDialog::reject); -} - -CGridSettingsDialog::~CGridSettingsDialog() -{ -} - -////////////////////////////////////////////////////////////////////////// -void CGridSettingsDialog::OnInitDialog() -{ - CGrid* pGrid = GetIEditor()->GetViewManager()->GetGrid(); - - ui->m_userDefined->setChecked(gSettings.snap.bGridUserDefined); - ui->m_getFromObject->setChecked(gSettings.snap.bGridGetFromSelected); - - ui->m_angleX->setValue(pGrid->rotationAngles.x); - ui->m_angleY->setValue(pGrid->rotationAngles.y); - ui->m_angleZ->setValue(pGrid->rotationAngles.z); - - ui->m_translationX->setValue(pGrid->translation.x); - ui->m_translationY->setValue(pGrid->translation.y); - ui->m_translationZ->setValue(pGrid->translation.z); - - ui->m_gridSize->setValue(pGrid->size); - ui->m_gridScale->setValue(pGrid->scale); - ui->m_snapToGrid->setChecked(pGrid->IsEnabled()); - - ui->m_angleSnap->setChecked(pGrid->IsAngleSnapEnabled()); - ui->m_angleSnapScale->setValue(pGrid->GetAngleSnap()); - ui->m_displayCP->setChecked(gSettings.snap.constructPlaneDisplay); - - ui->m_CPSize->setValue(gSettings.snap.constructPlaneSize); - ui->m_displaySnapMarker->setChecked(gSettings.snap.markerDisplay); - ui->m_snapMarkerSize->setValue(gSettings.snap.markerSize); - - ui->m_snapMarkerColor->SetColor(gSettings.snap.markerColor); - - EnableGridPropertyControls(gSettings.snap.bGridUserDefined, gSettings.snap.bGridGetFromSelected); -} - -////////////////////////////////////////////////////////////////////////// -void CGridSettingsDialog::accept() -{ - UpdateValues(); - gSettings.Save(); - QDialog::accept(); -} - -void CGridSettingsDialog::OnBnUserDefined() -{ - EnableGridPropertyControls(ui->m_userDefined->isChecked(), ui->m_getFromObject->isChecked()); - OnValueUpdate(); -} - -void CGridSettingsDialog::OnBnGetFromObject() -{ - EnableGridPropertyControls(ui->m_userDefined->isChecked(), ui->m_getFromObject->isChecked()); -} - -void CGridSettingsDialog::EnableGridPropertyControls(const bool isUserDefined, const bool isGetFromObject) -{ - ui->m_getFromObject->setEnabled(isUserDefined == true); - - ui->m_angleX->setEnabled(isUserDefined == true && isGetFromObject == false); - ui->m_angleY->setEnabled(isUserDefined == true && isGetFromObject == false); - ui->m_angleZ->setEnabled(isUserDefined == true && isGetFromObject == false); - ui->m_translationX->setEnabled(isUserDefined == true && isGetFromObject == false); - ui->m_translationY->setEnabled(isUserDefined == true && isGetFromObject == false); - ui->m_translationZ->setEnabled(isUserDefined == true && isGetFromObject == false); - ui->m_getAnglesFromObject->setEnabled(isUserDefined == true && isGetFromObject == false); - ui->m_getTranslationFromObject->setEnabled(isUserDefined == true && isGetFromObject == false); -} - -////////////////////////////////////////////////////////////////////////// -void CGridSettingsDialog::UpdateValues() -{ - CGrid* pGrid = GetIEditor()->GetViewManager()->GetGrid(); - - pGrid->Enable(ui->m_snapToGrid->isChecked()); - pGrid->size = ui->m_gridSize->value(); - pGrid->scale = ui->m_gridScale->value(); - - gSettings.snap.bGridUserDefined = ui->m_userDefined->isChecked(); - gSettings.snap.bGridGetFromSelected = ui->m_getFromObject->isChecked(); - pGrid->rotationAngles.x = ui->m_angleX->value(); - pGrid->rotationAngles.y = ui->m_angleY->value(); - pGrid->rotationAngles.z = ui->m_angleZ->value(); - pGrid->translation.x = ui->m_translationX->value(); - pGrid->translation.y = ui->m_translationY->value(); - pGrid->translation.z = ui->m_translationZ->value(); - - pGrid->bAngleSnapEnabled = ui->m_angleSnap->isChecked(); - pGrid->angleSnap = ui->m_angleSnapScale->value(); - - gSettings.snap.constructPlaneDisplay = ui->m_displayCP->isChecked(); - gSettings.snap.constructPlaneSize = ui->m_CPSize->value(); - - gSettings.snap.markerDisplay = ui->m_displaySnapMarker->isChecked(); - gSettings.snap.markerSize = ui->m_snapMarkerSize->value(); - gSettings.snap.markerColor = ui->m_snapMarkerColor->Color(); - - NotificationBus::Broadcast(&Notifications::OnGridValuesUpdated); -} - - -////////////////////////////////////////////////////////////////////////// -void CGridSettingsDialog::OnValueUpdate() -{ - UpdateValues(); - GetIEditor()->UpdateViews(eRedrawViewports); -} - -#include diff --git a/Code/Sandbox/Editor/GridSettingsDialog.h b/Code/Sandbox/Editor/GridSettingsDialog.h deleted file mode 100644 index fe5934ec7e..0000000000 --- a/Code/Sandbox/Editor/GridSettingsDialog.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#ifndef CRYINCLUDE_EDITOR_GRIDSETTINGSDIALOG_H -#define CRYINCLUDE_EDITOR_GRIDSETTINGSDIALOG_H - -#pragma once - -#if !defined(Q_MOC_RUN) -#include -#include -#endif - -// CGridSettingsDialog dialog - -namespace Ui { - class CGridSettingsDialog; -} - -class CGridSettingsDialog - : public QDialog -{ - Q_OBJECT -public: - - class Notifications - : public AZ::EBusTraits - { - public: - static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; - - virtual void OnGridValuesUpdated() {} - }; - - using NotificationBus = AZ::EBus; - - CGridSettingsDialog(QWidget* pParent = nullptr); // standard constructor - virtual ~CGridSettingsDialog(); - -private slots: - void accept() override; - void OnBnUserDefined(); - void OnBnGetFromObject(); - void OnValueUpdate(); - -private: - void EnableGridPropertyControls(const bool isUserDefined, const bool isGetFromObject); - - void OnInitDialog(); - void UpdateValues(); - - QScopedPointer ui; -}; - -#endif // CRYINCLUDE_EDITOR_GRIDSETTINGSDIALOG_H diff --git a/Code/Sandbox/Editor/GridSettingsDialog.ui b/Code/Sandbox/Editor/GridSettingsDialog.ui deleted file mode 100644 index f77abbece7..0000000000 --- a/Code/Sandbox/Editor/GridSettingsDialog.ui +++ /dev/null @@ -1,505 +0,0 @@ - - - CGridSettingsDialog - - - - 0 - 0 - 307 - 707 - - - - - - - - - Grid - - - - - - Snap to Grid - - - - - - - Grid Lines Every: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 0.010000000000000 - - - 1024.000000000000000 - - - 0.010000000000000 - - - - - - - units - - - - - - - Units Per Meter: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 0.010000000000000 - - - 1024.000000000000000 - - - 0.010000000000000 - - - - - - - meters - - - - - - - User Defined Grid - - - - - - - Get Angles And Trans. From Selected - - - - - - - Rotation by X: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - -180.000000000000000 - - - 180.000000000000000 - - - 0.010000000000000 - - - - - - - degrees - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Rotation by Y: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - -180.000000000000000 - - - 180.000000000000000 - - - 0.010000000000000 - - - - - - - degrees - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Rotation by Z: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - -180.000000000000000 - - - 180.000000000000000 - - - 0.010000000000000 - - - - - - - degrees - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Translation by X: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 0.010000000000000 - - - - - - - Translation by Y: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 0.010000000000000 - - - - - - - Translation by Z: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 0.010000000000000 - - - - - - - Get Angles From Selected - - - - - - - Get Translation From Selected - - - - - - - - - - Angle Snapping - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - 80 - 0 - - - - degrees - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Angle Snap - - - - - - - Angle Snap: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Horizontal - - - - 40 - 0 - - - - - - - - - - - Construction Plane - - - - - - Size: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Display - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 0.010000000000000 - - - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 80 - 0 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - m_displayCP - m_CPSize - - - - - - Snap Marker - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 0.010000000000000 - - - - - - - Display - - - - - - - - 80 - 0 - - - - Color - - - - - - - Size: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - ColorButton - QToolButton -
QtUI/ColorButton.h
-
-
- - -
diff --git a/Code/Sandbox/Editor/MainWindow.cpp b/Code/Sandbox/Editor/MainWindow.cpp index 5abb780bac..b1d85c2999 100644 --- a/Code/Sandbox/Editor/MainWindow.cpp +++ b/Code/Sandbox/Editor/MainWindow.cpp @@ -66,7 +66,6 @@ AZ_POP_DISABLE_WARNING #include "AssetImporter/AssetImporterManager/AssetImporterDragAndDropHandler.h" #include "CryEdit.h" #include "Controls/ConsoleSCB.h" -#include "Grid.h" #include "ViewManager.h" #include "CryEditDoc.h" #include "ToolBox.h" @@ -97,7 +96,6 @@ AZ_POP_DISABLE_WARNING #include "AzAssetBrowser/AzAssetBrowserWindow.h" #include "AssetEditor/AssetEditorWindow.h" -#include "GridSettingsDialog.h" #include "ActionManager.h" // uncomment this to show thumbnail demo widget @@ -123,12 +121,6 @@ static const char* g_openLocationAttributeName = "OpenLocation"; //Indicates whe static const char* g_assetImporterName = "AssetImporter"; -static const char* g_snapToGridEnabled = "mainwindow/snapGridEnabled"; -static const char* g_snapToGridSize = "mainwindow/snapGridSize"; -static const char* g_snapAngleEnabled = "mainwindow/snapAngleEnabled"; -static const char* g_snapAngle = "mainwindow/snapAngle"; -static const char* g_terrainFollow = "mainwindow/terrainFollow"; - class CEditorOpenViewCommand : public _i_reference_target_t { @@ -308,10 +300,8 @@ namespace class SnapToWidget : public QWidget - , public CGridSettingsDialog::NotificationBus::Handler { public: - typedef AZStd::function SetValueCallback; typedef AZStd::function GetValueCallback; @@ -335,12 +325,13 @@ public: m_spinBox->setEnabled(defaultAction->isChecked()); m_spinBox->setMinimum(1e-2f); - OnGridValuesUpdated(); + { + QSignalBlocker signalBlocker(m_spinBox); + m_spinBox->setValue(m_getValueCallback()); + } QObject::connect(m_spinBox, QOverload::of(&AzQtComponents::DoubleSpinBox::valueChanged), this, &SnapToWidget::OnValueChanged); QObject::connect(defaultAction, &QAction::changed, this, &SnapToWidget::OnActionChanged); - - CGridSettingsDialog::NotificationBus::Handler::BusConnect(); } void SetIcon(QIcon icon) @@ -348,14 +339,6 @@ public: m_toolButton->setIcon(icon); } - void OnGridValuesUpdated() override - { - // Blocking signals to not trigger the valueChanged callback when we set the value on the spin box. - QSignalBlocker signalBlocker(m_spinBox); - double value = m_getValueCallback(); - m_spinBox->setValue(value); - } - protected: void OnValueChanged(double value) @@ -543,7 +526,6 @@ void MainWindow::Initialize() RegisterStdViewClasses(); InitCentralWidget(); - LoadConfig(); InitActions(); // load toolbars ("shelves") and macros @@ -673,31 +655,8 @@ void MainWindow::closeEvent(QCloseEvent* event) QMainWindow::closeEvent(event); } -void MainWindow::LoadConfig() -{ - CGrid* grid = gSettings.pGrid; - Q_ASSERT(grid); - bool terrainValue; - - ReadConfigValue(g_snapAngleEnabled, grid->bAngleSnapEnabled); - ReadConfigValue(g_snapAngle, grid->angleSnap); - ReadConfigValue(g_snapToGridEnabled, grid->bEnabled); - ReadConfigValue(g_snapToGridSize, grid->size); - ReadConfigValue(g_terrainFollow, terrainValue); - GetIEditor()->SetTerrainAxisIgnoreObjects(terrainValue); -} - void MainWindow::SaveConfig() { - CGrid* grid = gSettings.pGrid; - Q_ASSERT(grid); - - m_settings.setValue(g_snapAngleEnabled, grid->bAngleSnapEnabled); - m_settings.setValue(g_snapAngle, grid->angleSnap); - m_settings.setValue(g_snapToGridEnabled, grid->bEnabled); - m_settings.setValue(g_snapToGridSize, grid->size); - m_settings.setValue(g_terrainFollow, GetIEditor()->IsTerrainAxisIgnoreObjects()); - m_settings.setValue("mainWindowState", saveState()); QtViewPaneManager::instance()->SaveLayout(); if (m_pLayoutWnd) @@ -941,7 +900,6 @@ void MainWindow::InitActions() .SetStatusTip(tr("Render in Wireframe Mode.")) .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateWireframe); - am->AddAction(ID_VIEW_GRIDSETTINGS, tr("Grid Settings...")); am->AddAction(ID_SWITCHCAMERA_DEFAULTCAMERA, tr("Default Camera")).SetCheckable(true) .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSwitchToDefaultCamera); am->AddAction(ID_SWITCHCAMERA_SEQUENCECAMERA, tr("Sequence Camera")).SetCheckable(true) @@ -1479,15 +1437,6 @@ MainStatusBar* MainWindow::StatusBar() const return static_cast(statusBar()); } -void MainWindow::OnUpdateSnapToGrid(QAction* action) -{ - Q_ASSERT(action->isCheckable()); - bool bEnabled = gSettings.pGrid->IsEnabled(); - action->setChecked(bEnabled); - - action->setText(QObject::tr("Snap To Grid")); -} - KeyboardCustomizationSettings* MainWindow::GetShortcutManager() const { return m_keyboardCustomization; diff --git a/Code/Sandbox/Editor/MainWindow.h b/Code/Sandbox/Editor/MainWindow.h index adf271b383..ca8cc11677 100644 --- a/Code/Sandbox/Editor/MainWindow.h +++ b/Code/Sandbox/Editor/MainWindow.h @@ -191,9 +191,7 @@ private: void InitToolActionHandlers(); void InitToolBars(); void InitStatusBar(); - void OnUpdateSnapToGrid(QAction* action); void OnViewPaneCreated(const QtViewPane* pane); - void LoadConfig(); template void ReadConfigValue(const QString& key, TValue& value) diff --git a/Code/Sandbox/Editor/Objects/AxisGizmo.cpp b/Code/Sandbox/Editor/Objects/AxisGizmo.cpp index ef2b91685a..8e10d03080 100644 --- a/Code/Sandbox/Editor/Objects/AxisGizmo.cpp +++ b/Code/Sandbox/Editor/Objects/AxisGizmo.cpp @@ -18,7 +18,6 @@ // Editor #include "Viewport.h" #include "GizmoManager.h" -#include "Grid.h" #include "ViewManager.h" #include "Settings.h" #include "RenderHelpers/AxisHelper.h" @@ -244,7 +243,8 @@ Matrix34 CAxisGizmo::GetTransformation(RefCoordSys coordSys, IDisplayViewport* v break; case COORDS_USERDEFINED: { - Matrix34 userTM = GetIEditor()->GetViewManager()->GetGrid()->GetMatrix(); + Matrix34 userTM; + userTM.SetIdentity(); userTM.SetTranslation(m_object->GetWorldTM().GetTranslation()); return userTM; } diff --git a/Code/Sandbox/Editor/Objects/BaseObject.cpp b/Code/Sandbox/Editor/Objects/BaseObject.cpp index 6819bb5469..4c76f68f2f 100644 --- a/Code/Sandbox/Editor/Objects/BaseObject.cpp +++ b/Code/Sandbox/Editor/Objects/BaseObject.cpp @@ -1268,12 +1268,6 @@ int CBaseObject::MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint& if (event == eMouseWheel) { double angle = 1; - - if (view->GetViewManager()->GetGrid()->IsAngleSnapEnabled()) - { - angle = view->GetViewManager()->GetGrid()->GetAngleSnap(); - } - Quat rot = GetRotation(); rot.SetRotationXYZ(Ang3(0, 0, rot.GetRotZ() + DEG2RAD(flags > 0 ? angle * (-1) : angle))); SetRotation(rot); diff --git a/Code/Sandbox/Editor/Objects/SelectionGroup.cpp b/Code/Sandbox/Editor/Objects/SelectionGroup.cpp index 98e00645ee..a2c88c7302 100644 --- a/Code/Sandbox/Editor/Objects/SelectionGroup.cpp +++ b/Code/Sandbox/Editor/Objects/SelectionGroup.cpp @@ -342,7 +342,8 @@ void CSelectionGroup::Rotate(const Matrix34& rotateTM, int referenceCoordSys) if (referenceCoordSys == COORDS_USERDEFINED) { - Matrix34 userTM = GetIEditor()->GetViewManager()->GetGrid()->GetMatrix(); + Matrix34 userTM; + userTM.SetIdentity(); Matrix34 invUserTM = userTM.GetInvertedFast(); ToOrigin = invUserTM * ToOrigin; diff --git a/Code/Sandbox/Editor/RenderViewport.cpp b/Code/Sandbox/Editor/RenderViewport.cpp index 49064b5bc5..f199590e4f 100644 --- a/Code/Sandbox/Editor/RenderViewport.cpp +++ b/Code/Sandbox/Editor/RenderViewport.cpp @@ -1993,28 +1993,27 @@ AzFramework::CameraState CRenderViewport::GetCameraState() bool CRenderViewport::GridSnappingEnabled() { - return GetViewManager()->GetGrid()->IsEnabled(); + return false; } float CRenderViewport::GridSize() { - const CGrid* grid = GetViewManager()->GetGrid(); - return grid->scale * grid->size; + return 0.0f; } bool CRenderViewport::ShowGrid() { - return gSettings.viewports.bShowGridGuide; + return false; } bool CRenderViewport::AngleSnappingEnabled() { - return GetViewManager()->GetGrid()->IsAngleSnapEnabled(); + return false; } float CRenderViewport::AngleStep() { - return GetViewManager()->GetGrid()->GetAngleSnap(); + return 0.0f; } AZ::Vector3 CRenderViewport::PickTerrain(const AzFramework::ScreenPoint& point) @@ -3890,94 +3889,13 @@ void CRenderViewport::ActivateWindowAndSetFocus() ////////////////////////////////////////////////////////////////////////// void CRenderViewport::RenderConstructionPlane() { - DisplayContext& dc = m_displayContext; - - int prevState = dc.GetState(); - dc.DepthWriteOff(); - // Draw Construction plane. - - CGrid* pGrid = GetViewManager()->GetGrid(); - - RefCoordSys coordSys = COORDS_WORLD; - - Vec3 p = m_constructionMatrix[coordSys].GetTranslation(); - Vec3 n = m_constructionPlane.n; - - Vec3 u = Vec3(1, 0, 0); - Vec3 v = Vec3(0, 1, 0); - - - if (gSettings.snap.bGridUserDefined) - { - Ang3 angles = Ang3(pGrid->rotationAngles.x * gf_PI / 180.0, pGrid->rotationAngles.y * gf_PI / 180.0, pGrid->rotationAngles.z * gf_PI / 180.0); - Matrix34 tm = Matrix33::CreateRotationXYZ(angles); - - u = tm * u; - v = tm * v; - } - - float step = pGrid->scale * pGrid->size; - float size = gSettings.snap.constructPlaneSize; - - dc.SetColor(0, 0, 1, 0.1f); - - float s = size; - - dc.DrawQuad(p - u * s - v * s, p + u * s - v * s, p + u * s + v * s, p - u * s + v * s); - - int nSteps = int(size / step); - int i; - // Draw X lines. - dc.SetColor(1, 0, 0.2f, 0.3f); - - for (i = -nSteps; i <= nSteps; i++) - { - dc.DrawLine(p - u * size + v * (step * i), p + u * size + v * (step * i)); - } - // Draw Y lines. - dc.SetColor(0.2f, 1.0f, 0, 0.3f); - for (i = -nSteps; i <= nSteps; i++) - { - dc.DrawLine(p - v * size + u * (step * i), p + v * size + u * (step * i)); - } - - // Draw origin lines. - - dc.SetLineWidth(2); - - //X - dc.SetColor(1, 0, 0); - dc.DrawLine(p - u * s, p + u * s); - - //Y - dc.SetColor(0, 1, 0); - dc.DrawLine(p - v * s, p + v * s); - - //Z - dc.SetColor(0, 0, 1); - dc.DrawLine(p - n * s, p + n * s); - - dc.SetLineWidth(0); - - dc.SetState(prevState); + // noop } ////////////////////////////////////////////////////////////////////////// void CRenderViewport::RenderSnappingGrid() { - // First, Check whether we should draw the grid or not. - CGrid* pGrid = GetViewManager()->GetGrid(); - if (pGrid->IsEnabled() == false && pGrid->IsAngleSnapEnabled() == false) - { - return; - } - - DisplayContext& dc = m_displayContext; - - int prevState = dc.GetState(); - dc.DepthWriteOff(); - - dc.SetState(prevState); + // noop } ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Sandbox/Editor/Resource.h b/Code/Sandbox/Editor/Resource.h index ddc9ff2359..31fc9909f1 100644 --- a/Code/Sandbox/Editor/Resource.h +++ b/Code/Sandbox/Editor/Resource.h @@ -79,7 +79,6 @@ #define ID_EDIT_HIDE 32898 #define ID_EDIT_UNHIDEALL 32899 #define ID_RELOAD_TERRAIN 32902 -#define ID_VIEW_GRIDSETTINGS 32904 #define ID_VIEW_CONFIGURELAYOUT 32906 #define ID_TOOLS_LOGMEMORYUSAGE 32908 #define ID_TERRAIN_EXPORTBLOCK 32909 diff --git a/Code/Sandbox/Editor/Settings.h b/Code/Sandbox/Editor/Settings.h index 93e61bc1ed..b4609555df 100644 --- a/Code/Sandbox/Editor/Settings.h +++ b/Code/Sandbox/Editor/Settings.h @@ -40,8 +40,6 @@ #include -class CGrid; - struct SGizmoSettings { float axisGizmoSize; @@ -393,9 +391,6 @@ AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING //! Keeps the editor active even if no focus is set int keepEditorActive; - //! Pointer to currently used grid. - CGrid* pGrid; - SGizmoSettings gizmo; // Settings of the snapping. diff --git a/Code/Sandbox/Editor/ViewManager.cpp b/Code/Sandbox/Editor/ViewManager.cpp index 334e78a826..8bb14a3aca 100644 --- a/Code/Sandbox/Editor/ViewManager.cpp +++ b/Code/Sandbox/Editor/ViewManager.cpp @@ -49,8 +49,6 @@ bool CViewManager::IsMultiViewportEnabled() ////////////////////////////////////////////////////////////////////// CViewManager::CViewManager() { - gSettings.pGrid = &m_grid; - m_zoomFactor = 1; m_origin2D(0, 0, 0); diff --git a/Code/Sandbox/Editor/ViewManager.h b/Code/Sandbox/Editor/ViewManager.h index d617b5c54e..e2b42573d5 100644 --- a/Code/Sandbox/Editor/ViewManager.h +++ b/Code/Sandbox/Editor/ViewManager.h @@ -20,7 +20,6 @@ #pragma once #include "Cry_Geo.h" -#include "Grid.h" #include "Viewport.h" #include "Include/IViewPane.h" #include "QtViewPaneManager.h" @@ -67,10 +66,6 @@ public: void SetUpdateRegion(const AABB& updateRegion) { m_updateRegion = updateRegion; }; const AABB& GetUpdateRegion() { return m_updateRegion; }; - /** Retrieve Grid used for viewes. - */ - CGrid* GetGrid() { return &m_grid; }; - /** Get 2D viewports origin. */ Vec3 GetOrigin2D() const { return m_origin2D; } @@ -137,7 +132,6 @@ private: AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING AABB m_updateRegion; - CGrid m_grid; //! Origin of 2d viewports. Vec3 m_origin2D; //! Zoom of 2d viewports. diff --git a/Code/Sandbox/Editor/Viewport.cpp b/Code/Sandbox/Editor/Viewport.cpp index cc278b18b0..da4a389aa0 100644 --- a/Code/Sandbox/Editor/Viewport.cpp +++ b/Code/Sandbox/Editor/Viewport.cpp @@ -1182,12 +1182,12 @@ float QtViewport::GetZoomFactor() const ////////////////////////////////////////////////////////////////////////// Vec3 QtViewport::SnapToGrid(const Vec3& vec) { - return m_viewManager->GetGrid()->Snap(vec, m_fGridZoom); + return vec; } float QtViewport::GetGridStep() const { - return m_viewManager->GetGrid()->scale * m_viewManager->GetGrid()->size; + return 0.0f; } ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Sandbox/Editor/editor_lib_files.cmake b/Code/Sandbox/Editor/editor_lib_files.cmake index 5f6c1ed2bd..4832e2b8c2 100644 --- a/Code/Sandbox/Editor/editor_lib_files.cmake +++ b/Code/Sandbox/Editor/editor_lib_files.cmake @@ -437,9 +437,6 @@ set(FILES GotoPositionDlg.cpp GotoPositionDlg.h GotoPositionDlg.ui - GridSettingsDialog.cpp - GridSettingsDialog.h - GridSettingsDialog.ui InfoBar.cpp InfoBar.qrc InfoBar.h @@ -835,8 +832,6 @@ set(FILES WelcomeScreen/WelcomeScreenDialog.qrc 2DViewport.cpp 2DViewport.h - Grid.cpp - Grid.h LayoutWnd.cpp LayoutWnd.h EditorViewportWidget.cpp