Merge branch 'development' into Prefab/SaveAllPrefabs

Signed-off-by: srikappa-amzn <srikappa@amazon.com>
This commit is contained in:
srikappa-amzn
2021-09-08 14:11:50 -07:00
2167 changed files with 12739 additions and 36286 deletions
+3 -12
View File
@@ -236,10 +236,7 @@ QString CEditorCommandManager::Execute(const AZStd::string& module, const AZStd:
}
else
{
QString errMsg;
errMsg = QStringLiteral("Error: Trying to execute a unknown command, '%1'!").arg(fullName.c_str());
CryLogAlways(errMsg.toUtf8().data());
CryLogAlways("Error: Trying to execute a unknown command, '%s'!", fullName.c_str());
}
return "";
@@ -272,10 +269,7 @@ QString CEditorCommandManager::Execute(const AZStd::string& cmdLine)
}
else
{
QString errMsg;
errMsg = QStringLiteral("Error: Trying to execute a unknown command, '%1'!").arg(cmdLine.c_str());
CryLogAlways(errMsg.toUtf8().data());
CryLogAlways("Error: Trying to execute a unknown command, '%s'!", cmdLine.c_str());
}
return "";
@@ -294,10 +288,7 @@ void CEditorCommandManager::Execute(int commandId)
}
else
{
QString errMsg;
errMsg = QStringLiteral("Error: Trying to execute a unknown command of ID '%1'!").arg(commandId);
CryLogAlways(errMsg.toUtf8().data());
CryLogAlways("Error: Trying to execute a unknown command of ID '%d'!", commandId);
}
}
+1 -1
View File
@@ -36,7 +36,7 @@ void CConsoleDialog::SetInfoText(const char* text)
{
if (gEnv && gEnv->pLog) // before log system was initialized
{
CryLogAlways(text);
CryLogAlways("%s", text);
}
}
+8 -10
View File
@@ -26,9 +26,6 @@
#include <AzQtComponents/Components/Widgets/ScrollBar.h>
#include <AzQtComponents/Components/Widgets/SliderCombo.h>
// CryCommon
#include <CryCommon/SFunctor.h>
// Editor
#include "QtViewPaneManager.h"
#include "Core/QtEditorApplication.h"
@@ -392,7 +389,7 @@ void CConsoleSCB::RegisterViewClass()
opts.showInMenu = true;
opts.builtInActionId = ID_VIEW_CONSOLEWINDOW;
opts.shortcut = QKeySequence(Qt::Key_QuoteLeft);
AzToolsFramework::RegisterViewPane<CConsoleSCB>(LyViewPane::Console, LyViewPane::CategoryTools, opts);
}
@@ -421,9 +418,6 @@ void CConsoleSCB::RefreshStyle()
m_colorTable[6] = QColor(0xff, 0xaa, 0x22); // Warning (Yellow)
}
m_colorTable[0] = textColor;
m_colorTable[1] = textColor;
const bool uiAndDark = !GetIEditor()->IsInConsolewMode() && CConsoleSCB::GetCreatedInstance() && m_backgroundTheme == AzToolsFramework::ConsoleColorTheme::Dark;
QColor bgColor;
@@ -435,8 +429,13 @@ void CConsoleSCB::RefreshStyle()
else
{
bgColor = Qt::white;
textColor = Qt::black;
AzQtComponents::ScrollBar::applyDarkStyle(ui->textEdit);
}
m_colorTable[0] = textColor;
m_colorTable[1] = textColor;
ui->textEdit->setBackgroundVisible(!uiAndDark);
ui->textEdit->setStyleSheet(uiAndDark ? QString() : QString("QPlainTextEdit{ background: %1 }").arg(bgColor.name(QColor::HexRgb)));
@@ -604,8 +603,7 @@ static CVarBlock* VarBlockFromConsoleVars()
// Add our on change handler so we can update the CVariable created for
// the matching ICVar that has been modified
SFunctor onChange;
onChange.Set(OnVariableUpdated, i, pCVar);
AZStd::function<void()> onChange = [row=i,pCVar=pCVar]() { OnVariableUpdated(row,pCVar); };
pCVar->AddOnChangeFunctor(onChange);
pVariable->SetDescription(pCVar->GetHelp());
@@ -927,7 +925,7 @@ QWidget* ConsoleVariableItemDelegate::createEditor(QWidget* parent, const QStyle
return editor;
}
}
// If we get here, value being edited is a string, so use our styled line
// edit widget
AzQtComponents::StyledLineEdit* lineEdit = new AzQtComponents::StyledLineEdit(parent);
-10
View File
@@ -1940,16 +1940,6 @@ void CCryEditDoc::SetDocumentReady(bool bReady)
m_bDocumentReady = bReady;
}
void CCryEditDoc::GetMemoryUsage(ICrySizer* pSizer) const
{
{
SIZER_COMPONENT_NAME(pSizer, "UndoManager(estimate)");
GetIEditor()->GetUndoManager()->GetMemoryUsage(pSizer);
}
pSizer->Add(*this);
}
void CCryEditDoc::RegisterConsoleVariables()
{
doc_validate_surface_types = gEnv->pConsole->GetCVar("doc_validate_surface_types");
-2
View File
@@ -134,8 +134,6 @@ public: // Create from serialization only
void RegisterListener(IDocListener* listener);
void UnregisterListener(IDocListener* listener);
void GetMemoryUsage(ICrySizer* pSizer) const;
static bool IsBackupOrTempLevelSubdirectory(const QString& folderName);
protected:
+4 -4
View File
@@ -27,8 +27,8 @@
#include "EditorPreferencesPageGeneral.h"
#include "EditorPreferencesPageFiles.h"
#include "EditorPreferencesPageViewportGeneral.h"
#include "EditorPreferencesPageViewportGizmo.h"
#include "EditorPreferencesPageViewportMovement.h"
#include "EditorPreferencesPageViewportManipulator.h"
#include "EditorPreferencesPageViewportCamera.h"
#include "EditorPreferencesPageViewportDebug.h"
#include "EditorPreferencesPageExperimentalLighting.h"
#include "EditorPreferencesPageAWS.h"
@@ -65,8 +65,8 @@ EditorPreferencesDialog::EditorPreferencesDialog(QWidget* pParent)
CEditorPreferencesPage_General::Reflect(*serializeContext);
CEditorPreferencesPage_Files::Reflect(*serializeContext);
CEditorPreferencesPage_ViewportGeneral::Reflect(*serializeContext);
CEditorPreferencesPage_ViewportGizmo::Reflect(*serializeContext);
CEditorPreferencesPage_ViewportMovement::Reflect(*serializeContext);
CEditorPreferencesPage_ViewportManipulator::Reflect(*serializeContext);
CEditorPreferencesPage_ViewportCamera::Reflect(*serializeContext);
CEditorPreferencesPage_ViewportDebug::Reflect(*serializeContext);
CEditorPreferencesPage_ExperimentalLighting::Reflect(*serializeContext);
CEditorPreferencesPage_AWS::Reflect(*serializeContext);
@@ -8,7 +8,7 @@
#include "EditorDefs.h"
#include "EditorPreferencesPageViewportMovement.h"
#include "EditorPreferencesPageViewportCamera.h"
#include <AzCore/std/sort.h>
#include <AzFramework/Input/Buses/Requests/InputDeviceRequestBus.h>
@@ -58,7 +58,7 @@ static AZStd::vector<AZStd::string> GetEditorInputNames()
return inputNames;
}
void CEditorPreferencesPage_ViewportMovement::Reflect(AZ::SerializeContext& serialize)
void CEditorPreferencesPage_ViewportCamera::Reflect(AZ::SerializeContext& serialize)
{
serialize.Class<CameraMovementSettings>()
->Version(2)
@@ -93,36 +93,37 @@ void CEditorPreferencesPage_ViewportMovement::Reflect(AZ::SerializeContext& seri
->Field("OrbitDolly", &CameraInputSettings::m_orbitDollyChannelId)
->Field("OrbitPan", &CameraInputSettings::m_orbitPanChannelId);
serialize.Class<CEditorPreferencesPage_ViewportMovement>()
serialize.Class<CEditorPreferencesPage_ViewportCamera>()
->Version(1)
->Field("CameraMovementSettings", &CEditorPreferencesPage_ViewportMovement::m_cameraMovementSettings)
->Field("CameraInputSettings", &CEditorPreferencesPage_ViewportMovement::m_cameraInputSettings);
->Field("CameraMovementSettings", &CEditorPreferencesPage_ViewportCamera::m_cameraMovementSettings)
->Field("CameraInputSettings", &CEditorPreferencesPage_ViewportCamera::m_cameraInputSettings);
if (AZ::EditContext* editContext = serialize.GetEditContext())
{
const float minValue = 0.0001f;
editContext->Class<CameraMovementSettings>("Camera Movement Settings", "")
->DataElement(
AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_translateSpeed, "Camera Movement Speed", "Camera movement speed")
->Attribute(AZ::Edit::Attributes::Min, 0.01f)
->Attribute(AZ::Edit::Attributes::Min, minValue)
->DataElement(
AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_rotateSpeed, "Camera Rotation Speed", "Camera rotation speed")
->Attribute(AZ::Edit::Attributes::Min, 0.01f)
->Attribute(AZ::Edit::Attributes::Min, minValue)
->DataElement(
AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_boostMultiplier, "Camera Boost Multiplier",
"Camera boost multiplier to apply to movement speed")
->Attribute(AZ::Edit::Attributes::Min, 0.01f)
->Attribute(AZ::Edit::Attributes::Min, minValue)
->DataElement(
AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_scrollSpeed, "Camera Scroll Speed",
"Camera movement speed while using scroll/wheel input")
->Attribute(AZ::Edit::Attributes::Min, 0.01f)
->Attribute(AZ::Edit::Attributes::Min, minValue)
->DataElement(
AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_dollySpeed, "Camera Dolly Speed",
"Camera movement speed while using mouse motion to move in and out")
->Attribute(AZ::Edit::Attributes::Min, 0.01f)
->Attribute(AZ::Edit::Attributes::Min, minValue)
->DataElement(
AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_panSpeed, "Camera Pan Speed",
"Camera movement speed while panning using the mouse")
->Attribute(AZ::Edit::Attributes::Min, 0.01f)
->Attribute(AZ::Edit::Attributes::Min, minValue)
->DataElement(
AZ::Edit::UIHandlers::CheckBox, &CameraMovementSettings::m_rotateSmoothing, "Camera Rotate Smoothing",
"Is camera rotation smoothing enabled or disabled")
@@ -130,7 +131,7 @@ void CEditorPreferencesPage_ViewportMovement::Reflect(AZ::SerializeContext& seri
->DataElement(
AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_rotateSmoothness, "Camera Rotate Smoothness",
"Amount of camera smoothing to apply while rotating the camera")
->Attribute(AZ::Edit::Attributes::Min, 0.01f)
->Attribute(AZ::Edit::Attributes::Min, minValue)
->Attribute(AZ::Edit::Attributes::Visibility, &CameraMovementSettings::RotateSmoothingVisibility)
->DataElement(
AZ::Edit::UIHandlers::CheckBox, &CameraMovementSettings::m_translateSmoothing, "Camera Translate Smoothing",
@@ -139,7 +140,7 @@ void CEditorPreferencesPage_ViewportMovement::Reflect(AZ::SerializeContext& seri
->DataElement(
AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_translateSmoothness, "Camera Translate Smoothness",
"Amount of camera smoothing to apply while translating the camera")
->Attribute(AZ::Edit::Attributes::Min, 0.01f)
->Attribute(AZ::Edit::Attributes::Min, minValue)
->Attribute(AZ::Edit::Attributes::Visibility, &CameraMovementSettings::TranslateSmoothingVisibility)
->DataElement(
AZ::Edit::UIHandlers::CheckBox, &CameraMovementSettings::m_orbitYawRotationInverted, "Camera Orbit Yaw Inverted",
@@ -207,35 +208,50 @@ void CEditorPreferencesPage_ViewportMovement::Reflect(AZ::SerializeContext& seri
"Key/button to begin camera orbit pan")
->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames);
editContext->Class<CEditorPreferencesPage_ViewportMovement>("Viewport Preferences", "Viewport Preferences")
editContext->Class<CEditorPreferencesPage_ViewportCamera>("Viewport Preferences", "Viewport Preferences")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Visibility, AZ_CRC("PropertyVisibility_ShowChildrenOnly", 0xef428f20))
->DataElement(
AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_ViewportMovement::m_cameraMovementSettings,
AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_ViewportCamera::m_cameraMovementSettings,
"Camera Movement Settings", "Camera Movement Settings")
->DataElement(
AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_ViewportMovement::m_cameraInputSettings, "Camera Input Settings",
AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_ViewportCamera::m_cameraInputSettings, "Camera Input Settings",
"Camera Input Settings");
}
}
CEditorPreferencesPage_ViewportMovement::CEditorPreferencesPage_ViewportMovement()
CEditorPreferencesPage_ViewportCamera::CEditorPreferencesPage_ViewportCamera()
{
InitializeSettings();
m_icon = QIcon(":/res/Camera.svg");
}
const char* CEditorPreferencesPage_ViewportMovement::GetTitle()
const char* CEditorPreferencesPage_ViewportCamera::GetCategory()
{
return "Viewports";
}
const char* CEditorPreferencesPage_ViewportCamera::GetTitle()
{
return "Camera";
}
QIcon& CEditorPreferencesPage_ViewportMovement::GetIcon()
QIcon& CEditorPreferencesPage_ViewportCamera::GetIcon()
{
return m_icon;
}
void CEditorPreferencesPage_ViewportMovement::OnApply()
void CEditorPreferencesPage_ViewportCamera::OnCancel()
{
// noop
}
bool CEditorPreferencesPage_ViewportCamera::OnQueryCancel()
{
return true;
}
void CEditorPreferencesPage_ViewportCamera::OnApply()
{
SandboxEditor::SetCameraTranslateSpeed(m_cameraMovementSettings.m_translateSpeed);
SandboxEditor::SetCameraRotateSpeed(m_cameraMovementSettings.m_rotateSpeed);
@@ -270,7 +286,7 @@ void CEditorPreferencesPage_ViewportMovement::OnApply()
&SandboxEditor::EditorModularViewportCameraComposerNotificationBus::Events::OnEditorModularViewportCameraComposerSettingsChanged);
}
void CEditorPreferencesPage_ViewportMovement::InitializeSettings()
void CEditorPreferencesPage_ViewportCamera::InitializeSettings()
{
m_cameraMovementSettings.m_translateSpeed = SandboxEditor::CameraTranslateSpeed();
m_cameraMovementSettings.m_rotateSpeed = SandboxEditor::CameraRotateSpeed();
@@ -19,32 +19,22 @@ inline AZ::Crc32 EditorPropertyVisibility(const bool enabled)
return enabled ? AZ::Edit::PropertyVisibility::Show : AZ::Edit::PropertyVisibility::Hide;
}
class CEditorPreferencesPage_ViewportMovement : public IPreferencesPage
class CEditorPreferencesPage_ViewportCamera : public IPreferencesPage
{
public:
AZ_RTTI(CEditorPreferencesPage_ViewportMovement, "{BC593332-7EAF-4171-8A35-1C5DE5B40909}", IPreferencesPage)
AZ_RTTI(CEditorPreferencesPage_ViewportCamera, "{BC593332-7EAF-4171-8A35-1C5DE5B40909}", IPreferencesPage)
static void Reflect(AZ::SerializeContext& serialize);
CEditorPreferencesPage_ViewportMovement();
virtual ~CEditorPreferencesPage_ViewportMovement() = default;
CEditorPreferencesPage_ViewportCamera();
virtual ~CEditorPreferencesPage_ViewportCamera() = default;
virtual const char* GetCategory() override
{
return "Viewports";
}
virtual const char* GetTitle();
virtual QIcon& GetIcon() override;
virtual void OnApply() override;
virtual void OnCancel() override
{
}
virtual bool OnQueryCancel() override
{
return true;
}
const char* GetCategory() override;
const char* GetTitle() override;
QIcon& GetIcon() override;
void OnApply() override;
void OnCancel() override;
bool OnQueryCancel() override;
private:
void InitializeSettings();
@@ -1,100 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "EditorPreferencesPageViewportGizmo.h"
// Editor
#include "Settings.h"
void CEditorPreferencesPage_ViewportGizmo::Reflect(AZ::SerializeContext& serialize)
{
serialize.Class<AxisGizmo>()
->Version(1)
->Field("Size", &AxisGizmo::m_size)
->Field("Text", &AxisGizmo::m_text)
->Field("MaxCount", &AxisGizmo::m_maxCount);
serialize.Class<Helpers>()
->Version(1)
->Field("LabelsOn", &Helpers::m_helpersGlobalScale)
->Field("LabelsOn", &Helpers::m_tagpointScaleMulti)
->Field("LabelsOn", &Helpers::m_rulerSphereScale)
->Field("LabelsDistance", &Helpers::m_rulerSphereTrans);
serialize.Class<CEditorPreferencesPage_ViewportGizmo>()
->Version(1)
->Field("Axis Gizmo", &CEditorPreferencesPage_ViewportGizmo::m_axisGizmo)
->Field("Helpers", &CEditorPreferencesPage_ViewportGizmo::m_helpers);
AZ::EditContext* editContext = serialize.GetEditContext();
if (editContext)
{
editContext->Class<AxisGizmo>("Axis Gizmo", "")
->DataElement(AZ::Edit::UIHandlers::SpinBox, &AxisGizmo::m_size, "Size", "Axis Gizmo Size")
->DataElement(AZ::Edit::UIHandlers::CheckBox, &AxisGizmo::m_text, "Text Labels", "Text Labels on Axis Gizmo")
->DataElement(AZ::Edit::UIHandlers::SpinBox, &AxisGizmo::m_maxCount, "Max Count", "Max Count of Axis Gizmos");
editContext->Class<Helpers>("Helpers", "")
->DataElement(AZ::Edit::UIHandlers::SpinBox, &Helpers::m_helpersGlobalScale, "Helpers Scale", "Helpers Scale")
->Attribute(AZ::Edit::Attributes::Min, 0.01f)
->Attribute(AZ::Edit::Attributes::Max, 100.0f)
->DataElement(AZ::Edit::UIHandlers::SpinBox, &Helpers::m_tagpointScaleMulti, "Tagpoint Scale Multiplier", "Tagpoint Scale Multiplier")
->Attribute(AZ::Edit::Attributes::Min, 0.01f)
->Attribute(AZ::Edit::Attributes::Max, 100.0f)
->DataElement(AZ::Edit::UIHandlers::SpinBox, &Helpers::m_rulerSphereScale, "Ruler Sphere Scale", "Ruler Sphere Scale")
->Attribute(AZ::Edit::Attributes::Min, 0.1f)
->Attribute(AZ::Edit::Attributes::Max, 100.0f)
->Attribute(AZ::Edit::Attributes::Step, 0.1f)
->DataElement(AZ::Edit::UIHandlers::SpinBox, &Helpers::m_rulerSphereTrans, "Ruler Sphere Transparency", "Ruler Sphere Transparency")
->Attribute(AZ::Edit::Attributes::Min, 0.01f)
->Attribute(AZ::Edit::Attributes::Max, 100.0f);
editContext->Class<CEditorPreferencesPage_ViewportGizmo>("Gizmo Viewport Preferences", "Gizmo Viewport Preferences")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Visibility, AZ_CRC("PropertyVisibility_ShowChildrenOnly", 0xef428f20))
->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_ViewportGizmo::m_axisGizmo, "Axis Gizmo", "Axis Gizmo")
->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_ViewportGizmo::m_helpers, "Helpers", "Helpers");
}
}
CEditorPreferencesPage_ViewportGizmo::CEditorPreferencesPage_ViewportGizmo()
{
InitializeSettings();
m_icon = QIcon(":/res/Gizmos.svg");
}
QIcon& CEditorPreferencesPage_ViewportGizmo::GetIcon()
{
return m_icon;
}
void CEditorPreferencesPage_ViewportGizmo::OnApply()
{
gSettings.gizmo.axisGizmoSize = m_axisGizmo.m_size;
gSettings.gizmo.axisGizmoText = m_axisGizmo.m_text;
gSettings.gizmo.axisGizmoMaxCount = m_axisGizmo.m_maxCount;
gSettings.gizmo.helpersScale = m_helpers.m_helpersGlobalScale;
gSettings.gizmo.tagpointScaleMulti = m_helpers.m_tagpointScaleMulti;
gSettings.gizmo.rulerSphereScale = m_helpers.m_rulerSphereScale;
gSettings.gizmo.rulerSphereTrans = m_helpers.m_rulerSphereTrans;
}
void CEditorPreferencesPage_ViewportGizmo::InitializeSettings()
{
m_axisGizmo.m_size = gSettings.gizmo.axisGizmoSize;
m_axisGizmo.m_text = gSettings.gizmo.axisGizmoText;
m_axisGizmo.m_maxCount = gSettings.gizmo.axisGizmoMaxCount;
m_helpers.m_helpersGlobalScale = gSettings.gizmo.helpersScale;
m_helpers.m_tagpointScaleMulti = gSettings.gizmo.tagpointScaleMulti;
m_helpers.m_rulerSphereScale = gSettings.gizmo.rulerSphereScale;
m_helpers.m_rulerSphereTrans = gSettings.gizmo.rulerSphereTrans;
}
@@ -1,63 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include "Include/IPreferencesPage.h"
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/RTTI/RTTI.h>
#include <AzCore/Math/Vector3.h>
#include <QIcon>
class CEditorPreferencesPage_ViewportGizmo
: public IPreferencesPage
{
public:
AZ_RTTI(CEditorPreferencesPage_ViewportGizmo, "{14433511-8175-4348-954E-82D903475B06}", IPreferencesPage)
static void Reflect(AZ::SerializeContext& serialize);
CEditorPreferencesPage_ViewportGizmo();
virtual ~CEditorPreferencesPage_ViewportGizmo() = default;
virtual const char* GetCategory() override { return "Viewports"; }
virtual const char* GetTitle() override { return "Gizmos"; }
virtual QIcon& GetIcon() override;
virtual void OnApply() override;
virtual void OnCancel() override {}
virtual bool OnQueryCancel() override { return true; }
private:
void InitializeSettings();
struct AxisGizmo
{
AZ_TYPE_INFO(AxisGizmo, "{7D90D60E-996B-4F54-8748-B26EFA781EE2}")
float m_size;
bool m_text;
int m_maxCount;
};
struct Helpers
{
AZ_TYPE_INFO(Helpers, "{EC99922E-F61C-4AA0-9A51-630E09AB55AA}")
float m_helpersGlobalScale;
float m_tagpointScaleMulti;
float m_rulerSphereScale;
float m_rulerSphereTrans;
};
AxisGizmo m_axisGizmo;
Helpers m_helpers;
QIcon m_icon;
};
@@ -0,0 +1,91 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "EditorPreferencesPageViewportManipulator.h"
// Editor
#include "EditorViewportSettings.h"
#include "Settings.h"
void CEditorPreferencesPage_ViewportManipulator::Reflect(AZ::SerializeContext& serialize)
{
serialize.Class<Manipulators>()
->Version(1)
->Field("LineBoundWidth", &Manipulators::m_manipulatorLineBoundWidth)
->Field("CircleBoundWidth", &Manipulators::m_manipulatorCircleBoundWidth);
serialize.Class<CEditorPreferencesPage_ViewportManipulator>()->Version(2)->Field(
"Manipulators", &CEditorPreferencesPage_ViewportManipulator::m_manipulators);
if (AZ::EditContext* editContext = serialize.GetEditContext())
{
editContext->Class<Manipulators>("Manipulators", "")
->DataElement(
AZ::Edit::UIHandlers::SpinBox, &Manipulators::m_manipulatorLineBoundWidth, "Line Bound Width",
"Manipulator Line Bound Width")
->Attribute(AZ::Edit::Attributes::Min, 0.001f)
->Attribute(AZ::Edit::Attributes::Max, 2.0f)
->DataElement(
AZ::Edit::UIHandlers::SpinBox, &Manipulators::m_manipulatorCircleBoundWidth, "Circle Bound Width",
"Manipulator Circle Bound Width")
->Attribute(AZ::Edit::Attributes::Min, 0.001f)
->Attribute(AZ::Edit::Attributes::Max, 2.0f);
editContext
->Class<CEditorPreferencesPage_ViewportManipulator>("Manipulator Viewport Preferences", "Manipulator Viewport Preferences")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Visibility, AZ_CRC("PropertyVisibility_ShowChildrenOnly", 0xef428f20))
->DataElement(
AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_ViewportManipulator::m_manipulators, "Manipulators", "Manipulators");
}
}
CEditorPreferencesPage_ViewportManipulator::CEditorPreferencesPage_ViewportManipulator()
{
InitializeSettings();
m_icon = QIcon(":/res/Gizmos.svg");
}
const char* CEditorPreferencesPage_ViewportManipulator::GetCategory()
{
return "Viewports";
}
const char* CEditorPreferencesPage_ViewportManipulator::GetTitle()
{
return "Manipulators";
}
QIcon& CEditorPreferencesPage_ViewportManipulator::GetIcon()
{
return m_icon;
}
void CEditorPreferencesPage_ViewportManipulator::OnCancel()
{
// noop
}
bool CEditorPreferencesPage_ViewportManipulator::OnQueryCancel()
{
return true;
}
void CEditorPreferencesPage_ViewportManipulator::OnApply()
{
SandboxEditor::SetManipulatorLineBoundWidth(m_manipulators.m_manipulatorLineBoundWidth);
SandboxEditor::SetManipulatorCircleBoundWidth(m_manipulators.m_manipulatorCircleBoundWidth);
}
void CEditorPreferencesPage_ViewportManipulator::InitializeSettings()
{
m_manipulators.m_manipulatorLineBoundWidth = SandboxEditor::ManipulatorLineBoundWidth();
m_manipulators.m_manipulatorCircleBoundWidth = SandboxEditor::ManipulatorCircleBoundWidth();
}
@@ -0,0 +1,48 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include "Include/IPreferencesPage.h"
#include <AzCore/Math/Vector3.h>
#include <AzCore/RTTI/RTTI.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <QIcon>
class CEditorPreferencesPage_ViewportManipulator : public IPreferencesPage
{
public:
AZ_RTTI(CEditorPreferencesPage_ViewportManipulator, "{14433511-8175-4348-954E-82D903475B06}", IPreferencesPage)
static void Reflect(AZ::SerializeContext& serialize);
CEditorPreferencesPage_ViewportManipulator();
virtual ~CEditorPreferencesPage_ViewportManipulator() = default;
const char* GetCategory() override;
const char* GetTitle() override;
QIcon& GetIcon() override;
void OnApply() override;
void OnCancel() override;
bool OnQueryCancel() override;
private:
void InitializeSettings();
struct Manipulators
{
AZ_TYPE_INFO(Manipulators, "{2974439C-4839-41F6-B526-F317999B9DB9}")
float m_manipulatorLineBoundWidth = 0.0f;
float m_manipulatorCircleBoundWidth = 0.0f;
};
Manipulators m_manipulators;
QIcon m_icon;
};
+22
View File
@@ -20,6 +20,8 @@ namespace SandboxEditor
constexpr AZStd::string_view AngleSnappingSetting = "/Amazon/Preferences/Editor/AngleSnapping";
constexpr AZStd::string_view AngleSizeSetting = "/Amazon/Preferences/Editor/AngleSize";
constexpr AZStd::string_view ShowGridSetting = "/Amazon/Preferences/Editor/ShowGrid";
constexpr AZStd::string_view ManipulatorLineBoundWidthSetting = "/Amazon/Preferences/Editor/Manipulator/LineBoundWidth";
constexpr AZStd::string_view ManipulatorCircleBoundWidthSetting = "/Amazon/Preferences/Editor/Manipulator/CircleBoundWidth";
constexpr AZStd::string_view CameraTranslateSpeedSetting = "/Amazon/Preferences/Editor/Camera/TranslateSpeed";
constexpr AZStd::string_view CameraBoostMultiplierSetting = "/Amazon/Preferences/Editor/Camera/BoostMultiplier";
constexpr AZStd::string_view CameraRotateSpeedSetting = "/Amazon/Preferences/Editor/Camera/RotateSpeed";
@@ -156,6 +158,26 @@ namespace SandboxEditor
SetRegistry(ShowGridSetting, showing);
}
float ManipulatorLineBoundWidth()
{
return aznumeric_cast<float>(GetRegistry(ManipulatorLineBoundWidthSetting, 0.1));
}
void SetManipulatorLineBoundWidth(const float lineBoundWidth)
{
SetRegistry(ManipulatorLineBoundWidthSetting, lineBoundWidth);
}
float ManipulatorCircleBoundWidth()
{
return aznumeric_cast<float>(GetRegistry(ManipulatorCircleBoundWidthSetting, 0.1));
}
void SetManipulatorCircleBoundWidth(const float circleBoundWidth)
{
SetRegistry(ManipulatorCircleBoundWidthSetting, circleBoundWidth);
}
float CameraTranslateSpeed()
{
return aznumeric_cast<float>(GetRegistry(CameraTranslateSpeedSetting, 10.0));
+6
View File
@@ -47,6 +47,12 @@ namespace SandboxEditor
SANDBOX_API bool ShowingGrid();
SANDBOX_API void SetShowingGrid(bool showing);
SANDBOX_API float ManipulatorLineBoundWidth();
SANDBOX_API void SetManipulatorLineBoundWidth(float lineBoundWidth);
SANDBOX_API float ManipulatorCircleBoundWidth();
SANDBOX_API void SetManipulatorCircleBoundWidth(float circleBoundWidth);
SANDBOX_API float CameraTranslateSpeed();
SANDBOX_API void SetCameraTranslateSpeed(float speed);
+24 -13
View File
@@ -113,18 +113,6 @@ void StartFixedCursorMode(QObject *viewport);
#define RENDER_MESH_TEST_DISTANCE (0.2f)
#define CURSOR_FONT_HEIGHT 8.0f
//! Viewport settings for the EditorViewportWidget
struct EditorViewportSettings : public AzToolsFramework::ViewportInteraction::ViewportSettings
{
bool GridSnappingEnabled() const override;
float GridSize() const override;
bool ShowGrid() const override;
bool AngleSnappingEnabled() const override;
float AngleStep() const override;
};
static const EditorViewportSettings g_EditorViewportSettings;
namespace AZ::ViewportHelpers
{
static const char TextCantCreateCameraNoLevel[] = "Cannot create camera when no level is loaded.";
@@ -218,6 +206,7 @@ EditorViewportWidget::~EditorViewportWidget()
m_pPrimaryViewport = nullptr;
}
m_editorViewportSettings.Disconnect();
DisconnectViewportInteractionRequestBus();
m_editorEntityNotifications.reset();
Camera::EditorCameraRequestBus::Handler::BusDisconnect();
@@ -1073,7 +1062,7 @@ void EditorViewportWidget::SetViewportId(int id)
m_editorModularViewportCameraComposer = AZStd::make_unique<SandboxEditor::EditorModularViewportCameraComposer>(AzFramework::ViewportId(id));
m_renderViewport->GetControllerList()->Add(m_editorModularViewportCameraComposer->CreateModularViewportCameraController());
m_renderViewport->SetViewportSettings(&g_EditorViewportSettings);
m_editorViewportSettings.Connect(AzFramework::ViewportId(id));
UpdateScene();
@@ -1098,6 +1087,7 @@ void EditorViewportWidget::ConnectViewportInteractionRequestBus()
{
AzToolsFramework::ViewportInteraction::ViewportFreezeRequestBus::Handler::BusConnect(GetViewportId());
AzToolsFramework::ViewportInteraction::MainEditorViewportInteractionRequestBus::Handler::BusConnect(GetViewportId());
AzToolsFramework::ViewportInteraction::EditorEntityViewportInteractionRequestBus::Handler::BusConnect(GetViewportId());
m_viewportUi.ConnectViewportUiBus(GetViewportId());
AzFramework::InputSystemCursorConstraintRequestBus::Handler::BusConnect();
@@ -1108,6 +1098,7 @@ void EditorViewportWidget::DisconnectViewportInteractionRequestBus()
AzFramework::InputSystemCursorConstraintRequestBus::Handler::BusDisconnect();
m_viewportUi.DisconnectViewportUiBus();
AzToolsFramework::ViewportInteraction::EditorEntityViewportInteractionRequestBus::Handler::BusDisconnect();
AzToolsFramework::ViewportInteraction::MainEditorViewportInteractionRequestBus::Handler::BusDisconnect();
AzToolsFramework::ViewportInteraction::ViewportFreezeRequestBus::Handler::BusDisconnect();
}
@@ -2534,6 +2525,16 @@ void EditorViewportWidget::SetAsActiveViewport()
}
}
void EditorViewportSettings::Connect(const AzFramework::ViewportId viewportId)
{
AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Handler::BusConnect(viewportId);
}
void EditorViewportSettings::Disconnect()
{
AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Handler::BusDisconnect();
}
bool EditorViewportSettings::GridSnappingEnabled() const
{
return SandboxEditor::GridSnappingEnabled();
@@ -2559,6 +2560,16 @@ float EditorViewportSettings::AngleStep() const
return SandboxEditor::AngleSnappingSize();
}
float EditorViewportSettings::ManipulatorLineBoundWidth() const
{
return SandboxEditor::ManipulatorLineBoundWidth();
}
float EditorViewportSettings::ManipulatorCircleBoundWidth() const
{
return SandboxEditor::ManipulatorCircleBoundWidth();
}
AZ_CVAR_EXTERNED(bool, ed_previewGameInFullscreen_once);
bool EditorViewportWidget::ShouldPreviewFullscreen() const
+37 -12
View File
@@ -63,6 +63,22 @@ namespace AzToolsFramework
class ManipulatorManager;
}
//! Viewport settings for the EditorViewportWidget
struct EditorViewportSettings : public AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Handler
{
void Connect(AzFramework::ViewportId viewportId);
void Disconnect();
// ViewportSettingsRequestBus overrides ...
bool GridSnappingEnabled() const override;
float GridSize() const override;
bool ShowGrid() const override;
bool AngleSnappingEnabled() const override;
float AngleStep() const override;
float ManipulatorLineBoundWidth() const override;
float ManipulatorCircleBoundWidth() const override;
};
// EditorViewportWidget window
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
@@ -75,6 +91,7 @@ class SANDBOX_API EditorViewportWidget final
, private AzFramework::InputSystemCursorConstraintRequestBus::Handler
, private AzToolsFramework::ViewportInteraction::ViewportFreezeRequestBus::Handler
, private AzToolsFramework::ViewportInteraction::MainEditorViewportInteractionRequestBus::Handler
, private AzToolsFramework::ViewportInteraction::EditorEntityViewportInteractionRequestBus::Handler
, private AzFramework::AssetCatalogEventBus::Handler
, private AZ::RPI::SceneNotificationBus::Handler
{
@@ -112,10 +129,12 @@ private:
CameraComponent,
ViewSourceTypesCount,
};
enum class PlayInEditorState
{
Editor, Starting, Started
};
enum class KeyPressedState
{
AllUp,
@@ -126,7 +145,7 @@ private:
////////////////////////////////////////////////////////////////////////
// Method overrides ...
// QWidget
// QWidget overrides ...
void focusOutEvent(QFocusEvent* event) override;
void keyPressEvent(QKeyEvent* event) override;
bool event(QEvent* event) override;
@@ -134,7 +153,7 @@ private:
void paintEvent(QPaintEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
// QtViewport/IDisplayViewport/CViewport
// QtViewport/IDisplayViewport/CViewport overrides ...
EViewportType GetType() const override { return ET_ViewportCamera; }
void SetType([[maybe_unused]] EViewportType type) override { assert(type == ET_ViewportCamera); };
AzToolsFramework::ViewportInteraction::MouseInteraction BuildMouseInteraction(
@@ -160,16 +179,17 @@ private:
void Update() override;
void UpdateContent(int flags) override;
// SceneNotificationBus
// SceneNotificationBus overrides ...
void OnBeginPrepareRender() override;
// Camera::CameraNotificationBus
// Camera::CameraNotificationBus overrides ...
void OnActiveViewChanged(const AZ::EntityId&) override;
// IEditorEventListener
// IEditorEventListener overrides ...
void OnEditorNotifyEvent(EEditorNotifyEvent event) override;
// AzToolsFramework::EditorEntityContextNotificationBus (handler moved to cpp to resolve link issues in unity builds)
// AzToolsFramework::EditorEntityContextNotificationBus overrides ...
// note: handler moved to cpp to resolve link issues in unity builds
void OnStartPlayInEditor();
void OnStopPlayInEditor();
void OnStartPlayInEditorBegin();
@@ -178,10 +198,10 @@ private:
void BeginUndoTransaction() override;
void EndUndoTransaction() override;
// AzFramework::InputSystemCursorConstraintRequestBus
// AzFramework::InputSystemCursorConstraintRequestBus overrides ...
void* GetSystemCursorConstraintWindow() const override;
// AzToolsFramework::ViewportFreezeRequestBus
// AzToolsFramework::ViewportFreezeRequestBus overrides ...
bool IsViewportInputFrozen() override;
void FreezeViewportInput(bool freeze) override;
@@ -189,13 +209,15 @@ private:
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;
// Camera::EditorCameraRequestBus
// EditorEntityViewportInteractionRequestBus overrides ...
void FindVisibleEntities(AZStd::vector<AZ::EntityId>& visibleEntities) override;
// Camera::EditorCameraRequestBus overrides ...
void SetViewFromEntityPerspective(const AZ::EntityId& entityId) override;
void SetViewAndMovementLockFromEntityPerspective(const AZ::EntityId& entityId, bool lockCameraMovement) override;
AZ::EntityId GetCurrentViewEntityId() override;
@@ -311,7 +333,7 @@ private:
// 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
// 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
@@ -338,7 +360,7 @@ private:
// 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
// Reentrancy guard for on paint events
bool m_isOnPaint = false;
// Shapes of various safe frame helpers which can be displayed in the editor
@@ -381,6 +403,9 @@ private:
// Atom debug display
AzFramework::DebugDisplayRequests* m_debugDisplay = nullptr;
// Type to return current state of editor viewport settings
EditorViewportSettings m_editorViewportSettings;
// The default view created for the viewport context, which is used as the "Editor Camera"
AZ::RPI::ViewPtr m_defaultView;
-54
View File
@@ -249,60 +249,6 @@ void CErrorReport::SetImmediateMode(bool bEnable)
}
}
//////////////////////////////////////////////////////////////////////////
void CErrorReport::Report(SValidatorRecord& record)
{
if ((record.flags & VALIDATOR_FLAG_IGNORE_IN_EDITOR))
{
return;
}
CErrorRecord err;
if (record.text)
{
err.error = record.text;
}
if (record.description)
{
err.description = record.description;
}
if (record.file)
{
err.file = record.file;
}
else
{
err.file = m_currentFilename;
}
err.severity = (CErrorRecord::ESeverity)record.severity;
err.assetScope = record.assetScope;
err.flags = 0;
if (record.flags & VALIDATOR_FLAG_FILE)
{
err.flags |= CErrorRecord::FLAG_NOFILE;
}
if (record.flags & VALIDATOR_FLAG_TEXTURE)
{
err.flags |= CErrorRecord::FLAG_TEXTURE;
}
if (record.flags & VALIDATOR_FLAG_SCRIPT)
{
err.flags |= CErrorRecord::FLAG_SCRIPT;
}
if (record.flags & VALIDATOR_FLAG_AI)
{
err.flags |= CErrorRecord::FLAG_AI;
}
err.module = record.module;
err.pObject = m_pObject;
err.pItem = m_pItem;
ReportError(err);
}
//////////////////////////////////////////////////////////////////////////
void CErrorReport::SetCurrentValidatorObject(CBaseObject* pObject)
{
-5
View File
@@ -121,11 +121,6 @@ public:
//! Assign current filename.
void SetCurrentFile(const QString& file);
//////////////////////////////////////////////////////////////////////////
// Implement IValidator interface.
//////////////////////////////////////////////////////////////////////////
virtual void Report(SValidatorRecord& record);
private:
//! Array of all error records added to report.
std::vector<CErrorRecord> m_errors;
-5
View File
@@ -176,11 +176,6 @@ struct SSystemUserCallback
return CryMessageBox(text, caption, uType);
}
void GetMemoryUsage(ICrySizer* pSizer) override
{
GetIEditor()->GetMemoryUsage(pSizer);
}
void OnSplashScreenDone()
{
m_pLogo = nullptr;
+1 -7
View File
@@ -5,10 +5,6 @@
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_GAMEEXPORTER_H
#define CRYINCLUDE_EDITOR_GAMEEXPORTER_H
#pragma once
#include "Util/PakFile.h"
@@ -62,7 +58,7 @@ public:
// In auto exporting mode, highest possible settings will be chosen and no UI dialogs will be shown.
void SetAutoExportMode(bool bAuto) { m_bAutoExportMode = bAuto; }
bool Export(unsigned int flags = 0, EEndian eExportEndian = GetPlatformEndian(), const char* subdirectory = 0);
bool Export(unsigned int flags = 0, EEndian eExportEndian = eEndianness_Little, const char* subdirectory = 0);
static CGameExporter* GetCurrentExporter() { return m_pCurrentExporter; }
@@ -116,5 +112,3 @@ void SetupTerrainInfo(const size_t octreeCompiledDataSize, Func&& setupTerrainFn
setupTerrainFn(octreeCompiledDataSize);
}
}
#endif // CRYINCLUDE_EDITOR_GAMEEXPORTER_H
-1
View File
@@ -701,7 +701,6 @@ struct IEditor
virtual CUIEnumsDatabase* GetUIEnumsDatabase() = 0;
virtual void AddUIEnums() = 0;
virtual void GetMemoryUsage(ICrySizer* pSizer) = 0;
virtual void ReduceMemory() = 0;
//! Export manager for exporting objects and a terrain from the game to DCC tools
+2 -14
View File
@@ -680,8 +680,8 @@ const SGizmoParameters& CEditorImpl::GetGlobalGizmoParameters()
m_pGizmoParameters->axisConstraint = m_selectedAxis;
m_pGizmoParameters->referenceCoordSys = m_refCoordsSys;
m_pGizmoParameters->axisGizmoScale = gSettings.gizmo.axisGizmoSize;
m_pGizmoParameters->axisGizmoText = gSettings.gizmo.axisGizmoText;
m_pGizmoParameters->axisGizmoScale = 1.0f;
m_pGizmoParameters->axisGizmoText = false;
return *m_pGizmoParameters;
}
@@ -1506,18 +1506,6 @@ void CEditorImpl::ShowStatusText(bool bEnable)
m_bShowStatusText = bEnable;
}
void CEditorImpl::GetMemoryUsage(ICrySizer* pSizer)
{
SIZER_COMPONENT_NAME(pSizer, "Editor");
if (GetDocument())
{
SIZER_COMPONENT_NAME(pSizer, "Document");
GetDocument()->GetMemoryUsage(pSizer);
}
}
void CEditorImpl::ReduceMemory()
{
GetIEditor()->GetUndoManager()->ClearRedoStack();
-1
View File
@@ -280,7 +280,6 @@ public:
void SetMatEditMode(bool bIsMatEditMode);
CUIEnumsDatabase* GetUIEnumsDatabase() { return m_pUIEnumsDatabase; };
void AddUIEnums();
void GetMemoryUsage(ICrySizer* pSizer);
void ReduceMemory();
// Get Export manager
IExportManager* GetExportManager();
+1 -4
View File
@@ -64,10 +64,7 @@ void CIconManager::Reset()
int i;
for (i = 0; i < sizeof(m_objects) / sizeof(m_objects[0]); i++)
{
if (m_objects[i])
{
m_objects[i]->Release();
}
delete m_objects[i];
m_objects[i] = nullptr;
}
for (i = 0; i < eIcon_COUNT; i++)
+6 -7
View File
@@ -24,16 +24,15 @@ inline AZStd::string ToString(const QString& s)
class CCommand
{
static inline bool FromString(int32 &val, const char* s) {
if(!s)
static inline bool FromString(int32& val, const char* s)
{
if (!s)
{
return false;
}
val = (int)strtol(s, nullptr, 10);
if(val==0 && errno!=0) {
return false;
}
return true;
val = static_cast<int>(strtol(s, nullptr, 10));
const bool parsing_error = val == 0 && errno != 0;
return !parsing_error;
}
public:
CCommand(
+1 -1
View File
@@ -15,6 +15,6 @@ struct IEditorMaterial
: public CBaseLibraryItem
{
virtual int GetFlags() const = 0;
virtual _smart_ptr<IMaterial> GetMatInfo(bool bUseExistingEngineMaterial = false) = 0;
virtual IMaterial* GetMatInfo(bool bUseExistingEngineMaterial = false) = 0;
virtual void DisableHighlightForFrame() = 0;
};
+1 -1
View File
@@ -19,7 +19,7 @@
struct IEditorMaterialManager
{
virtual void GotoMaterial(_smart_ptr<IMaterial> pMaterial) = 0;
virtual void GotoMaterial(IMaterial* pMaterial) = 0;
};
#endif // CRYINCLUDE_EDITOR_MATERIAL_MATERIALMANAGER_H
+1 -14
View File
@@ -9,23 +9,18 @@
// Description : Class that collects error reports to present them later.
#ifndef CRYINCLUDE_EDITOR_INTERFACE_ERRORREPORT_H
#define CRYINCLUDE_EDITOR_INTERFACE_ERRORREPORT_H
#pragma once
#include <IValidator.h>
// forward declarations.
class CParticleItem;
class CBaseObject;
class CBaseLibraryItem;
class CErrorRecord;
class QString;
/*! Error report manages collection of errors occurred during map analyzes or level load.
*/
struct IErrorReport
: public IValidator
{
virtual ~IErrorReport(){}
@@ -62,12 +57,4 @@ struct IErrorReport
//! Assign current filename.
virtual void SetCurrentFile(const QString& file) = 0;
//////////////////////////////////////////////////////////////////////////
// Implement IValidator interface.
//////////////////////////////////////////////////////////////////////////
virtual void Report(SValidatorRecord& record) = 0;
};
#endif // CRYINCLUDE_EDITOR_ERRORREPORT_H
-1
View File
@@ -89,7 +89,6 @@ public:
//! Get array of objects, managed by manager (not contain sub objects of groups).
//! @param layer if 0 get objects for all layers, or layer to get objects from.
virtual void GetObjects(CBaseObjectsArray& objects) const = 0;
//virtual void GetObjects(DynArray<CBaseObject*>& objects) const = 0;
//! Get array of objects that pass the filter.
//! @param filter The filter functor, return true if you want to get the certain obj, return false if want to skip it.
-1
View File
@@ -170,7 +170,6 @@ public:
MOCK_METHOD0(IsSourceControlConnected, bool());
MOCK_METHOD0(GetUIEnumsDatabase, CUIEnumsDatabase* ());
MOCK_METHOD0(AddUIEnums, void());
MOCK_METHOD1(GetMemoryUsage, void(ICrySizer* ));
MOCK_METHOD0(ReduceMemory, void());
MOCK_METHOD0(GetExportManager, IExportManager* ());
MOCK_METHOD2(SetEditorConfigSpec, void(ESystemConfigSpec , ESystemConfigPlatform ));
+3 -3
View File
@@ -67,7 +67,7 @@ SANDBOX_API void ErrorV(const char* format, va_list argList)
str += szBuffer;
//CLogFile::WriteLine( str );
CryWarning(VALIDATOR_MODULE_EDITOR, VALIDATOR_ERROR, str.toUtf8().data());
CryWarning(VALIDATOR_MODULE_EDITOR, VALIDATOR_ERROR, "%s", str.toUtf8().data());
if (!CCryEditApp::instance()->IsInTestMode() && !CCryEditApp::instance()->IsInExportMode() && !CCryEditApp::instance()->IsInLevelLoadTestMode())
{
@@ -95,7 +95,7 @@ SANDBOX_API void WarningV(const char* format, va_list argList)
char szBuffer[MAX_LOGBUFFER_SIZE];
azvsnprintf(szBuffer, MAX_LOGBUFFER_SIZE, format, argList);
CryWarning(VALIDATOR_MODULE_EDITOR, VALIDATOR_WARNING, szBuffer);
CryWarning(VALIDATOR_MODULE_EDITOR, VALIDATOR_WARNING, "%s", szBuffer);
bool bNoUI = false;
ICVar* pCVar = gEnv->pConsole->GetCVar("sys_no_crash_dialog");
@@ -478,7 +478,7 @@ void CLogFile::WriteString(const char* pszString)
{
if (gEnv && gEnv->pLog)
{
gEnv->pLog->LogPlus(pszString);
gEnv->pLog->LogPlus("%s", pszString);
}
}
+2 -2
View File
@@ -2735,7 +2735,7 @@ bool CBaseObject::IntersectRayMesh(const Vec3& raySrc, const Vec3& rayDir, SRayH
return false;
}
Matrix34A worldTM;
Matrix34 worldTM;
IStatObj* pStatObj = pRenderNode->GetEntityStatObj(0, 0, &worldTM);
if (!pStatObj)
{
@@ -2743,7 +2743,7 @@ bool CBaseObject::IntersectRayMesh(const Vec3& raySrc, const Vec3& rayDir, SRayH
}
// transform decal into object space
Matrix34A worldTM_Inverted = worldTM.GetInverted();
Matrix34 worldTM_Inverted = worldTM.GetInverted();
Matrix33 worldRot(worldTM_Inverted);
worldRot.Transpose();
// put hit direction into the object space
+2 -13
View File
@@ -709,7 +709,7 @@ void CObjectManager::ShowDuplicationMsgWarning(CBaseObject* obj, const QString&
);
// If id is taken.
CryWarning(VALIDATOR_MODULE_EDITOR, VALIDATOR_WARNING, sRenameWarning.toUtf8().data());
CryWarning(VALIDATOR_MODULE_EDITOR, VALIDATOR_WARNING, "%s", sRenameWarning.toUtf8().data());
if (bShowMsgBox)
{
@@ -759,17 +759,6 @@ void CObjectManager::GetObjects(CBaseObjectsArray& objects) const
}
}
//void CObjectManager::GetObjects(DynArray<CBaseObject*>& objects) const
//{
// CBaseObjectsArray objectArray;
// GetObjects(objectArray);
// objects.clear();
// for (size_t i = 0, iCount(objectArray.size()); i < iCount; ++i)
// {
// objects.push_back(objectArray[i]);
// }
//}
void CObjectManager::GetObjects(CBaseObjectsArray& objects, BaseObjectFilterFunctor const& filter) const
{
objects.clear();
@@ -2378,7 +2367,7 @@ void CObjectManager::SetObjectSelected(CBaseObject* pObject, bool bSelect)
if (bSelect && !GetIEditor()->GetTransformManipulator())
{
if (CAxisGizmo::GetGlobalAxisGizmoCount() < gSettings.gizmo.axisGizmoMaxCount)
if (CAxisGizmo::GetGlobalAxisGizmoCount() < 1 /*legacy axisGizmoMaxCount*/)
{
// Create axis gizmo for this object.
m_gizmoManager->AddGizmo(new CAxisGizmo(pObject));
-1
View File
@@ -122,7 +122,6 @@ public:
//! Get array of objects, managed by manager (not contain sub objects of groups).
//! @param layer if 0 get objects for all layers, or layer to get objects from.
void GetObjects(CBaseObjectsArray& objects) const;
//void GetObjects(DynArray<CBaseObject*>& objects) const;
//! Get array of objects that pass the filter.
//! @param filter The filter functor, return true if you want to get the certain obj, return false if want to skip it.
@@ -37,7 +37,6 @@
#include <AzToolsFramework/ToolsComponents/EditorEntityIconComponentBus.h>
#include <AzToolsFramework/Undo/UndoCacheInterface.h>
#include <LmbrCentral/Rendering/RenderNodeBus.h>
#include <LmbrCentral/Rendering/MaterialOwnerBus.h>
#include <IDisplayViewport.h>
#include <CryCommon/Cry_GeoIntersect.h>
+1 -5
View File
@@ -24,11 +24,7 @@ PLUGIN_API IPlugin* CreatePluginInstance(PLUGIN_INIT_PARAM* pInitParam)
// Make sure the ffmpeg command can be executed before registering the command
if (!CFFMPEGPlugin::RuntimeTest())
{
AZStd::string msg =
"FFMPEG plugin: Failed to execute FFmepg. Please run Setup Assistant, "
"go to the 'Optional software' section of the 'Install software' tab, "
"and make sure the FFmpeg executable is correctly configured.";
GetIEditor()->GetSystem()->GetILog()->Log(msg.c_str());
GetIEditor()->GetSystem()->GetILog()->Log("FFMPEG plugin: Failed to execute FFmpeg. Please install FFmpeg.");
}
else
{
+4 -4
View File
@@ -17,8 +17,8 @@
#include "EditorPreferencesPageGeneral.h"
#include "EditorPreferencesPageFiles.h"
#include "EditorPreferencesPageViewportGeneral.h"
#include "EditorPreferencesPageViewportGizmo.h"
#include "EditorPreferencesPageViewportMovement.h"
#include "EditorPreferencesPageViewportManipulator.h"
#include "EditorPreferencesPageViewportCamera.h"
#include "EditorPreferencesPageViewportDebug.h"
#include "EditorPreferencesPageExperimentalLighting.h"
#include "EditorPreferencesPageAWS.h"
@@ -35,8 +35,8 @@ CStdPreferencesClassDesc::CStdPreferencesClassDesc()
[](){ return new CEditorPreferencesPage_General(); },
[](){ return new CEditorPreferencesPage_Files(); },
[](){ return new CEditorPreferencesPage_ViewportGeneral(); },
[](){ return new CEditorPreferencesPage_ViewportMovement(); },
[](){ return new CEditorPreferencesPage_ViewportGizmo(); },
[](){ return new CEditorPreferencesPage_ViewportCamera(); },
[](){ return new CEditorPreferencesPage_ViewportManipulator(); },
[](){ return new CEditorPreferencesPage_ViewportDebug(); }
};
+1 -1
View File
@@ -313,7 +313,7 @@ namespace
{
if (strcmp(pMessage, "") != 0)
{
CryLogAlways(pMessage);
CryLogAlways("%s", pMessage);
}
}
-37
View File
@@ -82,7 +82,6 @@ private:
namespace
{
class QtApplicationListener
: public AzToolsFramework::EditorEvents::Bus::Handler
{
@@ -99,20 +98,8 @@ namespace
delete this;
}
};
}
//////////////////////////////////////////////////////////////////////////
SGizmoSettings::SGizmoSettings()
{
axisGizmoSize = 0.2f;
axisGizmoText = true;
axisGizmoMaxCount = 50;
helpersScale = 1.f;
tagpointScaleMulti = 0.5f;
rulerSphereScale = 0.5f;
rulerSphereTrans = 0.5f;
}
//////////////////////////////////////////////////////////////////////////
SEditorSettings::SEditorSettings()
{
@@ -565,18 +552,6 @@ void SEditorSettings::Save()
SaveValue("Settings", "ShowScaleWarnings", viewports.bShowScaleWarnings);
SaveValue("Settings", "ShowRotationWarnings", viewports.bShowRotationWarnings);
//////////////////////////////////////////////////////////////////////////
// Gizmos.
//////////////////////////////////////////////////////////////////////////
SaveValue("Settings", "AxisGizmoSize", gizmo.axisGizmoSize);
SaveValue("Settings", "AxisGizmoText", gizmo.axisGizmoText);
SaveValue("Settings", "AxisGizmoMaxCount", gizmo.axisGizmoMaxCount);
SaveValue("Settings", "HelpersScale", gizmo.helpersScale);
SaveValue("Settings", "TagPointScaleMulti", gizmo.tagpointScaleMulti);
SaveValue("Settings", "RulerSphereScale", gizmo.rulerSphereScale);
SaveValue("Settings", "RulerSphereTrans", gizmo.rulerSphereTrans);
//////////////////////////////////////////////////////////////////////////
SaveValue("Settings", "TextEditorScript", textEditorForScript);
SaveValue("Settings", "TextEditorShaders", textEditorForShaders);
SaveValue("Settings", "TextEditorBSpaces", textEditorForBspaces);
@@ -778,18 +753,6 @@ void SEditorSettings::Load()
LoadValue("Settings", "ShowScaleWarnings", viewports.bShowScaleWarnings);
LoadValue("Settings", "ShowRotationWarnings", viewports.bShowRotationWarnings);
//////////////////////////////////////////////////////////////////////////
// Gizmos.
//////////////////////////////////////////////////////////////////////////
LoadValue("Settings", "AxisGizmoSize", gizmo.axisGizmoSize);
LoadValue("Settings", "AxisGizmoText", gizmo.axisGizmoText);
LoadValue("Settings", "AxisGizmoMaxCount", gizmo.axisGizmoMaxCount);
LoadValue("Settings", "HelpersScale", gizmo.helpersScale);
LoadValue("Settings", "TagPointScaleMulti", gizmo.tagpointScaleMulti);
LoadValue("Settings", "RulerSphereScale", gizmo.rulerSphereScale);
LoadValue("Settings", "RulerSphereTrans", gizmo.rulerSphereTrans);
//////////////////////////////////////////////////////////////////////////
LoadValue("Settings", "TextEditorScript", textEditorForScript);
LoadValue("Settings", "TextEditorShaders", textEditorForShaders);
LoadValue("Settings", "TextEditorBSpaces", textEditorForBspaces);
-18
View File
@@ -23,22 +23,6 @@
#include <AzQtComponents/Components/Widgets/ToolBar.h>
struct SGizmoSettings
{
float axisGizmoSize;
bool axisGizmoText;
int axisGizmoMaxCount;
float helpersScale;
float tagpointScaleMulti;
// Scale size and transparency for debug spheres when using Ruler tool
float rulerSphereScale;
float rulerSphereTrans;
SGizmoSettings();
};
//////////////////////////////////////////////////////////////////////////
// Settings for snapping in the viewports.
//////////////////////////////////////////////////////////////////////////
@@ -387,8 +371,6 @@ AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
//! Keeps the editor active even if no focus is set
int keepEditorActive;
SGizmoSettings gizmo;
// Settings of the snapping.
SSnapSettings snap;
@@ -719,8 +719,7 @@ bool CSequenceBatchRenderDialog::GetResolutionFromCustomResText(const char* cust
int scannedWidth = retCustomWidth; // initialize with default fall-back values - they'll be overwritten in the case of a succesful sscanf below.
int scannedHeight = retCustomHeight;
QString strFormat = QString::fromLatin1(customResFormat).replace(QRegularExpression(QStringLiteral("%\\d")), QStringLiteral("%d"));
scanSuccess = (azsscanf(customResText, strFormat.toStdString().c_str(), &scannedWidth, &scannedHeight) == 2);
scanSuccess = (azsscanf(customResText, "Custom(%d x %d)...", &scannedWidth, &scannedHeight) == 2);
if (scanSuccess)
{
retCustomWidth = scannedWidth;
-36
View File
@@ -62,17 +62,6 @@ public:
}
}
// to get memory statistics
void GetMemoryUsage(ICrySizer* pSizer)
{
for (int i = 0; i < m_undoSteps.size(); i++)
{
m_undoSteps[i]->GetMemoryUsage(pSizer);
}
pSizer->Add(*this);
}
private:
//! Undo steps included in this step.
std::vector<CUndoStep*> m_undoSteps;
@@ -746,31 +735,6 @@ int CUndoManager::GetMaxUndoStep() const
return GetIEditor()->GetEditorSettings()->undoLevels;
}
void CUndoManager::GetMemoryUsage(ICrySizer* pSizer)
{
if (m_currentUndo)
{
m_currentUndo->GetMemoryUsage(pSizer);
}
if (m_superUndo)
{
m_superUndo->GetMemoryUsage(pSizer);
}
for (std::list<CUndoStep*>::const_iterator it = m_undoStack.begin(); it != m_undoStack.end(); it++)
{
(*it)->GetMemoryUsage(pSizer);
}
for (std::list<CUndoStep*>::const_iterator it = m_redoStack.begin(); it != m_redoStack.end(); it++)
{
(*it)->GetMemoryUsage(pSizer);
}
pSizer->Add(*this);
}
void CUndoManager::AddListener(IUndoManagerListener* pListener)
{
stl::push_back_unique(m_listeners, pListener);
+1 -18
View File
@@ -12,9 +12,9 @@
#pragma once
#include "IUndoManagerListener.h"
#include "CrySizer.h" // ICrySizer
#include "IUndoObject.h"
#include <AzCore/Asset/AssetManager.h>
#include <CryCommon/StlUtils.h>
struct IUndoObject;
class CSuperUndoStep;
@@ -79,20 +79,6 @@ public:
}
}
// to get memory statistics
void GetMemoryUsage(ICrySizer* pSizer)
{
size_t nThisSize = sizeof(*this);
for (int i = 0; i < m_undoObjects.size(); i++)
{
nThisSize += m_undoObjects[i]->GetSize();
}
pSizer->Add(m_name);
pSizer->Add(this, nThisSize);
}
// get undo object at index i
IUndoObject* GetUndoObject(int i = 0)
{
@@ -241,9 +227,6 @@ public:
void ClearUndoStack(int num);
void ClearRedoStack(int num);
// to get memory statistics
void GetMemoryUsage(ICrySizer* pSizer);
void AddListener(IUndoManagerListener* pListener);
void RemoveListener(IUndoManagerListener* pListener);
-3
View File
@@ -20,9 +20,6 @@
#include <Cry_Color.h>
#include <CryCommon/ISystem.h>
//! Typedef for quaternion.
//typedef CryQuat Quat;
#include <QColor>
#include <QDataStream>
#include <QGuiApplication>
+1 -1
View File
@@ -52,7 +52,7 @@ bool CImageASC::Save(const QString& fileName, const CFloatImage& image)
}
// First print the file header
fprintf(file, fileHeader.c_str());
fprintf(file, "%s", fileHeader.c_str());
// Then print all the pixels.
for (uint32 y = 0; y < height; y++)
+1 -1
View File
@@ -103,7 +103,7 @@ bool CImageUtil::SavePGM(const QString& fileName, const CImageEx& image)
}
// First print the file header
fprintf(file, fileHeader.c_str());
fprintf(file, "%s", fileHeader.c_str());
// Then print all the pixels.
for (uint32 y = 0; y < height; y++)
+1 -1
View File
@@ -37,7 +37,7 @@ public:
struct SStatObj
{
Matrix34 tm;
_smart_ptr<IStatObj> pStatObj;
IStatObj* pStatObj;
};
private:
+1 -1
View File
@@ -78,7 +78,7 @@ bool CMemoryBlock::Allocate(int size, int uncompressedSize)
{
QString str;
str = QStringLiteral("CMemoryBlock::Allocate failed to allocate %1Mb of Memory").arg(size / (1024 * 1024));
CryLogAlways(str.toUtf8().data());
CryLogAlways("%s", str.toUtf8().data());
QMessageBox::critical(QApplication::activeWindow(), QString(), str + QString("\r\nSandbox will try to reduce its working memory set to free memory for this allocation."));
GetIEditor()->ReduceMemory();
+2 -3
View File
@@ -1092,9 +1092,8 @@ bool QtViewport::HitTest(const QPoint& point, HitContext& hitInfo)
const int viewportId = GetViewportId();
AzToolsFramework::EntityIdList visibleEntityIds;
AzToolsFramework::ViewportInteraction::MainEditorViewportInteractionRequestBus::Event(
viewportId,
&AzToolsFramework::ViewportInteraction::MainEditorViewportInteractionRequests::FindVisibleEntities,
AzToolsFramework::ViewportInteraction::EditorEntityViewportInteractionRequestBus::Event(
viewportId, &AzToolsFramework::ViewportInteraction::EditorEntityViewportInteractionRequestBus::Events::FindVisibleEntities,
visibleEntityIds);
// Look through all visible entities to find the closest one to the specified mouse point
+4 -4
View File
@@ -554,10 +554,10 @@ set(FILES
EditorPreferencesPageFiles.cpp
EditorPreferencesPageViewportGeneral.h
EditorPreferencesPageViewportGeneral.cpp
EditorPreferencesPageViewportGizmo.h
EditorPreferencesPageViewportGizmo.cpp
EditorPreferencesPageViewportMovement.h
EditorPreferencesPageViewportMovement.cpp
EditorPreferencesPageViewportManipulator.h
EditorPreferencesPageViewportManipulator.cpp
EditorPreferencesPageViewportCamera.h
EditorPreferencesPageViewportCamera.cpp
EditorPreferencesPageViewportDebug.h
EditorPreferencesPageViewportDebug.cpp
EditorPreferencesPageExperimentalLighting.h
+1 -1
View File
@@ -278,7 +278,7 @@ namespace AZ
#define AZ_Printf(window, ...) AZ::Debug::Trace::Instance().Printf(window, __VA_ARGS__);
#if !defined(RELEASE) || defined(PERFORMANCE_BUILD)
#if !defined(RELEASE)
// Unconditional critical error log, enabled up to Performance config
#define AZ_Fatal(window, format, ...) AZ::Debug::Trace::Instance().Printf(window, "[FATAL] " format "\n", ##__VA_ARGS__);
#define AZ_Crash() AZ::Debug::Trace::Instance().Crash();
@@ -628,7 +628,7 @@ int AZ::Intersect::IntersectRayCappedCylinder(
int AZ::Intersect::IntersectRayCone(
const Vector3& rayOrigin, const Vector3& rayDir,
const Vector3& coneApex, const Vector3& coneDir, float coneHeight,
float coneBaseRaidus, float& t1, float& t2)
float coneBaseRadius, float& t1, float& t2)
{
// Q = rayOrgin, A = coneApex
Vector3 AQ = rayOrigin - coneApex;
@@ -646,7 +646,7 @@ int AZ::Intersect::IntersectRayCone(
return 0;
}
float r2 = coneBaseRaidus * coneBaseRaidus;
float r2 = coneBaseRadius * coneBaseRadius;
float h2 = coneHeight * coneHeight;
float m2 = m * m;
@@ -240,7 +240,7 @@ namespace AZ
//! @return The number of intersecting points.
int IntersectRayCone(
const Vector3& rayOrigin, const Vector3& rayDir,
const Vector3& coneApex, const Vector3& coneDir, float coneHeight, float coneBaseRaidus,
const Vector3& coneApex, const Vector3& coneDir, float coneHeight, float coneBaseRadius,
float& t1, float& t2);
//! Test intersection between a ray and a plane in 3D.
@@ -1290,13 +1290,13 @@ namespace AZ
const EventArray& GetEvents() const;
#if defined(PERFORMANCE_BUILD) || !defined(_RELEASE) // m_scriptPath is only available in non-Release mode
#if !defined(_RELEASE) // m_scriptPath is only available in non-Release mode
AZStd::string m_scriptPath;
#endif
AZStd::string GetScriptPath() const
{
#if defined(PERFORMANCE_BUILD) || !defined(_RELEASE) // m_scriptPath is only available in non-Release mode
#if !defined(_RELEASE) // m_scriptPath is only available in non-Release mode
return m_scriptPath;
#else
return{};
@@ -1305,7 +1305,7 @@ namespace AZ
void SetScriptPath(const char* scriptPath)
{
#if defined(PERFORMANCE_BUILD) || !defined(_RELEASE) // m_scriptPath is only available in non-Release mode
#if !defined(_RELEASE) // m_scriptPath is only available in non-Release mode
m_scriptPath = scriptPath;
#else
AZ_UNUSED(scriptPath);
@@ -3727,7 +3727,7 @@ LUA_API const Node* lua_getDummyNode()
if (m_handler)
{
#if defined(PERFORMANCE_BUILD) || !defined(_RELEASE)
#if !defined(_RELEASE)
const AZStd::string_view luaString("Lua");
lua_Debug info;
for (int level = 0; lua_getstack(m_lua, level, &info); ++level)
@@ -3739,7 +3739,7 @@ LUA_API const Node* lua_getDummyNode()
break;
}
}
#endif//defined(PERFORMANCE_BUILD) || !defined(_RELEASE)
#endif
BindEvents(scriptTable);
+6 -7
View File
@@ -12,10 +12,12 @@
ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME})
ly_get_list_relative_pal_filename(common_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/Common)
if(PAL_TRAIT_PROF_PIX_SUPPORTED AND LY_PIX_ENABLED)
set(LY_PIX_PATH "${LY_3RDPARTY_PATH}/winpixeventruntime" CACHE PATH "Path to the Windows Pix Event Runtime.")
set(AZ_CORE_PIX_BUILD_DEPENDENCIES 3rdParty::pix)
set(AZ_CORE_PIX_BUILD_DEFINES "USE_PIX")
if(PAL_TRAIT_PROF_PIX_SUPPORTED)
set(LY_PIX_ENABLED OFF CACHE BOOL "Enables PIX profiler integration.")
if(LY_PIX_ENABLED)
message(STATUS "PIX found, enabling as profiler")
set(AZ_CORE_PIX_BUILD_DEPENDENCIES 3rdParty::pix)
endif()
endif()
ly_add_target(
@@ -41,9 +43,6 @@ ly_add_target(
3rdParty::zstd
3rdParty::cityhash
${AZ_CORE_PIX_BUILD_DEPENDENCIES}
COMPILE_DEFINITIONS
PUBLIC
${AZ_CORE_PIX_BUILD_DEFINES}
)
ly_add_source_properties(
SOURCES
@@ -18,7 +18,7 @@ namespace AZ
{
void OutputToDebugger([[maybe_unused]] const char* window, [[maybe_unused]] const char* message)
{
__android_log_print(ANDROID_LOG_INFO, window, message);
__android_log_print(ANDROID_LOG_INFO, window, "%s", message);
}
}
}
@@ -609,6 +609,21 @@ namespace UnitTest
EXPECT_EQ(hits, 0);
}
// replicates a scenario in the Editor using a cone and a pick ray which should have failed but passed
// note: To replicate this, select an entity so the default translation manipulator appears, move very close to the
// entity, hover the mouse over one of the manipulator linear manipulator arrows (cone part) and move the mouse away
// notice the manipulator will remain highlighted as a successful intersection is still reported
TEST(MATH_IntersectRayConeTestEditor, DISABLED_RayConeEditorScenarioTest)
{
auto rayOrigin = Vector3(0.0f, -0.808944702f, 0.0f);
auto rayDir = Vector3(0.301363617f, 0.939044654f, 0.165454566f);
float t1 = 0.0f;
float t2 = 0.0f;
int hits = Intersect::IntersectRayCone(
rayOrigin, rayDir, AZ::Vector3(0.0f, 0.0f, 0.161788940f), AZ::Vector3(0.0f, 0.0f, -1.0f), 0.0453009047, 0.0113252262, t1, t2);
EXPECT_EQ(hits, 0);
}
class MATH_IntersectRayQuadTest
: public AllocatorsFixture
{
@@ -987,7 +987,7 @@ namespace AzFramework
void AssetCatalog::AddCatalogEntry(AZStd::shared_ptr<AzFramework::AssetRegistry> deltaCatalog)
{
AZStd::lock_guard<AZStd::recursive_mutex> lock(m_deltaCatalogMutex);
#if defined(PERFORMANCE_BUILD) || !defined(_RELEASE)
#if !defined(_RELEASE)
for (const auto& thisElement : m_deltaCatalogList)
{
if (thisElement == deltaCatalog)
@@ -1010,7 +1010,7 @@ namespace AzFramework
AZ_Warning("AssetCatalog", false, "Catalog name %p can't be inserted at slot %u", deltaCatalog.get(), catalogIndex);
return;
}
#if defined(PERFORMANCE_BUILD) || !defined(_RELEASE)
#if !defined(_RELEASE)
for (const auto& thisElement : m_deltaCatalogList)
{
if (thisElement == deltaCatalog)
@@ -14,6 +14,7 @@
#include <AzCore/Math/Vector2.h>
#include <AzCore/Math/Vector3.h>
#include <AzCore/Math/Vector4.h>
#include <AzCore/Math/Matrix3x4.h>
#include <AzCore/Math/Color.h>
#include <AzCore/Math/Transform.h>
#include <AzCore/Component/ComponentBus.h>
@@ -100,6 +101,8 @@ namespace AzFramework
virtual AZ::u32 SetState(AZ::u32 state) { (void)state; return 0; }
virtual void PushMatrix(const AZ::Transform& tm) { (void)tm; }
virtual void PopMatrix() {}
virtual void PushPremultipliedMatrix(const AZ::Matrix3x4& matrix) { (void)matrix; }
virtual AZ::Matrix3x4 PopPremultipliedMatrix() { return AZ::Matrix3x4::CreateIdentity(); }
protected:
~DebugDisplayRequests() = default;
@@ -311,7 +311,6 @@ namespace AzFramework
// On some platforms, threadid is just a number but on other platforms it is a pointer of some kind
// uintptr_t will ensure that the data will always fit
uintptr_t threadID = threadId ? threadId : (uintptr_t)(AZStd::this_thread::get_id().m_id);
const char* printFormatter = m_machineReadable ? "~~%p~~%s~~" : "{%p}[%14s]";
// while it may be tempting to check the fileio Pointer here, any emit of any warning or error would be fatal
// since we're already logging, and we don't want to log while you log.
@@ -331,7 +330,14 @@ namespace AzFramework
azsnprintf(buffer, 80, "~~%llu~~%i", rawTime, severity);
m_fileIO->Write(m_fileHandle, buffer, strlen(buffer));
azsnprintf(buffer, 80, printFormatter, threadID, categoryActual);
if (m_machineReadable) // Branching instead of using a ternary on the format string to avoid warning 4774 (format literal expected)
{
azsnprintf(buffer, 80, "~~%p~~%s~~", reinterpret_cast<void*>(threadID), categoryActual);
}
else
{
azsnprintf(buffer, 80, "{%p}[%14s]", reinterpret_cast<void*>(threadID), categoryActual);
}
m_fileIO->Write(m_fileHandle, buffer, strlen(buffer));
m_fileIO->Write(m_fileHandle, dataSource, dataLength);
@@ -349,8 +355,14 @@ namespace AzFramework
{
return;
}
azsnprintf(categorybuffer, 64, printFormatter, threadID, categoryActual);
if (m_machineReadable) // Branching instead of using a ternary on the format string to avoid warning 4774 (format literal expected)
{
azsnprintf(categorybuffer, 64, "~~%p~~%s~~", reinterpret_cast<void*>(threadID), categoryActual);
}
else
{
azsnprintf(categorybuffer, 64, "{%p}[%14s]", reinterpret_cast<void*>(threadID), categoryActual);
}
if ((category) && (categoryLen))
{
@@ -588,6 +588,12 @@ namespace AzFramework
// pass through the camera's position and look vector for use in the lookAt function
if (const auto lookAt = lookAtFn(targetCamera.Translation(), targetCamera.Rotation().GetBasisY()))
{
// default to internal look at behavior if the look at point matches the camera translation
if (targetCamera.m_lookAt.IsClose(*lookAt))
{
return false;
}
auto transform = AZ::Transform::CreateLookAt(targetCamera.m_lookAt, *lookAt);
nextCamera.m_lookDist = -lookAt->GetDistance(targetCamera.m_lookAt);
UpdateCameraFromTransform(nextCamera, transform);
@@ -45,6 +45,7 @@ namespace AzFramework
protected:
~BoundsRequests() = default;
};
using BoundsRequestBus = AZ::EBus<BoundsRequests>;
//! Returns a union of all local Aabbs provided by components implementing the BoundsRequestBus.
@@ -6,6 +6,7 @@
*
*/
#include <AZTestShared/Math/MathTestHelpers.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h>
@@ -47,18 +48,17 @@ namespace UnitTest
m_firstPersonTranslateCamera =
AZStd::make_shared<AzFramework::TranslateCameraInput>(AzFramework::LookTranslation, m_translateCameraInputChannelIds);
auto orbitCamera =
AZStd::make_shared<AzFramework::OrbitCameraInput>(AzFramework::InputChannelId("keyboard_key_modifier_alt_l"));
m_orbitCamera = AZStd::make_shared<AzFramework::OrbitCameraInput>(m_orbitChannelId);
auto orbitRotateCamera = AZStd::make_shared<AzFramework::RotateCameraInput>(AzFramework::InputDeviceMouse::Button::Left);
auto orbitTranslateCamera =
AZStd::make_shared<AzFramework::TranslateCameraInput>(AzFramework::OrbitTranslation, m_translateCameraInputChannelIds);
orbitCamera->m_orbitCameras.AddCamera(orbitRotateCamera);
orbitCamera->m_orbitCameras.AddCamera(orbitTranslateCamera);
m_orbitCamera->m_orbitCameras.AddCamera(orbitRotateCamera);
m_orbitCamera->m_orbitCameras.AddCamera(orbitTranslateCamera);
m_cameraSystem->m_cameras.AddCamera(m_firstPersonRotateCamera);
m_cameraSystem->m_cameras.AddCamera(m_firstPersonTranslateCamera);
m_cameraSystem->m_cameras.AddCamera(orbitCamera);
m_cameraSystem->m_cameras.AddCamera(m_orbitCamera);
// these tests rely on using motion delta, not cursor positions (default is true)
AzFramework::ed_cameraSystemUseCursor = false;
@@ -68,6 +68,7 @@ namespace UnitTest
{
AzFramework::ed_cameraSystemUseCursor = true;
m_orbitCamera.reset();
m_firstPersonRotateCamera.reset();
m_firstPersonTranslateCamera.reset();
@@ -77,12 +78,14 @@ namespace UnitTest
AllocatorsTestFixture::TearDown();
}
AzFramework::InputChannelId m_orbitChannelId = AzFramework::InputChannelId("keyboard_key_modifier_alt_l");
AzFramework::TranslateCameraInputChannelIds m_translateCameraInputChannelIds;
AZStd::shared_ptr<AzFramework::RotateCameraInput> m_firstPersonRotateCamera;
AZStd::shared_ptr<AzFramework::TranslateCameraInput> m_firstPersonTranslateCamera;
AZStd::shared_ptr<AzFramework::OrbitCameraInput> m_orbitCamera;
};
TEST_F(CameraInputFixture, Begin_and_end_OrbitCameraInput_consumes_correct_events)
TEST_F(CameraInputFixture, BeginAndEndOrbitCameraInputConsumesCorrectEvents)
{
// begin orbit camera
const bool consumed1 = HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ AzFramework::InputDeviceKeyboard::Key::ModifierAltL,
@@ -102,7 +105,7 @@ namespace UnitTest
EXPECT_THAT(allConsumed, ElementsAre(true, false, true, false));
}
TEST_F(CameraInputFixture, Begin_CameraInput_notifies_ActivationBeganFn_for_TranslateCameraInput)
TEST_F(CameraInputFixture, BeginCameraInputNotifiesActivationBeganFnForTranslateCameraInput)
{
bool activationBegan = false;
m_firstPersonTranslateCamera->SetActivationBeganFn(
@@ -111,13 +114,13 @@ namespace UnitTest
activationBegan = true;
});
HandleEventAndUpdate(
AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId, AzFramework::InputChannel::State::Began });
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId,
AzFramework::InputChannel::State::Began });
EXPECT_TRUE(activationBegan);
}
TEST_F(CameraInputFixture, Begin_CameraInput_notifies_ActivationBeganFn_after_delta_for_RotateCameraInput)
TEST_F(CameraInputFixture, BeginCameraInputNotifiesActivationBeganFnAfterDeltaForRotateCameraInput)
{
bool activationBegan = false;
m_firstPersonRotateCamera->SetActivationBeganFn(
@@ -133,7 +136,7 @@ namespace UnitTest
EXPECT_TRUE(activationBegan);
}
TEST_F(CameraInputFixture, Begin_CameraInput_does_not_notify_ActivationBeganFn_with_no_delta_for_RotateCameraInput)
TEST_F(CameraInputFixture, BeginCameraInputDoesNotNotifyActivationBeganFnWithNoDeltaForRotateCameraInput)
{
bool activationBegan = false;
m_firstPersonRotateCamera->SetActivationBeganFn(
@@ -148,7 +151,7 @@ namespace UnitTest
EXPECT_FALSE(activationBegan);
}
TEST_F(CameraInputFixture, End_CameraInput_notifies_ActivationEndFn_after_delta_for_RotateCameraInput)
TEST_F(CameraInputFixture, EndCameraInputNotifiesActivationEndFnAfterDeltaForRotateCameraInput)
{
bool activationEnded = false;
m_firstPersonRotateCamera->SetActivationEndedFn(
@@ -166,7 +169,7 @@ namespace UnitTest
EXPECT_TRUE(activationEnded);
}
TEST_F(CameraInputFixture, End_CameraInput_does_not_notify_ActivationBeganFn_or_ActivationBeganFn_with_no_delta_for_RotateCameraInput)
TEST_F(CameraInputFixture, EndCameraInputDoesNotNotifyActivationBeganFnOrActivationBeganFnWithNoDeltaForRotateCameraInput)
{
bool activationBegan = false;
m_firstPersonRotateCamera->SetActivationBeganFn(
@@ -191,7 +194,7 @@ namespace UnitTest
EXPECT_FALSE(activationEnded);
}
TEST_F(CameraInputFixture, End_CameraInput_notifies_ActivationBeganFn_or_ActivationEndFn_with_TranslateCamera)
TEST_F(CameraInputFixture, End_CameraInputNotifiesActivationBeganFnOrActivationEndFnWithTranslateCamera)
{
bool activationBegan = false;
m_firstPersonTranslateCamera->SetActivationBeganFn(
@@ -207,16 +210,16 @@ namespace UnitTest
activationEnded = true;
});
HandleEventAndUpdate(
AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId, AzFramework::InputChannel::State::Began });
HandleEventAndUpdate(
AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId, AzFramework::InputChannel::State::Ended });
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId,
AzFramework::InputChannel::State::Began });
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId,
AzFramework::InputChannel::State::Ended });
EXPECT_TRUE(activationBegan);
EXPECT_TRUE(activationEnded);
}
TEST_F(CameraInputFixture, End_activation_called_for_CameraInput_if_active_when_cameras_are_cleared)
TEST_F(CameraInputFixture, EndActivationCalledForCameraInputIfActiveWhenCamerasAreCleared)
{
bool activationEnded = false;
m_firstPersonTranslateCamera->SetActivationEndedFn(
@@ -225,11 +228,37 @@ namespace UnitTest
activationEnded = true;
});
HandleEventAndUpdate(
AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId, AzFramework::InputChannel::State::Began });
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId,
AzFramework::InputChannel::State::Began });
m_cameraSystem->m_cameras.Clear();
EXPECT_TRUE(activationEnded);
}
TEST_F(CameraInputFixture, OrbitCameraInputHandlesLookAtPointAndSelfAtSamePositionWhenOrbiting)
{
// create pathological lookAtFn that just returns the same position as the camera
m_orbitCamera->SetLookAtFn(
[](const AZ::Vector3& position, [[maybe_unused]] const AZ::Vector3& direction)
{
return position;
});
AzFramework::UpdateCameraFromTransform(
m_targetCamera,
AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion::CreateFromEulerAnglesDegrees(AZ::Vector3(0.0f, 0.0f, 90.0f)), AZ::Vector3(10.0f, 10.0f, 10.0f)));
m_camera = m_targetCamera;
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_orbitChannelId, AzFramework::InputChannel::State::Began });
// verify the camera yaw has not changed and the look at point
// does not match that of the camera translation
using ::testing::Eq;
using ::testing::Not;
EXPECT_THAT(m_camera.m_yaw, Eq(AZ::DegToRad(90.0f)));
EXPECT_THAT(m_camera.m_lookAt, Not(IsClose(m_camera.Translation())));
}
} // namespace UnitTest
@@ -92,8 +92,7 @@ namespace AzManipulatorTestFramework
{
if (m_logging)
{
AZStd::string message = AZStd::string::format(format, args...);
AZ_Printf("[ActionDispatcher] %s", message.c_str());
AZ_Printf("ActionDispatcher", format, args...);
}
}
@@ -150,7 +149,7 @@ namespace AzManipulatorTestFramework
template <typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::MouseLButtonDown()
{
Log("Mouse left button down");
Log("%s", "Mouse left button down");
MouseLButtonDownImpl();
return static_cast<DerivedDispatcherT*>(this);
}
@@ -158,7 +157,7 @@ namespace AzManipulatorTestFramework
template <typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::MouseLButtonUp()
{
Log("Mouse left button up");
Log("%s", "Mouse left button up");
MouseLButtonUpImpl();
return static_cast<DerivedDispatcherT*>(this);
}
@@ -45,6 +45,9 @@ namespace AzManipulatorTestFramework
virtual void SetAngularStep(float step) = 0;
//! Get the viewport id.
virtual int GetViewportId() const = 0;
//! Updates the visibility state.
//! Updates which entities are currently visible given the current camera state.
virtual void UpdateVisibility() = 0;
};
//! This interface is used to simulate the manipulator manager while the manipulators are under test.
@@ -12,8 +12,8 @@
#include <AzManipulatorTestFramework/AzManipulatorTestFrameworkUtils.h>
#include <AzManipulatorTestFramework/ImmediateModeActionDispatcher.h>
#include <AzManipulatorTestFramework/IndirectManipulatorViewportInteraction.h>
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemViewportSelectionRequestBus.h>
#include <AzToolsFramework/ViewportSelection/EditorDefaultSelection.h>
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemViewportSelectionRequestBus.h>
#include <type_traits>
namespace UnitTest
@@ -21,20 +21,18 @@ namespace UnitTest
//! Fixture to provide the indirect call viewport interaction that is dependent on AzToolsFramework::ToolsApplication.
//! \tparam ToolsApplicationFixtureT The fixture that provides the AzToolsFramework::ToolsApplication functionality.
template<typename ToolsApplicationFixtureT>
class IndirectCallManipulatorViewportInteractionFixtureMixin
: public ToolsApplicationFixtureT
class IndirectCallManipulatorViewportInteractionFixtureMixin : public ToolsApplicationFixtureT
{
using IndirectCallManipulatorViewportInteraction =
AzManipulatorTestFramework::IndirectCallManipulatorViewportInteraction;
using IndirectCallManipulatorViewportInteraction = AzManipulatorTestFramework::IndirectCallManipulatorViewportInteraction;
using ImmediateModeActionDispatcher = AzManipulatorTestFramework::ImmediateModeActionDispatcher;
void SetUpEditorFixtureImpl() override
{
ToolsApplicationFixtureT::SetUpEditorFixtureImpl();
m_viewportManipulatorInteraction = AZStd::make_unique<IndirectCallManipulatorViewportInteraction>();
m_actionDispatcher = AZStd::make_unique<ImmediateModeActionDispatcher>(*m_viewportManipulatorInteraction);
m_cameraState = AzFramework::CreateIdentityDefaultCamera(
AZ::Vector3::CreateZero(), AzManipulatorTestFramework::DefaultViewportSize);
m_cameraState =
AzFramework::CreateIdentityDefaultCamera(AZ::Vector3::CreateZero(), AzManipulatorTestFramework::DefaultViewportSize);
}
void TearDownEditorFixtureImpl() override
@@ -9,8 +9,8 @@
#pragma once
#include <AzManipulatorTestFramework/AzManipulatorTestFramework.h>
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemViewportSelectionRequestBus.h>
#include <AzToolsFramework/ViewportSelection/EditorDefaultSelection.h>
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemViewportSelectionRequestBus.h>
namespace AzManipulatorTestFramework
{
@@ -18,13 +18,12 @@ namespace AzManipulatorTestFramework
class IndirectCallManipulatorManager;
//! Implementation of manipulator viewport interaction that manipulates the manager indirectly via bus calls.
class IndirectCallManipulatorViewportInteraction
: public ManipulatorViewportInteraction
class IndirectCallManipulatorViewportInteraction : public ManipulatorViewportInteraction
{
public:
IndirectCallManipulatorViewportInteraction();
~IndirectCallManipulatorViewportInteraction();
// ManipulatorViewportInteractionInterface ...
const ViewportInteractionInterface& GetViewportInteraction() const override;
const ManipulatorManagerInterface& GetManipulatorManager() const override;
@@ -8,6 +8,7 @@
#pragma once
#include <AzFramework/Visibility/EntityVisibilityQuery.h>
#include <AzManipulatorTestFramework/AzManipulatorTestFramework.h>
namespace AzManipulatorTestFramework
@@ -17,14 +18,15 @@ namespace AzManipulatorTestFramework
//! Implementation of the viewport interaction model to handle viewport interaction requests.
class ViewportInteraction
: public ViewportInteractionInterface
, private AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Handler
, public AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Handler
, public AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Handler
, private AzToolsFramework::ViewportInteraction::EditorEntityViewportInteractionRequestBus::Handler
{
public:
ViewportInteraction();
~ViewportInteraction();
// ViewportInteractionInterface ...
AzFramework::CameraState GetCameraState() override;
// ViewportInteractionInterface overrides ...
void SetCameraState(const AzFramework::CameraState& cameraState) override;
AzFramework::DebugDisplayRequests& GetDebugDisplay() override;
void EnableGridSnaping() override;
@@ -34,19 +36,30 @@ namespace AzManipulatorTestFramework
void SetGridSize(float size) override;
void SetAngularStep(float step) override;
int GetViewportId() const override;
void UpdateVisibility() override;
// ViewportInteractionRequestBus overrides ...
AzFramework::CameraState GetCameraState() override;
AzFramework::ScreenPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition);
AZStd::optional<AZ::Vector3> ViewportScreenToWorld(const AzFramework::ScreenPoint& screenPosition, float depth) override;
AZStd::optional<AzToolsFramework::ViewportInteraction::ProjectedViewportRay> ViewportScreenToWorldRay(
const AzFramework::ScreenPoint& screenPosition) override;
float DeviceScalingFactor() override;
// ViewportSettingsRequestBus overrides ...
bool GridSnappingEnabled() const override;
float GridSize() const override;
bool ShowGrid() const override;
bool AngleSnappingEnabled() const override;
float AngleStep() const override;
float ManipulatorLineBoundWidth() const override;
float ManipulatorCircleBoundWidth() const override;
// EditorEntityViewportInteractionRequestBus overrides ...
void FindVisibleEntities(AZStd::vector<AZ::EntityId>& visibleEntities) override;
private:
// ViewportInteractionRequestBus ...
bool GridSnappingEnabled();
float GridSize();
bool ShowGrid();
bool AngleSnappingEnabled();
float AngleStep();
AzFramework::ScreenPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition);
private:
AzFramework::EntityVisibilityQuery m_entityVisibilityQuery;
AZStd::unique_ptr<NullDebugDisplayRequests> m_nullDebugDisplayRequests;
const int m_viewportId = 1234; // Arbitrary viewport id for manipulator tests
AzFramework::CameraState m_cameraState;
@@ -91,12 +91,12 @@ namespace AzManipulatorTestFramework
AzToolsFramework::ViewportInteraction::MousePick BuildMousePick(
const AzFramework::ScreenPoint& screenPoint, const AzFramework::CameraState& cameraState)
{
const auto screenToWorld = AzFramework::ScreenToWorld(screenPoint, cameraState);
const auto nearPlaneWorldPosition = AzFramework::ScreenToWorld(screenPoint, cameraState);
AzToolsFramework::ViewportInteraction::MousePick mousePick;
mousePick.m_screenCoordinates = screenPoint;
mousePick.m_rayOrigin = screenToWorld;
mousePick.m_rayDirection = (screenToWorld - cameraState.m_position).GetNormalized();
mousePick.m_rayOrigin = cameraState.m_position;
mousePick.m_rayDirection = (nearPlaneWorldPosition - cameraState.m_position).GetNormalized();
return mousePick;
}
@@ -16,8 +16,7 @@ namespace AzManipulatorTestFramework
using MouseInteractionEvent = AzToolsFramework::ViewportInteraction::MouseInteractionEvent;
//! Implementation of the manipulator interface using bus calls to access to the manipulator manager.
class IndirectCallManipulatorManager
: public ManipulatorManagerInterface
class IndirectCallManipulatorManager : public ManipulatorManagerInterface
{
public:
IndirectCallManipulatorManager(ViewportInteractionInterface& viewportInteraction);
@@ -39,11 +38,12 @@ namespace AzManipulatorTestFramework
void IndirectCallManipulatorManager::ConsumeMouseInteractionEvent(const MouseInteractionEvent& event)
{
m_viewportInteraction.UpdateVisibility();
DrawManipulators();
AzToolsFramework::EditorInteractionSystemViewportSelectionRequestBus::Event(
AzToolsFramework::GetEntityContextId(),
&AzToolsFramework::ViewportInteraction::InternalMouseViewportRequests::InternalHandleAllMouseInteractions,
event);
&AzToolsFramework::ViewportInteraction::InternalMouseViewportRequests::InternalHandleAllMouseInteractions, event);
DrawManipulators();
}
@@ -24,7 +24,7 @@ namespace AzManipulatorTestFramework
{
const char* error = "Couldn't add action to sequence, dispatcher is locked (you must call ResetSequence() \
before adding actions to this dispatcher)";
Log(error);
Log("%s", error);
AZ_Assert(false, "Error: %s", error);
}
@@ -108,7 +108,7 @@ namespace AzManipulatorTestFramework
RetainedModeActionDispatcher* RetainedModeActionDispatcher::ResetSequence()
{
Log("Resetting the action sequence");
Log("%s", "Resetting the action sequence");
m_actions.clear();
m_dispatcher.ResetEvent();
m_locked = false;
@@ -25,10 +25,14 @@ namespace AzManipulatorTestFramework
: m_nullDebugDisplayRequests(AZStd::make_unique<NullDebugDisplayRequests>())
{
AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Handler::BusConnect(m_viewportId);
AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Handler::BusConnect(m_viewportId);
AzToolsFramework::ViewportInteraction::EditorEntityViewportInteractionRequestBus::Handler::BusConnect(m_viewportId);
}
ViewportInteraction::~ViewportInteraction()
{
AzToolsFramework::ViewportInteraction::EditorEntityViewportInteractionRequestBus::Handler::BusDisconnect();
AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Handler::BusDisconnect();
AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Handler::BusDisconnect();
}
@@ -37,31 +41,51 @@ namespace AzManipulatorTestFramework
return m_cameraState;
}
bool ViewportInteraction::GridSnappingEnabled()
bool ViewportInteraction::GridSnappingEnabled() const
{
return m_gridSnapping;
}
float ViewportInteraction::GridSize()
float ViewportInteraction::GridSize() const
{
return m_gridSize;
}
bool ViewportInteraction::ShowGrid()
bool ViewportInteraction::ShowGrid() const
{
return false;
}
bool ViewportInteraction::AngleSnappingEnabled()
bool ViewportInteraction::AngleSnappingEnabled() const
{
return m_angularSnapping;
}
float ViewportInteraction::AngleStep()
float ViewportInteraction::AngleStep() const
{
return m_angularStep;
}
float ViewportInteraction::ManipulatorLineBoundWidth() const
{
return 0.1f;
}
float ViewportInteraction::ManipulatorCircleBoundWidth() const
{
return 0.1f;
}
void ViewportInteraction::FindVisibleEntities(AZStd::vector<AZ::EntityId>& visibleEntitiesOut)
{
visibleEntitiesOut.assign(m_entityVisibilityQuery.Begin(), m_entityVisibilityQuery.End());
}
void ViewportInteraction::UpdateVisibility()
{
m_entityVisibilityQuery.UpdateVisibility(m_cameraState);
}
AzFramework::ScreenPoint ViewportInteraction::ViewportWorldToScreen(const AZ::Vector3& worldPosition)
{
return AzFramework::WorldToScreen(worldPosition, m_cameraState);
@@ -49,9 +49,9 @@ namespace UnitTest
bool snapping = false;
m_viewportInteraction->EnableGridSnaping();
AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::EventResult(
AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::EventResult(
snapping, m_viewportInteraction->GetViewportId(),
&AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Events::GridSnappingEnabled);
&AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Events::GridSnappingEnabled);
EXPECT_TRUE(snapping);
}
@@ -61,9 +61,9 @@ namespace UnitTest
bool snapping = true;
m_viewportInteraction->DisableGridSnaping();
AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::EventResult(
AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::EventResult(
snapping, m_viewportInteraction->GetViewportId(),
&AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Events::GridSnappingEnabled);
&AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Events::GridSnappingEnabled);
EXPECT_FALSE(snapping);
}
@@ -76,9 +76,9 @@ namespace UnitTest
m_viewportInteraction->SetGridSize(expectedGridSize);
m_viewportInteraction->DisableGridSnaping();
AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::EventResult(
AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::EventResult(
gridSize, m_viewportInteraction->GetViewportId(),
&AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Events::GridSize);
&AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Events::GridSize);
EXPECT_EQ(gridSize, expectedGridSize);
}
@@ -88,9 +88,9 @@ namespace UnitTest
bool snapping = false;
m_viewportInteraction->EnableAngularSnaping();
AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::EventResult(
AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::EventResult(
snapping, m_viewportInteraction->GetViewportId(),
&AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Events::AngleSnappingEnabled);
&AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Events::AngleSnappingEnabled);
EXPECT_TRUE(snapping);
}
@@ -100,9 +100,9 @@ namespace UnitTest
bool snapping = true;
m_viewportInteraction->DisableAngularSnaping();
AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::EventResult(
AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::EventResult(
snapping, m_viewportInteraction->GetViewportId(),
&AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Events::AngleSnappingEnabled);
&AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Events::AngleSnappingEnabled);
EXPECT_FALSE(snapping);
}
@@ -114,9 +114,9 @@ namespace UnitTest
m_viewportInteraction->SetAngularStep(expectedAngularStep);
AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::EventResult(
AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::EventResult(
angularStep, m_viewportInteraction->GetViewportId(),
&AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Events::AngleStep);
&AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Events::AngleStep);
EXPECT_EQ(angularStep, expectedAngularStep);
}
@@ -96,7 +96,7 @@ namespace AzToolsFramework
{
AZ::EBusReduceResult<AZ::Aabb, AzFramework::AabbUnionAggregator> aabbResult(AZ::Aabb::CreateNull());
EditorComponentSelectionRequestsBus::EventResult(
aabbResult, entityId, &EditorComponentSelectionRequests::GetEditorSelectionBoundsViewport, viewportInfo);
aabbResult, entityId, &EditorComponentSelectionRequestsBus::Events::GetEditorSelectionBoundsViewport, viewportInfo);
return aabbResult.value;
}
@@ -70,8 +70,12 @@ namespace AzToolsFramework
//! Determines if the caller needs to wait for the Python VM to initialize (non-main thread only)
virtual void WaitForInitialization() {}
//! Acquires the Python global interpreter lock (GIL) and executed the callback
//! Acquires the Python global interpreter lock (GIL) and execute the callback
virtual void ExecuteWithLock(AZStd::function<void()> executionCallback) = 0;
//! Tries to acquire the Python global interpreter lock (GIL) and execute the callback.
//! @return Whether it was able to lock the mutex or not.
virtual bool TryExecuteWithLock(AZStd::function<void()> executionCallback) = 0;
};
//! A bus to handle post notifications to the console views of Python output
@@ -226,6 +226,7 @@ namespace AzToolsFramework
m_translationManipulator = AZStd::make_shared<IndexedTranslationManipulator<Vertex>>(
Dimensions(), vertexIndex, vertex, WorldFromLocalWithUniformScale(entityComponentIdPair.GetEntityId()),
GetNonUniformScale(entityComponentIdPair.GetEntityId()));
m_translationManipulator->m_manipulator.SetLineBoundWidth(AzToolsFramework::ManipulatorLineBoundWidth());
// setup how the manipulator should look
m_manipulatorConfiguratorFn(&m_translationManipulator->m_manipulator);
@@ -137,8 +137,8 @@ namespace AzToolsFramework
bool GridSnapping(const int viewportId)
{
bool snapping = false;
ViewportInteraction::ViewportInteractionRequestBus::EventResult(
snapping, viewportId, &ViewportInteraction::ViewportInteractionRequestBus::Events::GridSnappingEnabled);
ViewportInteraction::ViewportSettingsRequestBus::EventResult(
snapping, viewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::GridSnappingEnabled);
return snapping;
}
@@ -146,8 +146,8 @@ namespace AzToolsFramework
float GridSize(const int viewportId)
{
float gridSize = 0.0f;
ViewportInteraction::ViewportInteractionRequestBus::EventResult(
gridSize, viewportId, &ViewportInteraction::ViewportInteractionRequestBus::Events::GridSize);
ViewportInteraction::ViewportSettingsRequestBus::EventResult(
gridSize, viewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::GridSize);
return gridSize;
}
@@ -168,8 +168,8 @@ namespace AzToolsFramework
bool AngleSnapping(const int viewportId)
{
bool snapping = false;
ViewportInteraction::ViewportInteractionRequestBus::EventResult(
snapping, viewportId, &ViewportInteraction::ViewportInteractionRequestBus::Events::AngleSnappingEnabled);
ViewportInteraction::ViewportSettingsRequestBus::EventResult(
snapping, viewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::AngleSnappingEnabled);
return snapping;
}
@@ -177,8 +177,8 @@ namespace AzToolsFramework
float AngleStep(const int viewportId)
{
float angle = 0.0f;
ViewportInteraction::ViewportInteractionRequestBus::EventResult(
angle, viewportId, &ViewportInteraction::ViewportInteractionRequestBus::Events::AngleStep);
ViewportInteraction::ViewportSettingsRequestBus::EventResult(
angle, viewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::AngleStep);
return angle;
}
@@ -186,8 +186,8 @@ namespace AzToolsFramework
bool ShowingGrid(const int viewportId)
{
bool show = false;
ViewportInteraction::ViewportInteractionRequestBus::EventResult(
show, viewportId, &ViewportInteraction::ViewportInteractionRequestBus::Events::ShowGrid);
ViewportInteraction::ViewportSettingsRequestBus::EventResult(
show, viewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::ShowGrid);
return show;
}
@@ -10,6 +10,7 @@
#include <AzCore/Component/NonUniformScaleBus.h>
#include <AzCore/Component/TransformBus.h>
#include <AzCore/Console/IConsole.h>
#include <AzCore/Math/VectorConversions.h>
#include <AzCore/std/containers/array.h>
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
@@ -22,6 +23,14 @@
#include <AzToolsFramework/Maths/TransformUtils.h>
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
AZ_CVAR(
bool,
ed_manipulatorDisplayBoundDebug,
false,
nullptr,
AZ::ConsoleFunctorFlags::Null,
"Display additional debug drawing for manipulator bounds");
namespace AzToolsFramework
{
const float g_defaultManipulatorSphereRadius = 0.1f;
@@ -118,6 +127,14 @@ namespace AzToolsFramework
return quadBound;
}
// calculate line in world space (axis and length).
static AZStd::pair<AZ::Vector3, AZ::Vector3> CalculateLine(
const AZ::Vector3& localPosition, const AZ::Transform& worldFromLocal, const AZ::Vector3& axis, const float length)
{
return { worldFromLocal.TransformPoint(localPosition),
TransformPositionNoScaling(worldFromLocal, localPosition + (axis * length)) };
}
// calculate line bound in world space (axis and length).
static Picking::BoundShapeLineSegment CalculateLineBound(
const AZ::Vector3& localPosition,
@@ -127,8 +144,9 @@ namespace AzToolsFramework
const float width)
{
Picking::BoundShapeLineSegment lineBound;
lineBound.m_start = worldFromLocal.TransformPoint(localPosition);
lineBound.m_end = TransformPositionNoScaling(worldFromLocal, localPosition + (axis * length));
const auto line = CalculateLine(localPosition, worldFromLocal, axis, length);
lineBound.m_start = line.first;
lineBound.m_end = line.second;
lineBound.m_width = width;
return lineBound;
}
@@ -395,13 +413,29 @@ namespace AzToolsFramework
m_axis, m_cameraCorrectedAxis, managerState, mouseInteraction, manipulatorState.m_worldFromLocal,
manipulatorState.m_localPosition, cameraState);
const Picking::BoundShapeLineSegment lineBound = CalculateLineBound(
manipulatorState.m_localPosition, manipulatorState.m_worldFromLocal, m_cameraCorrectedAxis, m_length * viewScale,
m_width * viewScale);
const auto worldLine =
CalculateLine(manipulatorState.m_localPosition, manipulatorState.m_worldFromLocal, m_cameraCorrectedAxis, m_length * viewScale);
debugDisplay.SetColor(ViewColor(manipulatorState.m_mouseOver, m_color, m_mouseOverColor).GetAsVector4());
debugDisplay.SetLineWidth(defaultLineWidth(manipulatorState.m_mouseOver));
debugDisplay.DrawLine(lineBound.m_start, lineBound.m_end);
debugDisplay.DrawLine(worldLine.first, worldLine.second);
// ensure length of bound takes into account logical width of line (m_length - m_width)
const Picking::BoundShapeLineSegment lineBound = CalculateLineBound(
manipulatorState.m_localPosition, manipulatorState.m_worldFromLocal, m_cameraCorrectedAxis, (m_length - m_width) * viewScale,
m_width * viewScale);
if (ed_manipulatorDisplayBoundDebug)
{
debugDisplay.DrawBall(lineBound.m_start, lineBound.m_width, false);
debugDisplay.DrawBall(lineBound.m_end, lineBound.m_width, false);
const auto line = lineBound.m_end - lineBound.m_start;
const auto height = line.GetLength();
const auto axis = line / height;
const auto center = lineBound.m_start + axis * height * 0.5f;
debugDisplay.DrawSolidCylinder(center, axis, lineBound.m_width, height, false);
}
RefreshBoundInternal(managerId, manipulatorId, lineBound);
}
@@ -578,13 +612,30 @@ namespace AzToolsFramework
const Picking::BoundShapeTorus torusBound = CalculateTorusBound(
manipulatorState.m_localPosition, manipulatorState.m_worldFromLocal, m_axis, m_radius * viewScale, m_width * viewScale);
// transform circle based on delta between default z up axis and other axes
const AZ::Transform worldFromLocalWithOrientation =
AZ::Transform::CreateTranslation(manipulatorState.m_worldFromLocal.GetTranslation()) *
const AZ::Transform orientation =
AZ::Transform::CreateFromQuaternion((QuaternionFromTransformNoScaling(manipulatorState.m_worldFromLocal) *
AZ::Quaternion::CreateShortestArc(AZ::Vector3::CreateAxisZ(), m_axis))
.GetNormalized());
// transform circle based on delta between default z up axis and other axes
const AZ::Transform worldFromLocalWithOrientation =
AZ::Transform::CreateTranslation(manipulatorState.m_worldFromLocal.GetTranslation()) * orientation;
if (ed_manipulatorDisplayBoundDebug)
{
debugDisplay.SetColor(AZ::Colors::BlanchedAlmond);
debugDisplay.PushMatrix(orientation);
debugDisplay.DrawCircle(torusBound.m_center + AZ::Vector3::CreateAxisZ() * torusBound.m_minorRadius, torusBound.m_majorRadius);
debugDisplay.DrawCircle(
torusBound.m_center + AZ::Vector3::CreateAxisZ() * torusBound.m_minorRadius,
torusBound.m_majorRadius + torusBound.m_minorRadius);
debugDisplay.DrawCircle(torusBound.m_center - AZ::Vector3::CreateAxisZ() * torusBound.m_minorRadius, torusBound.m_majorRadius);
debugDisplay.DrawCircle(
torusBound.m_center - AZ::Vector3::CreateAxisZ() * torusBound.m_minorRadius,
torusBound.m_majorRadius + torusBound.m_minorRadius);
debugDisplay.PopMatrix();
}
debugDisplay.CullOn();
debugDisplay.PushMatrix(worldFromLocalWithOrientation);
debugDisplay.SetColor(ViewColor(manipulatorState.m_mouseOver, m_color, m_mouseOverColor).GetAsVector4());
@@ -604,7 +655,10 @@ namespace AzToolsFramework
}
void DrawFullCircle(
AzFramework::DebugDisplayRequests& debugDisplay, const AZ::Vector3& position, const float radius, const AZ::Vector3& /*viewPos*/)
AzFramework::DebugDisplayRequests& debugDisplay,
const AZ::Vector3& position,
const float radius,
[[maybe_unused]] const AZ::Vector3& viewPos)
{
debugDisplay.DrawCircle(position, radius);
}
@@ -130,11 +130,13 @@ namespace AzToolsFramework
for (size_t manipulatorIndex = 0; manipulatorIndex < m_localAngularManipulators.size(); ++manipulatorIndex)
{
m_localAngularManipulators[manipulatorIndex]->SetView(CreateManipulatorViewCircle(
*m_localAngularManipulators[manipulatorIndex], colors[manipulatorIndex], radius, 0.05f, DrawHalfDottedCircle));
*m_localAngularManipulators[manipulatorIndex], colors[manipulatorIndex], radius, m_circleBoundWidth, DrawHalfDottedCircle));
}
const float viewAlignedScale = 1.12f;
m_viewAngularManipulator->SetView(CreateManipulatorViewCircle(
*m_viewAngularManipulator, AZ::Color(1.0f, 1.0f, 1.0f, 1.0f), radius + (radius * 0.12f), 0.05f, DrawFullCircle));
*m_viewAngularManipulator, AZ::Color(1.0f, 1.0f, 1.0f, 1.0f), radius * viewAlignedScale, m_circleBoundWidth,
DrawFullCircle));
}
bool RotationManipulators::PerformingActionViewAxis() const
@@ -151,4 +153,9 @@ namespace AzToolsFramework
manipulatorFn(m_viewAngularManipulator.get());
}
void RotationManipulators::SetCircleBoundWidth(const float circleBoundWidth)
{
m_circleBoundWidth = circleBoundWidth;
}
} // namespace AzToolsFramework
@@ -42,6 +42,9 @@ namespace AzToolsFramework
bool PerformingActionViewAxis() const;
//! Sets the bound width to use for the circle (torus) of an angular manipulator.
void SetCircleBoundWidth(float circleBoundWidth);
private:
AZ_DISABLE_COPY_MOVE(RotationManipulators)
@@ -49,5 +52,6 @@ namespace AzToolsFramework
AZStd::array<AZStd::shared_ptr<AngularManipulator>, 3> m_localAngularManipulators;
AZStd::shared_ptr<AngularManipulator> m_viewAngularManipulator;
float m_circleBoundWidth = 0.1f; //!< The default circle bound width for the angular manipulator torus.
};
} // namespace AzToolsFramework
@@ -120,18 +120,18 @@ namespace AzToolsFramework
const float axisLength, const AZ::Color& axis1Color, const AZ::Color& axis2Color, const AZ::Color& axis3Color)
{
const float boxSize = 0.1f;
const float lineWidth = 0.05f;
const AZ::Color colors[] = { axis1Color, axis2Color, axis3Color };
for (size_t manipulatorIndex = 0; manipulatorIndex < m_axisScaleManipulators.size(); ++manipulatorIndex)
{
const auto lineLength = axisLength - boxSize;
ManipulatorViews views;
views.emplace_back(
CreateManipulatorViewLine(*m_axisScaleManipulators[manipulatorIndex], colors[manipulatorIndex], axisLength, lineWidth));
CreateManipulatorViewLine(*m_axisScaleManipulators[manipulatorIndex], colors[manipulatorIndex], axisLength, m_lineBoundWidth));
views.emplace_back(CreateManipulatorViewBox(
AZ::Transform::CreateIdentity(), colors[manipulatorIndex],
m_axisScaleManipulators[manipulatorIndex]->GetAxis() * (axisLength - boxSize), AZ::Vector3(boxSize)));
m_axisScaleManipulators[manipulatorIndex]->GetAxis() * lineLength, AZ::Vector3(boxSize)));
m_axisScaleManipulators[manipulatorIndex]->SetViews(AZStd::move(views));
}
@@ -150,4 +150,9 @@ namespace AzToolsFramework
manipulatorFn(m_uniformScaleManipulator.get());
}
void ScaleManipulators::SetLineBoundWidth(const float lineBoundWidth)
{
m_lineBoundWidth = lineBoundWidth;
}
} // namespace AzToolsFramework
@@ -41,6 +41,9 @@ namespace AzToolsFramework
void ConfigureView(float axisLength, const AZ::Color& axis1Color, const AZ::Color& axis2Color, const AZ::Color& axis3Color);
//! Sets the bound width to use for the line/axis of a linear manipulator.
void SetLineBoundWidth(float lineBoundWidth);
private:
AZ_DISABLE_COPY_MOVE(ScaleManipulators)
@@ -49,5 +52,6 @@ namespace AzToolsFramework
AZStd::array<AZStd::shared_ptr<LinearManipulator>, 3> m_axisScaleManipulators;
AZStd::shared_ptr<LinearManipulator> m_uniformScaleManipulator;
float m_lineBoundWidth = 0.01f; //!< The default line bound width for the linear manipulator axis.
};
} // namespace AzToolsFramework
@@ -235,24 +235,25 @@ namespace AzToolsFramework
}
void TranslationManipulators::ConfigureLinearView(
float axisLength,
const float axisLength,
const AZ::Color& axis1Color,
const AZ::Color& axis2Color,
const AZ::Color& axis3Color /*= AZ::Color(0.0f, 0.0f, 1.0f, 0.5f)*/)
{
const float coneLength = 0.28f;
const float coneRadius = 0.07f;
const float lineWidth = 0.05f;
const AZ::Color axesColor[] = { axis1Color, axis2Color, axis3Color };
const auto configureLinearView =
[lineWidth, coneLength, axisLength, coneRadius](LinearManipulator* linearManipulator, const AZ::Color& color)
const auto configureLinearView = [lineBoundWidth = m_lineBoundWidth, coneLength, axisLength,
coneRadius](LinearManipulator* linearManipulator, const AZ::Color& color)
{
const auto lineLength = axisLength - coneLength;
ManipulatorViews views;
views.emplace_back(CreateManipulatorViewLine(*linearManipulator, color, axisLength, lineWidth));
views.emplace_back(CreateManipulatorViewCone(
*linearManipulator, color, linearManipulator->GetAxis() * (axisLength - coneLength), coneLength, coneRadius));
views.emplace_back(CreateManipulatorViewLine(*linearManipulator, color, lineLength, lineBoundWidth));
views.emplace_back(
CreateManipulatorViewCone(*linearManipulator, color, linearManipulator->GetAxis() * lineLength, coneLength, coneRadius));
linearManipulator->SetViews(AZStd::move(views));
};
@@ -316,6 +317,11 @@ namespace AzToolsFramework
}
}
void TranslationManipulators::SetLineBoundWidth(const float lineBoundWidth)
{
m_lineBoundWidth = lineBoundWidth;
}
void ConfigureTranslationManipulatorAppearance3d(TranslationManipulators* translationManipulators)
{
translationManipulators->SetAxes(AZ::Vector3::CreateAxisX(), AZ::Vector3::CreateAxisY(), AZ::Vector3::CreateAxisZ());
@@ -65,6 +65,9 @@ namespace AzToolsFramework
void ConfigureSurfaceView(float radius, const AZ::Color& color);
//! Sets the bound width to use for the line/axis of a linear manipulator.
void SetLineBoundWidth(float lineBoundWidth);
private:
AZ_DISABLE_COPY_MOVE(TranslationManipulators)
@@ -76,6 +79,7 @@ namespace AzToolsFramework
AZStd::vector<AZStd::shared_ptr<LinearManipulator>> m_linearManipulators;
AZStd::vector<AZStd::shared_ptr<PlanarManipulator>> m_planarManipulators;
AZStd::shared_ptr<SurfaceManipulator> m_surfaceManipulator = nullptr;
float m_lineBoundWidth = 0.01f; //!< The default line bound width for the linear manipulator axis.
};
//! IndexedTranslationManipulator wraps a standard TranslationManipulators and allows it to be linked
@@ -16,6 +16,79 @@ namespace AzToolsFramework
{
namespace Picking
{
// this intersection algorithm is adapted from 'Capped Cone' by Inigo Quilez
// ref: https://www.iquilezles.org/www/articles/intersectors/intersectors.htm and https://www.shadertoy.com/view/llcfRf
// all algorithms/code snippets are kindly made available under the MIT License - https://www.iquilezles.org/www/index.htm
bool IntersectRayCone(
const AZ::Vector3& rayOrigin,
const AZ::Vector3& rayDirection,
const AZ::Vector3& coneApex,
const AZ::Vector3& coneAxis,
float coneHeight,
float coneBaseRadius,
float& t)
{
const AZ::Vector3& pa = coneApex;
const AZ::Vector3& pb = coneApex + coneHeight * coneAxis;
const AZ::Vector3& ro = rayOrigin;
const AZ::Vector3& rd = rayDirection;
float rb = coneBaseRadius;
AZ::Vector3 ba = pb - pa;
AZ::Vector3 oa = ro - pa;
AZ::Vector3 ob = ro - pb;
float m0 = ba.Dot(ba);
float m1 = oa.Dot(ba);
float m2 = ob.Dot(ba);
float m3 = rd.Dot(ba);
auto dot2 = [](const AZ::Vector3& v)
{
return v.Dot(v);
};
// cap
if (m2 > 0.0f)
{
if (dot2(ob * m3 - rd * m2) < (rb * rb * m3 * m3))
{
t = -m2 / m3;
return true;
}
}
// body
float m4 = rd.Dot(oa);
float m5 = oa.Dot(oa);
float hy = m0 + rb * rb;
float k2 = m0 * m0 - m3 * m3 * hy;
float k1 = m0 * m0 * m4 - m1 * m3 * hy;
float k0 = m0 * m0 * m5 - m1 * m1 * hy;
// note: solving for simultaneously being on the sloping surface of the cone and being on the ray boils down
// to a quadratic equation - the discriminant of the quadratic determines if there are 1, 2 or no solutions
//
// if the discriminant is less than 0 the ray is not intersecting the cone, if it is equal to 0 then the ray
// is intersecting the cone once and if it is greater than 0 the ray is intersecting the cone twice
float discriminant = k1 * k1 - k2 * k0;
if (discriminant < 0.0f)
{
return false;
}
float tt = (-k1 - AZ::Sqrt(discriminant)) / k2;
float y = m1 + tt * m3;
if (y >= 0.0f && y < m0)
{
t = tt;
return true;
}
return false;
}
bool ManipulatorBoundSphere::IntersectRay(
const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDirection, float& rayIntersectionDistance)
{
@@ -86,11 +159,10 @@ namespace AzToolsFramework
bool ManipulatorBoundCone::IntersectRay(
const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDirection, float& rayIntersectionDistance)
{
float t1 = std::numeric_limits<float>::max();
float t2 = std::numeric_limits<float>::max();
if (AZ::Intersect::IntersectRayCone(rayOrigin, rayDirection, m_apexPosition, m_dir, m_height, m_radius, t1, t2) > 0)
float t = std::numeric_limits<float>::max();
if (IntersectRayCone(rayOrigin, rayDirection, m_apexPosition, m_dir, m_height, m_radius, t))
{
rayIntersectionDistance = AZStd::GetMin(t1, t2);
rayIntersectionDistance = t;
return true;
}
@@ -23,6 +23,26 @@ namespace AzToolsFramework
{
namespace Picking
{
//! Custom ray/cone intersect function for manipulator bounds to workaround a bug in the current AZ::Intersect implementation.
//! @note Does not give reliable results if the ray origin is inside the cone.
//! @param rayOrigin The origin of the ray to test.
//! @param rayDirection The direction of the ray to test, it must be unit length.
//! @param coneApex The apex of the cone.
//! @param coneAxis The unit-length axis (direction) from the apex to the base.
//! @param coneHeight The height of the cone, from the apex to the base.
//! @param coneBaseRadius The radius of the cone base.
//! @param[out] t A possible coefficient in the ray's explicit equation from which an intersecting point is calculated
//! as "rayOrigin + t * rayDirection". 't' is the closest intersecting point to the ray origin.
//! @return true for intersecting, false for not intersecting.
bool IntersectRayCone(
const AZ::Vector3& rayOrigin,
const AZ::Vector3& rayDirection,
const AZ::Vector3& coneApex,
const AZ::Vector3& coneAxis,
float coneHeight,
float coneBaseRadius,
float& t);
class ManipulatorBoundSphere : public BoundShapeInterface
{
public:
@@ -61,7 +61,7 @@ namespace AzToolsFramework
m_prefabUndoCache.Destroy();
}
PrefabOperationResult PrefabPublicHandler::CreatePrefabInMemory(const EntityIdList& entityIds, AZ::IO::PathView filePath)
CreatePrefabResult PrefabPublicHandler::CreatePrefabInMemory(const EntityIdList& entityIds, AZ::IO::PathView filePath)
{
EntityList inputEntityList, topLevelEntities;
AZ::EntityId commonRootEntityId;
@@ -70,9 +70,11 @@ namespace AzToolsFramework
entityIds, inputEntityList, topLevelEntities, commonRootEntityId, commonRootEntityOwningInstance);
if (!findCommonRootOutcome.IsSuccess())
{
return findCommonRootOutcome;
return AZ::Failure(findCommonRootOutcome.TakeError());
}
AZ::EntityId containerEntityId;
InstanceOptionalReference instanceToCreate;
{
// Initialize Undo Batch object
@@ -92,7 +94,7 @@ namespace AzToolsFramework
inputEntityList, commonRootEntityOwningInstance->get(), entities, instances);
if (!retrieveEntitiesAndInstancesOutcome.IsSuccess())
{
return retrieveEntitiesAndInstancesOutcome;
return AZ::Failure(retrieveEntitiesAndInstancesOutcome.TakeError());
}
AZStd::unordered_map<AZ::EntityId, AZStd::string> oldEntityAliases;
@@ -153,7 +155,7 @@ namespace AzToolsFramework
"(A null instance is returned)."));
}
AZ::EntityId containerEntityId = instanceToCreate->get().GetContainerEntityId();
containerEntityId = instanceToCreate->get().GetContainerEntityId();
// Apply the correct transform to the container for the new instance, and store the patch for use when creating the link.
PrefabDom patch = ApplyContainerTransformAndGeneratePatch(containerEntityId, commonRootEntityId, topLevelEntities);
@@ -261,10 +263,10 @@ namespace AzToolsFramework
}
}
return AZ::Success();
return AZ::Success(containerEntityId);
}
PrefabOperationResult PrefabPublicHandler::CreatePrefabInDisk(const EntityIdList& entityIds, AZ::IO::PathView filePath)
CreatePrefabResult PrefabPublicHandler::CreatePrefabInDisk(const EntityIdList& entityIds, AZ::IO::PathView filePath)
{
auto result = CreatePrefabInMemory(entityIds, filePath);
if (result.IsSuccess())
@@ -42,11 +42,12 @@ namespace AzToolsFramework
void UnregisterPrefabPublicHandlerInterface();
// PrefabPublicInterface...
PrefabOperationResult CreatePrefabInDisk(
CreatePrefabResult CreatePrefabInDisk(
const EntityIdList& entityIds, AZ::IO::PathView filePath) override;
PrefabOperationResult CreatePrefabInMemory(
CreatePrefabResult CreatePrefabInMemory(
const EntityIdList& entityIds, AZ::IO::PathView filePath) override;
InstantiatePrefabResult InstantiatePrefab(AZStd::string_view filePath, AZ::EntityId parent, const AZ::Vector3& position) override;
InstantiatePrefabResult InstantiatePrefab(
AZStd::string_view filePath, AZ::EntityId parent, const AZ::Vector3& position) override;
PrefabOperationResult SavePrefab(AZ::IO::Path filePath) override;
PrefabEntityResult CreateEntity(AZ::EntityId parentId, const AZ::Vector3& position) override;
@@ -24,8 +24,9 @@ namespace AzToolsFramework
namespace Prefab
{
typedef AZ::Outcome<void, AZStd::string> PrefabOperationResult;
typedef AZ::Outcome<AZ::EntityId, AZStd::string> CreatePrefabResult;
typedef AZ::Outcome<AZ::EntityId, AZStd::string> InstantiatePrefabResult;
typedef AZ::Outcome<void, AZStd::string> PrefabOperationResult;
typedef AZ::Outcome<bool, AZStd::string> PrefabRequestResult;
typedef AZ::Outcome<AZ::EntityId, AZStd::string> PrefabEntityResult;
@@ -44,9 +45,10 @@ namespace AzToolsFramework
* Automatically detects descendants of entities, and discerns between entities and child instances.
* @param entityIds The entities that should form the new prefab (along with their descendants).
* @param filePath The absolute path for the new prefab file.
* @return An outcome object; on failure, it comes with an error message detailing the cause of the error.
* @return An outcome object with an entityId of the new prefab's container entity;
* on failure, it comes with an error message detailing the cause of the error.
*/
virtual PrefabOperationResult CreatePrefabInDisk(
virtual CreatePrefabResult CreatePrefabInDisk(
const EntityIdList& entityIds, AZ::IO::PathView filePath) = 0;
/**
@@ -54,9 +56,10 @@ namespace AzToolsFramework
* Automatically detects descendants of entities, and discerns between entities and child instances.
* @param entityIds The entities that should form the new prefab (along with their descendants).
* @param filePath The absolute path for the new prefab file.
* @return An outcome object; on failure, it comes with an error message detailing the cause of the error.
* @return An outcome object with an entityId of the new prefab's container entity;
* on failure, it comes with an error message detailing the cause of the error.
*/
virtual PrefabOperationResult CreatePrefabInMemory(
virtual CreatePrefabResult CreatePrefabInMemory(
const EntityIdList& entityIds, AZ::IO::PathView filePath) = 0;
/**
@@ -10,6 +10,7 @@
#include <AzCore/Component/EntityId.h>
#include <AzCore/EBus/EBus.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/Math/Vector3.h>
#include <AzCore/Outcome/Outcome.h>
#include <AzCore/std/containers/vector.h>
@@ -22,8 +23,9 @@ namespace AzToolsFramework
namespace Prefab
{
using PrefabOperationResult = AZ::Outcome<void, AZStd::string>;
using CreatePrefabResult = AZ::Outcome<AZ::EntityId, AZStd::string>;
using InstantiatePrefabResult = AZ::Outcome<AZ::EntityId, AZStd::string>;
using PrefabOperationResult = AZ::Outcome<void, AZStd::string>;
/**
* The primary purpose of this bus is to facilitate writing automated tests for prefabs.
@@ -47,14 +49,16 @@ namespace AzToolsFramework
/**
* Create a prefab out of the entities provided, at the path provided, and keep it in memory.
* Automatically detects descendants of entities, and discerns between entities and child instances.
* Return whether the creation succeeded or not.
* Return an outcome object with an container entity id of the prefab created if creation succeeded;
* on failure, it comes with an error message detailing the cause of the error.
*/
virtual PrefabOperationResult CreatePrefabInMemory(
virtual CreatePrefabResult CreatePrefabInMemory(
const EntityIdList& entityIds, AZStd::string_view filePath) = 0;
/**
* Instantiate a prefab from a prefab file.
* Return the container entity id of the prefab instantiated if instantiation succeeded.
* Return an outcome object with an container entity id of the prefab instantiated if instantiation succeeded;
* on failure, it comes with an error message detailing the cause of the error.
*/
virtual InstantiatePrefabResult InstantiatePrefab(
AZStd::string_view filePath, AZ::EntityId parent, const AZ::Vector3& position) = 0;
@@ -62,10 +66,9 @@ namespace AzToolsFramework
/**
* Deletes all entities and their descendants from the owning instance. Bails if the entities don't
* all belong to the same instance.
* Return whether the deletion succeeded or not.
* Return an outcome object; on failure, it comes with an error message detailing the cause of the error.
*/
virtual PrefabOperationResult DeleteEntitiesAndAllDescendantsInInstance(const EntityIdList& entityIds) = 0;
};
using PrefabPublicRequestBus = AZ::EBus<PrefabPublicRequests>;
@@ -45,7 +45,7 @@ namespace AzToolsFramework
m_prefabPublicInterface = nullptr;
}
PrefabOperationResult PrefabPublicRequestHandler::CreatePrefabInMemory(const EntityIdList& entityIds, AZStd::string_view filePath)
CreatePrefabResult PrefabPublicRequestHandler::CreatePrefabInMemory(const EntityIdList& entityIds, AZStd::string_view filePath)
{
return m_prefabPublicInterface->CreatePrefabInMemory(entityIds, filePath);
}
@@ -31,7 +31,7 @@ namespace AzToolsFramework
void Connect();
void Disconnect();
PrefabOperationResult CreatePrefabInMemory(const EntityIdList& entityIds, AZStd::string_view filePath) override;
CreatePrefabResult CreatePrefabInMemory(const EntityIdList& entityIds, AZStd::string_view filePath) override;
InstantiatePrefabResult InstantiatePrefab(AZStd::string_view filePath, AZ::EntityId parent, const AZ::Vector3& position) override;
PrefabOperationResult DeleteEntitiesAndAllDescendantsInInstance(const EntityIdList& entityIds) override;
@@ -0,0 +1,65 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <AzToolsFramework/Viewport/ViewportMessages.h>
namespace AzToolsFramework
{
AzFramework::ClickDetector::ClickEvent ClickDetectorEventFromViewportInteraction(
const ViewportInteraction::MouseInteractionEvent& mouseInteraction)
{
if (mouseInteraction.m_mouseInteraction.m_mouseButtons.Left())
{
if (mouseInteraction.m_mouseEvent == ViewportInteraction::MouseEvent::Down)
{
return AzFramework::ClickDetector::ClickEvent::Down;
}
if (mouseInteraction.m_mouseEvent == ViewportInteraction::MouseEvent::Up)
{
return AzFramework::ClickDetector::ClickEvent::Up;
}
}
return AzFramework::ClickDetector::ClickEvent::Nil;
}
float ManipulatorLineBoundWidth(const AzFramework::ViewportId viewportId /*= AzFramework::InvalidViewportId*/)
{
float lineBoundWidth = 0.0f;
if (viewportId != AzFramework::InvalidViewportId)
{
ViewportInteraction::ViewportSettingsRequestBus::EventResult(
lineBoundWidth, viewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::ManipulatorLineBoundWidth);
}
else
{
ViewportInteraction::ViewportSettingsRequestBus::BroadcastResult(
lineBoundWidth, &ViewportInteraction::ViewportSettingsRequestBus::Events::ManipulatorLineBoundWidth);
}
return lineBoundWidth;
}
float ManipulatorCicleBoundWidth(const AzFramework::ViewportId viewportId /*= AzFramework::InvalidViewportId*/)
{
float circleBoundWidth = 0.0f;
if (viewportId != AzFramework::InvalidViewportId)
{
ViewportInteraction::ViewportSettingsRequestBus::EventResult(
circleBoundWidth, viewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::ManipulatorCircleBoundWidth);
}
else
{
ViewportInteraction::ViewportSettingsRequestBus::BroadcastResult(
circleBoundWidth, &ViewportInteraction::ViewportSettingsRequestBus::Events::ManipulatorCircleBoundWidth);
}
return circleBoundWidth;
}
} // namespace AzToolsFramework
@@ -156,22 +156,12 @@ namespace AzToolsFramework
class ViewportInteractionRequests
{
public:
//! Return the current camera state for this viewport.
//! Returns the current camera state for this viewport.
virtual AzFramework::CameraState GetCameraState() = 0;
//! Return if grid snapping is enabled.
virtual bool GridSnappingEnabled() = 0;
//! Return the grid snapping size.
virtual float GridSize() = 0;
//! Does the grid currently want to be displayed.
virtual bool ShowGrid() = 0;
//! Return if angle snapping is enabled.
virtual bool AngleSnappingEnabled() = 0;
//! Return the angle snapping/step size.
virtual float AngleStep() = 0;
//! Transform a point in world space to screen space coordinates in Qt Widget space.
//! Transforms a point in world space to screen space coordinates in Qt Widget space.
//! Multiply by DeviceScalingFactor to get the position in viewport pixel space.
virtual AzFramework::ScreenPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition) = 0;
//! Transform a point from Qt widget screen space to world space based on the given clip space depth.
//! Transforms a point from Qt widget screen space to world space based on the given clip space depth.
//! Depth specifies a relative camera depth to project in the range of [0.f, 1.f].
//! Returns the world space position if successful.
virtual AZStd::optional<AZ::Vector3> ViewportScreenToWorld(const AzFramework::ScreenPoint& screenPosition, float depth) = 0;
@@ -185,12 +175,13 @@ namespace AzToolsFramework
~ViewportInteractionRequests() = default;
};
//! Type to inherit to implement ViewportInteractionRequests.
using ViewportInteractionRequestBus = AZ::EBus<ViewportInteractionRequests, ViewportEBusTraits>;
//! Interface to return only viewport specific settings (e.g. snapping).
class ViewportSettings
class ViewportSettingsRequests
{
public:
virtual ~ViewportSettings() = default;
//! Return if grid snapping is enabled.
virtual bool GridSnappingEnabled() const = 0;
//! Return the grid snapping size.
@@ -201,20 +192,31 @@ namespace AzToolsFramework
virtual bool AngleSnappingEnabled() const = 0;
//! Return the angle snapping/step size.
virtual float AngleStep() const = 0;
//! Returns the current line bound width for manipulators.
virtual float ManipulatorLineBoundWidth() const = 0;
//! Returns the current circle (torus) bound width for manipulators.
virtual float ManipulatorCircleBoundWidth() const = 0;
protected:
~ViewportSettingsRequests() = default;
};
//! Type to inherit to implement ViewportInteractionRequests.
using ViewportInteractionRequestBus = AZ::EBus<ViewportInteractionRequests, ViewportEBusTraits>;
//! Type to inherit to implement ViewportSettingsRequests.
using ViewportSettingsRequestBus = AZ::EBus<ViewportSettingsRequests, ViewportEBusTraits>;
//! An interface to notify when changes to viewport settings have happened.
class ViewportSettingNotifications
{
public:
virtual void OnGridSnappingChanged([[maybe_unused]] bool enabled) {}
virtual void OnDrawHelpersChanged([[maybe_unused]] bool enabled) {}
virtual void OnGridSnappingChanged([[maybe_unused]] bool enabled)
{
}
virtual void OnDrawHelpersChanged([[maybe_unused]] bool enabled)
{
}
protected:
ViewportSettingNotifications() = default;
~ViewportSettingNotifications() = default;
};
using ViewportSettingsNotificationBus = AZ::EBus<ViewportSettingNotifications, ViewportEBusTraits>;
@@ -248,8 +250,6 @@ namespace AzToolsFramework
virtual AZ::Vector3 PickTerrain(const AzFramework::ScreenPoint& point) = 0;
//! Return the terrain height given a world position in 2d (xy plane).
virtual float TerrainHeight(const AZ::Vector2& position) = 0;
//! Given the current view frustum (viewport) return all visible entities.
virtual void FindVisibleEntities(AZStd::vector<AZ::EntityId>& visibleEntities) = 0;
//! Is the user holding a modifier key to move the manipulator space from local to world.
virtual bool ShowingWorldSpace() = 0;
//! Return the widget to use as the parent for the viewport context menu.
@@ -267,7 +267,20 @@ namespace AzToolsFramework
//! Type to inherit to implement MainEditorViewportInteractionRequests.
using MainEditorViewportInteractionRequestBus = AZ::EBus<MainEditorViewportInteractionRequests, ViewportEBusTraits>;
//! Viewport requests for managing the viewport's cursor state.
//! Editor entity requests to be made about the viewport.
class EditorEntityViewportInteractionRequests
{
public:
//! Given the current view frustum (viewport) return all visible entities.
virtual void FindVisibleEntities(AZStd::vector<AZ::EntityId>& visibleEntities) = 0;
protected:
~EditorEntityViewportInteractionRequests() = default;
};
using EditorEntityViewportInteractionRequestBus = AZ::EBus<EditorEntityViewportInteractionRequests, ViewportEBusTraits>;
//! Viewport requests for managing the viewport cursor state.
class ViewportMouseCursorRequests
{
public:
@@ -319,21 +332,14 @@ namespace AzToolsFramework
//! Maps a mouse interaction event to a ClickDetector event.
//! @note Function only cares about up or down events, all other events are mapped to Nil (ignored).
inline AzFramework::ClickDetector::ClickEvent ClickDetectorEventFromViewportInteraction(
const ViewportInteraction::MouseInteractionEvent& mouseInteraction)
{
if (mouseInteraction.m_mouseInteraction.m_mouseButtons.Left())
{
if (mouseInteraction.m_mouseEvent == ViewportInteraction::MouseEvent::Down)
{
return AzFramework::ClickDetector::ClickEvent::Down;
}
AzFramework::ClickDetector::ClickEvent ClickDetectorEventFromViewportInteraction(
const ViewportInteraction::MouseInteractionEvent& mouseInteraction);
if (mouseInteraction.m_mouseEvent == ViewportInteraction::MouseEvent::Up)
{
return AzFramework::ClickDetector::ClickEvent::Up;
}
}
return AzFramework::ClickDetector::ClickEvent::Nil;
}
//! Wrap EBus call to retrieve manipulator line bound width.
//! @note It is possible to pass AzFramework::InvalidViewportId (the default) to perform a Broadcast as opposed to a targeted Event.
float ManipulatorLineBoundWidth(AzFramework::ViewportId viewportId = AzFramework::InvalidViewportId);
//! Wrap EBus call to retrieve manipulator circle bound width.
//! @note It is possible to pass AzFramework::InvalidViewportId (the default) to perform a Broadcast as opposed to a targeted Event.
float ManipulatorCicleBoundWidth(AzFramework::ViewportId viewportId = AzFramework::InvalidViewportId);
} // namespace AzToolsFramework
@@ -19,7 +19,7 @@
namespace AzToolsFramework
{
// default ray length for picking in the viewport
static const float s_pickRayLength = 1000.0f;
static const float EditorPickRayLength = 1000.0f;
AZ::Vector3 CalculateCenterOffset(const AZ::EntityId entityId, const EditorTransformComponentSelectionRequests::Pivot pivot)
{
@@ -60,16 +60,27 @@ namespace AzToolsFramework
return screenPosition;
}
bool AabbIntersectMouseRay(const ViewportInteraction::MouseInteraction& mouseInteraction, const AZ::Aabb& aabb)
bool AabbIntersectRay(const AZ::Vector3& origin, const AZ::Vector3& direction, const AZ::Aabb& aabb, float& distance)
{
AZ_PROFILE_FUNCTION(AzToolsFramework);
const AZ::Vector3 rayScaledDir = mouseInteraction.m_mousePick.m_rayDirection * s_pickRayLength;
const AZ::Vector3 rayScaledDir = direction * EditorPickRayLength;
AZ::Vector3 startNormal;
float t, end;
return AZ::Intersect::IntersectRayAABB(
mouseInteraction.m_mousePick.m_rayOrigin, rayScaledDir, rayScaledDir.GetReciprocal(), aabb, t, end, startNormal) > 0;
AZ::Vector3 startNormal;
if (AZ::Intersect::IntersectRayAABB(origin, rayScaledDir, rayScaledDir.GetReciprocal(), aabb, t, end, startNormal) > 0)
{
distance = t * EditorPickRayLength;
return true;
}
return false;
}
bool AabbIntersectMouseRay(const ViewportInteraction::MouseInteraction& mouseInteraction, const AZ::Aabb& aabb)
{
float unused;
return AabbIntersectRay(mouseInteraction.m_mousePick.m_rayOrigin, mouseInteraction.m_mousePick.m_rayDirection, aabb, unused);
}
bool PickEntity(
@@ -117,8 +128,7 @@ namespace AzToolsFramework
{
float scaling = 1.0f;
ViewportInteraction::ViewportInteractionRequestBus::EventResult(
scaling, viewportId,
&ViewportInteraction::ViewportInteractionRequestBus::Events::DeviceScalingFactor);
scaling, viewportId, &ViewportInteraction::ViewportInteractionRequestBus::Events::DeviceScalingFactor);
return scaling;
}
@@ -46,6 +46,10 @@ namespace AzToolsFramework
//! in screen space intersected an aabb in world space.
bool AabbIntersectMouseRay(const ViewportInteraction::MouseInteraction& mouseInteraction, const AZ::Aabb& aabb);
//! Wrapper to perform an intersection between a ray and an aabb.
//! Note: direction should be normalized (it is scaled internally by the editor pick distance).
bool AabbIntersectRay(const AZ::Vector3& origin, const AZ::Vector3& direction, const AZ::Aabb& aabb, float& distance);
//! Return if a mouse interaction (pick ray) did intersect the tested EntityId.
bool PickEntity(
AZ::EntityId entityId, const ViewportInteraction::MouseInteraction& mouseInteraction, float& closestDistance, int viewportId);
@@ -488,8 +488,8 @@ namespace AzToolsFramework
void SnappingCluster::TrySetVisible(const bool visible)
{
bool snapping = false;
ViewportInteraction::ViewportInteractionRequestBus::EventResult(
snapping, ViewportUi::DefaultViewportId, &ViewportInteraction::ViewportInteractionRequestBus::Events::GridSnappingEnabled);
ViewportInteraction::ViewportSettingsRequestBus::EventResult(
snapping, ViewportUi::DefaultViewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::GridSnappingEnabled);
// show snapping viewport ui only if there are entities selected and snapping is enabled
SetViewportUiClusterVisible(m_clusterId, visible && snapping);
@@ -1249,6 +1249,7 @@ namespace AzToolsFramework
AZStd::unique_ptr<TranslationManipulators> translationManipulators = AZStd::make_unique<TranslationManipulators>(
TranslationManipulators::Dimensions::Three, AZ::Transform::CreateIdentity(), AZ::Vector3::CreateOne());
translationManipulators->SetLineBoundWidth(ManipulatorLineBoundWidth(ViewportUi::DefaultViewportId));
InitializeManipulators(*translationManipulators);
@@ -1376,6 +1377,7 @@ namespace AzToolsFramework
AZStd::unique_ptr<RotationManipulators> rotationManipulators =
AZStd::make_unique<RotationManipulators>(AZ::Transform::CreateIdentity());
rotationManipulators->SetCircleBoundWidth(ManipulatorCicleBoundWidth(ViewportUi::DefaultViewportId));
InitializeManipulators(*rotationManipulators);
@@ -1545,6 +1547,7 @@ namespace AzToolsFramework
AZ_PROFILE_FUNCTION(AzToolsFramework);
AZStd::unique_ptr<ScaleManipulators> scaleManipulators = AZStd::make_unique<ScaleManipulators>(AZ::Transform::CreateIdentity());
scaleManipulators->SetLineBoundWidth(ManipulatorLineBoundWidth(ViewportUi::DefaultViewportId));
InitializeManipulators(*scaleManipulators);
@@ -2544,8 +2547,8 @@ namespace AzToolsFramework
if (buttonId == m_snappingCluster.m_snapToWorldButtonId)
{
float gridSize = 1.0f;
ViewportInteraction::ViewportInteractionRequestBus::EventResult(
gridSize, ViewportUi::DefaultViewportId, &ViewportInteraction::ViewportInteractionRequestBus::Events::GridSize);
ViewportInteraction::ViewportSettingsRequestBus::EventResult(
gridSize, ViewportUi::DefaultViewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::GridSize);
SnapSelectedEntitiesToWorldGrid(gridSize);
}
@@ -161,8 +161,8 @@ namespace AzToolsFramework
// request list of visible entities from authoritative system
EntityIdList nextVisibleEntityIds;
ViewportInteraction::MainEditorViewportInteractionRequestBus::Event(
viewportInfo.m_viewportId, &ViewportInteraction::MainEditorViewportInteractionRequestBus::Events::FindVisibleEntities,
ViewportInteraction::EditorEntityViewportInteractionRequestBus::Event(
viewportInfo.m_viewportId, &ViewportInteraction::EditorEntityViewportInteractionRequestBus::Events::FindVisibleEntities,
nextVisibleEntityIds);
// only bother resorting if we know the lists have changed
@@ -481,6 +481,7 @@ set(FILES
Viewport/VertexContainerDisplay.h
Viewport/VertexContainerDisplay.cpp
Viewport/ViewportMessages.h
Viewport/ViewportMessages.cpp
Viewport/ViewportTypes.h
Viewport/ViewportTypes.cpp
ViewportUi/Button.h

Some files were not shown because too many files have changed in this diff Show More