diff --git a/Code/Sandbox/Editor/CryEdit.cpp b/Code/Sandbox/Editor/CryEdit.cpp index a972a4bd9b..6f81580251 100644 --- a/Code/Sandbox/Editor/CryEdit.cpp +++ b/Code/Sandbox/Editor/CryEdit.cpp @@ -3702,8 +3702,8 @@ void CCryEditApp::OnViewCycle2dviewport() ////////////////////////////////////////////////////////////////////////// void CCryEditApp::OnDisplayGotoPosition() { - CGotoPositionDlg dlg; - dlg.exec(); + GotoPositionDialog dialog; + dialog.exec(); } ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Sandbox/Editor/CryEditPy.cpp b/Code/Sandbox/Editor/CryEditPy.cpp index edbeccb04f..e286e4a0d6 100644 --- a/Code/Sandbox/Editor/CryEditPy.cpp +++ b/Code/Sandbox/Editor/CryEditPy.cpp @@ -32,6 +32,7 @@ #include "GameEngine.h" #include "UndoConfigSpec.h" #include "ViewManager.h" +#include "EditorViewportCamera.h" ////////////////////////////////////////////////////////////////////////// namespace @@ -241,26 +242,15 @@ namespace void PySetCurrentViewPosition(float x, float y, float z) { - AzToolsFramework::IEditorCameraController* editorCameraController = AZ::Interface::Get(); - AZ_Error("editor", editorCameraController, "IEditorCameraController is not registered."); - if (editorCameraController) - { - editorCameraController->SetCurrentViewPosition(AZ::Vector3{ x, y, z }); - } + SandboxEditor::SetDefaultViewportCameraPosition(AZ::Vector3(x, y, z)); } - void PySetCurrentViewRotation(float x, float y, float z) + void PySetCurrentViewRotation(float x, [[maybe_unused]] float y, float z) { - AzToolsFramework::IEditorCameraController* editorCameraController = AZ::Interface::Get(); - AZ_Error("editor", editorCameraController, "IEditorCameraController is not registered."); - if (editorCameraController) - { - editorCameraController->SetCurrentViewRotation(AZ::Vector3{ x, y, z }); - } + SandboxEditor::SetDefaultViewportCameraRotation(AZ::DegToRad(x), AZ::DegToRad(z)); } } - namespace { void PyStartProcessDetached(const char* process, const char* args) @@ -488,9 +478,9 @@ namespace AzToolsFramework addLegacyGeneral(behaviorContext->Method("load_all_plugins", ::Command_LoadPlugins, nullptr, "Loads all available plugins.")); addLegacyGeneral(behaviorContext->Method("get_current_view_position", PyGetCurrentViewPosition, nullptr, "Returns the position of the current view as a Vec3.")); - addLegacyGeneral(behaviorContext->Method("get_current_view_rotation", PyGetCurrentViewRotation, nullptr, "Returns the rotation of the current view as a Vec3 of Euler angles.")); + addLegacyGeneral(behaviorContext->Method("get_current_view_rotation", PyGetCurrentViewRotation, nullptr, "Returns the rotation of the current view as a Vec3 of Euler angles in degrees.")); addLegacyGeneral(behaviorContext->Method("set_current_view_position", PySetCurrentViewPosition, nullptr, "Sets the position of the current view as given x, y, z coordinates.")); - addLegacyGeneral(behaviorContext->Method("set_current_view_rotation", PySetCurrentViewRotation, nullptr, "Sets the rotation of the current view as given x, y, z Euler angles.")); + addLegacyGeneral(behaviorContext->Method("set_current_view_rotation", PySetCurrentViewRotation, nullptr, "Sets the rotation of the current view as given x, y, z Euler angles in degrees.")); addLegacyGeneral(behaviorContext->Method("export_to_engine", CCryEditApp::Command_ExportToEngine, nullptr, "Exports the current level to the engine.")); addLegacyGeneral(behaviorContext->Method("set_config_spec", PySetConfigSpec, nullptr, "Sets the system config spec and platform.")); diff --git a/Code/Sandbox/Editor/EditorViewportCamera.cpp b/Code/Sandbox/Editor/EditorViewportCamera.cpp new file mode 100644 index 0000000000..30fce566e5 --- /dev/null +++ b/Code/Sandbox/Editor/EditorViewportCamera.cpp @@ -0,0 +1,55 @@ +/* + * 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. + * + */ + +#include + +#include +#include + +namespace SandboxEditor +{ + void SetDefaultViewportCameraPosition(const AZ::Vector3& position) + { + auto viewportContextManager = AZ::Interface::Get(); + if (auto viewportContext = viewportContextManager->GetDefaultViewportContext()) + { + const auto& currentCameraTransform = viewportContext->GetCameraTransform(); + viewportContext->SetCameraTransform( + AZ::Transform::CreateFromQuaternionAndTranslation(currentCameraTransform.GetRotation(), position)); + } + } + + void SetDefaultViewportCameraRotation(const float pitch, const float yaw) + { + auto viewportContextManager = AZ::Interface::Get(); + if (auto viewportContext = viewportContextManager->GetDefaultViewportContext()) + { + const auto rotation = AZ::Quaternion::CreateRotationZ(yaw) * AZ::Quaternion::CreateRotationX(pitch); + const auto& currentCameraTransform = viewportContext->GetCameraTransform(); + viewportContext->SetCameraTransform( + AZ::Transform::CreateFromQuaternionAndTranslation(rotation, currentCameraTransform.GetTranslation())); + } + } + + AZ::Transform GetDefaultViewportCameraTransform() + { + auto viewportContextManager = AZ::Interface::Get(); + if (auto viewportContext = viewportContextManager->GetDefaultViewportContext()) + { + return viewportContext->GetCameraTransform(); + } + + AZ_WarningOnce("EditorViewport", false, "Default viewport camera not found"); + + return AZ::Transform::CreateIdentity(); + } +} // namespace SandboxEditor diff --git a/Code/Sandbox/Editor/EditorViewportCamera.h b/Code/Sandbox/Editor/EditorViewportCamera.h new file mode 100644 index 0000000000..97c37e337e --- /dev/null +++ b/Code/Sandbox/Editor/EditorViewportCamera.h @@ -0,0 +1,35 @@ +/* + * 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. + * + */ + +#pragma once + +#include + +namespace AZ +{ + class Transform; + class Vector3; +} // namespace AZ + +namespace SandboxEditor +{ + //! Set the default viewport camera translation/position. + SANDBOX_API void SetDefaultViewportCameraPosition(const AZ::Vector3& position); + + //! Set the default viewport camera orientation/rotation. + //! @param pitch Amount of pitch in radians. + //! @param yaw Amount of yaw in radians. + SANDBOX_API void SetDefaultViewportCameraRotation(float pitch, float yaw); + + //! Get the default viewport camera transform. + SANDBOX_API AZ::Transform GetDefaultViewportCameraTransform(); +} // namespace SandboxEditor diff --git a/Code/Sandbox/Editor/EditorViewportWidget.cpp b/Code/Sandbox/Editor/EditorViewportWidget.cpp index 0d3405f8f0..bc8c8bea0b 100644 --- a/Code/Sandbox/Editor/EditorViewportWidget.cpp +++ b/Code/Sandbox/Editor/EditorViewportWidget.cpp @@ -1265,7 +1265,7 @@ void EditorViewportWidget::SetViewportId(int id) AzFramework::RenderGeometry::RayResult renderGeometryIntersectionResult; AzFramework::RenderGeometry::IntersectorBus::EventResult( renderGeometryIntersectionResult, AzToolsFramework::GetEntityContextId(), - &AzFramework::RenderGeometry::IntersectorInterface::RayIntersect, ray); + &AzFramework::RenderGeometry::IntersectorBus::Events::RayIntersect, ray); // attempt a ray intersection with any visible mesh and return the intersection position if successful if (renderGeometryIntersectionResult) diff --git a/Code/Sandbox/Editor/GameEngine.cpp b/Code/Sandbox/Editor/GameEngine.cpp index c338a2e28d..24e9577fdf 100644 --- a/Code/Sandbox/Editor/GameEngine.cpp +++ b/Code/Sandbox/Editor/GameEngine.cpp @@ -267,14 +267,12 @@ AZ_POP_DISABLE_WARNING m_levelExtension = EditorUtils::LevelFile::GetDefaultFileExtension(); m_playerViewTM.SetIdentity(); GetIEditor()->RegisterNotifyListener(this); - AZ::Interface::Register(this); } AZ_PUSH_DISABLE_WARNING(4273, "-Wunknown-warning-option") CGameEngine::~CGameEngine() { AZ_POP_DISABLE_WARNING - AZ::Interface::Unregister(this); GetIEditor()->UnregisterNotifyListener(this); m_pISystem->GetIMovieSystem()->SetCallback(NULL); @@ -349,38 +347,6 @@ static void CmdGotoEditor(IConsoleCmdArgs* pArgs) } } -void CGameEngine::SetCurrentViewPosition(const AZ::Vector3& position) -{ - CViewport* pRenderViewport = GetIEditor()->GetViewManager()->GetGameViewport(); - if (pRenderViewport) - { - CUndo undo("Set Current View Position"); - if (CUndo::IsRecording()) - { - CUndo::Record(new CUndoViewPosition()); - } - Matrix34 tm = pRenderViewport->GetViewTM(); - tm.SetTranslation(Vec3(position.GetX(), position.GetY(), position.GetZ())); - pRenderViewport->SetViewTM(tm); - } -} - -void CGameEngine::SetCurrentViewRotation(const AZ::Vector3& rotation) -{ - CViewport* pRenderViewport = GetIEditor()->GetViewManager()->GetGameViewport(); - if (pRenderViewport) - { - CUndo undo("Set Current View Rotation"); - if (CUndo::IsRecording()) - { - CUndo::Record(new CUndoViewRotation()); - } - Matrix34 tm = pRenderViewport->GetViewTM(); - tm.SetRotationXYZ(Ang3(DEG2RAD(rotation.GetX()), DEG2RAD(rotation.GetY()), DEG2RAD(rotation.GetZ())), tm.GetTranslation()); - pRenderViewport->SetViewTM(tm); - } -} - AZ::Outcome CGameEngine::Init( bool bPreviewMode, bool bTestMode, diff --git a/Code/Sandbox/Editor/GameEngine.h b/Code/Sandbox/Editor/GameEngine.h index 669b37bbb3..3737852338 100644 --- a/Code/Sandbox/Editor/GameEngine.h +++ b/Code/Sandbox/Editor/GameEngine.h @@ -32,24 +32,6 @@ struct IInitializeUIInfo; #include #include -namespace AzToolsFramework -{ - //! Operates the Editor's camera - class IEditorCameraController - { - public: - AZ_RTTI(IEditorCameraController, "{AEF60D3E-10A1-4161-9379-F68C69A5959C}"); - - IEditorCameraController() = default; - IEditorCameraController(IEditorCameraController&&) = delete; - IEditorCameraController& operator=(IEditorCameraController&&) = delete; - virtual ~IEditorCameraController() = default; - - virtual void SetCurrentViewPosition([[maybe_unused]] const AZ::Vector3& position) {} - virtual void SetCurrentViewRotation([[maybe_unused]] const AZ::Vector3& rotation) {} - }; -} - class ThreadedOnErrorHandler : public QObject { Q_OBJECT @@ -68,7 +50,6 @@ AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING //! This class serves as a high-level wrapper for CryEngine game. class SANDBOX_API CGameEngine : public IEditorNotifyListener - , private AzToolsFramework::IEditorCameraController { AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING public: @@ -153,11 +134,6 @@ public: } private: - AZ_PUSH_DISABLE_WARNING(4273, "-Wunknown-warning-option") - void SetCurrentViewPosition(const AZ::Vector3& position) override; - void SetCurrentViewRotation(const AZ::Vector3& rotation) override; - AZ_POP_DISABLE_OVERRIDE_WARNING - void SetGameMode(bool inGame); void SwitchToInGame(); void SwitchToInEditor(); diff --git a/Code/Sandbox/Editor/GotoPositionDlg.cpp b/Code/Sandbox/Editor/GotoPositionDlg.cpp index f52a45cad4..967c2d032b 100644 --- a/Code/Sandbox/Editor/GotoPositionDlg.cpp +++ b/Code/Sandbox/Editor/GotoPositionDlg.cpp @@ -1,174 +1,122 @@ /* -* 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. -* -*/ + * 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 "GotoPositionDlg.h" #include "EditorDefs.h" -#include "GotoPositionDlg.h" - // Editor -#include "ViewManager.h" +#include "EditorViewportCamera.h" #include "GameEngine.h" +#include "ViewManager.h" +#include + +#include +#include AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING #include AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING -///////////////////////////////////////////////////////////////////////////// -// CGotoPositionDlg dialog - - -CGotoPositionDlg::CGotoPositionDlg(QWidget* pParent /*=NULL*/) - : QDialog(pParent) - , m_ui(new Ui::GotoPositionDlg) +GotoPositionDialog::GotoPositionDialog(QWidget* parent) + : QDialog(parent) + , m_ui(new Ui::GotoPositionDialog) { m_ui->setupUi(this); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setFixedSize(size()); OnInitDialog(); - auto doubleValueChanged = static_cast(&QDoubleSpinBox::valueChanged); - auto valueChanged = static_cast(&QSpinBox::valueChanged); + auto doubleValueChanged = static_cast(&QDoubleSpinBox::valueChanged); - connect(m_ui->m_posEdit, &QLineEdit::editingFinished, this, &CGotoPositionDlg::OnChangeEdit); - connect(m_ui->m_dymX, doubleValueChanged, this, &CGotoPositionDlg::OnUpdateNumbers); - connect(m_ui->m_dymY, doubleValueChanged, this, &CGotoPositionDlg::OnUpdateNumbers); - connect(m_ui->m_dymZ, doubleValueChanged, this, &CGotoPositionDlg::OnUpdateNumbers); - connect(m_ui->m_dymAngleX, doubleValueChanged, this, &CGotoPositionDlg::OnUpdateNumbers); - connect(m_ui->m_dymAngleY, doubleValueChanged, this, &CGotoPositionDlg::OnUpdateNumbers); - connect(m_ui->m_dymAngleZ, doubleValueChanged, this, &CGotoPositionDlg::OnUpdateNumbers); - connect(m_ui->m_dymSegX, valueChanged, this, &CGotoPositionDlg::OnUpdateNumbers); - connect(m_ui->m_dymSegY, valueChanged, this, &CGotoPositionDlg::OnUpdateNumbers); + connect(m_ui->m_posEdit, &QLineEdit::editingFinished, this, &GotoPositionDialog::OnChangeEdit); + connect(m_ui->m_dymX, doubleValueChanged, this, &GotoPositionDialog::OnUpdateNumbers); + connect(m_ui->m_dymY, doubleValueChanged, this, &GotoPositionDialog::OnUpdateNumbers); + connect(m_ui->m_dymZ, doubleValueChanged, this, &GotoPositionDialog::OnUpdateNumbers); + connect(m_ui->m_dymAnglePitch, doubleValueChanged, this, &GotoPositionDialog::OnUpdateNumbers); + connect(m_ui->m_dymAngleYaw, doubleValueChanged, this, &GotoPositionDialog::OnUpdateNumbers); } -CGotoPositionDlg::~CGotoPositionDlg() +GotoPositionDialog::~GotoPositionDialog() = default; + +void GotoPositionDialog::OnInitDialog() { -} + const auto cameraTransform = SandboxEditor::GetDefaultViewportCameraTransform(); + const auto cameraTranslation = cameraTransform.GetTranslation(); + const auto cameraRotation = AzFramework::EulerAngles(AZ::Matrix3x3::CreateFromQuaternion(cameraTransform.GetRotation())); + const auto pitchDegrees = AZ::RadToDeg(cameraRotation.GetX()); + const auto yawDegrees = AZ::RadToDeg(cameraRotation.GetZ()); -///////////////////////////////////////////////////////////////////////////// -// CGotoPositionDlg message handlers + // position + m_ui->m_dymX->setRange(-64000.0, 64000.0); + m_ui->m_dymX->setValue(cameraTranslation.GetX()); + m_ui->m_dymY->setRange(-64000.0, 64000.0); + m_ui->m_dymY->setValue(cameraTranslation.GetY()); -void CGotoPositionDlg::OnInitDialog() -{ - Vec3 pos; - Ang3 angle; + m_ui->m_dymZ->setRange(-64000.0, 64000.0); + m_ui->m_dymZ->setValue(cameraTranslation.GetZ()); - CViewport* pRenderViewport = GetIEditor()->GetViewManager()->GetGameViewport(); - if (pRenderViewport) - { - Matrix34 tm = pRenderViewport->GetViewTM(); - pos = pRenderViewport->GetViewTM().GetTranslation(); - angle = RAD2DEG(Ang3::GetAnglesXYZ(tm)); - } + // rotation + m_ui->m_dymAnglePitch->setRange(-180.0, 180.0); + m_ui->m_dymAnglePitch->setValue(pitchDegrees); - // CORDS -------------------------------------- - m_ui->m_dymX->setRange(-64000, 64000); - m_ui->m_dymX->setValue(pos.x); + m_ui->m_dymAngleYaw->setRange(-180.0, 180.0); + m_ui->m_dymAngleYaw->setValue(yawDegrees); - m_ui->m_dymY->setRange(-64000, 64000); - m_ui->m_dymY->setValue(pos.y); - - m_ui->m_dymZ->setRange(-64000, 64000); - m_ui->m_dymZ->setValue(pos.z); - - // ANGLES ------------------------------------- - m_ui->m_dymAngleX->setRange(-180, 180); - m_ui->m_dymAngleX->setValue(angle.x); - - m_ui->m_dymAngleY->setRange(-180, 180); - m_ui->m_dymAngleY->setValue(angle.y); - - m_ui->m_dymAngleZ->setRange(-180, 180); - m_ui->m_dymAngleZ->setValue(angle.z); - - - m_ui->m_labelSeg->setVisible(false); - m_ui->m_labelSegX->setVisible(false); - m_ui->m_labelSegY->setVisible(false); - m_ui->m_dymSegX->setVisible(false); - m_ui->m_dymSegY->setVisible(false); - - // Ensure the goto button is highlighted correctly. + // ensure the goto button is highlighted correctly. m_ui->pushButton->setDefault(true); OnUpdateNumbers(); } - -void CGotoPositionDlg::OnChangeEdit() +void GotoPositionDialog::OnChangeEdit() { - const int lengthInSw = 8; - const int strNum = 6; - AZStd::vector pos(strNum); + const int argCount = 5; + AZStd::vector transform(argCount); - m_sPos = m_ui->m_posEdit->text(); - const QStringList parts = m_sPos.split(QRegularExpression("[\\s,;\\t]"), Qt::SkipEmptyParts); - for (int k = 0; k < strNum && k < parts.count(); ++k) + m_transform = m_ui->m_posEdit->text(); + const QStringList parts = m_transform.split(QRegularExpression("[\\s,;\\t]"), Qt::SkipEmptyParts); + for (int i = 0; i < argCount && i < parts.count(); ++i) { - pos[k] = parts[k].toDouble(); + transform[i] = parts[i].toDouble(); } - m_ui->m_dymX->setValue(pos[0]); - m_ui->m_dymY->setValue(pos[1]); - m_ui->m_dymZ->setValue(pos[2]); - m_ui->m_dymAngleX->setValue(pos[3]); - m_ui->m_dymAngleY->setValue(pos[4]); - m_ui->m_dymAngleZ->setValue(pos[5]); - - if constexpr (strNum == lengthInSw) - { - if (parts.count() == lengthInSw) - { - m_ui->m_dymSegX->setValue(static_cast(parts[6].toDouble())); - m_ui->m_dymSegY->setValue(static_cast(parts[7].toDouble())); - } - } + m_ui->m_dymX->setValue(transform[0]); + m_ui->m_dymY->setValue(transform[1]); + m_ui->m_dymZ->setValue(transform[2]); + m_ui->m_dymAnglePitch->setValue(transform[3]); + m_ui->m_dymAngleYaw->setValue(transform[4]); } - -////////////////////////////////////////////////////////////////////////// -void CGotoPositionDlg::OnUpdateNumbers() +void GotoPositionDialog::OnUpdateNumbers() { - m_ui->m_posEdit->setText(QString::fromLatin1("%1, %2, %3, %4, %5, %6") - .arg(m_ui->m_dymX->value(), 2, 'f', 2).arg(m_ui->m_dymY->value(), 2, 'f', 2).arg(m_ui->m_dymZ->value(), 2, 'f', 2) - .arg(m_ui->m_dymAngleX->value(), 2, 'f', 2).arg(m_ui->m_dymAngleY->value(), 2, 'f', 2).arg(m_ui->m_dymAngleZ->value(), 2, 'f', 2)); + m_ui->m_posEdit->setText(QString::fromLatin1("%1, %2, %3, %4, %5") + .arg(m_ui->m_dymX->value(), 2, 'f', 2) + .arg(m_ui->m_dymY->value(), 2, 'f', 2) + .arg(m_ui->m_dymZ->value(), 2, 'f', 2) + .arg(m_ui->m_dymAnglePitch->value(), 2, 'f', 2) + .arg(m_ui->m_dymAngleYaw->value(), 2, 'f', 2)); } - -void CGotoPositionDlg::accept() +void GotoPositionDialog::accept() { - Vec3 vPos(m_ui->m_dymX->value(), m_ui->m_dymY->value(), m_ui->m_dymZ->value()); - - m_ui->m_dymX->setValue(vPos.x); - m_ui->m_dymY->setValue(vPos.y); - m_ui->m_dymZ->setValue(vPos.z); - - AzToolsFramework::IEditorCameraController* editorCameraController = AZ::Interface::Get(); - AZ_Error("editor", editorCameraController, "IEditorCameraCommands is not registered."); - if (editorCameraController) - { - editorCameraController->SetCurrentViewPosition(AZ::Vector3{ - aznumeric_cast(m_ui->m_dymX->value()), - aznumeric_cast(m_ui->m_dymY->value()), - aznumeric_cast(m_ui->m_dymZ->value()) - }); - editorCameraController->SetCurrentViewRotation(AZ::Vector3{ - aznumeric_cast(m_ui->m_dymAngleX->value()), - aznumeric_cast(m_ui->m_dymAngleY->value()), - aznumeric_cast(m_ui->m_dymAngleZ->value()) - }); - } + SandboxEditor::SetDefaultViewportCameraPosition(AZ::Vector3( + aznumeric_cast(m_ui->m_dymX->value()), aznumeric_cast(m_ui->m_dymY->value()), + aznumeric_cast(m_ui->m_dymZ->value()))); + SandboxEditor::SetDefaultViewportCameraRotation( + AZ::DegToRad(aznumeric_cast(m_ui->m_dymAnglePitch->value())), + AZ::DegToRad(aznumeric_cast(m_ui->m_dymAngleYaw->value()))); QDialog::accept(); } diff --git a/Code/Sandbox/Editor/GotoPositionDlg.h b/Code/Sandbox/Editor/GotoPositionDlg.h index 4d9857aa0a..df5c30c546 100644 --- a/Code/Sandbox/Editor/GotoPositionDlg.h +++ b/Code/Sandbox/Editor/GotoPositionDlg.h @@ -11,12 +11,7 @@ */ // Original file Copyright Crytek GMBH or its affiliates, used under license. -#ifndef CRYINCLUDE_EDITOR_GOTOPOSITIONDLG_H -#define CRYINCLUDE_EDITOR_GOTOPOSITIONDLG_H - #pragma once -// GotoPositionDlg.h : header file -// #if !defined(Q_MOC_RUN) #include @@ -24,22 +19,19 @@ namespace Ui { - class GotoPositionDlg; + class GotoPositionDialog; } -///////////////////////////////////////////////////////////////////////////// -// CGotoPositionDlg dialog - -class CGotoPositionDlg +//! GotoPositionDialog for setting camera position and rotation. +class GotoPositionDialog : public QDialog { Q_OBJECT - // Construction -public: - CGotoPositionDlg(QWidget* pParent = nullptr); // standard constructor - ~CGotoPositionDlg(); - // Implementation +public: + explicit GotoPositionDialog(QWidget* parent = nullptr); + ~GotoPositionDialog(); + protected: void OnInitDialog(); void accept() override; @@ -47,12 +39,9 @@ protected: void OnUpdateNumbers(); void OnChangeEdit(); - public: - QString m_sPos; + QString m_transform; private: - QScopedPointer m_ui; + QScopedPointer m_ui; }; - -#endif // CRYINCLUDE_EDITOR_GOTOPOSITIONDLG_H diff --git a/Code/Sandbox/Editor/GotoPositionDlg.ui b/Code/Sandbox/Editor/GotoPositionDlg.ui index 9791b5bff1..99d7f16579 100644 --- a/Code/Sandbox/Editor/GotoPositionDlg.ui +++ b/Code/Sandbox/Editor/GotoPositionDlg.ui @@ -1,226 +1,166 @@ - GotoPositionDlg - + GotoPositionDialog + 0 0 - 290 - 180 + 182 + 174 Go to Position - + + + 6 + + + + + QLayout::SetDefaultConstraint + + + 6 + + + + + Angles: + + + + + + + + + + + + + Enter position here: + + + + + + + Position: + + + + + + + Z: + + + + + + + Y: + + + + + + + Pitch: + + + + + + + Yaw: + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + + X: + + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 22 - 20 - - - - - - - - - - - - - - - - - - - - - - - Z: - - - - - - - Y: - - - - - - - Enter position here: - - - - - - - X: - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Position: - - - - - - - X: - - - - - - - X: - - - - - - - - - - Y: - - - - - - - Y: - - - - - - - Z: - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 22 - 20 - - - - - - - - Angles: - - - - - - - Segments: - - - - - - - - - - + + + Qt::Horizontal + + + + 0 + 0 + + + - - - - - Qt::Horizontal - - - - 0 - 0 - - - - - - - - Go To - - - - - - - Cancel - - - - + + + Go To + + - + + + + Cancel + + + + + + m_posEdit m_dymX m_dymY m_dymZ - m_dymAngleX - m_dymAngleY - m_dymAngleZ - m_dymSegX - m_dymSegY + m_dymAnglePitch + m_dymAngleYaw pushButton_2 pushButton @@ -229,7 +169,7 @@ pushButton clicked() - GotoPositionDlg + GotoPositionDialog accept() @@ -245,7 +185,7 @@ pushButton_2 clicked() - GotoPositionDlg + GotoPositionDialog reject() diff --git a/Code/Sandbox/Editor/editor_lib_files.cmake b/Code/Sandbox/Editor/editor_lib_files.cmake index dc9d794021..07333cf6d5 100644 --- a/Code/Sandbox/Editor/editor_lib_files.cmake +++ b/Code/Sandbox/Editor/editor_lib_files.cmake @@ -817,6 +817,8 @@ set(FILES EditorViewportWidget.h EditorViewportSettings.cpp EditorViewportSettings.h + EditorViewportCamera.cpp + EditorViewportCamera.h ViewportManipulatorController.cpp ViewportManipulatorController.h LegacyViewportCameraController.cpp