diff --git a/AutomatedTesting/Gem/Editor/Scripts/__init__.py b/AutomatedTesting/Gem/Editor/Scripts/__init__.py new file mode 100644 index 0000000000..79f8fa4422 --- /dev/null +++ b/AutomatedTesting/Gem/Editor/Scripts/__init__.py @@ -0,0 +1,10 @@ +""" +All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +its licensors. + +For complete copyright and license terms please see the LICENSE at the root of this +distribution (the "License"). All use of this software is governed by the License, +or, if provided, by the license below or the license accompanying this file. Do not +remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +""" diff --git a/AutomatedTesting/Gem/Editor/Scripts/bootstrap.py b/AutomatedTesting/Gem/Editor/Scripts/bootstrap.py new file mode 100644 index 0000000000..e41f9c1767 --- /dev/null +++ b/AutomatedTesting/Gem/Editor/Scripts/bootstrap.py @@ -0,0 +1,13 @@ +""" +All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +its licensors. + +For complete copyright and license terms please see the LICENSE at the root of this +distribution (the "License"). All use of this software is governed by the License, +or, if provided, by the license below or the license accompanying this file. Do not +remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +""" +import sys, os +sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../../PythonTests') +from PythonAssetBuilder import bootstrap_tests diff --git a/AutomatedTesting/Gem/PythonTests/CMakeLists.txt b/AutomatedTesting/Gem/PythonTests/CMakeLists.txt index b7a5f85087..c527aea98c 100644 --- a/AutomatedTesting/Gem/PythonTests/CMakeLists.txt +++ b/AutomatedTesting/Gem/PythonTests/CMakeLists.txt @@ -134,6 +134,25 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS) ) endif() +## Python Asset Builder ## +if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS) + ly_add_pytest( + NAME AutomatedTesting::PythonAssetBuilder + TEST_SUITE periodic + TEST_SERIAL + PATH ${CMAKE_CURRENT_LIST_DIR}/PythonAssetBuilder + TIMEOUT 3600 + RUNTIME_DEPENDENCIES + Legacy::Editor + Legacy::CryRenderNULL + AZ::AssetProcessor + AutomatedTesting.Assets + Gem::EditorPythonBindings.Editor + Gem::PythonAssetBuilder.Editor + COMPONENT TestTools + ) +endif() + ## Blast ## if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS) ly_add_pytest( diff --git a/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/AssetBuilder_test.py b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/AssetBuilder_test.py new file mode 100644 index 0000000000..e914182542 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/AssetBuilder_test.py @@ -0,0 +1,57 @@ +""" +All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +its licensors. + +For complete copyright and license terms please see the LICENSE at the root of this +distribution (the "License"). All use of this software is governed by the License, +or, if provided, by the license below or the license accompanying this file. Do not +remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +""" +# +# This launches the AssetProcessor and Editor then attempts to find the expected +# assets created by a Python Asset Builder and the output of a scene pipeline script +# +import sys +import os +import pytest +import logging +pytest.importorskip('ly_test_tools') + +import ly_test_tools.environment.file_system as file_system +import ly_test_tools.log.log_monitor +import ly_test_tools.environment.waiter as waiter + +@pytest.mark.SUITE_sandbox +@pytest.mark.parametrize('launcher_platform', ['windows_editor']) +@pytest.mark.parametrize('project', ['AutomatedTesting']) +@pytest.mark.parametrize('level', ['auto_test']) +class TestPythonAssetProcessing(object): + def test_DetectPythonCreatedAsset(self, request, editor, level, launcher_platform): + unexpected_lines = [] + expected_lines = [ + 'Mock asset exists', + 'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center.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_X_positive.azmodel) found', + 'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center.azmodel) found', + 'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center.azmodel) found', + 'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center.azmodel) found', + 'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center.azmodel) found', + 'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center.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]) + + with editor.start(): + editorlog_file = os.path.join(editor.workspace.paths.project_log(), 'Editor.log') + log_monitor = ly_test_tools.log.log_monitor.LogMonitor(editor, editorlog_file) + waiter.wait_for( + lambda: editor.is_alive(), + timeout, + exc=("Log file '{}' was never opened by another process.".format(editorlog_file)), + interval=1) + log_monitor.monitor_log_for_lines(expected_lines, unexpected_lines, halt_on_unexpected, timeout) diff --git a/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/AssetBuilder_test_case.py b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/AssetBuilder_test_case.py new file mode 100644 index 0000000000..54857c2067 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/AssetBuilder_test_case.py @@ -0,0 +1,52 @@ +""" +All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +its licensors. + +For complete copyright and license terms please see the LICENSE at the root of this +distribution (the "License"). All use of this software is governed by the License, +or, if provided, by the license below or the license accompanying this file. Do not +remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +""" +import azlmbr.bus +import azlmbr.asset +import azlmbr.editor +import azlmbr.math +import azlmbr.legacy.general + +def raise_and_stop(msg): + print (msg) + azlmbr.editor.EditorToolsApplicationRequestBus(azlmbr.bus.Broadcast, 'ExitNoPrompt') + +# These tests are meant to check that the test_asset.mock source asset turned into +# a test_asset.mock_asset product asset via the Python asset builder system +mockAssetType = azlmbr.math.Uuid_CreateString('{9274AD17-3212-4651-9F3B-7DCCB080E467}', 0) +mockAssetPath = 'gem/pythontests/pythonassetbuilder/test_asset.mock_asset' +assetId = azlmbr.asset.AssetCatalogRequestBus(azlmbr.bus.Broadcast, 'GetAssetIdByPath', mockAssetPath, mockAssetType, False) +if (assetId.is_valid() is False): + raise_and_stop(f'Mock AssetId is not valid! Got {assetId.to_string()} instead') + +if (assetId.to_string().endswith(':54c06b89') is False): + raise_and_stop(f'Mock AssetId has unexpected sub-id for {mockAssetPath}!') + +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): + 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 has unexpected asset ID ({assetIdString}) for ({generatedModelAssetPath})!') + else: + print(f'Expected subId for asset ({generatedModelAssetPath}) found') + +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_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_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_Z_positive.azmodel', '1024be55') +test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_Z_negative.azmodel', '1052c94e') + +azlmbr.editor.EditorToolsApplicationRequestBus(azlmbr.bus.Broadcast, 'ExitNoPrompt') diff --git a/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/__init__.py b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/__init__.py new file mode 100644 index 0000000000..6ed3dc4bda --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/__init__.py @@ -0,0 +1,10 @@ +""" +All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +its licensors. + +For complete copyright and license terms please see the LICENSE at the root of this +distribution (the "License"). All use of this software is governed by the License, +or, if provided, by the license below or the license accompanying this file. Do not +remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +""" \ No newline at end of file diff --git a/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/bootstrap_tests.py b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/bootstrap_tests.py new file mode 100644 index 0000000000..9e7b738a4d --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/bootstrap_tests.py @@ -0,0 +1,17 @@ +""" +All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +its licensors. + +For complete copyright and license terms please see the LICENSE at the root of this +distribution (the "License"). All use of this software is governed by the License, +or, if provided, by the license below or the license accompanying this file. Do not +remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +""" +import os +import sys +try: + sys.path.append(os.path.dirname(os.path.abspath(__file__))) + import mock_asset_builder +except: + print ('skipping asset builder testing via mock_asset_builder') diff --git a/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/export_chunks_builder.py b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/export_chunks_builder.py new file mode 100644 index 0000000000..ad68a486b1 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/export_chunks_builder.py @@ -0,0 +1,88 @@ +""" +All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +its licensors. + +For complete copyright and license terms please see the LICENSE at the root of this +distribution (the "License"). All use of this software is governed by the License, +or, if provided, by the license below or the license accompanying this file. Do not +remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +""" +import uuid, os +import azlmbr.scene as sceneApi +import azlmbr.scene.graph +from scene_api import scene_data as sceneData + +def get_mesh_node_names(sceneGraph): + meshDataList = [] + node = sceneGraph.get_root() + children = [] + + while node.IsValid(): + # store children to process after siblings + if sceneGraph.has_node_child(node): + children.append(sceneGraph.get_node_child(node)) + + # store any node that has mesh data content + nodeContent = sceneGraph.get_node_content(node) + if nodeContent is not None and nodeContent.CastWithTypeName('MeshData'): + if sceneGraph.is_node_end_point(node) is False: + meshDataList.append(sceneData.SceneGraphName(sceneGraph.get_node_name(node))) + + # advance to next node + if sceneGraph.has_node_sibling(node): + node = sceneGraph.get_node_sibling(node) + elif children: + node = children.pop() + else: + node = azlmbr.scene.graph.NodeIndex() + + return meshDataList + +def update_manifest(scene): + graph = sceneData.SceneGraph(scene.graph) + meshNameList = get_mesh_node_names(graph) + sceneManifest = sceneData.SceneManifest() + sourceFilenameOnly = os.path.basename(scene.sourceFilename) + sourceFilenameOnly = sourceFilenameOnly.replace('.','_') + + for activeMeshIndex in range(len(meshNameList)): + chunkName = meshNameList[activeMeshIndex] + chunkPath = chunkName.get_path() + meshGroupName = '{}_{}'.format(sourceFilenameOnly, chunkName.get_name()) + meshGroup = sceneManifest.add_mesh_group(meshGroupName) + meshGroup['id'] = '{' + str(uuid.uuid5(uuid.NAMESPACE_DNS, sourceFilenameOnly + chunkPath)) + '}' + sceneManifest.mesh_group_add_comment(meshGroup, 'auto generated by scene manifest') + sceneManifest.mesh_group_add_advanced_coordinate_system(meshGroup, None, None, None, 1.0) + + # create selection node list + pathSet = set() + for meshIndex in range(len(meshNameList)): + targetPath = meshNameList[meshIndex].get_path() + if (activeMeshIndex == meshIndex): + sceneManifest.mesh_group_select_node(meshGroup, targetPath) + else: + if targetPath not in pathSet: + pathSet.update(targetPath) + sceneManifest.mesh_group_unselect_node(meshGroup, targetPath) + + return sceneManifest.export() + +mySceneJobHandler = None + +def on_update_manifest(args): + scene = args[0] + result = update_manifest(scene) + global mySceneJobHandler + mySceneJobHandler.disconnect() + mySceneJobHandler = None + return result + +def main(): + global mySceneJobHandler + mySceneJobHandler = sceneApi.ScriptBuildingNotificationBusHandler() + mySceneJobHandler.connect() + mySceneJobHandler.add_callback('OnUpdateManifest', on_update_manifest) + +if __name__ == "__main__": + main() diff --git a/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/geom_group.fbx b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/geom_group.fbx new file mode 100644 index 0000000000..8945a5505a --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/geom_group.fbx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:66d38948309ef273adf74b63eaa38f8fc2e2bdfbab3933d2ee082ce6a8cb108e +size 30496 diff --git a/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/geom_group.fbx.assetinfo b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/geom_group.fbx.assetinfo new file mode 100644 index 0000000000..707c6f3705 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/geom_group.fbx.assetinfo @@ -0,0 +1,9 @@ +{ + "values": + [ + { + "$type": "ScriptProcessorRule", + "scriptFilename": "Gem/PythonTests/PythonAssetBuilder/export_chunks_builder.py" + } + ] +} diff --git a/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/mock_asset_builder.py b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/mock_asset_builder.py new file mode 100644 index 0000000000..3b695e3ccd --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/mock_asset_builder.py @@ -0,0 +1,121 @@ +""" +All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +its licensors. + +For complete copyright and license terms please see the LICENSE at the root of this +distribution (the "License"). All use of this software is governed by the License, +or, if provided, by the license below or the license accompanying this file. Do not +remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +""" +import azlmbr.asset +import azlmbr.asset.builder +import azlmbr.bus +import azlmbr.math +import os, traceback, binascii, sys + +jobKeyName = 'Mock Asset' + +def log_exception_traceback(): + exc_type, exc_value, exc_tb = sys.exc_info() + data = traceback.format_exception(exc_type, exc_value, exc_tb) + print(str(data)) + +# creates a single job to compile for each platform +def create_jobs(request): + # create job descriptor for each platform + jobDescriptorList = [] + for platformInfo in request.enabledPlatforms: + jobDesc = azlmbr.asset.builder.JobDescriptor() + jobDesc.jobKey = jobKeyName + jobDesc.set_platform_identifier(platformInfo.identifier) + jobDescriptorList.append(jobDesc) + + response = azlmbr.asset.builder.CreateJobsResponse() + response.result = azlmbr.asset.builder.CreateJobsResponse_ResultSuccess + response.createJobOutputs = jobDescriptorList + return response + +def on_create_jobs(args): + try: + request = args[0] + return create_jobs(request) + except: + log_exception_traceback() + # returing back a default CreateJobsResponse() records an asset error + return azlmbr.asset.builder.CreateJobsResponse() + +def process_file(request): + # prepare output folder + basePath, _ = os.path.split(request.sourceFile) + outputPath = os.path.join(request.tempDirPath, basePath) + os.makedirs(outputPath, exist_ok=True) + + # write out a mock file + basePath, sourceFile = os.path.split(request.sourceFile) + mockFilename = os.path.splitext(sourceFile)[0] + '.mock_asset' + mockFilename = os.path.join(basePath, mockFilename) + mockFilename = mockFilename.replace('\\', '/') + tempFilename = os.path.join(request.tempDirPath, mockFilename) + + # write out a tempFilename like a JSON + fileOutput = open(tempFilename, "w") + fileOutput.write('{}') + fileOutput.close() + + # generate a product asset file entry + subId = binascii.crc32(mockFilename.encode()) + mockAssetType = azlmbr.math.Uuid_CreateString('{9274AD17-3212-4651-9F3B-7DCCB080E467}', 0) + product = azlmbr.asset.builder.JobProduct(mockFilename, mockAssetType, subId) + product.dependenciesHandled = True + productOutputs = [] + productOutputs.append(product) + + # fill out response object + response = azlmbr.asset.builder.ProcessJobResponse() + response.outputProducts = productOutputs + response.resultCode = azlmbr.asset.builder.ProcessJobResponse_Success + response.dependenciesHandled = True + return response + +# using the incoming 'request' find the type of job via 'jobKey' to determine what to do +def on_process_job(args): + try: + request = args[0] + if (request.jobDescription.jobKey.startswith(jobKeyName)): + return process_file(request) + except: + log_exception_traceback() + # returning back an empty ProcessJobResponse() will record an error + return azlmbr.asset.builder.ProcessJobResponse() + +# register asset builder +def register_asset_builder(busId): + assetPattern = azlmbr.asset.builder.AssetBuilderPattern() + assetPattern.pattern = '*.mock' + assetPattern.type = azlmbr.asset.builder.AssetBuilderPattern_Wildcard + + builderDescriptor = azlmbr.asset.builder.AssetBuilderDesc() + builderDescriptor.name = "Mock Builder" + builderDescriptor.patterns = [assetPattern] + builderDescriptor.busId = busId + builderDescriptor.version = 1 + + outcome = azlmbr.asset.builder.PythonAssetBuilderRequestBus(azlmbr.bus.Broadcast, 'RegisterAssetBuilder', builderDescriptor) + if outcome.IsSuccess(): + # created the asset builder to hook into the notification bus + handler = azlmbr.asset.builder.PythonBuilderNotificationBusHandler() + handler.connect(busId) + handler.add_callback('OnCreateJobsRequest', on_create_jobs) + handler.add_callback('OnProcessJobRequest', on_process_job) + return handler + +# create the asset builder handler +busIdString = '{CF5C74C1-9ED4-5851-95B1-0B15090DBEC7}' +busId = azlmbr.math.Uuid_CreateString(busIdString, 0) +handler = None +try: + handler = register_asset_builder(busId) +except: + handler = None + log_exception_traceback() diff --git a/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/test_asset.mock b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/test_asset.mock new file mode 100644 index 0000000000..6d6a52e643 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/test_asset.mock @@ -0,0 +1 @@ +mock data \ No newline at end of file diff --git a/AutomatedTesting/LightingPresets/greenwich_park_02.lightingconfig.json b/AutomatedTesting/LightingPresets/greenwich_park_02.lightingconfig.json index 1646dd18a2..bfb92bbb6f 100644 --- a/AutomatedTesting/LightingPresets/greenwich_park_02.lightingconfig.json +++ b/AutomatedTesting/LightingPresets/greenwich_park_02.lightingconfig.json @@ -1,7 +1,6 @@ { "configurations": [ { - "autoSelect": false, "displayName": "Greenwich Park 02", "skyboxImageAsset": { "assetId": { @@ -64,7 +63,6 @@ "shadowCatcherOpacity": 0.20000000298023225 }, { - "autoSelect": false, "displayName": "Greenwich Park 02 (Alt)", "skyboxImageAsset": { "assetId": { diff --git a/Code/Framework/AzCore/AzCore/Component/ComponentApplication.cpp b/Code/Framework/AzCore/AzCore/Component/ComponentApplication.cpp index a3af2648cf..c55f565615 100644 --- a/Code/Framework/AzCore/AzCore/Component/ComponentApplication.cpp +++ b/Code/Framework/AzCore/AzCore/Component/ComponentApplication.cpp @@ -341,6 +341,16 @@ namespace AZ ; } } + + if (auto behaviorContext = azrtti_cast(context)) + { + behaviorContext->EBus("ComponentApplicationBus") + ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) + ->Attribute(AZ::Script::Attributes::Category, "Components") + + ->Event("GetEntityName", &ComponentApplicationBus::Events::GetEntityName) + ->Event("SetEntityName", &ComponentApplicationBus::Events::SetEntityName); + } } //========================================================================= @@ -1050,6 +1060,20 @@ namespace AZ return AZStd::string(); } + //========================================================================= + // SetEntityName + //========================================================================= + bool ComponentApplication::SetEntityName(const EntityId& id, const AZStd::string_view name) + { + Entity* entity = FindEntity(id); + if (entity) + { + entity->SetName(name); + return true; + } + return false; + } + //========================================================================= // EnumerateEntities //========================================================================= diff --git a/Code/Framework/AzCore/AzCore/Component/ComponentApplication.h b/Code/Framework/AzCore/AzCore/Component/ComponentApplication.h index ef5c813573..3ebcf39d95 100644 --- a/Code/Framework/AzCore/AzCore/Component/ComponentApplication.h +++ b/Code/Framework/AzCore/AzCore/Component/ComponentApplication.h @@ -209,6 +209,7 @@ namespace AZ bool DeleteEntity(const EntityId& id) override; Entity* FindEntity(const EntityId& id) override; AZStd::string GetEntityName(const EntityId& id) override; + bool SetEntityName(const EntityId& id, const AZStd::string_view name) override; void EnumerateEntities(const ComponentApplicationRequests::EntityCallback& callback) override; ComponentApplication* GetApplication() override { return this; } /// Returns the serialize context that has been registered with the app, if there is one. diff --git a/Code/Framework/AzCore/AzCore/Component/ComponentApplicationBus.h b/Code/Framework/AzCore/AzCore/Component/ComponentApplicationBus.h index d0f161aa39..3582e6ebb8 100644 --- a/Code/Framework/AzCore/AzCore/Component/ComponentApplicationBus.h +++ b/Code/Framework/AzCore/AzCore/Component/ComponentApplicationBus.h @@ -130,7 +130,13 @@ namespace AZ //! @param entity A reference to the entity whose name you are seeking. //! @return The name of the entity with the specified entity ID. //! If no entity is found for the specified ID, it returns an empty string. - virtual AZStd::string GetEntityName(const EntityId& id) { (void)id; return AZStd::string(); }; + virtual AZStd::string GetEntityName(const EntityId& id) { (void)id; return AZStd::string(); } + + //! Sets the name of the entity that has the specified entity ID. + //! Entity names are not enforced to be unique. + //! @param entityId A reference to the entity whose name you want to change. + //! @return True if the name was changed successfully, false if it wasn't. + virtual bool SetEntityName([[maybe_unused]] const EntityId& id, [[maybe_unused]] const AZStd::string_view name) { return false; } //! The type that AZ::ComponentApplicationRequests::EnumerateEntities uses to //! pass entity callbacks to the application for enumeration. diff --git a/Code/Framework/AzCore/AzCore/Math/Quaternion.cpp b/Code/Framework/AzCore/AzCore/Math/Quaternion.cpp index ca09f8b453..143fe59ca7 100644 --- a/Code/Framework/AzCore/AzCore/Math/Quaternion.cpp +++ b/Code/Framework/AzCore/AzCore/Math/Quaternion.cpp @@ -258,7 +258,8 @@ namespace AZ Method("CreateFromMatrix3x3", &Quaternion::CreateFromMatrix3x3)-> Method("CreateFromMatrix4x4", &Quaternion::CreateFromMatrix4x4)-> Method("CreateFromAxisAngle", &Quaternion::CreateFromAxisAngle)-> - Method("CreateShortestArc", &Quaternion::CreateShortestArc) + Method("CreateShortestArc", &Quaternion::CreateShortestArc)-> + Method("CreateFromEulerAnglesDegrees", &Quaternion::CreateFromEulerAnglesDegrees) ; } } diff --git a/Code/Framework/AzCore/AzCore/Math/Transform.cpp b/Code/Framework/AzCore/AzCore/Math/Transform.cpp index 77d8658d0f..bb3f764492 100644 --- a/Code/Framework/AzCore/AzCore/Math/Transform.cpp +++ b/Code/Framework/AzCore/AzCore/Math/Transform.cpp @@ -250,6 +250,7 @@ namespace AZ Attribute(Script::Attributes::ExcludeFrom, Script::Attributes::ExcludeFlags::All)-> Attribute(Script::Attributes::Storage, Script::Attributes::StorageType::Value)-> Attribute(Script::Attributes::GenericConstructorOverride, &Internal::TransformDefaultConstructor)-> + Constructor()-> Method("GetBasis", &Transform::GetBasis)-> Method("GetBasisX", &Transform::GetBasisX)-> Method("GetBasisY", &Transform::GetBasisY)-> diff --git a/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.cpp b/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.cpp index 52085757fe..27f6f222dd 100644 --- a/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.cpp +++ b/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.cpp @@ -506,6 +506,7 @@ namespace AZ::SettingsRegistryMergeUtils void MergeSettingsToRegistry_AddRuntimeFilePaths(SettingsRegistryInterface& registry) { + using FixedValueString = AZ::SettingsRegistryInterface::FixedValueString; // Binary folder AZ::IO::FixedMaxPath path = AZ::Utils::GetExecutableDirectory(); registry.Set(FilePathKey_BinaryFolder, path.LexicallyNormal().Native()); @@ -514,28 +515,25 @@ namespace AZ::SettingsRegistryMergeUtils AZ::IO::FixedMaxPath engineRoot = FindEngineRoot(registry); registry.Set(FilePathKey_EngineRootFolder, engineRoot.LexicallyNormal().Native()); - constexpr size_t bufferSize = 64; - auto buffer = AZStd::fixed_string::format("%s/project_path", BootstrapSettingsRootKey); - - AZ::SettingsRegistryInterface::FixedValueString projectPathKey(buffer); + auto projectPathKey = FixedValueString::format("%s/project_path", BootstrapSettingsRootKey); SettingsRegistryInterface::FixedValueString projectPathValue; if (registry.Get(projectPathValue, projectPathKey)) { // Cache folder // Get the name of the asset platform assigned by the bootstrap. First check for platform version such as "windows_assets" // and if that's missing just get "assets". - constexpr char platformName[] = AZ_TRAIT_OS_PLATFORM_CODENAME_LOWER; - - buffer = AZStd::fixed_string::format("%s/%s_assets", BootstrapSettingsRootKey, platformName); - AZStd::string_view assetPlatformKey(buffer); - // Use the platform codename to retrieve the default asset platform value - SettingsRegistryInterface::FixedValueString assetPlatform = AZ::OSPlatformToDefaultAssetPlatform(AZ_TRAIT_OS_PLATFORM_CODENAME); - if (!registry.Get(assetPlatform, assetPlatformKey)) + FixedValueString assetPlatform; + if (auto assetPlatformKey = FixedValueString::format("%s/%s_assets", BootstrapSettingsRootKey, AZ_TRAIT_OS_PLATFORM_CODENAME_LOWER); + !registry.Get(assetPlatform, assetPlatformKey)) { - buffer = AZStd::fixed_string::format("%s/assets", BootstrapSettingsRootKey); - assetPlatformKey = AZStd::string_view(buffer); + assetPlatformKey = FixedValueString::format("%s/assets", BootstrapSettingsRootKey); registry.Get(assetPlatform, assetPlatformKey); } + if (assetPlatform.empty()) + { + // Use the platform codename to retrieve the default asset platform value + assetPlatform = AZ::OSPlatformToDefaultAssetPlatform(AZ_TRAIT_OS_PLATFORM_CODENAME); + } // Project path - corresponds to the @devassets@ alias // NOTE: Here we append to engineRoot, but if projectPathValue is absolute then engineRoot is discarded. @@ -575,8 +573,7 @@ namespace AZ::SettingsRegistryMergeUtils { // Cache: project root - no corresponding fileIO alias, but this is where the asset database lives. // A registry override is accepted using the "project_cache_path" key. - buffer = AZStd::fixed_string::format("%s/project_cache_path", BootstrapSettingsRootKey); - AZStd::string_view projectCacheRootOverrideKey(buffer); + auto projectCacheRootOverrideKey = FixedValueString::format("%s/project_cache_path", BootstrapSettingsRootKey); // Clear path to make sure that the `project_cache_path` value isn't concatenated to the project path path.clear(); if (registry.Get(path.Native(), projectCacheRootOverrideKey)) diff --git a/Code/Framework/AzCore/CMakeLists.txt b/Code/Framework/AzCore/CMakeLists.txt index c77205a760..db2c79f0c9 100644 --- a/Code/Framework/AzCore/CMakeLists.txt +++ b/Code/Framework/AzCore/CMakeLists.txt @@ -40,14 +40,13 @@ ly_add_target( ${common_dir} ${AZ_CORE_RADTELEMETRY_INCLUDE_DIRECTORIES} BUILD_DEPENDENCIES - PRIVATE - 3rdParty::zlib - 3rdParty::zstd - 3rdParty::cityhash PUBLIC 3rdParty::Lua 3rdParty::RapidJSON 3rdParty::RapidXML + 3rdParty::zlib + 3rdParty::zstd + 3rdParty::cityhash ${AZ_CORE_RADTELEMETRY_BUILD_DEPENDENCIES} ) ly_add_source_properties( diff --git a/Code/Framework/AzFramework/CMakeLists.txt b/Code/Framework/AzFramework/CMakeLists.txt index f62f205efd..50e1fcb5a4 100644 --- a/Code/Framework/AzFramework/CMakeLists.txt +++ b/Code/Framework/AzFramework/CMakeLists.txt @@ -33,12 +33,12 @@ ly_add_target( BUILD_DEPENDENCIES PRIVATE AZ::AzCore + PUBLIC + AZ::GridMate 3rdParty::md5 3rdParty::zlib 3rdParty::zstd 3rdParty::lz4 - PUBLIC - AZ::GridMate ) if(LY_ENABLE_STATISTICAL_PROFILING) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/SearchWidget.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/SearchWidget.cpp index 7c2f26042f..d2edbcce32 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/SearchWidget.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/SearchWidget.cpp @@ -170,6 +170,15 @@ namespace AzToolsFramework return m_filter; } + QSharedPointer SearchWidget::GetStringFilter() const + { + return m_stringFilter; + } + + QSharedPointer SearchWidget::GetTypesFilter() const + { + return m_typesFilter; + } } // namespace AssetBrowser } // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/SearchWidget.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/SearchWidget.h index 0453333c94..be649bc81d 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/SearchWidget.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/SearchWidget.h @@ -39,6 +39,10 @@ namespace AzToolsFramework QSharedPointer GetFilter() const; + QSharedPointer GetStringFilter() const; + + QSharedPointer GetTypesFilter() const; + QString GetFilterString() const { return textFilter(); } void ClearStringFilter() { ClearTextFilter(); } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.cpp index 6ab3625dd2..629dcd639d 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.cpp @@ -136,6 +136,48 @@ namespace AzToolsFramework return entity->GetName(); } + EntityList EntityIdListToEntityList(const EntityIdList& inputEntityIds) + { + EntityList entities; + entities.reserve(inputEntityIds.size()); + + for (AZ::EntityId entityId : inputEntityIds) + { + if (!entityId.IsValid()) + { + continue; + } + + if (auto entity = GetEntityById(entityId)) + { + entities.emplace_back(entity); + } + } + + return entities; + } + + EntityList EntityIdSetToEntityList(const EntityIdSet& inputEntityIds) + { + EntityList entities; + entities.reserve(inputEntityIds.size()); + + for (AZ::EntityId entityId : inputEntityIds) + { + if (!entityId.IsValid()) + { + continue; + } + + if (auto entity = GetEntityById(entityId)) + { + entities.emplace_back(entity); + } + } + + return entities; + } + void GetAllComponentsForEntity(const AZ::Entity* entity, AZ::Entity::ComponentArrayType& componentsOnEntity) { if (entity) @@ -1068,6 +1110,45 @@ namespace AzToolsFramework return !allEntityClonesContainer.m_entities.empty(); } + EntityIdSet GetCulledEntityHierarchy(const EntityIdList& entities) + { + EntityIdSet culledEntities; + + for (const AZ::EntityId& entityId : entities) + { + bool selectionIncludesTransformHeritage = false; + AZ::EntityId parentEntityId = entityId; + do + { + AZ::EntityId nextParentId; + AZ::TransformBus::EventResult( + /*result*/ nextParentId, + /*address*/ parentEntityId, + &AZ::TransformBus::Events::GetParentId); + parentEntityId = nextParentId; + if (!parentEntityId.IsValid()) + { + break; + } + for (const AZ::EntityId& parentCheck : entities) + { + if (parentCheck == parentEntityId) + { + selectionIncludesTransformHeritage = true; + break; + } + } + } while (parentEntityId.IsValid() && !selectionIncludesTransformHeritage); + + if (!selectionIncludesTransformHeritage) + { + culledEntities.insert(entityId); + } + } + + return culledEntities; + } + namespace Internal { void CloneSliceEntitiesAndChildren( diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.h index 39f4c37c29..5454b19f7a 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.h @@ -47,6 +47,9 @@ namespace AzToolsFramework AZStd::string GetEntityName(const AZ::EntityId& entityId, const AZStd::string_view& nameOverride = {}); + EntityList EntityIdListToEntityList(const EntityIdList& inputEntityIds); + EntityList EntityIdSetToEntityList(const EntityIdSet& inputEntityIds); + template struct AddComponents { @@ -202,4 +205,8 @@ namespace AzToolsFramework /// Wrap EBus SetSelectedEntities call. void SelectEntities(const AzToolsFramework::EntityIdList& entities); + /// Return a set of entities, culling any that have an ancestor in the list. + /// e.g. This is useful for getting a concise set of entities that need to be duplicated. + EntityIdSet GetCulledEntityHierarchy(const EntityIdList& entities); + }; // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp index 4b23b46ffd..cb16e0c099 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp @@ -94,6 +94,7 @@ namespace AzToolsFramework m_prefabSystemComponent->RemoveTemplate(templateId); } m_rootInstance->Reset(); + m_rootInstance->SetContainerEntityName("Level"); AzFramework::EntityOwnershipServiceNotificationBus::Event( m_entityContextId, &AzFramework::EntityOwnershipServiceNotificationBus::Events::OnEntityOwnershipServiceReset); @@ -198,6 +199,7 @@ namespace AzToolsFramework m_rootInstance->SetTemplateId(templateId); m_rootInstance->SetTemplateSourcePath(m_loaderInterface->GetRelativePathToProject(filename)); + m_rootInstance->SetContainerEntityName("Level"); m_prefabSystemComponent->PropagateTemplateChanges(templateId); return true; @@ -279,18 +281,29 @@ namespace AzToolsFramework AZStd::unique_ptr createdPrefabInstance = m_prefabSystemComponent->CreatePrefab(entities, AZStd::move(nestedPrefabInstances), filePath); - if (!instanceToParentUnder) - { - instanceToParentUnder = *m_rootInstance; - } - if (createdPrefabInstance) { + if (!instanceToParentUnder) + { + instanceToParentUnder = *m_rootInstance; + } + Prefab::Instance& addedInstance = instanceToParentUnder->get().AddInstance(AZStd::move(createdPrefabInstance)); - HandleEntitiesAdded({addedInstance.m_containerEntity.get()}); + AZ::Entity* containerEntity = addedInstance.m_containerEntity.get(); + containerEntity->AddComponent(aznew Prefab::EditorPrefabComponent()); + HandleEntitiesAdded({containerEntity}); + HandleEntitiesAdded(entities); + + // Update the template of the instance since we modified the entities of the instance by calling HandleEntitiesAdded. + Prefab::PrefabDom serializedInstance; + if (Prefab::PrefabDomUtils::StoreInstanceInPrefabDom(addedInstance, serializedInstance)) + { + m_prefabSystemComponent->UpdatePrefabTemplate(addedInstance.GetTemplateId(), serializedInstance); + } + return addedInstance; } - HandleEntitiesAdded(entities); + return AZStd::nullopt; } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.h index ad11547506..36a60cc501 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.h @@ -186,7 +186,7 @@ namespace AzToolsFramework PlayInEditorData m_playInEditorData; ////////////////////////////////////////////////////////////////////////// - // PrefabSystemComponentInterface interface implementation + // PrefabEditorEntityOwnershipInterface implementation Prefab::InstanceOptionalReference CreatePrefab( const AZStd::vector& entities, AZStd::vector>&& nestedPrefabInstances, AZ::IO::PathView filePath, Prefab::InstanceOptionalReference instanceToParentUnder) override; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp index 0a5b43482e..c1eee62dbc 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp @@ -123,7 +123,11 @@ namespace AzToolsFramework void Instance::SetTemplateSourcePath(AZ::IO::PathView sourcePath) { m_templateSourcePath = sourcePath; - m_containerEntity->SetName(sourcePath.Filename().Native()); + } + + void Instance::SetContainerEntityName(AZStd::string_view containerName) + { + m_containerEntity->SetName(containerName); } bool Instance::AddEntity(AZ::Entity& entity) @@ -563,7 +567,7 @@ namespace AzToolsFramework AZ::EntityId Instance::GetContainerEntityId() const { - return m_containerEntity->GetId(); + return m_containerEntity ? m_containerEntity->GetId() : AZ::EntityId(); } bool Instance::HasContainerEntity() const diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.h index d1c7a4d853..186dce0f50 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.h @@ -80,6 +80,7 @@ namespace AzToolsFramework const AZ::IO::Path& GetTemplateSourcePath() const; void SetTemplateSourcePath(AZ::IO::PathView sourcePath); + void SetContainerEntityName(AZStd::string_view containerName); bool AddEntity(AZ::Entity& entity); bool AddEntity(AZ::Entity& entity, EntityAlias entityAlias); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/InstanceUpdateExecutor.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/InstanceUpdateExecutor.cpp index 65de6b713c..71b1e04ec8 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/InstanceUpdateExecutor.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/InstanceUpdateExecutor.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -116,10 +117,24 @@ namespace AzToolsFramework "Could not find Template using Id '%llu'. Unable to update Instance.", currentTemplateId); + // Remove the instance from update queue if its corresponding template couldn't be found isUpdateSuccessful = false; + m_instancesUpdateQueue.pop(); + continue; } } + auto findInstancesResult = m_templateInstanceMapperInterface->FindInstancesOwnedByTemplate(instanceTemplateId)->get(); + + if (findInstancesResult.find(instanceToUpdate) == findInstancesResult.end()) + { + // Since nested instances get reconstructed during propagation, remove any nested instance that no longer + // maps to a template. + isUpdateSuccessful = false; + m_instancesUpdateQueue.pop(); + continue; + } + Template& currentTemplate = currentTemplateReference->get(); Instance::EntityList newEntities; if (PrefabDomUtils::LoadInstanceFromPrefabDom(*instanceToUpdate, newEntities, currentTemplate.GetPrefabDom())) @@ -139,9 +154,18 @@ namespace AzToolsFramework } m_instancesUpdateQueue.pop(); - } + for (auto entityIdIterator = selectedEntityIds.begin(); entityIdIterator != selectedEntityIds.end(); entityIdIterator++) + { + // Since entities get recreated during propagation, we need to check whether the entities correspoding to the list + // of selected entity ids are present or not. + AZ::Entity* entity = GetEntityById(*entityIdIterator); + if (entity == nullptr) + { + selectedEntityIds.erase(entityIdIterator--); + } + } ToolsApplicationRequestBus::Broadcast(&ToolsApplicationRequests::SetSelectedEntities, selectedEntityIds); // Enable the Outliner diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp index 26191c97af..772e0ae52e 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp @@ -15,15 +15,16 @@ #include #include +#include #include #include #include #include -#include #include #include #include #include +#include #include #include #include @@ -37,12 +38,14 @@ namespace AzToolsFramework void PrefabPublicHandler::RegisterPrefabPublicHandlerInterface() { m_instanceEntityMapperInterface = AZ::Interface::Get(); - AZ_Assert( - m_instanceEntityMapperInterface, "PrefabPublicHandler - Could not retrieve instance of InstanceEntityMapperInterface"); + AZ_Assert(m_instanceEntityMapperInterface, "PrefabPublicHandler - Could not retrieve instance of InstanceEntityMapperInterface"); m_instanceToTemplateInterface = AZ::Interface::Get(); AZ_Assert(m_instanceToTemplateInterface, "PrefabPublicHandler - Could not retrieve instance of InstanceToTemplateInterface"); + m_prefabLoaderInterface = AZ::Interface::Get(); + AZ_Assert(m_prefabLoaderInterface, "Could not get PrefabLoaderInterface on PrefabPublicHandler construction."); + m_prefabSystemComponentInterface = AZ::Interface::Get(); AZ_Assert(m_prefabSystemComponentInterface, "Could not get PrefabSystemComponentInterface on PrefabPublicHandler construction."); @@ -59,92 +62,160 @@ namespace AzToolsFramework } PrefabOperationResult PrefabPublicHandler::CreatePrefab(const AZStd::vector& entityIds, AZ::IO::PathView filePath) + { + EntityList inputEntityList, topLevelEntities; + AZ::EntityId commonRootEntityId; + InstanceOptionalReference commonRootEntityOwningInstance; + PrefabOperationResult findCommonRootOutcome = FindCommonRootOwningInstance( + entityIds, inputEntityList, topLevelEntities, commonRootEntityId, commonRootEntityOwningInstance); + if (!findCommonRootOutcome.IsSuccess()) + { + return findCommonRootOutcome; + } + + InstanceOptionalReference instanceToCreate; + { + // Initialize Undo Batch object + ScopedUndoBatch undoBatch("Create Prefab"); + + PrefabDom commonRootInstanceDomBeforeCreate; + m_instanceToTemplateInterface->GenerateDomForInstance( + commonRootInstanceDomBeforeCreate, commonRootEntityOwningInstance->get()); + + AZStd::vector entities; + AZStd::vector> instances; + + // Retrieve all entities affected and identify Instances + if (!RetrieveAndSortPrefabEntitiesAndInstances(inputEntityList, commonRootEntityOwningInstance->get(), entities, instances)) + { + return AZ::Failure( + AZStd::string("Could not create a new prefab out of the entities provided - entities do not share a common root.")); + } + + // When we create a prefab with other prefab instances, we have to remove the existing links between the source and + // target templates of the other instances. + for (auto& nestedInstance : instances) + { + PrefabUndoHelpers::RemoveLink( + nestedInstance->GetTemplateId(), commonRootEntityOwningInstance->get().GetTemplateId(), + nestedInstance->GetInstanceAlias(), nestedInstance->GetLinkId(), undoBatch.GetUndoBatch()); + } + + auto prefabEditorEntityOwnershipInterface = AZ::Interface::Get(); + if (!prefabEditorEntityOwnershipInterface) + { + return AZ::Failure(AZStd::string("Could not create a new prefab out of the entities provided - internal error " + "(PrefabEditorEntityOwnershipInterface unavailable).")); + } + + // Create the Prefab + instanceToCreate = prefabEditorEntityOwnershipInterface->CreatePrefab( + entities, AZStd::move(instances), filePath, commonRootEntityOwningInstance); + + if (!instanceToCreate) + { + return AZ::Failure(AZStd::string("Could not create a new prefab out of the entities provided - internal error " + "(A null instance is returned).")); + } + + PrefabUndoHelpers::UpdatePrefabInstance( + commonRootEntityOwningInstance->get(), "Update prefab instance", commonRootInstanceDomBeforeCreate, undoBatch.GetUndoBatch()); + + CreateLink( + topLevelEntities, instanceToCreate->get(), commonRootEntityOwningInstance->get().GetTemplateId(), undoBatch.GetUndoBatch(), + commonRootEntityId); + AZ::EntityId containerEntityId = instanceToCreate->get().GetContainerEntityId(); + + // Change top level entities to be parented to the container entity + // Mark them as dirty so this change is correctly applied to the template + for (AZ::Entity* topLevelEntity : topLevelEntities) + { + m_prefabUndoCache.UpdateCache(topLevelEntity->GetId()); + undoBatch.MarkEntityDirty(topLevelEntity->GetId()); + AZ::TransformBus::Event(topLevelEntity->GetId(), &AZ::TransformBus::Events::SetParent, containerEntityId); + } + + // Select Container Entity + { + auto selectionUndo = aznew SelectionCommand({containerEntityId}, "Select Prefab Container Entity"); + selectionUndo->SetParent(undoBatch.GetUndoBatch()); + ToolsApplicationRequestBus::Broadcast(&ToolsApplicationRequestBus::Events::RunRedoSeparately, selectionUndo); + } + } + + // Save Template to file + m_prefabLoaderInterface->SaveTemplate(instanceToCreate->get().GetTemplateId()); + + return AZ::Success(); + } + + PrefabOperationResult PrefabPublicHandler::FindCommonRootOwningInstance( + const AZStd::vector& entityIds, EntityList& inputEntityList, EntityList& topLevelEntities, + AZ::EntityId& commonRootEntityId, InstanceOptionalReference& commonRootEntityOwningInstance) { // Retrieve entityList from entityIds - EntityList inputEntityList; - EntityIdListToEntityList(entityIds, inputEntityList); + inputEntityList = EntityIdListToEntityList(entityIds); // Find common root and top level entities bool entitiesHaveCommonRoot = false; - AZ::EntityId commonRootEntityId; - EntityList topLevelEntities; AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult( - entitiesHaveCommonRoot, - &AzToolsFramework::ToolsApplicationRequests::FindCommonRootInactive, - inputEntityList, - commonRootEntityId, - &topLevelEntities - ); + entitiesHaveCommonRoot, &AzToolsFramework::ToolsApplicationRequests::FindCommonRootInactive, inputEntityList, + commonRootEntityId, &topLevelEntities); // Bail if entities don't share a common root if (!entitiesHaveCommonRoot) { - return AZ::Failure(AZStd::string("Could not create a new prefab out of the entities provided - entities do not share a common root.")); - } - - AZ::Entity* commonRootEntity = nullptr; - if (commonRootEntityId.IsValid()) - { - commonRootEntity = GetEntityById(commonRootEntityId); + return AZ::Failure(AZStd::string("Failed to create a prefab: Provided entities do not share a common root.")); } // Retrieve the owning instance of the common root entity, which will be our new instance's parent instance. - InstanceOptionalReference commonRootEntityOwningInstance = GetOwnerInstanceByEntityId(commonRootEntityId); - AZ_Assert(commonRootEntityOwningInstance.has_value(), "Failed to create prefab : " - "Couldn't get a valid owning instance for the common root entity of the enities provided"); - - AZStd::vector entities; - AZStd::vector> instances; - - // Retrieve all entities affected and identify Instances - if (!RetrieveAndSortPrefabEntitiesAndInstances(inputEntityList, commonRootEntityOwningInstance->get(), entities, instances)) + commonRootEntityOwningInstance = GetOwnerInstanceByEntityId(commonRootEntityId); + if (!commonRootEntityOwningInstance) { - return AZ::Failure(AZStd::string("Could not create a new prefab out of the entities provided - entities do not share a common root.")); + AZ_Assert( + false, + "Failed to create prefab : Couldn't get a valid owning instance for the common root entity of the enities provided"); + return AZ::Failure(AZStd::string( + "Failed to create prefab : Couldn't get a valid owning instance for the common root entity of the enities provided")); } + return AZ::Success(); + } - auto prefabEditorEntityOwnershipInterface = AZ::Interface::Get(); - if (!prefabEditorEntityOwnershipInterface) - { - return AZ::Failure(AZStd::string("Could not create a new prefab out of the entities provided - internal error " - "(PrefabEditorEntityOwnershipInterface unavailable).")); - } + void PrefabPublicHandler::CreateLink( + const EntityList& topLevelEntities, Instance& sourceInstance, TemplateId targetTemplateId, + UndoSystem::URSequencePoint* undoBatch, AZ::EntityId commonRootEntityId) + { + AZ::EntityId containerEntityId = sourceInstance.GetContainerEntityId(); + AZ::Entity* containerEntity = GetEntityById(containerEntityId); + Prefab::PrefabDom containerEntityDomBefore; + m_instanceToTemplateInterface->GenerateDomForEntity(containerEntityDomBefore, *containerEntity); - InstanceOptionalReference instance = prefabEditorEntityOwnershipInterface->CreatePrefab( - entities, AZStd::move(instances), filePath, commonRootEntityOwningInstance); - - if (!instance) - { - return AZ::Failure(AZStd::string("Could not create a new prefab out of the entities provided - internal error " - "(A null instance is returned).")); - } - - AZ::EntityId containerEntityId = instance->get().GetContainerEntityId(); AZ::Vector3 containerEntityTranslation(AZ::Vector3::CreateZero()); AZ::Quaternion containerEntityRotation(AZ::Quaternion::CreateZero()); // Set the transform (translation, rotation) of the container entity GenerateContainerEntityTransform(topLevelEntities, containerEntityTranslation, containerEntityRotation); + // Set container entity to be child of common root + AZ::TransformBus::Event(containerEntityId, &AZ::TransformBus::Events::SetParent, commonRootEntityId); + AZ::TransformBus::Event(containerEntityId, &AZ::TransformBus::Events::SetLocalTranslation, containerEntityTranslation); AZ::TransformBus::Event(containerEntityId, &AZ::TransformBus::Events::SetLocalRotationQuaternion, containerEntityRotation); - // Set container entity to be child of common root - AZ::TransformBus::Event(containerEntityId, &AZ::TransformBus::Events::SetParent, commonRootEntityId); - - // Assign the EditorPrefabComponent to the instance container - EntityCompositionRequests::AddComponentsOutcome outcome; - EntityCompositionRequestBus::BroadcastResult( - outcome, &EntityCompositionRequests::AddComponentsToEntities, EntityIdList{containerEntityId}, - AZ::ComponentTypeList{azrtti_typeid()}); - - // Change top level entities to be parented to the container entity - for (AZ::Entity* topLevelEntity : topLevelEntities) - { - AZ::TransformBus::Event(topLevelEntity->GetId(), &AZ::TransformBus::Events::SetParent, containerEntityId); - } - - return AZ::Success(); + PrefabDom containerEntityDomAfter; + m_instanceToTemplateInterface->GenerateDomForEntity(containerEntityDomAfter, *containerEntity); + + PrefabDom patch; + m_instanceToTemplateInterface->GeneratePatch(patch, containerEntityDomBefore, containerEntityDomAfter); + m_instanceToTemplateInterface->AppendEntityAliasToPatchPaths(patch, containerEntityId); + + PrefabUndoHelpers::CreateLink( + sourceInstance.GetTemplateId(), targetTemplateId, patch, sourceInstance.GetInstanceAlias(), + undoBatch); + + // Update the cache - this prevents these changes from being stored in the regular undo/redo nodes + m_prefabUndoCache.Store(containerEntityId, AZStd::move(containerEntityDomAfter)); } PrefabOperationResult PrefabPublicHandler::InstantiatePrefab(AZStd::string_view /*filePath*/, AZ::EntityId /*parent*/, AZ::Vector3 /*position*/) @@ -174,14 +245,7 @@ namespace AzToolsFramework AZStd::string("SavePrefab - Path error. Path could be invalid, or the prefab may not be loaded in this level.")); } - auto prefabLoaderInterface = AZ::Interface::Get(); - if (prefabLoaderInterface == nullptr) - { - return AZ::Failure(AZStd::string( - "Could not save prefab - internal error (PrefabLoaderInterface unavailable).")); - } - - if (!prefabLoaderInterface->SaveTemplate(templateId)) + if (!m_prefabLoaderInterface->SaveTemplate(templateId)) { return AZ::Failure(AZStd::string("Could not save prefab - internal error (Json write operation failure).")); } @@ -262,13 +326,13 @@ namespace AzToolsFramework if (instanceOptionalReference.has_value()) { - PrefabDom beforeState; - m_prefabUndoCache.Retrieve(entityId, beforeState); - PrefabDom afterState; AZ::Entity* entity = GetEntityById(entityId); if (entity) { + PrefabDom beforeState; + m_prefabUndoCache.Retrieve(entityId, beforeState); + m_instanceToTemplateInterface->GenerateDomForEntity(afterState, *entity); PrefabDom patch; @@ -287,7 +351,10 @@ namespace AzToolsFramework // Update the cache m_prefabUndoCache.Store(entityId, AZStd::move(afterState)); } - + else + { + m_prefabUndoCache.PurgeCache(entityId); + } } } @@ -419,8 +486,7 @@ namespace AzToolsFramework InstanceOptionalReference instance = GetOwnerInstanceByEntityId(entityIds[0]); // Retrieve entityList from entityIds - EntityList inputEntityList; - EntityIdListToEntityList(entityIds, inputEntityList); + EntityList inputEntityList = EntityIdListToEntityList(entityIds); AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework); @@ -655,7 +721,7 @@ namespace AzToolsFramework InstanceOptionalReference owningInstance = m_instanceEntityMapperInterface->FindOwningInstance(entity->GetId()); AZ_Assert( owningInstance.has_value(), - "An error occored while retrieving entities and prefab instances : " + "An error occurred while retrieving entities and prefab instances : " "Owning instance of entity with id '%llu' couldn't be found", entity->GetId()); @@ -739,7 +805,7 @@ namespace AzToolsFramework { AZ_Assert( false, - "An error occored in function EntitiesBelongToSameInstance: " + "An error occurred in function EntitiesBelongToSameInstance: " "Owning instance of entity with id '%llu' couldn't be found", entityId); return false; @@ -767,18 +833,5 @@ namespace AzToolsFramework return true; } - - void PrefabPublicHandler::EntityIdListToEntityList(const EntityIdList& inputEntityIds, EntityList& outEntities) - { - outEntities.reserve(inputEntityIds.size()); - - for (AZ::EntityId entityId : inputEntityIds) - { - if (entityId.IsValid()) - { - outEntities.emplace_back(GetEntityById(entityId)); - } - } - } } } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.h index 80f28d7edb..19985bbf51 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.h @@ -27,8 +27,10 @@ namespace AzToolsFramework namespace Prefab { class Instance; + class InstanceEntityMapperInterface; class InstanceToTemplateInterface; + class PrefabLoaderInterface; class PrefabSystemComponentInterface; class PrefabPublicHandler final @@ -67,13 +69,40 @@ namespace AzToolsFramework InstanceOptionalReference GetOwnerInstanceByEntityId(AZ::EntityId entityId) const; bool EntitiesBelongToSameInstance(const EntityIdList& entityIds) const; + /** + * Creates a link between the templates of an instance and its parent. + * + * \param topLevelEntities The list of entities that are immediate children to the container entity of the instance. + * \param sourceInstance The instance that corresponds to the source template of the link. + * \param targetInstance The id of the target template. + * \param undoBatch The undo batch to set as parent for this create link action. + * \param commonRootEntityId The id of the entity that the source instance should be parented under. + */ + void CreateLink( + const EntityList& topLevelEntities, Instance& sourceInstance, TemplateId targetTemplateId, + UndoSystem::URSequencePoint* undoBatch, AZ::EntityId commonRootEntityId); + + /** + * Given a list of entityIds, finds the prefab instance that owns the common root entity of the entityIds. + * + * \param entityIds The list of entity ids. + * \param inputEntityList The list of entities corresponding to the entity ids. + * \param topLevelEntities The list of entities that are immediate children of the common root entity. + * \param commonRootEntityId The entity id of the common root entity of all the entityIds. + * \param commonRootEntityOwningInstance The owning instance of the common root entity. + * \return PrefabOperationResult indicating whether the action was successful or not. + */ + PrefabOperationResult FindCommonRootOwningInstance( + const AZStd::vector& entityIds, EntityList& inputEntityList, EntityList& topLevelEntities, + AZ::EntityId& commonRootEntityId, InstanceOptionalReference& commonRootEntityOwningInstance); + static Instance* GetParentInstance(Instance* instance); static Instance* GetAncestorOfInstanceThatIsChildOfRoot(const Instance* ancestor, Instance* descendant); static void GenerateContainerEntityTransform(const EntityList& topLevelEntities, AZ::Vector3& translation, AZ::Quaternion& rotation); - static void EntityIdListToEntityList(const EntityIdList& inputEntityIds, EntityList& outEntities); InstanceEntityMapperInterface* m_instanceEntityMapperInterface = nullptr; InstanceToTemplateInterface* m_instanceToTemplateInterface = nullptr; + PrefabLoaderInterface* m_prefabLoaderInterface = nullptr; PrefabSystemComponentInterface* m_prefabSystemComponentInterface = nullptr; // Caches entity states for undo/redo purposes diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.cpp index bf9fd658c6..54e99c9416 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.cpp @@ -104,7 +104,6 @@ namespace AzToolsFramework return nullptr; } - AZStd::unique_ptr newInstance = AZStd::make_unique(AZStd::move(containerEntity)); for (AZ::Entity* entity : entities) @@ -122,6 +121,7 @@ namespace AzToolsFramework } newInstance->SetTemplateSourcePath(relativeFilePath); + newInstance->SetContainerEntityName(relativeFilePath.Stem().Native()); TemplateId newTemplateId = CreateTemplateFromInstance(*newInstance); if (newTemplateId == InvalidTemplateId) @@ -142,7 +142,6 @@ namespace AzToolsFramework void PrefabSystemComponent::PropagateTemplateChanges(TemplateId templateId) { - UpdatePrefabInstances(templateId); auto templateIdToLinkIdsIterator = m_templateToLinkIdsMap.find(templateId); if (templateIdToLinkIdsIterator != m_templateToLinkIdsMap.end()) { @@ -153,15 +152,24 @@ namespace AzToolsFramework templateIdToLinkIdsIterator->second.end())); UpdateLinkedInstances(linkIdsToUpdateQueue); } + else + { + UpdatePrefabInstances(templateId); + } } void PrefabSystemComponent::UpdatePrefabTemplate(TemplateId templateId, const PrefabDom& updatedDom) { - PrefabDom& templateDomToUpdate = FindTemplateDom(templateId); - if (AZ::JsonSerialization::Compare(templateDomToUpdate, updatedDom) != AZ::JsonSerializerCompareResult::Equal) + auto templateToUpdate = FindTemplate(templateId); + if (templateToUpdate) { - templateDomToUpdate.CopyFrom(updatedDom, templateDomToUpdate.GetAllocator()); - PropagateTemplateChanges(templateId); + PrefabDom& templateDomToUpdate = templateToUpdate->get().GetPrefabDom(); + if (AZ::JsonSerialization::Compare(templateDomToUpdate, updatedDom) != AZ::JsonSerializerCompareResult::Equal) + { + templateDomToUpdate.CopyFrom(updatedDom, templateDomToUpdate.GetAllocator()); + templateToUpdate->get().MarkAsDirty(true); + PropagateTemplateChanges(templateId); + } } } @@ -615,7 +623,12 @@ namespace AzToolsFramework instancesValue = memberFound->value; } - instancesValue->get().AddMember(rapidjson::StringRef(instanceAlias.c_str()), PrefabDomValue(), targetTemplateDom.GetAllocator()); + // Only add the instance if it's not there already + if (instancesValue->get().FindMember(rapidjson::StringRef(instanceAlias.c_str())) == instancesValue->get().MemberEnd()) + { + instancesValue->get().AddMember( + rapidjson::StringRef(instanceAlias.c_str()), PrefabDomValue(), targetTemplateDom.GetAllocator()); + } Template& sourceTemplate = sourceTemplateRef->get(); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndo.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndo.cpp index 0d9f9f72a5..ea3fa5d84d 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndo.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndo.cpp @@ -124,7 +124,7 @@ namespace AzToolsFramework const TemplateId& targetId, const TemplateId& sourceId, const InstanceAlias& instanceAlias, - const PrefabDomReference linkDom, + PrefabDomReference linkDom, const LinkId linkId) { m_targetId = targetId; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndo.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndo.h index 7a765c5db7..0d15d707d2 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndo.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndo.h @@ -101,7 +101,7 @@ namespace AzToolsFramework const TemplateId& targetId, const TemplateId& sourceId, const InstanceAlias& instanceAlias, - const PrefabDomReference linkDom = PrefabDomReference(), + PrefabDomReference linkDom = PrefabDomReference(), const LinkId linkId = InvalidLinkId); void Undo() override; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndoHelpers.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndoHelpers.cpp index da41635d03..c9b6c88a97 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndoHelpers.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndoHelpers.cpp @@ -32,6 +32,28 @@ namespace AzToolsFramework state->SetParent(undoBatch); state->Redo(); } + + void CreateLink( + TemplateId sourceTemplateId, TemplateId targetTemplateId, PrefabDomReference patch, + const InstanceAlias& instanceAlias, UndoSystem::URSequencePoint* undoBatch) + { + auto linkAddUndo = aznew PrefabUndoInstanceLink("Create Link"); + linkAddUndo->Capture(targetTemplateId, sourceTemplateId, instanceAlias, patch, InvalidLinkId); + linkAddUndo->SetParent(undoBatch); + linkAddUndo->Redo(); + } + + void RemoveLink( + TemplateId sourceTemplateId, TemplateId targetTemplateId, const InstanceAlias& instanceAlias, + LinkId linkId, UndoSystem::URSequencePoint* undoBatch) + { + auto linkRemoveUndo = aznew PrefabUndoInstanceLink("Remove Link"); + PrefabDom emptyLinkDom; + linkRemoveUndo->Capture( + targetTemplateId, sourceTemplateId, instanceAlias, emptyLinkDom, linkId); + linkRemoveUndo->SetParent(undoBatch); + linkRemoveUndo->Redo(); + } } } // namespace Prefab } // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndoHelpers.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndoHelpers.h index 81d0048e9e..5f81ef14a8 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndoHelpers.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndoHelpers.h @@ -21,6 +21,12 @@ namespace AzToolsFramework void UpdatePrefabInstance( const Instance& instance, AZStd::string_view undoMessage, const PrefabDom& instanceDomBeforeUpdate, UndoSystem::URSequencePoint* undoBatch); + void CreateLink( + TemplateId sourceTemplateId, TemplateId targetTemplateId, PrefabDomReference patch, + const InstanceAlias& instanceAlias, UndoSystem::URSequencePoint* undoBatch); + void RemoveLink( + TemplateId sourceTemplateId, TemplateId targetTemplateId, const InstanceAlias& instanceAlias, + LinkId linkId, UndoSystem::URSequencePoint* undoBatch); } } // namespace Prefab } // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailWidget.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailWidget.cpp index f2b81fdb98..1aefa6f189 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailWidget.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailWidget.cpp @@ -79,7 +79,9 @@ namespace AzToolsFramework int realHeight = qMin(aznumeric_cast(originalWidth /aspectRatio), originalHeight); int realWidth = aznumeric_cast(realHeight * aspectRatio); int x = (originalWidth - realWidth) / 2; - painter.drawPixmap(QRect(x, 0, realHeight, realWidth), pixmap); + // pixmap needs to be manually scaled to produce smoother result and avoid looking pixelated + // using painter.setRenderHint(QPainter::SmoothPixmapTransform); does not seem to work + painter.drawPixmap(QPoint(x, 0), pixmap.scaled(realWidth, realHeight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); } QWidget::paintEvent(event); } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.cpp index 98edd26f88..84266d3707 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.cpp @@ -61,6 +61,11 @@ namespace AzToolsFramework return true; } + bool EditorEntityUiHandlerBase::CanRename(AZ::EntityId /*entityId*/) const + { + return true; + } + void EditorEntityUiHandlerBase::PaintItemBackground(QPainter* /*painter*/, const QStyleOptionViewItem& /*option*/, const QModelIndex& /*index*/) const { } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.h b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.h index 7360e7ff0b..1aa5e5720f 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.h @@ -47,6 +47,8 @@ namespace AzToolsFramework virtual QPixmap GenerateItemIcon(AZ::EntityId entityId) const; //! Returns whether the element's lock and visibility state should be accessible in the Outliner virtual bool CanToggleLockVisibility(AZ::EntityId entityId) const; + //! Returns whether the element's name should be editable + virtual bool CanRename(AZ::EntityId entityId) const; //! Paints the background of the item in the Outliner. virtual void PaintItemBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp index ea281aacf7..5b44594398 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp @@ -945,6 +945,12 @@ namespace AzToolsFramework return false; } + // Disable reparenting to the root level + if (!newParentId.IsValid()) + { + return false; + } + // Ignore entities not owned by the editor context. It is assumed that all entities belong // to the same context since multiple selection doesn't span across views. for (const AZ::EntityId& entityId : selectedEntityIds) @@ -974,39 +980,33 @@ namespace AzToolsFramework } } - if (newParentId.IsValid()) + bool isLayerEntity = false; + Layers::EditorLayerComponentRequestBus::EventResult( + isLayerEntity, + entityId, + &Layers::EditorLayerComponentRequestBus::Events::HasLayer); + // Layers can only have other layers as parents, or have no parent. + if (isLayerEntity) { - bool isLayerEntity = false; + bool newParentIsLayer = false; Layers::EditorLayerComponentRequestBus::EventResult( - isLayerEntity, - entityId, + newParentIsLayer, + newParentId, &Layers::EditorLayerComponentRequestBus::Events::HasLayer); - // Layers can only have other layers as parents, or have no parent. - if (isLayerEntity) + if (!newParentIsLayer) { - bool newParentIsLayer = false; - Layers::EditorLayerComponentRequestBus::EventResult( - newParentIsLayer, - newParentId, - &Layers::EditorLayerComponentRequestBus::Events::HasLayer); - if (!newParentIsLayer) - { - return false; - } + return false; } } } //Only check the entity pointer if the entity id is valid because //we want to allow dragging items to unoccupied parts of the tree to un-parent them - if (newParentId.IsValid()) + AZ::Entity* newParentEntity = nullptr; + AZ::ComponentApplicationBus::BroadcastResult(newParentEntity, &AZ::ComponentApplicationRequests::FindEntity, newParentId); + if (!newParentEntity) { - AZ::Entity* newParentEntity = nullptr; - AZ::ComponentApplicationBus::BroadcastResult(newParentEntity, &AZ::ComponentApplicationRequests::FindEntity, newParentId); - if (!newParentEntity) - { - return false; - } + return false; } //reject dragging on to yourself or your children @@ -1344,14 +1344,15 @@ namespace AzToolsFramework emit EnableSelectionUpdates(false); auto parentIndex = GetIndexFromEntity(parentId); auto childIndex = GetIndexFromEntity(childId); - beginRemoveRows(parentIndex, childIndex.row(), childIndex.row()); + beginResetModel(); } void EntityOutlinerListModel::OnEntityInfoUpdatedRemoveChildEnd(AZ::EntityId parentId, AZ::EntityId childId) { (void)childId; AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework); - endRemoveRows(); + + endResetModel(); //must refresh partial lock/visibility of parents m_isFilterDirty = true; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.cpp index 08fc764507..3ee8a14285 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -271,6 +272,12 @@ namespace AzToolsFramework m_listModel->Initialize(); + m_editorEntityUiInterface = AZ::Interface::Get(); + + AZ_Assert( + m_editorEntityUiInterface != nullptr, + "EntityOutlinerWidget requires a EditorEntityUiInterface instance on Initialize."); + EditorPickModeNotificationBus::Handler::BusConnect(GetEntityContextId()); EntityHighlightMessages::Bus::Handler::BusConnect(); EntityOutlinerModelNotificationBus::Handler::BusConnect(); @@ -562,7 +569,13 @@ namespace AzToolsFramework if (m_selectedEntityIds.size() == 1) { - contextMenu->addAction(m_actionToRenameSelection); + auto entityId = m_selectedEntityIds.front(); + auto entityUiHandler = m_editorEntityUiInterface->GetHandler(entityId); + + if (!entityUiHandler || entityUiHandler->CanRename(entityId)) + { + contextMenu->addAction(m_actionToRenameSelection); + } } if (m_selectedEntityIds.size() == 1) @@ -688,11 +701,17 @@ namespace AzToolsFramework if (m_selectedEntityIds.size() == 1) { - const QModelIndex proxyIndex = GetIndexFromEntityId(m_selectedEntityIds.front()); - if (proxyIndex.isValid()) + auto entityId = m_selectedEntityIds.front(); + auto entityUiHandler = m_editorEntityUiInterface->GetHandler(entityId); + + if (!entityUiHandler || entityUiHandler->CanRename(entityId)) { - m_gui->m_objectTree->setCurrentIndex(proxyIndex); - m_gui->m_objectTree->QTreeView::edit(proxyIndex); + const QModelIndex proxyIndex = GetIndexFromEntityId(entityId); + if (proxyIndex.isValid()) + { + m_gui->m_objectTree->setCurrentIndex(proxyIndex); + m_gui->m_objectTree->QTreeView::edit(proxyIndex); + } } } } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.hxx b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.hxx index cf8c55abd1..f225bb49b8 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.hxx +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.hxx @@ -42,6 +42,7 @@ namespace Ui namespace AzToolsFramework { + class EditorEntityUiInterface; class EntityOutlinerListModel; class EntityOutlinerSortFilterProxyModel; @@ -193,6 +194,8 @@ namespace AzToolsFramework EntityIdSet m_entitiesToSort; EntityOutliner::DisplaySortMode m_sortMode; bool m_sortContentQueued; + + EditorEntityUiInterface* m_editorEntityUiInterface = nullptr; }; } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.cpp index 828a49ef94..7915403c0a 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.cpp @@ -50,11 +50,31 @@ namespace AzToolsFramework return QPixmap(m_levelRootIconPath); } + QString LevelRootUiHandler::GenerateItemInfoString(AZ::EntityId entityId) const + { + QString infoString; + + AZ::IO::Path path = m_prefabPublicInterface->GetOwningInstancePrefabPath(entityId); + + if (!path.empty()) + { + infoString = + QObject::tr("(%1)").arg(path.Filename().Native().data()); + } + + return infoString; + } + bool LevelRootUiHandler::CanToggleLockVisibility(AZ::EntityId /*entityId*/) const { return false; } + bool LevelRootUiHandler::CanRename(AZ::EntityId /*entityId*/) const + { + return false; + } + void LevelRootUiHandler::PaintItemBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& /*index*/) const { if (!painter) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.h b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.h index a8b2e4a4f8..19c1244040 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.h @@ -34,7 +34,9 @@ namespace AzToolsFramework // EditorEntityUiHandler... QPixmap GenerateItemIcon(AZ::EntityId entityId) const override; + QString GenerateItemInfoString(AZ::EntityId entityId) const override; bool CanToggleLockVisibility(AZ::EntityId entityId) const override; + bool CanRename(AZ::EntityId entityId) const override; void PaintItemBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; private: diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.cpp index 55c7fb3f65..181f5b9a9d 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.cpp @@ -310,6 +310,9 @@ namespace AzToolsFramework { initEntityPropertyEditorResources(); + m_prefabPublicInterface = AZ::Interface::Get(); + AZ_Assert(m_prefabPublicInterface != nullptr, "EntityPropertyEditor requires a PrefabPublicInterface instance on Initialize."); + setObjectName("EntityPropertyEditor"); setAcceptDrops(true); @@ -405,8 +408,6 @@ namespace AzToolsFramework CreateActions(); UpdateContents(); - m_prefabPublicInterface = AZ::Interface::Get(); - EditorEntityContextNotificationBus::Handler::BusConnect(); //forced to register global event filter with application for selection @@ -693,11 +694,38 @@ namespace AzToolsFramework m_gui->m_entityIcon->repaint(); } + EntityPropertyEditor::InspectorLayout EntityPropertyEditor::GetCurrentInspectorLayout() const + { + if (!m_prefabsAreEnabled) + { + return m_isLevelEntityEditor ? InspectorLayout::LEVEL : InspectorLayout::ENTITY; + } + + AZ::EntityId levelContainerEntityId = m_prefabPublicInterface->GetLevelInstanceContainerEntityId(); + if (AZStd::find(m_selectedEntityIds.begin(), m_selectedEntityIds.end(), levelContainerEntityId) != m_selectedEntityIds.end()) + { + if (m_selectedEntityIds.size() > 1) + { + return InspectorLayout::INVALID; + } + else + { + return InspectorLayout::LEVEL; + } + } + else + { + return InspectorLayout::ENTITY; + } + } + void EntityPropertyEditor::UpdateEntityDisplay() { UpdateStatusComboBox(); - if (m_isLevelEntityEditor) + InspectorLayout layout = GetCurrentInspectorLayout(); + + if (layout == InspectorLayout::LEVEL) { AZStd::string levelName; AzToolsFramework::EditorRequestBus::BroadcastResult(levelName, &AzToolsFramework::EditorRequests::GetLevelName); @@ -737,13 +765,20 @@ namespace AzToolsFramework AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework); SelectionEntityTypeInfo result = SelectionEntityTypeInfo::None; - if (m_isLevelEntityEditor) + InspectorLayout layout = GetCurrentInspectorLayout(); + + if (layout == InspectorLayout::LEVEL) { // The Level Inspector should only have a list of selectable components after the // level entity itself is valid (i.e. "selected"). return selection.empty() ? SelectionEntityTypeInfo::None : SelectionEntityTypeInfo::LevelEntity; } + if (layout == InspectorLayout::INVALID) + { + return SelectionEntityTypeInfo::Mixed; + } + for (AZ::EntityId selectedEntityId : selection) { bool isLayerEntity = false; @@ -909,16 +944,18 @@ namespace AzToolsFramework } } + bool isLevelLayout = GetCurrentInspectorLayout() == InspectorLayout::LEVEL; + m_gui->m_entityDetailsLabel->setText(entityDetailsLabelText); m_gui->m_entityDetailsLabel->setVisible(entityDetailsVisible); m_gui->m_entityNameEditor->setVisible(hasEntitiesDisplayed); m_gui->m_entityNameLabel->setVisible(hasEntitiesDisplayed); m_gui->m_entityIcon->setVisible(hasEntitiesDisplayed); - m_gui->m_pinButton->setVisible(m_overrideSelectedEntityIds.empty() && hasEntitiesDisplayed && !m_isSystemEntityEditor && !m_isLevelEntityEditor); - m_gui->m_statusLabel->setVisible(hasEntitiesDisplayed && !m_isSystemEntityEditor && !m_isLevelEntityEditor); - m_gui->m_statusComboBox->setVisible(hasEntitiesDisplayed && !m_isSystemEntityEditor && !m_isLevelEntityEditor); - m_gui->m_entityIdLabel->setVisible(hasEntitiesDisplayed && !m_isSystemEntityEditor && !m_isLevelEntityEditor); - m_gui->m_entityIdText->setVisible(hasEntitiesDisplayed && !m_isSystemEntityEditor && !m_isLevelEntityEditor); + m_gui->m_pinButton->setVisible(m_overrideSelectedEntityIds.empty() && hasEntitiesDisplayed && !m_isSystemEntityEditor); + m_gui->m_statusLabel->setVisible(hasEntitiesDisplayed && !m_isSystemEntityEditor && !isLevelLayout); + m_gui->m_statusComboBox->setVisible(hasEntitiesDisplayed && !m_isSystemEntityEditor && !isLevelLayout); + m_gui->m_entityIdLabel->setVisible(hasEntitiesDisplayed && !m_isSystemEntityEditor && !isLevelLayout); + m_gui->m_entityIdText->setVisible(hasEntitiesDisplayed && !m_isSystemEntityEditor && !isLevelLayout); bool displayComponentSearchBox = hasEntitiesDisplayed; if (hasEntitiesDisplayed) @@ -941,7 +978,7 @@ namespace AzToolsFramework UpdateEntityDisplay(); } - m_gui->m_darkBox->setVisible(displayComponentSearchBox && !m_isSystemEntityEditor && !m_isLevelEntityEditor); + m_gui->m_darkBox->setVisible(displayComponentSearchBox && !m_isSystemEntityEditor && !isLevelLayout); m_gui->m_entitySearchBox->setVisible(displayComponentSearchBox); bool displayAddComponentMenu = CanAddComponentsToSelection(selectionEntityTypeInfo); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.hxx b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.hxx index fed9c55f15..677dc98277 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.hxx +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.hxx @@ -521,6 +521,15 @@ namespace AzToolsFramework bool m_isSystemEntityEditor; bool m_isLevelEntityEditor = false; + enum class InspectorLayout + { + ENTITY = 0, // All selected entities are regular entities + LEVEL, // The selected entity is the level prefab container entity + INVALID // Other entities are selected alongside the level prefab container entity + }; + + InspectorLayout GetCurrentInspectorLayout() const; + // the spacer's job is to make sure that its always at the end of the list of components. QSpacerItem* m_spacer; bool m_isAlreadyQueuedRefresh; diff --git a/Code/Framework/AzToolsFramework/Tests/Entity/EditorEntityHelpersTests.cpp b/Code/Framework/AzToolsFramework/Tests/Entity/EditorEntityHelpersTests.cpp new file mode 100644 index 0000000000..51feacfa2b --- /dev/null +++ b/Code/Framework/AzToolsFramework/Tests/Entity/EditorEntityHelpersTests.cpp @@ -0,0 +1,57 @@ +/* +* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +* its licensors. +* +* For complete copyright and license terms please see the LICENSE at the root of this +* distribution (the "License"). All use of this software is governed by the License, +* or, if provided, by the license below or the license accompanying this file. Do not +* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* +*/ + +#include + +#include +#include +#include + +namespace UnitTest +{ + class EditorEntityHelpersTest + : public ToolsApplicationFixture + { + void SetUpEditorFixtureImpl() override + { + m_parent1 = CreateDefaultEditorEntity("Parent1"); + m_child1 = CreateDefaultEditorEntity("Child1"); + m_child2 = CreateDefaultEditorEntity("Child2"); + m_grandChild1 = CreateDefaultEditorEntity("GrandChild1"); + m_parent2 = CreateDefaultEditorEntity("Parent2"); + + AZ::TransformBus::Event(m_child1, &AZ::TransformBus::Events::SetParent, m_parent1); + AZ::TransformBus::Event(m_child2, &AZ::TransformBus::Events::SetParent, m_parent1); + AZ::TransformBus::Event(m_grandChild1, &AZ::TransformBus::Events::SetParent, m_child1); + } + + public: + AZ::EntityId m_parent1; + AZ::EntityId m_child1; + AZ::EntityId m_child2; + AZ::EntityId m_grandChild1; + AZ::EntityId m_parent2; + }; + + TEST_F(EditorEntityHelpersTest, EditorEntityHelpersTests_GetCulledEntityHierarchy) + { + AzToolsFramework::EntityIdList testEntityIds{ m_parent1, m_child1, m_child2, m_grandChild1, m_parent2 }; + + AzToolsFramework::EntityIdSet culledSet = AzToolsFramework::GetCulledEntityHierarchy(testEntityIds); + + // There should only be two EntityIds returned (m_parent1, and m_parent2), + // since all the others should be culled out since they have a common ancestor + // in the list already + using ::testing::UnorderedElementsAre; + EXPECT_THAT(culledSet, UnorderedElementsAre(m_parent1, m_parent2)); + } +} diff --git a/Code/Framework/AzToolsFramework/Tests/aztoolsframeworktests_files.cmake b/Code/Framework/AzToolsFramework/Tests/aztoolsframeworktests_files.cmake index 7a2cd373a2..e54aa187e4 100644 --- a/Code/Framework/AzToolsFramework/Tests/aztoolsframeworktests_files.cmake +++ b/Code/Framework/AzToolsFramework/Tests/aztoolsframeworktests_files.cmake @@ -85,7 +85,9 @@ set(FILES Prefab/SpawnableSortEntitiesTestFixture.cpp Prefab/SpawnableSortEntitiesTestFixture.h Entity/EditorEntityContextComponentTests.cpp + Entity/EditorEntityHelpersTests.cpp Entity/EditorEntitySearchComponentTests.cpp + Entity/EditorEntitySelectionTests.cpp SliceStabilityTests/SliceStabilityTestFramework.h SliceStabilityTests/SliceStabilityTestFramework.cpp SliceStabilityTests/SliceStabilityCreateTests.cpp diff --git a/Code/Framework/GridMate/CMakeLists.txt b/Code/Framework/GridMate/CMakeLists.txt index f326bda179..20ce582307 100644 --- a/Code/Framework/GridMate/CMakeLists.txt +++ b/Code/Framework/GridMate/CMakeLists.txt @@ -28,8 +28,9 @@ ly_add_target( ${pal_dir} BUILD_DEPENDENCIES PRIVATE - 3rdParty::OpenSSL AZ::AzCore + PUBLIC + 3rdParty::OpenSSL ) ly_add_source_properties( diff --git a/Code/Sandbox/Editor/AlignTool.cpp b/Code/Sandbox/Editor/AlignTool.cpp deleted file mode 100644 index 4b3aedfbfa..0000000000 --- a/Code/Sandbox/Editor/AlignTool.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "EditorDefs.h" - -#include "AlignTool.h" - -// Editor -#include "Objects/BaseObject.h" -#include "Objects/SelectionGroup.h" - -////////////////////////////////////////////////////////////////////////// -bool CAlignPickCallback::m_bActive = false; - -////////////////////////////////////////////////////////////////////////// -//! Called when object picked. -void CAlignPickCallback::OnPick(CBaseObject* picked) -{ - Matrix34 pickedTM(picked->GetWorldTM()); - - AABB pickedAABB; - picked->GetBoundBox(pickedAABB); - pickedAABB.Move(-pickedTM.GetTranslation()); - Vec3 pickedPivot = pickedAABB.GetCenter(); - - AABB pickedLocalAABB; - picked->GetLocalBounds(pickedLocalAABB); - - const Quat& pickedRot = picked->GetRotation(); - const Vec3& pickedScale = picked->GetScale(); - const Vec3& pickedPos = picked->GetPos(); - - bool bKeepScale = CheckVirtualKey(Qt::Key_Shift); - bool bKeepRotation = CheckVirtualKey(Qt::Key_Alt); - bool bAlignToBoundBox = CheckVirtualKey(Qt::Key_Control); - bool bApplyTransform = !bKeepScale && !bKeepRotation && !bAlignToBoundBox; - - { - bool bUndo = !CUndo::IsRecording(); - if (bUndo) - { - GetIEditor()->BeginUndo(); - } - - CSelectionGroup* selGroup = GetIEditor()->GetSelection(); - selGroup->FilterParents(); - - for (int i = 0; i < selGroup->GetFilteredCount(); i++) - { - CBaseObject* pMovedObj = selGroup->GetFilteredObject(i); - - if (bKeepScale || bKeepRotation || bApplyTransform) - { - if (bKeepScale && bKeepRotation) // Keep scale and rotation of a moved object - { - pMovedObj->SetWorldTM(Matrix34::Create(pMovedObj->GetScale(), pMovedObj->GetRotation(), pickedPos), eObjectUpdateFlags_UserInput); - } - else if (bKeepScale) // Keep only scale of a moved object - { - pMovedObj->SetWorldTM(Matrix34::Create(pMovedObj->GetScale(), pickedRot, pickedPos), eObjectUpdateFlags_UserInput); - } - else if (bKeepRotation) // Keep only rotation of a moved object - { - pMovedObj->SetWorldTM(Matrix34::Create(pickedScale, pMovedObj->GetRotation(), pickedPos), eObjectUpdateFlags_UserInput); - } - else // Scale, Rotation and Position of a picked object are applied to a moved object. - { - pMovedObj->SetWorldTM(pickedTM, eObjectUpdateFlags_UserInput); - } - } - else if (bAlignToBoundBox) // align to the bounding box. - { - if (pickedLocalAABB.GetVolume() == 0.0f) - { - continue; - } - - AABB movedLocalAABB; - pMovedObj->GetLocalBounds(movedLocalAABB); - if (fabs(movedLocalAABB.max.x - movedLocalAABB.min.x) < VEC_EPSILON && - fabs(movedLocalAABB.max.y - movedLocalAABB.min.y) < VEC_EPSILON && - fabs(movedLocalAABB.max.z - movedLocalAABB.min.z) < VEC_EPSILON) - { - continue; - } - - const Vec3& movedScale(pMovedObj->GetScale()); - Matrix34 movedScaleTM = Matrix34::CreateScale(movedScale); - AABB movedLocalScaledAABB; - movedLocalScaledAABB.min = movedScaleTM.TransformVector(movedLocalAABB.min); - movedLocalScaledAABB.max = movedScaleTM.TransformVector(movedLocalAABB.max); - - float fMovedWidth = movedLocalScaledAABB.max.x - movedLocalScaledAABB.min.x; - float fMovedHeight = movedLocalScaledAABB.max.z - movedLocalScaledAABB.min.z; - float fMovedLength = movedLocalScaledAABB.max.y - movedLocalScaledAABB.min.y; - - Matrix34 pickedScaleTM = Matrix34::CreateScale(picked->GetScale()); - AABB pickedLocalScaledAABB; - pickedLocalScaledAABB.min = pickedScaleTM.TransformVector(pickedLocalAABB.min); - pickedLocalScaledAABB.max = pickedScaleTM.TransformVector(pickedLocalAABB.max); - float fScaledPickedtWidth = pickedLocalScaledAABB.max.x - pickedLocalScaledAABB.min.x; - float fScaledPickedHeight = pickedLocalScaledAABB.max.z - pickedLocalScaledAABB.min.z; - float fScaledPickedLength = pickedLocalScaledAABB.max.y - pickedLocalScaledAABB.min.y; - - Vec3 scale((fScaledPickedtWidth / fMovedWidth) * movedScale.x, (fScaledPickedLength / fMovedLength) * movedScale.y, (fScaledPickedHeight / fMovedHeight) * movedScale.z); - Matrix34 scaleRotTM = Matrix34::Create(scale, pickedRot, Vec3(0, 0, 0)); - Vec3 movedPivot = scaleRotTM.TransformVector(movedLocalAABB.GetCenter()); - - pMovedObj->SetWorldTM(Matrix34::Create(scale, pickedRot, Vec3(pickedPos + (pickedPivot - movedPivot))), eObjectUpdateFlags_UserInput); - } - } - m_bActive = false; - if (bUndo) - { - GetIEditor()->AcceptUndo("Align To Object"); - } - } - delete this; -} - -//! Called when pick mode cancelled. -void CAlignPickCallback::OnCancelPick() -{ - m_bActive = false; - delete this; -} - -//! Return true if specified object is pickable. -bool CAlignPickCallback::OnPickFilter([[maybe_unused]] CBaseObject* filterObject) -{ - return true; -}; diff --git a/Code/Sandbox/Editor/AlignTool.h b/Code/Sandbox/Editor/AlignTool.h deleted file mode 100644 index 43cd01013d..0000000000 --- a/Code/Sandbox/Editor/AlignTool.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#ifndef CRYINCLUDE_EDITOR_ALIGNTOOL_H -#define CRYINCLUDE_EDITOR_ALIGNTOOL_H - -#pragma once - -////////////////////////////////////////////////////////////////////////// -class CAlignPickCallback - : public IPickObjectCallback -{ -public: - CAlignPickCallback() { m_bActive = true; }; - //! Called when object picked. - virtual void OnPick(CBaseObject* picked); - //! Called when pick mode cancelled. - virtual void OnCancelPick(); - //! Return true if specified object is pickable. - virtual bool OnPickFilter(CBaseObject* filterObject); - - static bool IsActive() { return m_bActive; } - - virtual bool IsNeedSpecificBehaviorForSpaceAcce() { return true; } -private: - static bool m_bActive; -}; - - -#endif // CRYINCLUDE_EDITOR_ALIGNTOOL_H diff --git a/Code/Sandbox/Editor/Core/LevelEditorMenuHandler.cpp b/Code/Sandbox/Editor/Core/LevelEditorMenuHandler.cpp index 1c9e7d90d2..f00085d5ad 100644 --- a/Code/Sandbox/Editor/Core/LevelEditorMenuHandler.cpp +++ b/Code/Sandbox/Editor/Core/LevelEditorMenuHandler.cpp @@ -580,7 +580,6 @@ void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMe auto alignMenu = modifyMenu.AddMenu(tr("Align")); alignMenu.AddAction(ID_OBJECTMODIFY_ALIGNTOGRID); - alignMenu.AddAction(ID_OBJECTMODIFY_ALIGN); alignMenu.AddAction(ID_MODIFY_ALIGNOBJTOSURF); auto constrainMenu = modifyMenu.AddMenu(tr("Constrain")); diff --git a/Code/Sandbox/Editor/CryEdit.cpp b/Code/Sandbox/Editor/CryEdit.cpp index dff5b2267c..7aefcffb5a 100644 --- a/Code/Sandbox/Editor/CryEdit.cpp +++ b/Code/Sandbox/Editor/CryEdit.cpp @@ -95,8 +95,6 @@ AZ_POP_DISABLE_WARNING #include "Core/QtEditorApplication.h" #include "StringDlg.h" -#include "LinkTool.h" -#include "AlignTool.h" #include "VoxelAligningTool.h" #include "NewLevelDialog.h" #include "GridSettingsDialog.h" @@ -126,7 +124,6 @@ AZ_POP_DISABLE_WARNING #include "EditorPreferencesDialog.h" #include "GraphicsSettingsDialog.h" #include "FeedbackDialog/FeedbackDialog.h" -#include "MatEditMainDlg.h" #include "AnimationContext.h" #include "GotoPositionDlg.h" @@ -401,8 +398,6 @@ void CCryEditApp::RegisterActionHandlers() ON_COMMAND(ID_EDITMODE_MOVE, OnEditmodeMove) ON_COMMAND(ID_EDITMODE_ROTATE, OnEditmodeRotate) ON_COMMAND(ID_EDITMODE_SCALE, OnEditmodeScale) - ON_COMMAND(ID_EDITTOOL_LINK, OnEditToolLink) - ON_COMMAND(ID_EDITTOOL_UNLINK, OnEditToolUnlink) ON_COMMAND(ID_EDITMODE_SELECT, OnEditmodeSelect) ON_COMMAND(ID_EDIT_ESCAPE, OnEditEscape) ON_COMMAND(ID_OBJECTMODIFY_SETAREA, OnObjectSetArea) @@ -422,7 +417,6 @@ void CCryEditApp::RegisterActionHandlers() ON_COMMAND(ID_SELECTION_SAVE, OnSelectionSave) ON_COMMAND(ID_IMPORT_ASSET, OnOpenAssetImporter) ON_COMMAND(ID_SELECTION_LOAD, OnSelectionLoad) - ON_COMMAND(ID_OBJECTMODIFY_ALIGN, OnAlignObject) ON_COMMAND(ID_MODIFY_ALIGNOBJTOSURF, OnAlignToVoxel) ON_COMMAND(ID_OBJECTMODIFY_ALIGNTOGRID, OnAlignToGrid) ON_COMMAND(ID_LOCK_SELECTION, OnLockSelection) @@ -1898,14 +1892,6 @@ BOOL CCryEditApp::InitInstance() CWipFeatureManager::Init(); #endif - if (GetIEditor()->IsInMatEditMode()) - { - m_pMatEditDlg = new CMatEditMainDlg(QStringLiteral("Material Editor")); - m_pEditor->InitFinished(); - m_pMatEditDlg->show(); - return true; - } - if (!m_bConsoleMode && !m_bPreviewMode) { GetIEditor()->UpdateViews(); @@ -2905,51 +2891,6 @@ void CCryEditApp::OnEditmodeScale() } } -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnEditToolLink() -{ - // TODO: Add your command handler code here - if (qobject_cast(GetIEditor()->GetEditTool())) - { - GetIEditor()->SetEditTool(0); - } - else - { - GetIEditor()->SetEditTool(new CLinkTool()); - } -} - -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnUpdateEditToolLink(QAction* action) -{ - if (!GetIEditor()->GetDocument()) - { - action->setEnabled(false); - return; - } - action->setEnabled(GetIEditor()->GetDocument()->IsDocumentReady()); - CEditTool* pEditTool = GetIEditor()->GetEditTool(); - action->setChecked(qobject_cast(pEditTool) != nullptr); -} - -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnEditToolUnlink() -{ - CUndo undo("Unlink Object(s)"); - CSelectionGroup* pSelection = GetIEditor()->GetObjectManager()->GetSelection(); - for (int i = 0; i < pSelection->GetCount(); i++) - { - CBaseObject* pBaseObj = pSelection->GetObject(i); - pBaseObj->DetachThis(); - } -} - -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnUpdateEditToolUnlink(QAction* action) -{ - action->setEnabled(false); -} - ////////////////////////////////////////////////////////////////////////// void CCryEditApp::OnEditmodeSelect() { @@ -3519,14 +3460,6 @@ void CCryEditApp::OnUpdateSelected(QAction* action) action->setEnabled(!GetIEditor()->GetSelection()->IsEmpty()); } -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnAlignObject() -{ - // Align pick callback will release itself. - CAlignPickCallback* alignCallback = new CAlignPickCallback; - GetIEditor()->PickObject(alignCallback, 0, "Align to Object"); -} - ////////////////////////////////////////////////////////////////////////// void CCryEditApp::OnAlignToGrid() { @@ -3547,15 +3480,6 @@ void CCryEditApp::OnAlignToGrid() } } -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnUpdateAlignObject(QAction* action) -{ - Q_ASSERT(action->isCheckable()); - action->setChecked(CAlignPickCallback::IsActive()); - - action->setEnabled(!GetIEditor()->GetSelection()->IsEmpty()); -} - ////////////////////////////////////////////////////////////////////////// void CCryEditApp::OnAlignToVoxel() { diff --git a/Code/Sandbox/Editor/CryEdit.h b/Code/Sandbox/Editor/CryEdit.h index 7480b34e5a..94c39991e9 100644 --- a/Code/Sandbox/Editor/CryEdit.h +++ b/Code/Sandbox/Editor/CryEdit.h @@ -28,7 +28,6 @@ class CCryDocManager; class CQuickAccessBar; -class CMatEditMainDlg; class CCryEditDoc; class CEditCommandLineInfo; class CMainFrame; @@ -225,10 +224,6 @@ public: void OnEditmodeMove(); void OnEditmodeRotate(); void OnEditmodeScale(); - void OnEditToolLink(); - void OnUpdateEditToolLink(QAction* action); - void OnEditToolUnlink(); - void OnUpdateEditToolUnlink(QAction* action); void OnEditmodeSelect(); void OnEditEscape(); void OnObjectSetArea(); @@ -257,10 +252,8 @@ public: void OnOpenAssetImporter(); void OnSelectionLoad(); void OnUpdateSelected(QAction* action); - void OnAlignObject(); void OnAlignToVoxel(); void OnAlignToGrid(); - void OnUpdateAlignObject(QAction* action); void OnUpdateAlignToVoxel(QAction* action); void OnLockSelection(); void OnEditLevelData(); @@ -367,7 +360,6 @@ private: //! Autotest mode: Special mode meant for automated testing, things like blocking dialogs or error report windows won't appear bool m_bAutotestMode = false; - CMatEditMainDlg* m_pMatEditDlg = nullptr; CConsoleDialog* m_pConsoleDialog = nullptr; AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING diff --git a/Code/Sandbox/Editor/EditorViewportWidget.cpp b/Code/Sandbox/Editor/EditorViewportWidget.cpp index 5d8da91644..f7365e74e0 100644 --- a/Code/Sandbox/Editor/EditorViewportWidget.cpp +++ b/Code/Sandbox/Editor/EditorViewportWidget.cpp @@ -276,9 +276,6 @@ void EditorViewportWidget::paintEvent([[maybe_unused]] QPaintEvent* event) if ((ge && ge->IsLevelLoaded()) || (GetType() != ET_ViewportCamera)) { setRenderOverlayVisible(true); - m_isOnPaint = true; - Update(); - m_isOnPaint = false; } else { @@ -809,6 +806,10 @@ void EditorViewportWidget::OnBeginPrepareRender() return; } + m_isOnPaint = true; + Update(); + m_isOnPaint = false; + float fNearZ = GetIEditor()->GetConsoleVar("cl_DefaultNearPlane"); float fFarZ = m_Camera.GetFarPlane(); @@ -883,6 +884,11 @@ void EditorViewportWidget::OnBeginPrepareRender() GetIEditor()->GetSystem()->SetViewCamera(m_Camera); + if (GetIEditor()->IsInGameMode()) + { + return; + } + PreWidgetRendering(); RenderAll(); @@ -908,13 +914,6 @@ void EditorViewportWidget::OnBeginPrepareRender() m_debugDisplay->DepthTestOn(); PostWidgetRendering(); - -#if 0 // ATOMSHIM FIXUP - if (!m_renderer->IsStereoEnabled()) -#endif - { - GetIEditor()->GetSystem()->RenderStatistics(); - } } ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Sandbox/Editor/IEditor.h b/Code/Sandbox/Editor/IEditor.h index 7715e64fe5..722f2a7c25 100644 --- a/Code/Sandbox/Editor/IEditor.h +++ b/Code/Sandbox/Editor/IEditor.h @@ -391,21 +391,6 @@ enum EModifiedModule eModifiedAll = -1 }; -//! Callback class passed to PickObject. -struct IPickObjectCallback -{ - virtual ~IPickObjectCallback() = default; - - //! Called when object picked. - virtual void OnPick(CBaseObject* picked) = 0; - //! Called when pick mode cancelled. - virtual void OnCancelPick() = 0; - //! Return true if specified object is pickable. - virtual bool OnPickFilter([[maybe_unused]] CBaseObject* filterObject) { return true; }; - //! If need a specific behavior when holding space, return true or if not, return false. - virtual bool IsNeedSpecificBehaviorForSpaceAcce() { return false; } -}; - //! Class provided by editor for various registration functions. struct CRegistrationContext { @@ -570,20 +555,6 @@ struct IEditor //! Get access to object manager. virtual struct IObjectManager* GetObjectManager() = 0; virtual CSettingsManager* GetSettingsManager() = 0; - //! Set pick object mode. - //! When object picked callback will be called, with OnPick - //! If pick operation is canceled Cancel will be called - //! @param targetClass specifies objects of which class are supposed to be picked - //! @param bMultipick if true pick tool will pick multiple object - virtual void PickObject( - IPickObjectCallback* callback, - const QMetaObject* targetClass = 0, - const char* statusText = 0, - bool bMultipick = false) = 0; - //! Cancel current pick operation - virtual void CancelPick() = 0; - //! Return true if editor now in object picking mode - virtual bool IsPicking() = 0; //! Get DB manager that own items of specified type. virtual IDataBaseManager* GetDBItemManager(EDataBaseItemType itemType) = 0; //! Get Manager of Materials. diff --git a/Code/Sandbox/Editor/IEditorImpl.cpp b/Code/Sandbox/Editor/IEditorImpl.cpp index 4a0a73c9ac..399ac45794 100644 --- a/Code/Sandbox/Editor/IEditorImpl.cpp +++ b/Code/Sandbox/Editor/IEditorImpl.cpp @@ -65,7 +65,6 @@ AZ_POP_DISABLE_WARNING #include "UIEnumsDatabase.h" #include "Util/Ruler.h" #include "RenderHelpers/AxisHelper.h" -#include "PickObjectTool.h" #include "Settings.h" #include "Include/IObjectManager.h" #include "Include/ISourceControl.h" @@ -170,7 +169,6 @@ CEditorImpl::CEditorImpl() , m_pShaderEnum(nullptr) , m_pIconManager(nullptr) , m_bSelectionLocked(true) - , m_pPickTool(nullptr) , m_pAxisGizmo(nullptr) , m_pGameEngine(nullptr) , m_pAnimationContext(nullptr) @@ -794,11 +792,6 @@ void CEditorImpl::SetEditTool(CEditTool* tool, bool bStopCurrentTool) m_pEditTool->BeginEditParams(this, 0); } - // Make sure pick is aborted. - if (tool != m_pPickTool) - { - m_pPickTool = nullptr; - } Notify(eNotify_OnEditToolChange); } @@ -1069,34 +1062,6 @@ bool CEditorImpl::IsSelectionLocked() return m_bSelectionLocked; } -void CEditorImpl::PickObject(IPickObjectCallback* callback, const QMetaObject* targetClass, const char* statusText, bool bMultipick) -{ - m_pPickTool = new CPickObjectTool(callback, targetClass); - - static_cast(m_pPickTool.get())->SetMultiplePicks(bMultipick); - if (statusText) - { - m_pPickTool.get()->SetStatusText(statusText); - } - - SetEditTool(m_pPickTool); -} - -void CEditorImpl::CancelPick() -{ - SetEditTool(0); - m_pPickTool = 0; -} - -bool CEditorImpl::IsPicking() -{ - if (GetEditTool() == m_pPickTool && m_pPickTool != 0) - { - return true; - } - return false; -} - CViewManager* CEditorImpl::GetViewManager() { return m_pViewManager; diff --git a/Code/Sandbox/Editor/IEditorImpl.h b/Code/Sandbox/Editor/IEditorImpl.h index 9e3b3abc66..4a8d5fa191 100644 --- a/Code/Sandbox/Editor/IEditorImpl.h +++ b/Code/Sandbox/Editor/IEditorImpl.h @@ -181,10 +181,7 @@ public: void SelectObject(CBaseObject* obj); void LockSelection(bool bLock); bool IsSelectionLocked(); - void PickObject(IPickObjectCallback* callback, const QMetaObject* targetClass = 0, const char* statusText = 0, bool bMultipick = false); - void CancelPick(); - bool IsPicking(); IDataBaseManager* GetDBItemManager(EDataBaseItemType itemType); CMaterialManager* GetMaterialManager() { return m_pMaterialManager; } CMusicManager* GetMusicManager() { return m_pMusicManager; }; @@ -409,7 +406,6 @@ protected: QString m_primaryCDFolder; QString m_userFolder; bool m_bSelectionLocked; - _smart_ptr m_pPickTool; class CAxisGizmo* m_pAxisGizmo; CGameEngine* m_pGameEngine; CAnimationContext* m_pAnimationContext; diff --git a/Code/Sandbox/Editor/LayoutWnd.cpp b/Code/Sandbox/Editor/LayoutWnd.cpp index 56c0bcb849..34a96bca53 100644 --- a/Code/Sandbox/Editor/LayoutWnd.cpp +++ b/Code/Sandbox/Editor/LayoutWnd.cpp @@ -418,8 +418,11 @@ void CLayoutWnd::CreateLayout(EViewLayout layout, bool bBindViewports, EViewport QRect rcView = rect(); rcView.setBottom(rcView.bottom() - m_infoBar->height()); + // Ensure we delete our old view immediately so it can relinquish its backing ViewportContext if (m_maximizedView) - m_maximizedView->deleteLater(); + { + delete m_maximizedView; + } m_maximizedView = new CLayoutViewPane(this); m_maximizedView->SetId(0); diff --git a/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h b/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h index a290ef5de5..e48fb5fec1 100644 --- a/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h +++ b/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h @@ -90,9 +90,6 @@ public: MOCK_METHOD0(IsSelectionLocked, bool()); MOCK_METHOD0(GetObjectManager, struct IObjectManager* ()); MOCK_METHOD0(GetSettingsManager, CSettingsManager* ()); - MOCK_METHOD4(PickObject, void(IPickObjectCallback*,const QMetaObject*,const char* ,bool bMultipick)); - MOCK_METHOD0(CancelPick, void()); - MOCK_METHOD0(IsPicking, bool()); MOCK_METHOD1(GetDBItemManager, IDataBaseManager* (EDataBaseItemType)); MOCK_METHOD0(GetMaterialManager, CMaterialManager* ()); MOCK_METHOD0(GetMaterialManagerLibrary, IBaseLibraryManager* ()); diff --git a/Code/Sandbox/Editor/LinkTool.cpp b/Code/Sandbox/Editor/LinkTool.cpp deleted file mode 100644 index 4602875b77..0000000000 --- a/Code/Sandbox/Editor/LinkTool.cpp +++ /dev/null @@ -1,286 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "EditorDefs.h" - -#include "LinkTool.h" - -// Editor -#include "Viewport.h" -#include "Objects/EntityObject.h" -#include "Objects/SelectionGroup.h" -#include - -// AzCore -#include - -#ifdef LoadCursor -#undef LoadCursor -#endif - -namespace -{ - const float kGeomCacheNodePivotSizeScale = 0.0025f; -} - -////////////////////////////////////////////////////////////////////////// -CLinkTool::CLinkTool() - : m_nodeName(nullptr) - , m_pGeomCacheRenderNode(nullptr) -{ - m_pChild = NULL; - SetStatusText("Click on object and drag a link to a new parent"); - - m_hLinkCursor = CMFCUtils::LoadCursor(IDC_POINTER_LINK); - m_hLinkNowCursor = CMFCUtils::LoadCursor(IDC_POINTER_LINKNOW); - m_hCurrCursor = &m_hLinkCursor; - AZ::EntitySystemBus::Handler::BusConnect(); -} - -////////////////////////////////////////////////////////////////////////// -CLinkTool::~CLinkTool() -{ - AZ::EntitySystemBus::Handler::BusDisconnect(); -} - -////////////////////////////////////////////////////////////////////////// -void CLinkTool::LinkObject(CBaseObject* pChild, CBaseObject* pParent) -{ - if (pChild == NULL) - { - return; - } - - if (ChildIsValid(pParent, pChild)) - { - CUndo undo("Link Object"); - - if (qobject_cast(pChild)) - { - static_cast(pChild)->SetAttachTarget(""); - static_cast(pChild)->SetAttachType(CEntityObject::eAT_Pivot); - } - - pParent->AttachChild(pChild, true); - - QString str; - str = tr("%1 attached to %2").arg(pChild->GetName(), pParent->GetName()); - SetStatusText(str); - } - else - { - SetStatusText("Error: Cyclic linking or already linked."); - } -} - -////////////////////////////////////////////////////////////////////////// -void CLinkTool::LinkSelectedToParent(CBaseObject* pParent) -{ - if (pParent) - { - if (IsRelevant(pParent)) - { - CSelectionGroup* pSel = GetIEditor()->GetSelection(); - if (!pSel->GetCount()) - { - return; - } - CUndo undo("Link Object(s)"); - for (int i = 0; i < pSel->GetCount(); i++) - { - CBaseObject* pChild = pSel->GetObject(i); - if (pChild == pParent) - { - continue; - } - LinkObject(pChild, pParent); - } - } - } -} - -////////////////////////////////////////////////////////////////////////// -bool CLinkTool::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, [[maybe_unused]] int flags) -{ - view->SetCursorString(""); - - m_hCurrCursor = &m_hLinkCursor; - if (event == eMouseLDown) - { - HitContext hitInfo; - view->HitTest(point, hitInfo); - CBaseObject* obj = hitInfo.object; - if (obj) - { - if (IsRelevant(obj)) - { - m_StartDrag = obj->GetWorldPos(); - m_pChild = obj; - } - } - } - else if (event == eMouseLUp) - { - HitContext hitInfo; - view->HitTest(point, hitInfo); - CBaseObject* obj = hitInfo.object; - if (obj) - { - if (IsRelevant(obj)) - { - CSelectionGroup* pSelectionGroup = GetIEditor()->GetSelection(); - int nGroupCount = pSelectionGroup->GetCount(); - if (pSelectionGroup && nGroupCount > 1) - { - LinkSelectedToParent(obj); - } - if (!pSelectionGroup || nGroupCount <= 1 || !pSelectionGroup->IsContainObject(m_pChild)) - { - LinkObject(m_pChild, obj); - } - } - } - m_pChild = NULL; - } - else if (event == eMouseMove) - { - m_EndDrag = view->ViewToWorld(point); - m_nodeName = nullptr; - m_pGeomCacheRenderNode = nullptr; - - HitContext hitInfo; - if (view->HitTest(point, hitInfo)) - { - m_EndDrag = hitInfo.raySrc + hitInfo.rayDir * hitInfo.dist; - } - - CBaseObject* obj = hitInfo.object; - if (obj) - { - if (IsRelevant(obj)) - { - QString name = obj->GetName(); - if (hitInfo.name) - { - name += QString("\n ") + hitInfo.name; - } - - // Set Cursors. - view->SetCursorString(name); - if (m_pChild) - { - if (ChildIsValid(obj, m_pChild)) - { - m_hCurrCursor = &m_hLinkNowCursor; - } - } - } - } - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CLinkTool::OnKeyDown([[maybe_unused]] CViewport* view, uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) -{ - if (nChar == VK_ESCAPE) - { - // Cancel selection. - GetIEditor()->SetEditTool(nullptr); - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -void CLinkTool::Display(DisplayContext& dc) -{ - if (m_pChild && m_EndDrag != Vec3(ZERO)) - { - ColorF lineColor = (m_hCurrCursor == &m_hLinkNowCursor) ? ColorF(0, 1, 0) : ColorF(1, 0, 0); - dc.DrawLine(m_StartDrag, m_EndDrag, lineColor, lineColor); - } -} - -////////////////////////////////////////////////////////////////////////// -void CLinkTool::OnEntityDestruction(const AZ::EntityId& entityId) -{ - if (m_pChild && (m_pChild->GetType() == OBJTYPE_AZENTITY)) - { - CComponentEntityObject* childComponentEntity = static_cast(m_pChild); - AZ::EntityId childEntityId = childComponentEntity->GetAssociatedEntityId(); - if(entityId == childEntityId) - { - GetIEditor()->SetEditTool(nullptr); - } - } -} - -////////////////////////////////////////////////////////////////////////// -bool CLinkTool::ChildIsValid(CBaseObject* pParent, CBaseObject* pChild, int nDir) -{ - if (!pParent) - { - return false; - } - if (!pChild) - { - return false; - } - if (pParent == pChild) - { - return false; - } - - // Legacy entities and AZ entities shouldn't be linked. - if ((pParent->GetType() == OBJTYPE_AZENTITY) != (pChild->GetType() == OBJTYPE_AZENTITY)) - { - return false; - } - - CBaseObject* pObj; - if (nDir & 1) - { - pObj = pChild->GetParent(); - if (pObj) - { - if (!ChildIsValid(pParent, pObj, 1)) - { - return false; - } - } - } - if (nDir & 2) - { - for (int i = 0; i < pChild->GetChildCount(); i++) - { - pObj = pChild->GetChild(i); - if (pObj) - { - if (!ChildIsValid(pParent, pObj, 2)) - { - return false; - } - } - } - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CLinkTool::OnSetCursor(CViewport* vp) -{ - vp->SetCursor(*m_hCurrCursor); - return true; -} - -#include diff --git a/Code/Sandbox/Editor/LinkTool.h b/Code/Sandbox/Editor/LinkTool.h deleted file mode 100644 index a24370f7fe..0000000000 --- a/Code/Sandbox/Editor/LinkTool.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : Definition of CLinkTool, tool used to link objects. - - -#ifndef CRYINCLUDE_EDITOR_LINKTOOL_H -#define CRYINCLUDE_EDITOR_LINKTOOL_H - -#pragma once - -#if !defined(Q_MOC_RUN) -#include -#include "EditTool.h" -#include "Include/IObjectManager.h" -#endif - -class CEntityObject; - -////////////////////////////////////////////////////////////////////////// -class CLinkTool - : public CEditTool - , public IObjectSelectCallback - , private AZ::EntitySystemBus::Handler -{ - Q_OBJECT -public: - Q_INVOKABLE CLinkTool(); // IPickObjectCallback *callback,CRuntimeClass *targetClass=NULL ); - - // Ovverides from CEditTool - bool MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags); - - virtual void BeginEditParams([[maybe_unused]] IEditor* ie, [[maybe_unused]] int flags) {}; - virtual void EndEditParams() {}; - - virtual void Display(DisplayContext& dc); - virtual bool OnKeyDown(CViewport* view, uint32 nChar, uint32 nRepCnt, uint32 nFlags); - virtual bool OnKeyUp([[maybe_unused]] CViewport* view, [[maybe_unused]] uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) { return false; }; - - virtual bool OnSelectObject([[maybe_unused]] CBaseObject* obj) {return false; } - virtual bool CanSelectObject([[maybe_unused]] CBaseObject* obj) { return true; }; - - virtual bool OnSetCursor(CViewport* vp); - - void LinkSelectedToParent(CBaseObject* pParent); - -protected: - virtual ~CLinkTool(); - // Delete itself. - void DeleteThis() { delete this; }; - -private: - bool IsRelevant([[maybe_unused]] CBaseObject* obj) { return true; } - bool ChildIsValid(CBaseObject* pParent, CBaseObject* pChild, int nDir = 3); - void LinkObject(CBaseObject* pChild, CBaseObject* pParent); - void LinkToNode(CEntityObject* pChild, CEntityObject* pParent, const char* nodeName); - - // AZ::EntitySystemBus::Handler - void OnEntityDestruction(const AZ::EntityId& entityId) override; - - - CBaseObject* m_pChild; - Vec3 m_StartDrag; - Vec3 m_EndDrag; - - QCursor m_hLinkCursor; - QCursor m_hLinkNowCursor; - QCursor* m_hCurrCursor; - - const char* m_nodeName; - IGeomCacheRenderNode* m_pGeomCacheRenderNode; -}; - - -#endif // CRYINCLUDE_EDITOR_LINKTOOL_H diff --git a/Code/Sandbox/Editor/MainWindow.cpp b/Code/Sandbox/Editor/MainWindow.cpp index ab5e0cf559..6acd8cfc20 100644 --- a/Code/Sandbox/Editor/MainWindow.cpp +++ b/Code/Sandbox/Editor/MainWindow.cpp @@ -92,7 +92,6 @@ AZ_POP_DISABLE_WARNING #include "TrackView/TrackViewDialog.h" #include "ErrorReportDialog.h" -#include "Material/MaterialDialog.h" #include "LensFlareEditor/LensFlareEditor.h" #include "TimeOfDayDialog.h" @@ -1105,15 +1104,6 @@ void MainWindow::InitActions() .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSelected) .SetIcon(Style::icon("Align_to_grid")) .SetApplyHoverEffect(); - am->AddAction(ID_OBJECTMODIFY_ALIGN, tr("Align to object")).SetCheckable(true) -#if AZ_TRAIT_OS_PLATFORM_APPLE - .SetStatusTip(tr(u8"\u2318: Align an object to a bounding box, \u2325 : Keep Rotation of the moved object, Shift : Keep Scale of the moved object")) -#else - .SetStatusTip(tr("Ctrl: Align an object to a bounding box, Alt : Keep Rotation of the moved object, Shift : Keep Scale of the moved object")) -#endif - .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateAlignObject) - .SetIcon(Style::icon("Align_to_Object")) - .SetApplyHoverEffect(); am->AddAction(ID_MODIFY_ALIGNOBJTOSURF, tr("Align object to surface (Hold CTRL)")).SetCheckable(true) .SetToolTip(tr("Align object to surface (Hold CTRL)")) .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateAlignToVoxel) @@ -1450,15 +1440,6 @@ void MainWindow::InitActions() .SetApplyHoverEffect(); // Edit Mode Toolbar Actions - am->AddAction(ID_EDITTOOL_LINK, tr("Link an object to parent")) - .SetIcon(Style::icon("add_link")) - .SetApplyHoverEffect() - .SetCheckable(true) - .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateEditToolLink); - am->AddAction(ID_EDITTOOL_UNLINK, tr("Unlink all selected objects")) - .SetIcon(Style::icon("remove_link")) - .SetApplyHoverEffect() - .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateEditToolUnlink); am->AddAction(IDC_SELECTION_MASK, tr("Selected Object Types")); am->AddAction(ID_REF_COORDS_SYS, tr("Reference coordinate system")) .SetShortcut(tr("Ctrl+W")) @@ -1974,7 +1955,6 @@ void MainWindow::RegisterStdViewClasses() if (!AZ::Interface::Get()) { - CMaterialDialog::RegisterViewClass(); CLensFlareEditor::RegisterViewClass(); CTimeOfDayDialog::RegisterViewClass(); } diff --git a/Code/Sandbox/Editor/MatEditMainDlg.cpp b/Code/Sandbox/Editor/MatEditMainDlg.cpp deleted file mode 100644 index 9a96ad15d0..0000000000 --- a/Code/Sandbox/Editor/MatEditMainDlg.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : implementation file - -#include "EditorDefs.h" - -#include "MatEditMainDlg.h" - -// Qt -#include -#include - -// Editor -#include "Material/MaterialDialog.h" -#include "Material/MaterialManager.h" -#include "MaterialSender.h" - - -CMatEditMainDlg::CMatEditMainDlg(const QString& title, QWidget* pParent /*=NULL*/) - : QWidget(pParent) -{ - resize(1000, 600); - - setWindowTitle(title); - - QTimer* t = new QTimer(this); - connect(t, &QTimer::timeout, this, &CMatEditMainDlg::OnKickIdle); - t->start(250); - - m_materialDialog = new CMaterialDialog(); // must be created after the timer - auto layout = new QVBoxLayout(this); - layout->addWidget(m_materialDialog); - -#ifdef Q_OS_WIN - if (auto aed = QAbstractEventDispatcher::instance()) - { - aed->installNativeEventFilter(this); - } -#endif -} - -CMatEditMainDlg::~CMatEditMainDlg() -{ -#ifdef Q_OS_WIN - if (auto aed = QAbstractEventDispatcher::instance()) - { - aed->removeNativeEventFilter(this); - } -#endif -} - -///////////////////////////////////////////////////////////////////////////// -// CMatEditMainDlg message handlers - -void CMatEditMainDlg::showEvent(QShowEvent*) -{ - if (QWindow *win = window()->windowHandle()) - { - // Make sure our top-level window decorator wrapper set this exact title - // 3ds Max Exporter will use ::FindWindow with this name - win->setTitle("Material Editor"); - } -} - -bool CMatEditMainDlg::nativeEventFilter(const QByteArray&, void* message, long*) -{ -#ifdef Q_OS_WIN - // WM_MATEDITSEND is Windows only. Used by 3ds Max exporter. - MSG* msg = static_cast(message); - if (msg->message == WM_MATEDITSEND) - { - OnMatEditSend(msg->wParam); - return true; - } -#endif - - return false; -} - -void CMatEditMainDlg::closeEvent(QCloseEvent* event) -{ - QWidget::closeEvent(event); - qApp->quit(); -} - -void CMatEditMainDlg::OnKickIdle() -{ - GetIEditor()->Notify(eNotify_OnIdleUpdate); -} - -void CMatEditMainDlg::OnMatEditSend(int param) -{ - if (param != eMSM_Init) - { - GetIEditor()->GetMaterialManager()->SyncMaterialEditor(); - } -} - -#include diff --git a/Code/Sandbox/Editor/MatEditMainDlg.h b/Code/Sandbox/Editor/MatEditMainDlg.h deleted file mode 100644 index b329933c1f..0000000000 --- a/Code/Sandbox/Editor/MatEditMainDlg.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#ifndef CRYINCLUDE_EDITOR_MATEDITMAINDLG_H -#define CRYINCLUDE_EDITOR_MATEDITMAINDLG_H - -#pragma once - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#endif - -class CMaterialDialog; - -class CMatEditMainDlg - : public QWidget - , public QAbstractNativeEventFilter -{ - Q_OBJECT -public: - explicit CMatEditMainDlg(const QString& title = QString(), QWidget* parent = nullptr); - ~CMatEditMainDlg(); - - bool nativeEventFilter(const QByteArray& eventType, void* message, long* result) override; - -protected: - void closeEvent(QCloseEvent* event) override; - void showEvent(QShowEvent* event) override; - -private: - void OnKickIdle(); - void OnMatEditSend(int param); - CMaterialDialog* m_materialDialog = nullptr; -}; - -#endif // CRYINCLUDE_EDITOR_MATEDITMAINDLG_H diff --git a/Code/Sandbox/Editor/Material/MaterialDialog.cpp b/Code/Sandbox/Editor/Material/MaterialDialog.cpp deleted file mode 100644 index 5d5f14ecd2..0000000000 --- a/Code/Sandbox/Editor/Material/MaterialDialog.cpp +++ /dev/null @@ -1,2290 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "EditorDefs.h" - -#include "MaterialDialog.h" - -// Qt -#include -#include -#include -#include -#include -#include -#include -#include - -// AzToolsFramework -#include // for AzToolsFramework::ViewPaneOptions - -// Editor -#include "IEditor.h" -#include "EditTool.h" -#include "MaterialImageListCtrl.h" -#include "MaterialManager.h" -#include "MaterialHelpers.h" -#include "ShaderEnum.h" -#include "MatEditPreviewDlg.h" -#include "Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.h" -#include "Include/IObjectManager.h" -#include "Objects/BaseObject.h" -#include "Settings.h" -#include "Objects/SelectionGroup.h" -#include "LyViewPaneNames.h" - - -const QString EDITOR_OBJECTS_PATH("Objects\\Editor\\"); - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::RegisterViewClass() -{ - AzToolsFramework::ViewPaneOptions opts; - opts.shortcut = QKeySequence(Qt::Key_M); - opts.canHaveMultipleInstances = true; - - AzToolsFramework::RegisterViewPane(MATERIAL_EDITOR_NAME, LyViewPane::CategoryTools, opts); - - GetIEditor()->GetSettingsManager()->AddToolVersion(MATERIAL_EDITOR_NAME, MATERIAL_EDITOR_VER); -} - -const GUID& CMaterialDialog::GetClassID() -{ - static const GUID guid = - { - 0xc7891863, 0x1665, 0x45ac, { 0xae, 0x51, 0x48, 0x66, 0x71, 0xbc, 0x8b, 0x12 } - }; - return guid; -} - -inline float RoundDegree(float val) -{ - return (float)((int)(val * 100 + 0.5f)) * 0.01f; -} - -////////////////////////////////////////////////////////////////////////// -// Material structures. -////////////////////////////////////////////////////////////////////////// - -#ifndef _countof -#define _countof(array) (sizeof(array) / sizeof(array[0])) -#endif - -struct STextureVars -{ - CSmartVariable is_tile[2]; - - CSmartVariableEnum etcgentype; - CSmartVariableEnum etcmrotatetype; - CSmartVariableEnum etcmumovetype; - CSmartVariableEnum etcmvmovetype; - CSmartVariableEnum etextype; - CSmartVariableEnum filter; - - CSmartVariable is_tcgprojected; - CSmartVariable tiling[3]; - CSmartVariable rotate[3]; - CSmartVariable offset[3]; - CSmartVariable tcmuoscrate; - CSmartVariable tcmvoscrate; - CSmartVariable tcmuoscamplitude; - CSmartVariable tcmvoscamplitude; - CSmartVariable tcmuoscphase; - CSmartVariable tcmvoscphase; - CSmartVariable tcmrotoscrate; - CSmartVariable tcmrotoscamplitude; - CSmartVariable tcmrotoscphase; - CSmartVariable tcmrotosccenter[2]; - - CSmartVariableArray tableTiling; - CSmartVariableArray tableOscillator; - CSmartVariableArray tableRotator; - - void Reset() - { - SEfTexModificator defaultTextureCoordinateModifier; - SEfResTexture defaultTextureResource; - for (int i = 0; i < 2; i++) - { - *is_tile[i] = defaultTextureResource.GetTiling(i); - *tcmrotosccenter[i] = defaultTextureCoordinateModifier.m_RotOscCenter[i]; - } - - for (int i = 0; i < 3; i++) - { - *rotate[i] = RoundDegree(Word2Degr(defaultTextureCoordinateModifier.m_Rot[i])); - *tiling[i] = defaultTextureCoordinateModifier.m_Tiling[i]; - *offset[i] = defaultTextureCoordinateModifier.m_Offs[i]; - } - - etcgentype = defaultTextureCoordinateModifier.m_eTGType; - etcmrotatetype = defaultTextureCoordinateModifier.m_eRotType; - etcmumovetype = defaultTextureCoordinateModifier.m_eMoveType[0]; - etcmvmovetype = defaultTextureCoordinateModifier.m_eMoveType[1]; - etextype = defaultTextureResource.m_Sampler.m_eTexType; - filter = defaultTextureResource.m_Filter; - is_tcgprojected = defaultTextureCoordinateModifier.m_bTexGenProjected; - - tcmuoscrate = defaultTextureCoordinateModifier.m_OscRate[0]; - tcmvoscrate = defaultTextureCoordinateModifier.m_OscRate[1]; - - tcmuoscamplitude = defaultTextureCoordinateModifier.m_OscAmplitude[0]; - tcmvoscamplitude = defaultTextureCoordinateModifier.m_OscAmplitude[1]; - - tcmuoscphase = defaultTextureCoordinateModifier.m_OscPhase[0]; - tcmvoscphase = defaultTextureCoordinateModifier.m_OscPhase[1]; - - tcmrotoscrate = RoundDegree(Word2Degr(defaultTextureCoordinateModifier.m_RotOscRate[2])); - tcmrotoscamplitude = RoundDegree(Word2Degr(defaultTextureCoordinateModifier.m_RotOscAmplitude[2])); - tcmrotoscphase = RoundDegree(Word2Degr(defaultTextureCoordinateModifier.m_RotOscPhase[2])); - } -}; - -struct SMaterialLayerVars -{ - CSmartVariable bNoDraw; // disable layer rendering (useful in some cases) - CSmartVariable bFadeOut; // fade out layer rendering and parent rendering - CSmartVariableEnum shader; // shader layer name -}; - -struct SVertexWaveFormUI -{ - CSmartVariableArray table; - CSmartVariableEnum waveFormType; - CSmartVariable level; - CSmartVariable amplitude; - CSmartVariable phase; - CSmartVariable frequency; -}; - -////////////////////////////////////////////////////////////////////////// -struct SVertexModUI -{ - CSmartVariableEnum type; - CSmartVariable fDividerX; - CSmartVariable fDividerY; - CSmartVariable fDividerZ; - CSmartVariable fDividerW; - CSmartVariable vNoiseScale; - SVertexWaveFormUI wave; -}; - -/** User Interface definition of material. -*/ -class CMaterialUI -{ -public: - CSmartVariableEnum shader; - CSmartVariable bNoShadow; - CSmartVariable bAdditive; - CSmartVariable bWire; - CSmartVariable b2Sided; - CSmartVariable opacity; - CSmartVariable alphaTest; - CSmartVariable emissiveIntensity; - CSmartVariable voxelCoverage; - CSmartVariable heatAmount; - CSmartVariable bScatter; - CSmartVariable bHideAfterBreaking; - CSmartVariable bFogVolumeShadingQualityHigh; - CSmartVariable bBlendTerrainColor; - //CSmartVariable bTranslucenseLayer; - CSmartVariableEnum surfaceType; - - CSmartVariable allowLayerActivation; - - ////////////////////////////////////////////////////////////////////////// - // Material Value Propagation for dynamic material switches, as for instance - // used by breakable glass - ////////////////////////////////////////////////////////////////////////// - CSmartVariableEnum matPropagate; - CSmartVariable bPropagateMaterialSettings; - CSmartVariable bPropagateOpactity; - CSmartVariable bPropagateLighting; - CSmartVariable bPropagateAdvanced; - CSmartVariable bPropagateTexture; - CSmartVariable bPropagateVertexDef; - CSmartVariable bPropagateShaderParams; - CSmartVariable bPropagateLayerPresets; - CSmartVariable bPropagateShaderGenParams; - - ////////////////////////////////////////////////////////////////////////// - // Lighting - ////////////////////////////////////////////////////////////////////////// - CSmartVariable diffuse; // Diffuse color 0..1 - CSmartVariable specular; // Specular color 0..1 - CSmartVariable smoothness; // Specular shininess. - CSmartVariable emissiveCol; // Emissive color 0..1 - - ////////////////////////////////////////////////////////////////////////// - // Textures. - ////////////////////////////////////////////////////////////////////////// - CSmartVariableArray textureVars[EFTT_MAX]; - CSmartVariableArray advancedTextureGroup[EFTT_MAX]; - STextureVars textures[EFTT_MAX]; - - ////////////////////////////////////////////////////////////////////////// - // Material layers settings - ////////////////////////////////////////////////////////////////////////// - - // 8 max for now. change this later - SMaterialLayerVars materialLayers[MTL_LAYER_MAX_SLOTS]; - - ////////////////////////////////////////////////////////////////////////// - - SVertexModUI vertexMod; - - CSmartVariableArray tableShader; - CSmartVariableArray tableOpacity; - CSmartVariableArray tableLighting; - CSmartVariableArray tableTexture; - CSmartVariableArray tableAdvanced; - CSmartVariableArray tableVertexMod; - CSmartVariableArray tableEffects; - - CSmartVariableArray tableShaderParams; - CSmartVariableArray tableShaderGenParams; - - CVarEnumList* enumTexType; - CVarEnumList* enumTexGenType; - CVarEnumList* enumTexModRotateType; - CVarEnumList* enumTexModUMoveType; - CVarEnumList* enumTexModVMoveType; - CVarEnumList* enumTexFilterType; - - CVarEnumList* enumVertexMod; - CVarEnumList* enumWaveType; - - ////////////////////////////////////////////////////////////////////////// - int texUsageMask; - - CVarBlockPtr m_vars; - - typedef std::map TVarChangeNotifications; - TVarChangeNotifications m_varChangeNotifications; - - ////////////////////////////////////////////////////////////////////////// - void SetFromMaterial(CMaterial* mtl); - void SetToMaterial(CMaterial* mtl, int propagationFlags = MTL_PROPAGATE_ALL); - void SetTextureNames(CMaterial* mtl); - - void SetShaderResources(const SInputShaderResources& srTextures, bool bSetTextures = true); - void GetShaderResources(SInputShaderResources& sr, int propagationFlags); - - void SetVertexDeform(const SInputShaderResources& sr); - void GetVertexDeform(SInputShaderResources& sr, int propagationFlags); - - void PropagateFromLinkedMaterial(CMaterial* mtl); - void PropagateToLinkedMaterial(CMaterial* mtl, CVarBlockPtr pShaderParamsBlock); - void NotifyObjectsAboutMaterialChange(IVariable* var); - - - ////////////////////////////////////////////////////////////////////////// - CMaterialUI() - { - } - - ~CMaterialUI() - { - } - - ////////////////////////////////////////////////////////////////////////// - CVarBlock* CreateVars() - { - m_vars = new CVarBlock; - - ////////////////////////////////////////////////////////////////////////// - // Init enums. - ////////////////////////////////////////////////////////////////////////// - enumTexType = new CVarEnumList(); - enumTexType->AddItem("2D", eTT_2D); - enumTexType->AddItem("Cube-Map", eTT_Cube); - enumTexType->AddItem("Nearest Cube-Map probe for alpha blended", eTT_NearestCube); - enumTexType->AddItem("Dynamic 2D-Map", eTT_Dyn2D); - enumTexType->AddItem("From User Params", eTT_User); - - enumTexGenType = new CVarEnumList(); - enumTexGenType->AddItem("Stream", ETG_Stream); - enumTexGenType->AddItem("World", ETG_World); - enumTexGenType->AddItem("Camera", ETG_Camera); - - enumTexModRotateType = new CVarEnumList(); - enumTexModRotateType->AddItem("No Change", ETMR_NoChange); - enumTexModRotateType->AddItem("Fixed Rotation", ETMR_Fixed); - enumTexModRotateType->AddItem("Constant Rotation", ETMR_Constant); - enumTexModRotateType->AddItem("Oscillated Rotation", ETMR_Oscillated); - - enumTexModUMoveType = new CVarEnumList(); - enumTexModUMoveType->AddItem("No Change", ETMM_NoChange); - enumTexModUMoveType->AddItem("Fixed Moving", ETMM_Fixed); - enumTexModUMoveType->AddItem("Constant Moving", ETMM_Constant); - enumTexModUMoveType->AddItem("Jitter Moving", ETMM_Jitter); - enumTexModUMoveType->AddItem("Pan Moving", ETMM_Pan); - enumTexModUMoveType->AddItem("Stretch Moving", ETMM_Stretch); - enumTexModUMoveType->AddItem("Stretch-Repeat Moving", ETMM_StretchRepeat); - - enumTexModVMoveType = new CVarEnumList(); - enumTexModVMoveType->AddItem("No Change", ETMM_NoChange); - enumTexModVMoveType->AddItem("Fixed Moving", ETMM_Fixed); - enumTexModVMoveType->AddItem("Constant Moving", ETMM_Constant); - enumTexModVMoveType->AddItem("Jitter Moving", ETMM_Jitter); - enumTexModVMoveType->AddItem("Pan Moving", ETMM_Pan); - enumTexModVMoveType->AddItem("Stretch Moving", ETMM_Stretch); - enumTexModVMoveType->AddItem("Stretch-Repeat Moving", ETMM_StretchRepeat); - - enumTexFilterType = new CVarEnumList(); - enumTexFilterType->AddItem("Default", FILTER_NONE); - enumTexFilterType->AddItem("Point", FILTER_POINT); - enumTexFilterType->AddItem("Linear", FILTER_LINEAR); - enumTexFilterType->AddItem("Bilinear", FILTER_BILINEAR); - enumTexFilterType->AddItem("Trilinear", FILTER_TRILINEAR); - enumTexFilterType->AddItem("Anisotropic 2x", FILTER_ANISO2X); - enumTexFilterType->AddItem("Anisotropic 4x", FILTER_ANISO4X); - enumTexFilterType->AddItem("Anisotropic 8x", FILTER_ANISO8X); - enumTexFilterType->AddItem("Anisotropic 16x", FILTER_ANISO16X); - - ////////////////////////////////////////////////////////////////////////// - // Vertex Mods. - ////////////////////////////////////////////////////////////////////////// - enumVertexMod = new CVarEnumList(); - enumVertexMod->AddItem("None", eDT_Unknown); - enumVertexMod->AddItem("Sin Wave", eDT_SinWave); - enumVertexMod->AddItem("Sin Wave using vertex color", eDT_SinWaveUsingVtxColor); - enumVertexMod->AddItem("Bulge", eDT_Bulge); - enumVertexMod->AddItem("Squeeze", eDT_Squeeze); - enumVertexMod->AddItem("FixedOffset", eDT_FixedOffset); - - ////////////////////////////////////////////////////////////////////////// - - enumWaveType = new CVarEnumList(); - enumWaveType->AddItem("Sin", eWF_Sin); - - ////////////////////////////////////////////////////////////////////////// - // Fill shaders enum. - ////////////////////////////////////////////////////////////////////////// - CVarEnumList* enumShaders = new CVarEnumList(); - { - CShaderEnum* pShaderEnum = GetIEditor()->GetShaderEnum(); - pShaderEnum->EnumShaders(); - for (int i = 0; i < pShaderEnum->GetShaderCount(); i++) - { - QString shaderName = pShaderEnum->GetShader(i); - if (shaderName.contains("_Overlay", Qt::CaseInsensitive)) - { - continue; - } - enumShaders->AddItem(shaderName, shaderName); - } - } - - ////////////////////////////////////////////////////////////////////////// - // Fill surface types. - ////////////////////////////////////////////////////////////////////////// - CVarEnumList* enumSurfaceTypes = new CVarEnumList(); - { - QStringList types; - types.push_back(""); // Push empty surface type. - ISurfaceTypeEnumerator* pSurfaceTypeEnum = gEnv->p3DEngine->GetMaterialManager()->GetSurfaceTypeManager()->GetEnumerator(); - if (pSurfaceTypeEnum) - { - for (ISurfaceType* pSurfaceType = pSurfaceTypeEnum->GetFirst(); pSurfaceType; pSurfaceType = pSurfaceTypeEnum->GetNext()) - { - types.push_back(pSurfaceType->GetName()); - } - std::sort(types.begin(), types.end()); - for (int i = 0; i < types.size(); i++) - { - QString name = types[i]; - if (name.left(4) == "mat_") - { - name.remove(0, 4); - } - enumSurfaceTypes->AddItem(name, types[i]); - } - } - } - - ////////////////////////////////////////////////////////////////////////// - // Init tables. - ////////////////////////////////////////////////////////////////////////// - AddVariable(m_vars, tableShader, "Material Settings", ""); - AddVariable(m_vars, tableOpacity, "Opacity Settings", ""); - AddVariable(m_vars, tableLighting, "Lighting Settings", ""); - AddVariable(m_vars, tableAdvanced, "Advanced", ""); - AddVariable(m_vars, tableTexture, "Texture Maps", ""); - AddVariable(m_vars, tableShaderParams, "Shader Params", ""); - AddVariable(m_vars, tableShaderGenParams, "Shader Generation Params", ""); - AddVariable(m_vars, tableVertexMod, "Vertex Deformation", ""); - - tableTexture->SetFlags(tableTexture->GetFlags() | IVariable::UI_ROLLUP2); - tableVertexMod->SetFlags(tableVertexMod->GetFlags() | IVariable::UI_ROLLUP2 | IVariable::UI_COLLAPSED); - tableAdvanced->SetFlags(tableAdvanced->GetFlags() | IVariable::UI_COLLAPSED); - tableShaderGenParams->SetFlags(tableShaderGenParams->GetFlags() | IVariable::UI_ROLLUP2 | IVariable::UI_COLLAPSED); - tableShaderParams->SetFlags(tableShaderParams->GetFlags() | IVariable::UI_ROLLUP2); - - - ////////////////////////////////////////////////////////////////////////// - // Shader. - ////////////////////////////////////////////////////////////////////////// - AddVariable(tableShader, shader, "Shader", "Selects shader type for specific surface response and options"); - AddVariable(tableShader, surfaceType, "Surface Type", "Defines how entities interact with surfaces using the material effects system"); - m_varChangeNotifications["Surface Type"] = MATERIALCHANGE_SURFACETYPE; - - shader->SetEnumList(enumShaders); - - surfaceType->SetEnumList(enumSurfaceTypes); - - // Properties that use this scriptingDescription are based on what's available in MaterialHelpers::SetGetMaterialParamVec3 and MaterialHelpers::SetGetMaterialParamFloat. - // This should match what's done in MaterialHelpers.cpp AddRealNameToDescription(). - auto scriptingDescription = [](const AZStd::string& scriptAccessibleName, const AZStd::string& description) { return description + "\n(Script Param Name = " + scriptAccessibleName + ")"; }; - - ////////////////////////////////////////////////////////////////////////// - // Opacity. - ////////////////////////////////////////////////////////////////////////// - AddVariable(tableOpacity, opacity, "Opacity", - scriptingDescription("opacity", "Sets the transparency amount. Uses 0-99 to set Alpha Blend and 100 for Opaque and Alpha Test.").c_str(), IVariable::DT_PERCENT); - AddVariable(tableOpacity, alphaTest, "AlphaTest", - scriptingDescription("alpha", "Uses the alpha mask and refines the transparent edge. Uses 0-50 to bias toward white or 50-100 to bias toward black.").c_str(), IVariable::DT_PERCENT); - AddVariable(tableOpacity, bAdditive, "Additive", "Adds material color to the background color resulting in a brighter transparent surface"); - opacity->SetLimits(0, 100, 1, true, true); - alphaTest->SetLimits(0, 100, 1, true, true); - - ////////////////////////////////////////////////////////////////////////// - // Lighting. - ////////////////////////////////////////////////////////////////////////// - AddVariable(tableLighting, diffuse, "Diffuse Color (Tint)", scriptingDescription("diffuse", "Tints the material diffuse color. Physically based materials should be left at white").c_str(), IVariable::DT_COLOR); - AddVariable(tableLighting, specular, "Specular Color", scriptingDescription("specular", "Reflective and shininess intensity and color of reflective highlights").c_str(), IVariable::DT_COLOR); - AddVariable(tableLighting, smoothness, "Smoothness", scriptingDescription("shininess", "Smoothness or glossiness simulating how light bounces off the surface").c_str()); - AddVariable(tableLighting, emissiveIntensity, "Emissive Intensity (kcd/m2)", scriptingDescription("emissive_intensity", "Brightness simulating light emitting from the surface making an object glow").c_str()); - AddVariable(tableLighting, emissiveCol, "Emissive Color", scriptingDescription("emissive_color", "Tints the emissive color").c_str(), IVariable::DT_COLOR); - emissiveIntensity->SetLimits(0, EMISSIVE_INTENSITY_SOFT_MAX, 1, true, false); - smoothness->SetLimits(0, 255, 1, true, true); - - ////////////////////////////////////////////////////////////////////////// - // Init texture variables. - ////////////////////////////////////////////////////////////////////////// - for (EEfResTextures texId = EEfResTextures(0); texId < EFTT_MAX; texId = EEfResTextures(texId + 1)) - { - if (!MaterialHelpers::IsAdjustableTexSlot(texId)) - { - continue; - } - - InitTextureVars(texId, MaterialHelpers::LookupTexName(texId), MaterialHelpers::LookupTexDesc(texId)); - } - - //AddVariable( tableAdvanced,bWire,"Wireframe" ); - AddVariable(tableAdvanced, allowLayerActivation, "Allow layer activation", ""); - AddVariable(tableAdvanced, b2Sided, "2 Sided", "Enables both sides of mesh faces to render"); - AddVariable(tableAdvanced, bNoShadow, "No Shadow", "Disables casting shadows from mesh faces"); - AddVariable(tableAdvanced, bScatter, "Use Scattering", "Deprecated"); - AddVariable(tableAdvanced, bHideAfterBreaking, "Hide After Breaking", "Causes the object to disappear after procedurally breaking"); - AddVariable(tableAdvanced, bFogVolumeShadingQualityHigh, "Fog Volume Shading Quality High", "high fog volume shading quality behaves more accurately with fog volumes."); - AddVariable(tableAdvanced, bBlendTerrainColor, "Blend Terrain Color", ""); - AddVariable(tableAdvanced, voxelCoverage, "Voxel Coverage", "Fine tunes occlusion amount for svogi feature. Higher values occlude more closely to object shape."); - voxelCoverage->SetLimits(0, 1.0f); - - ////////////////////////////////////////////////////////////////////////// - // Material Value Propagation for dynamic material switches, as for instance - // used by breakable glass - ////////////////////////////////////////////////////////////////////////// - AddVariable(tableAdvanced, matPropagate, "Link to Material", ""); - AddVariable(tableAdvanced, bPropagateMaterialSettings, "Propagate Material Settings", ""); - AddVariable(tableAdvanced, bPropagateOpactity, "Propagate Opacity Settings", ""); - AddVariable(tableAdvanced, bPropagateLighting, "Propagate Lighting Settings", ""); - AddVariable(tableAdvanced, bPropagateAdvanced, "Propagate Advanced Settings", ""); - AddVariable(tableAdvanced, bPropagateTexture, "Propagate Texture Maps", ""); - AddVariable(tableAdvanced, bPropagateShaderParams, "Propagate Shader Params", ""); - AddVariable(tableAdvanced, bPropagateShaderGenParams, "Propagate Shader Generation", ""); - AddVariable(tableAdvanced, bPropagateVertexDef, "Propagate Vertex Deformation", ""); - - ////////////////////////////////////////////////////////////////////////// - // Init Vertex Deformation. - ////////////////////////////////////////////////////////////////////////// - vertexMod.type->SetEnumList(enumVertexMod); - AddVariable(tableVertexMod, vertexMod.type, "Type", "Choose method to define how the vertices will deform"); - AddVariable(tableVertexMod, vertexMod.fDividerX, "Wave Length", "Length of wave deformation"); - - AddVariable(tableVertexMod, vertexMod.wave.table, "Parameters", "Fine tunes how the vertices deform"); - - vertexMod.wave.waveFormType->SetEnumList(enumWaveType); - AddVariable(vertexMod.wave.table, vertexMod.wave.waveFormType, "Type", "Sin type will include vertex color in calculation"); - AddVariable(vertexMod.wave.table, vertexMod.wave.level, "Level", "Scales the object equally in xyz"); - AddVariable(vertexMod.wave.table, vertexMod.wave.amplitude, "Amplitude", "Strength of vertex deformation (vertex color: b, normal: z)"); - AddVariable(vertexMod.wave.table, vertexMod.wave.phase, "Phase", "Offset of vertex deformation (vertex color: r, normal: x)"); - AddVariable(vertexMod.wave.table, vertexMod.wave.frequency, "Frequency", "Speed of vertex animation (vertex color: g, normal: y)"); - - return m_vars; - } - -private: - ////////////////////////////////////////////////////////////////////////// - void InitTextureVars(int id, const QString& name, const QString& desc) - { - textureVars[id]->SetFlags(IVariable::UI_BOLD); - textureVars[id]->SetFlags(textureVars[id]->GetFlags() | IVariable::UI_AUTO_EXPAND); - advancedTextureGroup[id]->SetFlags(advancedTextureGroup[id]->GetFlags() | IVariable::UI_COLLAPSED); - AddVariable(tableTexture, *textureVars[id], name.toUtf8().data(), desc.toUtf8().data(), IVariable::DT_TEXTURE); - AddVariable(*textureVars[id], *advancedTextureGroup[id], "Advanced", "Controls UV tiling, offset, and rotation as well as texture filtering"); - - AddVariable(*advancedTextureGroup[id], textures[id].etextype, "TexType", ""); - AddVariable(*advancedTextureGroup[id], textures[id].filter, "Filter", "Sets texture smoothing method to determine texture pixel quality"); - - AddVariable(*advancedTextureGroup[id], textures[id].is_tcgprojected, "IsProjectedTexGen", ""); - AddVariable(*advancedTextureGroup[id], textures[id].etcgentype, "TexGenType", "Controls UV projection behavior"); - - if (IsTextureModifierSupportedForTextureMap(static_cast(id))) - { - ////////////////////////////////////////////////////////////////////////// - // Tiling table. - AddVariable(*advancedTextureGroup[id], textures[id].tableTiling, "Tiling", "Controls UV tiling, offset, and rotation"); - { - CVariableArray& table = textures[id].tableTiling; - table.SetFlags(IVariable::UI_BOLD); - AddVariable(table, *textures[id].is_tile[0], "IsTileU", "Enables UV tiling on U"); - AddVariable(table, *textures[id].is_tile[1], "IsTileV", "Enables UV tiling on V"); - AddVariable(table, *textures[id].tiling[0], "TileU", "Multiplies tiled projection on U"); - AddVariable(table, *textures[id].tiling[1], "TileV", "Multiplies tiled projection on V"); - AddVariable(table, *textures[id].offset[0], "OffsetU", "Offsets texture projection on U"); - AddVariable(table, *textures[id].offset[1], "OffsetV", "Offsets texture projection on V"); - AddVariable(table, *textures[id].rotate[0], "RotateU", "Rotates texture projection on U"); - AddVariable(table, *textures[id].rotate[1], "RotateV", "Rotates texture projection on V"); - AddVariable(table, *textures[id].rotate[2], "RotateW", "Rotates texture projection on W"); - } - - ////////////////////////////////////////////////////////////////////////// - // Rotator tables. - AddVariable(*advancedTextureGroup[id], textures[id].tableRotator, "Rotator", "Controls the animated UV rotation"); - { - CVariableArray& table = textures[id].tableRotator; - table.SetFlags(IVariable::UI_BOLD); - AddVariable(table, textures[id].etcmrotatetype, "Type", "Controls the behavior of UV rotation"); - AddVariable(table, textures[id].tcmrotoscrate, "Rate", "Sets the speed (number of complete cycles per unit of time) of rotation"); - AddVariable(table, textures[id].tcmrotoscphase, "Phase", "Sets the initial offset of rotation"); - AddVariable(table, textures[id].tcmrotoscamplitude, "Amplitude", "Sets the strength (maximum value) of rotation"); - AddVariable(table, *textures[id].tcmrotosccenter[0], "CenterU", "Sets the center of rotation along U"); - AddVariable(table, *textures[id].tcmrotosccenter[1], "CenterV", "Sets the center of rotation along V"); - } - - ////////////////////////////////////////////////////////////////////////// - // Oscillator table - AddVariable(*advancedTextureGroup[id], textures[id].tableOscillator, "Oscillator", "Controls the animated UV oscillation"); - { - CVariableArray& table = textures[id].tableOscillator; - table.SetFlags(IVariable::UI_BOLD); - AddVariable(table, textures[id].etcmumovetype, "TypeU", "Sets the behavior of oscillation in the U direction"); - AddVariable(table, textures[id].etcmvmovetype, "TypeV", "Sets the behavior of oscillation in the V direction"); - AddVariable(table, textures[id].tcmuoscrate, "RateU", "Sets the speed (number of complete cycles per unit of time) of oscillation in U"); - AddVariable(table, textures[id].tcmvoscrate, "RateV", "Sets the speed (number of complete cycles per unit of time) of oscillation in V"); - AddVariable(table, textures[id].tcmuoscphase, "PhaseU", "Sets the initial offset of oscillation in U"); - AddVariable(table, textures[id].tcmvoscphase, "PhaseV", "Sets the initial offset of oscillation in V"); - AddVariable(table, textures[id].tcmuoscamplitude, "AmplitudeU", "Sets the strength (maximum value) of oscillation in U"); - AddVariable(table, textures[id].tcmvoscamplitude, "AmplitudeV", "Sets the strength (maximum value) of oscillation in V"); - } - } - - ////////////////////////////////////////////////////////////////////////// - // Assign enums tables to variable. - ////////////////////////////////////////////////////////////////////////// - textures[id].etextype->SetEnumList(enumTexType); - textures[id].etcgentype->SetEnumList(enumTexGenType); - textures[id].etcmrotatetype->SetEnumList(enumTexModRotateType); - textures[id].etcmumovetype->SetEnumList(enumTexModUMoveType); - textures[id].etcmvmovetype->SetEnumList(enumTexModVMoveType); - textures[id].filter->SetEnumList(enumTexFilterType); - } - ////////////////////////////////////////////////////////////////////////// - - void AddVariable(CVariableBase& varArray, CVariableBase& var, const char* varName, const char* varTooltip, unsigned char dataType = IVariable::DT_SIMPLE) - { - if (varName) - { - var.SetName(varName); - } - if (varTooltip) - { - var.SetDescription(varTooltip); - } - var.SetDataType(dataType); - varArray.AddVariable(&var); - } - ////////////////////////////////////////////////////////////////////////// - void AddVariable(CVarBlock* vars, CVariableBase& var, const char* varName, const char* varTooltip, unsigned char dataType = IVariable::DT_SIMPLE) - { - if (varName) - { - var.SetName(varName); - } - if (varTooltip) - { - var.SetDescription(varTooltip); - } - var.SetDataType(dataType); - vars->AddVariable(&var); - } - - void SetTextureResources(const SEfResTexture *pTextureRes, uint16 tex, bool bSetTextures); - void GetTextureResources(SInputShaderResources& sr, int texid, int propagationFlags); - void ResetTextureResources(uint16 tex); - Vec4 ToVec4(const ColorF& col) { return Vec4(col.r, col.g, col.b, col.a); } - Vec3 ToVec3(const ColorF& col) { return Vec3(col.r, col.g, col.b); } - ColorF ToCFColor(const Vec3& col) { return ColorF(col); } - ColorF ToCFColor(const Vec4& col) { return ColorF(col); } -}; - -////////////////////////////////////////////////////////////////////////// -void CMaterialUI::NotifyObjectsAboutMaterialChange(IVariable* var) -{ - if (!var) - { - return; - } - - TVarChangeNotifications::iterator it = m_varChangeNotifications.find(var->GetName()); - if (it == m_varChangeNotifications.end()) - { - return; - } - - CMaterial* pMaterial = GetIEditor()->GetMaterialManager()->GetCurrentMaterial(); - if (!pMaterial) - { - return; - } - - // Get a parent, if we are editing submaterial - if (pMaterial->GetParent() != 0) - { - pMaterial = pMaterial->GetParent(); - } - - CBaseObjectsArray objects; - GetIEditor()->GetObjectManager()->GetObjects(objects); - int numObjects = objects.size(); - for (int i = 0; i < numObjects; ++i) - { - CBaseObject* pObject = objects[i]; - if (pObject->GetRenderMaterial() == pMaterial) - { - pObject->OnMaterialChanged(it->second); - } - } -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialUI::SetShaderResources(const SInputShaderResources& srTextures, bool bSetTextures) -{ - alphaTest = srTextures.m_AlphaRef; - voxelCoverage = (float) srTextures.m_VoxelCoverage / 255.0f; - - diffuse = ToVec3(srTextures.m_LMaterial.m_Diffuse); - specular = ToVec3(srTextures.m_LMaterial.m_Specular); - emissiveCol = ToVec3(srTextures.m_LMaterial.m_Emittance); - emissiveIntensity = srTextures.m_LMaterial.m_Emittance.a; - opacity = srTextures.m_LMaterial.m_Opacity; - smoothness = srTextures.m_LMaterial.m_Smoothness; - - SetVertexDeform(srTextures); - - - for (EEfResTextures texId = EEfResTextures(0); texId < EFTT_MAX; texId = EEfResTextures(texId + 1)) - { - if (!MaterialHelpers::IsAdjustableTexSlot(texId)) - { - continue; - } - - auto foundIter = srTextures.m_TexturesResourcesMap.find((ResourceSlotIndex)texId); - if (foundIter != srTextures.m_TexturesResourcesMap.end()) - { - const SEfResTexture* pTextureRes = const_cast(&foundIter->second); - SetTextureResources(pTextureRes, texId, bSetTextures); - } - else - { - ResetTextureResources(texId); - } - } -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialUI::GetShaderResources(SInputShaderResources& sr, int propagationFlags) -{ - if (propagationFlags & MTL_PROPAGATE_OPACITY) - { - sr.m_LMaterial.m_Opacity = opacity; - sr.m_AlphaRef = alphaTest; - } - - if (propagationFlags & MTL_PROPAGATE_ADVANCED) - { - sr.m_VoxelCoverage = int_round(voxelCoverage * 255.0f); - } - - if (propagationFlags & MTL_PROPAGATE_LIGHTING) - { - sr.m_LMaterial.m_Diffuse = ToCFColor(diffuse); - sr.m_LMaterial.m_Specular = ToCFColor(specular); - sr.m_LMaterial.m_Emittance = ColorF(emissiveCol, emissiveIntensity); - sr.m_LMaterial.m_Smoothness = smoothness; - } - - GetVertexDeform(sr, propagationFlags); - - for (EEfResTextures texId = EEfResTextures(0); texId < EFTT_MAX; texId = EEfResTextures(texId + 1)) - { - if (!MaterialHelpers::IsAdjustableTexSlot(texId)) - { - continue; - } - - GetTextureResources(sr, texId, propagationFlags); - } -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialUI::SetTextureResources( const SEfResTexture *pTextureRes, uint16 texSlot, bool bSetTextures) -{ - /* - // Enable/Disable texture map, depending on the mask. - int flags = textureVars[tex].GetFlags(); - if ((1 << tex) & texUsageMask) - flags &= ~IVariable::UI_DISABLED; - else - flags |= IVariable::UI_DISABLED; - textureVars[tex].SetFlags( flags ); - */ - - if (bSetTextures) - { - QString texFilename = pTextureRes->m_Name.c_str(); - texFilename = Path::ToUnixPath(texFilename); - textureVars[texSlot]->Set(texFilename); - } - - //textures[tex].amount = pTextureRes->m_Amount; - *textures[texSlot].is_tile[0] = pTextureRes->m_bUTile; - *textures[texSlot].is_tile[1] = pTextureRes->m_bVTile; - - *textures[texSlot].tiling[0] = pTextureRes->GetTiling(0); - *textures[texSlot].tiling[1] = pTextureRes->GetTiling(1); - *textures[texSlot].offset[0] = pTextureRes->GetOffset(0); - *textures[texSlot].offset[1] = pTextureRes->GetOffset(1); - textures[texSlot].filter = (int)pTextureRes->m_Filter; - textures[texSlot].etextype = pTextureRes->m_Sampler.m_eTexType; - - if (pTextureRes->m_Ext.m_pTexModifier) - { - textures[texSlot].etcgentype = pTextureRes->m_Ext.m_pTexModifier->m_eTGType; - textures[texSlot].etcmumovetype = pTextureRes->m_Ext.m_pTexModifier->m_eMoveType[0]; - textures[texSlot].etcmvmovetype = pTextureRes->m_Ext.m_pTexModifier->m_eMoveType[1]; - textures[texSlot].etcmrotatetype = pTextureRes->m_Ext.m_pTexModifier->m_eRotType; - textures[texSlot].is_tcgprojected = pTextureRes->m_Ext.m_pTexModifier->m_bTexGenProjected; - textures[texSlot].tcmuoscrate = pTextureRes->m_Ext.m_pTexModifier->m_OscRate[0]; - textures[texSlot].tcmuoscphase = pTextureRes->m_Ext.m_pTexModifier->m_OscPhase[0]; - textures[texSlot].tcmuoscamplitude = pTextureRes->m_Ext.m_pTexModifier->m_OscAmplitude[0]; - textures[texSlot].tcmvoscrate = pTextureRes->m_Ext.m_pTexModifier->m_OscRate[1]; - textures[texSlot].tcmvoscphase = pTextureRes->m_Ext.m_pTexModifier->m_OscPhase[1]; - textures[texSlot].tcmvoscamplitude = pTextureRes->m_Ext.m_pTexModifier->m_OscAmplitude[1]; - - for (int i = 0; i < 3; i++) - { - *textures[texSlot].rotate[i] = RoundDegree(Word2Degr(pTextureRes->m_Ext.m_pTexModifier->m_Rot[i])); - } - textures[texSlot].tcmrotoscrate = RoundDegree(Word2Degr(pTextureRes->m_Ext.m_pTexModifier->m_RotOscRate[2])); - textures[texSlot].tcmrotoscphase = RoundDegree(Word2Degr(pTextureRes->m_Ext.m_pTexModifier->m_RotOscPhase[2])); - textures[texSlot].tcmrotoscamplitude = RoundDegree(Word2Degr(pTextureRes->m_Ext.m_pTexModifier->m_RotOscAmplitude[2])); - *textures[texSlot].tcmrotosccenter[0] = pTextureRes->m_Ext.m_pTexModifier->m_RotOscCenter[0]; - *textures[texSlot].tcmrotosccenter[1] = pTextureRes->m_Ext.m_pTexModifier->m_RotOscCenter[1]; - } - else - { - textures[texSlot].etcgentype = 0; - textures[texSlot].etcmumovetype = 0; - textures[texSlot].etcmvmovetype = 0; - textures[texSlot].etcmrotatetype = 0; - textures[texSlot].is_tcgprojected = false; - textures[texSlot].tcmuoscrate = 0; - textures[texSlot].tcmuoscphase = 0; - textures[texSlot].tcmuoscamplitude = 0; - textures[texSlot].tcmvoscrate = 0; - textures[texSlot].tcmvoscphase = 0; - textures[texSlot].tcmvoscamplitude = 0; - - for (int i = 0; i < 3; i++) - { - *textures[texSlot].rotate[i] = 0; - } - - textures[texSlot].tcmrotoscrate = 0; - textures[texSlot].tcmrotoscphase = 0; - textures[texSlot].tcmrotoscamplitude = 0; - *textures[texSlot].tcmrotosccenter[0] = 0; - *textures[texSlot].tcmrotosccenter[1] = 0; - } -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialUI::ResetTextureResources(uint16 texSlot) -{ - QString texFilename = ""; - textureVars[texSlot]->Set(texFilename); - textures[texSlot].Reset(); -} - -void CMaterialUI::GetTextureResources(SInputShaderResources& sr, int tex, int propagationFlags) -{ - if ((propagationFlags & MTL_PROPAGATE_TEXTURES) == 0) - { - return; - } - - QString texFilename; - textureVars[tex]->Get(texFilename); - if (texFilename.isEmpty()) - { - // Remove the texture if the path was cleared in the UI - sr.m_TexturesResourcesMap.erase(tex); - - // If the normal map/second normal map has been cleared in the UI, - // we must also clear the smoothness/second smoothness since smoothness lives in the alpha of the normal - if (tex == EFTT_NORMALS) - { - sr.m_TexturesResourcesMap.erase(EFTT_SMOOTHNESS); - } - // EFTT_CUSTOM_SECONDARY is the 2nd normal - if (tex == EFTT_CUSTOM_SECONDARY) - { - sr.m_TexturesResourcesMap.erase(EFTT_SECOND_SMOOTHNESS); - } - return; - } - texFilename = Path::ToUnixPath(texFilename); - - // Clear any texture resource that has no associated file - if (texFilename.size() > AZ_MAX_PATH_LEN) - { - AZ_Error("Material Editor", false, "Texture path exceeds the maximium allowable length of %d.", AZ_MAX_PATH_LEN); - return; - } - - // The following line will insert the slot if did not exist. - SEfResTexture* pTextureRes = &(sr.m_TexturesResourcesMap[tex]); - pTextureRes->m_Name = texFilename.toUtf8().data(); - - //pTextureRes->m_Amount = textures[tex].amount; - pTextureRes->m_bUTile = *textures[tex].is_tile[0]; - pTextureRes->m_bVTile = *textures[tex].is_tile[1]; - SEfTexModificator& texm = *pTextureRes->AddModificator(); - texm.m_bTexGenProjected = textures[tex].is_tcgprojected; - - texm.m_Tiling[0] = *textures[tex].tiling[0]; - texm.m_Tiling[1] = *textures[tex].tiling[1]; - texm.m_Offs[0] = *textures[tex].offset[0]; - texm.m_Offs[1] = *textures[tex].offset[1]; - pTextureRes->m_Filter = (int)textures[tex].filter; - pTextureRes->m_Sampler.m_eTexType = textures[tex].etextype; - texm.m_eRotType = textures[tex].etcmrotatetype; - texm.m_eTGType = textures[tex].etcgentype; - texm.m_eMoveType[0] = textures[tex].etcmumovetype; - texm.m_eMoveType[1] = textures[tex].etcmvmovetype; - texm.m_OscRate[0] = textures[tex].tcmuoscrate; - texm.m_OscPhase[0] = textures[tex].tcmuoscphase; - texm.m_OscAmplitude[0] = textures[tex].tcmuoscamplitude; - texm.m_OscRate[1] = textures[tex].tcmvoscrate; - texm.m_OscPhase[1] = textures[tex].tcmvoscphase; - texm.m_OscAmplitude[1] = textures[tex].tcmvoscamplitude; - - for (int i = 0; i < 3; i++) - { - texm.m_Rot[i] = Degr2Word(*textures[tex].rotate[i]); - } - texm.m_RotOscRate[2] = Degr2Word(textures[tex].tcmrotoscrate); - texm.m_RotOscPhase[2] = Degr2Word(textures[tex].tcmrotoscphase); - texm.m_RotOscAmplitude[2] = Degr2Word(textures[tex].tcmrotoscamplitude); - texm.m_RotOscCenter[0] = *textures[tex].tcmrotosccenter[0]; - texm.m_RotOscCenter[1] = *textures[tex].tcmrotosccenter[1]; - texm.m_RotOscCenter[2] = 0.0f; -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialUI::SetVertexDeform(const SInputShaderResources& sr) -{ - vertexMod.type = (int)sr.m_DeformInfo.m_eType; - vertexMod.fDividerX = sr.m_DeformInfo.m_fDividerX; - vertexMod.vNoiseScale = sr.m_DeformInfo.m_vNoiseScale; - - vertexMod.wave.waveFormType = EWaveForm::eWF_Sin; - vertexMod.wave.amplitude = sr.m_DeformInfo.m_WaveX.m_Amp; - vertexMod.wave.level = sr.m_DeformInfo.m_WaveX.m_Level; - vertexMod.wave.phase = sr.m_DeformInfo.m_WaveX.m_Phase; - vertexMod.wave.frequency = sr.m_DeformInfo.m_WaveX.m_Freq; -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialUI::GetVertexDeform(SInputShaderResources& sr, int propagationFlags) -{ - if ((propagationFlags & MTL_PROPAGATE_VERTEX_DEF) == 0) - { - return; - } - - sr.m_DeformInfo.m_eType = (EDeformType)((int)vertexMod.type); - sr.m_DeformInfo.m_fDividerX = vertexMod.fDividerX; - sr.m_DeformInfo.m_vNoiseScale = vertexMod.vNoiseScale; - - sr.m_DeformInfo.m_WaveX.m_eWFType = (EWaveForm)((int)vertexMod.wave.waveFormType); - sr.m_DeformInfo.m_WaveX.m_Amp = vertexMod.wave.amplitude; - sr.m_DeformInfo.m_WaveX.m_Level = vertexMod.wave.level; - sr.m_DeformInfo.m_WaveX.m_Phase = vertexMod.wave.phase; - sr.m_DeformInfo.m_WaveX.m_Freq = vertexMod.wave.frequency; -} - -void CMaterialUI::PropagateToLinkedMaterial(CMaterial* mtl, CVarBlockPtr pShaderParams) -{ - if (!mtl) - { - return; - } - CMaterial* subMtl = NULL, * parentMtl = mtl->GetParent(); - const QString& linkedMaterialName = matPropagate; - int propFlags = 0; - - if (parentMtl) - { - for (int i = 0; i < parentMtl->GetSubMaterialCount(); ++i) - { - CMaterial* pMtl = parentMtl->GetSubMaterial(i); - if (pMtl && pMtl != mtl && pMtl->GetFullName() == linkedMaterialName) - { - subMtl = pMtl; - break; - } - } - } - if (!linkedMaterialName.isEmpty() && subMtl) - { - // Ensure that the linked material is cleared if it can't be found anymore - mtl->LinkToMaterial(linkedMaterialName); - } - // Note: It's only allowed to propagate the shader params and shadergen params - // if we also propagate the actual shader to the linked material as well, else - // bogus values will be set - bPropagateShaderParams = (int)bPropagateShaderParams & - (int)bPropagateMaterialSettings; - bPropagateShaderGenParams = (int)bPropagateShaderGenParams & - (int)bPropagateMaterialSettings; - - propFlags |= MTL_PROPAGATE_MATERIAL_SETTINGS & - (int)bPropagateMaterialSettings; - propFlags |= MTL_PROPAGATE_OPACITY & - (int)bPropagateOpactity; - propFlags |= MTL_PROPAGATE_LIGHTING & - (int)bPropagateLighting; - propFlags |= MTL_PROPAGATE_ADVANCED & - (int)bPropagateAdvanced; - propFlags |= MTL_PROPAGATE_TEXTURES & - (int)bPropagateTexture; - propFlags |= MTL_PROPAGATE_SHADER_PARAMS & - (int)bPropagateShaderParams; - propFlags |= MTL_PROPAGATE_SHADER_GEN & - (int)bPropagateShaderGenParams; - propFlags |= MTL_PROPAGATE_VERTEX_DEF & - (int)bPropagateVertexDef; - propFlags |= MTL_PROPAGATE_LAYER_PRESETS & - (int)bPropagateLayerPresets; - mtl->SetPropagationFlags(propFlags); - - if (subMtl) - { - SetToMaterial(subMtl, propFlags | MTL_PROPAGATE_RESERVED); - if (propFlags & MTL_PROPAGATE_SHADER_PARAMS) - { - if (CVarBlock* pPublicVars = subMtl->GetPublicVars(mtl->GetShaderResources())) - { - subMtl->SetPublicVars(pPublicVars, subMtl); - } - } - if (propFlags & MTL_PROPAGATE_SHADER_GEN) - { - subMtl->SetShaderGenParamsVars(mtl->GetShaderGenParamsVars()); - } - subMtl->Update(); - subMtl->UpdateMaterialLayers(); - } -} - -void CMaterialUI::PropagateFromLinkedMaterial(CMaterial* mtl) -{ - if (!mtl) - { - return; - } - CMaterial* subMtl = NULL, * parentMtl = mtl->GetParent(); - const QString& linkedMaterialName = mtl->GetLinkedMaterialName(); - //CVarEnumList *enumMtls = new CVarEnumList; - if (parentMtl) - { - for (int i = 0; i < parentMtl->GetSubMaterialCount(); ++i) - { - CMaterial* pMtl = parentMtl->GetSubMaterial(i); - if (!pMtl || pMtl == mtl) - { - continue; - } - const QString& subMtlName = pMtl->GetFullName(); - //enumMtls->AddItem(subMtlName, subMtlName); - if (subMtlName == linkedMaterialName) - { - subMtl = pMtl; - break; - } - } - } - matPropagate = QString(); - //matPropagate.SetEnumList(enumMtls); - if (!linkedMaterialName.isEmpty() && !subMtl) - { - // Ensure that the linked material is cleared if it can't be found anymore - mtl->LinkToMaterial(QString()); - } - else - { - matPropagate = linkedMaterialName; - } - bPropagateMaterialSettings = mtl->GetPropagationFlags() & MTL_PROPAGATE_MATERIAL_SETTINGS; - bPropagateOpactity = mtl->GetPropagationFlags() & MTL_PROPAGATE_OPACITY; - bPropagateLighting = mtl->GetPropagationFlags() & MTL_PROPAGATE_LIGHTING; - bPropagateTexture = mtl->GetPropagationFlags() & MTL_PROPAGATE_TEXTURES; - bPropagateAdvanced = mtl->GetPropagationFlags() & MTL_PROPAGATE_ADVANCED; - bPropagateVertexDef = mtl->GetPropagationFlags() & MTL_PROPAGATE_VERTEX_DEF; - bPropagateShaderParams = mtl->GetPropagationFlags() & MTL_PROPAGATE_SHADER_PARAMS; - bPropagateLayerPresets = mtl->GetPropagationFlags() & MTL_PROPAGATE_LAYER_PRESETS; - bPropagateShaderGenParams = mtl->GetPropagationFlags() & MTL_PROPAGATE_SHADER_GEN; -} - -void CMaterialUI::SetFromMaterial(CMaterial* mtlIn) -{ - QString shaderName = mtlIn->GetShaderName(); - if (!shaderName.isEmpty()) - { - // Capitalize first letter. - shaderName = shaderName[0].toUpper() + shaderName.mid(1); - } - - shader = shaderName; - - int mtlFlags = mtlIn->GetFlags(); - bNoShadow = (mtlFlags & MTL_FLAG_NOSHADOW); - bAdditive = (mtlFlags & MTL_FLAG_ADDITIVE); - bWire = (mtlFlags & MTL_FLAG_WIRE); - b2Sided = (mtlFlags & MTL_FLAG_2SIDED); - bScatter = (mtlFlags & MTL_FLAG_SCATTER); - bHideAfterBreaking = (mtlFlags & MTL_FLAG_HIDEONBREAK); - bFogVolumeShadingQualityHigh = (mtlFlags & MTL_FLAG_FOG_VOLUME_SHADING_QUALITY_HIGH); - bBlendTerrainColor = (mtlFlags & MTL_FLAG_BLEND_TERRAIN); - texUsageMask = mtlIn->GetTexmapUsageMask(); - - allowLayerActivation = mtlIn->LayerActivationAllowed(); - - // Detail, decal and custom textures are always active. - const uint32 nDefaultFlagsEFTT = (1 << EFTT_DETAIL_OVERLAY) | (1 << EFTT_DECAL_OVERLAY) | (1 << EFTT_CUSTOM) | (1 << EFTT_CUSTOM_SECONDARY); - texUsageMask |= nDefaultFlagsEFTT; - if ((texUsageMask & (1 << EFTT_NORMALS))) - { - texUsageMask |= 1 << EFTT_NORMALS; - } - - surfaceType = mtlIn->GetSurfaceTypeName(); - SetShaderResources(mtlIn->GetShaderResources(), true); - - // Propagate settings and properties to a sub material if edited - PropagateFromLinkedMaterial(mtlIn); - - // set each material layer - SMaterialLayerResources* pMtlLayerResources = mtlIn->GetMtlLayerResources(); - for (int l(0); l < MTL_LAYER_MAX_SLOTS; ++l) - { - materialLayers[l].shader = pMtlLayerResources[l].m_shaderName; - materialLayers[l].bNoDraw = pMtlLayerResources[l].m_nFlags & MTL_LAYER_USAGE_NODRAW; - materialLayers[l].bFadeOut = pMtlLayerResources[l].m_nFlags & MTL_LAYER_USAGE_FADEOUT; - } -} - -void CMaterialUI::SetToMaterial(CMaterial* mtl, int propagationFlags) -{ - int mtlFlags = mtl->GetFlags(); - - if (propagationFlags & MTL_PROPAGATE_ADVANCED) - { - if (bNoShadow) - { - mtlFlags |= MTL_FLAG_NOSHADOW; - } - else - { - mtlFlags &= ~MTL_FLAG_NOSHADOW; - } - } - - if (propagationFlags & MTL_PROPAGATE_OPACITY) - { - if (bAdditive) - { - mtlFlags |= MTL_FLAG_ADDITIVE; - } - else - { - mtlFlags &= ~MTL_FLAG_ADDITIVE; - } - } - - if (bWire) - { - mtlFlags |= MTL_FLAG_WIRE; - } - else - { - mtlFlags &= ~MTL_FLAG_WIRE; - } - - if (propagationFlags & MTL_PROPAGATE_ADVANCED) - { - if (b2Sided) - { - mtlFlags |= MTL_FLAG_2SIDED; - } - else - { - mtlFlags &= ~MTL_FLAG_2SIDED; - } - - if (bScatter) - { - mtlFlags |= MTL_FLAG_SCATTER; - } - else - { - mtlFlags &= ~MTL_FLAG_SCATTER; - } - - if (bHideAfterBreaking) - { - mtlFlags |= MTL_FLAG_HIDEONBREAK; - } - else - { - mtlFlags &= ~MTL_FLAG_HIDEONBREAK; - } - - if (bFogVolumeShadingQualityHigh) - { - mtlFlags |= MTL_FLAG_FOG_VOLUME_SHADING_QUALITY_HIGH; - } - else - { - mtlFlags &= ~MTL_FLAG_FOG_VOLUME_SHADING_QUALITY_HIGH; - } - - if (bBlendTerrainColor) - { - mtlFlags |= MTL_FLAG_BLEND_TERRAIN; - } - else - { - mtlFlags &= ~MTL_FLAG_BLEND_TERRAIN; - } - } - - mtl->SetFlags(mtlFlags); - - mtl->SetLayerActivation(allowLayerActivation); - - // set each material layer - if (propagationFlags & MTL_PROPAGATE_LAYER_PRESETS) - { - SMaterialLayerResources* pMtlLayerResources = mtl->GetMtlLayerResources(); - for (int l(0); l < MTL_LAYER_MAX_SLOTS; ++l) - { - if (pMtlLayerResources[l].m_shaderName != materialLayers[l].shader) - { - pMtlLayerResources[l].m_shaderName = materialLayers[l].shader; - pMtlLayerResources[l].m_bRegetPublicParams = true; - } - - if (materialLayers[l].bNoDraw) - { - pMtlLayerResources[l].m_nFlags |= MTL_LAYER_USAGE_NODRAW; - } - else - { - pMtlLayerResources[l].m_nFlags &= ~MTL_LAYER_USAGE_NODRAW; - } - - if (materialLayers[l].bFadeOut) - { - pMtlLayerResources[l].m_nFlags |= MTL_LAYER_USAGE_FADEOUT; - } - else - { - pMtlLayerResources[l].m_nFlags &= ~MTL_LAYER_USAGE_FADEOUT; - } - } - } - - if (propagationFlags & MTL_PROPAGATE_MATERIAL_SETTINGS) - { - mtl->SetSurfaceTypeName(surfaceType); - // If shader name is different reload shader. - mtl->SetShaderName(shader); - } - - GetShaderResources(mtl->GetShaderResources(), propagationFlags); -} - -void CMaterialUI::SetTextureNames(CMaterial* mtl) -{ - SInputShaderResources& sr = mtl->GetShaderResources(); - - for ( auto& iter : sr.m_TexturesResourcesMap ) - { - uint16 texId = iter.first; - if (!MaterialHelpers::IsAdjustableTexSlot((EEfResTextures)texId)) - { - continue; - } - - SEfResTexture* pTextureRes = &(iter.second); - textureVars[texId]->Set(pTextureRes->m_Name.c_str()); - } -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -class CMtlPickCallback - : public IPickObjectCallback -{ -public: - CMtlPickCallback() { m_bActive = true; }; - //! Called when object picked. - virtual void OnPick(CBaseObject* picked) - { - m_bActive = false; - CMaterial* pMtl = picked->GetMaterial(); - if (pMtl) - { - GetIEditor()->OpenMaterialLibrary(pMtl); - } - delete this; - } - //! Called when pick mode canceled. - virtual void OnCancelPick() - { - m_bActive = false; - delete this; - } - //! Return true if specified object is pickable. - virtual bool OnPickFilter(CBaseObject* filterObject) - { - // Check if object have material. - if (filterObject->GetMaterial()) - { - return true; - } - else - { - return false; - } - } - static bool IsActive() { return m_bActive; }; -private: - static bool m_bActive; -}; -bool CMtlPickCallback::m_bActive = false; -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -// CMaterialDialog implementation. -////////////////////////////////////////////////////////////////////////// -CMaterialDialog::CMaterialDialog(QWidget* parent /* = 0 */) - : QMainWindow(parent) - , m_wndMtlBrowser(0) -{ - m_propsCtrl = new TwoColumnPropertyControl; - m_propsCtrl->Setup(true, 150); - m_propsCtrl->SetSavedStateKey("MaterialDialog"); - m_propsCtrl->setMinimumWidth(460); - - m_placeHolderLabel = new QLabel(tr("Select a material in the Material Editor hierarchy to view properties")); - m_placeHolderLabel->setMinimumHeight(250); - m_placeHolderLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); - - SEventLog toolEvent(MATERIAL_EDITOR_NAME, "", MATERIAL_EDITOR_VER); - GetIEditor()->GetSettingsManager()->RegisterEvent(toolEvent); - - m_pMatManager = GetIEditor()->GetMaterialManager(); - - m_shaderGenParamsVars = 0; - - m_textureSlots = 0; - - m_pMaterialUI = new CMaterialUI; - - m_bForceReloadPropsCtrl = true; - - m_pMaterialImageListModel.reset(new QMaterialImageListModel); - - m_pMaterialImageListCtrl.reset(new CMaterialImageListCtrl); - m_pMaterialImageListCtrl->setModel(m_pMaterialImageListModel.data()); - - // Immediately create dialog. - OnInitDialog(); - - GetIEditor()->RegisterNotifyListener(this); - m_pMatManager->AddListener(this); - m_propsCtrl->SetUndoCallback(AZStd::bind(&CMaterialDialog::OnUndo, this, AZStd::placeholders::_1)); - m_propsCtrl->SetStoreUndoByItems(false); - - // KDAB_TODO: hack until we have proper signal coming from the IEDitor - connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::awake, this, &CMaterialDialog::UpdateActions); -} - -////////////////////////////////////////////////////////////////////////// -CMaterialDialog::~CMaterialDialog() -{ - m_pMatManager->RemoveListener(this); - GetIEditor()->UnregisterNotifyListener(this); - m_wndMtlBrowser->SetImageListCtrl(NULL); - - delete m_pMaterialUI; - m_vars = 0; - m_publicVars = 0; - m_shaderGenParamsVars = 0; - m_textureSlots = 0; - - m_propsCtrl->ClearUndoCallback(); - m_propsCtrl->RemoveAllItems(); - - SEventLog toolEvent(MATERIAL_EDITOR_NAME, "", MATERIAL_EDITOR_VER); - GetIEditor()->GetSettingsManager()->UnregisterEvent(toolEvent); -} - -BOOL CMaterialDialog::OnInitDialog() -{ - setWindowTitle(tr(LyViewPane::MaterialEditor)); - if (gEnv->p3DEngine) - { - ISurfaceTypeManager* pSurfaceTypeManager = gEnv->p3DEngine->GetMaterialManager()->GetSurfaceTypeManager(); - if (pSurfaceTypeManager) - { - pSurfaceTypeManager->LoadSurfaceTypes(); - } - } - - InitToolbar(IDR_DB_MATERIAL_BAR); - - setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); - - // hide menu bar - menuBar()->hide(); - - // Create status bar. - { - m_statusBar = this->statusBar(); - m_statusBar->setSizeGripEnabled(false); - } - - QSplitter* centralWidget = new QSplitter(Qt::Horizontal, this); - setCentralWidget(centralWidget); - - QSplitter* rightWidget = new QSplitter(Qt::Vertical, centralWidget); - centralWidget->addWidget(rightWidget); - - rightWidget->addWidget(m_propsCtrl); - - m_vars = m_pMaterialUI->CreateVars(); - m_propsCtrl->AddVarBlock(m_vars); - - m_propsCtrl->setEnabled(false); - m_propsCtrl->hide(); - - ////////////////////////////////////////////////////////////////////////// - // Preview Pane - ////////////////////////////////////////////////////////////////////////// - { - rightWidget->insertWidget(0, m_pMaterialImageListCtrl.data()); - - int h = m_pMaterialImageListCtrl->sizeHint().height(); - m_pMaterialImageListCtrl->hide(); - rightWidget->setSizes({h, height() - h }); - } - - rightWidget->addWidget(m_placeHolderLabel); - m_placeHolderLabel->setAlignment(Qt::AlignCenter); - - ////////////////////////////////////////////////////////////////////////// - // Browser Pane - ////////////////////////////////////////////////////////////////////////// - if (!m_wndMtlBrowser) - { - m_wndMtlBrowser = new MaterialBrowserWidget(this); - m_wndMtlBrowser->SetListener(this); - m_wndMtlBrowser->SetImageListCtrl(m_pMaterialImageListCtrl.data()); - //m_wndMtlBrowser->resize(width() / 3, height()); - - centralWidget->insertWidget(0, m_wndMtlBrowser); - - int w = m_wndMtlBrowser->sizeHint().height(); - centralWidget->setSizes({ w, width() - w }); - centralWidget->setStretchFactor(0, 0); - centralWidget->setStretchFactor(1, 1); - - // Start the background processing of material files after the widget has been initialized - m_wndMtlBrowser->StartRecordUpdateJobs(); - } - - // Set the image list control to give stretch priority to the other widgets. This is both to avoid resizing the - // image list control when the window is resized and to avoid an issue with the QSplitter resizing the image list - // control when enabling/disabling the other two widgets. - const int materialImageControlIndex = 0; - const int materialImagePropertiesControlIndex = 1; - const int materialPlaceholderLabelIndex = 2; - rightWidget->setStretchFactor(materialImageControlIndex, 0); - rightWidget->setStretchFactor(materialImagePropertiesControlIndex, 1); - rightWidget->setStretchFactor(materialPlaceholderLabelIndex, 1); - - resize(1200, 800); - - return true; // return true unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void CMaterialDialog::closeEvent(QCloseEvent *ev) -{ - // We call save before running any dtors, as it might trigger a modal dialog / nested event loop - // asking to overwrite files, and that causes a crash - m_wndMtlBrowser->SaveCurrentMaterial(); - ev->accept(); // All good, dialog will close now -} - -////////////////////////////////////////////////////////////////////////// -// Create the toolbar -void CMaterialDialog::InitToolbar([[maybe_unused]] UINT nToolbarResID) -{ - // detect if the new viewport interaction model is enabled and give - // feedback to the user that certain operations are not yet compatible - const bool newViewportInteractionModelEnabled = GetIEditor()->IsNewViewportInteractionModelEnabled(); - const char* const newViewportInteractionModelWarning = - "This option is currently not available with the new Viewport Interaction Model enabled"; - - m_toolbar = addToolBar(tr("Material ToolBar")); - m_toolbar->setFloatable(false); - - QIcon assignselectionIcon; - assignselectionIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_assignselection_normal.png" }, QIcon::Normal); - assignselectionIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_assignselection_active.png" }, QIcon::Active); - assignselectionIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_assignselection_disabled.png" }, QIcon::Disabled); - - m_assignToSelectionAction = - m_toolbar->addAction(assignselectionIcon, - newViewportInteractionModelEnabled - ? tr(newViewportInteractionModelWarning) - : tr("Assign Item to Selected Objects"), - this, SLOT(OnAssignMaterialToSelection())); - - QIcon resetIcon; - resetIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_reset_normal.png" }, QIcon::Normal); - resetIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_reset_active.png" }, QIcon::Active); - resetIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_reset_disabled.png" }, QIcon::Disabled); - - m_resetAction = - m_toolbar->addAction(resetIcon, - newViewportInteractionModelEnabled - ? tr(newViewportInteractionModelWarning) - : tr("Reset Material on Selection to Default"), - this, SLOT(OnResetMaterialOnSelection())); - - QIcon getfromselectionIcon; - getfromselectionIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_getfromselection_normal.png" }, QIcon::Normal); - getfromselectionIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_getfromselection_active.png" }, QIcon::Active); - getfromselectionIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_getfromselection_disabled.png" }, QIcon::Disabled); - - m_getFromSelectionAction = - m_toolbar->addAction( - getfromselectionIcon, - newViewportInteractionModelEnabled - ? tr(newViewportInteractionModelWarning) - : tr("Get Properties From Selection"), - this, SLOT(OnGetMaterialFromSelection())); - - QIcon pickIcon; - pickIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_pick_normal.png" }, QIcon::Normal); - pickIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_pick_active.png" }, QIcon::Active); - pickIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_pick_disabled.png" }, QIcon::Disabled); - - m_pickAction = m_toolbar->addAction( - pickIcon, - newViewportInteractionModelEnabled - ? tr(newViewportInteractionModelWarning) - : tr("Pick Material from Object"), - this, SLOT(OnPickMtl())); - - m_pickAction->setCheckable(true); - - if (newViewportInteractionModelEnabled) - { - m_pickAction->setEnabled(false); - } - - QAction* sepAction = m_toolbar->addSeparator(); - m_filterTypeSelection = new QComboBox(this); - m_filterTypeSelection->addItem(tr("All Materials")); - m_filterTypeSelection->addItem(tr("Used In Level")); - m_filterTypeSelection->setMinimumWidth(150); - QAction* cbAction = m_toolbar->addWidget(m_filterTypeSelection); - m_filterTypeSelection->setCurrentIndex(0); - connect(m_filterTypeSelection, SIGNAL(currentIndexChanged(int)), this, SLOT(OnChangedBrowserListType(int))); - m_toolbar->addSeparator(); - QIcon addIcon; - addIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_add_normal.png" }, QIcon::Normal); - addIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_add_active.png" }, QIcon::Active); - addIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_add_disabled.png" }, QIcon::Disabled); - m_addAction = m_toolbar->addAction(addIcon, tr("Add New Item"), this, SLOT(OnAddItem())); - QIcon saveIcon; - saveIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_save_normal.png" }, QIcon::Normal); - saveIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_save_active.png" }, QIcon::Active); - saveIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_save_disabled.png" }, QIcon::Disabled); - m_saveAction = m_toolbar->addAction(saveIcon, tr("Save Item"), this, SLOT(OnSaveItem())); - QIcon removeIcon; - removeIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_remove_normal.png" }, QIcon::Normal); - removeIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_remove_active.png" }, QIcon::Active); - removeIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_remove_disabled.png" }, QIcon::Disabled); - m_removeAction = m_toolbar->addAction(removeIcon, tr("Remove Item"), this, SLOT(OnDeleteItem())); - m_toolbar->addSeparator(); - QIcon copyIcon; - copyIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_copy_normal.png" }, QIcon::Normal); - copyIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_copy_active.png" }, QIcon::Active); - copyIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_copy_disabled.png" }, QIcon::Disabled); - m_copyAction = m_toolbar->addAction(copyIcon, tr("Copy Material"), this, SLOT(OnCopy())); - QIcon pasteIcon; - pasteIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_paste_normal.png" }, QIcon::Normal); - pasteIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_paste_active.png" }, QIcon::Active); - pasteIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_paste_disabled.png" }, QIcon::Disabled); - m_pasteAction = m_toolbar->addAction(pasteIcon, tr("Paste Material"), this, SLOT(OnPaste())); - m_toolbar->addSeparator(); - QIcon previewIcon; - previewIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_preview_normal.png" }, QIcon::Normal); - previewIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_preview_active.png" }, QIcon::Active); - previewIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_preview_disabled.png" }, QIcon::Disabled); - m_previewAction = m_toolbar->addAction(previewIcon, tr("Open Large Material Preview Window"), this, SLOT(OnMaterialPreview())); - m_toolbar->addSeparator(); - QIcon resetViewportIcon; - resetViewportIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_reset_viewport_normal.png" }, QIcon::Normal); - resetViewportIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_reset_viewport_active.png" }, QIcon::Active); - resetViewportIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_reset_viewport_disabled.png" }, QIcon::Disabled); - m_resetViewporAction = m_toolbar->addAction(resetViewportIcon, tr("Reset Material Viewport"), this, SLOT(OnResetMaterialViewport())); - - UpdateActions(); - setContextMenuPolicy(Qt::ContextMenuPolicy::NoContextMenu); - - connect(m_toolbar, &QToolBar::orientationChanged, m_toolbar, [=](Qt::Orientation orientation) - { - if (orientation == Qt::Vertical) - { - m_toolbar->removeAction(cbAction); - } - else - { - m_toolbar->insertAction(sepAction, cbAction); - } - }); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::ReloadItems() -{ - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnAddItem() -{ - m_wndMtlBrowser->OnAddNewMaterial(); - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnSaveItem() -{ - CMaterial* pMtl = GetSelectedMaterial(); - if (pMtl) - { - CMaterial* parent = pMtl->GetParent(); - - if (!pMtl->Save(false)) - { - if (!parent) - { - QMessageBox::warning(this, QString(), tr("The material file cannot be saved. The file is located in a PAK archive or access is denied")); - } - } - - if (parent) - { - //The reload function will clear all the sub-material references, and re-create them. - //Thus pMtl will point to old sub-material that should be deleted instead. - //So we need to set m_pMatManager's current material to the new one. - int index = -1; - - //Find the corresponding sub-material and record its index - for (int i = 0; i < parent->GetSubMaterialCount(); i++) - { - if (parent->GetSubMaterial(i) == pMtl) - { - index = i; - break; - } - } - pMtl->Reload(); - - if (index >= 0 && index < parent->GetSubMaterialCount()) - { - m_pMatManager->SetCurrentMaterial(parent->GetSubMaterial(index)); - } - else //If we can't find the sub-material, use parent instead - { - m_pMatManager->SetCurrentMaterial(parent); - } - } - else - { - pMtl->Reload(); - } - - } - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnDeleteItem() -{ - m_wndMtlBrowser->DeleteItem(); - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::SetMaterialVars([[maybe_unused]] CMaterial* mtl) -{ -} - - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::UpdateShaderParamsUI(CMaterial* pMtl) -{ - ////////////////////////////////////////////////////////////////////////// - // Shader Gen Mask. - ////////////////////////////////////////////////////////////////////////// - IVariable* shaderGenParamsContainerVar = m_pMaterialUI->tableShaderGenParams.GetVar(); - if (m_propsCtrl->FindVariable(shaderGenParamsContainerVar)) - { - m_shaderGenParamsVars = pMtl->GetShaderGenParamsVars(); - m_propsCtrl->ReplaceVarBlock(shaderGenParamsContainerVar, m_shaderGenParamsVars); - } - - ////////////////////////////////////////////////////////////////////////// - // Shader Public Params. - ////////////////////////////////////////////////////////////////////////// - IVariable* publicVars = m_pMaterialUI->tableShaderParams.GetVar(); - if (m_propsCtrl->FindVariable(publicVars)) - { - bool bNeedUpdateMaterialFromUI = false; - CVarBlockPtr pPublicVars = pMtl->GetPublicVars(pMtl->GetShaderResources()); - if (m_publicVars && pPublicVars) - { - // list of shader parameters depends on list of shader generation parameters - // we need to keep values of vars which not presented in every combinations, - // but probably adjusted by user, to keep his work. - // m_excludedPublicVars is used for these values - if (m_excludedPublicVars.pMaterial) - { - if (m_excludedPublicVars.pMaterial != pMtl) - { - m_excludedPublicVars.vars.DeleteAllVariables(); - } - else - { - // find new presented vars in pPublicVars, which not existed in old m_publicVars - for (int j = pPublicVars->GetNumVariables() - 1; j >= 0; --j) - { - IVariable* pVar = pPublicVars->GetVariable(j); - bool isVarExist = false; - for (int i = m_publicVars->GetNumVariables() - 1; i >= 0; --i) - { - IVariable* pOldVar = m_publicVars->GetVariable(i); - if (!QString::compare(pOldVar->GetName(), pVar->GetName())) - { - isVarExist = true; - break; - } - } - if (!isVarExist) // var exist in new pPublicVars block, but not in previous (m_publicVars) - { - // try to find value for this var inside "excluded vars" collection - for (int i = m_excludedPublicVars.vars.GetNumVariables() - 1; i >= 0; --i) - { - IVariable* pStoredVar = m_excludedPublicVars.vars.GetVariable(i); - if (!QString::compare(pStoredVar->GetName(), pVar->GetName()) && pVar->GetDataType() == pStoredVar->GetDataType()) - { - pVar->CopyValue(pStoredVar); - m_excludedPublicVars.vars.DeleteVariable(pStoredVar); - bNeedUpdateMaterialFromUI = true; - break; - } - } - } - } - } - } - // We only want to collect vars if the old and new block are part of the same - // material, otherwise we are storing state from one material to an other. - if (m_excludedPublicVars.pMaterial == pMtl) - { - // collect excluded vars from old block (m_publicVars) - // which exist in m_publicVars but not in a new generated pPublicVars block - for (int i = m_publicVars->GetNumVariables() - 1; i >= 0; --i) - { - IVariable* pOldVar = m_publicVars->GetVariable(i); - bool isVarExist = false; - for (int j = pPublicVars->GetNumVariables() - 1; j >= 0; --j) - { - IVariable* pVar = pPublicVars->GetVariable(j); - if (!QString::compare(pOldVar->GetName(), pVar->GetName())) - { - isVarExist = true; - break; - } - } - if (!isVarExist) - { - m_excludedPublicVars.vars.AddVariable(pOldVar->Clone(false)); - } - } - } - m_excludedPublicVars.pMaterial = pMtl; - } - - m_publicVars = pPublicVars; - if (m_publicVars) - { - m_publicVars->Sort(); - } - - m_propsCtrl->ReplaceVarBlock(publicVars, m_publicVars); - - if (m_publicVars && bNeedUpdateMaterialFromUI) - { - pMtl->SetPublicVars(m_publicVars, pMtl); - } - } - IVariable* textureSlotsVar = m_pMaterialUI->tableTexture.GetVar(); - if (m_propsCtrl->FindVariable(textureSlotsVar)) - { - m_textureSlots = pMtl->UpdateTextureNames(m_pMaterialUI->textureVars); - m_propsCtrl->ReplaceVarBlock(textureSlotsVar, m_textureSlots); - } - - ////////////////////////////////////////////////////////////////////////// -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::SelectItem(CBaseLibraryItem* item, bool bForceReload) -{ - static bool bNoRecursiveSelect = false; - if (bNoRecursiveSelect) - { - return; - } - - bool bChanged = item != m_pPrevSelectedItem || bForceReload; - - if (!bChanged) - { - return; - } - - m_pPrevSelectedItem = item; - - // Empty preview control. - //m_previewCtrl.SetEntity(0); - m_pMatManager->SetCurrentMaterial((CMaterial*)item); - - if (!item) - { - m_statusBar->clearMessage(); - m_propsCtrl->setEnabled(false); - m_propsCtrl->hide(); - m_pMaterialImageListCtrl->hide(); - m_placeHolderLabel->setText(tr("Select a material in the Material Editor hierarchy to view properties")); - m_placeHolderLabel->show(); - return; - } - - // Render preview geometry with current material - CMaterial* mtl = (CMaterial*)item; - - QString statusText; - if (mtl->IsPureChild() && mtl->GetParent()) - { - statusText = mtl->GetParent()->GetName() + " [" + mtl->GetName() + "]"; - } - else - { - statusText = mtl->GetName(); - } - - - if (mtl->IsDummy()) - { - statusText += " (Not Found)"; - } - else if (!mtl->CanModify()) - { - statusText += " (Read Only)"; - } - m_statusBar->showMessage(statusText); - - if (mtl->IsMultiSubMaterial()) - { - // Cannot edit it. - m_propsCtrl->setEnabled(false); - m_propsCtrl->EnableUpdateCallback(false); - m_propsCtrl->hide(); - - m_placeHolderLabel->setText(tr("Select a material to view properties")); - m_placeHolderLabel->show(); - - //return; - } - else - { - m_propsCtrl->setEnabled(true); - m_propsCtrl->EnableUpdateCallback(false); - m_propsCtrl->show(); - m_placeHolderLabel->hide(); - } - m_pMaterialImageListCtrl->show(); - - if (m_bForceReloadPropsCtrl) - { - // CPropertyCtrlEx skip OnPaint and another methods for redraw - // OnSize method is forced to invalidate control for redraw - m_propsCtrl->InvalidateCtrl(); - m_bForceReloadPropsCtrl = false; - } - - UpdatePreview(); - - // Update variables. - m_propsCtrl->EnableUpdateCallback(false); - m_pMaterialUI->SetFromMaterial(mtl); - m_propsCtrl->EnableUpdateCallback(true); - - mtl->SetShaderParamPublicScript(); - - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // Set Shader Gen Params. - ////////////////////////////////////////////////////////////////////////// - UpdateShaderParamsUI(mtl); - ////////////////////////////////////////////////////////////////////////// - - m_propsCtrl->SetUpdateCallback(AZStd::bind(&CMaterialDialog::OnUpdateProperties, this, AZStd::placeholders::_1)); - m_propsCtrl->EnableUpdateCallback(true); - - if (mtl->IsDummy()) - { - m_propsCtrl->setEnabled(false); - } - else - { - m_propsCtrl->setEnabled(true); - m_propsCtrl->SetGrayed(!mtl->CanModify()); - } - if (mtl) - { - m_pMaterialImageListCtrl->SelectMaterial(mtl); - } -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnUpdateProperties(IVariable* var) -{ - CMaterial* mtl = GetSelectedMaterial(); - if (!mtl) - { - return; - } - - bool bShaderChanged = (m_pMaterialUI->shader == var); - bool bShaderGenMaskChanged = false; - if (m_shaderGenParamsVars) - { - bShaderGenMaskChanged = m_shaderGenParamsVars->IsContainsVariable(var); - } - - bool bMtlLayersChanged = false; - int nCurrLayer = -1; - - // Check for shader changes - for (int l(0); l < MTL_LAYER_MAX_SLOTS; ++l) - { - if ((m_pMaterialUI->materialLayers[l].shader == var)) - { - bMtlLayersChanged = true; - nCurrLayer = l; - break; - } - } - - ////////////////////////////////////////////////////////////////////////// - // Assign modified Shader Gen Params to shader. - ////////////////////////////////////////////////////////////////////////// - if (bShaderGenMaskChanged) - { - mtl->SetShaderGenParamsVars(m_shaderGenParamsVars); - } - ////////////////////////////////////////////////////////////////////////// - // Invalidate material and save changes. - //m_pMatManager->MarkMaterialAsModified(mtl); - // - - mtl->RecordUndo("Material parameter", true); - m_pMaterialUI->SetToMaterial(mtl); - mtl->Update(); - - // - ////////////////////////////////////////////////////////////////////////// - // Assign new public vars to material. - // Must be after material update. - ////////////////////////////////////////////////////////////////////////// - - GetIEditor()->SuspendUndo(); - - if (m_publicVars != NULL && !bShaderChanged) - { - mtl->SetPublicVars(m_publicVars, mtl); - } - - /* - bool bUpdateLayers = false; - for(int l(0); l < MTL_LAYER_MAX_SLOTS; ++l) - { - if ( m_varsMtlLayersShaderParams[l] != NULL && l != nCurrLayer) - { - SMaterialLayerResources *pCurrResource = pTemplateMtl ? &pTemplateMtl->GetMtlLayerResources()[l] : &pMtlLayerResources[l]; - SShaderItem &pCurrShaderItem = pCurrResource->m_pMatLayer->GetShaderItem(); - CVarBlock* pVarBlock = pTemplateMtl ? pTemplateMtl->GetPublicVars( pCurrResource->m_shaderResources ) : m_varsMtlLayersShaderParams[l]; - mtl->SetPublicVars( pVarBlock, pCurrResource->m_shaderResources, pCurrShaderItem.m_pShaderResources, pCurrShaderItem.m_pShader); - bUpdateLayers = true; - } - } - */ - //if( bUpdateLayers ) - { - mtl->UpdateMaterialLayers(); - } - - m_pMaterialUI->PropagateToLinkedMaterial(mtl, m_shaderGenParamsVars); - if (var) - { - GetIEditor()->GetMaterialManager()->HighlightedMaterialChanged(mtl); - m_pMaterialUI->NotifyObjectsAboutMaterialChange(var); - } - - GetIEditor()->ResumeUndo(); - - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - if (bShaderChanged || bShaderGenMaskChanged || bMtlLayersChanged) - { - m_pMaterialUI->SetFromMaterial(mtl); - } - //m_pMaterialUI->SetTextureNames( mtl ); - - UpdatePreview(); - - // When shader changed. - if (bShaderChanged || bShaderGenMaskChanged || bMtlLayersChanged) - { - ////////////////////////////////////////////////////////////////////////// - // Set material layers params - ////////////////////////////////////////////////////////////////////////// - /* - if( bMtlLayersChanged) // only update changed shader in material layers - { - SMaterialLayerResources *pCurrResource = &pMtlLayerResources[nCurrLayer]; - - // delete old property item - if ( m_varsMtlLayersShaderParamsItems[nCurrLayer] ) - { - m_propsCtrl->DeleteItem( m_varsMtlLayersShaderParamsItems[nCurrLayer] ); - m_varsMtlLayersShaderParamsItems[nCurrLayer] = 0; - } - - m_varsMtlLayersShaderParams[nCurrLayer] = mtl->GetPublicVars( pCurrResource->m_shaderResources ); - - if ( m_varsMtlLayersShaderParams[nCurrLayer] ) - { - m_varsMtlLayersShaderParamsItems[nCurrLayer] = m_propsCtrl->AddVarBlockAt( m_varsMtlLayersShaderParams[nCurrLayer], "Shader Params", m_varsMtlLayersShaderItems[nCurrLayer] ); - } - } - */ - - UpdateShaderParamsUI(mtl); - } - - if (bShaderGenMaskChanged || bShaderChanged || bMtlLayersChanged) - { - m_propsCtrl->InvalidateCtrl(); - } - - m_pMaterialImageListModel->InvalidateMaterial(mtl); -} - -////////////////////////////////////////////////////////////////////////// -CMaterial* CMaterialDialog::GetSelectedMaterial() -{ - CBaseLibraryItem* pItem = m_pMatManager->GetCurrentMaterial(); - return (CMaterial*)pItem; -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnAssignMaterialToSelection() -{ - CUndo undo("Assign Material To Selection"); - GetIEditor()->GetMaterialManager()->Command_AssignToSelection(); - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnSelectAssignedObjects() -{ - CUndo undo("Select Objects With Current Material"); - GetIEditor()->GetMaterialManager()->Command_SelectAssignedObjects(); - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnResetMaterialOnSelection() -{ - GetIEditor()->GetMaterialManager()->Command_ResetSelection(); - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnGetMaterialFromSelection() -{ - GetIEditor()->GetMaterialManager()->Command_SelectFromObject(); - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::DeleteItem([[maybe_unused]] CBaseLibraryItem* pItem) -{ - m_wndMtlBrowser->DeleteItem(); - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// - -void CMaterialDialog::UpdateActions() -{ - if (isHidden()) - { - return; - } - - CMaterial* mtl = GetSelectedMaterial(); - if (mtl && mtl->CanModify(false)) - { - m_saveAction->setEnabled(true); - } - else - { - m_saveAction->setEnabled(false); - } - - if (GetIEditor()->GetEditTool() && GetIEditor()->GetEditTool()->GetClassDesc() && QString::compare(GetIEditor()->GetEditTool()->GetClassDesc()->ClassName(), "EditTool.PickMaterial") == 0) - { - m_pickAction->setChecked(true); - } - else - { - m_pickAction->setChecked(false); - } - - if (mtl && (!GetIEditor()->GetSelection()->IsEmpty() || GetIEditor()->IsInPreviewMode())) - { - m_assignToSelectionAction->setEnabled(true); - } - else - { - m_assignToSelectionAction->setEnabled(false); - } - - if (!GetIEditor()->GetSelection()->IsEmpty() || GetIEditor()->IsInPreviewMode()) - { - m_resetAction->setEnabled(true); - m_getFromSelectionAction->setEnabled(true); - } - else - { - m_resetAction->setEnabled(false); - m_getFromSelectionAction->setEnabled(false); - } -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnPickMtl() -{ - if (GetIEditor()->GetEditTool() && QString::compare(GetIEditor()->GetEditTool()->GetClassDesc()->ClassName(), "EditTool.PickMaterial") == 0) - { - GetIEditor()->SetEditTool(NULL); - } - else - { - GetIEditor()->SetEditTool("EditTool.PickMaterial"); - } - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnCopy() -{ - m_wndMtlBrowser->OnCopy(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnPaste() -{ - m_wndMtlBrowser->OnPaste(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnMaterialPreview() -{ - if (!m_pPreviewDlg) - { - m_pPreviewDlg = new CMatEditPreviewDlg(this); - m_pPreviewDlg->show(); - } -} - -////////////////////////////////////////////////////////////////////////// -bool CMaterialDialog::SetItemName(CBaseLibraryItem* item, const QString& groupName, const QString& itemName) -{ - assert(item); - // Make prototype name. - QString fullName = groupName + "/" + itemName; - IDataBaseItem* pOtherItem = m_pMatManager->FindItemByName(fullName); - if (pOtherItem && pOtherItem != item) - { - // Ensure uniqness of name. - Warning("Duplicate Item Name %s", fullName.toUtf8().data()); - return false; - } - else - { - item->SetName(fullName); - } - return true; -} - - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnBrowserSelectItem(IDataBaseItem* pItem, bool bForce) -{ - SelectItem((CBaseLibraryItem*)pItem, bForce); - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::UpdatePreview() -{ -}; - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnChangedBrowserListType(int sel) -{ - m_wndMtlBrowser->ShowOnlyLevelMaterials(sel == 1); - m_pMatManager->SetCurrentMaterial(0); - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnUndo(IVariable* pVar) -{ - if (!m_pMatManager->GetCurrentMaterial()) - { - return; - } - - QString undoName; - if (pVar) - { - undoName = tr("%1 modified").arg(pVar->GetName()); - } - else - { - undoName = tr("Material parameter was modified"); - } - - if (!CUndo::IsRecording()) - { - if (!CUndo::IsSuspended()) - { - CUndo undo(undoName.toUtf8().data()); - m_pMatManager->GetCurrentMaterial()->RecordUndo(undoName.toUtf8().data(), true); - } - } - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnDataBaseItemEvent(IDataBaseItem* pItem, EDataBaseItemEvent event) -{ - switch (event) - { - case EDB_ITEM_EVENT_UPDATE_PROPERTIES: - if (pItem && pItem == m_pMatManager->GetCurrentMaterial()) - { - SelectItem(m_pMatManager->GetCurrentMaterial(), true); - } - break; - } -} - -// If an object is selected or de-selected, update the available actions in the Material Editor toolbar -void CMaterialDialog::OnEditorNotifyEvent(EEditorNotifyEvent event) -{ - switch (event) - { - case eNotify_OnSelectionChange: - UpdateActions(); - break; - case eNotify_OnCloseScene: - case eNotify_OnEndNewScene: - case eNotify_OnEndSceneOpen: - m_filterTypeSelection->setCurrentIndex(0); - break; - } -} - -void CMaterialDialog::OnResetMaterialViewport() -{ - m_pMaterialImageListCtrl->LoadModel(); -} - -#include diff --git a/Code/Sandbox/Editor/Material/MaterialDialog.h b/Code/Sandbox/Editor/Material/MaterialDialog.h deleted file mode 100644 index 48e68e2322..0000000000 --- a/Code/Sandbox/Editor/Material/MaterialDialog.h +++ /dev/null @@ -1,176 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#pragma once - -#if !defined(Q_MOC_RUN) -#include "MaterialBrowser.h" - -#include -#include -#include -#endif - -static const char* MATERIAL_EDITOR_NAME = "Material Editor"; -static const char* MATERIAL_EDITOR_VER = "1.00"; - - -class QComboBox; -class QLabel; - -class CMaterial; -class CMaterialManager; -class CMatEditPreviewDlg; -class CMaterialSender; -class CMaterialImageListCtrl; -class QMaterialImageListModel; -class TwoColumnPropertyControl; - -/** Dialog which hosts entity prototype library. -*/ - - -struct SMaterialExcludedVars -{ - CMaterial* pMaterial; - CVarBlock vars; - - SMaterialExcludedVars() - : pMaterial(nullptr) - { - } -}; - - -class CMaterialDialog - : public QMainWindow - , public IMaterialBrowserListener - , public IDataBaseManagerListener - , public IEditorNotifyListener -{ - Q_OBJECT -public: - CMaterialDialog(QWidget* parent = 0); - ~CMaterialDialog(); - - static void RegisterViewClass(); - static const GUID& GetClassID(); - -public slots: - void OnAssignMaterialToSelection(); - void OnResetMaterialOnSelection(); - void OnGetMaterialFromSelection(); - -protected: - BOOL OnInitDialog(); - void closeEvent(QCloseEvent *ev) override; - -protected slots: - void OnAddItem(); - void OnDeleteItem(); - void OnSaveItem(); - void OnPickMtl(); - void OnCopy(); - void OnPaste(); - void OnMaterialPreview(); - void OnSelectAssignedObjects(); - void OnChangedBrowserListType(int); - void OnResetMaterialViewport(); - - void UpdateActions(); - -protected: - ////////////////////////////////////////////////////////////////////////// - // Some functions can be overriden to modify standart functionality. - ////////////////////////////////////////////////////////////////////////// - virtual void InitToolbar(UINT nToolbarResID); - - virtual void SelectItem(CBaseLibraryItem* item, bool bForceReload = false); - virtual void DeleteItem(CBaseLibraryItem* pItem); - virtual bool SetItemName(CBaseLibraryItem* item, const QString& groupName, const QString& itemName); - virtual void ReloadItems(); - - ////////////////////////////////////////////////////////////////////////// - // IMaterialBrowserListener implementation. - ////////////////////////////////////////////////////////////////////////// - virtual void OnBrowserSelectItem(IDataBaseItem* pItem, bool bForce); - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // IDataBaseManagerListener implementation. - ////////////////////////////////////////////////////////////////////////// - virtual void OnDataBaseItemEvent(IDataBaseItem* pItem, EDataBaseItemEvent event); - ////////////////////////////////////////////////////////////////////////// - - // IEditorNotifyListener implementation. - virtual void OnEditorNotifyEvent(EEditorNotifyEvent event); - - ////////////////////////////////////////////////////////////////////////// - CMaterial* GetSelectedMaterial(); - void OnUpdateProperties(IVariable* var); - void OnUndo(IVariable* pVar); - - void UpdateShaderParamsUI(CMaterial* pMtl); - - void UpdatePreview(); - - //void SetTextureVars( CVariableArray *texVar,CMaterial *mtl,int id,const CString &name ); - void SetMaterialVars(CMaterial* mtl); - - MaterialBrowserWidget* m_wndMtlBrowser; - - QStatusBar* m_statusBar; - //CXTCaption m_wndCaption; - - TwoColumnPropertyControl* m_propsCtrl; - bool m_bForceReloadPropsCtrl; - - QLabel* m_placeHolderLabel; - - CBaseLibraryItem* m_pPrevSelectedItem; - - // Material manager. - CMaterialManager* m_pMatManager; - - CVarBlockPtr m_vars; - CVarBlockPtr m_publicVars; - - // collection of excluded vars from m_publicVars for remembering values - // when updating shader params - SMaterialExcludedVars m_excludedPublicVars; - - CVarBlockPtr m_shaderGenParamsVars; - CVarBlockPtr m_textureSlots; - - class CMaterialUI* m_pMaterialUI; - - QPointer m_pPreviewDlg; - - QScopedPointer m_pMaterialImageListCtrl; - QScopedPointer m_pMaterialImageListModel; - - QToolBar* m_toolbar; - QComboBox* m_filterTypeSelection; - QAction* m_addAction; - QAction* m_assignToSelectionAction; - QAction* m_copyAction; - QAction* m_getFromSelectionAction; - QAction* m_pasteAction; - QAction* m_pickAction; - QAction* m_previewAction; - QAction* m_removeAction; - QAction* m_resetAction; - QAction* m_saveAction; - QAction* m_resetViewporAction; -}; - diff --git a/Code/Sandbox/Editor/Material/MaterialDialog.qrc b/Code/Sandbox/Editor/Material/MaterialDialog.qrc index 43bfbd6ea0..c99e5b052a 100644 --- a/Code/Sandbox/Editor/Material/MaterialDialog.qrc +++ b/Code/Sandbox/Editor/Material/MaterialDialog.qrc @@ -1,39 +1,4 @@ - - images/materialdialog_add_disabled.png - images/materialdialog_copy_disabled.png - images/materialdialog_paste_disabled.png - images/materialdialog_preview_disabled.png - images/materialdialog_remove_disabled.png - images/materialdialog_save_disabled.png - images/materialdialog_assignselection_disabled.png - images/materialdialog_getfromselection_disabled.png - images/materialdialog_pick_disabled.png - images/materialdialog_reset_disabled.png - images/materialdialog_assignselection_active.png - images/materialdialog_assignselection_normal.png - images/materialdialog_add_active.png - images/materialdialog_add_normal.png - images/materialdialog_copy_active.png - images/materialdialog_copy_normal.png - images/materialdialog_getfromselection_active.png - images/materialdialog_getfromselection_normal.png - images/materialdialog_paste_active.png - images/materialdialog_paste_normal.png - images/materialdialog_pick_active.png - images/materialdialog_pick_normal.png - images/materialdialog_preview_active.png - images/materialdialog_preview_normal.png - images/materialdialog_remove_active.png - images/materialdialog_remove_normal.png - images/materialdialog_reset_active.png - images/materialdialog_reset_normal.png - images/materialdialog_save_active.png - images/materialdialog_save_normal.png - images/materialdialog_reset_viewport_active.png - images/materialdialog_reset_viewport_disabled.png - images/materialdialog_reset_viewport_normal.png - images/material_browser_00.png images/material_browser_01.png diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_add.png b/Code/Sandbox/Editor/Material/images/materialdialog_add.png deleted file mode 100644 index aa8d657f23..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_add.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:703f6875258486629bc1db68ce80fe1653f0d2876cd1252d03f72f6eae04dd84 -size 392 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_add_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_add_active.png deleted file mode 100644 index 467365d1ad..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_add_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3f3c05f8425956e9c1e380fde9a65df8f0d341868900a3589d9f629f34a0ddf6 -size 251 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_add_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_add_disabled.png deleted file mode 100644 index 399e45469e..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_add_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:25554e93a4f0d9b904a2a3628c315ee55c0ad8831bb5891a9d7e27e5cb9a5416 -size 261 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_add_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_add_normal.png deleted file mode 100644 index 1eb8d63ef5..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_add_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b2ee886c6e487a6490361609fdd44c64438e40c7e5a4c40fda866ec399ec4727 -size 256 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_assignselection.png b/Code/Sandbox/Editor/Material/images/materialdialog_assignselection.png deleted file mode 100644 index 72fdb0537a..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_assignselection.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:943ff19774cbe8d47c1e8001a48e6d137fdac2c0af63c9092911c37be0d6d6a8 -size 471 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_assignselection_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_assignselection_active.png deleted file mode 100644 index 605107f750..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_assignselection_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:400d669d7a658968549f6ee776ee415b871b207c444d8797a404b76d536131b1 -size 325 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_assignselection_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_assignselection_disabled.png deleted file mode 100644 index 3505f577a4..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_assignselection_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:02bdc8aad92bb75b118c4a703a3e5b1369376620b3836a125faedc7f6b42b49b -size 330 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_assignselection_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_assignselection_normal.png deleted file mode 100644 index 0e9c984e1d..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_assignselection_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:38097d3041defeec0179390a73bb463e54e7f4c1f0b1a20e77ab3f69ea9cf13c -size 332 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_copy.png b/Code/Sandbox/Editor/Material/images/materialdialog_copy.png deleted file mode 100644 index 08fc0c6987..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_copy.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e1d9fe8e97655bf776b20e242d66900980721ba2f3ee93c02cd4062a8b872eed -size 433 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_copy_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_copy_active.png deleted file mode 100644 index 67a010be86..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_copy_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:468b68c44d8ef183b292c1bc6ca4dc583357f693db9ea2cd198fb2af22537be1 -size 249 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_copy_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_copy_disabled.png deleted file mode 100644 index d585dbae6e..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_copy_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b27a1346f2edebe34ee06d7892a467bfc67952d0f8e4458e09a74a6dbf62fe98 -size 336 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_copy_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_copy_normal.png deleted file mode 100644 index 4b42f5c9a2..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_copy_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c3f40524a96689b8c8549bc662415df654494baeeda6eed47e66b455ac902eeb -size 254 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection.png b/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection.png deleted file mode 100644 index 76c343a718..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cebe97de0d879d239fcd61595fd28b73760aa6452dcf4dabc54bfe034e2e33c1 -size 476 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection_active.png deleted file mode 100644 index cc58f4f767..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:699ee40aeedfc50b7766e94ef66e645762eb183ddd6ce134b4bdab01c3957ab9 -size 327 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection_disabled.png deleted file mode 100644 index 6e4a425058..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5f1fd8a7cecb22901c6d73f2e6129f3bada0f94cf73d9a8fd2676a972faa5719 -size 348 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection_normal.png deleted file mode 100644 index 1c319c319d..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d432de9e921d23fbbf3c1b805f644b9554aa206011a87c063d167c30c7c4579e -size 335 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_paste.png b/Code/Sandbox/Editor/Material/images/materialdialog_paste.png deleted file mode 100644 index 95740d44d8..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_paste.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c006e70efd8bdb1dd5aac867db9d97de587e8d518ba0693d19c319e34a74c7d0 -size 501 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_paste_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_paste_active.png deleted file mode 100644 index aabb4f2520..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_paste_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:00c291361664d357502f5267fccd0a6fff0c3f2e906c0402d57ad9fa5ca7f023 -size 255 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_paste_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_paste_disabled.png deleted file mode 100644 index 9abc336f71..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_paste_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d68fc8604a23eb3bcc0cac9bb6e83dd4dc4cdab70b0bdaec3c456559727c6b5b -size 354 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_paste_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_paste_normal.png deleted file mode 100644 index 158bf9d690..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_paste_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4055c7f029d7711e5c32f3f74901bf1dcc1540fd2c0f3f30dc74743d7f2cc042 -size 355 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_pick.png b/Code/Sandbox/Editor/Material/images/materialdialog_pick.png deleted file mode 100644 index e08b45ac66..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_pick.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:99e2c0378137bef94eb6f281e0168852540bf1ca823b9bcd4365ef2849db9956 -size 420 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_pick_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_pick_active.png deleted file mode 100644 index 392b4ab63e..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_pick_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:34075016c93f1914fe4d12ead7c5ee322a18466f08a476eff7c127e4e1429224 -size 290 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_pick_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_pick_disabled.png deleted file mode 100644 index 865a91152d..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_pick_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:dc289621f8a9d3e714cd985651d7d6f20495fb7be46e1f60c283d8920c730d0b -size 307 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_pick_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_pick_normal.png deleted file mode 100644 index 5c1086b22d..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_pick_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7e9d5c878acf9fee4252cb854f192690d3f50d46dc4e5f5b1b5812b79fc2cdf7 -size 296 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_preview.png b/Code/Sandbox/Editor/Material/images/materialdialog_preview.png deleted file mode 100644 index c7d79780ee..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_preview.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e2e912c40f07ca3d2a9b2aa1c5caf3acc181436b6a1b560fc021450701331b4c -size 403 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_preview_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_preview_active.png deleted file mode 100644 index d2e1d8230d..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_preview_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:00663e473803ba6c2798c494676b0a65fd62d7484f6d7b51d9fc8955ad586477 -size 273 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_preview_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_preview_disabled.png deleted file mode 100644 index 56716582bb..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_preview_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:34b7d5520cfc8f00ff580558db4f0ec4297458d310321471204daa8678db5fc1 -size 298 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_preview_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_preview_normal.png deleted file mode 100644 index f54cd90c2a..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_preview_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7bca1a8811739949aa2e87486f8697dfae5bc5238894dd1b95ae80aa6f80d517 -size 279 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_remove.png b/Code/Sandbox/Editor/Material/images/materialdialog_remove.png deleted file mode 100644 index d530169b78..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_remove.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:db86d857b651a2fec80418f8b251447bb3fcf4c0cf64bdee12c3b656adbde29a -size 422 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_remove_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_remove_active.png deleted file mode 100644 index 78ec0e0806..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_remove_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fef72444f077879d5c0186c9583f67aa45aafc23214d9e7de90a7c595609270f -size 258 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_remove_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_remove_disabled.png deleted file mode 100644 index a69ef52e75..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_remove_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d2117fda3ed6a28032ae8f03ed7f9a7a0960f4691e49903c63b2150027dfe1ea -size 302 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_remove_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_remove_normal.png deleted file mode 100644 index b84a504285..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_remove_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:06b384ecc11ed2547a9bf466f585889d647c29a4883840070e444a382e80c41c -size 266 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_reset.png b/Code/Sandbox/Editor/Material/images/materialdialog_reset.png deleted file mode 100644 index e2eedad0bf..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_reset.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4b9ee01e7fe2f19b0e736efe09c2b81d3243e369375b4f26346e6abd499e54a6 -size 476 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_reset_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_reset_active.png deleted file mode 100644 index e86ed4dcb8..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_reset_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:935a041332be1fe11ed01c09a3cd367fb9ede7e7eb04909614943f80e741d35f -size 334 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_reset_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_reset_disabled.png deleted file mode 100644 index 2e4e403a30..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_reset_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2b343233ab25a73fcdb4fff5509011497814fc4cb591065bdb3043a0f1092577 -size 342 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_reset_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_reset_normal.png deleted file mode 100644 index 8d8b8a1bd9..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_reset_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1cc0183d7f57f15c4efeffb32795921f2f4e9c7965955fd0a392f826d5f6b6c8 -size 337 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_reset_viewport_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_reset_viewport_active.png deleted file mode 100644 index 41590634f5..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_reset_viewport_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9a8467c1dcc343f637e0f7f5071a20b8881a43d567fb32fd96f5383f7b69bbb6 -size 430 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_reset_viewport_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_reset_viewport_disabled.png deleted file mode 100644 index c6518416c0..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_reset_viewport_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0fd5ec79fc2c679f99ac5eb63d725f2cc815b09286bd0f3b5d2921eeb2e1e8cc -size 406 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_reset_viewport_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_reset_viewport_normal.png deleted file mode 100644 index eef1d5236f..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_reset_viewport_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3e19713b6586581d2336e833d8ecbd78b4b8f15b1c49a29d80acbf05e8aae3df -size 418 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_save.png b/Code/Sandbox/Editor/Material/images/materialdialog_save.png deleted file mode 100644 index 4408a8ba1d..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_save.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4de0f4a102e5c4990d5d23e22b5cdd16532192f3a125758b608cd8c731278898 -size 355 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_save_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_save_active.png deleted file mode 100644 index b0961d34a9..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_save_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d0b6f7c69112d124eac1123ffa840268c16148fef9ded3a67f84d3ad8d73eb96 -size 212 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_save_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_save_disabled.png deleted file mode 100644 index cc694f079f..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_save_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0b795fb88a6f301d7ecc9ce75141bdcf9e6dca25043730661aa4d1f09b055d6f -size 222 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_save_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_save_normal.png deleted file mode 100644 index 6293be8be5..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_save_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:88fbce753cdd9381a814e3b2ec5d16df7cc26f2a37ad30b7010be71ae9183510 -size 214 diff --git a/Code/Sandbox/Editor/PickObjectTool.cpp b/Code/Sandbox/Editor/PickObjectTool.cpp deleted file mode 100644 index dc1fce110e..0000000000 --- a/Code/Sandbox/Editor/PickObjectTool.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "EditorDefs.h" - -#include "PickObjectTool.h" - -// Editor -#include "Viewport.h" -#include "Include/HitContext.h" -#include "Objects/BaseObject.h" - - -////////////////////////////////////////////////////////////////////////// -CPickObjectTool::CPickObjectTool(IPickObjectCallback* callback, const QMetaObject* targetClass) -{ - assert(callback != 0); - m_callback = callback; - m_targetClass = targetClass; - m_bMultiPick = false; -} - -////////////////////////////////////////////////////////////////////////// -CPickObjectTool::~CPickObjectTool() -{ - GetIEditor()->GetObjectManager()->SetSelectCallback(0); - //m_prevSelectCallback = 0; - if (m_callback) - { - m_callback->OnCancelPick(); - } -} - -////////////////////////////////////////////////////////////////////////// -void CPickObjectTool::BeginEditParams([[maybe_unused]] IEditor* ie, [[maybe_unused]] int flags) -{ - QString str = "Pick object"; - if (m_targetClass) - { - str = tr("Pick %1 object").arg(m_targetClass->className()); - } - SetStatusText(str); - - //m_prevSelectCallback = - GetIEditor()->GetObjectManager()->SetSelectCallback(this); -} - -////////////////////////////////////////////////////////////////////////// -bool CPickObjectTool::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, [[maybe_unused]] int flags) -{ - if (event == eMouseLDown) - { - HitContext hitInfo; - view->HitTest(point, hitInfo); - CBaseObject* obj = hitInfo.object; - if (obj) - { - if (IsRelevant(obj)) - { - if (m_callback) - { - // Can pick this one. - m_callback->OnPick(obj); - } - if (!m_bMultiPick) - { - m_callback = 0; - GetIEditor()->SetEditTool(0); - } - } - } - } - else if (event == eMouseMove) - { - HitContext hitInfo; - view->HitTest(point, hitInfo); - CBaseObject* obj = hitInfo.object; - if (obj) - { - if (IsRelevant(obj)) - { - // Set Cursors. - view->SetCurrentCursor(STD_CURSOR_HIT, obj->GetName()); - } - } - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CPickObjectTool::OnSelectObject(CBaseObject* obj) -{ - if (IsRelevant(obj)) - { - // Can pick this one. - if (m_callback) - { - m_callback->OnPick(obj); - m_callback = 0; - } - if (!m_bMultiPick) - { - GetIEditor()->SetEditTool(0); - } - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CPickObjectTool::CanSelectObject(CBaseObject* obj) -{ - return IsRelevant(obj); -} - -////////////////////////////////////////////////////////////////////////// -bool CPickObjectTool::OnKeyDown([[maybe_unused]] CViewport* view, uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) -{ - if (nChar == VK_ESCAPE) - { - // Cancel selection. - GetIEditor()->SetEditTool(0); - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CPickObjectTool::IsRelevant(CBaseObject* obj) -{ - assert(obj != 0); - if (obj == NULL) - { - return false; - } - if (!m_callback) - { - return false; - } - - if (!m_targetClass) - { - return m_callback->OnPickFilter(obj); - } - else - { - if (obj->metaObject() == m_targetClass || m_targetClass->cast(obj)) - { - return m_callback->OnPickFilter(obj); - } - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CPickObjectTool::IsNeedSpecificBehaviorForSpaceAcce() -{ - if (m_callback && m_callback->IsNeedSpecificBehaviorForSpaceAcce()) - { - return true; - } - return false; -} - -#include diff --git a/Code/Sandbox/Editor/PickObjectTool.h b/Code/Sandbox/Editor/PickObjectTool.h deleted file mode 100644 index 3b0241042a..0000000000 --- a/Code/Sandbox/Editor/PickObjectTool.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : Definition of PickObjectTool, tool used to pick objects. - - -#ifndef CRYINCLUDE_EDITOR_PICKOBJECTTOOL_H -#define CRYINCLUDE_EDITOR_PICKOBJECTTOOL_H - -#if !defined(Q_MOC_RUN) -#include "EditTool.h" -#include "IObjectManager.h" -#endif - -#pragma once - -////////////////////////////////////////////////////////////////////////// -class CPickObjectTool - : public CEditTool - , public IObjectSelectCallback -{ - Q_OBJECT -public: - CPickObjectTool(IPickObjectCallback* callback, const QMetaObject* targetClass = NULL); - - //! If set to true, pick tool will not stop picking after first pick. - void SetMultiplePicks(bool bEnable) { m_bMultiPick = bEnable; }; - - // Ovverides from CEditTool - bool MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags); - - virtual void BeginEditParams(IEditor* ie, int flags); - virtual void EndEditParams() {}; - - virtual void Display([[maybe_unused]] DisplayContext& dc) {}; - virtual bool OnKeyDown(CViewport* view, uint32 nChar, uint32 nRepCnt, uint32 nFlags); - virtual bool OnKeyUp([[maybe_unused]] CViewport* view, [[maybe_unused]] uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) { return false; }; - - ////////////////////////////////////////////////////////////////////////// - // IObjectSelectCallback - ////////////////////////////////////////////////////////////////////////// - virtual bool OnSelectObject(CBaseObject* obj); - virtual bool CanSelectObject(CBaseObject* obj); - ////////////////////////////////////////////////////////////////////////// - - virtual bool IsNeedSpecificBehaviorForSpaceAcce(); - -protected: - virtual ~CPickObjectTool(); - // Delete itself. - void DeleteThis() { delete this; }; - -private: - bool IsRelevant(CBaseObject* obj); - - //! Object that requested pick. - IPickObjectCallback* m_callback; - - //! If target class specified, will pick only objects that belongs to that runtime class. - const QMetaObject* m_targetClass; - - bool m_bMultiPick; -}; - - -#endif // CRYINCLUDE_EDITOR_PICKOBJECTTOOL_H diff --git a/Code/Sandbox/Editor/QtViewPaneManager.cpp b/Code/Sandbox/Editor/QtViewPaneManager.cpp index ad33eecfee..b242f3d914 100644 --- a/Code/Sandbox/Editor/QtViewPaneManager.cpp +++ b/Code/Sandbox/Editor/QtViewPaneManager.cpp @@ -36,6 +36,8 @@ #include #include +#include + #include #include #include @@ -983,6 +985,11 @@ bool QtViewPaneManager::ClosePanesWithRollback(const QVector& panesToKe */ void QtViewPaneManager::RestoreDefaultLayout(bool resetSettings) { + // Get whether the prefab system is enabled + bool isPrefabSystemEnabled = false; + AzFramework::ApplicationRequests::Bus::BroadcastResult( + isPrefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled); + if (resetSettings) { // We're going to do something destructive (removing all of the viewpane settings). Better confirm with the user @@ -1022,7 +1029,11 @@ void QtViewPaneManager::RestoreDefaultLayout(bool resetSettings) state.viewPanes.push_back(LyViewPane::EntityInspector); state.viewPanes.push_back(LyViewPane::AssetBrowser); state.viewPanes.push_back(LyViewPane::Console); - state.viewPanes.push_back(LyViewPane::LevelInspector); + + if (!isPrefabSystemEnabled) + { + state.viewPanes.push_back(LyViewPane::LevelInspector); + } state.mainWindowState = m_defaultMainWindowState; @@ -1047,7 +1058,12 @@ void QtViewPaneManager::RestoreDefaultLayout(bool resetSettings) const QtViewPane* assetBrowserViewPane = OpenPane(LyViewPane::AssetBrowser, QtViewPane::OpenMode::UseDefaultState); const QtViewPane* entityInspectorViewPane = OpenPane(LyViewPane::EntityInspector, QtViewPane::OpenMode::UseDefaultState); const QtViewPane* consoleViewPane = OpenPane(LyViewPane::Console, QtViewPane::OpenMode::UseDefaultState); - const QtViewPane* levelInspectorPane = OpenPane(LyViewPane::LevelInspector, QtViewPane::OpenMode::UseDefaultState); + + const QtViewPane* levelInspectorPane = nullptr; + if (!isPrefabSystemEnabled) + { + levelInspectorPane = OpenPane(LyViewPane::LevelInspector, QtViewPane::OpenMode::UseDefaultState); + } // This class does all kinds of behind the scenes magic to make docking / restore work, especially with groups // so instead of doing our special default layout attach / docking right now, we want to make it happen diff --git a/Code/Sandbox/Editor/Resource.h b/Code/Sandbox/Editor/Resource.h index a4bd2c1143..afcd0c7a6f 100644 --- a/Code/Sandbox/Editor/Resource.h +++ b/Code/Sandbox/Editor/Resource.h @@ -181,8 +181,6 @@ #define ID_TV_STOP 33568 #define ID_TV_PAUSE 33569 #define ID_ADDNODE 33570 -#define ID_EDITTOOL_LINK 33571 -#define ID_EDITTOOL_UNLINK 33572 #define ID_ADDSCENETRACK 33573 #define ID_FIND 33574 #define ID_SNAP_TO_GRID 33575 @@ -214,7 +212,6 @@ #define ID_TV_JUMPSTART 33601 #define ID_TV_PREVKEY 33602 #define ID_TV_NEXTKEY 33603 -#define ID_OBJECTMODIFY_ALIGN 33604 #define ID_PLAY_LOOP 33607 #define ID_TERRAIN 33611 #define ID_OBJECTMODIFY_ALIGNTOGRID 33619 diff --git a/Code/Sandbox/Editor/ToolbarManager.cpp b/Code/Sandbox/Editor/ToolbarManager.cpp index 4679f9cb6a..d39dabf034 100644 --- a/Code/Sandbox/Editor/ToolbarManager.cpp +++ b/Code/Sandbox/Editor/ToolbarManager.cpp @@ -585,13 +585,6 @@ AmazonToolbar ToolbarManager::GetEditModeToolbar() const t.AddAction(ID_TOOLBAR_WIDGET_UNDO, ORIGINAL_TOOLBAR_VERSION); t.AddAction(ID_TOOLBAR_WIDGET_REDO, ORIGINAL_TOOLBAR_VERSION); - if (!GetIEditor()->IsNewViewportInteractionModelEnabled()) - { - t.AddAction(ID_TOOLBAR_SEPARATOR, ORIGINAL_TOOLBAR_VERSION); - t.AddAction(ID_EDITTOOL_LINK, ORIGINAL_TOOLBAR_VERSION); - t.AddAction(ID_EDITTOOL_UNLINK, ORIGINAL_TOOLBAR_VERSION); - } - t.AddAction(ID_TOOLBAR_SEPARATOR, ORIGINAL_TOOLBAR_VERSION); if (!GetIEditor()->IsNewViewportInteractionModelEnabled()) @@ -630,7 +623,6 @@ AmazonToolbar ToolbarManager::GetObjectToolbar() const AmazonToolbar t = AmazonToolbar("Object", QObject::tr("Object Toolbar")); t.SetMainToolbar(true); t.AddAction(ID_GOTO_SELECTED, ORIGINAL_TOOLBAR_VERSION); - t.AddAction(ID_OBJECTMODIFY_ALIGN, ORIGINAL_TOOLBAR_VERSION); t.AddAction(ID_OBJECTMODIFY_ALIGNTOGRID, ORIGINAL_TOOLBAR_VERSION); t.AddAction(ID_OBJECTMODIFY_SETHEIGHT, ORIGINAL_TOOLBAR_VERSION); t.AddAction(ID_MODIFY_ALIGNOBJTOSURF, ORIGINAL_TOOLBAR_VERSION); diff --git a/Code/Sandbox/Editor/ViewportManipulatorController.cpp b/Code/Sandbox/Editor/ViewportManipulatorController.cpp index 910d037670..8ce2ea1cd9 100644 --- a/Code/Sandbox/Editor/ViewportManipulatorController.cpp +++ b/Code/Sandbox/Editor/ViewportManipulatorController.cpp @@ -95,6 +95,11 @@ bool ViewportManipulatorControllerInstance::HandleInputChannelEvent(const AzFram AZStd::optional overrideButton; AZStd::optional eventType; + // Because we receive events multiple times at separate priorities for manipulator events and + // viewport interaction events, we want to avoid updating our "last tick state" until we're on our last event, + // which currently is the low priority Interaction processor. + const bool finishedProcessingEvents = event.m_priority == InteractionPriority; + if (IsMouseMove(event.m_inputChannel)) { // Cache the ray trace results when doing manipulator interaction checks, no need to recalculate after @@ -120,10 +125,11 @@ bool ViewportManipulatorControllerInstance::HandleInputChannelEvent(const AzFram } else if (auto mouseButton = GetMouseButton(event.m_inputChannel); mouseButton != MouseButton::None) { + const AZ::u32 mouseButtonValue = static_cast(mouseButton); overrideButton = mouseButton; if (event.m_inputChannel.GetState() == InputChannel::State::Began) { - m_state.m_mouseButtons.m_mouseButtons |= static_cast(mouseButton); + m_state.m_mouseButtons.m_mouseButtons |= mouseButtonValue; if (IsDoubleClick(mouseButton)) { // Only remove the double click flag once we're done processing both Manipulator and Interaction events @@ -135,8 +141,8 @@ bool ViewportManipulatorControllerInstance::HandleInputChannelEvent(const AzFram } else { - // Only insert the double click timing once we're done processing both Manipulator and Interaction events, to avoid a false IsDoubleClick positive - if (event.m_priority == InteractionPriority) + // Only insert the double click timing once we're done processing events, to avoid a false IsDoubleClick positive + if (finishedProcessingEvents) { m_pendingDoubleClicks[mouseButton] = m_curTime; } @@ -145,8 +151,18 @@ bool ViewportManipulatorControllerInstance::HandleInputChannelEvent(const AzFram } else if (event.m_inputChannel.GetState() == InputChannel::State::Ended) { - m_state.m_mouseButtons.m_mouseButtons &= ~static_cast(mouseButton); - eventType = MouseEvent::Up; + // If we've actually logged a mouse down event, forward a mouse up event. + // This prevents corner cases like the context menu thinking it should be opened even though no one clicked in this viewport, + // due to RenderViewportWidget ensuring all controllers get InputChannel::State::Ended events. + if (m_state.m_mouseButtons.m_mouseButtons & mouseButtonValue) + { + // Erase the button from our state if we're done processing events. + if (event.m_priority == InteractionPriority) + { + m_state.m_mouseButtons.m_mouseButtons &= ~mouseButtonValue; + } + eventType = MouseEvent::Up; + } } } else if (auto keyboardModifier = GetKeyboardModifier(event.m_inputChannel); keyboardModifier != KeyboardModifier::None) diff --git a/Code/Sandbox/Editor/editor_lib_files.cmake b/Code/Sandbox/Editor/editor_lib_files.cmake index 9084a566ae..5696931f26 100644 --- a/Code/Sandbox/Editor/editor_lib_files.cmake +++ b/Code/Sandbox/Editor/editor_lib_files.cmake @@ -316,8 +316,6 @@ set(FILES Material/MaterialHelpers.cpp Material/MaterialHelpers.h Material/MaterialDialog.qrc - Material/MaterialDialog.cpp - Material/MaterialDialog.h Material/MaterialPreviewModelView.cpp Material/MaterialPreviewModelView.h Material/PreviewModelView.cpp @@ -535,8 +533,6 @@ set(FILES Dialogs/PythonScriptsDialog.ui Dialogs/Generic/UserOptions.cpp Dialogs/Generic/UserOptions.h - AlignTool.cpp - AlignTool.h ObjectCloneTool.cpp ObjectCloneTool.h EditMode/SubObjectSelectionReferenceFrameCalculator.cpp @@ -547,10 +543,6 @@ set(FILES RotateTool.h EditTool.cpp EditTool.h - LinkTool.cpp - LinkTool.h - PickObjectTool.cpp - PickObjectTool.h VoxelAligningTool.cpp VoxelAligningTool.h Export/ExportManager.cpp @@ -632,8 +624,6 @@ set(FILES LensFlareEditor/LensFlareView.h LogFileImpl.cpp LogFileImpl.h - MatEditMainDlg.cpp - MatEditMainDlg.h MatEditPreviewDlg.cpp MatEditPreviewDlg.h Material/MaterialBrowser.cpp diff --git a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/ComponentEntityEditorPlugin.cpp b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/ComponentEntityEditorPlugin.cpp index 17face523b..e5ad2a2872 100644 --- a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/ComponentEntityEditorPlugin.cpp +++ b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/ComponentEntityEditorPlugin.cpp @@ -143,15 +143,6 @@ ComponentEntityEditorPlugin::ComponentEntityEditorPlugin([[maybe_unused]] IEdito LyViewPane::CategoryTools, pinnedInspectorOptions); - ViewPaneOptions levelInspectorOptions; - levelInspectorOptions.canHaveMultipleInstances = false; - levelInspectorOptions.preferedDockingArea = Qt::RightDockWidgetArea; - levelInspectorOptions.paneRect = QRect(50, 50, 400, 700); - RegisterViewPane( - LyViewPane::LevelInspector, - LyViewPane::CategoryTools, - levelInspectorOptions); - bool prefabSystemEnabled = false; AzFramework::ApplicationRequests::Bus::BroadcastResult(prefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled); @@ -170,8 +161,14 @@ ComponentEntityEditorPlugin::ComponentEntityEditorPlugin([[maybe_unused]] IEdito } else { - // Add the Legacy Outliner to the Tools Menu + ViewPaneOptions levelInspectorOptions; + levelInspectorOptions.canHaveMultipleInstances = false; + levelInspectorOptions.preferedDockingArea = Qt::RightDockWidgetArea; + levelInspectorOptions.paneRect = QRect(50, 50, 400, 700); + RegisterViewPane( + LyViewPane::LevelInspector, LyViewPane::CategoryTools, levelInspectorOptions); + // Add the Legacy Outliner to the Tools Menu ViewPaneOptions outlinerOptions; outlinerOptions.canHaveMultipleInstances = true; outlinerOptions.preferedDockingArea = Qt::LeftDockWidgetArea; diff --git a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp index d9e3d9bb8c..9c917b25c0 100644 --- a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp +++ b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp @@ -670,9 +670,13 @@ void SandboxIntegrationManager::PopulateEditorGlobalContextMenu(QMenu* menu, con action = menu->addAction(QObject::tr("Create layer")); QObject::connect(action, &QAction::triggered, [this] { ContextMenu_NewLayer(); }); + AzToolsFramework::EntityIdList entities; + AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult( + entities, + &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities); + SetupLayerContextMenu(menu); - AzToolsFramework::EntityIdSet flattenedSelection; - GetSelectedEntitiesSetWithFlattenedHierarchy(flattenedSelection); + AzToolsFramework::EntityIdSet flattenedSelection = AzToolsFramework::GetCulledEntityHierarchy(entities); AzToolsFramework::SetupAddToLayerMenu(menu, flattenedSelection, [this] { return ContextMenu_NewLayer(); }); SetupSliceContextMenu(menu); @@ -1220,10 +1224,14 @@ void SandboxIntegrationManager::CloneSelection(bool& handled) { AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework); - AzToolsFramework::EntityIdSet duplicationSet; - GetSelectedEntitiesSetWithFlattenedHierarchy(duplicationSet); + AzToolsFramework::EntityIdList entities; + AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult( + entities, + &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities); - if (duplicationSet.size() > 0) + AzToolsFramework::EntityIdSet duplicationSet = AzToolsFramework::GetCulledEntityHierarchy(entities); + + if (!duplicationSet.empty()) { AZStd::unordered_set clonedEntities; handled = AzToolsFramework::CloneInstantiatedEntities(duplicationSet, clonedEntities); diff --git a/Code/Tools/SceneAPI/SceneCore/Containers/SceneGraph.cpp b/Code/Tools/SceneAPI/SceneCore/Containers/SceneGraph.cpp index 934b0154c9..87c265481f 100644 --- a/Code/Tools/SceneAPI/SceneCore/Containers/SceneGraph.cpp +++ b/Code/Tools/SceneAPI/SceneCore/Containers/SceneGraph.cpp @@ -43,7 +43,7 @@ namespace AZ AZ::BehaviorContext* behaviorContext = azrtti_cast(context); if (behaviorContext) { - behaviorContext->Class() + behaviorContext->Class("NodeIndex") ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) ->Attribute(AZ::Script::Attributes::Module, "scene.graph") ->Constructor<>() @@ -57,7 +57,7 @@ namespace AZ ->Attribute(AZ::Script::Attributes::Operator, AZ::Script::Attributes::OperatorType::ToString) ; - behaviorContext->Class() + behaviorContext->Class("SceneGraphName") ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) ->Attribute(AZ::Script::Attributes::Module, "scene.graph") ->Constructor() diff --git a/Gems/AWSClientAuth/Code/Source/Authentication/AuthenticationProviderManager.cpp b/Gems/AWSClientAuth/Code/Source/Authentication/AuthenticationProviderManager.cpp index f6e5efd106..d4d2d0d67b 100644 --- a/Gems/AWSClientAuth/Code/Source/Authentication/AuthenticationProviderManager.cpp +++ b/Gems/AWSClientAuth/Code/Source/Authentication/AuthenticationProviderManager.cpp @@ -48,7 +48,7 @@ namespace AWSClientAuth m_settingsRegistry = AZStd::make_shared(); AZStd::array resolvedPath{}; - AZ::IO::FileIOBase::GetInstance()->ResolvePath(settingsRegistryPath.data(), resolvedPath.data(), resolvedPath.size()); + fileIO->ResolvePath(settingsRegistryPath.data(), resolvedPath.data(), resolvedPath.size()); if (!m_settingsRegistry->MergeSettingsFile(resolvedPath.data(), AZ::SettingsRegistryInterface::Format::JsonMergePatch)) diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/BuilderSettingManager.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/BuilderSettingManager.cpp index e30fb9c6a2..3b6c906c10 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/BuilderSettingManager.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/BuilderSettingManager.cpp @@ -524,6 +524,10 @@ namespace ImageProcessingAtom { return outPreset; } + else + { + AZ_Warning("Image Processing", false, "Image dimensions are not compatible with preset '%s'. The default preset will be used.", presetInfo->m_name.c_str()); + } } //uncompressed one which could be used for almost everything diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageBuilderComponent.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageBuilderComponent.cpp index 4de024c088..5d5fd21b44 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageBuilderComponent.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageBuilderComponent.cpp @@ -79,7 +79,7 @@ namespace ImageProcessingAtom builderDescriptor.m_busId = azrtti_typeid(); builderDescriptor.m_createJobFunction = AZStd::bind(&ImageBuilderWorker::CreateJobs, &m_imageBuilder, AZStd::placeholders::_1, AZStd::placeholders::_2); builderDescriptor.m_processJobFunction = AZStd::bind(&ImageBuilderWorker::ProcessJob, &m_imageBuilder, AZStd::placeholders::_1, AZStd::placeholders::_2); - builderDescriptor.m_version = 19; // [ATOM-14459] + builderDescriptor.m_version = 22; // [ATOM-14765] builderDescriptor.m_analysisFingerprint = ImageProcessingAtom::BuilderSettingManager::Instance()->GetAnalysisFingerprint(); m_imageBuilder.BusConnect(builderDescriptor.m_busId); AssetBuilderSDK::AssetBuilderBus::Broadcast(&AssetBuilderSDK::AssetBuilderBusTraits::RegisterBuilderInformation, builderDescriptor); diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Config/Albedo.preset b/Gems/Atom/Asset/ImageProcessingAtom/Config/Albedo.preset index d81fefede2..c00185e255 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Config/Albedo.preset +++ b/Gems/Atom/Asset/ImageProcessingAtom/Config/Albedo.preset @@ -11,6 +11,7 @@ "_basecolor", "_diff", "_color", + "_col", "_albedo", "_alb", "_bc", @@ -31,6 +32,7 @@ "FileMasks": [ "_diff", "_color", + "_col", "_albedo", "_alb", "_basecolor", @@ -51,6 +53,7 @@ "FileMasks": [ "_diff", "_color", + "_col", "_albedo", "_alb", "_basecolor", @@ -71,6 +74,7 @@ "FileMasks": [ "_diff", "_color", + "_col", "_albedo", "_alb", "_basecolor", @@ -91,6 +95,7 @@ "FileMasks": [ "_diff", "_color", + "_col", "_albedo", "_alb", "_basecolor", diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Config/AmbientOcclusion.preset b/Gems/Atom/Asset/ImageProcessingAtom/Config/AmbientOcclusion.preset index 222a1d4c7b..6b1197e28d 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Config/AmbientOcclusion.preset +++ b/Gems/Atom/Asset/ImageProcessingAtom/Config/AmbientOcclusion.preset @@ -9,7 +9,10 @@ "SourceColor": "Linear", "DestColor": "Linear", "FileMasks": [ - "_ao" + "_ao", + "_ambocc", + "_amb", + "_ambientocclusion" ], "PixelFormat": "BC4" }, @@ -33,7 +36,10 @@ "SourceColor": "Linear", "DestColor": "Linear", "FileMasks": [ - "_ao" + "_ao", + "_ambocc", + "_amb", + "_ambientocclusion" ], "PixelFormat": "EAC_R11" }, @@ -43,7 +49,10 @@ "SourceColor": "Linear", "DestColor": "Linear", "FileMasks": [ - "_ao" + "_ao", + "_ambocc", + "_amb", + "_ambientocclusion" ], "PixelFormat": "BC4" }, @@ -53,7 +62,10 @@ "SourceColor": "Linear", "DestColor": "Linear", "FileMasks": [ - "_ao" + "_ao", + "_ambocc", + "_amb", + "_ambientocclusion" ], "PixelFormat": "BC4" } diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Config/Displacement.preset b/Gems/Atom/Asset/ImageProcessingAtom/Config/Displacement.preset index 1cac9c1d3a..569ff6ce23 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Config/Displacement.preset +++ b/Gems/Atom/Asset/ImageProcessingAtom/Config/Displacement.preset @@ -9,12 +9,20 @@ "SourceColor": "Linear", "DestColor": "Linear", "FileMasks": [ - "_displ" + "_displ", + "_disp", + "_dsp", + "_d", + "_dm", + "_displacement", + "_height", + "_hm", + "_ht", + "_h" ], "PixelFormat": "BC4", "DiscardAlpha": true, "IsPowerOf2": true, - "Swizzle": "aaa1", "MipMapSetting": { "MipGenType": "Box" } @@ -26,13 +34,21 @@ "SourceColor": "Linear", "DestColor": "Linear", "FileMasks": [ - "_displ" + "_displ", + "_disp", + "_dsp", + "_d", + "_dm", + "_displacement", + "_height", + "_hm", + "_ht", + "_h" ], "PixelFormat": "EAC_R11", "DiscardAlpha": true, "IsPowerOf2": true, "SizeReduceLevel": 3, - "Swizzle": "aaa1", "MipMapSetting": { "MipGenType": "Box" } @@ -57,7 +73,6 @@ "PixelFormat": "EAC_R11", "DiscardAlpha": true, "IsPowerOf2": true, - "Swizzle": "aaa1", "MipMapSetting": { "MipGenType": "Box" } @@ -68,12 +83,20 @@ "SourceColor": "Linear", "DestColor": "Linear", "FileMasks": [ - "_displ" + "_displ", + "_disp", + "_dsp", + "_d", + "_dm", + "_displacement", + "_height", + "_hm", + "_ht", + "_h" ], "PixelFormat": "BC4", "DiscardAlpha": true, "IsPowerOf2": true, - "Swizzle": "aaa1", "MipMapSetting": { "MipGenType": "Box" } @@ -84,12 +107,20 @@ "SourceColor": "Linear", "DestColor": "Linear", "FileMasks": [ - "_displ" + "_displ", + "_disp", + "_dsp", + "_d", + "_dm", + "_displacement", + "_height", + "_hm", + "_ht", + "_h" ], "PixelFormat": "BC4", "DiscardAlpha": true, "IsPowerOf2": true, - "Swizzle": "aaa1", "MipMapSetting": { "MipGenType": "Box" } diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Config/Emissive.preset b/Gems/Atom/Asset/ImageProcessingAtom/Config/Emissive.preset index d3290eb469..5dc75397a0 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Config/Emissive.preset +++ b/Gems/Atom/Asset/ImageProcessingAtom/Config/Emissive.preset @@ -8,7 +8,11 @@ "Name": "Emissive", "RGB_Weight": "CIEXYZ", "FileMasks": [ - "_emissive" + "_emissive", + "_e", + "_glow", + "_em", + "_emit" ], "PixelFormat": "BC7", "DiscardAlpha": true @@ -33,7 +37,11 @@ "Name": "Emissive", "RGB_Weight": "CIEXYZ", "FileMasks": [ - "_emissive" + "_emissive", + "_e", + "_glow", + "_em", + "_emit" ], "PixelFormat": "ASTC_6x6", "DiscardAlpha": true @@ -43,7 +51,11 @@ "Name": "Emissive", "RGB_Weight": "CIEXYZ", "FileMasks": [ - "_emissive" + "_emissive", + "_e", + "_glow", + "_em", + "_emit" ], "PixelFormat": "BC7", "DiscardAlpha": true @@ -53,7 +65,11 @@ "Name": "Emissive", "RGB_Weight": "CIEXYZ", "FileMasks": [ - "_emissive" + "_emissive", + "_e", + "_glow", + "_em", + "_emit" ], "PixelFormat": "BC7", "DiscardAlpha": true diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Config/IBLSkybox.preset b/Gems/Atom/Asset/ImageProcessingAtom/Config/IBLSkybox.preset index 867fc73959..fef756e354 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Config/IBLSkybox.preset +++ b/Gems/Atom/Asset/ImageProcessingAtom/Config/IBLSkybox.preset @@ -27,7 +27,7 @@ }, "PlatformsPresets": { "es3": { - "UUID": "{E6441EAC-9843-484B-8EFC-C03B2935B48D}", + "UUID": "{E6441EAC-9843-484B-8EFC-C03B2935B48D}", "Name": "IBLSkybox", "FileMasks": [ "_iblskyboxcm" @@ -61,7 +61,7 @@ "MinTextureSize": 256, "IsPowerOf2": true, "CubemapSettings": { - "RequiresConvolve": false, + "RequiresConvolve": false, "GenerateIBLSpecular": true, "IBLSpecularPreset": "{908DA68C-97FB-4C4A-97BC-5A55F30F14FA}", "GenerateIBLDiffuse": true, @@ -69,7 +69,7 @@ } }, "osx_gl": { - "UUID": "{E6441EAC-9843-484B-8EFC-C03B2935B48D}", + "UUID": "{E6441EAC-9843-484B-8EFC-C03B2935B48D}", "Name": "IBLSkybox", "FileMasks": [ "_iblskyboxcm" diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Config/LayerMask.preset b/Gems/Atom/Asset/ImageProcessingAtom/Config/LayerMask.preset index 363a6f9f9d..66927b175c 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Config/LayerMask.preset +++ b/Gems/Atom/Asset/ImageProcessingAtom/Config/LayerMask.preset @@ -9,7 +9,8 @@ "SourceColor": "Linear", "DestColor": "Linear", "FileMasks": [ - "_layers" + "_layers", + "_rgbmask" ], "PixelFormat": "R8G8B8X8" }, @@ -20,7 +21,8 @@ "SourceColor": "Linear", "DestColor": "Linear", "FileMasks": [ - "_layers" + "_layers", + "_rgbmask" ], "PixelFormat": "R8G8B8X8" }, @@ -30,7 +32,8 @@ "SourceColor": "Linear", "DestColor": "Linear", "FileMasks": [ - "_layers" + "_layers", + "_rgbmask" ], "PixelFormat": "R8G8B8X8" }, @@ -40,7 +43,8 @@ "SourceColor": "Linear", "DestColor": "Linear", "FileMasks": [ - "_layers" + "_layers", + "_rgbmask" ], "PixelFormat": "R8G8B8X8" }, @@ -50,7 +54,8 @@ "SourceColor": "Linear", "DestColor": "Linear", "FileMasks": [ - "_layers" + "_layers", + "_rgbmask" ], "PixelFormat": "R8G8B8X8" } diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Config/NormalsWithSmoothness.preset b/Gems/Atom/Asset/ImageProcessingAtom/Config/NormalsWithSmoothness.preset index fb8b1da6a4..2c61d6f5a6 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Config/NormalsWithSmoothness.preset +++ b/Gems/Atom/Asset/ImageProcessingAtom/Config/NormalsWithSmoothness.preset @@ -9,7 +9,11 @@ "SourceColor": "Linear", "DestColor": "Linear", "FileMasks": [ - "_ddna" + "_ddna", + "_normala", + "_nrma", + "_nma", + "_na" ], "PixelFormat": "BC5s", "PixelFormatAlpha": "BC4", @@ -48,7 +52,11 @@ "SourceColor": "Linear", "DestColor": "Linear", "FileMasks": [ - "_ddna" + "_ddna", + "_normala", + "_nrma", + "_nma", + "_na" ], "PixelFormat": "ASTC_4x4", "PixelFormatAlpha": "ASTC_4x4", @@ -65,7 +73,11 @@ "SourceColor": "Linear", "DestColor": "Linear", "FileMasks": [ - "_ddna" + "_ddna", + "_normala", + "_nrma", + "_nma", + "_na" ], "PixelFormat": "BC5s", "PixelFormatAlpha": "BC4", @@ -82,7 +94,11 @@ "SourceColor": "Linear", "DestColor": "Linear", "FileMasks": [ - "_ddna" + "_ddna", + "_normala", + "_nrma", + "_nma", + "_na" ], "PixelFormat": "BC5s", "PixelFormatAlpha": "BC4", diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Config/Opacity.preset b/Gems/Atom/Asset/ImageProcessingAtom/Config/Opacity.preset index bd9299d71d..79fb235508 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Config/Opacity.preset +++ b/Gems/Atom/Asset/ImageProcessingAtom/Config/Opacity.preset @@ -11,7 +11,14 @@ "FileMasks": [ "_sss", "_trans", - "_opac" + "_opac", + "_opacity", + "_o", + "_opac", + "_op", + "_mask", + "_msk", + "_blend" ], "PixelFormat": "BC4", "IsPowerOf2": true, @@ -28,7 +35,14 @@ "FileMasks": [ "_sss", "_trans", - "_opac" + "_opac", + "_opacity", + "_o", + "_opac", + "_op", + "_mask", + "_msk", + "_blend" ], "PixelFormat": "EAC_R11", "IsPowerOf2": true, @@ -67,7 +81,14 @@ "FileMasks": [ "_sss", "_trans", - "_opac" + "_opac", + "_opacity", + "_o", + "_opac", + "_op", + "_mask", + "_msk", + "_blend" ], "PixelFormat": "BC4", "IsPowerOf2": true, @@ -83,7 +104,14 @@ "FileMasks": [ "_sss", "_trans", - "_opac" + "_opac", + "_opacity", + "_o", + "_opac", + "_op", + "_mask", + "_msk", + "_blend" ], "PixelFormat": "BC4", "IsPowerOf2": true, diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Config/Reflectance.preset b/Gems/Atom/Asset/ImageProcessingAtom/Config/Reflectance.preset index ca773debbb..7a6af50728 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Config/Reflectance.preset +++ b/Gems/Atom/Asset/ImageProcessingAtom/Config/Reflectance.preset @@ -24,7 +24,8 @@ "_mt", "_metalness", "_metallic", - "_roughness" + "_roughness", + "_rough" ], "PixelFormat": "BC1", "IsPowerOf2": true, @@ -53,7 +54,8 @@ "_mt", "_metalness", "_metallic", - "_roughness" + "_roughness", + "_rough" ], "PixelFormat": "ETC2", "IsPowerOf2": true, @@ -81,7 +83,8 @@ "_mt", "_metalness", "_metallic", - "_roughness" + "_roughness", + "_rough" ], "PixelFormat": "ASTC_6x6", "IsPowerOf2": true, @@ -109,7 +112,8 @@ "_mt", "_metalness", "_metallic", - "_roughness" + "_roughness", + "_rough" ], "PixelFormat": "BC1", "IsPowerOf2": true, @@ -137,7 +141,8 @@ "_mt", "_metalness", "_metallic", - "_roughness" + "_roughness", + "_rough" ], "PixelFormat": "BC1", "IsPowerOf2": true, diff --git a/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderVariantAssetBuilder.cpp b/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderVariantAssetBuilder.cpp index 1e3c7b6759..3572fb72ae 100644 --- a/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderVariantAssetBuilder.cpp +++ b/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderVariantAssetBuilder.cpp @@ -407,17 +407,20 @@ namespace AZ const auto& jobParameters = request.m_jobDescription.m_jobParameters; if (jobParameters.find(ShaderVariantLoadErrorParam) != jobParameters.end()) { - if (jobParameters.find(ShouldExitEarlyFromProcessJobParam) != jobParameters.end()) - { - AZ_TracePrintf(ShaderVariantAssetBuilderName, "Doing nothing on behalf of [%s] because it's been overriden by game project.", jobParameters.at(ShaderVariantLoadErrorParam).c_str()); - response.m_resultCode = AssetBuilderSDK::ProcessJobResult_Success; - return; - } AZ_Error(ShaderVariantAssetBuilderName, false, "Error during CreateJobs: %s", jobParameters.at(ShaderVariantLoadErrorParam).c_str()); response.m_resultCode = AssetBuilderSDK::ProcessJobResult_Failed; return; } + if (jobParameters.find(ShouldExitEarlyFromProcessJobParam) != jobParameters.end()) + { + AZ_TracePrintf( + ShaderVariantAssetBuilderName, "Doing nothing on behalf of [%s] because it's been overriden by game project.", + jobParameters.at(ShaderVariantLoadErrorParam).c_str()); + response.m_resultCode = AssetBuilderSDK::ProcessJobResult_Success; + return; + } + AssetBuilderSDK::JobCancelListener jobCancelListener(request.m_jobId); if (jobCancelListener.IsCancelled()) { diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Utils/LightingPreset.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Utils/LightingPreset.h index 1c220e0d8d..f1d8337a35 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Utils/LightingPreset.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Utils/LightingPreset.h @@ -78,7 +78,6 @@ namespace AZ AZ_CLASS_ALLOCATOR(LightingPreset, AZ::SystemAllocator, 0); static void Reflect(AZ::ReflectContext* context); - bool m_autoSelect = false; AZStd::string m_displayName; AZ::Data::Asset m_iblDiffuseImageAsset; AZ::Data::Asset m_iblSpecularImageAsset; diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Utils/ModelPreset.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Utils/ModelPreset.h index 896d6fb78f..9ca8c13859 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Utils/ModelPreset.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Utils/ModelPreset.h @@ -32,7 +32,6 @@ namespace AZ AZ_CLASS_ALLOCATOR(ModelPreset, AZ::SystemAllocator, 0); static void Reflect(AZ::ReflectContext* context); - bool m_autoSelect = false; AZStd::string m_displayName; AZ::Data::Asset m_modelAsset; AZ::Data::Asset m_previewImageAsset; diff --git a/Gems/Atom/Feature/Common/Code/Source/Utils/EditorLightingPreset.cpp b/Gems/Atom/Feature/Common/Code/Source/Utils/EditorLightingPreset.cpp index e7f9c8b09f..1da9463bd8 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Utils/EditorLightingPreset.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Utils/EditorLightingPreset.cpp @@ -112,7 +112,6 @@ namespace AZ ->ClassElement(AZ::Edit::ClassElements::EditorData, "") ->Attribute(AZ::Edit::Attributes::AutoExpand, true) ->DataElement(AZ::Edit::UIHandlers::Default, &LightingPreset::m_displayName, "Display Name", "Identifier used for display and selection") - ->DataElement(AZ::Edit::UIHandlers::Default, &LightingPreset::m_autoSelect, "Auto Select", "When true, the configuration is automatically selected when loaded") ->DataElement(AZ::Edit::UIHandlers::Default, &LightingPreset::m_iblDiffuseImageAsset, "IBL Diffuse Image Asset", "IBL diffuse image asset reference") ->DataElement(AZ::Edit::UIHandlers::Default, &LightingPreset::m_iblSpecularImageAsset, "IBL Specular Image Asset", "IBL specular image asset reference") ->DataElement(AZ::Edit::UIHandlers::Default, &LightingPreset::m_skyboxImageAsset, "Skybox Image Asset", "Skybox image asset reference") diff --git a/Gems/Atom/Feature/Common/Code/Source/Utils/EditorModelPreset.cpp b/Gems/Atom/Feature/Common/Code/Source/Utils/EditorModelPreset.cpp index b8b0b610f3..bed320c45d 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Utils/EditorModelPreset.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Utils/EditorModelPreset.cpp @@ -32,7 +32,6 @@ namespace AZ ->ClassElement(AZ::Edit::ClassElements::EditorData, "") ->Attribute(AZ::Edit::Attributes::AutoExpand, true) ->DataElement(AZ::Edit::UIHandlers::Default, &ModelPreset::m_displayName, "Display Name", "Identifier used for display and selection") - ->DataElement(AZ::Edit::UIHandlers::Default, &ModelPreset::m_autoSelect, "Auto Select", "When true, the configuration is automatically selected when loaded") ->DataElement(AZ::Edit::UIHandlers::Default, &ModelPreset::m_modelAsset, "Model Asset", "Model asset reference") ->DataElement(AZ::Edit::UIHandlers::Default, &ModelPreset::m_previewImageAsset, "Preview Image Asset", "Preview image asset reference") ; diff --git a/Gems/Atom/Feature/Common/Code/Source/Utils/LightingPreset.cpp b/Gems/Atom/Feature/Common/Code/Source/Utils/LightingPreset.cpp index 837a725a9f..77924b87a3 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Utils/LightingPreset.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Utils/LightingPreset.cpp @@ -105,8 +105,7 @@ namespace AZ serializeContext->RegisterGenericType>(); serializeContext->Class() - ->Version(4) - ->Field("autoSelect", &LightingPreset::m_autoSelect) + ->Version(5) ->Field("displayName", &LightingPreset::m_displayName) ->Field("iblDiffuseImageAsset", &LightingPreset::m_iblDiffuseImageAsset) ->Field("iblSpecularImageAsset", &LightingPreset::m_iblSpecularImageAsset) @@ -128,7 +127,6 @@ namespace AZ ->Attribute(AZ::Script::Attributes::Module, "render") ->Constructor() ->Constructor() - ->Property("autoSelect", BehaviorValueProperty(&LightingPreset::m_autoSelect)) ->Property("displayName", BehaviorValueProperty(&LightingPreset::m_displayName)) ->Property("alternateSkyboxImageAsset", BehaviorValueProperty(&LightingPreset::m_alternateSkyboxImageAsset)) ->Property("skyboxImageAsset", BehaviorValueProperty(&LightingPreset::m_skyboxImageAsset)) diff --git a/Gems/Atom/Feature/Common/Code/Source/Utils/ModelPreset.cpp b/Gems/Atom/Feature/Common/Code/Source/Utils/ModelPreset.cpp index e93bfa527a..2795617c18 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Utils/ModelPreset.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Utils/ModelPreset.cpp @@ -25,8 +25,7 @@ namespace AZ if (auto serializeContext = azrtti_cast(context)) { serializeContext->Class() - ->Version(2) - ->Field("autoSelect", &ModelPreset::m_autoSelect) + ->Version(3) ->Field("displayName", &ModelPreset::m_displayName) ->Field("modelAsset", &ModelPreset::m_modelAsset) ->Field("previewImageAsset", &ModelPreset::m_previewImageAsset) @@ -41,7 +40,6 @@ namespace AZ ->Attribute(AZ::Script::Attributes::Module, "render") ->Constructor() ->Constructor() - ->Property("autoSelect", BehaviorValueProperty(&ModelPreset::m_autoSelect)) ->Property("displayName", BehaviorValueProperty(&ModelPreset::m_displayName)) ->Property("modelAsset", BehaviorValueProperty(&ModelPreset::m_modelAsset)) ->Property("previewImageAsset", BehaviorValueProperty(&ModelPreset::m_previewImageAsset)) diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialPropertyValue.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialPropertyValue.h index cafd31d8a5..758afb1c66 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialPropertyValue.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialPropertyValue.h @@ -65,6 +65,7 @@ namespace AZ MaterialPropertyValue(const Vector4& value) : m_value(value) {} MaterialPropertyValue(const Color& value) : m_value(value) {} MaterialPropertyValue(const Data::Asset& value) : m_value(value) {} + MaterialPropertyValue(const Data::Instance& value) : m_value(value) {} MaterialPropertyValue(const AZStd::string& value) : m_value(value) {} //! Copy constructor diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Buffer/Buffer.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Buffer/Buffer.cpp index 81fd9e751b..afcf4670f3 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Buffer/Buffer.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Buffer/Buffer.cpp @@ -74,7 +74,8 @@ namespace AZ const RHI::BufferView* Buffer::GetBufferView() const { - if(RHI::CheckBitsAny(m_rhiBuffer->GetDescriptor().m_bindFlags, RHI::BufferBindFlags::InputAssembly | RHI::BufferBindFlags::DynamicInputAssembly)) + if (m_rhiBuffer->GetDescriptor().m_bindFlags == RHI::BufferBindFlags::InputAssembly || + m_rhiBuffer->GetDescriptor().m_bindFlags == RHI::BufferBindFlags::DynamicInputAssembly) { AZ_Assert(false, "Input assembly buffer doesn't need a regular buffer view, it requires a stream or index buffer view."); diff --git a/Gems/Atom/TestData/TestData/LightingPresets/urban_street_02.lightingpreset.azasset b/Gems/Atom/TestData/TestData/LightingPresets/urban_street_02.lightingpreset.azasset index d0a290649b..a676d5fba6 100644 --- a/Gems/Atom/TestData/TestData/LightingPresets/urban_street_02.lightingpreset.azasset +++ b/Gems/Atom/TestData/TestData/LightingPresets/urban_street_02.lightingpreset.azasset @@ -3,7 +3,6 @@ "Version": 1, "ClassName": "AZ::Render::LightingPreset", "ClassData": { - "autoSelect": false, "displayName": "Urban Street 02", "skyboxImageAsset": { "assetId": { diff --git a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material index c013eecae5..e84c6296be 100644 --- a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material +++ b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material @@ -7,7 +7,7 @@ "layer1_ambientOcclusion": { "enable": true, "factor": 1.6399999856948853, - "textureMap": "TestData/Textures/cc0/bark1disp2.jpg" + "textureMap": "TestData/Textures/cc0/bark1_disp.jpg" }, "layer1_baseColor": { "color": [ @@ -16,7 +16,7 @@ 0.12039368599653244, 1.0 ], - "textureMap": "TestData/Textures/cc0/bark1col.jpg" + "textureMap": "TestData/Textures/cc0/bark1_col.jpg" }, "layer1_emissive": { "color": [ @@ -30,16 +30,16 @@ "layer1_normal": { "factor": 0.4444443881511688, "flipY": true, - "textureMap": "TestData/Textures/cc0/bark1norm.jpg" + "textureMap": "TestData/Textures/cc0/bark1_norm.jpg" }, "layer1_parallax": { "enable": true, "factor": 0.02500000037252903, - "textureMap": "TestData/Textures/cc0/bark1disp2.jpg" + "textureMap": "TestData/Textures/cc0/bark1_disp.jpg" }, "layer1_roughness": { "lowerBound": 0.010100999847054482, - "textureMap": "TestData/Textures/cc0/bark1roughness.jpg" + "textureMap": "TestData/Textures/cc0/bark1_roughness.jpg" }, "layer1_specularF0": { "factor": 0.5099999904632568, @@ -55,7 +55,7 @@ }, "layer2_ambientOcclusion": { "factor": 1.2200000286102296, - "textureMap": "TestData/Textures/cc0/bark1disp2.jpg" + "textureMap": "TestData/Textures/cc0/bark1_disp.jpg" }, "layer2_baseColor": { "textureMap": "TestData/Textures/cc0/Lava004_1K_Color.jpg" diff --git a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/002_ParallaxPdo.material b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/002_ParallaxPdo.material index 471b437bd2..126e1a7fcb 100644 --- a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/002_ParallaxPdo.material +++ b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/002_ParallaxPdo.material @@ -5,18 +5,18 @@ "propertyLayoutVersion": 3, "properties": { "layer1_baseColor": { - "textureMap": "TestData/Textures/cc0/bark1col.jpg" + "textureMap": "TestData/Textures/cc0/bark1_col.jpg" }, "layer1_normal": { - "textureMap": "TestData/Textures/cc0/bark1norm.jpg" + "textureMap": "TestData/Textures/cc0/bark1_norm.jpg" }, "layer1_parallax": { "enable": true, "factor": 0.03999999910593033, - "textureMap": "TestData/Textures/cc0/bark1disp2.jpg" + "textureMap": "TestData/Textures/cc0/bark1_disp.jpg" }, "layer1_roughness": { - "textureMap": "TestData/Textures/cc0/bark1roughness.jpg" + "textureMap": "TestData/Textures/cc0/bark1_roughness.jpg" }, "layer2_baseColor": { "textureMap": "TestData/Textures/cc0/Rock030_2K_Color.jpg" diff --git a/Gems/Atom/TestData/TestData/Textures/cc0/bark1_col.jpg b/Gems/Atom/TestData/TestData/Textures/cc0/bark1_col.jpg new file mode 100644 index 0000000000..0a4c5f380c --- /dev/null +++ b/Gems/Atom/TestData/TestData/Textures/cc0/bark1_col.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bd44119610135ca5674de7144647df6580d7ac3e03576e9a8e87e741548e7364 +size 2105853 diff --git a/Gems/Atom/TestData/TestData/Textures/cc0/bark1_disp.jpg b/Gems/Atom/TestData/TestData/Textures/cc0/bark1_disp.jpg new file mode 100644 index 0000000000..57c74af488 --- /dev/null +++ b/Gems/Atom/TestData/TestData/Textures/cc0/bark1_disp.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4dbb74aac2450d6457bb02d36bd3d74e671c2dc7e938e090331151ecc52d545b +size 845683 diff --git a/Gems/Atom/TestData/TestData/Textures/cc0/bark1_norm.jpg b/Gems/Atom/TestData/TestData/Textures/cc0/bark1_norm.jpg new file mode 100644 index 0000000000..41b1d6d30b --- /dev/null +++ b/Gems/Atom/TestData/TestData/Textures/cc0/bark1_norm.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e69a3844c3a595245619a9dda4ed8981476a516ad3648a8b4dfb8151a68b0db5 +size 4439966 diff --git a/Gems/Atom/TestData/TestData/Textures/cc0/bark1_roughness.jpg b/Gems/Atom/TestData/TestData/Textures/cc0/bark1_roughness.jpg new file mode 100644 index 0000000000..2e7ccba4e0 --- /dev/null +++ b/Gems/Atom/TestData/TestData/Textures/cc0/bark1_roughness.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a8caa5961599624a6414d7277c389dd85b175b9587989b815ffd90aff8f62b6c +size 1747230 diff --git a/Gems/Atom/TestData/TestData/Textures/cc0/bark1col.jpg b/Gems/Atom/TestData/TestData/Textures/cc0/bark1col.jpg deleted file mode 100644 index 944a968d5b..0000000000 --- a/Gems/Atom/TestData/TestData/Textures/cc0/bark1col.jpg +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:24f5c234f11a1b29de9000b5a7ba74262f1bc5ebd2227ca1e85a12fa0e8b5237 -size 8273450 diff --git a/Gems/Atom/TestData/TestData/Textures/cc0/bark1disp.jpg b/Gems/Atom/TestData/TestData/Textures/cc0/bark1disp.jpg deleted file mode 100644 index c8a2a44e9b..0000000000 --- a/Gems/Atom/TestData/TestData/Textures/cc0/bark1disp.jpg +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0112ac235da74c60105b0e1a2da49c1e4ab7b89a60960a60cec54ad65db0b4b6 -size 4585685 diff --git a/Gems/Atom/TestData/TestData/Textures/cc0/bark1disp2.jpg b/Gems/Atom/TestData/TestData/Textures/cc0/bark1disp2.jpg deleted file mode 100644 index f93d68141b..0000000000 --- a/Gems/Atom/TestData/TestData/Textures/cc0/bark1disp2.jpg +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6a202449e5d787e76d959b6bee7a4b60b3821441ac918944c21358742ed1c546 -size 878112 diff --git a/Gems/Atom/TestData/TestData/Textures/cc0/bark1norm.jpg b/Gems/Atom/TestData/TestData/Textures/cc0/bark1norm.jpg deleted file mode 100644 index f68ed8b696..0000000000 --- a/Gems/Atom/TestData/TestData/Textures/cc0/bark1norm.jpg +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b0100b3c356d76ae1cb4c42bd4cc9c58ff359155aab6b9e3c1b205fe25956738 -size 16848020 diff --git a/Gems/Atom/TestData/TestData/Textures/cc0/bark1roughness.jpg b/Gems/Atom/TestData/TestData/Textures/cc0/bark1roughness.jpg deleted file mode 100644 index f6e7acd7b6..0000000000 --- a/Gems/Atom/TestData/TestData/Textures/cc0/bark1roughness.jpg +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:11badf07e6a7d0501c915f669ff1b14c8744d427d47d06e2fdca46b8f86839c9 -size 4441528 diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp index e08a5a045c..bf46ece27b 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp @@ -164,6 +164,8 @@ namespace AtomToolsFramework bool RenderViewportWidget::OnInputChannelEventFiltered(const AzFramework::InputChannel& inputChannel) { + bool shouldConsumeEvent = true; + // Grab keyboard focus if we've been clicked on. // Qt normally handles this for us, but we're filtering native events before they get // synthesized into QMouseEvents. @@ -175,9 +177,18 @@ namespace AtomToolsFramework // Don't consume new input events if we don't currently have focus. // We do forward Ended events, as they may be relevant to our current state // (e.g. a key gets released after we lose focus, it shouldn't remain "stuck"). - if (!hasFocus() && inputChannel.GetState() != AzFramework::InputChannel::State::Ended) + if (!hasFocus()) { - return false; + if (inputChannel.GetState() == AzFramework::InputChannel::State::Ended) + { + // Forward the input ended event to our controllers, but don't prevent other viewports from receiving it. + shouldConsumeEvent = false; + } + else + { + // Not an event we should listen to, abort. + return false; + } } // If we receive a mouse button event from outside of our viewport, ignore it even if we have focus. @@ -196,7 +207,9 @@ namespace AtomToolsFramework } AzFramework::NativeWindowHandle windowId = reinterpret_cast(winId()); - return m_controllerList->HandleInputChannelEvent({GetId(), windowId, inputChannel}); + const bool eventHandled = m_controllerList->HandleInputChannelEvent({GetId(), windowId, inputChannel}); + // If our controllers handled the event and it's one we can safely consume (i.e. it's not an Ended event that other viewports might need), consume it. + return eventHandled && shouldConsumeEvent; } void RenderViewportWidget::OnTick([[maybe_unused]]float deltaTime, AZ::ScriptTimePoint time) diff --git a/Gems/Atom/Tools/MaterialEditor/Assets/MaterialEditor/LightingPresets/_TEMPLATE_.lightingconfig.json.template b/Gems/Atom/Tools/MaterialEditor/Assets/MaterialEditor/LightingPresets/_TEMPLATE_.lightingconfig.json.template index 7cfa7edbc3..6d87c5eb7b 100644 --- a/Gems/Atom/Tools/MaterialEditor/Assets/MaterialEditor/LightingPresets/_TEMPLATE_.lightingconfig.json.template +++ b/Gems/Atom/Tools/MaterialEditor/Assets/MaterialEditor/LightingPresets/_TEMPLATE_.lightingconfig.json.template @@ -2,7 +2,6 @@ "configurations": [ { "displayName": "Substance: