Merge branch 'development' of https://github.com/aws-lumberyard-dev/o3de into mnaumov/2679

This commit is contained in:
mnaumov
2021-08-17 09:53:04 -07:00
187 changed files with 2593 additions and 3304 deletions
@@ -8,7 +8,7 @@ INTRODUCTION
------------
EditorPythonBindings is a Python project that contains a collection of editor testing tools
developed by the Lumberyard feature teams. The project contains tools for system level
developed by the O3DE feature teams. The project contains tools for system level
editor tests.
@@ -23,7 +23,7 @@ installed on your system.
INSTALL
-----------
It is recommended to set up these these tools with Lumberyard's CMake build commands.
It is recommended to set up these these tools with O3DE's CMake build commands.
Assuming CMake is already setup on your operating system, below are some sample build commands:
cd /path/to/od3e/
mkdir windows_vs2019
@@ -27,19 +27,19 @@ class TestPythonAssetProcessing(object):
unexpected_lines = []
expected_lines = [
'Mock asset exists',
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_positive.azmodel) found',
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_negative.azmodel) found',
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_positive.azmodel) found',
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_negative.azmodel) found',
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_positive.azmodel) found',
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_negative.azmodel) found',
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center.azmodel) found'
'AssetId found for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_positive_1.azmodel) found',
'AssetId found for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_negative_1.azmodel) found',
'AssetId found for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_positive_1.azmodel) found',
'AssetId found for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_negative_1.azmodel) found',
'AssetId found for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_positive_1.azmodel) found',
'AssetId found for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_negative_1.azmodel) found',
'AssetId found for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center_1.azmodel) found'
]
timeout = 180
halt_on_unexpected = False
test_directory = os.path.join(os.path.dirname(__file__))
testFile = os.path.join(test_directory, 'AssetBuilder_test_case.py')
editor.args.extend(['-NullRenderer', "--skipWelcomeScreenDialog", "--autotest_mode", "--runpythontest", testFile])
editor.args.extend(['-NullRenderer', '-rhi=Null', "--skipWelcomeScreenDialog", "--autotest_mode", "--runpythontest", testFile])
with editor.start():
editorlog_file = os.path.join(editor.workspace.paths.project_log(), 'Editor.log')
@@ -29,21 +29,21 @@ if (assetIdString.endswith(':528cca58') is False):
print ('Mock asset exists')
# These tests detect if the geom_group.fbx file turns into a number of azmodel product assets
def test_azmodel_product(generatedModelAssetPath, expectedSubId):
def test_azmodel_product(generatedModelAssetPath):
azModelAssetType = azlmbr.math.Uuid_CreateString('{2C7477B6-69C5-45BE-8163-BCD6A275B6D8}', 0)
assetId = azlmbr.asset.AssetCatalogRequestBus(azlmbr.bus.Broadcast, 'GetAssetIdByPath', generatedModelAssetPath, azModelAssetType, False)
assetIdString = assetId.to_string()
if (assetIdString.endswith(':' + expectedSubId) is False):
raise_and_stop(f'Asset at path {generatedModelAssetPath} has unexpected asset ID ({assetIdString}) for ({generatedModelAssetPath}), expected {expectedSubId}!')
if (assetId.is_valid()):
print(f'AssetId found for asset ({generatedModelAssetPath}) found')
else:
print(f'Expected subId for asset ({generatedModelAssetPath}) found')
raise_and_stop(f'Asset at path {generatedModelAssetPath} has unexpected asset ID ({assetIdString})!')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_positive.azmodel', '1024be55')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_negative.azmodel', '1052c94e')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_positive.azmodel', '10130556')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_negative.azmodel', '1065724d')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_positive.azmodel', '10d16e68')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_negative.azmodel', '10a71973')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center.azmodel', '10412075')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_positive_1.azmodel')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_negative_1.azmodel')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_positive_1.azmodel')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_negative_1.azmodel')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_positive_1.azmodel')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_negative_1.azmodel')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center_1.azmodel')
azlmbr.editor.EditorToolsApplicationRequestBus(azlmbr.bus.Broadcast, 'ExitNoPrompt')
@@ -206,8 +206,8 @@ def run():
# PostFX Layer Component
ComponentTests("PostFX Layer")
# Radius Weight Modifier Component
ComponentTests("Radius Weight Modifier")
# PostFX Radius Weight Modifier Component
ComponentTests("PostFX Radius Weight Modifier")
# Light Component
ComponentTests("Light")
@@ -47,28 +47,28 @@ def open_material(file_path):
"""
:return: uuid of material document opened
"""
return materialeditor.MaterialDocumentSystemRequestBus(bus.Broadcast, "OpenDocument", file_path)
return azlmbr.atomtools.AtomToolsDocumentSystemRequestBus(bus.Broadcast, "OpenDocument", file_path)
def is_open(document_id):
"""
:return: bool
"""
return materialeditor.MaterialDocumentRequestBus(bus.Event, "IsOpen", document_id)
return azlmbr.atomtools.AtomToolsDocumentRequestBus(bus.Event, "IsOpen", document_id)
def save_document(document_id):
"""
:return: bool success
"""
return materialeditor.MaterialDocumentSystemRequestBus(bus.Broadcast, "SaveDocument", document_id)
return azlmbr.atomtools.AtomToolsDocumentSystemRequestBus(bus.Broadcast, "SaveDocument", document_id)
def save_document_as_copy(document_id, target_path):
"""
:return: bool success
"""
return materialeditor.MaterialDocumentSystemRequestBus(
return azlmbr.atomtools.AtomToolsDocumentSystemRequestBus(
bus.Broadcast, "SaveDocumentAsCopy", document_id, target_path
)
@@ -77,7 +77,7 @@ def save_document_as_child(document_id, target_path):
"""
:return: bool success
"""
return materialeditor.MaterialDocumentSystemRequestBus(
return azlmbr.atomtools.AtomToolsDocumentSystemRequestBus(
bus.Broadcast, "SaveDocumentAsChild", document_id, target_path
)
@@ -86,39 +86,39 @@ def save_all():
"""
:return: bool success
"""
return materialeditor.MaterialDocumentSystemRequestBus(bus.Broadcast, "SaveAllDocuments")
return azlmbr.atomtools.AtomToolsDocumentSystemRequestBus(bus.Broadcast, "SaveAllDocuments")
def close_document(document_id):
"""
:return: bool success
"""
return materialeditor.MaterialDocumentSystemRequestBus(bus.Broadcast, "CloseDocument", document_id)
return azlmbr.atomtools.AtomToolsDocumentSystemRequestBus(bus.Broadcast, "CloseDocument", document_id)
def close_all_documents():
"""
:return: bool success
"""
return materialeditor.MaterialDocumentSystemRequestBus(bus.Broadcast, "CloseAllDocuments")
return azlmbr.atomtools.AtomToolsDocumentSystemRequestBus(bus.Broadcast, "CloseAllDocuments")
def close_all_except_selected(document_id):
"""
:return: bool success
"""
return materialeditor.MaterialDocumentSystemRequestBus(bus.Broadcast, "CloseAllDocumentsExcept", document_id)
return azlmbr.atomtools.AtomToolsDocumentSystemRequestBus(bus.Broadcast, "CloseAllDocumentsExcept", document_id)
def get_property(document_id, property_name):
"""
:return: property value or invalid value if the document is not open or the property_name can't be found
"""
return materialeditor.MaterialDocumentRequestBus(bus.Event, "GetPropertyValue", document_id, property_name)
return azlmbr.atomtools.AtomToolsDocumentRequestBus(bus.Event, "GetPropertyValue", document_id, property_name)
def set_property(document_id, property_name, value):
materialeditor.MaterialDocumentRequestBus(bus.Event, "SetPropertyValue", document_id, property_name, value)
azlmbr.atomtools.AtomToolsDocumentRequestBus(bus.Event, "SetPropertyValue", document_id, property_name, value)
def is_pane_visible(pane_name):
@@ -175,7 +175,7 @@ def wait_for_condition(function, timeout_in_seconds=1.0):
with Timeout(timeout_in_seconds) as t:
while True:
try:
atomtools.general.idle_wait_frames(1)
azlmbr.atomtools.general.idle_wait_frames(1)
except Exception:
print("WARNING: Couldn't wait for frame")
@@ -269,6 +269,6 @@ class ScreenshotHelper:
def capture_screenshot(file_path):
return ScreenshotHelper(atomtools.general.idle_wait_frames).capture_screenshot_blocking(
return ScreenshotHelper(azlmbr.atomtools.general.idle_wait_frames).capture_screenshot_blocking(
os.path.join(file_path)
)
@@ -32,7 +32,7 @@ class TestAtomEditorComponentsMain(object):
Tests the following Atom components and verifies all "expected_lines" appear in Editor.log:
1. Display Mapper
2. Light
3. Radius Weight Modifier
3. PostFX Radius Weight Modifier
4. PostFX Layer
5. Physical Sky
6. Global Skylight (IBL)
@@ -126,18 +126,18 @@ class TestAtomEditorComponentsMain(object):
"PostFX Layer_test: Entity deleted: True",
"PostFX Layer_test: UNDO entity deletion works: True",
"PostFX Layer_test: REDO entity deletion works: True",
# Radius Weight Modifier Component
"Radius Weight Modifier Entity successfully created",
"Radius Weight Modifier_test: Component added to the entity: True",
"Radius Weight Modifier_test: Component removed after UNDO: True",
"Radius Weight Modifier_test: Component added after REDO: True",
"Radius Weight Modifier_test: Entered game mode: True",
"Radius Weight Modifier_test: Exit game mode: True",
"Radius Weight Modifier_test: Entity is hidden: True",
"Radius Weight Modifier_test: Entity is shown: True",
"Radius Weight Modifier_test: Entity deleted: True",
"Radius Weight Modifier_test: UNDO entity deletion works: True",
"Radius Weight Modifier_test: REDO entity deletion works: True",
# PostFX Radius Weight Modifier Component
"PostFX Radius Weight Modifier Entity successfully created",
"PostFX Radius Weight Modifier_test: Component added to the entity: True",
"PostFX Radius Weight Modifier_test: Component removed after UNDO: True",
"PostFX Radius Weight Modifier_test: Component added after REDO: True",
"PostFX Radius Weight Modifier_test: Entered game mode: True",
"PostFX Radius Weight Modifier_test: Exit game mode: True",
"PostFX Radius Weight Modifier_test: Entity is hidden: True",
"PostFX Radius Weight Modifier_test: Entity is shown: True",
"PostFX Radius Weight Modifier_test: Entity deleted: True",
"PostFX Radius Weight Modifier_test: UNDO entity deletion works: True",
"PostFX Radius Weight Modifier_test: REDO entity deletion works: True",
# Light Component
"Light Entity successfully created",
"Light_test: Component added to the entity: True",
@@ -61,7 +61,7 @@ class AssetPickerUIUXTest(EditorTestHelper):
5) Verify if Mesh Asset is assigned via both OK/Enter options
Note:
- This test file must be called from the Lumberyard Editor command terminal
- This test file must be called from the O3DE Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
@@ -37,7 +37,7 @@ class TestBasicEditorWorkflows(EditorTestHelper):
async def run_test(self):
"""
Summary:
Open Lumberyard editor and check if basic Editor workflows are completable.
Open O3DE editor and check if basic Editor workflows are completable.
Expected Behavior:
- A new level can be created
@@ -48,7 +48,7 @@ class TestBasicEditorWorkflows(EditorTestHelper):
- Level can be exported
Note:
- This test file must be called from the Lumberyard Editor command terminal
- This test file must be called from the O3DE Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
@@ -36,7 +36,7 @@ class TestEditMenuOptions(EditorTestHelper):
2) Interact with Edit Menu options
Note:
- This test file must be called from the Lumberyard Editor command terminal
- This test file must be called from the O3DE Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
@@ -32,7 +32,7 @@ class TestFileMenuOptions(EditorTestHelper):
2) Interact with File Menu options
Note:
- This test file must be called from the Lumberyard Editor command terminal
- This test file must be called from the O3DE Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
@@ -36,7 +36,7 @@ class TestViewMenuOptions(EditorTestHelper):
2) Interact with View Menu options
Note:
- This test file must be called from the Lumberyard Editor command terminal
- This test file must be called from the O3DE Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
@@ -52,7 +52,7 @@ def Pane_PropertiesChanged_RetainsOnRestart():
from utils import TestHelper as helper
import pyside_utils
# Lumberyard Imports
# O3DE Imports
import azlmbr.legacy.general as general
# Pyside imports
@@ -53,7 +53,7 @@ def Editor_NewExistingLevels_Works():
10) Save, Load and Export an existing level and close editor
Note:
- This test file must be called from the Lumberyard Editor command terminal
- This test file must be called from the O3DE Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
@@ -1,17 +1,5 @@
{
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "iPhoneNotificationIcon40x40.png",
"scale" : "2x"
},
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "iPhoneNotificationIcon60x60.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
@@ -48,18 +36,6 @@
"filename" : "iPhoneAppIcon180x180.png",
"scale" : "3x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "iPadNotificationIcon20x20.png",
"scale" : "1x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "iPadNotificationIcon40x40.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "ipad",
@@ -101,16 +77,10 @@
"idiom" : "ipad",
"filename" : "iPadProAppIcon167x167.png",
"scale" : "2x"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "iOSAppStoreIcon1024x1024.png",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
}
@@ -1,17 +1,5 @@
{
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "iPhoneNotificationIcon40x40.png",
"scale" : "2x"
},
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "iPhoneNotificationIcon60x60.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
@@ -48,18 +36,6 @@
"filename" : "iPhoneAppIcon180x180.png",
"scale" : "3x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "iPadNotificationIcon20x20.png",
"scale" : "1x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "iPadNotificationIcon40x40.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "ipad",
@@ -101,16 +77,10 @@
"idiom" : "ipad",
"filename" : "iPadProAppIcon167x167.png",
"scale" : "2x"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "iOSAppStoreIcon1024x1024.png",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
}
@@ -1,50 +1,5 @@
{
"images" : [
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "2436h",
"filename" : "iPhoneLaunchImage1125x2436.png",
"minimum-system-version" : "11.0",
"orientation" : "portrait",
"scale" : "3x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "2436h",
"filename" : "iPhoneLaunchImage2436x1125.png",
"minimum-system-version" : "11.0",
"orientation" : "landscape",
"scale" : "3x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "736h",
"filename" : "iPhoneLaunchImage1242x2208.png",
"minimum-system-version" : "8.0",
"orientation" : "portrait",
"scale" : "3x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "736h",
"filename" : "iPhoneLaunchImage2208x1242.png",
"minimum-system-version" : "8.0",
"orientation" : "landscape",
"scale" : "3x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "667h",
"filename" : "iPhoneLaunchImage750x1334.png",
"minimum-system-version" : "8.0",
"orientation" : "portrait",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
@@ -166,4 +121,4 @@
"version" : 1,
"author" : "xcode"
}
}
}
+4
View File
@@ -238,9 +238,13 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
3rdParty::Qt::Core
3rdParty::Qt::Gui
3rdParty::Qt::Widgets
3rdParty::Qt::Test
Legacy::CryCommon
AZ::AzToolsFramework
AZ::AzToolsFramework.Tests
AZ::AzToolsFrameworkTestCommon
Legacy::EditorLib
Gem::AtomToolsFramework.Static
RUNTIME_DEPENDENCIES
Gem::LmbrCentral
)
@@ -10,7 +10,6 @@
// Editor
#include "PropertyCtrl.h"
#include "PropertyAnimationCtrl.h"
#include "PropertyResourceCtrl.h"
#include "PropertyGenericCtrl.h"
#include "PropertyMiscCtrl.h"
@@ -22,9 +21,7 @@ void RegisterReflectedVarHandlers()
if (!registered)
{
registered = true;
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew AnimationPropertyWidgetHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew FileResourceSelectorWidgetHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew ReverbPresetPropertyHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew SequencePropertyHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew SequenceIdPropertyHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew LocalStringPropertyHandler());
@@ -73,16 +73,6 @@ void GenericPopupPropertyEditor::SetPropertyType(PropertyType type)
m_propertyType = type;
}
void ReverbPresetPropertyEditor::onEditClicked()
{
CSelectEAXPresetDlg PresetDlg(this);
PresetDlg.SetCurrPreset(GetValue());
if (PresetDlg.exec() == QDialog::Accepted)
{
SetValue(PresetDlg.GetCurrPreset());
}
}
void SequencePropertyEditor::onEditClicked()
{
CSelectSequenceDialog gtDlg(this);
@@ -96,15 +96,6 @@ public:
}
};
class ReverbPresetPropertyEditor
: public GenericPopupPropertyEditor
{
public:
ReverbPresetPropertyEditor(QWidget* pParent = nullptr)
: GenericPopupPropertyEditor(pParent){}
void onEditClicked() override;
};
class MissionObjPropertyEditor
: public GenericPopupPropertyEditor
{
@@ -155,7 +146,6 @@ public:
// So we use our own
#define CONST_AZ_CRC(name, value) AZ::u32(value)
using ReverbPresetPropertyHandler = GenericPopupWidgetHandler<ReverbPresetPropertyEditor, CONST_AZ_CRC("ePropertyReverbPreset", 0x51469f38)>;
using MissionObjPropertyHandler = GenericPopupWidgetHandler<MissionObjPropertyEditor, CONST_AZ_CRC("ePropertyMissionObj", 0x4a2d0dc8)>;
using SequencePropertyHandler = GenericPopupWidgetHandler<SequencePropertyEditor, CONST_AZ_CRC("ePropertySequence", 0xdd1c7d44)>;
using SequenceIdPropertyHandler = GenericPopupWidgetHandler<SequenceIdPropertyEditor, CONST_AZ_CRC("ePropertySequenceId", 0x05983dcc)>;
@@ -17,9 +17,9 @@
// AzToolsFramework
#include <AzToolsFramework/AssetBrowser/AssetSelectionModel.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/UI/PropertyEditor/PropertyAudioCtrl.h>
// Editor
#include "IResourceSelectorHost.h"
#include "Controls/QToolTipWidget.h"
#include "Controls/BitmapToolTip.h"
@@ -35,8 +35,8 @@ BrowseButton::BrowseButton(PropertyType type, QWidget* parent /*= nullptr*/)
void BrowseButton::SetPathAndEmit(const QString& path)
{
//only emit if path changes, except for ePropertyGeomCache. Old property control
if (path != m_path || m_propertyType == ePropertyGeomCache)
//only emit if path changes. Old property control
if (path != m_path)
{
m_path = path;
emit PathChanged(m_path);
@@ -78,21 +78,6 @@ private:
// Filters for texture.
selection = AssetSelectionModel::AssetGroupSelection("Texture");
}
else if (m_propertyType == ePropertyModel)
{
// Filters for models.
selection = AssetSelectionModel::AssetGroupSelection("Geometry");
}
else if (m_propertyType == ePropertyGeomCache)
{
// Filters for geom caches.
selection = AssetSelectionModel::AssetTypeSelection("Geom Cache");
}
else if (m_propertyType == ePropertyFile)
{
// Filters for files.
selection = AssetSelectionModel::AssetTypeSelection("File");
}
else
{
return;
@@ -106,14 +91,7 @@ private:
switch (m_propertyType)
{
case ePropertyTexture:
case ePropertyModel:
newPath.replace("\\\\", "/");
}
switch (m_propertyType)
{
case ePropertyTexture:
case ePropertyModel:
case ePropertyFile:
if (newPath.size() > MAX_PATH)
{
newPath.resize(MAX_PATH);
@@ -125,26 +103,51 @@ private:
}
};
class ResourceSelectorButton
class AudioControlSelectorButton
: public BrowseButton
{
public:
AZ_CLASS_ALLOCATOR(ResourceSelectorButton, AZ::SystemAllocator, 0);
AZ_CLASS_ALLOCATOR(AudioControlSelectorButton, AZ::SystemAllocator, 0);
ResourceSelectorButton(PropertyType type, QWidget* pParent = nullptr)
AudioControlSelectorButton(PropertyType type, QWidget* pParent = nullptr)
: BrowseButton(type, pParent)
{
setToolTip(tr("Select resource"));
setToolTip(tr("Select Audio Control"));
}
private:
void OnClicked() override
{
SResourceSelectorContext x;
x.parentWidget = this;
x.typeName = Prop::GetPropertyTypeToResourceType(m_propertyType);
QString newPath = GetIEditor()->GetResourceSelectorHost()->SelectResource(x, m_path);
SetPathAndEmit(newPath);
AZStd::string resourceResult;
auto ConvertLegacyAudioPropertyType = [](const PropertyType type) -> AzToolsFramework::AudioPropertyType
{
switch (type)
{
case ePropertyAudioTrigger:
return AzToolsFramework::AudioPropertyType::Trigger;
case ePropertyAudioRTPC:
return AzToolsFramework::AudioPropertyType::Rtpc;
case ePropertyAudioSwitch:
return AzToolsFramework::AudioPropertyType::Switch;
case ePropertyAudioSwitchState:
return AzToolsFramework::AudioPropertyType::SwitchState;
case ePropertyAudioEnvironment:
return AzToolsFramework::AudioPropertyType::Environment;
case ePropertyAudioPreloadRequest:
return AzToolsFramework::AudioPropertyType::Preload;
default:
return AzToolsFramework::AudioPropertyType::NumTypes;
}
};
auto propType = ConvertLegacyAudioPropertyType(m_propertyType);
if (propType != AzToolsFramework::AudioPropertyType::NumTypes)
{
AzToolsFramework::AudioControlSelectorRequestBus::EventResult(
resourceResult, propType, &AzToolsFramework::AudioControlSelectorRequestBus::Events::SelectResource,
AZStd::string_view{ m_path.toUtf8().constData() });
SetPathAndEmit(QString{ resourceResult.c_str() });
}
}
};
@@ -235,18 +238,13 @@ void FileResourceSelectorWidget::SetPropertyType(PropertyType type)
AddButton(new TextureEditButton);
m_previewToolTip.reset(new CBitmapToolTip);
break;
case ePropertyModel:
case ePropertyGeomCache:
case ePropertyAudioTrigger:
case ePropertyAudioSwitch:
case ePropertyAudioSwitchState:
case ePropertyAudioRTPC:
case ePropertyAudioEnvironment:
case ePropertyAudioPreloadRequest:
AddButton(new ResourceSelectorButton(type));
break;
case ePropertyFile:
AddButton(new FileBrowseButton(type));
AddButton(new AudioControlSelectorButton(type));
break;
default:
break;
@@ -1,93 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
// Description : implementation file
#include "EditorDefs.h"
#include "ReflectedPropertiesPanel.h"
/////////////////////////////////////////////////////////////////////////////
// ReflectedPropertiesPanel dialog
ReflectedPropertiesPanel::ReflectedPropertiesPanel(QWidget* pParent)
: ReflectedPropertyControl(pParent)
{
}
//////////////////////////////////////////////////////////////////////////
void ReflectedPropertiesPanel::DeleteVars()
{
ClearVarBlock();
m_updateCallbacks.clear();
m_varBlock = nullptr;
}
//////////////////////////////////////////////////////////////////////////
void ReflectedPropertiesPanel::SetVarBlock(class CVarBlock* vb, ReflectedPropertyControl::UpdateVarCallback* updCallback, const char* category)
{
assert(vb);
m_varBlock = vb;
RemoveAllItems();
m_varBlock = vb;
AddVarBlock(m_varBlock, category);
SetUpdateCallback(AZStd::bind(&ReflectedPropertiesPanel::OnPropertyChanged, this, AZStd::placeholders::_1));
// When new object set all previous callbacks freed.
m_updateCallbacks.clear();
if (updCallback)
{
stl::push_back_unique(m_updateCallbacks, updCallback);
}
}
//////////////////////////////////////////////////////////////////////////
void ReflectedPropertiesPanel::AddVars(CVarBlock* vb, ReflectedPropertyControl::UpdateVarCallback* updCallback, const char* category)
{
assert(vb);
bool bNewBlock = false;
// Make a clone of properties.
if (!m_varBlock)
{
RemoveAllItems();
m_varBlock = vb->Clone(true);
AddVarBlock(m_varBlock, category);
bNewBlock = true;
}
m_varBlock->Wire(vb);
if (bNewBlock)
{
SetUpdateCallback(AZStd::bind(&ReflectedPropertiesPanel::OnPropertyChanged, this, AZStd::placeholders::_1));
// When new object set all previous callbacks freed.
m_updateCallbacks.clear();
}
if (updCallback)
{
stl::push_back_unique(m_updateCallbacks, updCallback);
}
}
void ReflectedPropertiesPanel::OnPropertyChanged(IVariable* pVar)
{
std::list<ReflectedPropertyControl::UpdateVarCallback*>::iterator iter;
for (iter = m_updateCallbacks.begin(); iter != m_updateCallbacks.end(); ++iter)
{
(*iter)->operator()(pVar);
}
}
@@ -1,46 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_REFLECTEDPROPERTIESPANEL_H
#define CRYINCLUDE_EDITOR_REFLECTEDPROPERTIESPANEL_H
#pragma once
#include "Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.h"
#include "Util/Variable.h"
/////////////////////////////////////////////////////////////////////////////
// ReflectedPropertiesPanel dialog
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
//This class is a port of ReflectedPropertiesPanel to use the ReflectedPropertyControl
class SANDBOX_API ReflectedPropertiesPanel
: public ReflectedPropertyControl
{
AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
public:
ReflectedPropertiesPanel(QWidget* pParent = nullptr); // standard constructor
void DeleteVars();
void AddVars(class CVarBlock* vb, ReflectedPropertyControl::UpdateVarCallback* func = nullptr, const char* category = nullptr);
void SetVarBlock(class CVarBlock* vb, ReflectedPropertyControl::UpdateVarCallback* func = nullptr, const char* category = nullptr);
protected:
void OnPropertyChanged(IVariable* pVar);
protected:
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
TSmartPtr<CVarBlock> m_varBlock;
std::list<ReflectedPropertyControl::UpdateVarCallback*> m_updateCallbacks;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
#endif // CRYINCLUDE_EDITOR_REFLECTEDPROPERTIESPANEL_H
@@ -255,9 +255,6 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
case ePropertySelection:
m_reflectedVarAdapter = new ReflectedVarEnumAdapter;
break;
case ePropertyAnimation:
m_reflectedVarAdapter = new ReflectedVarAnimationAdapter;
break;
case ePropertyColor:
m_reflectedVarAdapter = new ReflectedVarColorAdapter;
break;
@@ -265,7 +262,6 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
m_reflectedVarAdapter = new ReflectedVarUserAdapter;
break;
case ePropertyEquip:
case ePropertyReverbPreset:
case ePropertyGameToken:
case ePropertyMissionObj:
case ePropertySequence:
@@ -276,15 +272,12 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
m_reflectedVarAdapter = new ReflectedVarGenericPropertyAdapter(desc.m_type);
break;
case ePropertyTexture:
case ePropertyModel:
case ePropertyGeomCache:
case ePropertyAudioTrigger:
case ePropertyAudioSwitch:
case ePropertyAudioSwitchState:
case ePropertyAudioRTPC:
case ePropertyAudioEnvironment:
case ePropertyAudioPreloadRequest:
case ePropertyFile:
m_reflectedVarAdapter = new ReflectedVarResourceAdapter;
break;
case ePropertyFloatCurve:
@@ -569,7 +562,6 @@ void ReflectedPropertyItem::SetValue(const QString& sValue, bool bRecordUndo, bo
break;
case ePropertyTexture:
case ePropertyModel:
value.replace('\\', '/');
break;
}
@@ -578,8 +570,6 @@ void ReflectedPropertyItem::SetValue(const QString& sValue, bool bRecordUndo, bo
switch (m_type)
{
case ePropertyTexture:
case ePropertyModel:
case ePropertyFile:
if (value.length() >= MAX_PATH)
{
value = value.left(MAX_PATH);
@@ -31,12 +31,6 @@ void ReflectedVarInit::setupReflection(AZ::SerializeContext* serializeContext)
->Field("description", &CReflectedVar::m_description)
->Field("varName", &CReflectedVar::m_varName);
serializeContext->Class <CReflectedVarAnimation, CReflectedVar >()
->Version(1)
->Field("animation", &CReflectedVarAnimation::m_animation)
->Field("entityID", &CReflectedVarAnimation::m_entityID)
;
serializeContext->Class <CReflectedVarResource, CReflectedVar >()
->Version(1)
->Field("path", &CReflectedVarResource::m_path)
@@ -76,12 +70,6 @@ void ReflectedVarInit::setupReflection(AZ::SerializeContext* serializeContext)
AZ::EditContext* ec = serializeContext->GetEditContext();
if (ec)
{
ec->Class< CReflectedVarAnimation >("VarAnimation", "Animation")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::NameLabelOverride, &CReflectedVarAnimation::varName)
->Attribute(AZ::Edit::Attributes::DescriptionTextOverride, &CReflectedVarAnimation::description)
;
ec->Class< CReflectedVarResource >("VarResource", "Resource")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::NameLabelOverride, &CReflectedVarResource::varName)
@@ -284,8 +272,6 @@ AZ::u32 CReflectedVarGenericProperty::handler()
return AZ_CRC("ePropertyShader", 0xc40932f1);
case ePropertyEquip:
return AZ_CRC("ePropertyEquip", 0x66ffd290);
case ePropertyReverbPreset:
return AZ_CRC("ePropertyReverbPreset", 0x51469f38);
case ePropertyDeprecated0:
return AZ_CRC("ePropertyCustomAction", 0x4ffa5ba5);
case ePropertyGameToken:
@@ -265,32 +265,8 @@ public:
AZ::Vector3 m_color;
};
//Class to hold ePropertyAnimation (IVariable::DT_ANIMATION )
class CReflectedVarAnimation
: public CReflectedVar
{
public:
AZ_RTTI(CReflectedVarAnimation, "{635D982E-23EC-463F-8F33-4FC2C19D5673}", CReflectedVar)
CReflectedVarAnimation(const AZStd::string& name)
: CReflectedVar(name)
, m_entityID(0)
{}
CReflectedVarAnimation()
: m_entityID(0){}
AZStd::string varName() const { return m_varName; }
AZStd::string description() const { return m_description; }
AZStd::string m_animation;
AZ::EntityId m_entityID;
};
//Class to hold:
// ePropertyTexture (IVariable::DT_TEXTURE)
// ePropertyMaterial (IVariable::DT_MATERIAL)
// ePropertyModel (IVariable::DT_OBJECT)
// ePropertyGeomCache (IVariable::DT_GEOM_CACHE)
// ePropertyAudioTrigger (IVariable::DT_AUDIO_TRIGGER)
// ePropertyAudioSwitch (IVariable::DT_AUDIO_SWITCH )
// ePropertyAudioSwitchState (IVariable::DT_AUDIO_SWITCH_STATE)
@@ -344,7 +320,6 @@ public:
AZStd::vector<AZStd::string> m_itemDescriptions;
};
//Class to hold ePropertyAnimation (IVariable::DT_ANIMATION )
class CReflectedVarSpline
: public CReflectedVar
{
@@ -392,25 +392,6 @@ void ReflectedVarColorAdapter::SyncIVarToReflectedVar(IVariable *pVariable)
void ReflectedVarAnimationAdapter::SetVariable(IVariable *pVariable)
{
m_reflectedVar.reset(new CReflectedVarAnimation(pVariable->GetHumanName().toUtf8().data()));
m_reflectedVar->m_description = pVariable->GetDescription().toUtf8().data();
}
void ReflectedVarAnimationAdapter::SyncReflectedVarToIVar(IVariable *pVariable)
{
m_reflectedVar->m_entityID = static_cast<AZ::EntityId>(pVariable->GetUserData().value<AZ::u64>());
m_reflectedVar->m_animation = pVariable->GetDisplayValue().toUtf8().data();
}
void ReflectedVarAnimationAdapter::SyncIVarToReflectedVar(IVariable *pVariable)
{
pVariable->SetUserData(static_cast<AZ::u64>(m_reflectedVar->m_entityID));
pVariable->SetDisplayValue(m_reflectedVar->m_animation.c_str());
}
void ReflectedVarResourceAdapter::SetVariable(IVariable *pVariable)
{
m_reflectedVar.reset(new CReflectedVarResource(pVariable->GetHumanName().toUtf8().data()));
@@ -429,7 +410,7 @@ void ReflectedVarResourceAdapter::SyncReflectedVarToIVar(IVariable *pVariable)
void ReflectedVarResourceAdapter::SyncIVarToReflectedVar(IVariable *pVariable)
{
const bool bForceModified = (m_reflectedVar->m_propertyType == ePropertyGeomCache);
const bool bForceModified = false;
pVariable->SetForceModified(bForceModified);
pVariable->SetDisplayValue(m_reflectedVar->m_path.c_str());
@@ -218,20 +218,6 @@ AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
class EDITOR_CORE_API ReflectedVarAnimationAdapter
: public ReflectedVarAdapter
{
public:
void SetVariable(IVariable* pVariable) override;
void SyncReflectedVarToIVar(IVariable* pVariable) override;
void SyncIVarToReflectedVar(IVariable* pVariable) override;
CReflectedVar* GetReflectedVar() override { return m_reflectedVar.data(); }
private:
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
QScopedPointer<CReflectedVarAnimation > m_reflectedVar;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
class EDITOR_CORE_API ReflectedVarResourceAdapter
: public ReflectedVarAdapter
{
+2 -2
View File
@@ -130,7 +130,7 @@ public:
HotKey_BuildDefaults();
for (QPair<QString, QString> key : keys)
{
for (unsigned int j = 0; j < hotkeys.count(); j++)
for (int j = 0; j < hotkeys.count(); j++)
{
if (hotkeys[j].path.compare(key.first, Qt::CaseInsensitive) == 0)
{
@@ -256,7 +256,7 @@ public:
hotkey.second = settings.value("keySequence").toString();
if (!hotkey.first.isEmpty())
{
for (unsigned int j = 0; j < hotkeys.count(); j++)
for (int j = 0; j < hotkeys.count(); j++)
{
if (hotkeys[j].path.compare(hotkey.first, Qt::CaseInsensitive) == 0)
{
-2
View File
@@ -68,7 +68,6 @@ class CDisplaySettings;
struct SGizmoParameters;
class CLevelIndependentFileMan;
class CSelectionTreeManager;
struct IResourceSelectorHost;
struct SEditorSettings;
class CGameExporter;
class IAWSResourceManager;
@@ -714,7 +713,6 @@ struct IEditor
virtual ESystemConfigSpec GetEditorConfigSpec() const = 0;
virtual ESystemConfigPlatform GetEditorConfigPlatform() const = 0;
virtual void ReloadTemplates() = 0;
virtual IResourceSelectorHost* GetResourceSelectorHost() = 0;
virtual void ShowStatusText(bool bEnable) = 0;
// Provides a way to extend the context menu of an object. The function gets called every time the menu is opened.
-2
View File
@@ -67,7 +67,6 @@ AZ_POP_DISABLE_WARNING
#include "EditorFileMonitor.h"
#include "MainStatusBar.h"
#include "ResourceSelectorHost.h"
#include "Util/FileUtil_impl.h"
#include "Util/ImageUtil_impl.h"
#include "LogFileImpl.h"
@@ -187,7 +186,6 @@ CEditorImpl::CEditorImpl()
m_pAnimationContext = new CAnimationContext;
m_pImageUtil = new CImageUtil_impl();
m_pResourceSelectorHost.reset(CreateResourceSelectorHost());
m_selectedRegion.min = Vec3(0, 0, 0);
m_selectedRegion.max = Vec3(0, 0, 0);
DetectVersion();
-2
View File
@@ -290,7 +290,6 @@ public:
ESystemConfigPlatform GetEditorConfigPlatform() const;
void ReloadTemplates();
void AddErrorMessage(const QString& text, const QString& caption);
IResourceSelectorHost* GetResourceSelectorHost() { return m_pResourceSelectorHost.get(); }
virtual void ShowStatusText(bool bEnable);
void OnObjectContextMenuOpened(QMenu* pMenu, const CBaseObject* pObject);
@@ -374,7 +373,6 @@ protected:
//! Export manager for exporting objects and a terrain from the game to DCC tools
CExportManager* m_pExportManager;
std::unique_ptr<CEditorFileMonitor> m_pEditorFileMonitor;
std::unique_ptr<IResourceSelectorHost> m_pResourceSelectorHost;
QString m_selectFileBuffer;
QString m_levelNameBuffer;
+1 -1
View File
@@ -65,7 +65,7 @@ struct HotKey
int size = (m_catSize < o_catSize) ? m_catSize : o_catSize;
//sort categories to keep them together
for (unsigned int i = 0; i < size; i++)
for (int i = 0; i < size; i++)
{
if (m_categories[i] < o_categories[i])
{
-135
View File
@@ -1,135 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
// The aim of IResourceSelectorHost is to unify resource selection dialogs in a one
// API that can be reused with plugins. It also makes possible to register new
// resource selectors dynamically, e.g. inside plugins.
//
// Here is how new selectors are created. In your implementation file you add handler function:
//
// #include "IResourceSelectorHost.h"
//
// QString SoundFileSelector(const SResourceSelectorContext& x, const QString& previousValue)
// {
// CMyModalDialog dialog(CWnd::FromHandle(x.parentWindow));
// ...
// return previousValue;
// }
// REGISTER_RESOURCE_SELECTOR("Sound", SoundFileSelector, "Icons/sound_16x16.png")
//
// Here is how it can be invoked directly:
//
// SResourceSelectorContext x;
// x.parentWindow = parent.GetSafeHwnd();
// x.typeName = "Sound";
// string newValue = GetIEditor()->GetResourceSelector()->SelectResource(x, previousValue).c_str();
//
// If you have your own resource selectors in the plugin you will need to run
//
// RegisterModuleResourceSelectors(GetIEditor()->GetResourceSelector())
//
// during plugin initialization.
//
// If you want to be able to pass some custom context to the selector (e.g. source of the information for the
// list of items or something similar) then you can add a poitner argument to your selector function, i.e.:
//
// QString SoundFileSelector(const SResourceSelectorContext& x, const QString& previousValue,
// SoundFileList* list) // your context argument
#include <QString>
class QWidget;
struct SResourceSelectorContext
{
const char* typeName;
// use either parentWidget or parentWindow (not both) until everything porting to QWidget.
QWidget* parentWidget;
unsigned int entityId;
void* contextObject;
SResourceSelectorContext()
: parentWidget(0)
, typeName(0)
, entityId(0)
, contextObject()
{
}
};
// TResourceSelecitonFunction is used to declare handlers for specific types.
//
// For canceled dialogs previousValue should be returned.
typedef QString (* TResourceSelectionFunction)(const SResourceSelectorContext& selectorContext, const QString& previousValue);
typedef QString (* TResourceSelectionFunctionWithContext)(const SResourceSelectorContext& selectorContext, const QString& previousValue, void* contextObject);
struct SStaticResourceSelectorEntry;
// See note at the beginning of the file.
struct IResourceSelectorHost
{
virtual ~IResourceSelectorHost() = default;
virtual QString SelectResource(const SResourceSelectorContext& context, const QString& previousValue) = 0;
virtual const char* ResourceIconPath(const char* typeName) const = 0;
virtual void RegisterResourceSelector(const SStaticResourceSelectorEntry* entry) = 0;
// secondary responsibility of this class is to store global selections
virtual void SetGlobalSelection(const char* resourceType, const char* value) = 0;
virtual const char* GetGlobalSelection(const char* resourceType) const = 0;
};
// ---------------------------------------------------------------------------
#define INTERNAL_RSH_COMBINE_UTIL(A, B) A##B
#define INTERNAL_RSH_COMBINE(A, B) INTERNAL_RSH_COMBINE_UTIL(A, B)
#define REGISTER_RESOURCE_SELECTOR(name, function, icon) \
static SStaticResourceSelectorEntry INTERNAL_RSH_COMBINE(selector_##function, __LINE__)((name), (function), (icon));
struct SStaticResourceSelectorEntry
{
const char* typeName;
TResourceSelectionFunction function;
TResourceSelectionFunctionWithContext functionWithContext;
const char* iconPath;
static SStaticResourceSelectorEntry*& GetFirst() { static SStaticResourceSelectorEntry* first; return first; }
SStaticResourceSelectorEntry* next;
SStaticResourceSelectorEntry(const char* typeName, TResourceSelectionFunction function, const char* icon)
: typeName(typeName)
, function(function)
, functionWithContext()
, iconPath(icon)
{
next = GetFirst();
GetFirst() = this;
}
template<class T>
SStaticResourceSelectorEntry(const char* typeName, QString (*function)(const SResourceSelectorContext&, const QString& previousValue, T * context), const char* icon)
: typeName(typeName)
, function()
, functionWithContext(TResourceSelectionFunctionWithContext(function))
, iconPath(icon)
{
next = GetFirst();
GetFirst() = this;
}
};
inline void RegisterModuleResourceSelectors(IResourceSelectorHost* editorResourceSelector)
{
for (SStaticResourceSelectorEntry* current = SStaticResourceSelectorEntry::GetFirst(); current != 0; current = current->next)
{
editorResourceSelector->RegisterResourceSelector(current);
}
}
-1
View File
@@ -178,7 +178,6 @@ public:
MOCK_CONST_METHOD0(GetEditorConfigSpec, ESystemConfigSpec());
MOCK_CONST_METHOD0(GetEditorConfigPlatform, ESystemConfigPlatform());
MOCK_METHOD0(ReloadTemplates, void());
MOCK_METHOD0(GetResourceSelectorHost, IResourceSelectorHost* ());
MOCK_METHOD1(ShowStatusText, void(bool ));
MOCK_METHOD1(RegisterObjectContextMenuExtension, void(TContextMenuExtensionFunc ));
MOCK_METHOD0(GetEnv, SSystemGlobalEnvironment* ());
@@ -0,0 +1,152 @@
/*
* 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 <AzFramework/Viewport/CameraInput.h>
#include <AzFramework/Viewport/ViewportControllerList.h>
#include <AzToolsFramework/Input/QtEventToAzInputManager.h>
#include <AzToolsFramework/UnitTest/AzToolsFrameworkTestHelpers.h>
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemViewportSelectionRequestBus.h>
#include <Editor/ViewportManipulatorController.h>
namespace UnitTest
{
using AzToolsFramework::ViewportInteraction::MouseInteractionEvent;
class EditorInteractionViewportSelectionFake : public AzToolsFramework::EditorInteractionSystemViewportSelectionRequestBus::Handler
{
public:
void Connect();
void Disconnect();
// EditorInteractionSystemViewportSelectionRequestBus overrides ...
void SetHandler(const AzToolsFramework::ViewportSelectionRequestsBuilderFn& interactionRequestsBuilder);
void SetDefaultHandler();
bool InternalHandleMouseViewportInteraction(const MouseInteractionEvent& mouseInteraction);
bool InternalHandleMouseManipulatorInteraction(const MouseInteractionEvent& mouseInteraction);
AZStd::function<bool(const MouseInteractionEvent& mouseInteraction)> m_internalHandleMouseViewportInteraction;
AZStd::function<bool(const MouseInteractionEvent& mouseInteraction)> m_internalHandleMouseManipulatorInteraction;
};
void EditorInteractionViewportSelectionFake::Connect()
{
AzToolsFramework::EditorInteractionSystemViewportSelectionRequestBus::Handler::BusConnect(AzToolsFramework::GetEntityContextId());
}
void EditorInteractionViewportSelectionFake::Disconnect()
{
AzToolsFramework::EditorInteractionSystemViewportSelectionRequestBus::Handler::BusDisconnect();
}
void EditorInteractionViewportSelectionFake::SetHandler(
[[maybe_unused]] const AzToolsFramework::ViewportSelectionRequestsBuilderFn& interactionRequestsBuilder)
{
// noop
}
void EditorInteractionViewportSelectionFake::SetDefaultHandler()
{
// noop
}
bool EditorInteractionViewportSelectionFake::InternalHandleMouseViewportInteraction(const MouseInteractionEvent& mouseInteraction)
{
if (m_internalHandleMouseViewportInteraction)
{
return m_internalHandleMouseViewportInteraction(mouseInteraction);
}
return false;
}
bool EditorInteractionViewportSelectionFake::InternalHandleMouseManipulatorInteraction(const MouseInteractionEvent& mouseInteraction)
{
if (m_internalHandleMouseManipulatorInteraction)
{
return m_internalHandleMouseManipulatorInteraction(mouseInteraction);
}
return false;
}
class ViewportManipulatorControllerFixture : public AllocatorsTestFixture
{
public:
static const AzFramework::ViewportId TestViewportId = AzFramework::ViewportId(0);
void SetUp() override
{
AllocatorsTestFixture::SetUp();
m_rootWidget = AZStd::make_unique<QWidget>();
m_rootWidget->setFixedSize(QSize(100, 100));
m_controllerList = AZStd::make_shared<AzFramework::ViewportControllerList>();
m_controllerList->RegisterViewportContext(TestViewportId);
m_inputChannelMapper = AZStd::make_unique<AzToolsFramework::QtEventToAzInputMapper>(m_rootWidget.get(), TestViewportId);
}
void TearDown()
{
m_inputChannelMapper.reset();
m_controllerList->UnregisterViewportContext(TestViewportId);
m_controllerList.reset();
m_rootWidget.reset();
AllocatorsTestFixture::TearDown();
}
AZStd::unique_ptr<QWidget> m_rootWidget;
AzFramework::ViewportControllerListPtr m_controllerList;
AZStd::unique_ptr<AzToolsFramework::QtEventToAzInputMapper> m_inputChannelMapper;
};
TEST_F(ViewportManipulatorControllerFixture, An_event_is_not_propagated_to_the_viewport_when_a_manipulator_handles_it_first)
{
// forward input events to our controller list
QObject::connect(
m_inputChannelMapper.get(), &AzToolsFramework::QtEventToAzInputMapper::InputChannelUpdated, m_rootWidget.get(),
[this](const AzFramework::InputChannel* inputChannel, [[maybe_unused]] QEvent* event)
{
m_controllerList->HandleInputChannelEvent(
AzFramework::ViewportControllerInputEvent{ TestViewportId, nullptr, *inputChannel });
});
EditorInteractionViewportSelectionFake editorInteractionViewportFake;
editorInteractionViewportFake.m_internalHandleMouseManipulatorInteraction = [](const MouseInteractionEvent&)
{
// report the event was handled (manipulator was interacted with)
return true;
};
bool viewportInteractionCalled = false;
editorInteractionViewportFake.m_internalHandleMouseViewportInteraction = [&viewportInteractionCalled](const MouseInteractionEvent&)
{
// we should not call this as the manipulator will have consumed this event
viewportInteractionCalled = true;
return true;
};
editorInteractionViewportFake.Connect();
m_controllerList->Add(AZStd::make_shared<SandboxEditor::ViewportManipulatorController>());
// simulate a press and move
MousePressAndMove(m_rootWidget.get(), QPoint(10, 10), QPoint(10, 10), Qt::MouseButton::LeftButton);
MouseMove(m_rootWidget.get(), QPoint(20, 20), QPoint(10, 10), Qt::MouseButton::LeftButton);
MouseMove(m_rootWidget.get(), QPoint(30, 30), QPoint(0, 0), Qt::MouseButton::LeftButton);
QTest::mouseRelease(m_rootWidget.get(), Qt::MouseButton::LeftButton, Qt::KeyboardModifier::NoModifier, QPoint(30, 30));
// ensure the viewport did not receive the event when it was intercepted first by the manipulator
EXPECT_FALSE(viewportInteractionCalled);
editorInteractionViewportFake.Disconnect();
}
} // namespace UnitTest
@@ -9,7 +9,6 @@
#include "ComponentEntityEditorPlugin.h"
#include <LyViewPaneNames.h>
#include "IResourceSelectorHost.h"
#include "UI/QComponentEntityEditorMainWindow.h"
#include "UI/QComponentEntityEditorOutlinerWindow.h"
@@ -180,8 +179,6 @@ ComponentEntityEditorPlugin::ComponentEntityEditorPlugin([[maybe_unused]] IEdito
RegisterViewPane<SliceRelationshipWidget>(LyViewPane::SliceRelationships, LyViewPane::CategoryTools, options);
}
RegisterModuleResourceSelectors(GetIEditor()->GetResourceSelectorHost());
ComponentEntityEditorPluginInternal::RegisterSandboxObjects();
// Check for common mistakes in component declarations
@@ -82,7 +82,6 @@
#include <Editor/QtViewPaneManager.h>
#include <Editor/EditorViewportSettings.h>
#include <Editor/Util/PathUtil.h>
#include <IResourceSelectorHost.h>
#include "CryEdit.h"
#include "Undo/Undo.h"
@@ -1387,16 +1386,6 @@ AZStd::string SandboxIntegrationManager::GetLevelName()
return AZStd::string(GetIEditor()->GetGameEngine()->GetLevelName().toUtf8().constData());
}
AZStd::string SandboxIntegrationManager::SelectResource(const AZStd::string& resourceType, const AZStd::string& previousValue)
{
SResourceSelectorContext context;
context.parentWidget = GetMainWindow();
context.typeName = resourceType.c_str();
QString resource = GetEditor()->GetResourceSelectorHost()->SelectResource(context, previousValue.c_str());
return AZStd::string(resource.toUtf8().constData());
}
void SandboxIntegrationManager::OnContextReset()
{
// Deselect everything.
@@ -158,7 +158,6 @@ private:
void LaunchLuaEditor(const char* files) override;
bool IsLevelDocumentOpen() override;
AZStd::string GetLevelName() override;
AZStd::string SelectResource(const AZStd::string& resourceType, const AZStd::string& previousValue) override;
void OpenPinnedInspector(const AzToolsFramework::EntityIdSet& entities) override;
void ClosePinnedInspector(AzToolsFramework::EntityPropertyEditor* editor) override;
void GoToSelectedOrHighlightedEntitiesInViewports() override;
@@ -13,6 +13,7 @@
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
#include <SceneAPI/SceneCore/Components/LoadingComponent.h>
#include <SceneAPI/SceneCore/Utilities/Reporting.h>
#include <SceneSerializationHandler.h>
@@ -96,7 +97,7 @@ namespace AZ
}
AZStd::shared_ptr<SceneAPI::Containers::Scene> scene =
AssetImportRequest::LoadSceneFromVerifiedPath(cleanPath, sceneSourceGuid, AssetImportRequest::RequestingApplication::Editor);
AssetImportRequest::LoadSceneFromVerifiedPath(cleanPath, sceneSourceGuid, AssetImportRequest::RequestingApplication::Editor, SceneAPI::SceneCore::LoadingComponent::TYPEINFO_Uuid());
if (!scene)
{
AZ_TracePrintf(Utilities::ErrorWindow, "Failed to load the requested scene.");
-163
View File
@@ -1,163 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "ResourceSelectorHost.h"
// Qt
#include <QMessageBox>
#include <QString>
// AzToolsFramework
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/AssetBrowser/Search/Filter.h>
#include <AzToolsFramework/AssetBrowser/AssetSelectionModel.h>
class CResourceSelectorHost
: public IResourceSelectorHost
{
public:
CResourceSelectorHost()
{
RegisterModuleResourceSelectors(this);
}
QString SelectResource(const SResourceSelectorContext& context, const QString& previousValue) override
{
if (!context.typeName)
{
assert(false && "SResourceSelectorContext::typeName is not specified");
return QString();
}
TTypeMap::iterator it = m_typeMap.find(context.typeName);
if (it == m_typeMap.end())
{
QMessageBox::critical(QApplication::activeWindow(), QString(), QObject::tr("No Resource Selector is registered for resource type \"%1\"").arg(context.typeName));
return previousValue;
}
QString result = previousValue;
if (it->second->function)
{
result = it->second->function(context, previousValue);
}
else if (it->second->functionWithContext)
{
result = it->second->functionWithContext(context, previousValue, context.contextObject);
}
return result;
}
const char* ResourceIconPath(const char* typeName) const override
{
TTypeMap::const_iterator it = m_typeMap.find(typeName);
if (it != m_typeMap.end())
{
return it->second->iconPath;
}
return "";
}
void RegisterResourceSelector(const SStaticResourceSelectorEntry* entry) override
{
m_typeMap[entry->typeName] = entry;
}
void SetGlobalSelection(const char* resourceType, const char* value) override
{
if (!resourceType || !value)
{
return;
}
m_globallySelectedResources[resourceType] = value;
}
const char* GetGlobalSelection(const char* resourceType) const override
{
if (!resourceType)
{
return "";
}
auto it = m_globallySelectedResources.find(resourceType);
if (it != m_globallySelectedResources.end())
{
return it->second.c_str();
}
return "";
}
private:
using TTypeMap = std::map<AZStd::string, const SStaticResourceSelectorEntry *, stl::less_stricmp<AZStd::string>>;
TTypeMap m_typeMap;
std::map<AZStd::string, AZStd::string> m_globallySelectedResources;
};
// ---------------------------------------------------------------------------
IResourceSelectorHost* CreateResourceSelectorHost()
{
return new CResourceSelectorHost();
}
// ---------------------------------------------------------------------------
QString SoundFileSelector([[maybe_unused]] const SResourceSelectorContext& x, const QString& previousValue)
{
AssetSelectionModel selection = AssetSelectionModel::AssetTypeSelection("Audio");
AzToolsFramework::EditorRequests::Bus::Broadcast(&AzToolsFramework::EditorRequests::BrowseForAssets, selection);
if (selection.IsValid())
{
return Path::FullPathToGamePath(QString(selection.GetResult()->GetFullPath().c_str()));
}
else
{
return Path::FullPathToGamePath(previousValue);
}
}
REGISTER_RESOURCE_SELECTOR("Sound", SoundFileSelector, "")
// ---------------------------------------------------------------------------
QString ModelFileSelector([[maybe_unused]] const SResourceSelectorContext& x, const QString& previousValue)
{
AssetSelectionModel selection = AssetSelectionModel::AssetGroupSelection("Geometry");
AzToolsFramework::EditorRequests::Bus::Broadcast(&AzToolsFramework::EditorRequests::BrowseForAssets, selection);
if (selection.IsValid())
{
return Path::FullPathToGamePath(QString(selection.GetResult()->GetFullPath().c_str()));
}
else
{
return Path::FullPathToGamePath(previousValue);
}
}
REGISTER_RESOURCE_SELECTOR("Model", ModelFileSelector, "")
// ---------------------------------------------------------------------------
QString GeomCacheFileSelector([[maybe_unused]] const SResourceSelectorContext& x, const QString& previousValue)
{
AssetSelectionModel selection = AssetSelectionModel::AssetTypeSelection("Geom Cache");
AzToolsFramework::EditorRequests::Bus::Broadcast(&AzToolsFramework::EditorRequests::BrowseForAssets, selection);
if (selection.IsValid())
{
return Path::FullPathToGamePath(QString(selection.GetResult()->GetFullPath().c_str()));
}
else
{
return Path::FullPathToGamePath(previousValue);
}
}
REGISTER_RESOURCE_SELECTOR("GeomCache", GeomCacheFileSelector, "")
-18
View File
@@ -1,18 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_RESOURCESELECTORHOST_H
#define CRYINCLUDE_EDITOR_RESOURCESELECTORHOST_H
#pragma once
#include "IResourceSelectorHost.h"
IResourceSelectorHost* CreateResourceSelectorHost();
#endif // CRYINCLUDE_EDITOR_RESOURCESELECTORHOST_H
+1 -1
View File
@@ -351,7 +351,7 @@ void CVarBlock::EnableUpdateCallbacks(bool boEnable)
void CVarBlock::GatherUsedResourcesInVar(IVariable* pVar, CUsedResources& resources)
{
int type = pVar->GetDataType();
if (type == IVariable::DT_FILE || type == IVariable::DT_OBJECT || type == IVariable::DT_TEXTURE)
if (type == IVariable::DT_TEXTURE)
{
// this is file.
QString filename;
-6
View File
@@ -142,15 +142,10 @@ struct IVariable
DT_PERCENT, //!< Percent data type, (Same as simple but value is from 0-1 and UI will be from 0-100).
DT_COLOR,
DT_ANGLE,
DT_FILE,
DT_TEXTURE,
DT_ANIMATION,
DT_OBJECT,
DT_SHADER,
DT_LOCAL_STRING,
DT_EQUIP,
DT_REVERBPRESET,
DT_DEPRECATED0, // formerly DT_MATERIAL
DT_MATERIALLOOKUP,
DT_EXTARRAY, // Extendable Array
DT_SEQUENCE, // Movie Sequence (DEPRECATED, use DT_SEQUENCE_ID, instead.)
@@ -160,7 +155,6 @@ struct IVariable
DT_SEQUENCE_ID, // Movie Sequence
DT_LIGHT_ANIMATION, // Light Animation Node in the global Light Animation Set
DT_PARTICLE_EFFECT,
DT_GEOM_CACHE, // Geometry cache
DT_DEPRECATED, // formerly DT_FLARE
DT_AUDIO_TRIGGER,
DT_AUDIO_SWITCH,
-33
View File
@@ -37,17 +37,12 @@ namespace Prop
{ IVariable::DT_CURVE | IVariable::DT_PERCENT, "FloatCurve", ePropertyFloatCurve, 13 },
{ IVariable::DT_CURVE | IVariable::DT_COLOR, "ColorCurve", ePropertyColorCurve, 1 },
{ IVariable::DT_ANGLE, "Angle", ePropertyAngle, 0 },
{ IVariable::DT_FILE, "File", ePropertyFile, 7 },
{ IVariable::DT_TEXTURE, "Texture", ePropertyTexture, 4 },
{ IVariable::DT_ANIMATION, "Animation", ePropertyAnimation, -1 },
{ IVariable::DT_MOTION, "Motion", ePropertyMotion, -1 },
{ IVariable::DT_OBJECT, "Model", ePropertyModel, 5 },
{ IVariable::DT_SIMPLE, "Selection", ePropertySelection, -1 },
{ IVariable::DT_SIMPLE, "List", ePropertyList, -1 },
{ IVariable::DT_SHADER, "Shader", ePropertyShader, 9 },
{ IVariable::DT_DEPRECATED0, "DEPRECATED", ePropertyDeprecated2, -1 },
{ IVariable::DT_EQUIP, "Equip", ePropertyEquip, 11 },
{ IVariable::DT_REVERBPRESET, "ReverbPreset", ePropertyReverbPreset, 11 },
{ IVariable::DT_LOCAL_STRING, "LocalString", ePropertyLocalString, 3 },
{ IVariable::DT_SEQUENCE, "Sequence", ePropertySequence, -1 },
{ IVariable::DT_MISSIONOBJ, "Mission Objective", ePropertyMissionObj, -1 },
@@ -55,7 +50,6 @@ namespace Prop
{ IVariable::DT_SEQUENCE_ID, "SequenceId", ePropertySequenceId, -1 },
{ IVariable::DT_LIGHT_ANIMATION, "LightAnimation", ePropertyLightAnimation, -1 },
{ IVariable::DT_PARTICLE_EFFECT, "ParticleEffect", ePropertyParticleName, 3 },
{ IVariable::DT_GEOM_CACHE, "Geometry Cache", ePropertyGeomCache, 5 },
{ IVariable::DT_AUDIO_TRIGGER, "Audio Trigger", ePropertyAudioTrigger, 6 },
{ IVariable::DT_AUDIO_SWITCH, "Audio Switch", ePropertyAudioSwitch, 6 },
{ IVariable::DT_AUDIO_SWITCH_STATE, "Audio Switch", ePropertyAudioSwitchState, 6 },
@@ -301,31 +295,4 @@ namespace Prop
return -1;
}
const char* GetPropertyTypeToResourceType(PropertyType type)
{
// The strings below are names used together with
// REGISTER_RESOURCE_SELECTOR. See IResourceSelector.h.
switch (type)
{
case ePropertyModel:
return "Model";
case ePropertyGeomCache:
return "GeomCache";
case ePropertyAudioTrigger:
return "AudioTrigger";
case ePropertyAudioSwitch:
return "AudioSwitch";
case ePropertyAudioSwitchState:
return "AudioSwitchState";
case ePropertyAudioRTPC:
return "AudioRTPC";
case ePropertyAudioEnvironment:
return "AudioEnvironment";
case ePropertyAudioPreloadRequest:
return "AudioPreloadRequest";
default:
return nullptr;
}
}
}
-6
View File
@@ -28,16 +28,11 @@ enum PropertyType
ePropertyAngle,
ePropertyFloatCurve,
ePropertyColorCurve,
ePropertyFile,
ePropertyTexture,
ePropertyAnimation,
ePropertyModel,
ePropertySelection,
ePropertyList,
ePropertyShader,
ePropertyDeprecated2, // formerly ePropertyMaterial
ePropertyEquip,
ePropertyReverbPreset,
ePropertyLocalString,
ePropertyDeprecated0, // formerly ePropertyCustomAction
ePropertyGameToken,
@@ -48,7 +43,6 @@ enum PropertyType
ePropertyLightAnimation,
ePropertyDeprecated1, // formerly ePropertyFlare
ePropertyParticleName,
ePropertyGeomCache,
ePropertyAudioTrigger,
ePropertyAudioSwitch,
ePropertyAudioSwitchState,
+16 -7
View File
@@ -28,6 +28,8 @@ namespace SandboxEditor
{
}
ViewportManipulatorControllerInstance::~ViewportManipulatorControllerInstance() = default;
AzToolsFramework::ViewportInteraction::MouseButton ViewportManipulatorControllerInstance::GetMouseButton(
const AzFramework::InputChannel& inputChannel)
{
@@ -103,14 +105,21 @@ namespace SandboxEditor
// Cache the ray trace results when doing manipulator interaction checks, no need to recalculate after
if (event.m_priority == ManipulatorPriority)
{
AzFramework::ScreenPoint screenPosition = AzFramework::ScreenPoint(0, 0);
ViewportMouseCursorRequestBus::EventResult(
screenPosition, GetViewportId(), &ViewportMouseCursorRequestBus::Events::ViewportCursorScreenPosition);
const auto* position = event.m_inputChannel.GetCustomData<AzFramework::InputChannel::PositionData2D>();
AZ_Assert(position, "Expected PositionData2D but found nullptr");
m_mouseInteraction.m_mousePick.m_screenCoordinates = screenPosition;
AzFramework::WindowSize windowSize;
AzFramework::WindowRequestBus::EventResult(
windowSize, event.m_windowHandle, &AzFramework::WindowRequestBus::Events::GetClientAreaSize);
auto screenPoint = AzFramework::ScreenPoint(
position->m_normalizedPosition.GetX() * windowSize.m_width,
position->m_normalizedPosition.GetY() * windowSize.m_height);
m_mouseInteraction.m_mousePick.m_screenCoordinates = screenPoint;
AZStd::optional<ProjectedViewportRay> ray;
ViewportInteractionRequestBus::EventResult(
ray, GetViewportId(), &ViewportInteractionRequestBus::Events::ViewportScreenToWorldRay, screenPosition);
ray, GetViewportId(), &ViewportInteractionRequestBus::Events::ViewportScreenToWorldRay, screenPoint);
if (ray.has_value())
{
@@ -118,6 +127,7 @@ namespace SandboxEditor
m_mouseInteraction.m_mousePick.m_rayDirection = ray.value().direction;
}
}
eventType = MouseEvent::Move;
}
else if (auto mouseButton = GetMouseButton(event.m_inputChannel); mouseButton != MouseButton::None)
@@ -217,8 +227,7 @@ namespace SandboxEditor
interactionHandled, AzToolsFramework::GetEntityContextId(), targetInteractionEvent, mouseInteractionEvent);
}
// Only filter button/key press events, not release events
return interactionHandled && event.m_inputChannel.IsActive();
return interactionHandled;
}
void ViewportManipulatorControllerInstance::ResetInputChannels()
+12 -8
View File
@@ -8,25 +8,29 @@
#pragma once
#include <AzFramework/Viewport/ViewportId.h>
#include <AzFramework/Viewport/MultiViewportController.h>
#include <AzFramework/Input/Events/InputChannelEventListener.h>
#include <AzFramework/Viewport/MultiViewportController.h>
#include <AzFramework/Viewport/ViewportId.h>
#include <AzToolsFramework/Viewport/ViewportTypes.h>
#include <SandboxAPI.h>
namespace SandboxEditor
{
class ViewportManipulatorControllerInstance;
using ViewportManipulatorController = AzFramework::MultiViewportController<ViewportManipulatorControllerInstance, AzFramework::ViewportControllerPriority::DispatchToAllPriorities>;
using ViewportManipulatorController = AzFramework::
MultiViewportController<ViewportManipulatorControllerInstance, AzFramework::ViewportControllerPriority::DispatchToAllPriorities>;
class ViewportManipulatorControllerInstance final
: public AzFramework::MultiViewportControllerInstanceInterface<ViewportManipulatorController>
{
public:
explicit ViewportManipulatorControllerInstance(AzFramework::ViewportId viewport, ViewportManipulatorController* controller);
SANDBOX_API ViewportManipulatorControllerInstance(AzFramework::ViewportId viewport, ViewportManipulatorController* controller);
SANDBOX_API ~ViewportManipulatorControllerInstance();
bool HandleInputChannelEvent(const AzFramework::ViewportControllerInputEvent& event) override;
void ResetInputChannels() override;
void UpdateViewport(const AzFramework::ViewportControllerUpdateEvent& event) override;
SANDBOX_API bool HandleInputChannelEvent(const AzFramework::ViewportControllerInputEvent& event) override;
SANDBOX_API void ResetInputChannels() override;
SANDBOX_API void UpdateViewport(const AzFramework::ViewportControllerUpdateEvent& event) override;
private:
bool IsDoubleClick(AzToolsFramework::ViewportInteraction::MouseButton) const;
@@ -39,4 +43,4 @@ namespace SandboxEditor
AZStd::unordered_map<AzToolsFramework::ViewportInteraction::MouseButton, AZ::ScriptTimePoint> m_pendingDoubleClicks;
AZ::ScriptTimePoint m_curTime;
};
} //namespace SandboxEditor
} // namespace SandboxEditor
-8
View File
@@ -289,7 +289,6 @@ set(FILES
Include/IPlugin.h
Include/IPreferencesPage.h
Include/IRenderListener.h
Include/IResourceSelectorHost.h
Include/ISourceControl.h
Include/ISubObjectSelectionReferenceFrameCalculator.h
Include/ITextureDatabaseUpdater.h
@@ -360,8 +359,6 @@ set(FILES
Controls/TimelineCtrl.cpp
Controls/TimelineCtrl.h
Controls/WndGridHelper.h
Controls/ReflectedPropertyControl/PropertyAnimationCtrl.cpp
Controls/ReflectedPropertyControl/PropertyAnimationCtrl.h
Controls/ReflectedPropertyControl/PropertyGenericCtrl.cpp
Controls/ReflectedPropertyControl/PropertyGenericCtrl.h
Controls/ReflectedPropertyControl/PropertyMiscCtrl.cpp
@@ -372,8 +369,6 @@ set(FILES
Controls/ReflectedPropertyControl/PropertyResourceCtrl.h
Controls/ReflectedPropertyControl/PropertyCtrl.cpp
Controls/ReflectedPropertyControl/PropertyCtrl.h
Controls/ReflectedPropertyControl/ReflectedPropertiesPanel.cpp
Controls/ReflectedPropertyControl/ReflectedPropertiesPanel.h
MainStatusBar.cpp
MainStatusBar.h
MainStatusBarItems.h
@@ -590,8 +585,6 @@ set(FILES
FBXExporterDialog.ui
FileTypeUtils.cpp
LightmapCompiler/SimpleTriangleRasterizer.cpp
ResourceSelectorHost.cpp
ResourceSelectorHost.h
ToolBox.cpp
TrackViewNewSequenceDialog.cpp
TrackViewNewSequenceDialog.ui
@@ -668,7 +661,6 @@ set(FILES
TrackView/2DBezierKeyUIControls.cpp
TrackView/AssetBlendKeyUIControls.cpp
TrackView/CaptureKeyUIControls.cpp
TrackView/CharacterKeyUIControls.cpp
TrackView/ConsoleKeyUIControls.cpp
TrackView/EventKeyUIControls.cpp
TrackView/GotoKeyUIControls.cpp
+1
View File
@@ -20,6 +20,7 @@ set(FILES
Lib/Tests/test_ViewPanePythonBindings.cpp
Lib/Tests/test_ViewportTitleDlgPythonBindings.cpp
Lib/Tests/test_DisplaySettingsPythonBindings.cpp
Lib/Tests/test_ViewportManipulatorController.cpp
DisplaySettingsPythonFuncs.cpp
DisplaySettingsPythonFuncs.h
)
@@ -728,6 +728,7 @@ namespace AZ
DestroyReflectionManager();
static_cast<SettingsRegistryImpl*>(m_settingsRegistry.get())->ClearNotifiers();
static_cast<SettingsRegistryImpl*>(m_settingsRegistry.get())->ClearMergeEvents();
// Uninit and unload any dynamic modules.
m_moduleManager->UnloadModules();
@@ -123,6 +123,36 @@ namespace AZ
using NotifyEvent = AZ::Event<AZStd::string_view, Type>;
using NotifyEventHandler = typename NotifyEvent::Handler;
using PreMergeEventCallback = AZStd::function<void(AZStd::string_view path, AZStd::string_view rootKey)>;
using PostMergeEventCallback = AZStd::function<void(AZStd::string_view path, AZStd::string_view rootKey)>;
using PreMergeEvent = AZ::Event<AZStd::string_view, AZStd::string_view>;
using PostMergeEvent = AZ::Event<AZStd::string_view, AZStd::string_view>;
using PreMergeEventHandler = typename PreMergeEvent::Handler;
using PostMergeEventHandler = typename PostMergeEvent::Handler;
struct ScopedMergeEvent
{
ScopedMergeEvent(
PreMergeEvent& preMergeEvent, PostMergeEvent& postMergeEvent, AZStd::string_view filePath, AZStd::string_view rootKey)
: m_preMergeEvent{ preMergeEvent }
, m_postMergeEvent{ postMergeEvent }
, m_filePath{ filePath }
, m_rootKey{ rootKey }
{
preMergeEvent.Signal(m_filePath, m_rootKey);
}
~ScopedMergeEvent()
{
m_postMergeEvent.Signal(m_filePath, m_rootKey);
}
PreMergeEvent& m_preMergeEvent;
PostMergeEvent& m_postMergeEvent;
AZStd::string_view m_filePath;
AZStd::string_view m_rootKey;
};
using VisitorCallback =
AZStd::function<VisitResponse(AZStd::string_view path, AZStd::string_view valueName, VisitAction action, Type type)>;
//! Base class for the visitor class during traversal over the Settings Registry. The type-agnostic function is always
@@ -169,6 +199,20 @@ namespace AZ
//! @callback The function to call when an entry gets a new/updated value.
[[nodiscard]] virtual NotifyEventHandler RegisterNotifier(NotifyCallback&& callback) = 0;
//! Register a function that will be called before a file is merged.
//! @callback The function to call before a file is merged.
[[nodiscard]] virtual PreMergeEventHandler RegisterPreMergeEvent(const PreMergeEventCallback& callback) = 0;
//! Register a function that will be called before a file is merged.
//! @callback The function to call before a file is merged.
[[nodiscard]] virtual PreMergeEventHandler RegisterPreMergeEvent (PreMergeEventCallback&& callback) = 0;
//! Register a function that will be called after a file is merged.
//! @callback The function to call after a file is merged.
[[nodiscard]] virtual PostMergeEventHandler RegisterPostMergeEvent(const PostMergeEventCallback& callback) = 0;
//! Register a function that will be called after a file is merged.
//! @callback The function to call after a file is merged.
[[nodiscard]] virtual PostMergeEventHandler RegisterPostMergeEvent (PostMergeEventCallback&& callback) = 0;
//! Gets the boolean value at the provided path.
//! @param result The target to write the result to.
//! @param path The path to the value.
@@ -228,6 +228,53 @@ namespace AZ
m_notifiers.DisconnectAllHandlers();
}
auto SettingsRegistryImpl::RegisterPreMergeEvent(const PreMergeEventCallback& callback) -> PreMergeEventHandler
{
PreMergeEventHandler preMergeHandler{ callback };
{
AZStd::scoped_lock lock(m_settingMutex);
preMergeHandler.Connect(m_preMergeEvent);
}
return preMergeHandler;
}
auto SettingsRegistryImpl::RegisterPreMergeEvent(PreMergeEventCallback&& callback) -> PreMergeEventHandler
{
PreMergeEventHandler preMergeHandler{ AZStd::move(callback) };
{
AZStd::scoped_lock lock(m_settingMutex);
preMergeHandler.Connect(m_preMergeEvent);
}
return preMergeHandler;
}
auto SettingsRegistryImpl::RegisterPostMergeEvent(const PostMergeEventCallback& callback) -> PostMergeEventHandler
{
PostMergeEventHandler postMergeHandler{ callback };
{
AZStd::scoped_lock lock(m_settingMutex);
postMergeHandler.Connect(m_postMergeEvent);
}
return postMergeHandler;
}
auto SettingsRegistryImpl::RegisterPostMergeEvent(PostMergeEventCallback&& callback) -> PostMergeEventHandler
{
PostMergeEventHandler postMergeHandler{ AZStd::move(callback) };
{
AZStd::scoped_lock lock(m_settingMutex);
postMergeHandler.Connect(m_postMergeEvent);
}
return postMergeHandler;
}
void SettingsRegistryImpl::ClearMergeEvents()
{
AZStd::scoped_lock lock(m_settingMutex);
m_preMergeEvent.DisconnectAllHandlers();
m_postMergeEvent.DisconnectAllHandlers();
}
void SettingsRegistryImpl::SignalNotifier(AZStd::string_view jsonPath, Type type)
{
// Move the Notifier AZ::Event to a local AZ::Event in order to allow
@@ -1165,6 +1212,8 @@ namespace AZ
return false;
}
ScopedMergeEvent scopedMergeEvent(m_preMergeEvent, m_postMergeEvent, path, rootKey);
JsonSerializationResult::ResultCode mergeResult(JsonSerializationResult::Tasks::Merge);
if (rootKey.empty())
{
@@ -48,6 +48,12 @@ namespace AZ
[[nodiscard]] NotifyEventHandler RegisterNotifier(NotifyCallback&& callback) override;
void ClearNotifiers();
[[nodiscard]] PreMergeEventHandler RegisterPreMergeEvent(const PreMergeEventCallback& callback) override;
[[nodiscard]] PreMergeEventHandler RegisterPreMergeEvent(PreMergeEventCallback&& callback) override;
[[nodiscard]] PostMergeEventHandler RegisterPostMergeEvent(const PostMergeEventCallback& callback) override;
[[nodiscard]] PostMergeEventHandler RegisterPostMergeEvent(PostMergeEventCallback&& callback) override;
void ClearMergeEvents();
bool Get(bool& result, AZStd::string_view path) const override;
bool Get(s64& result, AZStd::string_view path) const override;
bool Get(u64& result, AZStd::string_view path) const override;
@@ -106,6 +112,9 @@ namespace AZ
mutable AZStd::recursive_mutex m_settingMutex;
mutable AZStd::recursive_mutex m_notifierMutex;
NotifyEvent m_notifiers;
PreMergeEvent m_preMergeEvent;
PostMergeEvent m_postMergeEvent;
rapidjson::Document m_settings;
JsonSerializerSettings m_serializationSettings;
JsonDeserializerSettings m_deserializationSettings;
@@ -25,6 +25,10 @@ namespace AZ
MOCK_CONST_METHOD2(Visit, bool(const VisitorCallback&, AZStd::string_view));
MOCK_METHOD1(RegisterNotifier, NotifyEventHandler(const NotifyCallback&));
MOCK_METHOD1(RegisterNotifier, NotifyEventHandler(NotifyCallback&&));
MOCK_METHOD1(RegisterPreMergeEvent, PreMergeEventHandler(const PreMergeEventCallback&));
MOCK_METHOD1(RegisterPreMergeEvent, PreMergeEventHandler(PreMergeEventCallback&&));
MOCK_METHOD1(RegisterPostMergeEvent, PostMergeEventHandler(const PostMergeEventCallback&));
MOCK_METHOD1(RegisterPostMergeEvent, PostMergeEventHandler(PostMergeEventCallback&&));
MOCK_CONST_METHOD2(Get, bool(bool&, AZStd::string_view));
MOCK_CONST_METHOD2(Get, bool(s64&, AZStd::string_view));
@@ -207,7 +207,10 @@ namespace AzFramework
// Handles Win32 Window Event callbacks
LRESULT CALLBACK NativeWindowImpl_Win32::WindowCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
NativeWindowImpl_Win32* nativeWindowImpl = reinterpret_cast<NativeWindowImpl_Win32*>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
NativeWindowImpl_Win32* nativeWindowImpl = reinterpret_cast<NativeWindowImpl_Win32*>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
// If set to true, call DefWindowProc to ensure the default Windows behavior occurs
bool shouldBubbleEventUp = false;
switch (message)
{
@@ -276,14 +279,19 @@ namespace AzFramework
uint32_t refreshRate = DisplayConfig.dmDisplayFrequency;
WindowNotificationBus::Event(
nativeWindowImpl->GetWindowHandle(), &WindowNotificationBus::Events::OnRefreshRateChanged, refreshRate);
shouldBubbleEventUp = true;
break;
}
default:
return DefWindowProc(hWnd, message, wParam, lParam);
shouldBubbleEventUp = true;
break;
}
return 0;
if (!shouldBubbleEventUp)
{
return 0;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
void NativeWindowImpl_Win32::WindowSizeChanged(const uint32_t width, const uint32_t height)
@@ -10,22 +10,9 @@
namespace AzNetworking
{
StringifySerializer::StringifySerializer(char delimeter, bool outputFieldNames, const AZStd::string& seperator)
: m_delimeter(delimeter)
, m_outputFieldNames(outputFieldNames)
, m_separator(seperator)
const StringifySerializer::ValueMap& StringifySerializer::GetValueMap() const
{
;
}
const AZStd::string& StringifySerializer::GetString() const
{
return m_string;
}
const StringifySerializer::StringMap& StringifySerializer::GetValueMap() const
{
return m_map;
return m_valueMap;
}
SerializerMode StringifySerializer::GetSerializerMode() const
@@ -137,22 +124,9 @@ namespace AzNetworking
template <typename T>
bool StringifySerializer::ProcessData(const char* name, const T& value)
{
// Only add delimeters after we have processed at least one element
if (!m_string.empty())
{
m_string += m_delimeter;
}
if (m_outputFieldNames)
{
m_string += m_prefix;
m_string += name;
m_string += m_separator;
}
AZ::CVarFixedString string = AZ::ConsoleTypeHelpers::ValueToString(value);
m_string += string.c_str();
m_map[m_prefix + name] = string.c_str();
const AZStd::string keyString = m_prefix + name;
AZ::CVarFixedString valueString = AZ::ConsoleTypeHelpers::ValueToString(value);
m_valueMap[keyString] = valueString.c_str();
return true;
}
}
@@ -20,17 +20,12 @@ namespace AzNetworking
{
public:
using StringMap = AZStd::map<AZStd::string, AZStd::string>;
using ValueMap = AZStd::map<AZStd::string, AZStd::string>;
StringifySerializer(char delimeter = ' ', bool outputFieldNames = true, const AZStd::string& seperator = "=");
StringifySerializer() = default;
// GetString
// After serializing objects, get the serialized values as a single string
const AZStd::string& GetString() const;
// GetValueMap
// After serializing objects, get the serialized values as key value pairs
const StringMap& GetValueMap() const;
//! After serializing objects, get the serialized values as a map of key/value pairs.
const ValueMap& GetValueMap() const;
// ISerializer interfaces
SerializerMode GetSerializerMode() const override;
@@ -62,15 +57,8 @@ namespace AzNetworking
template <typename T>
bool ProcessData(const char* name, const T& value);
private:
char m_delimeter;
bool m_outputFieldNames = true;
StringMap m_map;
AZStd::string m_string;
ValueMap m_valueMap;
AZStd::string m_prefix;
AZStd::string m_separator;
AZStd::deque<AZStd::size_t> m_prefixSizeStack;
};
}
@@ -841,9 +841,6 @@ namespace AzToolsFramework
*/
virtual AZStd::string GetComponentIconPath(const AZ::Uuid& /*componentType*/, AZ::Crc32 /*componentIconAttrib*/, AZ::Component* /*component*/) { return AZStd::string(); }
/// Resource Selector hook, returns a path for a resource.
virtual AZStd::string SelectResource(const AZStd::string& /*resourceType*/, const AZStd::string& /*previousValue*/) { return AZStd::string(); }
/**
* Calculate the navigation 2D radius in units of an agent given its Navigation Type Name
* @param angentTypeName the name that identifies the agent navigation type
@@ -162,7 +162,6 @@ namespace AzToolsFramework
: QObject(sourceWidget)
, m_sourceWidget(sourceWidget)
, m_keyboardModifiers(AZStd::make_shared<AzFramework::ModifierKeyStates>())
, m_cursorPosition(AZStd::make_shared<AzFramework::InputChannel::PositionData2D>())
{
InitializeKeyMappings();
InitializeMouseButtonMappings();
@@ -230,24 +229,17 @@ namespace AzToolsFramework
return false;
}
// Because there's no "end" to mouse movement and wheel events, we reset mouse movement channels that have been opened
// during the next processed non-mouse event.
if (m_mouseChannelsNeedUpdate && event->type() != QEvent::Type::MouseMove && event->type() != QEvent::Type::Wheel)
{
m_cursorPosition->m_normalizedPositionDelta = AZ::Vector2::CreateZero();
ProcessPendingMouseEvents();
m_mouseChannelsNeedUpdate = false;
}
const auto eventType = event->type();
// Only accept mouse & key release events that originate from an object that is not our target widget,
// as we don't want to erroneously intercept user input meant for another component.
if (object != m_sourceWidget && event->type() != QEvent::Type::KeyRelease && event->type() != QEvent::Type::MouseButtonRelease)
if (object != m_sourceWidget && eventType != QEvent::Type::KeyRelease && eventType != QEvent::Type::MouseButtonRelease)
{
return false;
}
// If our focus changes, go ahead and reset all input devices.
if (event->type() == QEvent::FocusIn || event->type() == QEvent::FocusOut)
if (eventType == QEvent::FocusIn || eventType == QEvent::FocusOut)
{
HandleFocusChange(event);
}
@@ -255,27 +247,28 @@ namespace AzToolsFramework
// ShortcutOverride is used in lieu of KeyPress for high priority input channels like Alt
// that need to be accepted and stopped before they bubble up and cause unintended behavior.
else if (
event->type() == QEvent::Type::KeyPress || event->type() == QEvent::Type::KeyRelease ||
event->type() == QEvent::Type::ShortcutOverride)
eventType == QEvent::Type::KeyPress || eventType == QEvent::Type::KeyRelease || eventType == QEvent::Type::ShortcutOverride)
{
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
HandleKeyEvent(keyEvent);
}
// Map mouse events to input channels.
else if (event->type() == QEvent::Type::MouseButtonPress || event->type() == QEvent::Type::MouseButtonRelease || event->type() == QEvent::Type::MouseButtonDblClick)
else if (
eventType == QEvent::Type::MouseButtonPress || eventType == QEvent::Type::MouseButtonRelease ||
eventType == QEvent::Type::MouseButtonDblClick)
{
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
HandleMouseButtonEvent(mouseEvent);
}
// Map mouse movement to the movement input channels.
// This includes SystemCursorPosition alongside Movement::X and Movement::Y.
else if (event->type() == QEvent::Type::MouseMove)
else if (eventType == QEvent::Type::MouseMove)
{
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
HandleMouseMoveEvent(mouseEvent);
}
// Map wheel events to the mouse Z movement channel.
else if (event->type() == QEvent::Type::Wheel)
else if (eventType == QEvent::Type::Wheel)
{
QWheelEvent* wheelEvent = static_cast<QWheelEvent*>(event);
HandleWheelEvent(wheelEvent);
@@ -303,14 +296,16 @@ namespace AzToolsFramework
auto mouseWheelChannel =
GetInputChannel<AzFramework::InputChannelDeltaWithSharedPosition2D>(AzFramework::InputDeviceMouse::Movement::Z);
systemCursorChannel->ProcessRawInputEvent(m_cursorPosition->m_normalizedPositionDelta.GetLength());
systemCursorChannel->ProcessRawInputEvent(m_mouseDevice->m_cursorPositionData2D->m_normalizedPositionDelta.GetLength());
// Generate movement events based on the pixel delta divided by the DPI scaling factor, to calculate a rough approximation
// of cursor movement velocity.
movementXChannel->ProcessRawInputEvent(
m_cursorPosition->m_normalizedPositionDelta.GetX() * aznumeric_cast<float>(m_sourceWidget->width()) / m_sourceWidget->devicePixelRatioF());
m_mouseDevice->m_cursorPositionData2D->m_normalizedPositionDelta.GetX() * aznumeric_cast<float>(m_sourceWidget->width()) /
m_sourceWidget->devicePixelRatioF());
movementYChannel->ProcessRawInputEvent(
m_cursorPosition->m_normalizedPositionDelta.GetY() * aznumeric_cast<float>(m_sourceWidget->height()) / m_sourceWidget->devicePixelRatioF());
mouseWheelChannel->ProcessRawInputEvent(0.f);
m_mouseDevice->m_cursorPositionData2D->m_normalizedPositionDelta.GetY() * aznumeric_cast<float>(m_sourceWidget->height()) /
m_sourceWidget->devicePixelRatioF());
mouseWheelChannel->ProcessRawInputEvent(0.0f);
NotifyUpdateChannelIfNotIdle(systemCursorChannel, nullptr);
NotifyUpdateChannelIfNotIdle(movementXChannel, nullptr);
@@ -358,14 +353,13 @@ namespace AzToolsFramework
void QtEventToAzInputMapper::HandleMouseMoveEvent(QMouseEvent* mouseEvent)
{
AZ::Vector2 lastCursorPosition = m_cursorPosition->m_normalizedPosition;
AZ::Vector2 lastCursorPosition = m_mouseDevice->m_cursorPositionData2D->m_normalizedPosition;
const QPoint mousePos = mouseEvent->pos();
const AZ::Vector2 normalizedPosition = WidgetPositionToNormalizedPosition(mousePos);
m_cursorPosition->m_normalizedPositionDelta = normalizedPosition - m_cursorPosition->m_normalizedPosition;
m_cursorPosition->m_normalizedPosition = normalizedPosition;
m_mouseDevice->m_cursorPositionData2D->m_normalizedPositionDelta = normalizedPosition - m_mouseDevice->m_cursorPositionData2D->m_normalizedPosition;
m_mouseDevice->m_cursorPositionData2D->m_normalizedPosition = normalizedPosition;
ProcessPendingMouseEvents();
m_mouseChannelsNeedUpdate = true;
if (m_capturingCursor)
{
@@ -376,7 +370,7 @@ namespace AzToolsFramework
// Even though we just set the cursor position, there are edge cases such as remote desktop that will leave
// the cursor position unchanged. For safety, we re-cache our last cursor position for delta generation.
QPoint actualWidgetPosition = m_sourceWidget->mapFromGlobal(QCursor::pos());
m_cursorPosition->m_normalizedPosition = WidgetPositionToNormalizedPosition(actualWidgetPosition);
m_mouseDevice->m_cursorPositionData2D->m_normalizedPosition = WidgetPositionToNormalizedPosition(actualWidgetPosition);
}
}
@@ -427,21 +421,18 @@ namespace AzToolsFramework
}
cursorZChannel->ProcessRawInputEvent(aznumeric_cast<float>(wheelAngle));
NotifyUpdateChannelIfNotIdle(cursorZChannel, wheelEvent);
m_mouseChannelsNeedUpdate = true;
}
void QtEventToAzInputMapper::HandleFocusChange(QEvent* event)
{
for (auto& channelData : m_channels)
{
// If resetting the input device changed the channel state, submit it to the mapped channel list
// for processing.
// If resetting the input device changed the channel state, submit it to the mapped channel list for processing.
if (channelData.second->IsActive())
{
channelData.second->UpdateState(false);
NotifyUpdateChannelIfNotIdle(channelData.second, event);
}
}
m_mouseChannelsNeedUpdate = false;
}
} // namespace AzToolsFramework
@@ -138,8 +138,6 @@ namespace AzToolsFramework
// The current keyboard modifier state used by our synthetic key input channels.
AZStd::shared_ptr<AzFramework::ModifierKeyStates> m_keyboardModifiers;
// The current normalized cursor position used by our synthetic system cursor event.
AZStd::shared_ptr<AzFramework::InputChannel::PositionData2D> m_cursorPosition;
// A lookup table for Qt key -> AZ input channel.
AZStd::unordered_map<Qt::Key, AzFramework::InputChannelId> m_keyMappings;
// A lookup table for Qt mouse button -> AZ input channel.
@@ -152,8 +150,6 @@ namespace AzToolsFramework
AZStd::unordered_map<AzFramework::InputChannelId, AzFramework::InputChannel*> m_channels;
// The source widget to map events from, used to calculate the relative mouse position within the widget bounds.
QWidget* m_sourceWidget;
// Flags when mouse movement channels have been opened and may need to be closed (as there are no movement ended events).
bool m_mouseChannelsNeedUpdate = false;
// Flags whether or not Qt events should currently be processed.
bool m_enabled = true;
// Flags whether or not the cursor is being constrained to the source widget (for invisible mouse movement).
@@ -5,11 +5,9 @@
*
*/
#include <AzToolsFramework/Logger/TraceLogger.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzToolsFramework/Logger/TraceLogger.h>
namespace AzToolsFramework
{
@@ -25,6 +23,22 @@ namespace AzToolsFramework
bool TraceLogger::OnOutput(const char* window, const char* message)
{
for (const auto& filter : m_windowFilters)
{
if (AZ::StringFunc::Contains(window, filter))
{
return true;
}
}
for (const auto& filter : m_messageFilters)
{
if (AZ::StringFunc::Contains(message, filter))
{
return true;
}
}
if (m_logFile)
{
m_logFile->AppendLog(AzFramework::LogFile::SEV_NORMAL, window, message);
@@ -36,10 +50,10 @@ namespace AzToolsFramework
return false;
}
void TraceLogger::WriteStartupLog(const AZStd::string& logFileName)
{
void TraceLogger::PrepareLogFile(const AZStd::string& logFileName)
{
using namespace AzFramework;
AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance();
AZ_Assert(fileIO != nullptr, "FileIO should be running at this point");
@@ -71,4 +85,34 @@ namespace AzToolsFramework
m_logFile->FlushLog();
}
}
void TraceLogger::AddWindowFilter(const AZStd::string& filter)
{
m_windowFilters.insert(filter);
}
void TraceLogger::RemoveWindowFilter(const AZStd::string& filter)
{
m_windowFilters.erase(filter);
}
void TraceLogger::ClearWindowFilter()
{
m_windowFilters.clear();
}
void TraceLogger::AddMessageFilter(const AZStd::string& filter)
{
m_messageFilters.insert(filter);
}
void TraceLogger::RemoveMessageFilter(const AZStd::string& filter)
{
m_messageFilters.erase(filter);
}
void TraceLogger::ClearMessageFilter()
{
m_messageFilters.clear();
}
} // namespace AzToolsFramework
@@ -22,8 +22,26 @@ namespace AzToolsFramework
TraceLogger();
~TraceLogger();
//! Intalize logging for O3DEToolsApplications
void WriteStartupLog(const AZStd::string& logFileName);
//! Open log file and dump log sink into it
void PrepareLogFile(const AZStd::string& logFileName);
//! Add filter to ignore messages for windows with matching names
void AddWindowFilter(const AZStd::string& filter);
//! Remove window filter
void RemoveWindowFilter(const AZStd::string& filter);
//! Clear window filters
void ClearWindowFilter();
//! Add filter to ignore messages with matching names
void AddMessageFilter(const AZStd::string& filter);
//! Remove message filter
void RemoveMessageFilter(const AZStd::string& filter);
//! Clear message filters
void ClearMessageFilter();
protected:
//////////////////////////////////////////////////////////////////////////
@@ -38,6 +56,8 @@ namespace AzToolsFramework
AZStd::string message;
};
AZStd::vector<LogMessage> m_startupLogSink;
AZStd::unordered_set<AZStd::string> m_windowFilters;
AZStd::unordered_set<AZStd::string> m_messageFilters;
AZStd::unique_ptr<AzFramework::LogFile> m_logFile;
};
} // namespace AzToolsFramework
@@ -6,7 +6,6 @@
*
*/
// Description : For listing available script commands with their descriptions
#include "ScriptHelpDialog.h"
@@ -23,6 +22,7 @@
// AzToolsFramework
#include <AzToolsFramework/API/EditorPythonConsoleBus.h> // for EditorPythonConsoleInterface
#include <AzToolsFramework/API/EditorWindowRequestBus.h>
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
#include <AzToolsFramework/PythonTerminal/ui_ScriptHelpDialog.h>
@@ -313,6 +313,45 @@ namespace AzToolsFramework
connect(ui->tableView, &ScriptTableView::doubleClicked, this, &CScriptHelpDialog::OnDoubleClick);
}
CScriptHelpDialog* CScriptHelpDialog::GetInstance()
{
static CScriptHelpDialog* pInstance = nullptr;
if (!pInstance)
{
QMainWindow* mainWindow = GetMainWindowOfCurrentApplication();
if (!mainWindow)
{
AZ_Assert(false, "Failed to find MainWindow.");
return nullptr;
}
QWidget* parentWidget = mainWindow->window()
? mainWindow->window()
: mainWindow; // MainWindow might have a WindowDecorationWrapper parent. Makes a difference on macOS.
pInstance = new CScriptHelpDialog(parentWidget);
}
return pInstance;
}
QMainWindow* CScriptHelpDialog::GetMainWindowOfCurrentApplication()
{
QWidget* mainWindowWidget = nullptr;
EditorWindowRequestBus::BroadcastResult(mainWindowWidget, &EditorWindowRequests::GetAppMainWindow);
if (QMainWindow* mainWindow = qobject_cast<QMainWindow*>(mainWindowWidget))
{
return mainWindow;
}
for (QWidget* topLevelWidget : qApp->topLevelWidgets())
{
if (QMainWindow* mainWindow = qobject_cast<QMainWindow*>(topLevelWidget))
{
return mainWindow;
}
}
return nullptr;
}
void CScriptHelpDialog::OnDoubleClick(const QModelIndex& index)
{
if (!index.isValid())
@@ -132,43 +132,13 @@ namespace AzToolsFramework
{
Q_OBJECT
public:
static CScriptHelpDialog* GetInstance()
{
static CScriptHelpDialog* pInstance = nullptr;
if (!pInstance)
{
QMainWindow* mainWindow = GetMainWindowOfCurrentApplication();
if (!mainWindow)
{
AZ_Assert(false, "Failed to find MainWindow.");
return nullptr;
}
QWidget* parentWidget = mainWindow->window() ? mainWindow->window() : mainWindow; // MainWindow might have a WindowDecorationWrapper parent. Makes a difference on macOS.
pInstance = new CScriptHelpDialog(parentWidget);
}
return pInstance;
}
static CScriptHelpDialog* GetInstance();
private Q_SLOTS:
void OnDoubleClick(const QModelIndex&);
private:
static QMainWindow* GetMainWindowOfCurrentApplication()
{
QMainWindow* mainWindow = nullptr;
for (QWidget* w : qApp->topLevelWidgets())
{
mainWindow = qobject_cast<QMainWindow*>(w);
if (mainWindow)
{
return mainWindow;
}
}
return nullptr;
}
explicit CScriptHelpDialog(QWidget* parent = nullptr);
static QMainWindow* GetMainWindowOfCurrentApplication();
QScopedPointer<Ui::ScriptDialog> ui;
};
} // namespace AzToolsFramework
@@ -7,8 +7,8 @@
*/
#include "PropertyAudioCtrl.h"
#include "PropertyQTConstants.h"
#include <UI/PropertyEditor/PropertyAudioCtrl.h>
#include <UI/PropertyEditor/PropertyQTConstants.h>
#include <QtWidgets/QLabel>
#include <QtWidgets/QLineEdit>
@@ -34,7 +34,7 @@ namespace AzToolsFramework
: QWidget(parent)
, m_browseEdit(nullptr)
, m_mainLayout(nullptr)
, m_propertyType(AudioPropertyType::Invalid)
, m_propertyType(AudioPropertyType::NumTypes)
{
// create the gui
m_mainLayout = new QHBoxLayout();
@@ -96,7 +96,7 @@ namespace AzToolsFramework
return;
}
if (type != AudioPropertyType::Invalid)
if (type != AudioPropertyType::NumTypes)
{
m_propertyType = type;
}
@@ -136,10 +136,11 @@ namespace AzToolsFramework
void AudioControlSelectorWidget::OnOpenAudioControlSelector()
{
AZStd::string resourceResult;
AZStd::string resourceType(GetResourceSelectorNameFromType(m_propertyType));
AZStd::string currentValue(m_controlName.toStdString().c_str());
EditorRequests::Bus::BroadcastResult(resourceResult, &EditorRequests::Bus::Events::SelectResource, resourceType, currentValue);
AZStd::string resourceResult;
AudioControlSelectorRequestBus::EventResult(
resourceResult, m_propertyType,
&AudioControlSelectorRequestBus::Events::SelectResource, currentValue);
SetControlName(QString(resourceResult.c_str()));
}
@@ -167,12 +168,12 @@ namespace AzToolsFramework
{
case AudioPropertyType::Trigger:
return { "AudioTrigger" };
case AudioPropertyType::Rtpc:
return { "AudioRTPC" };
case AudioPropertyType::Switch:
return { "AudioSwitch" };
case AudioPropertyType::SwitchState:
return { "AudioSwitchState" };
case AudioPropertyType::Rtpc:
return { "AudioRTPC" };
case AudioPropertyType::Environment:
return { "AudioEnvironment" };
case AudioPropertyType::Preload:
@@ -29,6 +29,27 @@ class QMimeData;
namespace AzToolsFramework
{
//=============================================================================
// Audio Control Selector Request Bus
// For connecting UI proper
//=============================================================================
class AudioControlSelectorRequests
: public AZ::EBusTraits
{
public:
// EBusTraits
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
using BusIdType = AudioPropertyType;
virtual AZStd::string SelectResource(AZStd::string_view previousValue)
{
return previousValue;
}
};
using AudioControlSelectorRequestBus = AZ::EBus<AudioControlSelectorRequests>;
//=============================================================================
// Audio Control Selector Widget
//=============================================================================
@@ -18,15 +18,15 @@
namespace AzToolsFramework
{
//=========================================================================
enum class AudioPropertyType
enum class AudioPropertyType : AZ::u32
{
Invalid = 0,
Trigger,
Trigger = 0,
Rtpc,
Switch,
SwitchState,
Rtpc,
Environment,
Preload,
NumTypes,
};
//=========================================================================
@@ -40,7 +40,7 @@ namespace AzToolsFramework
virtual ~CReflectedVarAudioControl() = default;
AZStd::string m_controlName;
AudioPropertyType m_propertyType = AudioPropertyType::Invalid;
AudioPropertyType m_propertyType = AudioPropertyType::NumTypes;
static void Reflect(AZ::ReflectContext* context)
{
@@ -27,6 +27,35 @@ using namespace AzToolsFramework;
namespace UnitTest
{
void MousePressAndMove(
QWidget* widget, const QPoint& initialPositionWidget, const QPoint& mouseDelta, const Qt::MouseButton mouseButton)
{
QPoint position = widget->mapToGlobal(initialPositionWidget);
QTest::mousePress(widget, mouseButton, Qt::NoModifier, position);
MouseMove(widget, initialPositionWidget, mouseDelta, mouseButton);
}
// Note: There are a series of bugs in Qt that appear to be preventing mouseMove events
// firing when sent through the QTest framework. This is a work around for our version
// of Qt. In future this can hopefully be simplified. See ^1 for workaround.
// More info: Issues with mouse move in Qt
// - https://bugreports.qt.io/browse/QTBUG-5232
// - https://bugreports.qt.io/browse/QTBUG-69414
// - https://lists.qt-project.org/pipermail/development/2019-July/036873.html
void MouseMove(QWidget* widget, const QPoint& initialPositionWidget, const QPoint& mouseDelta, const Qt::MouseButton mouseButton)
{
QPoint nextPosition = widget->mapToGlobal(initialPositionWidget + mouseDelta);
// ^1 To ensure a mouse move event is fired we must call the test mouse move function
// and also send a mouse move event that matches. Each on their own do not appear to
// work - please see the links above for more context.
QTest::mouseMove(widget, nextPosition);
QMouseEvent mouseMoveEvent(
QEvent::MouseMove, QPointF(nextPosition), QPointF(nextPosition), Qt::NoButton, mouseButton, Qt::NoModifier);
QApplication::sendEvent(widget, &mouseMoveEvent);
}
bool TestWidget::eventFilter(QObject* watched, QEvent* event)
{
AZ_UNUSED(watched);
@@ -59,6 +59,21 @@ namespace UnitTest
{
constexpr AZStd::string_view prefabSystemSetting = "/Amazon/Preferences/EnablePrefabSystem";
/// Performs a mouse press and move event on the provided widget.
/// @param widget The widget to perform the mouse press and move on.
/// @param initialPositionWidget The position of the mouse relative to the widget (will be remapped to a global position internally).
/// @param mouseDelta How far to move the mouse.
/// @param mouseButton The button to be used during the press and move.
void MousePressAndMove(
QWidget* widget, const QPoint& initialPositionWidget, const QPoint& mouseDelta, Qt::MouseButton mouseButton = Qt::LeftButton);
/// Performs a mouse move event on the provided widget.
/// @param widget The widget to perform the mouse move on.
/// @param initialPositionWidget The position of the mouse relative to the widget (will be remapped to a global position internally).
/// @param mouseDelta How far to move the mouse (note: mouseDelta may be zero and the mouse will only be moved to initialPosition).
/// @param mouseButton The button to be held during the move.
void MouseMove(QWidget* widget, const QPoint& initialPosition, const QPoint& mouseDelta, Qt::MouseButton mouseButton = Qt::NoButton);
/// Test widget to store QActions generated by EditorTransformComponentSelection.
class TestWidget : public QWidget
{
@@ -313,7 +313,7 @@ namespace AzToolsFramework
//! Utility function to return EntityContextId.
inline AzFramework::EntityContextId GetEntityContextId()
{
AzFramework::EntityContextId entityContextId;
auto entityContextId = AzFramework::EntityContextId::CreateNull();
EditorEntityContextRequestBus::BroadcastResult(entityContextId, &EditorEntityContextRequests::GetEditorEntityContextId);
return entityContextId;
@@ -60,6 +60,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
PUBLIC
AZ::AzTestShared
PRIVATE
3rdParty::Qt::Test
3rdParty::googletest::GMock
3rdParty::GoogleBenchmark
AZ::AzToolsFramework
@@ -76,8 +77,9 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
PRIVATE
Tests
BUILD_DEPENDENCIES
PRIVATE
PUBLIC
AZ::AzTestShared
PRIVATE
3rdParty::Qt::Test
AZ::AzFrameworkTestShared
AZ::AzToolsFramework
@@ -107,31 +107,6 @@ namespace UnitTest
EXPECT_THAT(m_doubleSpinBoxWithLineEdit, Ne(nullptr));
}
// Note: There are a series of bugs in Qt that appear to be preventing mouseMove events
// firing when sent through the QTest framework. This is a work around for our version
// of Qt. In future this can hopefully be simplified. See ^1 for workaround.
// More info: Issues with mouse move in Qt
// - https://bugreports.qt.io/browse/QTBUG-5232
// - https://bugreports.qt.io/browse/QTBUG-69414
// - https://lists.qt-project.org/pipermail/development/2019-July/036873.html
void MousePressAndMove(
QWidget* widget, const QPoint& widgetScreenPosition, const QPoint& mouseDelta)
{
QPoint position = widget->mapToGlobal(widgetScreenPosition);
QPoint nextPosition = widget->mapToGlobal(widgetScreenPosition + mouseDelta);
QTest::mousePress(widget, Qt::LeftButton, Qt::NoModifier, position);
// ^1 To ensure a mouse move event is fired we must call the test mouse move function
// and also send a mouse move event that matches. Each on their own do not appear to
// work - please see the links above for more context.
QTest::mouseMove(widget, nextPosition);
QMouseEvent mouseMoveEvent(
QEvent::MouseMove, QPointF(nextPosition), QPointF(nextPosition),
Qt::NoButton, Qt::LeftButton, Qt::NoModifier);
QApplication::sendEvent(widget, &mouseMoveEvent);
}
TEST_F(SpinBoxFixture, SpinBoxMousePressAndMoveRightScrollsValue)
{
m_doubleSpinBox->setValue(10.0);
+2 -1
View File
@@ -851,7 +851,8 @@ bool CLog::LogToMainThread(const char* szString, ELogType logType, bool bAdd, SL
{
// When logging from other thread then main, push all log strings to queue.
SLogMsg msg;
azstrcpy(msg.msg, AZ_ARRAY_SIZE(msg.msg), szString);
constexpr size_t maxArraySize = AZ_ARRAY_SIZE(msg.msg);
azstrncpy(msg.msg, maxArraySize, szString, maxArraySize - 1);
msg.bAdd = bAdd;
msg.destination = destination;
msg.logType = logType;
@@ -21,11 +21,16 @@ namespace AZ
{
AssImpMaterialWrapper::AssImpMaterialWrapper(aiMaterial* aiMaterial)
:SDKMaterial::MaterialWrapper(aiMaterial)
:m_assImpMaterial(aiMaterial)
{
AZ_Assert(aiMaterial, "Asset Importer Material cannot be null");
}
aiMaterial* AssImpMaterialWrapper::GetAssImpMaterial() const
{
return m_assImpMaterial;
}
AZStd::string AssImpMaterialWrapper::GetName() const
{
return m_assImpMaterial->GetName().C_Str();
@@ -20,6 +20,7 @@ namespace AZ
AZ_RTTI(AssImpMaterialWrapper, "{66992628-CFCE-441B-8849-9344A49AFAC9}", SDKMaterial::MaterialWrapper);
AssImpMaterialWrapper(aiMaterial* aiMaterial);
~AssImpMaterialWrapper() override = default;
aiMaterial* GetAssImpMaterial() const;
AZStd::string GetName() const override;
AZ::u64 GetUniqueId() const override;
AZ::Vector3 GetDiffuseColor() const override;
@@ -38,6 +39,9 @@ namespace AZ
AZStd::optional<bool> GetUseEmissiveMap() const;
AZStd::optional<float> GetEmissiveIntensity() const;
AZStd::optional<bool> GetUseAOMap() const;
protected:
aiMaterial* m_assImpMaterial = nullptr;
};
} // namespace AssImpSDKWrapper
}// namespace AZ
@@ -17,14 +17,16 @@ namespace AZ
namespace AssImpSDKWrapper
{
AssImpNodeWrapper::AssImpNodeWrapper(aiNode* sourceNode)
:SDKNode::NodeWrapper(sourceNode)
: m_assImpNode(sourceNode)
{
AZ_Assert(m_assImpNode, "Asset Importer Node cannot be null");
}
AssImpNodeWrapper::~AssImpNodeWrapper()
aiNode* AssImpNodeWrapper::GetAssImpNode() const
{
return m_assImpNode;
}
const char* AssImpNodeWrapper::GetName() const
{
return m_assImpNode->mName.C_Str();
@@ -20,7 +20,8 @@ namespace AZ
public:
AZ_RTTI(AssImpNodeWrapper, "{1043260B-9076-49B7-AD38-EF62E85F7C1D}", SDKNode::NodeWrapper);
AssImpNodeWrapper(aiNode* sourceNode);
~AssImpNodeWrapper() override;
~AssImpNodeWrapper() override = default;
aiNode* GetAssImpNode() const;
const char* GetName() const override;
AZ::u64 GetUniqueId() const override;
int GetChildCount() const override;
@@ -28,6 +29,9 @@ namespace AZ
const bool ContainsMesh();
bool ContainsBones(const aiScene& scene) const;
int GetMaterialCount() const override;
protected:
aiNode* m_assImpNode = nullptr;
};
} // namespace AssImpSDKWrapper
}// namespace AZ
@@ -25,15 +25,10 @@ namespace AZ
namespace AssImpSDKWrapper
{
AssImpSceneWrapper::AssImpSceneWrapper()
: SDKScene::SceneWrapperBase()
{
}
AssImpSceneWrapper::AssImpSceneWrapper(aiScene* aiScene)
: SDKScene::SceneWrapperBase(aiScene)
{
}
AssImpSceneWrapper::~AssImpSceneWrapper()
: m_assImpScene(aiScene)
{
}
@@ -114,6 +109,11 @@ namespace AZ
m_importer.FreeScene();
}
const aiScene* AssImpSceneWrapper::GetAssImpScene() const
{
return m_assImpScene;
}
AZStd::pair<AssImpSceneWrapper::AxisVector, int32_t> AssImpSceneWrapper::GetUpVectorAndSign() const
{
AZStd::pair<AssImpSceneWrapper::AxisVector, int32_t> result(AxisVector::Z, 1);
@@ -21,13 +21,14 @@ namespace AZ
AZ_RTTI(AssImpSceneWrapper, "{43A61F62-DCD4-4132-B80B-F2FBC80740BC}", SDKScene::SceneWrapperBase);
AssImpSceneWrapper();
AssImpSceneWrapper(aiScene* aiScene);
~AssImpSceneWrapper();
~AssImpSceneWrapper() override = default;
bool LoadSceneFromFile(const char* fileName) override;
bool LoadSceneFromFile(const AZStd::string& fileName) override;
const std::shared_ptr<SDKNode::NodeWrapper> GetRootNode() const override;
std::shared_ptr<SDKNode::NodeWrapper> GetRootNode() override;
virtual const aiScene* GetAssImpScene() const;
void Clear() override;
enum class AxisVector
@@ -43,7 +44,7 @@ namespace AZ
AZStd::string GetSceneFileName() const { return m_sceneFileName; }
protected:
const aiScene* m_assImpScene = nullptr;
Assimp::Importer m_importer;
// FBX SDK automatically resolved relative paths to textures based on the current file location.
@@ -12,21 +12,6 @@ namespace AZ
{
namespace SDKMaterial
{
MaterialWrapper::MaterialWrapper(aiMaterial* assImpMaterial)
: m_assImpMaterial(assImpMaterial)
{
}
MaterialWrapper::~MaterialWrapper()
{
m_assImpMaterial = nullptr;
}
aiMaterial* MaterialWrapper::GetAssImpMaterial()
{
return m_assImpMaterial;
}
AZStd::string MaterialWrapper::GetName() const
{
return AZStd::string();
@@ -34,10 +34,7 @@ namespace AZ
BaseColor
};
MaterialWrapper(aiMaterial* assImpmaterial);
virtual ~MaterialWrapper();
aiMaterial* GetAssImpMaterial();
virtual ~MaterialWrapper() = default;
virtual AZStd::string GetName() const;
virtual AZ::u64 GetUniqueId() const;
@@ -47,9 +44,6 @@ namespace AZ
virtual AZ::Vector3 GetEmissiveColor() const;
virtual float GetOpacity() const;
virtual float GetShininess() const;
protected:
aiMaterial* m_assImpMaterial = nullptr;
};
} // namespace SDKMaterial
} // namespace AZ
@@ -12,21 +12,6 @@ namespace AZ
{
namespace SDKNode
{
NodeWrapper::NodeWrapper(aiNode* aiNode)
: m_assImpNode(aiNode)
{
}
NodeWrapper::~NodeWrapper()
{
m_assImpNode = nullptr;
}
aiNode* NodeWrapper::GetAssImpNode()
{
return m_assImpNode;
}
const char* NodeWrapper::GetName() const
{
return "";
+1 -7
View File
@@ -20,9 +20,7 @@ namespace AZ
public:
AZ_RTTI(NodeWrapper, "{5EB0897B-9728-44B7-B056-BA34AAF14715}");
NodeWrapper() = default;
NodeWrapper(aiNode* aiNode);
virtual ~NodeWrapper();
virtual ~NodeWrapper() = default;
enum CurveNodeComponent
{
@@ -31,16 +29,12 @@ namespace AZ
Component_Z
};
aiNode* GetAssImpNode();
virtual const char* GetName() const;
virtual AZ::u64 GetUniqueId() const;
virtual int GetMaterialCount() const;
virtual int GetChildCount()const;
virtual const std::shared_ptr<NodeWrapper> GetChild(int childIndex) const;
aiNode* m_assImpNode = nullptr;
};
} //namespace Node
} //namespace AZ
@@ -13,12 +13,6 @@ namespace AZ
{
const char* SceneWrapperBase::s_defaultSceneName = "myScene";
SceneWrapperBase::SceneWrapperBase(aiScene* aiScene)
: m_assImpScene(aiScene)
{
}
bool SceneWrapperBase::LoadSceneFromFile([[maybe_unused]] const char* fileName)
{
return false;
@@ -40,12 +34,5 @@ namespace AZ
void SceneWrapperBase::Clear()
{
}
const aiScene* SceneWrapperBase::GetAssImpScene() const
{
return m_assImpScene;
}
} //namespace Scene
}// namespace AZ
@@ -20,9 +20,7 @@ namespace AZ
{
public:
AZ_RTTI(SceneWrapperBase, "{703CD344-2C75-4F30-8CE2-6BDEF2511AFD}");
SceneWrapperBase() = default;
virtual ~SceneWrapperBase() = default;
SceneWrapperBase(aiScene* aiScene);
virtual bool LoadSceneFromFile(const char* fileName);
virtual bool LoadSceneFromFile(const AZStd::string& fileName);
@@ -31,10 +29,6 @@ namespace AZ
virtual std::shared_ptr<SDKNode::NodeWrapper> GetRootNode();
virtual void Clear();
virtual const aiScene* GetAssImpScene() const;
const aiScene* m_assImpScene = nullptr;
static const char* s_defaultSceneName;
};
@@ -56,9 +56,9 @@ namespace AZ
Events::ProcessingResultCombiner combinedMaterialImportResults;
AZStd::unordered_map<int, AZStd::shared_ptr<SceneData::GraphData::MaterialData>> materialMap;
for (unsigned int idx = 0; idx < context.m_sourceNode.m_assImpNode->mNumMeshes; ++idx)
for (unsigned int idx = 0; idx < context.m_sourceNode.GetAssImpNode()->mNumMeshes; ++idx)
{
int meshIndex = context.m_sourceNode.m_assImpNode->mMeshes[idx];
int meshIndex = context.m_sourceNode.GetAssImpNode()->mMeshes[idx];
const aiMesh* assImpMesh = context.m_sourceScene.GetAssImpScene()->mMeshes[meshIndex];
AZ_Assert(assImpMesh, "Asset Importer Mesh should not be null.");
int materialIndex = assImpMesh->mMaterialIndex;
@@ -222,7 +222,12 @@ namespace AZ
int childCount = node.m_node->GetChildCount();
for (int i = 0; i < childCount; ++i)
{
std::shared_ptr<AssImpSDKWrapper::AssImpNodeWrapper> child = std::make_shared<AssImpSDKWrapper::AssImpNodeWrapper>(node.m_node->GetChild(i)->GetAssImpNode());
const std::shared_ptr<SDKNode::NodeWrapper> nodeWrapper = node.m_node->GetChild(i);
auto assImpNodeWrapper = azrtti_cast<AssImpSDKWrapper::AssImpNodeWrapper*>(nodeWrapper.get());
AZ_Assert(assImpNodeWrapper, "Child node is not the expected AssImpNodeWrapper type");
std::shared_ptr<AssImpSDKWrapper::AssImpNodeWrapper> child = std::make_shared<AssImpSDKWrapper::AssImpNodeWrapper>(assImpNodeWrapper->GetAssImpNode());
if (child)
{
nodes.emplace(AZStd::move(child), newNode);
@@ -104,7 +104,7 @@ namespace AZ
}
AZStd::shared_ptr<Containers::Scene> AssetImportRequest::LoadSceneFromVerifiedPath(const AZStd::string& assetFilePath, const Uuid& sourceGuid,
RequestingApplication requester)
RequestingApplication requester, const Uuid& loadingComponentUuid)
{
AZStd::string sceneName;
AzFramework::StringFunc::Path::GetFileName(assetFilePath.c_str(), sceneName);
@@ -113,7 +113,7 @@ namespace AZ
// Unique pointer, will deactivate and clean up once going out of scope.
SceneCore::EntityConstructor::EntityPointer loaders =
SceneCore::EntityConstructor::BuildEntity("Scene Loading", SceneCore::LoadingComponent::TYPEINFO_Uuid());
SceneCore::EntityConstructor::BuildEntity("Scene Loading", loadingComponentUuid);
ProcessingResultCombiner areAllPrepared;
AssetImportRequestBus::BroadcastResult(areAllPrepared, &AssetImportRequestBus::Events::PrepareForAssetLoading, *scene, requester);
@@ -102,8 +102,9 @@ namespace AZ
//! @param sourceGuid The guid assigned to the source file (not the manifest).
//! @param requester The application making the request to load the file. This can be used to optimize the type and amount of data
//! to load.
//! @param loadingComponentUuid The UUID assigned to the loading component.
static AZStd::shared_ptr<Containers::Scene> LoadSceneFromVerifiedPath(const AZStd::string& assetFilePath,
const Uuid&sourceGuid, RequestingApplication requester);
const Uuid& sourceGuid, RequestingApplication requester, const Uuid& loadingComponentUuid);
//! Utility function to determine if a given file path points to a scene manifest file (.assetinfo).
//! @param filePath A relative or absolute path to the file to check.
@@ -11,6 +11,7 @@
#include <AzCore/Math/Guid.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
#include <SceneAPI/SceneCore/Components/LoadingComponent.h>
#include <SceneAPI/SceneCore/Mocks/Events/MockAssetImportRequest.h>
namespace AZ
@@ -184,7 +185,7 @@ namespace AZ
EXPECT_CALL(handler, UpdateManifest(_, _, _)).Times(0);
AZStd::shared_ptr<Containers::Scene> result =
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic);
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic, SceneCore::LoadingComponent::TYPEINFO_Uuid());
EXPECT_EQ(nullptr, result);
}
@@ -207,7 +208,7 @@ namespace AZ
EXPECT_CALL(handler, UpdateManifest(_, _, _)).Times(0);
AZStd::shared_ptr<Containers::Scene> result =
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic);
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic, SceneCore::LoadingComponent::TYPEINFO_Uuid());
EXPECT_EQ(nullptr, result);
}
@@ -230,7 +231,7 @@ namespace AZ
EXPECT_CALL(handler, UpdateManifest(_, _, _)).Times(0);
AZStd::shared_ptr<Containers::Scene> result =
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic);
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic, SceneCore::LoadingComponent::TYPEINFO_Uuid());
EXPECT_EQ(nullptr, result);
}
@@ -253,7 +254,7 @@ namespace AZ
EXPECT_CALL(handler, UpdateManifest(_, _, _)).Times(0);
AZStd::shared_ptr<Containers::Scene> result =
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic);
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic, SceneCore::LoadingComponent::TYPEINFO_Uuid());
EXPECT_EQ(nullptr, result);
}
@@ -285,7 +286,7 @@ namespace AZ
EXPECT_CALL(manifestHandler, UpdateManifest(_, _, _)).Times(1);
AZStd::shared_ptr<Containers::Scene> result =
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic);
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic, SceneCore::LoadingComponent::TYPEINFO_Uuid());
EXPECT_EQ(nullptr, result);
}
@@ -313,7 +314,7 @@ namespace AZ
EXPECT_CALL(manifestHandler, UpdateManifest(_, _, _)).Times(1);
AZStd::shared_ptr<Containers::Scene> result =
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic);
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic, SceneCore::LoadingComponent::TYPEINFO_Uuid());
EXPECT_NE(nullptr, result);
}
@@ -81,7 +81,7 @@ namespace AZ
// Register Shader Asset Builder
AssetBuilderSDK::AssetBuilderDesc shaderAssetBuilderDescriptor;
shaderAssetBuilderDescriptor.m_name = "Shader Asset Builder";
shaderAssetBuilderDescriptor.m_version = 102; // ATOM-15472
shaderAssetBuilderDescriptor.m_version = 103; // ATOM-15058
// .shader file changes trigger rebuilds
shaderAssetBuilderDescriptor.m_patterns.push_back(AssetBuilderSDK::AssetBuilderPattern( AZStd::string::format("*.%s", RPI::ShaderSourceData::Extension), AssetBuilderSDK::AssetBuilderPattern::PatternType::Wildcard));
shaderAssetBuilderDescriptor.m_busId = azrtti_typeid<ShaderAssetBuilder>();
@@ -226,11 +226,9 @@ namespace AZ
if (!hasRasterProgram && !hasComputeProgram && !hasRayTracingProgram)
{
AZStd::string entryPointNames = ShaderBuilderUtility::GetAcceptableDefaultEntryPointNames(azslData);
return AZ::Failure(
AZStd::string::format( "Shader asset descriptor has a program variant that does not define any entry points. Either declare entry "
"points in the .shader file, or use one of the available default names (not case-sensitive): [%s]",
entryPointNames.c_str()));
AZStd::string( "Shader asset descriptor has a program variant that does not define any entry points."
" Please declare entry points in the .shader file."));
}
return AZ::Success(attributeMaps);
@@ -478,21 +476,18 @@ namespace AZ
}
}
// Discover entry points & type of programs.
MapOfStringToStageType shaderEntryPoints;
if (shaderSourceData.m_programSettings.m_entryPoints.empty())
{
AZ_TracePrintf(
ShaderAssetBuilderName,
"ProgramSettings do not specify entry points, will use GetDefaultEntryPointsFromShader()\n");
ShaderBuilderUtility::GetDefaultEntryPointsFromFunctionDataList(azslData.m_functions, shaderEntryPoints);
AZ_Error( ShaderAssetBuilderName, false, "ProgramSettings must specify entry points.");
response.m_resultCode = AssetBuilderSDK::ProcessJobResult_Failed;
return;
}
else
// Discover entry points & type of programs.
MapOfStringToStageType shaderEntryPoints;
for (const auto& entryPoint : shaderSourceData.m_programSettings.m_entryPoints)
{
for (const auto& entryPoint : shaderSourceData.m_programSettings.m_entryPoints)
{
shaderEntryPoints[entryPoint.m_name] = entryPoint.m_type;
}
shaderEntryPoints[entryPoint.m_name] = entryPoint.m_type;
}
bool hasRasterProgram = false;
@@ -809,91 +809,6 @@ namespace AZ
return success;
}
//! Returns a list of acceptable default entry point names
static void GetAcceptableDefaultEntryPoints(
const AZStd::vector<FunctionData>& azslFunctionDataList,
AZStd::unordered_map<AZStd::string, RPI::ShaderStageType>& defaultEntryPoints)
{
for (const auto& func : azslFunctionDataList)
{
if (!func.m_hasShaderStageVaryings)
{
// Not declaring any semantics for a shader entry is valid, but unusual.
// A shader entry with no semantics must be explicitly listed and won't be selected by default.
continue;
}
if (func.m_name.starts_with("VS") || func.m_name.ends_with("VS"))
{
defaultEntryPoints[func.m_name] = RPI::ShaderStageType::Vertex;
AZ_TracePrintf(
ShaderBuilderUtilityName, "Assuming \"%s\" is a valid Vertex shader entry point.\n", func.m_name.c_str());
}
else if (func.m_name.starts_with("PS") || func.m_name.ends_with("PS"))
{
defaultEntryPoints[func.m_name] = RPI::ShaderStageType::Fragment;
AZ_TracePrintf(
ShaderBuilderUtilityName, "Assuming \"%s\" is a valid Fragment shader entry point.\n",
func.m_name.c_str());
}
else if (func.m_name.starts_with("CS") || func.m_name.ends_with("CS"))
{
defaultEntryPoints[func.m_name] = RPI::ShaderStageType::Compute;
AZ_TracePrintf(
ShaderBuilderUtilityName, "Assuming \"%s\" is a valid Compute shader entry point.\n", func.m_name.c_str());
}
}
}
// DEPRECATED [ATOM-15472
//! Returns a list of acceptable default entry point names
//! This function
static void GetAcceptableDefaultEntryPoints(
const AzslData& azslData, AZStd::unordered_map<AZStd::string, RPI::ShaderStageType>& defaultEntryPoints)
{
return GetAcceptableDefaultEntryPoints(azslData.m_functions, defaultEntryPoints);
}
void GetDefaultEntryPointsFromFunctionDataList(
const AZStd::vector<FunctionData> azslFunctionDataList,
AZStd::unordered_map<AZStd::string, RPI::ShaderStageType>& shaderEntryPoints)
{
AZStd::unordered_map<AZStd::string, RPI::ShaderStageType> defaultEntryPoints;
GetAcceptableDefaultEntryPoints(azslFunctionDataList, defaultEntryPoints);
for (const auto& functionData : azslFunctionDataList)
{
for (const auto& defaultEntryPoint : defaultEntryPoints)
{
// Equal defaults to case insensitive compares...
if (AzFramework::StringFunc::Equal(defaultEntryPoint.first.c_str(), functionData.m_name.c_str()))
{
shaderEntryPoints[defaultEntryPoint.first] = defaultEntryPoint.second;
break; // stop looping default entry points and go to the next shader function
}
}
}
}
AZStd::string GetAcceptableDefaultEntryPointNames(const AzslData& azslData)
{
AZStd::unordered_map<AZStd::string, RPI::ShaderStageType> defaultEntryPointList;
GetAcceptableDefaultEntryPoints(azslData, defaultEntryPointList);
AZStd::vector<AZStd::string> defaultEntryPointNamesList;
for (const auto& shaderEntryPoint : defaultEntryPointList)
{
defaultEntryPointNamesList.push_back(shaderEntryPoint.first);
}
AZStd::string shaderEntryPoints;
AzFramework::StringFunc::Join(
shaderEntryPoints, defaultEntryPointNamesList.begin(), defaultEntryPointNamesList.end(), ", ");
return AZStd::move(shaderEntryPoints);
}
} // namespace ShaderBuilderUtility
} // namespace ShaderBuilder
} // AZ
@@ -94,10 +94,6 @@ namespace AZ
RPI::ShaderOutputContract& shaderOutputContract, size_t& colorAttachmentCount);
//! Returns a list of acceptable default entry point names as a single string for debug messages.
AZStd::string GetAcceptableDefaultEntryPointNames(const AzslData& shaderData);
//! Create a file from a string's content.
//! That file will be named filename.api.azslin
//! This is meant to be used at this stage:
@@ -138,10 +134,6 @@ namespace AZ
AZStd::vector<RPI::ShaderSourceData::SupervariantInfo> GetSupervariantListFromShaderSourceData(
const RPI::ShaderSourceData& shaderSourceData);
void GetDefaultEntryPointsFromFunctionDataList(
const AZStd::vector<FunctionData> azslFunctionDataList,
AZStd::unordered_map<AZStd::string, RPI::ShaderStageType>& shaderEntryPoints);
void LogProfilingData(const char* builderName, AZStd::string_view shaderPath);
//! Returns the asset path of a product artifact produced by ShaderAssetBuilder.
@@ -843,17 +843,14 @@ namespace AZ
MapOfStringToStageType shaderEntryPoints;
if (shaderSourceDescriptor.m_programSettings.m_entryPoints.empty())
{
AZ_TracePrintf(
ShaderVariantAssetBuilderName,
"ProgramSettings do not specify entry points, will use GetDefaultEntryPointsFromShader()\n");
ShaderBuilderUtility::GetDefaultEntryPointsFromFunctionDataList(azslFunctions, shaderEntryPoints);
AZ_Error(ShaderVariantAssetBuilderName, false, "ProgramSettings must specify entry points.");
response.m_resultCode = AssetBuilderSDK::ProcessJobResult_Failed;
return;
}
else
for (const auto& entryPoint : shaderSourceDescriptor.m_programSettings.m_entryPoints)
{
for (const auto& entryPoint : shaderSourceDescriptor.m_programSettings.m_entryPoints)
{
shaderEntryPoints[entryPoint.m_name] = entryPoint.m_type;
}
shaderEntryPoints[entryPoint.m_name] = entryPoint.m_type;
}
// 3- hlslCode
@@ -18,5 +18,20 @@
"BlendOp": "Add"
},
"ProgramSettings" :
{
"EntryPoints":
[
{
"name": "ShadowCatcherVS",
"type" : "Vertex"
},
{
"name": "ShadowCatcherPS",
"type" : "Fragment"
}
]
},
"DrawList": "transparent"
}
@@ -9,5 +9,16 @@
"DisableOptimizations" : false
},
"ProgramSettings" :
{
"EntryPoints":
[
{
"name": "DepthPassVS",
"type" : "Vertex"
}
]
},
"DrawList" : "depth"
}
@@ -13,5 +13,16 @@
"CompilerHints" : {
},
"ProgramSettings" :
{
"EntryPoints":
[
{
"name": "DepthPassVS",
"type" : "Vertex"
}
]
},
"DrawList" : "depthTransparentMax"
}
@@ -11,5 +11,16 @@
"DisableOptimizations" : false
},
"ProgramSettings" :
{
"EntryPoints":
[
{
"name": "DepthPassVS",
"type" : "Vertex"
}
]
},
"DrawList" : "depthTransparentMin"
}

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