Apply reviewer suggestions
Signed-off-by: Nemerle <nemerle5+git@gmail.com>
This commit is contained in:
@@ -40,11 +40,12 @@ def Menus_EditMenuOptions_Work():
|
||||
("Toggle Pivot Location",),
|
||||
("Reset Entity Transform",),
|
||||
("Reset Manipulator",),
|
||||
("Reset Transform (Local)",),
|
||||
("Reset Transform (World)",),
|
||||
("Hide Selection",),
|
||||
("Show All",),
|
||||
("Modify", "Snap", "Snap angle"),
|
||||
("Lock Selection",),
|
||||
("Unlock All Entities",),
|
||||
("Modify", "Snap", "Angle snapping"),
|
||||
("Modify", "Snap", "Grid snapping"),
|
||||
("Modify", "Transform Mode", "Move"),
|
||||
("Modify", "Transform Mode", "Rotate"),
|
||||
("Modify", "Transform Mode", "Scale"),
|
||||
|
||||
@@ -39,7 +39,8 @@ def Menus_ViewMenuOptions_Work():
|
||||
("Viewport", "Go to Location"),
|
||||
("Viewport", "Remember Location"),
|
||||
("Viewport", "Switch Camera"),
|
||||
("Viewport", "Show/Hide Helpers"),
|
||||
("Viewport", "Show Helpers"),
|
||||
("Viewport", "Show Icons"),
|
||||
("Refresh Style",),
|
||||
]
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"baseColor": {
|
||||
"color": [ 1.0, 1.0, 1.0 ],
|
||||
"factor": 0.75,
|
||||
"useTexture": false,
|
||||
"textureMap": ""
|
||||
},
|
||||
"metallic": {
|
||||
"factor": 0.0,
|
||||
"useTexture": false,
|
||||
"textureMap": ""
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.0,
|
||||
"useTexture": false,
|
||||
"textureMap": ""
|
||||
},
|
||||
"specularF0": {
|
||||
"factor": 0.5,
|
||||
"useTexture": false,
|
||||
"textureMap": ""
|
||||
},
|
||||
"normal": {
|
||||
"factor": 1.0,
|
||||
"useTexture": false,
|
||||
"textureMap": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 0.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 0.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.1
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 0.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.2
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 0.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.3
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 0.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.4
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 0.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.5
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 0.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.6
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 0.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.7
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 0.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 0.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.9
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 0.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 1.0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 1.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 1.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.1
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 1.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.2
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 1.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.3
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 1.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.4
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 1.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.5
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 1.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.6
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 1.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.7
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 1.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 1.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.9
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parentMaterial": "./basic.material",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"propertyLayoutVersion": 1,
|
||||
"properties": {
|
||||
"metallic": {
|
||||
"factor": 1.0
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 1.0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a476e99b55cf2a76fef6775c5a57dad29f8ffcb942c625bab04c89051a72a560
|
||||
size 62626
|
||||
@@ -10,5 +10,7 @@
|
||||
"version_name": "1.0.0.0",
|
||||
"orientation": "landscape"
|
||||
},
|
||||
"engine": "o3de"
|
||||
}
|
||||
"engine": "o3de",
|
||||
"display_name": "AutomatedTesting",
|
||||
"icon_path": "preview.png"
|
||||
}
|
||||
|
||||
@@ -538,6 +538,7 @@ void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMe
|
||||
auto snapMenu = modifyMenu.AddMenu(tr("Snap"));
|
||||
|
||||
snapMenu.AddAction(AzToolsFramework::SnapAngle);
|
||||
snapMenu.AddAction(AzToolsFramework::SnapToGrid);
|
||||
|
||||
auto transformModeMenu = modifyMenu.AddMenu(tr("Transform Mode"));
|
||||
transformModeMenu.AddAction(AzToolsFramework::EditModeMove);
|
||||
@@ -723,7 +724,8 @@ QMenu* LevelEditorMenuHandler::CreateViewMenu()
|
||||
// MISSING AVIRECORDER
|
||||
|
||||
viewportViewsMenuWrapper.AddSeparator();
|
||||
viewportViewsMenuWrapper.AddAction(ID_DISPLAY_SHOWHELPERS);
|
||||
viewportViewsMenuWrapper.AddAction(AzToolsFramework::Helpers);
|
||||
viewportViewsMenuWrapper.AddAction(AzToolsFramework::Icons);
|
||||
|
||||
// Refresh Style
|
||||
viewMenu.AddAction(ID_SKINS_REFRESH);
|
||||
|
||||
@@ -445,7 +445,6 @@ void CCryEditApp::RegisterActionHandlers()
|
||||
ON_COMMAND(ID_OPEN_ASSET_BROWSER, OnOpenAssetBrowserView)
|
||||
ON_COMMAND(ID_OPEN_AUDIO_CONTROLS_BROWSER, OnOpenAudioControlsEditor)
|
||||
|
||||
ON_COMMAND(ID_DISPLAY_SHOWHELPERS, OnShowHelpers)
|
||||
ON_COMMAND(ID_OPEN_TRACKVIEW, OnOpenTrackView)
|
||||
ON_COMMAND(ID_OPEN_UICANVASEDITOR, OnOpenUICanvasEditor)
|
||||
|
||||
@@ -2617,12 +2616,6 @@ void CCryEditApp::OnUpdateSelected(QAction* action)
|
||||
action->setEnabled(!GetIEditor()->GetSelection()->IsEmpty());
|
||||
}
|
||||
|
||||
void CCryEditApp::OnShowHelpers()
|
||||
{
|
||||
GetIEditor()->GetDisplaySettings()->DisplayHelpers(!GetIEditor()->GetDisplaySettings()->IsDisplayHelpers());
|
||||
GetIEditor()->Notify(eNotify_OnDisplayRenderUpdate);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnEditLevelData()
|
||||
{
|
||||
|
||||
@@ -237,7 +237,6 @@ public:
|
||||
void OnSyncPlayerUpdate(QAction* action);
|
||||
void OnResourcesReduceworkingset();
|
||||
void OnDummyCommand() {};
|
||||
void OnShowHelpers();
|
||||
void OnFileSave();
|
||||
void OnUpdateDocumentReady(QAction* action);
|
||||
void OnUpdateFileOpen(QAction* action);
|
||||
|
||||
@@ -68,8 +68,6 @@ void CDisplaySettings::SetObjectHideMask(int hideMask)
|
||||
m_objectHideMask = hideMask;
|
||||
|
||||
gSettings.objectHideMask = m_objectHideMask;
|
||||
|
||||
GetIEditor()->Notify(eNotify_OnDisplayRenderUpdate);
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include <AzToolsFramework/API/EditorCameraBus.h>
|
||||
#include <AzToolsFramework/API/ViewportEditorModeTrackerInterface.h>
|
||||
#include <AzToolsFramework/Manipulators/ManipulatorManager.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportSettings.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemViewportSelectionRequestBus.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorTransformComponentSelectionRequestBus.h>
|
||||
|
||||
@@ -665,13 +666,7 @@ void EditorViewportWidget::OnBeginPrepareRender()
|
||||
RenderAll();
|
||||
|
||||
// Draw 2D helpers.
|
||||
#ifdef LYSHINE_ATOM_TODO
|
||||
TransformationMatrices backupSceneMatrices;
|
||||
#endif
|
||||
m_debugDisplay->DepthTestOff();
|
||||
#ifdef LYSHINE_ATOM_TODO
|
||||
m_renderer->Set2DMode(m_rcClient.right(), m_rcClient.bottom(), backupSceneMatrices);
|
||||
#endif
|
||||
auto prevState = m_debugDisplay->GetState();
|
||||
m_debugDisplay->SetState(e_Mode3D | e_AlphaBlended | e_FillModeSolid | e_CullModeBack | e_DepthWriteOn | e_DepthTestOn);
|
||||
|
||||
@@ -1627,14 +1622,14 @@ Vec3 EditorViewportWidget::ViewToWorld(
|
||||
auto ray = m_renderViewport->ViewportScreenToWorldRay(AzToolsFramework::ViewportInteraction::ScreenPointFromQPoint(vp));
|
||||
|
||||
const float maxDistance = 10000.f;
|
||||
Vec3 v = AZVec3ToLYVec3(ray.direction) * maxDistance;
|
||||
Vec3 v = AZVec3ToLYVec3(ray.m_direction) * maxDistance;
|
||||
|
||||
if (!_finite(v.x) || !_finite(v.y) || !_finite(v.z))
|
||||
{
|
||||
return Vec3(0, 0, 0);
|
||||
}
|
||||
|
||||
Vec3 colp = AZVec3ToLYVec3(ray.origin) + 0.002f * v;
|
||||
Vec3 colp = AZVec3ToLYVec3(ray.m_origin) + 0.002f * v;
|
||||
|
||||
return colp;
|
||||
}
|
||||
@@ -2426,6 +2421,16 @@ AZ::Vector3 EditorViewportSettings::DefaultEditorCameraPosition() const
|
||||
return SandboxEditor::CameraDefaultEditorPosition();
|
||||
}
|
||||
|
||||
bool EditorViewportSettings::IconsVisible() const
|
||||
{
|
||||
return AzToolsFramework::IconsVisible();
|
||||
}
|
||||
|
||||
bool EditorViewportSettings::HelpersVisible() const
|
||||
{
|
||||
return AzToolsFramework::HelpersVisible();
|
||||
}
|
||||
|
||||
AZ_CVAR_EXTERNED(bool, ed_previewGameInFullscreen_once);
|
||||
|
||||
bool EditorViewportWidget::ShouldPreviewFullscreen() const
|
||||
|
||||
@@ -79,6 +79,8 @@ struct EditorViewportSettings : public AzToolsFramework::ViewportInteraction::Vi
|
||||
float ManipulatorCircleBoundWidth() const override;
|
||||
bool StickySelectEnabled() const override;
|
||||
AZ::Vector3 DefaultEditorCameraPosition() const override;
|
||||
bool IconsVisible() const override;
|
||||
bool HelpersVisible() const override;
|
||||
};
|
||||
|
||||
// EditorViewportWidget window
|
||||
|
||||
@@ -168,8 +168,6 @@ enum EEditorNotifyEvent
|
||||
eNotify_OnVegetationObjectSelection, // When vegetation objects selection change.
|
||||
eNotify_OnVegetationPanelUpdate, // When vegetation objects selection change.
|
||||
|
||||
eNotify_OnDisplayRenderUpdate, // Sent when editor finish terrain texture generation.
|
||||
|
||||
eNotify_OnDataBaseUpdate, // DataBase Library was modified.
|
||||
|
||||
eNotify_OnLayerImportBegin, //layer import was started
|
||||
|
||||
+65
-19
@@ -47,6 +47,7 @@ AZ_POP_DISABLE_WARNING
|
||||
#include <AzToolsFramework/API/EditorAnimationSystemRequestBus.h>
|
||||
#include <AzToolsFramework/SourceControl/QtSourceControlNotificationHandler.h>
|
||||
#include <AzToolsFramework/PythonTerminal/ScriptTermDialog.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportSettings.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorTransformComponentSelectionRequestBus.h>
|
||||
|
||||
// AzQtComponents
|
||||
@@ -445,11 +446,11 @@ void MainWindow::Initialize()
|
||||
{
|
||||
m_viewPaneManager->SetMainWindow(m_viewPaneHost, &m_settings, /*unused*/ QByteArray());
|
||||
|
||||
InitActions();
|
||||
|
||||
RegisterStdViewClasses();
|
||||
InitCentralWidget();
|
||||
|
||||
InitActions();
|
||||
|
||||
// load toolbars ("shelves") and macros
|
||||
GetIEditor()->GetToolBoxManager()->Load(m_actionManager);
|
||||
|
||||
@@ -798,27 +799,40 @@ void MainWindow::InitActions()
|
||||
EditorTransformComponentSelectionRequests::Mode::Scale);
|
||||
});
|
||||
|
||||
am->AddAction(AzToolsFramework::SnapToGrid, tr("Snap to grid"))
|
||||
am->AddAction(AzToolsFramework::SnapToGrid, tr("Grid snapping"))
|
||||
.SetIcon(Style::icon("Grid"))
|
||||
.SetStatusTip(tr("Toggle grid snapping"))
|
||||
.SetShortcut(tr("G"))
|
||||
.SetToolTip(tr("Snap to grid (G)"))
|
||||
.SetStatusTip(tr("Toggles snap to grid"))
|
||||
.SetCheckable(true)
|
||||
.RegisterUpdateCallback([](QAction* action) {
|
||||
Q_ASSERT(action->isCheckable());
|
||||
action->setChecked(SandboxEditor::GridSnappingEnabled());
|
||||
})
|
||||
.Connect(&QAction::triggered, []() { SandboxEditor::SetGridSnapping(!SandboxEditor::GridSnappingEnabled()); });
|
||||
.RegisterUpdateCallback(
|
||||
[](QAction* action)
|
||||
{
|
||||
Q_ASSERT(action->isCheckable());
|
||||
action->setChecked(SandboxEditor::GridSnappingEnabled());
|
||||
})
|
||||
.Connect(
|
||||
&QAction::triggered,
|
||||
[]
|
||||
{
|
||||
SandboxEditor::SetGridSnapping(!SandboxEditor::GridSnappingEnabled());
|
||||
});
|
||||
|
||||
am->AddAction(AzToolsFramework::SnapAngle, tr("Snap angle"))
|
||||
am->AddAction(AzToolsFramework::SnapAngle, tr("Angle snapping"))
|
||||
.SetIcon(Style::icon("Angle"))
|
||||
.SetStatusTip(tr("Snap angle"))
|
||||
.SetStatusTip(tr("Toggle angle snapping"))
|
||||
.SetCheckable(true)
|
||||
.RegisterUpdateCallback([](QAction* action) {
|
||||
Q_ASSERT(action->isCheckable());
|
||||
action->setChecked(SandboxEditor::AngleSnappingEnabled());
|
||||
})
|
||||
.Connect(&QAction::triggered, []() { SandboxEditor::SetAngleSnapping(!SandboxEditor::AngleSnappingEnabled()); });
|
||||
.RegisterUpdateCallback(
|
||||
[](QAction* action)
|
||||
{
|
||||
Q_ASSERT(action->isCheckable());
|
||||
action->setChecked(SandboxEditor::AngleSnappingEnabled());
|
||||
})
|
||||
.Connect(
|
||||
&QAction::triggered,
|
||||
[]
|
||||
{
|
||||
SandboxEditor::SetAngleSnapping(!SandboxEditor::AngleSnappingEnabled());
|
||||
});
|
||||
|
||||
// Display actions
|
||||
am->AddAction(ID_SWITCHCAMERA_DEFAULTCAMERA, tr("Default Camera")).SetCheckable(true)
|
||||
@@ -918,9 +932,41 @@ void MainWindow::InitActions()
|
||||
.SetStatusTip(tr("Cycle 2D Viewport"))
|
||||
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateNonGameMode);
|
||||
#endif
|
||||
am->AddAction(ID_DISPLAY_SHOWHELPERS, tr("Show/Hide Helpers"))
|
||||
am->AddAction(AzToolsFramework::Helpers, tr("Show Helpers"))
|
||||
.SetShortcut(tr("Shift+Space"))
|
||||
.SetToolTip(tr("Show/Hide Helpers (Shift+Space)"));
|
||||
.SetToolTip(tr("Show/Hide Helpers (Shift+Space)"))
|
||||
.SetCheckable(true)
|
||||
.RegisterUpdateCallback(
|
||||
[](QAction* action)
|
||||
{
|
||||
Q_ASSERT(action->isCheckable());
|
||||
action->setChecked(AzToolsFramework::HelpersVisible());
|
||||
})
|
||||
.Connect(
|
||||
&QAction::triggered,
|
||||
[]()
|
||||
{
|
||||
AzToolsFramework::SetHelpersVisible(!AzToolsFramework::HelpersVisible());
|
||||
AzToolsFramework::ViewportInteraction::ViewportSettingsNotificationBus::Broadcast(
|
||||
&AzToolsFramework::ViewportInteraction::ViewportSettingNotifications::OnDrawHelpersChanged,
|
||||
AzToolsFramework::HelpersVisible());
|
||||
});
|
||||
am->AddAction(AzToolsFramework::Icons, tr("Show Icons"))
|
||||
.SetShortcut(tr("Ctrl+Space"))
|
||||
.SetToolTip(tr("Show/Hide Icons (Ctrl+Space)"))
|
||||
.SetCheckable(true)
|
||||
.RegisterUpdateCallback(
|
||||
[](QAction* action)
|
||||
{
|
||||
Q_ASSERT(action->isCheckable());
|
||||
action->setChecked(AzToolsFramework::IconsVisible());
|
||||
})
|
||||
.Connect(
|
||||
&QAction::triggered,
|
||||
[]()
|
||||
{
|
||||
AzToolsFramework::SetIconsVisible(!AzToolsFramework::IconsVisible());
|
||||
});
|
||||
|
||||
// Audio actions
|
||||
am->AddAction(ID_SOUND_STOPALLSOUNDS, tr("Stop All Sounds"))
|
||||
|
||||
@@ -1986,8 +1986,3 @@ void SandboxIntegrationManager::BrowseForAssets(AssetSelectionModel& selection)
|
||||
{
|
||||
AssetBrowserComponentRequestBus::Broadcast(&AssetBrowserComponentRequests::PickAssets, selection, GetMainWindow());
|
||||
}
|
||||
|
||||
bool SandboxIntegrationManager::DisplayHelpersVisible()
|
||||
{
|
||||
return GetIEditor()->GetDisplaySettings()->IsDisplayHelpers();
|
||||
}
|
||||
|
||||
@@ -165,7 +165,6 @@ private:
|
||||
void InstantiateSliceFromAssetId(const AZ::Data::AssetId& assetId) override;
|
||||
void ClearRedoStack() override;
|
||||
int GetIconTextureIdFromEntityIconPath(const AZStd::string& entityIconPath) override;
|
||||
bool DisplayHelpersVisible() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1281,6 +1281,8 @@ void OutlinerWidget::OnSearchTextChanged(const QString& activeTextFilter)
|
||||
|
||||
m_listModel->SearchStringChanged(filterString);
|
||||
m_proxyModel->UpdateFilter();
|
||||
|
||||
m_gui->m_objectTree->expandAll();
|
||||
}
|
||||
|
||||
void OutlinerWidget::OnFilterChanged(const AzQtComponents::SearchTypeFilterList& activeTypeFilters)
|
||||
|
||||
@@ -191,7 +191,6 @@
|
||||
#define ID_BRUSH_CSGSUBSTRUCT 33837
|
||||
#define ID_MATERIAL_PICKTOOL 33842
|
||||
#define ID_MODIFY_AIPOINT_PICKIMPASSLINK 33865
|
||||
#define ID_DISPLAY_SHOWHELPERS 33871
|
||||
#define ID_FILE_EXPORTSELECTION 33875
|
||||
#define ID_EDIT_PASTE_WITH_LINKS 33893
|
||||
#define ID_FILE_EXPORT_TERRAINAREA 33904
|
||||
|
||||
@@ -129,8 +129,8 @@ namespace SandboxEditor
|
||||
ViewportInteractionRequestBus::EventResult(
|
||||
ray, GetViewportId(), &ViewportInteractionRequestBus::Events::ViewportScreenToWorldRay, screenPoint);
|
||||
|
||||
m_mouseInteraction.m_mousePick.m_rayOrigin = ray.origin;
|
||||
m_mouseInteraction.m_mousePick.m_rayDirection = ray.direction;
|
||||
m_mouseInteraction.m_mousePick.m_rayOrigin = ray.m_origin;
|
||||
m_mouseInteraction.m_mousePick.m_rayDirection = ray.m_direction;
|
||||
m_mouseInteraction.m_mousePick.m_screenCoordinates = screenPoint;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Description : CViewportTitleDlg implementation file
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
@@ -42,38 +41,18 @@
|
||||
#include <AzCore/std/algorithm.h>
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportMessages.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportSettings.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorTransformComponentSelectionRequestBus.h>
|
||||
|
||||
#include <LmbrCentral/Audio/AudioSystemComponentBus.h>
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
#include "ui_ViewportTitleDlg.h"
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
#endif //!defined(Q_MOC_RUN)
|
||||
#endif //! defined(Q_MOC_RUN)
|
||||
|
||||
// CViewportTitleDlg dialog
|
||||
|
||||
inline namespace Helpers
|
||||
{
|
||||
void ToggleHelpers()
|
||||
{
|
||||
const bool newValue = !GetIEditor()->GetDisplaySettings()->IsDisplayHelpers();
|
||||
GetIEditor()->GetDisplaySettings()->DisplayHelpers(newValue);
|
||||
GetIEditor()->Notify(eNotify_OnDisplayRenderUpdate);
|
||||
|
||||
if (newValue == false)
|
||||
{
|
||||
GetIEditor()->GetObjectManager()->SendEvent(EVENT_HIDE_HELPER);
|
||||
}
|
||||
AzToolsFramework::ViewportInteraction::ViewportSettingsNotificationBus::Broadcast(
|
||||
&AzToolsFramework::ViewportInteraction::ViewportSettingNotifications::OnDrawHelpersChanged, newValue);
|
||||
}
|
||||
|
||||
bool IsHelpersShown()
|
||||
{
|
||||
return GetIEditor()->GetDisplaySettings()->IsDisplayHelpers();
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
class CViewportTitleDlgDisplayInfoHelper
|
||||
@@ -98,7 +77,7 @@ namespace
|
||||
emit ViewportInfoStatusUpdated(static_cast<int>(state));
|
||||
}
|
||||
};
|
||||
} //end anonymous namespace
|
||||
} // end anonymous namespace
|
||||
|
||||
CViewportTitleDlg::CViewportTitleDlg(QWidget* pParent)
|
||||
: QWidget(pParent)
|
||||
@@ -215,13 +194,65 @@ void CViewportTitleDlg::SetupViewportInformationMenu()
|
||||
m_ui->m_debugInformationMenu->setMenu(GetViewportInformationMenu());
|
||||
connect(m_ui->m_debugInformationMenu, &QToolButton::clicked, this, &CViewportTitleDlg::OnToggleDisplayInfo);
|
||||
m_ui->m_debugInformationMenu->setPopupMode(QToolButton::MenuButtonPopup);
|
||||
|
||||
}
|
||||
|
||||
void CViewportTitleDlg::SetupHelpersButton()
|
||||
{
|
||||
connect(m_ui->m_helpers, &QToolButton::clicked, this, &CViewportTitleDlg::OnToggleHelpers);
|
||||
m_ui->m_helpers->setChecked(Helpers::IsHelpersShown());
|
||||
if (m_helpersMenu == nullptr)
|
||||
{
|
||||
m_helpersMenu = new QMenu("Helpers State", this);
|
||||
|
||||
auto helperAction = MainWindow::instance()->GetActionManager()->GetAction(AzToolsFramework::Helpers);
|
||||
connect(
|
||||
helperAction, &QAction::triggered, this,
|
||||
[this]
|
||||
{
|
||||
m_ui->m_helpers->setChecked(AzToolsFramework::HelpersVisible() || AzToolsFramework::IconsVisible());
|
||||
});
|
||||
|
||||
auto iconAction = MainWindow::instance()->GetActionManager()->GetAction(AzToolsFramework::Icons);
|
||||
connect(
|
||||
iconAction, &QAction::triggered, this,
|
||||
[this]
|
||||
{
|
||||
m_ui->m_helpers->setChecked(AzToolsFramework::HelpersVisible() || AzToolsFramework::IconsVisible());
|
||||
});
|
||||
|
||||
m_helpersAction = new QAction(tr("Helpers"), m_helpersMenu);
|
||||
m_helpersAction->setCheckable(true);
|
||||
connect(
|
||||
m_helpersAction, &QAction::triggered, this,
|
||||
[helperAction]
|
||||
{
|
||||
helperAction->trigger();
|
||||
});
|
||||
|
||||
m_iconsAction = new QAction(tr("Icons"), m_helpersMenu);
|
||||
m_iconsAction->setCheckable(true);
|
||||
connect(
|
||||
m_iconsAction, &QAction::triggered, this,
|
||||
[iconAction]
|
||||
{
|
||||
iconAction->trigger();
|
||||
});
|
||||
|
||||
m_helpersMenu->addAction(m_helpersAction);
|
||||
m_helpersMenu->addAction(m_iconsAction);
|
||||
|
||||
connect(
|
||||
m_helpersMenu, &QMenu::aboutToShow, this,
|
||||
[this]
|
||||
{
|
||||
m_helpersAction->setChecked(AzToolsFramework::HelpersVisible());
|
||||
m_iconsAction->setChecked(AzToolsFramework::IconsVisible());
|
||||
});
|
||||
|
||||
m_ui->m_helpers->setCheckable(true);
|
||||
m_ui->m_helpers->setMenu(m_helpersMenu);
|
||||
m_ui->m_helpers->setPopupMode(QToolButton::InstantPopup);
|
||||
}
|
||||
|
||||
m_ui->m_helpers->setChecked(AzToolsFramework::HelpersVisible() || AzToolsFramework::IconsVisible());
|
||||
}
|
||||
|
||||
void CViewportTitleDlg::SetupOverflowMenu()
|
||||
@@ -279,15 +310,20 @@ void CViewportTitleDlg::SetupOverflowMenu()
|
||||
UpdateMuteActionText();
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CViewportTitleDlg::SetViewPane(CLayoutViewPane* pViewPane)
|
||||
{
|
||||
if (m_pViewPane)
|
||||
{
|
||||
m_pViewPane->disconnect(this);
|
||||
}
|
||||
|
||||
m_pViewPane = pViewPane;
|
||||
|
||||
if (m_pViewPane)
|
||||
{
|
||||
connect(this, &QWidget::customContextMenuRequested, m_pViewPane, &CLayoutViewPane::ShowTitleMenu);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -318,7 +354,6 @@ void CViewportTitleDlg::OnInitDialog()
|
||||
m_ui->m_prefabFocusPath->hide();
|
||||
m_ui->m_prefabFocusBackButton->hide();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -336,13 +371,6 @@ void CViewportTitleDlg::OnMaximize()
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CViewportTitleDlg::OnToggleHelpers()
|
||||
{
|
||||
Helpers::ToggleHelpers();
|
||||
m_ui->m_helpers->setChecked(Helpers::IsHelpersShown());
|
||||
}
|
||||
|
||||
void CViewportTitleDlg::SetNoViewportInfo()
|
||||
{
|
||||
AZ::AtomBridge::AtomViewportInfoDisplayRequestBus::Broadcast(
|
||||
@@ -367,7 +395,6 @@ void CViewportTitleDlg::SetCompactViewportInfo()
|
||||
&AZ::AtomBridge::AtomViewportInfoDisplayRequestBus::Events::SetDisplayState, AZ::AtomBridge::ViewportInfoDisplayState::CompactInfo);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CViewportTitleDlg::UpdateDisplayInfo()
|
||||
{
|
||||
@@ -783,9 +810,6 @@ void CViewportTitleDlg::OnEditorNotifyEvent(EEditorNotifyEvent event)
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
case eNotify_OnDisplayRenderUpdate:
|
||||
m_ui->m_helpers->setChecked(Helpers::IsHelpersShown());
|
||||
break;
|
||||
case eNotify_OnBeginGameMode:
|
||||
case eNotify_OnEndGameMode:
|
||||
UpdateMuteActionText();
|
||||
@@ -997,24 +1021,18 @@ void CViewportTitleDlg::UpdateOverFlowMenuState()
|
||||
m_angleSizeActionWidget->setEnabled(angleSnappingActive);
|
||||
}
|
||||
|
||||
namespace
|
||||
namespace
|
||||
{
|
||||
void PyToggleHelpers()
|
||||
{
|
||||
GetIEditor()->GetDisplaySettings()->DisplayHelpers(!GetIEditor()->GetDisplaySettings()->IsDisplayHelpers());
|
||||
GetIEditor()->Notify(eNotify_OnDisplayRenderUpdate);
|
||||
|
||||
if (GetIEditor()->GetDisplaySettings()->IsDisplayHelpers() == false)
|
||||
{
|
||||
GetIEditor()->GetObjectManager()->SendEvent(EVENT_HIDE_HELPER);
|
||||
}
|
||||
AzToolsFramework::SetHelpersVisible(!AzToolsFramework::HelpersVisible());
|
||||
}
|
||||
|
||||
bool PyIsHelpersShown()
|
||||
{
|
||||
return GetIEditor()->GetDisplaySettings()->IsDisplayHelpers();
|
||||
return AzToolsFramework::HelpersVisible();
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
@@ -1029,11 +1047,12 @@ namespace AzToolsFramework
|
||||
->Attribute(AZ::Script::Attributes::Category, "Legacy/Editor")
|
||||
->Attribute(AZ::Script::Attributes::Module, "legacy.general");
|
||||
};
|
||||
|
||||
addLegacyGeneral(behaviorContext->Method("toggle_helpers", PyToggleHelpers, nullptr, "Toggles the display of helpers."));
|
||||
addLegacyGeneral(behaviorContext->Method("is_helpers_shown", PyIsHelpersShown, nullptr, "Gets the display state of helpers."));
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
#include "ViewportTitleDlg.moc"
|
||||
#include <moc_ViewportTitleDlg.cpp>
|
||||
|
||||
@@ -80,7 +80,6 @@ protected:
|
||||
void OnSystemEvent(ESystemEvent event, UINT_PTR wparam, UINT_PTR lparam) override;
|
||||
|
||||
void OnMaximize();
|
||||
void OnToggleHelpers();
|
||||
void UpdateDisplayInfo();
|
||||
|
||||
void SetupCameraDropdownMenu();
|
||||
@@ -153,6 +152,9 @@ protected:
|
||||
QMenu* m_aspectMenu = nullptr;
|
||||
QMenu* m_resolutionMenu = nullptr;
|
||||
QMenu* m_viewportInformationMenu = nullptr;
|
||||
QMenu* m_helpersMenu = nullptr;
|
||||
QAction* m_helpersAction = nullptr;
|
||||
QAction* m_iconsAction = nullptr;
|
||||
QAction* m_noInformationAction = nullptr;
|
||||
QAction* m_normalInformationAction = nullptr;
|
||||
QAction* m_fullInformationAction = nullptr;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
namespace AZ::Data
|
||||
{
|
||||
namespace Internal
|
||||
namespace DataStreamInternal
|
||||
{
|
||||
struct AssetDataStreamPrivate
|
||||
{
|
||||
@@ -39,7 +39,7 @@ namespace AZ::Data
|
||||
}
|
||||
void BlockUntilReadComplete()
|
||||
{
|
||||
AZStd::unique_lock<AZStd::mutex> lock(m_readRequestMutex);
|
||||
AZStd::unique_lock lock(m_readRequestMutex);
|
||||
m_readRequestActive.wait(
|
||||
lock,
|
||||
[this]
|
||||
@@ -59,9 +59,10 @@ namespace AZ::Data
|
||||
}
|
||||
};
|
||||
} // namespace Internal
|
||||
|
||||
AssetDataStream::AssetDataStream(AZ::IO::IStreamerTypes::RequestMemoryAllocator* bufferAllocator)
|
||||
: m_bufferAllocator(bufferAllocator ? bufferAllocator : &m_defaultAllocator)
|
||||
, m_privateData(new Internal::AssetDataStreamPrivate)
|
||||
: m_privateData(AZStd::make_unique<DataStreamInternal::AssetDataStreamPrivate>())
|
||||
, m_bufferAllocator(bufferAllocator ? bufferAllocator : &m_defaultAllocator)
|
||||
{
|
||||
ClearInternalStateData();
|
||||
}
|
||||
@@ -72,7 +73,6 @@ namespace AZ::Data
|
||||
{
|
||||
Close();
|
||||
}
|
||||
delete m_privateData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
#include <AzCore/IO/GenericStreams.h>
|
||||
#include <AzCore/IO/IStreamerTypes.h>
|
||||
#include <AzCore/std/function/function_template.h>
|
||||
|
||||
#include <AzCore/std/functional.h>
|
||||
#include <AzCore/std/smart_ptr/unique_ptr.h>
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
@@ -20,7 +20,7 @@ namespace AZStd
|
||||
|
||||
namespace AZ::Data
|
||||
{
|
||||
namespace Internal
|
||||
namespace DataStreamInternal
|
||||
{
|
||||
struct AssetDataStreamPrivate;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ namespace AZ::Data
|
||||
|
||||
void ClearInternalStateData();
|
||||
|
||||
Internal::AssetDataStreamPrivate* m_privateData;
|
||||
AZStd::unique_ptr<DataStreamInternal::AssetDataStreamPrivate> m_privateData;
|
||||
|
||||
//! The allocator to use for allocating / deallocating asset buffers
|
||||
AZ::IO::IStreamerTypes::RequestMemoryAllocator* m_bufferAllocator{ nullptr };
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace AZ::IO
|
||||
void CreateDedicatedCache(FileRequest* request, Requests::CreateDedicatedCacheData& data);
|
||||
void DestroyDedicatedCache(FileRequest* request, Requests::DestroyDedicatedCacheData& data);
|
||||
|
||||
void ReadFile(FileRequest* request, AZ::IO::Requests::ReadData& data);
|
||||
void ReadFile(FileRequest* request, Requests::ReadData& data);
|
||||
size_t FindCache(const RequestPath& filename, FileRange range);
|
||||
size_t FindCache(const RequestPath& filename, u64 offset);
|
||||
|
||||
|
||||
@@ -153,7 +153,6 @@ namespace AZ::IO::Requests
|
||||
|
||||
namespace AZ::IO
|
||||
{
|
||||
using namespace Requests;
|
||||
//
|
||||
// FileRequest
|
||||
//
|
||||
@@ -176,14 +175,14 @@ namespace AZ::IO
|
||||
m_parent = request->m_request.m_parent;
|
||||
request->m_request.m_parent = this;
|
||||
m_dependencies++;
|
||||
m_command.emplace<ExternalRequestData>(AZStd::move(request));
|
||||
m_command.emplace<Requests::ExternalRequestData>(AZStd::move(request));
|
||||
}
|
||||
|
||||
void FileRequest::CreateRequestPathStore(FileRequest* parent, RequestPath path)
|
||||
{
|
||||
AZ_Assert(AZStd::holds_alternative<AZStd::monostate>(m_command),
|
||||
"Attempting to set FileRequest to 'CreateRequestPathStore', but another task was already assigned.");
|
||||
m_command.emplace<RequestPathStoreData>(AZStd::move(path));
|
||||
m_command.emplace<Requests::RequestPathStoreData>(AZStd::move(path));
|
||||
SetOptionalParent(parent);
|
||||
}
|
||||
|
||||
@@ -192,7 +191,7 @@ namespace AZ::IO
|
||||
{
|
||||
AZ_Assert(AZStd::holds_alternative<AZStd::monostate>(m_command),
|
||||
"Attempting to set FileRequest to 'ReadRequest', but another task was already assigned.");
|
||||
m_command.emplace<ReadRequestData>(AZStd::move(path), output, outputSize, offset, size, deadline, priority);
|
||||
m_command.emplace<Requests::ReadRequestData>(AZStd::move(path), output, outputSize, offset, size, deadline, priority);
|
||||
}
|
||||
|
||||
void FileRequest::CreateReadRequest(RequestPath path, IStreamerTypes::RequestMemoryAllocator* allocator, u64 offset, u64 size,
|
||||
@@ -200,7 +199,7 @@ namespace AZ::IO
|
||||
{
|
||||
AZ_Assert(AZStd::holds_alternative<AZStd::monostate>(m_command),
|
||||
"Attempting to set FileRequest to 'ReadRequest', but another task was already assigned.");
|
||||
m_command.emplace<ReadRequestData>(AZStd::move(path), allocator, offset, size, deadline, priority);
|
||||
m_command.emplace<Requests::ReadRequestData>(AZStd::move(path), allocator, offset, size, deadline, priority);
|
||||
}
|
||||
|
||||
void FileRequest::CreateRead(FileRequest* parent, void* output, u64 outputSize, const RequestPath& path,
|
||||
@@ -208,7 +207,7 @@ namespace AZ::IO
|
||||
{
|
||||
AZ_Assert(AZStd::holds_alternative<AZStd::monostate>(m_command),
|
||||
"Attempting to set FileRequest to 'Read', but another task was already assigned.");
|
||||
m_command.emplace<ReadData>(output, outputSize, AZStd::move(path), offset, size, sharedRead);
|
||||
m_command.emplace<Requests::ReadData>(output, outputSize, AZStd::move(path), offset, size, sharedRead);
|
||||
SetOptionalParent(parent);
|
||||
}
|
||||
|
||||
@@ -223,7 +222,7 @@ namespace AZ::IO
|
||||
{
|
||||
AZ_Assert(AZStd::holds_alternative<AZStd::monostate>(m_command),
|
||||
"Attempting to set FileRequest to 'CompressedRead', but another task was already assigned.");
|
||||
m_command.emplace<CompressedReadData>(AZStd::move(compressionInfo), output, readOffset, readSize);
|
||||
m_command.emplace<Requests::CompressedReadData>(AZStd::move(compressionInfo), output, readOffset, readSize);
|
||||
SetOptionalParent(parent);
|
||||
}
|
||||
|
||||
@@ -231,7 +230,7 @@ namespace AZ::IO
|
||||
{
|
||||
AZ_Assert(AZStd::holds_alternative<AZStd::monostate>(m_command),
|
||||
"Attempting to set FileRequest to 'Wait', but another task was already assigned.");
|
||||
m_command.emplace<WaitData>();
|
||||
m_command.emplace<Requests::WaitData>();
|
||||
SetOptionalParent(parent);
|
||||
}
|
||||
|
||||
@@ -239,21 +238,21 @@ namespace AZ::IO
|
||||
{
|
||||
AZ_Assert(AZStd::holds_alternative<AZStd::monostate>(m_command),
|
||||
"Attempting to set FileRequest to 'FileExistsCheck', but another task was already assigned.");
|
||||
m_command.emplace<FileExistsCheckData>(path);
|
||||
m_command.emplace<Requests::FileExistsCheckData>(path);
|
||||
}
|
||||
|
||||
void FileRequest::CreateFileMetaDataRetrieval(const RequestPath& path)
|
||||
{
|
||||
AZ_Assert(AZStd::holds_alternative<AZStd::monostate>(m_command),
|
||||
"Attempting to set FileRequest to 'FileMetaDataRetrieval', but another task was already assigned.");
|
||||
m_command.emplace<FileMetaDataRetrievalData>(path);
|
||||
m_command.emplace<Requests::FileMetaDataRetrievalData>(path);
|
||||
}
|
||||
|
||||
void FileRequest::CreateCancel(FileRequestPtr target)
|
||||
{
|
||||
AZ_Assert(AZStd::holds_alternative<AZStd::monostate>(m_command),
|
||||
"Attempting to set FileRequest to 'Cancel', but another task was already assigned.");
|
||||
m_command.emplace<CancelData>(AZStd::move(target));
|
||||
m_command.emplace<Requests::CancelData>(AZStd::move(target));
|
||||
}
|
||||
|
||||
void FileRequest::CreateReschedule(FileRequestPtr target, AZStd::chrono::system_clock::time_point newDeadline,
|
||||
@@ -261,28 +260,28 @@ namespace AZ::IO
|
||||
{
|
||||
AZ_Assert(AZStd::holds_alternative<AZStd::monostate>(m_command),
|
||||
"Attempting to set FileRequest to 'Reschedule', but another task was already assigned.");
|
||||
m_command.emplace<RescheduleData>(AZStd::move(target), newDeadline, newPriority);
|
||||
m_command.emplace<Requests::RescheduleData>(AZStd::move(target), newDeadline, newPriority);
|
||||
}
|
||||
|
||||
void FileRequest::CreateFlush(RequestPath path)
|
||||
{
|
||||
AZ_Assert(AZStd::holds_alternative<AZStd::monostate>(m_command),
|
||||
"Attempting to set FileRequest to 'Flush', but another task was already assigned.");
|
||||
m_command.emplace<FlushData>(AZStd::move(path));
|
||||
m_command.emplace<Requests::FlushData>(AZStd::move(path));
|
||||
}
|
||||
|
||||
void FileRequest::CreateFlushAll()
|
||||
{
|
||||
AZ_Assert(AZStd::holds_alternative<AZStd::monostate>(m_command),
|
||||
"Attempting to set FileRequest to 'FlushAll', but another task was already assigned.");
|
||||
m_command.emplace<FlushAllData>();
|
||||
m_command.emplace<Requests::FlushAllData>();
|
||||
}
|
||||
|
||||
void FileRequest::CreateDedicatedCacheCreation(RequestPath path, const FileRange& range, FileRequest* parent)
|
||||
{
|
||||
AZ_Assert(AZStd::holds_alternative<AZStd::monostate>(m_command),
|
||||
"Attempting to set FileRequest to 'CreateDedicateCache', but another task was already assigned.");
|
||||
m_command.emplace<CreateDedicatedCacheData>(AZStd::move(path), range);
|
||||
m_command.emplace<Requests::CreateDedicatedCacheData>(AZStd::move(path), range);
|
||||
SetOptionalParent(parent);
|
||||
}
|
||||
|
||||
@@ -290,7 +289,7 @@ namespace AZ::IO
|
||||
{
|
||||
AZ_Assert(AZStd::holds_alternative<AZStd::monostate>(m_command),
|
||||
"Attempting to set FileRequest to 'DestroyDedicateCache', but another task was already assigned.");
|
||||
m_command.emplace<DestroyDedicatedCacheData>(AZStd::move(path), range);
|
||||
m_command.emplace<Requests::DestroyDedicatedCacheData>(AZStd::move(path), range);
|
||||
SetOptionalParent(parent);
|
||||
}
|
||||
|
||||
@@ -298,14 +297,14 @@ namespace AZ::IO
|
||||
{
|
||||
AZ_Assert(AZStd::holds_alternative<AZStd::monostate>(m_command),
|
||||
"Attempting to set FileRequest to 'Report', but another task was already assigned.");
|
||||
m_command.emplace<ReportData>(reportType);
|
||||
m_command.emplace<Requests::ReportData>(reportType);
|
||||
}
|
||||
|
||||
void FileRequest::CreateCustom(AZStd::any data, bool failWhenUnhandled, FileRequest* parent)
|
||||
{
|
||||
AZ_Assert(AZStd::holds_alternative<AZStd::monostate>(m_command),
|
||||
"Attempting to set FileRequest to 'Custom', but another task was already assigned.");
|
||||
m_command.emplace<CustomData>(AZStd::move(data), failWhenUnhandled);
|
||||
m_command.emplace<Requests::CustomData>(AZStd::move(data), failWhenUnhandled);
|
||||
SetOptionalParent(parent);
|
||||
}
|
||||
|
||||
@@ -429,7 +428,7 @@ namespace AZ::IO
|
||||
const FileRequest* current = this;
|
||||
while (current)
|
||||
{
|
||||
auto* link = AZStd::get_if<ExternalRequestData>(¤t->m_command);
|
||||
auto* link = AZStd::get_if<Requests::ExternalRequestData>(¤t->m_command);
|
||||
if (!link)
|
||||
{
|
||||
current = current->m_parent;
|
||||
|
||||
@@ -343,7 +343,7 @@ namespace AZ::IO
|
||||
m_numRunningJobs == 0;
|
||||
}
|
||||
|
||||
void FullFileDecompressor::PrepareReadRequest(FileRequest* request, Requests::ReadRequestData &data)
|
||||
void FullFileDecompressor::PrepareReadRequest(FileRequest* request, Requests::ReadRequestData& data)
|
||||
{
|
||||
CompressionInfo info;
|
||||
if (CompressionUtils::FindCompressionInfo(info, data.m_path.GetRelativePath()))
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
#include <AzCore/IO/Streamer/Scheduler.h>
|
||||
|
||||
#include <AzCore/IO/Streamer/FileRequest.h>
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
#include <AzCore/Debug/Profiler.h>
|
||||
#include <AzCore/IO/Streamer/FileRequest.h>
|
||||
#include <AzCore/std/containers/deque.h>
|
||||
#include <AzCore/std/sort.h>
|
||||
|
||||
@@ -37,9 +37,7 @@ namespace AZ::IO
|
||||
m_threadData.m_streamStack = AZStd::move(streamStack);
|
||||
}
|
||||
|
||||
Scheduler::~Scheduler()
|
||||
{
|
||||
}
|
||||
Scheduler::~Scheduler() = default;
|
||||
|
||||
void Scheduler::Start(const AZStd::thread_desc& threadDesc)
|
||||
{
|
||||
|
||||
@@ -60,13 +60,13 @@ namespace AZ::IO
|
||||
AZ_PROFILE_FUNCTION(AzCore);
|
||||
AZ_Assert(request, "PrepareRequest was provided a null request.");
|
||||
|
||||
if (AZStd::holds_alternative<Requests::ReadRequestData>(request->GetCommand()))
|
||||
if (AZStd::holds_alternative<Requests::ReadRequestData>(request->GetCommand()))
|
||||
{
|
||||
auto& readRequest = AZStd::get<Requests::ReadRequestData>(request->GetCommand());
|
||||
auto& readRequest = AZStd::get<Requests::ReadRequestData>(request->GetCommand());
|
||||
|
||||
FileRequest* read = m_context->GetNewInternalRequest();
|
||||
read->CreateRead(request, readRequest.m_output, readRequest.m_outputSize, readRequest.m_path,
|
||||
readRequest.m_offset, readRequest.m_size);
|
||||
read->CreateRead(
|
||||
request, readRequest.m_output, readRequest.m_outputSize, readRequest.m_path, readRequest.m_offset, readRequest.m_size);
|
||||
m_context->PushPreparedRequest(read);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -23,9 +23,8 @@ namespace AZ
|
||||
static constexpr char MissedDeadlinesName[] = "Missed deadlines";
|
||||
#endif // AZ_STREAMER_ADD_EXTRA_PROFILING_INFO
|
||||
|
||||
StreamerContext::StreamerContext()
|
||||
{
|
||||
}
|
||||
StreamerContext::StreamerContext() = default;
|
||||
|
||||
StreamerContext::~StreamerContext()
|
||||
{
|
||||
for (FileRequest* entry : m_internalRecycleBin)
|
||||
@@ -228,7 +227,7 @@ namespace AZ
|
||||
top->m_onCompletion(*top);
|
||||
AZ_PROFILE_INTERVAL_END(AzCore, top);
|
||||
}
|
||||
|
||||
|
||||
if (parent)
|
||||
{
|
||||
AZ_Assert(parent->m_dependencies > 0,
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/IO/Streamer/Statistics.h>
|
||||
#include <AzCore/IO/Streamer/StreamerConfiguration.h>
|
||||
#include <AzCore/IO/Streamer/StreamerContext_Platform.h>
|
||||
#include <AzCore/Statistics/RunningStatistic.h>
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/std/containers/deque.h>
|
||||
#include <AzCore/std/containers/queue.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
|
||||
@@ -254,13 +254,13 @@ namespace AZ
|
||||
Method("CreateFromMatrix3x3", &Quaternion::CreateFromMatrix3x3)->
|
||||
Method("CreateFromMatrix4x4", &Quaternion::CreateFromMatrix4x4)->
|
||||
Method("CreateFromAxisAngle", &Quaternion::CreateFromAxisAngle)->
|
||||
Method("CreateFromScaledAxisAngle", &Quaternion::CreateFromScaledAxisAngle)->
|
||||
Method("CreateShortestArc", &Quaternion::CreateShortestArc)->
|
||||
Method("CreateFromEulerAnglesDegrees", &Quaternion::CreateFromEulerAnglesDegrees)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Quaternion Quaternion::CreateFromMatrix3x3(const Matrix3x3& m)
|
||||
{
|
||||
return CreateFromBasis(m.GetBasisX(), m.GetBasisY(), m.GetBasisZ());
|
||||
@@ -430,4 +430,24 @@ namespace AZ
|
||||
outAngle = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vector3 Quaternion::ConvertToScaledAxisAngle() const
|
||||
{
|
||||
// Take the log of the quaternion to convert it to the exponential map
|
||||
// and multiply it by 2.0 to bring it into the scaled axis-angle representation.
|
||||
const AZ::Vector3 imaginary = GetImaginary();
|
||||
const float length = imaginary.GetLength();
|
||||
if (length < AZ::Constants::FloatEpsilon)
|
||||
{
|
||||
return imaginary * 2.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
const float halfAngle = acosf(AZ::GetClamp(GetW(), -1.0f, 1.0f));
|
||||
|
||||
// Multiply by 2.0 to convert the half angle into the full one.
|
||||
return halfAngle * 2.0f * (imaginary / length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +77,9 @@ namespace AZ
|
||||
|
||||
static Quaternion CreateFromAxisAngle(const Vector3& axis, float angle);
|
||||
|
||||
//! Create a quaternion from a scaled axis-angle representation.
|
||||
static Quaternion CreateFromScaledAxisAngle(const Vector3& scaledAxisAngle);
|
||||
|
||||
static Quaternion CreateShortestArc(const Vector3& v1, const Vector3& v2);
|
||||
|
||||
//! Creates a quaternion using rotation in degrees about the axes. First rotated about the X axis, followed by the Y axis, then the Z axis.
|
||||
@@ -231,6 +234,9 @@ namespace AZ
|
||||
//! @param[out] outAngle A float rotation angle around the axis in radians.
|
||||
void ConvertToAxisAngle(Vector3& outAxis, float& outAngle) const;
|
||||
|
||||
//! Convert the quaternion into scaled axis-angle representation.
|
||||
Vector3 ConvertToScaledAxisAngle() const;
|
||||
|
||||
//! Returns the imaginary (X/Y/Z) portion of the quaternion.
|
||||
Vector3 GetImaginary() const;
|
||||
|
||||
|
||||
@@ -109,6 +109,24 @@ namespace AZ
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE Quaternion Quaternion::CreateFromScaledAxisAngle(const Vector3& scaledAxisAngle)
|
||||
{
|
||||
const AZ::Vector3 exponentialMap = scaledAxisAngle / 2.0f;
|
||||
const float halfAngle = exponentialMap.GetLength();
|
||||
|
||||
if (halfAngle < AZ::Constants::FloatEpsilon)
|
||||
{
|
||||
return AZ::Quaternion::CreateFromVector3AndValue(exponentialMap, 1.0f).GetNormalized();
|
||||
}
|
||||
else
|
||||
{
|
||||
float sin, cos;
|
||||
SinCos(halfAngle, sin, cos);
|
||||
return AZ::Quaternion::CreateFromVector3AndValue((sin / halfAngle) * exponentialMap, cos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE void Quaternion::StoreToFloat4(float* values) const
|
||||
{
|
||||
Simd::Vec4::StoreUnaligned(values, m_value);
|
||||
|
||||
@@ -105,6 +105,8 @@ void ScriptContextDebug::ConnectHook()
|
||||
void ScriptContextDebug::DisconnectHook()
|
||||
{
|
||||
lua_sethook(m_context.NativeContext(), nullptr, 0, 0);
|
||||
m_currentStackLevel = -1;
|
||||
m_stepStackLevel = -1;
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
@@ -651,6 +653,11 @@ void AZ::LuaHook(lua_State* l, lua_Debug* ar)
|
||||
context->PopCallstack();
|
||||
}
|
||||
context->m_currentStackLevel--;
|
||||
|
||||
if (context->m_currentStackLevel == -1)
|
||||
{
|
||||
context->m_stepStackLevel = -1;
|
||||
}
|
||||
}
|
||||
else if (ar->event == LUA_HOOKLINE)
|
||||
{
|
||||
@@ -731,7 +738,7 @@ void AZ::LuaHook(lua_State* l, lua_Debug* ar)
|
||||
//}
|
||||
}
|
||||
|
||||
if (doBreak)
|
||||
if (doBreak && bp->m_lineNumber > 0)
|
||||
{
|
||||
context->m_luaDebug = ar;
|
||||
context->m_breakCallback(context, bp);
|
||||
|
||||
@@ -62,6 +62,7 @@ namespace AZ
|
||||
TimeSystem::TimeSystem()
|
||||
{
|
||||
m_lastInvokedTimeUs = static_cast<TimeUs>(AZStd::GetTimeNowMicroSecond());
|
||||
m_realLastInvokedTimeUs = static_cast<TimeUs>(AZStd::GetTimeNowMicroSecond());
|
||||
AZ::Interface<ITime>::Register(this);
|
||||
ITimeRequestBus::Handler::BusConnect();
|
||||
}
|
||||
@@ -101,7 +102,11 @@ namespace AZ
|
||||
|
||||
TimeUs TimeSystem::GetRealElapsedTimeUs() const
|
||||
{
|
||||
return static_cast<TimeUs>(AZStd::GetTimeNowMicroSecond());
|
||||
const TimeUs currentTime = static_cast<TimeUs>(AZStd::GetTimeNowMicroSecond());
|
||||
m_realAccumulatedTimeUs += currentTime - m_realLastInvokedTimeUs;
|
||||
m_realLastInvokedTimeUs = currentTime;
|
||||
|
||||
return m_realAccumulatedTimeUs;
|
||||
}
|
||||
|
||||
TimeUs TimeSystem::GetSimulationTickDeltaTimeUs() const
|
||||
|
||||
@@ -64,6 +64,14 @@ namespace AZ
|
||||
//! Mutable to allow GetElapsedTimeMs/TimeUs() to be a const functions.
|
||||
mutable TimeUs m_accumulatedTimeUs = AZ::Time::ZeroTimeUs;
|
||||
|
||||
//! Used to calculate the delta time between calls to GetRealElapsedTimeMs/TimeUs().
|
||||
//! Mutable to allow GetRealElapsedTimeMs/TimeUs() to be a const functions.
|
||||
mutable TimeUs m_realLastInvokedTimeUs = AZ::Time::ZeroTimeUs;
|
||||
|
||||
//! Accumulates the delta time of GetRealElapsedTimeMs/TimeUs() calls.
|
||||
//! Mutable to allow GetRealElapsedTimeMs/TimeUs() to be a const functions.
|
||||
mutable TimeUs m_realAccumulatedTimeUs = AZ::Time::ZeroTimeUs;
|
||||
|
||||
//! The current game tick delta time.
|
||||
//! Can be affected by time system cvars.
|
||||
//! Updated in AdvanceTickDeltaTimes().
|
||||
|
||||
@@ -69,6 +69,15 @@ namespace UnitTest
|
||||
return numAssertsFailed;
|
||||
}
|
||||
|
||||
void ResetSuppressionSettingsToDefault()
|
||||
{
|
||||
m_suppressErrors = true;
|
||||
m_suppressWarnings = true;
|
||||
m_suppressAsserts = true;
|
||||
m_suppressOutput = true;
|
||||
m_suppressPrintf = true;
|
||||
}
|
||||
|
||||
bool m_isAssertTest;
|
||||
bool m_suppressErrors = true;
|
||||
bool m_suppressWarnings = true;
|
||||
|
||||
+22
-20
@@ -254,27 +254,29 @@ namespace AZ::IO
|
||||
else if (!m_pendingRequests.empty())
|
||||
{
|
||||
FileRequest* request = m_pendingRequests.front();
|
||||
hasWorked = AZStd::visit([this, request](auto&& args)
|
||||
{
|
||||
using Command = AZStd::decay_t<decltype(args)>;
|
||||
hasWorked = AZStd::visit(
|
||||
[this, request](auto&& args)
|
||||
{
|
||||
using Command = AZStd::decay_t<decltype(args)>;
|
||||
if constexpr (AZStd::is_same_v<Command, Requests::FileExistsCheckData>)
|
||||
{
|
||||
FileExistsRequest(request);
|
||||
m_pendingRequests.pop_front();
|
||||
return true;
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, Requests::FileMetaDataRetrievalData>)
|
||||
{
|
||||
FileMetaDataRetrievalRequest(request);
|
||||
m_pendingRequests.pop_front();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "A request was added to StorageDriveWin's pending queue that isn't supported.");
|
||||
return false;
|
||||
}
|
||||
}, request->GetCommand());
|
||||
{
|
||||
FileExistsRequest(request);
|
||||
m_pendingRequests.pop_front();
|
||||
return true;
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, Requests::FileMetaDataRetrievalData>)
|
||||
{
|
||||
FileMetaDataRetrievalRequest(request);
|
||||
m_pendingRequests.pop_front();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "A request was added to StorageDriveWin's pending queue that isn't supported.");
|
||||
return false;
|
||||
}
|
||||
},
|
||||
request->GetCommand());
|
||||
}
|
||||
|
||||
return StreamStackEntry::ExecuteRequests() || hasFinalizedReads || hasWorked;
|
||||
|
||||
@@ -408,4 +408,106 @@ namespace UnitTest
|
||||
Matrix4x4 m = Matrix4x4::CreateFromQuaternion(rotQuat);
|
||||
AZ_TEST_ASSERT(m.IsClose(rotMatrix));
|
||||
}
|
||||
|
||||
class QuaternionScaledAxisAngleConversionFixture
|
||||
: public ::testing::TestWithParam<AZ::Quaternion>
|
||||
{
|
||||
public:
|
||||
AZ::Quaternion GetAbs(const AZ::Quaternion& in)
|
||||
{
|
||||
// Take the shortest path for quaternions containing rotations bigger than 180.0°.
|
||||
if (in.GetW() < 0.0f)
|
||||
{
|
||||
return -in;
|
||||
}
|
||||
|
||||
return in;
|
||||
}
|
||||
};
|
||||
|
||||
static const AZ::Quaternion RotationRepresentationConversionTestQuats[] =
|
||||
{
|
||||
AZ::Quaternion::CreateIdentity(),
|
||||
-AZ::Quaternion::CreateIdentity(),
|
||||
AZ::Quaternion::CreateRotationX(AZ::Constants::TwoPi),
|
||||
AZ::Quaternion::CreateRotationY(AZ::Constants::Pi),
|
||||
AZ::Quaternion::CreateRotationZ(AZ::Constants::HalfPi),
|
||||
AZ::Quaternion::CreateRotationX(AZ::Constants::QuarterPi),
|
||||
AZ::Quaternion(0.64f, 0.36f, 0.48f, 0.48f),
|
||||
AZ::Quaternion(0.70f, -0.34f, 0.10f, 0.62f),
|
||||
AZ::Quaternion(-0.38f, 0.34f, 0.70f, -0.50f),
|
||||
AZ::Quaternion(0.70f, -0.34f, -0.38f, 0.50f),
|
||||
AZ::Quaternion(0.00f, 0.00f, -0.28f, 0.96f),
|
||||
AZ::Quaternion(0.24f, -0.64f, 0.72f, 0.12f),
|
||||
AZ::Quaternion(-0.66f, 0.62f, 0.42f, 0.06f)
|
||||
};
|
||||
|
||||
TEST_P(QuaternionScaledAxisAngleConversionFixture, ScaledAxisAngleQuatRoundtripTests)
|
||||
{
|
||||
const AZ::Quaternion testQuat = GetAbs(GetParam());
|
||||
|
||||
// Convert test quaternion to scaled axis-angle representation.
|
||||
const AZ::Vector3 scaledAxisAngle = testQuat.ConvertToScaledAxisAngle();
|
||||
|
||||
// Convert the scaled axis-angle back into a quaternion.
|
||||
AZ::Quaternion backFromScaledAxisAngle = AZ::Quaternion::CreateFromScaledAxisAngle(scaledAxisAngle);
|
||||
|
||||
// Compare the original quaternion with the one after the conversion.
|
||||
EXPECT_TRUE(testQuat.IsClose(backFromScaledAxisAngle, 1e-6f));
|
||||
}
|
||||
|
||||
TEST_P(QuaternionScaledAxisAngleConversionFixture, AxisAngleQuatRoundtripTests)
|
||||
{
|
||||
const AZ::Quaternion testQuat = GetAbs(GetParam());
|
||||
|
||||
// Convert test quaternion to axis-angle representation.
|
||||
AZ::Vector3 axis;
|
||||
float angle;
|
||||
testQuat.ConvertToAxisAngle(axis, angle);
|
||||
|
||||
// Convert the axis-angle back into a quaternion and compare the original quaternion with the one after the conversion.
|
||||
const AZ::Quaternion backFromAxisAngle = AZ::Quaternion::CreateFromAxisAngle(axis, angle);
|
||||
EXPECT_TRUE(testQuat.IsClose(backFromAxisAngle, 1e-6f));
|
||||
}
|
||||
|
||||
TEST_P(QuaternionScaledAxisAngleConversionFixture, CompareAxisAngleConversionTests)
|
||||
{
|
||||
const AZ::Quaternion testQuat = GetAbs(GetParam());
|
||||
|
||||
// Convert test quaternion to scaled axis-angle representation.
|
||||
const AZ::Vector3 scaledAxisAngle = testQuat.ConvertToScaledAxisAngle();
|
||||
|
||||
// Convert test quaternion to axis-angle representation and scale it manually.
|
||||
AZ::Vector3 axis;
|
||||
float angle;
|
||||
testQuat.ConvertToAxisAngle(axis, angle);
|
||||
|
||||
// Compare the scaled result to the version from the helper that directly converts it to scaled axis-angle.
|
||||
AZ::Vector3 scaledResult = axis*angle;
|
||||
EXPECT_TRUE(scaledResult.IsClose(scaledAxisAngle, 1e-5f));
|
||||
}
|
||||
|
||||
TEST_P(QuaternionScaledAxisAngleConversionFixture, CompareScaledAxisAngleConversionTests)
|
||||
{
|
||||
const AZ::Quaternion testQuat = GetAbs(GetParam());
|
||||
|
||||
// Convert test quaternion to axis-angle representation and scale it manually.
|
||||
AZ::Vector3 axis;
|
||||
float angle;
|
||||
testQuat.ConvertToAxisAngle(axis, angle);
|
||||
AZ::Vector3 scaledResult = axis*angle;
|
||||
|
||||
// Special case handling for identity rotation.
|
||||
AZ::Vector3 axisFromScaledResult = scaledResult.GetNormalized();
|
||||
float angleFromScaledResult = scaledResult.GetLength();
|
||||
if (AZ::IsClose(angleFromScaledResult, 0.0f))
|
||||
{
|
||||
axisFromScaledResult = AZ::Vector3::CreateAxisY();
|
||||
}
|
||||
|
||||
const AZ::Quaternion backFromAxisAngle = AZ::Quaternion::CreateFromAxisAngle(axisFromScaledResult, angleFromScaledResult);
|
||||
EXPECT_TRUE(testQuat.IsClose(backFromAxisAngle, 1e-6f));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(MATH_Quaternion, QuaternionScaledAxisAngleConversionFixture, ::testing::ValuesIn(RotationRepresentationConversionTestQuats));
|
||||
}
|
||||
|
||||
@@ -213,27 +213,33 @@ namespace AzFramework
|
||||
|
||||
Camera Cameras::StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, const float scrollDelta, const float deltaTime)
|
||||
{
|
||||
for (int i = 0; i < m_idleCameraInputs.size();)
|
||||
for (int idleIndex = 0; idleIndex < m_idleCameraInputs.size();)
|
||||
{
|
||||
auto& cameraInput = m_idleCameraInputs[i];
|
||||
auto& cameraInput = m_idleCameraInputs[idleIndex];
|
||||
const bool canBegin = cameraInput->Beginning() &&
|
||||
AZStd::all_of(m_activeCameraInputs.cbegin(), m_activeCameraInputs.cend(),
|
||||
[](const auto& input)
|
||||
{
|
||||
return !input->Exclusive();
|
||||
}) &&
|
||||
(!cameraInput->Exclusive() || (cameraInput->Exclusive() && m_activeCameraInputs.empty()));
|
||||
(!cameraInput->Exclusive() || m_activeCameraInputs.empty());
|
||||
|
||||
if (canBegin)
|
||||
{
|
||||
m_activeCameraInputs.push_back(cameraInput);
|
||||
using AZStd::swap;
|
||||
swap(m_idleCameraInputs[i], m_idleCameraInputs[m_idleCameraInputs.size() - 1]);
|
||||
swap(m_idleCameraInputs[idleIndex], m_idleCameraInputs[m_idleCameraInputs.size() - 1]);
|
||||
m_idleCameraInputs.pop_back();
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
// if a camera attempted to start but was not allowed to, ensure activation is cancelled
|
||||
if (!cameraInput->Idle())
|
||||
{
|
||||
cameraInput->CancelActivation();
|
||||
}
|
||||
|
||||
idleIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,21 +251,21 @@ namespace AzFramework
|
||||
return acc;
|
||||
});
|
||||
|
||||
for (int i = 0; i < m_activeCameraInputs.size();)
|
||||
for (int activeIndex = 0; activeIndex < m_activeCameraInputs.size();)
|
||||
{
|
||||
auto& cameraInput = m_activeCameraInputs[i];
|
||||
auto& cameraInput = m_activeCameraInputs[activeIndex];
|
||||
if (cameraInput->Ending())
|
||||
{
|
||||
cameraInput->ClearActivation();
|
||||
m_idleCameraInputs.push_back(cameraInput);
|
||||
using AZStd::swap;
|
||||
swap(m_activeCameraInputs[i], m_activeCameraInputs[m_activeCameraInputs.size() - 1]);
|
||||
swap(m_activeCameraInputs[activeIndex], m_activeCameraInputs[m_activeCameraInputs.size() - 1]);
|
||||
m_activeCameraInputs.pop_back();
|
||||
}
|
||||
else
|
||||
{
|
||||
cameraInput->ContinueActivation();
|
||||
i++;
|
||||
activeIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -470,9 +476,10 @@ namespace AzFramework
|
||||
{
|
||||
if (input->m_state == InputChannel::State::Began)
|
||||
{
|
||||
m_translation |= TranslationFromKey(input->m_channelId, m_translateCameraInputChannelIds);
|
||||
if (m_translation != TranslationType::Nil)
|
||||
if (auto translation = TranslationFromKey(input->m_channelId, m_translateCameraInputChannelIds);
|
||||
translation != TranslationType::Nil)
|
||||
{
|
||||
m_translation |= translation;
|
||||
BeginActivation();
|
||||
}
|
||||
|
||||
@@ -484,11 +491,16 @@ namespace AzFramework
|
||||
// ensure we don't process end events in the idle state
|
||||
else if (input->m_state == InputChannel::State::Ended && !Idle())
|
||||
{
|
||||
m_translation &= ~(TranslationFromKey(input->m_channelId, m_translateCameraInputChannelIds));
|
||||
if (m_translation == TranslationType::Nil)
|
||||
if (auto translation = TranslationFromKey(input->m_channelId, m_translateCameraInputChannelIds);
|
||||
translation != TranslationType::Nil)
|
||||
{
|
||||
EndActivation();
|
||||
m_translation &= ~translation;
|
||||
if (m_translation == TranslationType::Nil)
|
||||
{
|
||||
EndActivation();
|
||||
}
|
||||
}
|
||||
|
||||
if (input->m_channelId == m_translateCameraInputChannelIds.m_boostChannelId)
|
||||
{
|
||||
m_boost = false;
|
||||
|
||||
@@ -185,6 +185,11 @@ namespace AzFramework
|
||||
m_activation = Activation::Ending;
|
||||
}
|
||||
|
||||
void CancelActivation()
|
||||
{
|
||||
m_activation = Activation::Idle;
|
||||
}
|
||||
|
||||
void ContinueActivation()
|
||||
{
|
||||
// continue activation is called after the first step of the camera input,
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
#include <AzCore/Math/Vector2.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#include <AzCore/RTTI/TypeInfoSimple.h>
|
||||
#include <AzCore/base.h>
|
||||
|
||||
@@ -203,6 +204,12 @@ namespace AzFramework
|
||||
return AZ::Vector2(aznumeric_cast<float>(screenPoint.m_x), aznumeric_cast<float>(screenPoint.m_y));
|
||||
}
|
||||
|
||||
//! Return an AZ::Vector3 from a ScreenPoint (including z/depth value, defaulting to 0.0f).
|
||||
inline AZ::Vector3 Vector3FromScreenPoint(const ScreenPoint& screenPoint, const float z = 0.0f)
|
||||
{
|
||||
return AZ::Vector3(aznumeric_cast<float>(screenPoint.m_x), aznumeric_cast<float>(screenPoint.m_y), z);
|
||||
}
|
||||
|
||||
//! Return an AZ::Vector2 from a ScreenVector.
|
||||
inline AZ::Vector2 Vector2FromScreenVector(const ScreenVector& screenVector)
|
||||
{
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
|
||||
#include <Psapi.h>
|
||||
|
||||
AZ_CVAR(bool, ap_tether_lifetime, false, nullptr, AZ::ConsoleFunctorFlags::Null,
|
||||
AZ_CVAR(bool, ap_tether_lifetime, true, nullptr, AZ::ConsoleFunctorFlags::Null,
|
||||
"If enabled, a parent process that launches the AP will terminate the AP on exit");
|
||||
|
||||
namespace AzFramework::AssetSystem::Platform
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace AzFramework
|
||||
AZStd::string operator()(const AZStd::vector<AZStd::string>& commandLineArray) const
|
||||
{
|
||||
AZStd::string commandLineResult;
|
||||
Az::StringFunc::Join(commandLineResult, commandLineArray.begin(), commandLineArray.end(), " ");
|
||||
AZ::StringFunc::Join(commandLineResult, commandLineArray.begin(), commandLineArray.end(), " ");
|
||||
return commandLineResult;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -416,4 +416,78 @@ namespace UnitTest
|
||||
using ::testing::FloatNear;
|
||||
EXPECT_THAT(m_camera.m_pitch, FloatNear(expectedPitch, 0.001f));
|
||||
}
|
||||
|
||||
TEST_F(CameraInputFixture, InvalidTranslationInputKeyCannotBeginTranslateCameraInputAgain)
|
||||
{
|
||||
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId,
|
||||
AzFramework::InputChannel::State::Began });
|
||||
|
||||
const bool consumed =
|
||||
m_cameraSystem->HandleEvents(AzFramework::DiscreteInputEvent{ m_orbitChannelId, AzFramework::InputChannel::State::Began });
|
||||
|
||||
using ::testing::IsFalse;
|
||||
using ::testing::IsTrue;
|
||||
EXPECT_THAT(consumed, IsTrue());
|
||||
EXPECT_THAT(m_firstPersonTranslateCamera->Beginning(), IsFalse());
|
||||
EXPECT_THAT(m_firstPersonTranslateCamera->Active(), IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(CameraInputFixture, InvalidTranslationInputKeyDownCannotBeginTranslateCameraInputAgain)
|
||||
{
|
||||
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId,
|
||||
AzFramework::InputChannel::State::Began });
|
||||
|
||||
const bool consumed =
|
||||
m_cameraSystem->HandleEvents(AzFramework::DiscreteInputEvent{ m_orbitChannelId, AzFramework::InputChannel::State::Began });
|
||||
|
||||
using ::testing::IsFalse;
|
||||
using ::testing::IsTrue;
|
||||
EXPECT_THAT(consumed, IsTrue());
|
||||
EXPECT_THAT(m_firstPersonTranslateCamera->Beginning(), IsFalse());
|
||||
EXPECT_THAT(m_firstPersonTranslateCamera->Active(), IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(CameraInputFixture, InvalidTranslationInputKeyUpDoesNotAffectTranslateCameraInputEnd)
|
||||
{
|
||||
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId,
|
||||
AzFramework::InputChannel::State::Began });
|
||||
|
||||
const bool consumed =
|
||||
m_cameraSystem->HandleEvents(AzFramework::DiscreteInputEvent{ m_orbitChannelId, AzFramework::InputChannel::State::Began });
|
||||
|
||||
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId,
|
||||
AzFramework::InputChannel::State::Ended });
|
||||
|
||||
using ::testing::IsFalse;
|
||||
using ::testing::IsTrue;
|
||||
EXPECT_THAT(consumed, IsTrue());
|
||||
EXPECT_THAT(m_firstPersonTranslateCamera->Idle(), IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(CameraInputFixture, OrbitCameraInputCannotBeLeftInInvalidStateIfItCannotFullyBeginAfterInputChannelBegin)
|
||||
{
|
||||
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId,
|
||||
AzFramework::InputChannel::State::Began });
|
||||
|
||||
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_orbitChannelId, AzFramework::InputChannel::State::Began });
|
||||
|
||||
using ::testing::IsFalse;
|
||||
using ::testing::IsTrue;
|
||||
EXPECT_THAT(m_orbitCamera->Beginning(), IsFalse());
|
||||
EXPECT_THAT(m_orbitCamera->Idle(), IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(CameraInputFixture, OrbitCameraInputCannotBeLeftInInvalidStateIfItCannotFullyBeginAfterInputChannelBeginAndEnd)
|
||||
{
|
||||
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId,
|
||||
AzFramework::InputChannel::State::Began });
|
||||
|
||||
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_orbitChannelId, AzFramework::InputChannel::State::Began });
|
||||
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_orbitChannelId, AzFramework::InputChannel::State::Ended });
|
||||
|
||||
using ::testing::IsFalse;
|
||||
using ::testing::IsTrue;
|
||||
EXPECT_THAT(m_orbitCamera->Ending(), IsFalse());
|
||||
EXPECT_THAT(m_orbitCamera->Idle(), IsTrue());
|
||||
}
|
||||
} // namespace UnitTest
|
||||
|
||||
+14
-10
@@ -26,29 +26,33 @@ namespace AzManipulatorTestFramework
|
||||
{
|
||||
public:
|
||||
virtual ~ViewportInteractionInterface() = default;
|
||||
//! Return the camera state.
|
||||
//! Returns the camera state.
|
||||
virtual AzFramework::CameraState GetCameraState() = 0;
|
||||
//! Set the camera state.
|
||||
//! Sets the camera state.
|
||||
virtual void SetCameraState(const AzFramework::CameraState& cameraState) = 0;
|
||||
//! Retrieve the debug display.
|
||||
//! Retrieves the debug display.
|
||||
virtual AzFramework::DebugDisplayRequests& GetDebugDisplay() = 0;
|
||||
//! Set if grid snapping is enabled or not.
|
||||
//! Sets if grid snapping is enabled or not.
|
||||
virtual void SetGridSnapping(bool enabled) = 0;
|
||||
//! Set if angular snapping is enabled or not.
|
||||
//! Sets if angular snapping is enabled or not.
|
||||
virtual void SetAngularSnapping(bool enabled) = 0;
|
||||
//! Set the grid size.
|
||||
//! Sets the grid size.
|
||||
virtual void SetGridSize(float size) = 0;
|
||||
//! Set the angular step.
|
||||
//! Sets the angular step.
|
||||
virtual void SetAngularStep(float step) = 0;
|
||||
//! Get the viewport id.
|
||||
//! Gets the viewport id.
|
||||
virtual AzFramework::ViewportId GetViewportId() const = 0;
|
||||
//! Updates the visibility state.
|
||||
//! Updates which entities are currently visible given the current camera state.
|
||||
virtual void UpdateVisibility() = 0;
|
||||
//! Set if sticky select is enabled or not.
|
||||
//! Sets if sticky select is enabled or not.
|
||||
virtual void SetStickySelect(bool enabled) = 0;
|
||||
//! Get default Editor Camera Position.
|
||||
//! Gets default Editor Camera Position.
|
||||
virtual AZ::Vector3 DefaultEditorCameraPosition() const = 0;
|
||||
//! Sets if icons are visible in the viewport.
|
||||
virtual void SetIconsVisible(bool visible) = 0;
|
||||
//! Sets if helpers are visible in the viewport.
|
||||
virtual void SetHelpersVisible(bool visible) = 0;
|
||||
};
|
||||
|
||||
//! This interface is used to simulate the manipulator manager while the manipulators are under test.
|
||||
|
||||
+1
-1
@@ -26,6 +26,7 @@ namespace UnitTest
|
||||
using IndirectCallManipulatorViewportInteraction = AzManipulatorTestFramework::IndirectCallManipulatorViewportInteraction;
|
||||
using ImmediateModeActionDispatcher = AzManipulatorTestFramework::ImmediateModeActionDispatcher;
|
||||
|
||||
public:
|
||||
void SetUpEditorFixtureImpl() override
|
||||
{
|
||||
ToolsApplicationFixtureT::SetUpEditorFixtureImpl();
|
||||
@@ -43,7 +44,6 @@ namespace UnitTest
|
||||
ToolsApplicationFixtureT::TearDownEditorFixtureImpl();
|
||||
}
|
||||
|
||||
public:
|
||||
AzFramework::CameraState m_cameraState;
|
||||
AZStd::unique_ptr<ImmediateModeActionDispatcher> m_actionDispatcher;
|
||||
AZStd::unique_ptr<IndirectCallManipulatorViewportInteraction> m_viewportManipulatorInteraction;
|
||||
|
||||
-23
@@ -27,29 +27,6 @@ namespace AzManipulatorTestFramework
|
||||
const AZ::Vector3& position = AZ::Vector3::CreateZero(),
|
||||
float radius = 1.0f);
|
||||
|
||||
//! Create a mouse pick from the specified ray and screen point.
|
||||
AzToolsFramework::ViewportInteraction::MousePick CreateMousePick(
|
||||
const AZ::Vector3& origin, const AZ::Vector3& direction, const AzFramework::ScreenPoint& screenPoint);
|
||||
|
||||
//! Build a mouse pick from the specified mouse position and camera state.
|
||||
AzToolsFramework::ViewportInteraction::MousePick BuildMousePick(
|
||||
const AzFramework::ScreenPoint& screenPoint, const AzFramework::CameraState& cameraState);
|
||||
|
||||
//! Create a mouse interaction from the specified pick, buttons, interaction id and keyboard modifiers.
|
||||
AzToolsFramework::ViewportInteraction::MouseInteraction CreateMouseInteraction(
|
||||
const AzToolsFramework::ViewportInteraction::MousePick& mousePick,
|
||||
AzToolsFramework::ViewportInteraction::MouseButtons buttons,
|
||||
AzToolsFramework::ViewportInteraction::InteractionId interactionId,
|
||||
AzToolsFramework::ViewportInteraction::KeyboardModifiers modifiers);
|
||||
|
||||
//! Create a mouse buttons from the specified mouse button.
|
||||
AzToolsFramework::ViewportInteraction::MouseButtons CreateMouseButtons(AzToolsFramework::ViewportInteraction::MouseButton button);
|
||||
|
||||
//! Create a mouse interaction event from the specified interaction and event.
|
||||
AzToolsFramework::ViewportInteraction::MouseInteractionEvent CreateMouseInteractionEvent(
|
||||
const AzToolsFramework::ViewportInteraction::MouseInteraction& mouseInteraction,
|
||||
AzToolsFramework::ViewportInteraction::MouseEvent event);
|
||||
|
||||
//! Dispatch a mouse event to the main manipulator manager via a bus call.
|
||||
void DispatchMouseInteractionEvent(const AzToolsFramework::ViewportInteraction::MouseInteractionEvent& event);
|
||||
|
||||
|
||||
+4
-1
@@ -24,9 +24,12 @@ namespace AzManipulatorTestFramework
|
||||
explicit IndirectCallManipulatorViewportInteraction(AZStd::shared_ptr<AzFramework::DebugDisplayRequests> debugDisplayRequests);
|
||||
~IndirectCallManipulatorViewportInteraction();
|
||||
|
||||
// ManipulatorViewportInteractionInterface ...
|
||||
// ManipulatorViewportInteraction overrides ...
|
||||
const ViewportInteractionInterface& GetViewportInteraction() const override;
|
||||
const ManipulatorManagerInterface& GetManipulatorManager() const override;
|
||||
// make non-const overloads visible
|
||||
using ManipulatorViewportInteraction::GetViewportInteraction;
|
||||
using ManipulatorViewportInteraction::GetManipulatorManager;
|
||||
|
||||
private:
|
||||
AZStd::unique_ptr<ViewportInteraction> m_viewportInteraction;
|
||||
|
||||
+9
-3
@@ -39,7 +39,8 @@ namespace AzManipulatorTestFramework
|
||||
AzFramework::ViewportId GetViewportId() const override;
|
||||
void UpdateVisibility() override;
|
||||
void SetStickySelect(bool enabled) override;
|
||||
AZ::Vector3 DefaultEditorCameraPosition() const override;
|
||||
void SetIconsVisible(bool visible) override;
|
||||
void SetHelpersVisible(bool visible) override;
|
||||
|
||||
// ViewportInteractionRequestBus overrides ...
|
||||
AzFramework::CameraState GetCameraState() override;
|
||||
@@ -58,6 +59,9 @@ namespace AzManipulatorTestFramework
|
||||
float ManipulatorLineBoundWidth() const override;
|
||||
float ManipulatorCircleBoundWidth() const override;
|
||||
bool StickySelectEnabled() const override;
|
||||
AZ::Vector3 DefaultEditorCameraPosition() const override;
|
||||
bool IconsVisible() const override;
|
||||
bool HelpersVisible() const override;
|
||||
|
||||
// EditorEntityViewportInteractionRequestBus overrides ...
|
||||
void FindVisibleEntities(AZStd::vector<AZ::EntityId>& visibleEntities) override;
|
||||
@@ -68,10 +72,12 @@ namespace AzManipulatorTestFramework
|
||||
AzFramework::EntityVisibilityQuery m_entityVisibilityQuery;
|
||||
AZStd::shared_ptr<AzFramework::DebugDisplayRequests> m_debugDisplayRequests;
|
||||
AzFramework::CameraState m_cameraState;
|
||||
float m_gridSize = 1.0f;
|
||||
float m_angularStep = 0.0f;
|
||||
bool m_gridSnapping = false;
|
||||
bool m_angularSnapping = false;
|
||||
bool m_stickySelect = true;
|
||||
float m_gridSize = 1.0f;
|
||||
float m_angularStep = 0.0f;
|
||||
bool m_iconsVisible = true;
|
||||
bool m_helpersVisible = true;
|
||||
};
|
||||
} // namespace AzManipulatorTestFramework
|
||||
|
||||
@@ -82,49 +82,6 @@ namespace AzManipulatorTestFramework
|
||||
return manipulator;
|
||||
}
|
||||
|
||||
AzToolsFramework::ViewportInteraction::MousePick CreateMousePick(
|
||||
const AZ::Vector3& origin, const AZ::Vector3& direction, const AzFramework::ScreenPoint& screenPoint)
|
||||
{
|
||||
return { origin, direction, screenPoint };
|
||||
}
|
||||
|
||||
AzToolsFramework::ViewportInteraction::MousePick BuildMousePick(
|
||||
const AzFramework::ScreenPoint& screenPoint, const AzFramework::CameraState& cameraState)
|
||||
{
|
||||
const auto nearPlaneWorldPosition = AzFramework::ScreenToWorld(screenPoint, cameraState);
|
||||
|
||||
AzToolsFramework::ViewportInteraction::MousePick mousePick;
|
||||
mousePick.m_screenCoordinates = screenPoint;
|
||||
mousePick.m_rayOrigin = nearPlaneWorldPosition;
|
||||
mousePick.m_rayDirection = (nearPlaneWorldPosition - cameraState.m_position).GetNormalized();
|
||||
|
||||
return mousePick;
|
||||
}
|
||||
|
||||
MouseInteraction CreateMouseInteraction(
|
||||
const MousePick& mousePick, MouseButtons buttons, InteractionId interactionId, KeyboardModifiers modifiers)
|
||||
{
|
||||
AzToolsFramework::ViewportInteraction::MouseInteraction interaction;
|
||||
interaction.m_mousePick = mousePick;
|
||||
interaction.m_mouseButtons = buttons;
|
||||
interaction.m_interactionId = interactionId;
|
||||
interaction.m_keyboardModifiers = modifiers;
|
||||
|
||||
return interaction;
|
||||
}
|
||||
|
||||
MouseButtons CreateMouseButtons(MouseButton button)
|
||||
{
|
||||
MouseButtons buttons;
|
||||
buttons.m_mouseButtons = static_cast<AZ::u32>(button);
|
||||
return buttons;
|
||||
}
|
||||
|
||||
MouseInteractionEvent CreateMouseInteractionEvent(const MouseInteraction& mouseInteraction, MouseEvent event)
|
||||
{
|
||||
return MouseInteractionEvent(mouseInteraction, event, /*captured=*/false);
|
||||
}
|
||||
|
||||
void DispatchMouseInteractionEvent(const MouseInteractionEvent& event)
|
||||
{
|
||||
AzToolsFramework::EditorInteractionSystemViewportSelectionRequestBus::Event(
|
||||
|
||||
@@ -120,7 +120,8 @@ namespace AzManipulatorTestFramework
|
||||
void ImmediateModeActionDispatcher::MousePositionImpl(const AzFramework::ScreenPoint& position)
|
||||
{
|
||||
const auto cameraState = m_manipulatorViewportInteraction.GetViewportInteraction().GetCameraState();
|
||||
GetMouseInteractionEvent()->m_mouseInteraction.m_mousePick = BuildMousePick(position, cameraState);
|
||||
GetMouseInteractionEvent()->m_mouseInteraction.m_mousePick =
|
||||
AzToolsFramework::ViewportInteraction::BuildMousePick(cameraState, position);
|
||||
GetMouseInteractionEvent()->m_mouseEvent = AzToolsFramework::ViewportInteraction::MouseEvent::Move;
|
||||
m_manipulatorViewportInteraction.GetManipulatorManager().ConsumeMouseInteractionEvent(*m_event);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <AzFramework/Viewport/ViewportScreen.h>
|
||||
#include <AzManipulatorTestFramework/ViewportInteraction.h>
|
||||
#include <AzToolsFramework/Manipulators/ManipulatorBus.h>
|
||||
#include <AzManipulatorTestFramework/AzManipulatorTestFrameworkUtils.h>
|
||||
|
||||
namespace AzManipulatorTestFramework
|
||||
{
|
||||
@@ -19,6 +20,9 @@ namespace AzManipulatorTestFramework
|
||||
AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Handler::BusConnect(m_viewportId);
|
||||
AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Handler::BusConnect(m_viewportId);
|
||||
AzToolsFramework::ViewportInteraction::EditorEntityViewportInteractionRequestBus::Handler::BusConnect(m_viewportId);
|
||||
|
||||
m_cameraState =
|
||||
AzFramework::CreateIdentityDefaultCamera(AZ::Vector3::CreateZero(), AzManipulatorTestFramework::DefaultViewportSize);
|
||||
}
|
||||
|
||||
ViewportInteraction::~ViewportInteraction()
|
||||
@@ -113,6 +117,16 @@ namespace AzManipulatorTestFramework
|
||||
m_stickySelect = enabled;
|
||||
}
|
||||
|
||||
void ViewportInteraction::SetIconsVisible(const bool visible)
|
||||
{
|
||||
m_iconsVisible = visible;
|
||||
}
|
||||
|
||||
void ViewportInteraction::SetHelpersVisible(const bool visible)
|
||||
{
|
||||
m_helpersVisible = visible;
|
||||
}
|
||||
|
||||
AZ::Vector3 ViewportInteraction::DefaultEditorCameraPosition() const
|
||||
{
|
||||
return {};
|
||||
@@ -148,4 +162,14 @@ namespace AzManipulatorTestFramework
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
bool ViewportInteraction::IconsVisible() const
|
||||
{
|
||||
return m_iconsVisible;
|
||||
}
|
||||
|
||||
bool ViewportInteraction::HelpersVisible() const
|
||||
{
|
||||
return m_helpersVisible;
|
||||
}
|
||||
} // namespace AzManipulatorTestFramework
|
||||
|
||||
+20
-19
@@ -8,21 +8,22 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzManipulatorTestFramework/AzManipulatorTestFrameworkUtils.h>
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <AzToolsFramework/UnitTest/AzToolsFrameworkTestHelpers.h>
|
||||
#include <AzManipulatorTestFramework/AzManipulatorTestFrameworkUtils.h>
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
class LinearManipulatorTestFixture
|
||||
: public ToolsApplicationFixture
|
||||
class LinearManipulatorTestFixture : public ToolsApplicationFixture
|
||||
{
|
||||
protected:
|
||||
LinearManipulatorTestFixture(const AzToolsFramework::ManipulatorManagerId& manipulatorManagerId)
|
||||
: m_manipulatorManagerId(manipulatorManagerId) {}
|
||||
: m_manipulatorManagerId(manipulatorManagerId)
|
||||
{
|
||||
}
|
||||
|
||||
void SetUpEditorFixtureImpl() override
|
||||
{
|
||||
{
|
||||
m_linearManipulator = AzManipulatorTestFramework::CreateLinearManipulator(
|
||||
m_manipulatorManagerId,
|
||||
/*position=*/AZ::Vector3::CreateZero(),
|
||||
@@ -31,21 +32,21 @@ namespace UnitTest
|
||||
// default sanity check call backs
|
||||
m_linearManipulator->InstallLeftMouseDownCallback(
|
||||
[this](const AzToolsFramework::LinearManipulator::Action& /*action*/)
|
||||
{
|
||||
m_receivedLeftMouseDown = true;
|
||||
});
|
||||
{
|
||||
m_receivedLeftMouseDown = true;
|
||||
});
|
||||
|
||||
m_linearManipulator->InstallMouseMoveCallback(
|
||||
[this](const AzToolsFramework::LinearManipulator::Action& /*action*/)
|
||||
{
|
||||
m_receivedMouseMove = true;
|
||||
});
|
||||
{
|
||||
m_receivedMouseMove = true;
|
||||
});
|
||||
|
||||
m_linearManipulator->InstallLeftMouseUpCallback(
|
||||
[this](const AzToolsFramework::LinearManipulator::Action& /*action*/)
|
||||
{
|
||||
m_receivedLeftMouseUp = true;
|
||||
});
|
||||
{
|
||||
m_receivedLeftMouseUp = true;
|
||||
});
|
||||
}
|
||||
|
||||
void TearDownEditorFixtureImpl() override
|
||||
@@ -63,16 +64,16 @@ namespace UnitTest
|
||||
bool m_receivedLeftMouseUp = false;
|
||||
|
||||
// initial world space starting position for mouse interaction
|
||||
const AzToolsFramework::ViewportInteraction::MousePick m_mouseStartingPositionRay =
|
||||
AzManipulatorTestFramework::CreateMousePick(
|
||||
AZ::Vector3(0.0f, -2.0f, 0.0f), AZ::Vector3(0.0f, 1.0f, 0.0f), AzFramework::ScreenPoint( 0,0 ));
|
||||
const AzToolsFramework::ViewportInteraction::MousePick m_mouseStartingPositionRay{ AZ::Vector3(0.0f, -2.0f, 0.0f),
|
||||
AZ::Vector3(0.0f, 1.0f, 0.0f),
|
||||
AzFramework::ScreenPoint(0, 0) };
|
||||
|
||||
// left mouse down ray in world space 2 units back from origin looking down +y axis with a null interaction
|
||||
// id and no keyboard modifiers
|
||||
AzToolsFramework::ViewportInteraction::MouseInteraction m_interaction =
|
||||
AzManipulatorTestFramework::CreateMouseInteraction(
|
||||
AzToolsFramework::ViewportInteraction::BuildMouseInteraction(
|
||||
m_mouseStartingPositionRay,
|
||||
AzManipulatorTestFramework::CreateMouseButtons(AzToolsFramework::ViewportInteraction::MouseButton::Left),
|
||||
AzToolsFramework::ViewportInteraction::BuildMouseButtons(AzToolsFramework::ViewportInteraction::MouseButton::Left),
|
||||
AzToolsFramework::ViewportInteraction::InteractionId(AZ::EntityId(0), 0),
|
||||
AzToolsFramework::ViewportInteraction::KeyboardModifiers(0));
|
||||
};
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
*/
|
||||
|
||||
#include "AzManipulatorTestFrameworkTestFixtures.h"
|
||||
|
||||
#include <AzToolsFramework/Viewport/ViewportTypes.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorDefaultSelection.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemViewportSelectionRequestBus.h>
|
||||
|
||||
@@ -34,8 +36,8 @@ namespace UnitTest
|
||||
TEST_F(AzManipulatorTestFrameworkBusCallTestFixture, ConsumeViewportLeftMouseClick)
|
||||
{
|
||||
// given a left mouse down ray in world space
|
||||
auto event =
|
||||
AzManipulatorTestFramework::CreateMouseInteractionEvent(m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Down);
|
||||
auto event = AzToolsFramework::ViewportInteraction::BuildMouseInteractionEvent(
|
||||
m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Down);
|
||||
|
||||
// consume the mouse down and up events
|
||||
AzManipulatorTestFramework::DispatchMouseInteractionEvent(event);
|
||||
@@ -53,8 +55,8 @@ namespace UnitTest
|
||||
TEST_F(AzManipulatorTestFrameworkBusCallTestFixture, ConsumeViewportMouseMoveHover)
|
||||
{
|
||||
// given a left mouse down ray in world space
|
||||
const auto event =
|
||||
AzManipulatorTestFramework::CreateMouseInteractionEvent(m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Move);
|
||||
const auto event = AzToolsFramework::ViewportInteraction::BuildMouseInteractionEvent(
|
||||
m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Move);
|
||||
|
||||
// consume the mouse move event
|
||||
AzManipulatorTestFramework::DispatchMouseInteractionEvent(event);
|
||||
@@ -72,8 +74,8 @@ namespace UnitTest
|
||||
TEST_F(AzManipulatorTestFrameworkBusCallTestFixture, ConsumeViewportMouseMoveActive)
|
||||
{
|
||||
// given a left mouse down ray in world space
|
||||
auto event =
|
||||
AzManipulatorTestFramework::CreateMouseInteractionEvent(m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Down);
|
||||
auto event = AzToolsFramework::ViewportInteraction::BuildMouseInteractionEvent(
|
||||
m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Down);
|
||||
|
||||
// consume the mouse down event
|
||||
AzManipulatorTestFramework::DispatchMouseInteractionEvent(event);
|
||||
@@ -113,8 +115,8 @@ namespace UnitTest
|
||||
});
|
||||
|
||||
// given a left mouse down ray in world space
|
||||
auto event =
|
||||
AzManipulatorTestFramework::CreateMouseInteractionEvent(m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Down);
|
||||
auto event = AzToolsFramework::ViewportInteraction::BuildMouseInteractionEvent(
|
||||
m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Down);
|
||||
|
||||
// consume the mouse down event
|
||||
AzManipulatorTestFramework::DispatchMouseInteractionEvent(event);
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#define AZ_TRAIT_DISABLE_FAILED_JOB_BASIC_TESTS true
|
||||
#define AZ_TRAIT_DISABLE_FAILED_MATH_TESTS true
|
||||
#define AZ_TRAIT_DISABLE_FAILED_MERGESETTINGSFOLDER_CONFLICTINGSPECIALIZATIONS true
|
||||
#define AZ_TRAIT_DISABLE_FAILED_MULTIPLAYER_GRIDMATE_TESTS true
|
||||
#define AZ_TRAIT_DISABLE_FAILED_NETWORKING_TESTS true
|
||||
#define AZ_TRAIT_DISABLE_FAILED_PHYSICS_TESTS true
|
||||
#define AZ_TRAIT_DISABLE_FAILED_SAVE_DATA_TESTS true
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#define AZ_TRAIT_UNIT_TEST_ENTITY_ID_GEN_TEST_COUNT 10000
|
||||
#define AZ_TRAIT_UNIT_TEST_DILLER_TRIGGER_EVENT_COUNT 100000
|
||||
|
||||
#define AZ_TRAIT_DISABLE_FAILED_MULTIPLAYER_GRIDMATE_TESTS true
|
||||
#define AZ_TRAIT_DISABLE_FAILED_NATIVE_WINDOWS_TESTS true
|
||||
#define AZ_TRAIT_DISABLE_FAILED_EMOTION_FX_TESTS true
|
||||
#define AZ_TRAIT_DISABLE_FAILED_DLL_TESTS true
|
||||
|
||||
@@ -5,9 +5,12 @@
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#include <ostream>
|
||||
|
||||
#include <AzCore/Component/EntityId.h>
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace AZ::IO
|
||||
{
|
||||
void PrintTo(const AZ::IO::PathView& path, ::std::ostream* os)
|
||||
@@ -24,4 +27,12 @@ namespace AZ::IO
|
||||
{
|
||||
*os << "path: " << AZ::IO::FixedMaxPath(path.Native(), AZ::IO::PosixPathSeparator).MakePreferred().c_str();
|
||||
}
|
||||
}
|
||||
} // namespace AZ::IO
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
void PrintTo(const AZ::EntityId entityId, ::std::ostream* os)
|
||||
{
|
||||
*os << entityId.ToString().c_str();
|
||||
}
|
||||
} // namespace AZ
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <iosfwd>
|
||||
@@ -37,4 +38,11 @@ namespace AZ::IO
|
||||
void PrintTo(const AZ::IO::FixedMaxPath& path, ::std::ostream* os);
|
||||
}
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
class EntityId;
|
||||
|
||||
void PrintTo(AZ::EntityId entityId, ::std::ostream* os);
|
||||
}
|
||||
|
||||
#include <AzTest/Printers.inl>
|
||||
|
||||
@@ -878,9 +878,6 @@ namespace AzToolsFramework
|
||||
/// Return the icon texture id (from internal IconManager) for a given entity icon path.
|
||||
/// This can be passed to DrawTextureLabel to draw an entity icon.
|
||||
virtual int GetIconTextureIdFromEntityIconPath(const AZStd::string& entityIconPath) = 0;
|
||||
|
||||
/// Returns if the Display Helpers option is toggled on in the Editor.
|
||||
virtual bool DisplayHelpersVisible() = 0;
|
||||
};
|
||||
|
||||
using EditorRequestBus = AZ::EBus<EditorRequests>;
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
#include <AzToolsFramework/Prefab/PrefabPublicInterface.h>
|
||||
#include <Entity/EntityUtilityComponent.h>
|
||||
#include <AzToolsFramework/Script/LuaSymbolsReporterSystemComponent.h>
|
||||
#include <Prefab/ProceduralPrefabSystemComponent.h>
|
||||
|
||||
#include <QtWidgets/QMessageBox>
|
||||
AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 4251: 'QFileInfo::d_ptr': class 'QSharedDataPointer<QFileInfoPrivate>' needs to have dll-interface to be used by clients of class 'QFileInfo'
|
||||
@@ -272,6 +273,7 @@ namespace AzToolsFramework
|
||||
azrtti_typeid<ReadOnlyEntitySystemComponent>(),
|
||||
azrtti_typeid<SliceMetadataEntityContextComponent>(),
|
||||
azrtti_typeid<Prefab::PrefabSystemComponent>(),
|
||||
azrtti_typeid<Prefab::ProceduralPrefabSystemComponent>(),
|
||||
azrtti_typeid<EditorEntityFixupComponent>(),
|
||||
azrtti_typeid<Components::EditorComponentAPIComponent>(),
|
||||
azrtti_typeid<Components::EditorLevelComponentAPIComponent>(),
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemComponent.h>
|
||||
#include <AzToolsFramework/Entity/EntityUtilityComponent.h>
|
||||
#include <AzToolsFramework/Script/LuaSymbolsReporterSystemComponent.h>
|
||||
#include <Prefab/ProceduralPrefabSystemComponent.h>
|
||||
|
||||
AZ_DEFINE_BUDGET(AzToolsFramework);
|
||||
|
||||
@@ -82,6 +83,7 @@ namespace AzToolsFramework
|
||||
SliceRequestComponent::CreateDescriptor(),
|
||||
Prefab::PrefabSystemComponent::CreateDescriptor(),
|
||||
Prefab::EditorPrefabComponent::CreateDescriptor(),
|
||||
Prefab::ProceduralPrefabSystemComponent::CreateDescriptor(),
|
||||
Components::EditorEntityActionComponent::CreateDescriptor(),
|
||||
Components::EditorEntityIconComponent::CreateDescriptor(),
|
||||
Components::EditorInspectorComponent::CreateDescriptor(),
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabDomUtils.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabSystemComponentInterface.h>
|
||||
#include <Prefab/ProceduralPrefabSystemComponentInterface.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
@@ -185,6 +186,20 @@ namespace AzToolsFramework
|
||||
TemplateReference newTemplateReference = m_prefabSystemComponentInterface->FindTemplate(newTemplateId);
|
||||
Template& newTemplate = newTemplateReference->get();
|
||||
|
||||
if(newTemplate.IsProcedural())
|
||||
{
|
||||
auto proceduralPrefabSystemComponentInterface = AZ::Interface<ProceduralPrefabSystemComponentInterface>::Get();
|
||||
|
||||
if (!proceduralPrefabSystemComponentInterface)
|
||||
{
|
||||
AZ_Error("Prefab", false, "Failed to find ProceduralPrefabSystemComponentInterface. Procedural Prefab will not be tracked for hotloading.");
|
||||
}
|
||||
else
|
||||
{
|
||||
proceduralPrefabSystemComponentInterface->RegisterProceduralPrefab(relativePath.Native(), newTemplateId);
|
||||
}
|
||||
}
|
||||
|
||||
// Mark the file as being in progress.
|
||||
progressedFilePathsSet.emplace(relativePath);
|
||||
|
||||
|
||||
@@ -26,6 +26,14 @@ namespace AzToolsFramework
|
||||
|
||||
virtual void OnPrefabTemplateDirtyFlagUpdated(
|
||||
[[maybe_unused]] TemplateId templateId, [[maybe_unused]] bool status) {}
|
||||
|
||||
// Sent after a single template has been removed
|
||||
// Does not get sent when all templates are being removed at once. Be sure to handle OnAllTemplatesRemoved as well.
|
||||
virtual void OnTemplateRemoved([[maybe_unused]] TemplateId templateId) {}
|
||||
|
||||
// Sent after all templates have been removed
|
||||
// Does not trigger individual OnTemplateRemoved events
|
||||
virtual void OnAllTemplatesRemoved() {}
|
||||
};
|
||||
|
||||
using PrefabPublicNotificationBus = AZ::EBus<PrefabPublicNotifications>;
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace AzToolsFramework
|
||||
newInstance->SetTemplateId(newTemplateId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PrefabSystemComponent::PropagateTemplateChanges(TemplateId templateId, InstanceOptionalConstReference instanceToExclude)
|
||||
{
|
||||
auto templateIdToLinkIdsIterator = m_templateToLinkIdsMap.find(templateId);
|
||||
@@ -442,7 +442,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
m_templateFilePathToIdMap.emplace(AZStd::make_pair(filePath, newTemplateId));
|
||||
|
||||
|
||||
return newTemplateId;
|
||||
}
|
||||
|
||||
@@ -469,7 +469,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
m_templateFilePathToIdMap.erase(templateToChange.GetFilePath());
|
||||
if (!m_templateFilePathToIdMap.try_emplace(filePath, templateId).second)
|
||||
{
|
||||
@@ -500,7 +500,7 @@ namespace AzToolsFramework
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//Remove all Links owned by the Template from TemplateToLinkIdsMap.
|
||||
Template& templateToDelete = findTemplateResult->get();
|
||||
const Template::Links& linkIdsToDelete = templateToDelete.GetLinks();
|
||||
@@ -546,7 +546,7 @@ namespace AzToolsFramework
|
||||
templateId, templateToDelete.GetFilePath().c_str());
|
||||
|
||||
m_templateInstanceMapper.UnregisterTemplate(templateId);
|
||||
|
||||
|
||||
result = m_templateIdMap.erase(templateId) != 0;
|
||||
AZ_Assert(result,
|
||||
"Prefab - PrefabSystemComponent::RemoveTemplate - "
|
||||
@@ -554,7 +554,10 @@ namespace AzToolsFramework
|
||||
"from Template Id Map.",
|
||||
templateId, templateToDelete.GetFilePath().c_str());
|
||||
|
||||
return;
|
||||
if (!m_removingAllTemplates)
|
||||
{
|
||||
PrefabPublicNotificationBus::Broadcast(&PrefabPublicNotificationBus::Events::OnTemplateRemoved, templateId);
|
||||
}
|
||||
}
|
||||
|
||||
void PrefabSystemComponent::RemoveAllTemplates()
|
||||
@@ -568,10 +571,15 @@ namespace AzToolsFramework
|
||||
templateIds.emplace_back(id);
|
||||
}
|
||||
|
||||
m_removingAllTemplates = true;
|
||||
|
||||
for (auto id : templateIds)
|
||||
{
|
||||
RemoveTemplate(id);
|
||||
}
|
||||
|
||||
m_removingAllTemplates = false;
|
||||
PrefabPublicNotificationBus::Broadcast(&PrefabPublicNotificationBus::Events::OnAllTemplatesRemoved);
|
||||
}
|
||||
|
||||
LinkId PrefabSystemComponent::AddLink(
|
||||
@@ -859,7 +867,7 @@ namespace AzToolsFramework
|
||||
|
||||
void PrefabSystemComponent::SaveAllDirtyTemplates(TemplateId rootTemplateId)
|
||||
{
|
||||
AZStd::set<AZ::IO::PathView> dirtyTemplatePaths = GetDirtyTemplatePaths(rootTemplateId);
|
||||
AZStd::set<AZ::IO::PathView> dirtyTemplatePaths = GetDirtyTemplatePaths(rootTemplateId);
|
||||
|
||||
for (AZ::IO::PathView dirtyTemplatePath : dirtyTemplatePaths)
|
||||
{
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace AzToolsFramework
|
||||
public:
|
||||
|
||||
using TargetTemplateIdToLinkIdMap = AZStd::unordered_map<TemplateId, AZStd::pair<AZStd::unordered_set<LinkId>, bool>>;
|
||||
|
||||
|
||||
AZ_COMPONENT(PrefabSystemComponent, "{27203AE6-A398-4614-881B-4EEB5E9B34E9}");
|
||||
|
||||
PrefabSystemComponent() = default;
|
||||
@@ -220,7 +220,7 @@ namespace AzToolsFramework
|
||||
const AZStd::vector<AZ::Entity*>& entities, AZStd::vector<AZStd::unique_ptr<Instance>>&& instancesToConsume,
|
||||
AZ::IO::PathView filePath, AZStd::unique_ptr<AZ::Entity> containerEntity = nullptr,
|
||||
InstanceOptionalReference parent = AZStd::nullopt, bool shouldCreateLinks = true) override;
|
||||
|
||||
|
||||
PrefabDom& FindTemplateDom(TemplateId templateId) override;
|
||||
|
||||
/**
|
||||
@@ -244,7 +244,7 @@ namespace AzToolsFramework
|
||||
|
||||
private:
|
||||
AZ_DISABLE_COPY_MOVE(PrefabSystemComponent);
|
||||
|
||||
|
||||
/**
|
||||
* Builds a new Prefab Template out of entities and instances and returns the first instance comprised of
|
||||
* these entities and instances.
|
||||
@@ -263,14 +263,14 @@ namespace AzToolsFramework
|
||||
/**
|
||||
* Updates all the linked Instances corresponding to the linkIds in the provided queue.
|
||||
* Queue gets populated with more linkId lists as linked instances are updated. Updating stops when the queue is empty.
|
||||
*
|
||||
*
|
||||
* @param linkIdsQueue A queue of vector of link-Ids to update.
|
||||
*/
|
||||
void UpdateLinkedInstances(AZStd::queue<LinkIds>& linkIdsQueue);
|
||||
|
||||
/**
|
||||
* Given a vector of link ids to update, splits them into smaller lists based on the target template id of the links.
|
||||
*
|
||||
*
|
||||
* @param linkIdsToUpdate The list of link ids to update.
|
||||
* @param targetTemplateIdToLinkIdMap The map of target templateIds to a pair of lists of linkIds and a bool flag indicating
|
||||
* whether any of the instances of the target template were updated.
|
||||
@@ -279,9 +279,9 @@ namespace AzToolsFramework
|
||||
TargetTemplateIdToLinkIdMap& targetTemplateIdToLinkIdMap);
|
||||
|
||||
/**
|
||||
* Updates a single linked instance corresponding to the given link Id and adds more linkIds to the
|
||||
* Updates a single linked instance corresponding to the given link Id and adds more linkIds to the
|
||||
* template change propagation queue(linkIdsQueue) when necessary.
|
||||
*
|
||||
*
|
||||
* @param linkIdToUpdate The id of the linked instance to update
|
||||
* @param targetTemplateIdToLinkIdMap The map of target templateIds to a pair of lists of linkIds and a bool flag indicating
|
||||
* whether any of the instances of the target template were updated.
|
||||
@@ -293,7 +293,7 @@ namespace AzToolsFramework
|
||||
/**
|
||||
* If all linked instances of a target template are updated and if the content of any of the linked instances changed,
|
||||
* this method fetches all the linked instances sourced by it and adds their corresponding ids to the LinkIdsQueue.
|
||||
*
|
||||
*
|
||||
* @param targetTemplateIdToLinkIdMap The map of target templateIds to a pair of lists of linkIds and a bool flag indicating
|
||||
* whether any of the instances of the target template were updated.
|
||||
* @param targetTemplateId The id of the template, whose linked instances we need to find if the template was updated.
|
||||
@@ -414,6 +414,9 @@ namespace AzToolsFramework
|
||||
PrefabPublicRequestHandler m_prefabPublicRequestHandler;
|
||||
|
||||
PrefabSystemScriptingHandler m_prefabSystemScriptingHandler;
|
||||
|
||||
// If true, individual template-remove messages will be suppressed
|
||||
bool m_removingAllTemplates = false;
|
||||
};
|
||||
} // namespace Prefab
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+9
-5
@@ -9,12 +9,11 @@
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Serialization/Json/RegistrationContext.h>
|
||||
#include <AzCore/Settings/SettingsRegistry.h>
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
#include <AzFramework/FileFunc/FileFunc.h>
|
||||
|
||||
namespace AZ::Prefab
|
||||
{
|
||||
static constexpr const char s_useProceduralPrefabsKey[] = "/O3DE/Preferences/Prefabs/UseProceduralPrefabs";
|
||||
|
||||
// ProceduralPrefabAsset
|
||||
|
||||
ProceduralPrefabAsset::ProceduralPrefabAsset(const AZ::Data::AssetId& assetId)
|
||||
@@ -58,9 +57,14 @@ namespace AZ::Prefab
|
||||
|
||||
bool ProceduralPrefabAsset::UseProceduralPrefabs()
|
||||
{
|
||||
bool useProceduralPrefabs = false;
|
||||
bool result = AZ::SettingsRegistry::Get()->GetObject(useProceduralPrefabs, s_useProceduralPrefabsKey);
|
||||
return result && useProceduralPrefabs;
|
||||
bool prefabsEnabled = false;
|
||||
AzFramework::ApplicationRequests::Bus::Broadcast(
|
||||
[&prefabsEnabled](AzFramework::ApplicationRequests::Bus::Events* ebus)
|
||||
{
|
||||
prefabsEnabled = ebus->IsPrefabSystemEnabled();
|
||||
});
|
||||
|
||||
return prefabsEnabled;
|
||||
}
|
||||
|
||||
// PrefabDomData
|
||||
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* 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 <AssetCatalog/PlatformAddressedAssetCatalogBus.h>
|
||||
#include <AzCore/Serialization/Json/JsonUtils.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzFramework/Asset/AssetCatalogBus.h>
|
||||
#include <AzToolsFramework/Prefab/ProceduralPrefabSystemComponent.h>
|
||||
#include <Prefab/PrefabDomUtils.h>
|
||||
#include <Prefab/PrefabLoaderInterface.h>
|
||||
#include <Prefab/PrefabSystemComponentInterface.h>
|
||||
#include <Prefab/Procedural/ProceduralPrefabAsset.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace Prefab
|
||||
{
|
||||
void ProceduralPrefabSystemComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto serializationContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializationContext->Class<ProceduralPrefabSystemComponent, AZ::Component>();
|
||||
}
|
||||
}
|
||||
|
||||
void ProceduralPrefabSystemComponent::Activate()
|
||||
{
|
||||
AZ::Interface<ProceduralPrefabSystemComponentInterface>::Register(this);
|
||||
AzFramework::AssetCatalogEventBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void ProceduralPrefabSystemComponent::Deactivate()
|
||||
{
|
||||
AzFramework::AssetCatalogEventBus::Handler::BusDisconnect();
|
||||
AZ::Interface<ProceduralPrefabSystemComponentInterface>::Unregister(this);
|
||||
|
||||
AZStd::scoped_lock lock(m_lookupMutex);
|
||||
m_assetIdToTemplateLookup.clear();
|
||||
}
|
||||
|
||||
void ProceduralPrefabSystemComponent::OnCatalogAssetChanged(const AZ::Data::AssetId& assetId)
|
||||
{
|
||||
TemplateId templateId = InvalidTemplateId;
|
||||
|
||||
{
|
||||
AZStd::scoped_lock lock(m_lookupMutex);
|
||||
auto itr = m_assetIdToTemplateLookup.find(assetId);
|
||||
|
||||
if (itr != m_assetIdToTemplateLookup.end())
|
||||
{
|
||||
templateId = itr->second;
|
||||
}
|
||||
}
|
||||
|
||||
if (templateId != InvalidTemplateId)
|
||||
{
|
||||
auto prefabSystemComponentInterface = AZ::Interface<PrefabSystemComponentInterface>::Get();
|
||||
|
||||
if (!prefabSystemComponentInterface)
|
||||
{
|
||||
AZ_Error("Prefab", false, "Failed to get PrefabSystemComponentInterface");
|
||||
return;
|
||||
}
|
||||
|
||||
AZStd::string assetPath;
|
||||
AZ::Data::AssetCatalogRequestBus::BroadcastResult(
|
||||
assetPath, &AZ::Data::AssetCatalogRequestBus::Events::GetAssetPathById, assetId);
|
||||
|
||||
auto readResult = AZ::Utils::ReadFile(assetPath, AZStd::numeric_limits<size_t>::max());
|
||||
if (!readResult.IsSuccess())
|
||||
{
|
||||
AZ_Error(
|
||||
"Prefab", false,
|
||||
"ProceduralPrefabSystemComponent::OnCatalogAssetChanged - Failed to read Prefab file from '%.*s'."
|
||||
"Error message: '%s'",
|
||||
AZ_STRING_ARG(assetPath), readResult.GetError().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
AZ::Outcome<PrefabDom, AZStd::string> readPrefabFileResult = AZ::JsonSerializationUtils::ReadJsonString(readResult.TakeValue());
|
||||
if (!readPrefabFileResult.IsSuccess())
|
||||
{
|
||||
AZ_Error(
|
||||
"Prefab", false,
|
||||
"ProceduralPrefabSystemComponent::OnCatalogAssetChanged - Failed to read Prefab json from '%.*s'."
|
||||
"Error message: '%s'",
|
||||
AZ_STRING_ARG(assetPath), readPrefabFileResult.GetError().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
AZ::IO::Path relativePath = AZ::Interface<PrefabLoaderInterface>::Get()->GenerateRelativePath(assetPath.c_str());
|
||||
PrefabDomPath sourcePath = PrefabDomPath((AZStd::string("/") + PrefabDomUtils::SourceName).c_str());
|
||||
sourcePath.Set(readPrefabFileResult.GetValue(), relativePath.Native().c_str());
|
||||
|
||||
prefabSystemComponentInterface->UpdatePrefabTemplate(templateId, readPrefabFileResult.TakeValue());
|
||||
}
|
||||
}
|
||||
|
||||
void ProceduralPrefabSystemComponent::OnTemplateRemoved(TemplateId removedTemplateId)
|
||||
{
|
||||
AZStd::scoped_lock lock(m_lookupMutex);
|
||||
|
||||
for (const auto& [assetId, templateId] : m_assetIdToTemplateLookup)
|
||||
{
|
||||
if (templateId == removedTemplateId)
|
||||
{
|
||||
m_assetIdToTemplateLookup.erase(assetId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProceduralPrefabSystemComponent::OnAllTemplatesRemoved()
|
||||
{
|
||||
AZStd::scoped_lock lock(m_lookupMutex);
|
||||
|
||||
m_assetIdToTemplateLookup.clear();
|
||||
}
|
||||
|
||||
void ProceduralPrefabSystemComponent::RegisterProceduralPrefab(const AZStd::string& prefabFilePath, TemplateId templateId)
|
||||
{
|
||||
AZ::Data::AssetId assetId;
|
||||
AZ::Data::AssetCatalogRequestBus::BroadcastResult(
|
||||
assetId, &AZ::Data::AssetCatalogRequestBus::Events::GetAssetIdByPath, prefabFilePath.c_str(),
|
||||
azrtti_typeid<AZ::Prefab::ProceduralPrefabAsset>(), false);
|
||||
|
||||
if (assetId.IsValid())
|
||||
{
|
||||
AZStd::scoped_lock lock(m_lookupMutex);
|
||||
m_assetIdToTemplateLookup[assetId] = templateId;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Error("Prefab", false, "Failed to find AssetId for prefab %s", prefabFilePath.c_str());
|
||||
}
|
||||
}
|
||||
} // namespace Prefab
|
||||
} // namespace AzToolsFramework
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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 <AzCore/Component/Component.h>
|
||||
#include <Prefab/ProceduralPrefabSystemComponentInterface.h>
|
||||
#include <AzFramework/Asset/AssetCatalogBus.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabPublicNotificationBus.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace Prefab
|
||||
{
|
||||
class ProceduralPrefabSystemComponent
|
||||
: public AZ::Component
|
||||
, ProceduralPrefabSystemComponentInterface
|
||||
, AzFramework::AssetCatalogEventBus::Handler
|
||||
, PrefabPublicNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(ProceduralPrefabSystemComponent, "{81211818-088A-49E6-894B-7A11764106B1}");
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
protected:
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
|
||||
void OnCatalogAssetChanged(const AZ::Data::AssetId&) override;
|
||||
|
||||
void OnTemplateRemoved(TemplateId templateId) override;
|
||||
void OnAllTemplatesRemoved() override;
|
||||
|
||||
void RegisterProceduralPrefab(const AZStd::string& prefabFilePath, TemplateId templateId) override;
|
||||
|
||||
AZStd::mutex m_lookupMutex;
|
||||
AZStd::unordered_map<AZ::Data::AssetId, TemplateId> m_assetIdToTemplateLookup;
|
||||
};
|
||||
} // namespace Prefab
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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 <AzCore/RTTI/RTTI.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabIdTypes.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace Prefab
|
||||
{
|
||||
class ProceduralPrefabSystemComponentInterface
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(ProceduralPrefabSystemComponentInterface, "{C403B89C-63DD-418C-B821-FBCBE1EF42AE}");
|
||||
|
||||
virtual ~ProceduralPrefabSystemComponentInterface() = default;
|
||||
|
||||
// Registers a procedural prefab file + templateId so the system can track changes and handle updates
|
||||
virtual void RegisterProceduralPrefab(const AZStd::string& prefabFilePath, TemplateId templateId) = 0;
|
||||
};
|
||||
|
||||
} // namespace Prefab
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+35
-12
@@ -26,7 +26,9 @@
|
||||
#include <AzToolsFramework/Entity/EditorEntityTransformBus.h>
|
||||
#include <AzToolsFramework/API/EntityPropertyEditorRequestsBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/ContainerEntity/ContainerEntityInterface.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
#include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntityInterface.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabPublicInterface.h>
|
||||
#include <AzToolsFramework/ToolsComponents/TransformComponentBus.h>
|
||||
#include <AzToolsFramework/ToolsComponents/TransformComponentSerializer.h>
|
||||
@@ -35,9 +37,8 @@
|
||||
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportMessages.h>
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
@@ -662,7 +663,6 @@ namespace AzToolsFramework
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Prevent this from parenting to its own child. Check if this entity is in the new parent's hierarchy.
|
||||
auto potentialParentTransformComponent = GetTransformComponent(parentId);
|
||||
if (potentialParentTransformComponent && potentialParentTransformComponent->IsEntityInHierarchy(GetEntityId()))
|
||||
@@ -931,14 +931,27 @@ namespace AzToolsFramework
|
||||
{
|
||||
return AZ::Failure(AZStd::string("You cannot set an entity's parent to itself!"));
|
||||
}
|
||||
else
|
||||
|
||||
// Don't allow the change if it will result in a cycle hierarchy
|
||||
auto potentialParentTransformComponent = GetTransformComponent(actualValue);
|
||||
if (potentialParentTransformComponent && potentialParentTransformComponent->IsEntityInHierarchy(GetEntityId()))
|
||||
{
|
||||
// Don't allow the change if it will result in a cycle hierarchy
|
||||
auto potentialParentTransformComponent = GetTransformComponent(actualValue);
|
||||
if (potentialParentTransformComponent && potentialParentTransformComponent->IsEntityInHierarchy(GetEntityId()))
|
||||
{
|
||||
return AZ::Failure(AZStd::string("You cannot set an entity to be a child of one of its own children!"));
|
||||
}
|
||||
return AZ::Failure(AZStd::string("You cannot set an entity to be a child of one of its own children!"));
|
||||
}
|
||||
|
||||
// Don't allow read-only entities to be re-parented at all.
|
||||
// Also don't allow entities to be parented under read-only entities.
|
||||
if (auto readOnlyEntityPublicInterface = AZ::Interface<ReadOnlyEntityPublicInterface>::Get();
|
||||
readOnlyEntityPublicInterface->IsReadOnly(GetEntityId()) || readOnlyEntityPublicInterface->IsReadOnly(actualValue))
|
||||
{
|
||||
return AZ::Failure(AZStd::string("You cannot set an entity to be a child of a read-only entity!"));
|
||||
}
|
||||
|
||||
// Don't allow entities to be parented under closed containers.
|
||||
if (auto containerEntityInterface = AZ::Interface<ContainerEntityInterface>::Get();
|
||||
!containerEntityInterface->IsContainerOpen(actualValue))
|
||||
{
|
||||
return AZ::Failure(AZStd::string("You cannot set an entity to be a child of a closed container!"));
|
||||
}
|
||||
|
||||
return AZ::Success();
|
||||
@@ -1245,6 +1258,15 @@ namespace AzToolsFramework
|
||||
|
||||
void TransformComponent::AddContextMenuActions(QMenu* menu)
|
||||
{
|
||||
bool parentEntityIsReadOnly = false;
|
||||
|
||||
// If the parent entity is marked as read-only, don't allow actions on this transform.
|
||||
if (auto readOnlyEntityPublicInterface = AZ::Interface<ReadOnlyEntityPublicInterface>::Get();
|
||||
readOnlyEntityPublicInterface->IsReadOnly(GetEntityId()))
|
||||
{
|
||||
parentEntityIsReadOnly = true;
|
||||
}
|
||||
|
||||
if (menu)
|
||||
{
|
||||
if (!menu->actions().empty())
|
||||
@@ -1266,10 +1288,10 @@ namespace AzToolsFramework
|
||||
|
||||
AzToolsFramework::ToolsApplicationEvents::Bus::Broadcast(&AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_Values);
|
||||
});
|
||||
resetAction->setEnabled(!m_editorTransform.m_locked);
|
||||
resetAction->setEnabled(!m_editorTransform.m_locked && !parentEntityIsReadOnly);
|
||||
|
||||
QString lockString = m_editorTransform.m_locked ? "Unlock transform values" : "Lock transform values";
|
||||
menu->addAction(lockString, [this, lockString]()
|
||||
QAction* lockAction = menu->addAction(lockString, [this, lockString]()
|
||||
{
|
||||
{
|
||||
AzToolsFramework::ScopedUndoBatch undo(lockString.toUtf8().data());
|
||||
@@ -1278,6 +1300,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
AzToolsFramework::ToolsApplicationEvents::Bus::Broadcast(&AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_AttributesAndValues);
|
||||
});
|
||||
lockAction->setEnabled(!parentEntityIsReadOnly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -548,11 +548,11 @@ namespace AzToolsFramework
|
||||
AZ::EntityId entityId = GetEntityFromIndex(index);
|
||||
|
||||
// Only allow renaming the entity if the UI Handler did not block it.
|
||||
auto entityUiHandler = m_editorEntityUiInterface->GetHandler(entityId);
|
||||
auto entityUiHandler = m_editorEntityUiInterface ? m_editorEntityUiInterface->GetHandler(entityId) : nullptr;
|
||||
bool canRename = !entityUiHandler || entityUiHandler->CanRename(entityId);
|
||||
|
||||
// Disable renaming for read-only entities.
|
||||
bool isReadOnly = m_readOnlyEntityPublicInterface->IsReadOnly(entityId);
|
||||
bool isReadOnly = m_readOnlyEntityPublicInterface ? m_readOnlyEntityPublicInterface->IsReadOnly(entityId) : false;
|
||||
|
||||
Qt::ItemFlags itemFlags = QAbstractItemModel::flags(index);
|
||||
switch (index.column())
|
||||
|
||||
+25
-14
@@ -27,6 +27,7 @@
|
||||
#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
|
||||
#include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntityInterface.h>
|
||||
#include <AzToolsFramework/FocusMode/FocusModeInterface.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportMessages.h>
|
||||
#include <AzToolsFramework/UI/ComponentPalette/ComponentPaletteUtil.hxx>
|
||||
#include <AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.h>
|
||||
@@ -154,9 +155,15 @@ namespace AzToolsFramework
|
||||
{
|
||||
initEntityOutlinerWidgetResources();
|
||||
|
||||
AzToolsFramework::EditorEntityContextRequestBus::BroadcastResult(
|
||||
m_editorEntityContextId, &AzToolsFramework::EditorEntityContextRequestBus::Events::GetEditorEntityContextId);
|
||||
|
||||
m_editorEntityUiInterface = AZ::Interface<AzToolsFramework::EditorEntityUiInterface>::Get();
|
||||
AZ_Assert(m_editorEntityUiInterface != nullptr, "EntityOutlinerWidget requires a EditorEntityUiInterface instance on Initialize.");
|
||||
|
||||
m_focusModeInterface = AZ::Interface<AzToolsFramework::FocusModeInterface>::Get();
|
||||
AZ_Assert(m_focusModeInterface != nullptr, "EntityOutlinerWidget requires a FocusModeInterface instance on Initialize.");
|
||||
|
||||
m_readOnlyEntityPublicInterface = AZ::Interface<AzToolsFramework::ReadOnlyEntityPublicInterface>::Get();
|
||||
AZ_Assert(
|
||||
(m_readOnlyEntityPublicInterface != nullptr),
|
||||
@@ -609,23 +616,27 @@ namespace AzToolsFramework
|
||||
{
|
||||
AZ::EntityId entityId = m_selectedEntityIds[0];
|
||||
|
||||
AZ::EntityId parentId;
|
||||
EditorEntityInfoRequestBus::EventResult(parentId, entityId, &EditorEntityInfoRequestBus::Events::GetParent);
|
||||
|
||||
EntityOrderArray entityOrderArray = GetEntityChildOrder(parentId);
|
||||
|
||||
if (entityOrderArray.size() > 1)
|
||||
// Don't allow moving the entity if it's the focus root.
|
||||
if (m_focusModeInterface->GetFocusRoot(m_editorEntityContextId) != entityId)
|
||||
{
|
||||
if (AZStd::find(entityOrderArray.begin(), entityOrderArray.end(), entityId) != entityOrderArray.end())
|
||||
{
|
||||
if (entityOrderArray.front() != entityId)
|
||||
{
|
||||
contextMenu->addAction(m_actionToMoveEntityUp);
|
||||
}
|
||||
AZ::EntityId parentId;
|
||||
EditorEntityInfoRequestBus::EventResult(parentId, entityId, &EditorEntityInfoRequestBus::Events::GetParent);
|
||||
|
||||
if (entityOrderArray.back() != entityId)
|
||||
EntityOrderArray entityOrderArray = GetEntityChildOrder(parentId);
|
||||
|
||||
if (entityOrderArray.size() > 1)
|
||||
{
|
||||
if (AZStd::find(entityOrderArray.begin(), entityOrderArray.end(), entityId) != entityOrderArray.end())
|
||||
{
|
||||
contextMenu->addAction(m_actionToMoveEntityDown);
|
||||
if (entityOrderArray.front() != entityId)
|
||||
{
|
||||
contextMenu->addAction(m_actionToMoveEntityUp);
|
||||
}
|
||||
|
||||
if (entityOrderArray.back() != entityId)
|
||||
{
|
||||
contextMenu->addAction(m_actionToMoveEntityDown);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace AzToolsFramework
|
||||
class EntityOutlinerListModel;
|
||||
class EntityOutlinerContainerProxyModel;
|
||||
class EntityOutlinerSortFilterProxyModel;
|
||||
class FocusModeInterface;
|
||||
class ReadOnlyEntityPublicInterface;
|
||||
|
||||
namespace EntityOutliner
|
||||
@@ -204,7 +205,10 @@ namespace AzToolsFramework
|
||||
EntityOutliner::DisplaySortMode m_sortMode;
|
||||
bool m_sortContentQueued;
|
||||
|
||||
AzFramework::EntityContextId m_editorEntityContextId = AzFramework::EntityContextId::CreateNull();
|
||||
|
||||
EditorEntityUiInterface* m_editorEntityUiInterface = nullptr;
|
||||
FocusModeInterface* m_focusModeInterface = nullptr;
|
||||
ReadOnlyEntityPublicInterface* m_readOnlyEntityPublicInterface = nullptr;
|
||||
};
|
||||
|
||||
|
||||
+66
-33
@@ -277,6 +277,26 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
bool onlySelectedEntityIsFocusedPrefabContainer = false;
|
||||
bool onlySelectedEntityIsClosedPrefabContainer = false;
|
||||
|
||||
if (selectedEntities.size() == 1)
|
||||
{
|
||||
AZ::EntityId selectedEntity = selectedEntities.front();
|
||||
|
||||
if (s_prefabPublicInterface->IsInstanceContainerEntity(selectedEntity))
|
||||
{
|
||||
if (s_prefabFocusPublicInterface->IsOwningPrefabBeingFocused(selectedEntity))
|
||||
{
|
||||
onlySelectedEntityIsFocusedPrefabContainer = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
onlySelectedEntityIsClosedPrefabContainer = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool itemWasShown = false;
|
||||
|
||||
// Create Prefab
|
||||
@@ -284,8 +304,7 @@ namespace AzToolsFramework
|
||||
if (!selectedEntities.empty())
|
||||
{
|
||||
// Hide if the only selected entity is the Focused Instance Container
|
||||
if (selectedEntities.size() > 1 ||
|
||||
selectedEntities[0] != s_prefabFocusPublicInterface->GetFocusedPrefabContainerEntityId(s_editorEntityContextId))
|
||||
if (!onlySelectedEntityIsFocusedPrefabContainer)
|
||||
{
|
||||
bool layerInSelection = false;
|
||||
|
||||
@@ -322,7 +341,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
// Instantiate Prefab
|
||||
if (!readOnlyEntityInSelection)
|
||||
if (selectedEntities.size() == 1 && !readOnlyEntityInSelection && !onlySelectedEntityIsClosedPrefabContainer)
|
||||
{
|
||||
QAction* instantiateAction = menu->addAction(QObject::tr("Instantiate Prefab..."));
|
||||
instantiateAction->setToolTip(QObject::tr("Instantiates a prefab file in the scene."));
|
||||
@@ -330,17 +349,15 @@ namespace AzToolsFramework
|
||||
QObject::connect(
|
||||
instantiateAction, &QAction::triggered, instantiateAction, [] { ContextMenu_InstantiatePrefab(); });
|
||||
|
||||
itemWasShown = true;
|
||||
}
|
||||
// Instantiate Procedural Prefab
|
||||
if (AZ::Prefab::ProceduralPrefabAsset::UseProceduralPrefabs())
|
||||
{
|
||||
QAction* action = menu->addAction(QObject::tr("Instantiate Procedural Prefab..."));
|
||||
action->setToolTip(QObject::tr("Instantiates a procedural prefab file in a prefab."));
|
||||
|
||||
// Instantiate Procedural Prefab
|
||||
if (AZ::Prefab::ProceduralPrefabAsset::UseProceduralPrefabs() && !readOnlyEntityInSelection)
|
||||
{
|
||||
QAction* action = menu->addAction(QObject::tr("Instantiate Procedural Prefab..."));
|
||||
action->setToolTip(QObject::tr("Instantiates a procedural prefab file in a prefab."));
|
||||
|
||||
QObject::connect(
|
||||
action, &QAction::triggered, action, [] { ContextMenu_InstantiateProceduralPrefab(); });
|
||||
QObject::connect(
|
||||
action, &QAction::triggered, action, [] { ContextMenu_InstantiateProceduralPrefab(); });
|
||||
}
|
||||
|
||||
itemWasShown = true;
|
||||
}
|
||||
@@ -362,14 +379,34 @@ namespace AzToolsFramework
|
||||
{
|
||||
if (!s_prefabFocusPublicInterface->IsOwningPrefabBeingFocused(selectedEntity))
|
||||
{
|
||||
// Edit Prefab
|
||||
QAction* editAction = menu->addAction(QObject::tr("Open/Edit Prefab"));
|
||||
editAction->setShortcut(QKeySequence(Qt::Key_Plus));
|
||||
editAction->setToolTip(QObject::tr("Edit the prefab in focus mode."));
|
||||
if (s_prefabPublicInterface->IsOwnedByProceduralPrefabInstance(selectedEntity))
|
||||
{
|
||||
// Inspect Prefab
|
||||
QAction* editAction = menu->addAction(QObject::tr("Inspect Procedural Prefab"));
|
||||
editAction->setShortcut(QKeySequence(Qt::Key_Plus));
|
||||
editAction->setToolTip(QObject::tr("See the procedural prefab contents in focus mode."));
|
||||
|
||||
QObject::connect(editAction, &QAction::triggered, editAction, [selectedEntity] {
|
||||
ContextMenu_EditPrefab(selectedEntity);
|
||||
});
|
||||
QObject::connect(
|
||||
editAction, &QAction::triggered, editAction,
|
||||
[selectedEntity]
|
||||
{
|
||||
ContextMenu_EditPrefab(selectedEntity);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// Edit Prefab
|
||||
QAction* editAction = menu->addAction(QObject::tr("Open/Edit Prefab"));
|
||||
editAction->setShortcut(QKeySequence(Qt::Key_Plus));
|
||||
editAction->setToolTip(QObject::tr("Edit the prefab in focus mode."));
|
||||
|
||||
QObject::connect(
|
||||
editAction, &QAction::triggered, editAction,
|
||||
[selectedEntity]
|
||||
{
|
||||
ContextMenu_EditPrefab(selectedEntity);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -420,21 +457,17 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
// Detach Prefab
|
||||
if (selectedEntities.size() == 1)
|
||||
if (onlySelectedEntityIsClosedPrefabContainer)
|
||||
{
|
||||
AZ::EntityId selectedEntityId = selectedEntities[0];
|
||||
AZ::EntityId selectedEntityId = selectedEntities.front();
|
||||
|
||||
if (s_prefabPublicInterface->IsInstanceContainerEntity(selectedEntityId) &&
|
||||
selectedEntityId != s_prefabFocusPublicInterface->GetFocusedPrefabContainerEntityId(s_editorEntityContextId))
|
||||
{
|
||||
QAction* detachPrefabAction = menu->addAction(QObject::tr("Detach Prefab..."));
|
||||
QObject::connect(
|
||||
detachPrefabAction, &QAction::triggered, detachPrefabAction,
|
||||
[selectedEntityId]
|
||||
{
|
||||
ContextMenu_DetachPrefab(selectedEntityId);
|
||||
});
|
||||
}
|
||||
QAction* detachPrefabAction = menu->addAction(QObject::tr("Detach Prefab..."));
|
||||
QObject::connect(
|
||||
detachPrefabAction, &QAction::triggered, detachPrefabAction,
|
||||
[selectedEntityId]
|
||||
{
|
||||
ContextMenu_DetachPrefab(selectedEntityId);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ namespace AzToolsFramework
|
||||
void PopulateEditorGlobalContextMenu(QMenu* menu, const AZ::Vector2& point, int flags) override;
|
||||
|
||||
// EditorEventsBus overrides ...
|
||||
void OnEscape();
|
||||
void OnEscape() override;
|
||||
|
||||
// EntityOutlinerSourceDropHandlingBus overrides ...
|
||||
void HandleSourceFileType(AZStd::string_view sourceFilePath, AZ::EntityId parentId, AZ::Vector3 position) const override;
|
||||
|
||||
@@ -89,8 +89,8 @@ namespace AzToolsFramework
|
||||
const float rayLength)
|
||||
{
|
||||
AZ_Assert(rayLength > 0.0f, "Invalid ray length passed to RefreshRayRequest");
|
||||
rayRequest.m_startWorldPosition = viewportRay.origin;
|
||||
rayRequest.m_endWorldPosition = viewportRay.origin + viewportRay.direction * rayLength;
|
||||
rayRequest.m_startWorldPosition = viewportRay.m_origin;
|
||||
rayRequest.m_endWorldPosition = viewportRay.m_origin + viewportRay.m_direction * rayLength;
|
||||
}
|
||||
|
||||
AZ::Vector3 FindClosestPickIntersection(
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user