diff --git a/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterCapsuleDamage.py b/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterCapsuleDamage.py index 80f83b26e2..a961ccdc52 100755 --- a/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterCapsuleDamage.py +++ b/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterCapsuleDamage.py @@ -17,7 +17,7 @@ from ActorSplitsAfterDamage import Tests def run(): from ActorSplitsAfterDamage import run as internal_run - from Utils import Constants + from editor_python_test_tools.utils import Constants def CapsuleDamage(target_id, position0): position1 = azlmbr.object.construct('Vector3', position0.x + 1.0, position0.y, position0.z) diff --git a/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterCollision.py b/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterCollision.py index d141cd3ce1..5692773d6d 100755 --- a/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterCollision.py +++ b/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterCollision.py @@ -54,14 +54,14 @@ def run(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus - from Utils import CollisionHandler - from Utils import BlastNotificationHandler + from editor_python_test_tools.utils import CollisionHandler + from editor_python_test_tools.utils import BlastNotificationHandler # Constants TIMEOUT = 2.0 diff --git a/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterDamage.py b/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterDamage.py index e991daebcd..ddd90ca89a 100755 --- a/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterDamage.py +++ b/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterDamage.py @@ -50,13 +50,13 @@ def run(damage_func): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus - from Utils import BlastNotificationHandler + from editor_python_test_tools.utils import BlastNotificationHandler # Constants TIMEOUT = 2.0 diff --git a/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterImpactSpreadDamage.py b/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterImpactSpreadDamage.py index 9139fe02b1..9b3fd1e596 100755 --- a/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterImpactSpreadDamage.py +++ b/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterImpactSpreadDamage.py @@ -17,7 +17,7 @@ from ActorSplitsAfterDamage import Tests def run(): from ActorSplitsAfterDamage import run as internal_run - from Utils import Constants + from editor_python_test_tools.utils import Constants def ImpactSpreadDamage(target_id, position): azlmbr.destruction.BlastFamilyDamageRequestBus(azlmbr.bus.Event, "Impact Spread Damage", target_id, diff --git a/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterRadialDamage.py b/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterRadialDamage.py index 77b942e95c..a219e63d34 100755 --- a/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterRadialDamage.py +++ b/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterRadialDamage.py @@ -17,7 +17,7 @@ from ActorSplitsAfterDamage import Tests def run(): from ActorSplitsAfterDamage import run as internal_run - from Utils import Constants + from editor_python_test_tools.utils import Constants def RadialDamage(target_id, position): azlmbr.destruction.BlastFamilyDamageRequestBus(azlmbr.bus.Event, "Radial Damage", target_id, diff --git a/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterShearDamage.py b/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterShearDamage.py index 404e655d36..e775be302d 100755 --- a/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterShearDamage.py +++ b/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterShearDamage.py @@ -17,7 +17,7 @@ from ActorSplitsAfterDamage import Tests def run(): from ActorSplitsAfterDamage import run as internal_run - from Utils import Constants + from editor_python_test_tools.utils import Constants def ShearDamage(target_id, position): normal = azlmbr.object.construct('Vector3', 1.0, 0.0, 0.0) diff --git a/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterStressDamage.py b/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterStressDamage.py index be002d5451..0195190348 100755 --- a/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterStressDamage.py +++ b/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterStressDamage.py @@ -17,7 +17,7 @@ from ActorSplitsAfterDamage import Tests def run(): from ActorSplitsAfterDamage import run as internal_run - from Utils import Constants + from editor_python_test_tools.utils import Constants def StressDamage(target_id, position): force = azlmbr.object.construct('Vector3', 0.0, 0.0, -100.0) # Should be enough to break `brittle` objects diff --git a/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterTriangleDamage.py b/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterTriangleDamage.py index 4635d67455..0351fe42e2 100755 --- a/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterTriangleDamage.py +++ b/AutomatedTesting/Gem/PythonTests/Blast/ActorSplitsAfterTriangleDamage.py @@ -17,7 +17,7 @@ from ActorSplitsAfterDamage import Tests def run(): from ActorSplitsAfterDamage import run as internal_run - from Utils import Constants + from editor_python_test_tools.utils import Constants def TriangleDamage(target_id, position): # Some points that form a triangle that contains the given position diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ComponentUpdateListProperty_test.py b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ComponentUpdateListProperty_test.py index 3ac4832428..9ab83a0723 100755 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ComponentUpdateListProperty_test.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ComponentUpdateListProperty_test.py @@ -16,7 +16,7 @@ import logging # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip("ly_test_tools") import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra logger = logging.getLogger(__name__) test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/EditorUtilityCommands_legacy_test_case.py b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/EditorUtilityCommands_legacy_test_case.py index 9bb9ba5337..9160530ba4 100755 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/EditorUtilityCommands_legacy_test_case.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/EditorUtilityCommands_legacy_test_case.py @@ -27,15 +27,6 @@ def testing_cvar(setMethod, methodName, label, value, compare): print('{} failed'.format(methodName)) -def testing_edit_mode(mode): - general.set_edit_mode(mode) - - if (general.get_edit_mode(mode)): - return True - - return False - - def testing_axis_constraints(constraint): general.set_axis_constraint(constraint) @@ -58,15 +49,6 @@ compare = lambda lhs, rhs: rhs == int(lhs) testing_cvar(general.set_cvar_integer, 'set_cvar_integer', 'sys_LocalMemoryGeometryLimit', 33, compare) -# ----- Test Edit Mode - -if (testing_edit_mode("SELECT") and testing_edit_mode('SELECTAREA') and - testing_edit_mode("MOVE") and testing_edit_mode("ROTATE") and - testing_edit_mode("SCALE") and testing_edit_mode("TOOL")): - - print("edit mode works") - - # ----- Test Axis Constraints if (testing_axis_constraints("X") and testing_axis_constraints("Y") and diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/EditorUtilityCommands_test.py b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/EditorUtilityCommands_test.py index 6261312814..bc258cce3f 100755 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/EditorUtilityCommands_test.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/EditorUtilityCommands_test.py @@ -33,7 +33,6 @@ class TestEditorAutomation(object): "SetCVarFromFloat worked", "SetCVarFromString worked", "SetCVarFromInteger worked", - "edit mode works", "axis constraint works", "end of editor utility tests" ] @@ -48,7 +47,6 @@ class TestEditorAutomation(object): "set_cvar_float worked", "set_cvar_string worked", "set_cvar_integer worked", - "edit mode works", "axis constraint works", "end of editor utility tests" ] diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/EditorUtilityCommands_test_case.py b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/EditorUtilityCommands_test_case.py index bae7da19b0..91dd883a10 100755 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/EditorUtilityCommands_test_case.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/EditorUtilityCommands_test_case.py @@ -28,15 +28,6 @@ def testing_cvar(setMethod, methodName, label, value, compare): print('{} failed'.format(methodName)) -def testing_edit_mode(mode): - python_editor_funcs.PythonEditorBus(bus.Broadcast, 'SetEditMode', mode) - - if mode == python_editor_funcs.PythonEditorBus(bus.Broadcast, 'GetEditMode'): - return True - - return False - - def testing_axis_constraints(constraint): python_editor_funcs.PythonEditorBus(bus.Broadcast, 'SetAxisConstraint', constraint) @@ -57,13 +48,6 @@ testing_cvar('SetCVarFromString', 'SetCVarFromString', 'e_ScreenShotFileFormat', compare = lambda lhs, rhs: rhs == int(lhs) testing_cvar('SetCVarFromInteger', 'SetCVarFromInteger', 'sys_LocalMemoryGeometryLimit', 33, compare) -# ----- Test Edit Mode - -if (testing_edit_mode("SELECT") and testing_edit_mode('SELECTAREA') and - testing_edit_mode("MOVE") and testing_edit_mode("ROTATE") and - testing_edit_mode("SCALE") and testing_edit_mode("TOOL")): - print("edit mode works") - # ----- Test Axis Constraints if (testing_axis_constraints("X") and testing_axis_constraints("Y") and diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/PySide_Example_test_case.py b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/PySide_Example_test_case.py index 8aba60e8e9..ed1c048fa6 100755 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/PySide_Example_test_case.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/PySide_Example_test_case.py @@ -25,7 +25,7 @@ import azlmbr.bus as bus import azlmbr.entity as entity import azlmbr.editor as editor import azlmbr.legacy.general as general -import pyside_component_utils +import editor_python_test_tools.pyside_component_utils as pysde_component_utils def PySide_Example_test_case(): diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/README.txt b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/README.txt new file mode 100644 index 0000000000..8c86e22681 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/README.txt @@ -0,0 +1,49 @@ +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. + + +INTRODUCTION +------------ + +EditorPythonBindings is a Python project that contains a collection of editor testing tools +developed by the Lumberyard feature teams. The project contains tools for system level +editor tests. + + +REQUIREMENTS +------------ + + * Python 3.7.5 (64-bit) + +It is recommended that you completely remove any other versions of Python +installed on your system. + + +INSTALL +----------- +It is recommended to set up these these tools with Lumberyard's CMake build commands. +Assuming CMake is already setup on your operating system, below are some sample build commands: + cd /path/to/od3e/ + mkdir windows_vs2019 + cd windows_vs2019 + cmake .. -G "Visual Studio 16 2019" -A x64 -T host=x64 -DLY_3RDPARTY_PATH="%3RDPARTYPATH%" -DLY_PROJECTS=AutomatedTesting +NOTE: +Using the above command also adds EditorPythonTestTools to the PYTHONPATH OS environment variable. +Additionally, some CTest scripts will add the Python interpreter path to the PYTHON OS environment variable. + +To manually install the project in development mode using your own installed Python interpreter: + cd /path/to/od3e/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools + /path/to/your/python -m pip install -e . + + +UNINSTALLATION +-------------- + +The preferred way to uninstall the project is: + /path/to/your/python -m pip uninstall editor_python_test_tools diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/__init__.py b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/__init__.py new file mode 100644 index 0000000000..79f8fa4422 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/__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/PythonTests/EditorPythonTestTools/editor_python_test_tools.egg-info/PKG-INFO b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools.egg-info/PKG-INFO new file mode 100644 index 0000000000..4fb74423c2 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools.egg-info/PKG-INFO @@ -0,0 +1,110 @@ +Metadata-Version: 1.0 +Name: editor-python-test-tools +Version: 1.0.0 +Summary: Lumberyard editor Python bindings test tools +Home-page: UNKNOWN +Author: UNKNOWN +Author-email: UNKNOWN +License: UNKNOWN +Description: 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. + + + INTRODUCTION + ------------ + + EditorPythonBindings is a Python project that contains a collection of testing tools + developed by the Lumberyard Test Tech team. The project contains + the following tools: + + * Workspace Manager: + A library to manipulate Lumberyard installations + * Launchers: + A library to test the game in a variety of platforms + + + REQUIREMENTS + ------------ + + * Python 3.7.5 (64-bit) + + It is recommended that you completely remove any other versions of Python + installed on your system. + + + INSTALL + ----------- + It is recommended to set up these these tools with Lumberyard's CMake build commands. + Assuming CMake is already setup on your operating system, below are some sample build commands: + cd /path/to/od3e/ + mkdir windows_vs2019 + cd windows_vs2019 + cmake .. -G "Visual Studio 16 2019" -A x64 -T host=x64 -DLY_3RDPARTY_PATH="%3RDPARTYPATH%" -DLY_PROJECTS=AutomatedTesting + NOTE: + Using the above command also adds LyTestTools to the PYTHONPATH OS environment variable. + Additionally, some CTest scripts will add the Python interpreter path to the PYTHON OS environment variable. + There is some LyTestTools functionality that will search for these, so feel free to populate them manually. + + To manually install the project in development mode using your own installed Python interpreter: + cd /path/to/lumberyard/dev/Tools/LyTestTools/ + /path/to/your/python -m pip install -e . + + For console/mobile testing, update the following .ini file in your root user directory: + i.e. C:/Users/myusername/ly_test_tools/devices.ini (a.k.a. %USERPROFILE%/ly_test_tools/devices.ini) + + You will need to add a section for the device, and a key holding the device identifier value (usually an IP or ID). + It should look similar to this for each device: + [android] + id = 988939353955305449 + + [gameconsole] + ip = 192.168.1.1 + + [gameconsole2] + ip = 192.168.1.2 + + + PACKAGE STRUCTURE + ----------------- + + The project is organized into packages. Each package corresponds to a tool: + + - LyTestTools.ly_test_tools._internal: contains logging setup, pytest fixture, and o3de workspace manager modules + - LyTestTools.ly_test_tools.builtin: builtin helpers and fixtures for quickly writing tests + - LyTestTools.ly_test_tools.console: modules used for consoles + - LyTestTools.ly_test_tools.environment: functions related to file/process management and cleanup + - LyTestTools.ly_test_tools.image: modules related to image capturing and processing + - LyTestTools.ly_test_tools.launchers: game launchers library + - LyTestTools.ly_test_tools.log: modules for interacting with generated or existing log files + - LyTestTools.ly_test_tools.o3de: modules used to interact with Open 3D Engine + - LyTestTools.ly_test_tools.mobile: modules used for android/ios + - LyTestTools.ly_test_tools.report: modules used for reporting + - LyTestTools.tests: LyTestTools integration, unit, and example usage tests + + + DIRECTORY STRUCTURE + ------------------- + + The directory structure corresponds to the package structure. For example, the + ly_test_tools.builtin package is located in the ly_test_tools/builtin/ directory. + + + ENTRY POINTS + ------------ + + Deploying the project in development mode installs only entry points for pytest fixtures. + + + UNINSTALLATION + -------------- + + The preferred way to uninstall the project is: + /path/to/your/python -m pip uninstall ly_test_tools + +Platform: UNKNOWN diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools.egg-info/SOURCES.txt b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools.egg-info/SOURCES.txt new file mode 100644 index 0000000000..1143b74a7c --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools.egg-info/SOURCES.txt @@ -0,0 +1,7 @@ +README.txt +setup.py +editor_python_test_tools.egg-info/PKG-INFO +editor_python_test_tools.egg-info/SOURCES.txt +editor_python_test_tools.egg-info/dependency_links.txt +editor_python_test_tools.egg-info/requires.txt +editor_python_test_tools.egg-info/top_level.txt \ No newline at end of file diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools.egg-info/dependency_links.txt b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools.egg-info/dependency_links.txt new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools.egg-info/requires.txt b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools.egg-info/requires.txt new file mode 100644 index 0000000000..f11e5b3d82 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools.egg-info/requires.txt @@ -0,0 +1 @@ +ly_test_tools diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools.egg-info/top_level.txt b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools.egg-info/top_level.txt new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools.egg-info/top_level.txt @@ -0,0 +1 @@ + diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/__init__.py b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/__init__.py new file mode 100644 index 0000000000..6ed3dc4bda --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/__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/automatedtesting_shared/editor_entity_utils.py b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/editor_entity_utils.py old mode 100755 new mode 100644 similarity index 98% rename from AutomatedTesting/Gem/PythonTests/automatedtesting_shared/editor_entity_utils.py rename to AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/editor_entity_utils.py index 3e009563b8..4dc71bf16b --- a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/editor_entity_utils.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/editor_entity_utils.py @@ -13,8 +13,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. from __future__ import annotations from typing import List, Tuple, Union -# Helper file Imports -import utils # Open 3D Engine Imports import azlmbr @@ -23,6 +21,8 @@ import azlmbr.editor as editor import azlmbr.math as math import azlmbr.legacy.general as general +# Helper file Imports +from editor_python_test_tools.utils import Report class EditorComponent: """ @@ -61,7 +61,7 @@ class EditorComponent: build_prop_tree_outcome.IsSuccess() ), f"Failure: Could not build property tree of component: '{self.get_component_name()}'" prop_tree = build_prop_tree_outcome.GetValue() - utils.Report.info(prop_tree.build_paths_list()) + Report.info(prop_tree.build_paths_list()) return prop_tree def get_component_property_value(self, component_property_path: str): @@ -291,7 +291,7 @@ class EditorEntity: status_text = "inactive" elif status == azlmbr.globals.property.EditorEntityStartStatus_EditorOnly: status_text = "editor" - utils.Report.info(f"The start status for {self.get_name} is {status_text}") + Report.info(f"The start status for {self.get_name} is {status_text}") self.start_status = status return status @@ -308,7 +308,7 @@ class EditorEntity: elif desired_start_status == "editor": status_to_set = azlmbr.globals.property.EditorEntityStartStatus_EditorOnly else: - utils.Report.info( + Report.info( f"Invalid desired_start_status argument for {self.get_name} set_start_status command;\ Use editor, active, or inactive" ) diff --git a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/editor_test_helper.py b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/editor_test_helper.py old mode 100755 new mode 100644 similarity index 98% rename from AutomatedTesting/Gem/PythonTests/automatedtesting_shared/editor_test_helper.py rename to AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/editor_test_helper.py index 64a19aafdf..74f34659c0 --- a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/editor_test_helper.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/editor_test_helper.py @@ -15,12 +15,13 @@ import sys import time from typing import Sequence -from .report import Report # Open 3D Engine specific imports import azlmbr.legacy.general as general import azlmbr.legacy.settings as settings +from editor_python_test_tools.utils import Report + class EditorTestHelper: def __init__(self, log_prefix: str, args: Sequence[str] = None) -> None: @@ -117,7 +118,8 @@ class EditorTestHelper: # Set the viewport back to whatever size it was at the start and restore the pane layout general.set_viewport_size(int(self.viewport_size.x), int(self.viewport_size.y)) general.set_viewport_expansion_policy("AutoExpand") - general.set_view_pane_layout(self.viewport_layout) + # Temporarily disabling reset of view pane layout: LYN-3120 + # general.set_view_pane_layout(self.viewport_layout) general.update_viewport() self.log("test finished") diff --git a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/hydra_editor_utils.py b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/hydra_editor_utils.py old mode 100755 new mode 100644 similarity index 100% rename from AutomatedTesting/Gem/PythonTests/automatedtesting_shared/hydra_editor_utils.py rename to AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/hydra_editor_utils.py diff --git a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/hydra_test_utils.py b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/hydra_test_utils.py old mode 100755 new mode 100644 similarity index 92% rename from AutomatedTesting/Gem/PythonTests/automatedtesting_shared/hydra_test_utils.py rename to AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/hydra_test_utils.py index a796fd70da..ee352f8a73 --- a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/hydra_test_utils.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/hydra_test_utils.py @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. import logging import os import tempfile + import ly_test_tools.log.log_monitor import ly_test_tools.environment.process_utils as process_utils import ly_test_tools.environment.waiter as waiter -from automatedtesting_shared.network_utils import check_for_listening_port from ly_remote_console.remote_console_commands import RemoteConsole as RemoteConsole from ly_remote_console.remote_console_commands import send_command_and_expect_response as send_command_and_expect_response logger = logging.getLogger(__name__) @@ -86,6 +86,19 @@ def launch_and_validate_results_launcher(launcher, level, remote_console_instanc :param log_monitor_timeout: Timeout for monitoring for lines in Game.log :param remote_console_port: The port used to communicate with the Remote Console. """ + + def _check_for_listening_port(port): + """ + Checks to see if the connection to the designated port was established. + :param port: Port to listen to. + :return: True if port is listening. + """ + port_listening = False + for conn in psutil.net_connections(): + if 'port={}'.format(port) in str(conn): + port_listening = True + return port_listening + if null_renderer: launcher.args.extend(["-NullRenderer"]) @@ -94,7 +107,7 @@ def launch_and_validate_results_launcher(launcher, level, remote_console_instanc # Ensure Remote Console can be reached waiter.wait_for( - lambda: check_for_listening_port(remote_console_port), + lambda: _check_for_listening_port(remote_console_port), port_listener_timeout, exc=AssertionError("Port {} not listening.".format(remote_console_port)), ) diff --git a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/pyside_component_utils.py b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/pyside_component_utils.py old mode 100755 new mode 100644 similarity index 98% rename from AutomatedTesting/Gem/PythonTests/automatedtesting_shared/pyside_component_utils.py rename to AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/pyside_component_utils.py index 38e5800c53..0432d4ae25 --- a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/pyside_component_utils.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/pyside_component_utils.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. import PySide2 -import pyside_utils +import editor_python_test_tools.pyside_utils def get_component_combobox_values(component_name, property_name, log_fn=None): diff --git a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/pyside_utils.py b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/pyside_utils.py old mode 100755 new mode 100644 similarity index 100% rename from AutomatedTesting/Gem/PythonTests/automatedtesting_shared/pyside_utils.py rename to AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/pyside_utils.py diff --git a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/utils.py b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/utils.py old mode 100755 new mode 100644 similarity index 100% rename from AutomatedTesting/Gem/PythonTests/automatedtesting_shared/utils.py rename to AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/utils.py diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/setup.py b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/setup.py new file mode 100644 index 0000000000..20f4911bab --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/setup.py @@ -0,0 +1,43 @@ +""" +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 platform + +from setuptools import setup, find_packages +from setuptools.command.develop import develop +from setuptools.command.build_py import build_py + +PACKAGE_ROOT = os.path.abspath(os.path.dirname(__file__)) + +PYTHON_64 = platform.architecture()[0] == '64bit' + + +if __name__ == '__main__': + if not PYTHON_64: + raise RuntimeError("32-bit Python is not a supported platform.") + + with open(os.path.join(PACKAGE_ROOT, 'README.txt')) as f: + long_description = f.read() + + setup( + name="editor_python_test_tools", + version="1.0.0", + description='O3DE editor Python bindings test tools', + long_description=long_description, + packages=find_packages(where='Tools', exclude=['tests']), + install_requires=[ + "ly_test_tools" + ], + tests_require=[ + ], + entry_points={ + }, + ) diff --git a/AutomatedTesting/Gem/PythonTests/NvCloth/C18977329_NvCloth_AddClothSimulationToMesh.py b/AutomatedTesting/Gem/PythonTests/NvCloth/C18977329_NvCloth_AddClothSimulationToMesh.py index d54edc4cb3..2677ba5605 100755 --- a/AutomatedTesting/Gem/PythonTests/NvCloth/C18977329_NvCloth_AddClothSimulationToMesh.py +++ b/AutomatedTesting/Gem/PythonTests/NvCloth/C18977329_NvCloth_AddClothSimulationToMesh.py @@ -47,14 +47,15 @@ def run(): import azlmbr.legacy.general as general + from editor_python_test_tools.editor_entity_utils import EditorEntity + from editor_python_test_tools.utils import Report + # Helper file Imports import ImportPathHelper as imports imports.init() - from utils import Report - from utils import TestHelper as helper - from utils import Tracer - from editor_entity_utils import EditorEntity + from editor_python_test_tools.utils import TestHelper as helper + from editor_python_test_tools.utils import Tracer # Constants FRAMES_IN_GAME_MODE = 200 diff --git a/AutomatedTesting/Gem/PythonTests/NvCloth/C18977330_NvCloth_AddClothSimulationToActor.py b/AutomatedTesting/Gem/PythonTests/NvCloth/C18977330_NvCloth_AddClothSimulationToActor.py index 2882ca6be2..2d4fa4e325 100755 --- a/AutomatedTesting/Gem/PythonTests/NvCloth/C18977330_NvCloth_AddClothSimulationToActor.py +++ b/AutomatedTesting/Gem/PythonTests/NvCloth/C18977330_NvCloth_AddClothSimulationToActor.py @@ -47,14 +47,15 @@ def run(): import azlmbr.legacy.general as general + from editor_python_test_tools.editor_entity_utils import EditorEntity + from editor_python_test_tools.utils import Report + # Helper file Imports import ImportPathHelper as imports imports.init() - from utils import Report - from utils import TestHelper as helper - from utils import Tracer - from editor_entity_utils import EditorEntity + from editor_python_test_tools.utils import TestHelper as helper + from editor_python_test_tools.utils import Tracer # Constants FRAMES_IN_GAME_MODE = 200 diff --git a/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/AssetBuilder_test.py b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/AssetBuilder_test.py index e914182542..818dc23079 100644 --- a/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/AssetBuilder_test.py +++ b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/AssetBuilder_test.py @@ -22,7 +22,7 @@ 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.SUITE_periodic @pytest.mark.parametrize('launcher_platform', ['windows_editor']) @pytest.mark.parametrize('project', ['AutomatedTesting']) @pytest.mark.parametrize('level', ['auto_test']) @@ -31,14 +31,13 @@ class TestPythonAssetProcessing(object): 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' + 'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_positive_1.azmodel) found', + 'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_negative_1.azmodel) found', + 'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_positive_1.azmodel) found', + 'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_negative_1.azmodel) found', + 'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_positive_1.azmodel) found', + 'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_negative_1.azmodel) found', + 'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center_1.azmodel) found' ] timeout = 180 halt_on_unexpected = False diff --git a/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/AssetBuilder_test_case.py b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/AssetBuilder_test_case.py index 54857c2067..cd9adfdbcf 100644 --- a/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/AssetBuilder_test_case.py +++ b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/AssetBuilder_test_case.py @@ -26,8 +26,9 @@ assetId = azlmbr.asset.AssetCatalogRequestBus(azlmbr.bus.Broadcast, 'GetAssetIdB 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}!') +assetIdString = assetId.to_string() +if (assetIdString.endswith(':528cca58') is False): + raise_and_stop(f'Mock AssetId {assetIdString} has unexpected sub-id for {mockAssetPath}!') print ('Mock asset exists') @@ -41,12 +42,12 @@ def test_azmodel_product(generatedModelAssetPath, expectedSubId): 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') +test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_positive_1.azmodel', '10315ae0') +test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_negative_1.azmodel', '10661093') +test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_positive_1.azmodel', '10af8810') +test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_negative_1.azmodel', '10f8c263') +test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_positive_1.azmodel', '100ac47f') +test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_negative_1.azmodel', '105d8e0c') +test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center_1.azmodel', '1002d464') azlmbr.editor.EditorToolsApplicationRequestBus(azlmbr.bus.Broadcast, 'ExitNoPrompt') diff --git a/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/export_chunks_builder.py b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/export_chunks_builder.py index ad68a486b1..7e1f108c28 100644 --- a/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/export_chunks_builder.py +++ b/AutomatedTesting/Gem/PythonTests/PythonAssetBuilder/export_chunks_builder.py @@ -1,7 +1,6 @@ """ 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 @@ -27,7 +26,10 @@ def get_mesh_node_names(sceneGraph): 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))) + nodeName = sceneData.SceneGraphName(sceneGraph.get_node_name(node)) + nodePath = nodeName.get_path() + if (len(nodeName.get_path())): + meshDataList.append(sceneData.SceneGraphName(sceneGraph.get_node_name(node))) # advance to next node if sceneGraph.has_node_sibling(node): @@ -54,17 +56,7 @@ def update_manifest(scene): 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) + sceneManifest.mesh_group_select_node(meshGroup, chunkPath) return sceneManifest.export() @@ -85,4 +77,4 @@ def main(): mySceneJobHandler.add_callback('OnUpdateManifest', on_update_manifest) if __name__ == "__main__": - main() + main() \ No newline at end of file diff --git a/AutomatedTesting/Gem/PythonTests/WhiteBox/C28798177_WhiteBox_AddComponentToEntity.py b/AutomatedTesting/Gem/PythonTests/WhiteBox/C28798177_WhiteBox_AddComponentToEntity.py index 9438b9d546..252126674c 100755 --- a/AutomatedTesting/Gem/PythonTests/WhiteBox/C28798177_WhiteBox_AddComponentToEntity.py +++ b/AutomatedTesting/Gem/PythonTests/WhiteBox/C28798177_WhiteBox_AddComponentToEntity.py @@ -33,8 +33,9 @@ def run(): import azlmbr.editor as editor import azlmbr.legacy.general as general - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + + from editor_python_test_tools.utils import TestHelper as helper # open level helper.init_idle() diff --git a/AutomatedTesting/Gem/PythonTests/WhiteBox/C28798205_WhiteBox_SetInvisible.py b/AutomatedTesting/Gem/PythonTests/WhiteBox/C28798205_WhiteBox_SetInvisible.py index 605361e071..b7c6719721 100755 --- a/AutomatedTesting/Gem/PythonTests/WhiteBox/C28798205_WhiteBox_SetInvisible.py +++ b/AutomatedTesting/Gem/PythonTests/WhiteBox/C28798205_WhiteBox_SetInvisible.py @@ -30,7 +30,7 @@ def run(): import sys import WhiteBoxInit as init import ImportPathHelper as imports - import Tests.ly_shared.hydra_editor_utils as hydra + import editor_python_test_tools.hydra_editor_utils as hydra imports.init() import azlmbr.whitebox.api as api @@ -40,8 +40,9 @@ def run(): import azlmbr.entity as entity import azlmbr.legacy.general as general - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + + from editor_python_test_tools.utils import TestHelper as helper # open level helper.init_idle() diff --git a/AutomatedTesting/Gem/PythonTests/WhiteBox/C29279329_WhiteBox_SetDefaultShape.py b/AutomatedTesting/Gem/PythonTests/WhiteBox/C29279329_WhiteBox_SetDefaultShape.py index 399a9f27d4..0b0a081186 100755 --- a/AutomatedTesting/Gem/PythonTests/WhiteBox/C29279329_WhiteBox_SetDefaultShape.py +++ b/AutomatedTesting/Gem/PythonTests/WhiteBox/C29279329_WhiteBox_SetDefaultShape.py @@ -37,8 +37,9 @@ def run(): import azlmbr.bus as bus import azlmbr.legacy.general as general - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + + from editor_python_test_tools.utils import TestHelper as helper def check_shape_result(success_fail_tuple, condition): result = Report.result(success_fail_tuple, condition) diff --git a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/asset_utils.py b/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/asset_utils.py index 1fe2771370..4d78e4f28b 100755 --- a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/asset_utils.py +++ b/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/asset_utils.py @@ -22,7 +22,7 @@ class Asset: """ Used to find Asset Id by its path and path of asset by its Id If a component has any asset property, then this class object can be called as: - asset_id = editor_entity_utils.EditorComponent.get_component_property_value() + asset_id = editor_python_test_tools.editor_entity_utils.EditorComponent.get_component_property_value() asset = asset_utils.Asset(asset_id) """ def __init__(self, id: azasset.AssetId): diff --git a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/landscape_canvas_utils.py b/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/landscape_canvas_utils.py index 6609e1a34f..d20dcabd73 100755 --- a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/landscape_canvas_utils.py +++ b/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/landscape_canvas_utils.py @@ -13,7 +13,7 @@ import azlmbr.bus as bus import azlmbr.editor as editor import azlmbr.landscapecanvas as landscapecanvas -from . import hydra_editor_utils as hydra +import editor_python_test_tools.hydra_editor_utils as hydra def find_nodes_matching_entity_component(component_name, entity_id): diff --git a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/AssetBrowser_SearchFiltering.py b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/AssetBrowser_SearchFiltering.py index 6dc59d9be0..75c17b2a69 100644 --- a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/AssetBrowser_SearchFiltering.py +++ b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/AssetBrowser_SearchFiltering.py @@ -22,9 +22,9 @@ import azlmbr.legacy.general as general import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper -import automatedtesting_shared.pyside_utils as pyside_utils +import editor_python_test_tools.hydra_editor_utils as hydra +import editor_python_test_tools.pyside_utils as pyside_utils +from editor_python_test_tools.editor_test_helper import EditorTestHelper class AssetBrowserSearchFilteringTest(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/AssetPicker_UI_UX.py b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/AssetPicker_UI_UX.py index c51e4ca55f..ce7dd33971 100644 --- a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/AssetPicker_UI_UX.py +++ b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/AssetPicker_UI_UX.py @@ -25,9 +25,9 @@ import azlmbr.paths import azlmbr.math as math sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper -import automatedtesting_shared.pyside_utils as pyside_utils +import editor_python_test_tools.hydra_editor_utils as hydra +import editor_python_test_tools.pyside_utils as pyside_utils +from editor_python_test_tools.editor_test_helper import EditorTestHelper class AssetPickerUIUXTest(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/ComponentCRUD_Add_Delete_Components.py b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/ComponentCRUD_Add_Delete_Components.py index cdc204043e..5e07a6df7d 100755 --- a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/ComponentCRUD_Add_Delete_Components.py +++ b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/ComponentCRUD_Add_Delete_Components.py @@ -26,9 +26,9 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper -import automatedtesting_shared.pyside_utils as pyside_utils +import editor_python_test_tools.hydra_editor_utils as hydra +import editor_python_test_tools.pyside_utils as pyside_utils +from editor_python_test_tools.editor_test_helper import EditorTestHelper class AddDeleteComponentsTest(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/InputBindings_Add_Remove_Input_Events.py b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/InputBindings_Add_Remove_Input_Events.py index d6d284664a..dbc942f471 100755 --- a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/InputBindings_Add_Remove_Input_Events.py +++ b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/InputBindings_Add_Remove_Input_Events.py @@ -25,9 +25,9 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper -import automatedtesting_shared.pyside_utils as pyside_utils +import editor_python_test_tools.hydra_editor_utils as hydra +import editor_python_test_tools.pyside_utils as pyside_utils +from editor_python_test_tools.editor_test_helper import EditorTestHelper class AddRemoveInputEventsTest(EditorTestHelper): def __init__(self): diff --git a/AutomatedTesting/Gem/PythonTests/editor/test_AssetBrowser.py b/AutomatedTesting/Gem/PythonTests/editor/test_AssetBrowser.py index 18dbee2424..48e65cd9fe 100644 --- a/AutomatedTesting/Gem/PythonTests/editor/test_AssetBrowser.py +++ b/AutomatedTesting/Gem/PythonTests/editor/test_AssetBrowser.py @@ -15,10 +15,11 @@ C13660195: Asset Browser - File Tree Navigation import os import pytest + # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") log_monitor_timeout = 180 diff --git a/AutomatedTesting/Gem/PythonTests/editor/test_AssetPicker.py b/AutomatedTesting/Gem/PythonTests/editor/test_AssetPicker.py index b7b6280125..ac499d734f 100644 --- a/AutomatedTesting/Gem/PythonTests/editor/test_AssetPicker.py +++ b/AutomatedTesting/Gem/PythonTests/editor/test_AssetPicker.py @@ -15,10 +15,11 @@ C13751579: Asset Picker UI/UX import os import pytest + # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") log_monitor_timeout = 90 diff --git a/AutomatedTesting/Gem/PythonTests/editor/test_ComponentCRUD.py b/AutomatedTesting/Gem/PythonTests/editor/test_ComponentCRUD.py index 8ee24d9aac..f4ae57c338 100755 --- a/AutomatedTesting/Gem/PythonTests/editor/test_ComponentCRUD.py +++ b/AutomatedTesting/Gem/PythonTests/editor/test_ComponentCRUD.py @@ -15,10 +15,11 @@ C16929880: Add Delete Components import os import pytest + # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") log_monitor_timeout = 180 diff --git a/AutomatedTesting/Gem/PythonTests/editor/test_Docking.py b/AutomatedTesting/Gem/PythonTests/editor/test_Docking.py index 16cccca3fe..a75b3b36cd 100644 --- a/AutomatedTesting/Gem/PythonTests/editor/test_Docking.py +++ b/AutomatedTesting/Gem/PythonTests/editor/test_Docking.py @@ -13,10 +13,11 @@ C6376081: Basic Function: Docked/Undocked Tools import os import pytest + # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") log_monitor_timeout = 180 diff --git a/AutomatedTesting/Gem/PythonTests/editor/test_InputBindings.py b/AutomatedTesting/Gem/PythonTests/editor/test_InputBindings.py index f7e6a8ce5f..cdcfe86ef7 100755 --- a/AutomatedTesting/Gem/PythonTests/editor/test_InputBindings.py +++ b/AutomatedTesting/Gem/PythonTests/editor/test_InputBindings.py @@ -15,10 +15,11 @@ C1506881: Adding/Removing Event Groups import os import pytest + # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") log_monitor_timeout = 180 diff --git a/AutomatedTesting/Gem/PythonTests/editor/test_Menus.py b/AutomatedTesting/Gem/PythonTests/editor/test_Menus.py index 1df25dc593..251bd7cfed 100644 --- a/AutomatedTesting/Gem/PythonTests/editor/test_Menus.py +++ b/AutomatedTesting/Gem/PythonTests/editor/test_Menus.py @@ -13,10 +13,11 @@ C16780783: Base Edit Menu Options (New Viewport Interaction Model) import os import pytest + # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") log_monitor_timeout = 180 diff --git a/AutomatedTesting/Gem/PythonTests/editor/test_SearchFiltering.py b/AutomatedTesting/Gem/PythonTests/editor/test_SearchFiltering.py index fa8b143739..a3d4739fd8 100755 --- a/AutomatedTesting/Gem/PythonTests/editor/test_SearchFiltering.py +++ b/AutomatedTesting/Gem/PythonTests/editor/test_SearchFiltering.py @@ -15,10 +15,11 @@ C13660194 : Asset Browser - Filtering import os import pytest + # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") log_monitor_timeout = 90 diff --git a/AutomatedTesting/Gem/PythonTests/editor/test_TreeNavigation.py b/AutomatedTesting/Gem/PythonTests/editor/test_TreeNavigation.py index a97e4696d5..069d09f144 100755 --- a/AutomatedTesting/Gem/PythonTests/editor/test_TreeNavigation.py +++ b/AutomatedTesting/Gem/PythonTests/editor/test_TreeNavigation.py @@ -15,10 +15,11 @@ C13660195: Asset Browser - File Tree Navigation import os import pytest + # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") log_monitor_timeout = 90 diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AltitudeFilter_ComponentAndOverrides_InstancesPlantAtSpecifiedAltitude.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AltitudeFilter_ComponentAndOverrides_InstancesPlantAtSpecifiedAltitude.py index 673e473390..a0279aecec 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AltitudeFilter_ComponentAndOverrides_InstancesPlantAtSpecifiedAltitude.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AltitudeFilter_ComponentAndOverrides_InstancesPlantAtSpecifiedAltitude.py @@ -25,8 +25,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AltitudeFilter_FilterStageToggle.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AltitudeFilter_FilterStageToggle.py index 1c51cc9554..09f8bb9814 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AltitudeFilter_FilterStageToggle.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AltitudeFilter_FilterStageToggle.py @@ -20,8 +20,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests")) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg @@ -53,6 +53,8 @@ class TestAltitudeFilterFilterStageToggle(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # Create basic vegetation entity position = math.Vector3(512.0, 512.0, 32.0) asset_path = os.path.join("Slices", "PinkFlower.dynamicslice") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AltitudeFilter_ShapeSample_InstancesPlantAtSpecifiedAltitude.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AltitudeFilter_ShapeSample_InstancesPlantAtSpecifiedAltitude.py index 7e76a80cc4..5d4154b030 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AltitudeFilter_ShapeSample_InstancesPlantAtSpecifiedAltitude.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AltitudeFilter_ShapeSample_InstancesPlantAtSpecifiedAltitude.py @@ -20,8 +20,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AreaComponentSlices_SliceCreationAndVisibilityToggle.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AreaComponentSlices_SliceCreationAndVisibilityToggle.py index d1fe82e3f7..786a7e3502 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AreaComponentSlices_SliceCreationAndVisibilityToggle.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AreaComponentSlices_SliceCreationAndVisibilityToggle.py @@ -21,8 +21,8 @@ import azlmbr.asset as asset import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests")) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg @@ -59,6 +59,8 @@ class TestAreaComponentsSliceCreationAndVisibilityToggle(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # 2) C2627900 Verifies if a slice containing the Vegetation Layer Spawner component can be created. # 2.1) Create basic vegetation entity position = math.Vector3(512.0, 512.0, 32.0) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AssetListCombiner_CombinedDescriptorsExpressInConfiguredArea.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AssetListCombiner_CombinedDescriptorsExpressInConfiguredArea.py index 786348bcc6..374813b298 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AssetListCombiner_CombinedDescriptorsExpressInConfiguredArea.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AssetListCombiner_CombinedDescriptorsExpressInConfiguredArea.py @@ -21,8 +21,8 @@ import azlmbr.paths import azlmbr.vegetation as vegetation sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AssetWeightSelector_InstancesExpressBasedOnWeight.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AssetWeightSelector_InstancesExpressBasedOnWeight.py index 85d4edfe6d..37bd47ed5d 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AssetWeightSelector_InstancesExpressBasedOnWeight.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AssetWeightSelector_InstancesExpressBasedOnWeight.py @@ -22,8 +22,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/Debugger_DebugCVarsWorks.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/Debugger_DebugCVarsWorks.py index 7d133f492d..aeb6170e43 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/Debugger_DebugCVarsWorks.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/Debugger_DebugCVarsWorks.py @@ -16,8 +16,8 @@ import azlmbr.legacy.general as general import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests")) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper class TestDebuggerDebugCVarsWorks(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DistanceBetweenFilterOverrides_InstancesPlantAtSpecifiedRadius.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DistanceBetweenFilterOverrides_InstancesPlantAtSpecifiedRadius.py index 82b2fc8407..1ccfc43585 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DistanceBetweenFilterOverrides_InstancesPlantAtSpecifiedRadius.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DistanceBetweenFilterOverrides_InstancesPlantAtSpecifiedRadius.py @@ -20,8 +20,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg @@ -63,6 +63,8 @@ class TestDistanceBetweenFilterComponentOverrides(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # 2) Create a new entity with required vegetation area components spawner_center_point = math.Vector3(520.0, 520.0, 32.0) asset_path = os.path.join("Slices", "1m_cube.dynamicslice") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DistanceBetweenFilter_InstancesPlantAtSpecifiedRadius.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DistanceBetweenFilter_InstancesPlantAtSpecifiedRadius.py index 9f15215358..09c5fd63cf 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DistanceBetweenFilter_InstancesPlantAtSpecifiedRadius.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DistanceBetweenFilter_InstancesPlantAtSpecifiedRadius.py @@ -20,8 +20,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg @@ -61,6 +61,8 @@ class TestDistanceBetweenFilterComponent(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # 2) Create a new entity with required vegetation area components spawner_center_point = math.Vector3(520.0, 520.0, 32.0) asset_path = os.path.join("Slices", "1m_cube.dynamicslice") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_DynamicSliceSpawnerWorks.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_DynamicSliceSpawnerWorks.py index b58c7488e5..0be220cad0 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_DynamicSliceSpawnerWorks.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_DynamicSliceSpawnerWorks.py @@ -18,8 +18,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg @@ -43,6 +43,7 @@ class TestDynamicSliceInstanceSpawner(EditorTestHelper): use_terrain=False, ) general.idle_wait(1.0) + general.set_current_view_position(512.0, 480.0, 38.0) # Grab the UUID that we need for creating an Dynamic Slice Instance Spawner dynamic_slice_spawner_uuid = azlmbr.math.Uuid_CreateString('{BBA5CC1E-B4CA-4792-89F7-93711E98FBD1}', 0) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_Embedded_E2E.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_Embedded_E2E.py index f25fbb2b6d..f24909c08d 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_Embedded_E2E.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_Embedded_E2E.py @@ -22,8 +22,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg @@ -65,6 +65,8 @@ class TestDynamicSliceInstanceSpawnerEmbeddedEditor(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # 2) Create a new entity with required vegetation area components and Script Canvas component for launcher test center_point = math.Vector3(512.0, 512.0, 32.0) asset_path = os.path.join("Slices", "PinkFlower.dynamicslice") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_External_E2E.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_External_E2E.py index 8af75f2d17..447ac403fb 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_External_E2E.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_External_E2E.py @@ -22,8 +22,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg @@ -65,6 +65,8 @@ class TestDynamicSliceInstanceSpawnerExternalEditor(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # 2) Create a new entity with required vegetation area components and switch the Vegetation Asset List Source # Type to External entity_position = math.Vector3(512.0, 512.0, 32.0) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/EmptyInstanceSpawner_EmptySpawnerWorks.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/EmptyInstanceSpawner_EmptySpawnerWorks.py index 4067de90fc..161ad038a5 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/EmptyInstanceSpawner_EmptySpawnerWorks.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/EmptyInstanceSpawner_EmptySpawnerWorks.py @@ -18,8 +18,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg @@ -43,6 +43,7 @@ class TestEmptyInstanceSpawner(EditorTestHelper): use_terrain=False, ) general.idle_wait(1.0) + general.set_current_view_position(512.0, 480.0, 38.0) # Grab the UUID that we need for creating an Empty Spawner empty_spawner_uuid = azlmbr.math.Uuid_CreateString('{23C40FD4-A55F-4BD3-BE5B-DC5423F217C2}', 0) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/InstanceSpawnerPriority_LayerAndSubPriority.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/InstanceSpawnerPriority_LayerAndSubPriority.py index 507d8f505e..684ca70e38 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/InstanceSpawnerPriority_LayerAndSubPriority.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/InstanceSpawnerPriority_LayerAndSubPriority.py @@ -21,8 +21,8 @@ import azlmbr.paths import azlmbr.vegetation as vegetation sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerBlender_E2E_Editor.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerBlender_E2E_Editor.py index 2e6992d7e2..0da7acc987 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerBlender_E2E_Editor.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerBlender_E2E_Editor.py @@ -29,8 +29,8 @@ import azlmbr.entity as EntityId import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerBlocker_InstancesBlockedInConfiguredArea.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerBlocker_InstancesBlockedInConfiguredArea.py index 53c29344e1..a856d8c093 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerBlocker_InstancesBlockedInConfiguredArea.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerBlocker_InstancesBlockedInConfiguredArea.py @@ -19,8 +19,8 @@ import azlmbr.legacy.general as general import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests")) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerSpawner_FilterStageToggle.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerSpawner_FilterStageToggle.py index 01c5001642..d84cd575e7 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerSpawner_FilterStageToggle.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerSpawner_FilterStageToggle.py @@ -19,8 +19,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests")) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerSpawner_InheritBehaviorFlag.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerSpawner_InheritBehaviorFlag.py index f55243bc9c..0e4cabe3db 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerSpawner_InheritBehaviorFlag.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerSpawner_InheritBehaviorFlag.py @@ -19,8 +19,8 @@ import azlmbr.surface_data as surface_data import azlmbr.vegetation as vegetation sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests")) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg @@ -60,6 +60,8 @@ class TestLayerSpawnerInheritBehavior(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # Create Emitter entity and add the required components position = math.Vector3(512.0, 512.0, 32.0) emitter_entity = dynveg.create_surface_entity("emitter_entity", position, 16.0, 16.0, 1.0) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerSpawner_InstancesPlantInAllSupportedShapes.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerSpawner_InstancesPlantInAllSupportedShapes.py index c124c631fd..add45d9671 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerSpawner_InstancesPlantInAllSupportedShapes.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerSpawner_InstancesPlantInAllSupportedShapes.py @@ -19,8 +19,8 @@ import azlmbr.entity as EntityId import azlmbr.math as math sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/MeshBlocker_InstancesBlockedByMesh.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/MeshBlocker_InstancesBlockedByMesh.py index 02dcc1f067..d366521304 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/MeshBlocker_InstancesBlockedByMesh.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/MeshBlocker_InstancesBlockedByMesh.py @@ -20,8 +20,8 @@ import azlmbr.legacy.general as general import azlmbr.math as math sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg @@ -61,6 +61,9 @@ class test_MeshBlocker_InstancesBlockedByMesh(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(500.49, 498.69, 46.66) + general.set_current_view_rotation(-42.05, 0.00, -36.33) + # Create entity with components "Vegetation Layer Spawner", "Vegetation Asset List", "Box Shape" entity_position = math.Vector3(512.0, 512.0, 32.0) asset_path = os.path.join("Slices", "PurpleFlower.dynamicslice") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/MeshBlocker_InstancesBlockedByMeshHeightTuning.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/MeshBlocker_InstancesBlockedByMeshHeightTuning.py index 66250bf451..a7a0bc146b 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/MeshBlocker_InstancesBlockedByMeshHeightTuning.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/MeshBlocker_InstancesBlockedByMeshHeightTuning.py @@ -24,8 +24,8 @@ import azlmbr.math as math sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/MeshSurfaceTagEmitter_DependentOnMeshComponent.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/MeshSurfaceTagEmitter_DependentOnMeshComponent.py index a5d04a3b6a..5757ed7559 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/MeshSurfaceTagEmitter_DependentOnMeshComponent.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/MeshSurfaceTagEmitter_DependentOnMeshComponent.py @@ -20,8 +20,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper class TestMeshSurfaceTagEmitter(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/MeshSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/MeshSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully.py index e0011ea28f..ffa805cb41 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/MeshSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/MeshSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully.py @@ -18,8 +18,8 @@ import azlmbr.paths import azlmbr.surface_data as surface_data sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper class TestMeshSurfaceTagEmitter(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/PhysXColliderSurfaceTagEmitter_E2E_Editor.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/PhysXColliderSurfaceTagEmitter_E2E_Editor.py index 13003cdfcd..1826549a01 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/PhysXColliderSurfaceTagEmitter_E2E_Editor.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/PhysXColliderSurfaceTagEmitter_E2E_Editor.py @@ -19,8 +19,8 @@ import azlmbr.bus as bus import azlmbr.math as math sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/PositionModifier_AutoSnapToSurfaceWorks.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/PositionModifier_AutoSnapToSurfaceWorks.py index d2d112907a..a215e21a94 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/PositionModifier_AutoSnapToSurfaceWorks.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/PositionModifier_AutoSnapToSurfaceWorks.py @@ -20,8 +20,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/PositionModifier_ComponentAndOverrides_InstancesPlantAtSpecifiedOffsets.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/PositionModifier_ComponentAndOverrides_InstancesPlantAtSpecifiedOffsets.py index bd2a2df16f..e3ee0e5313 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/PositionModifier_ComponentAndOverrides_InstancesPlantAtSpecifiedOffsets.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/PositionModifier_ComponentAndOverrides_InstancesPlantAtSpecifiedOffsets.py @@ -21,8 +21,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/RotationModifierOverrides_InstancesRotateWithinRange.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/RotationModifierOverrides_InstancesRotateWithinRange.py index b63692527c..25b6c65ca3 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/RotationModifierOverrides_InstancesRotateWithinRange.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/RotationModifierOverrides_InstancesRotateWithinRange.py @@ -24,8 +24,8 @@ import azlmbr.bus as bus import azlmbr.areasystem as areasystem sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg @@ -90,7 +90,7 @@ class TestRotationModifierOverrides_InstancesRotateWithinRange(EditorTestHelper) terrain_texture_resolution=4096, use_terrain=False, ) - general.run_console("e_WaterOcean=0") + general.set_current_view_position(512.0, 480.0, 38.0) # 2) Create vegetation entity and add components entity_position = math.Vector3(512.0, 512.0, 32.0) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/RotationModifier_InstancesRotateWithinRange.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/RotationModifier_InstancesRotateWithinRange.py index a14363d5e9..087bf284e0 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/RotationModifier_InstancesRotateWithinRange.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/RotationModifier_InstancesRotateWithinRange.py @@ -19,8 +19,8 @@ import azlmbr.bus as bus import azlmbr.areasystem as areasystem sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg @@ -103,7 +103,7 @@ class TestRotationModifier_InstancesRotateWithinRange(EditorTestHelper): terrain_texture_resolution=4096, use_terrain=False, ) - general.run_console("e_WaterOcean=0") + general.set_current_view_position(512.0, 480.0, 38.0) # 2) Set up vegetation entities asset_path = os.path.join("Slices", "PurpleFlower.dynamicslice") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/ScaleModifierOverrides_InstancesProperlyScale.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/ScaleModifierOverrides_InstancesProperlyScale.py index 296ffe793b..2c9d33eae4 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/ScaleModifierOverrides_InstancesProperlyScale.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/ScaleModifierOverrides_InstancesProperlyScale.py @@ -19,8 +19,8 @@ import azlmbr.legacy.general as general import azlmbr.math as math sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg # Constants diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/ScaleModifier_InstancesProperlyScale.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/ScaleModifier_InstancesProperlyScale.py index 333bc92352..f81758b2dd 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/ScaleModifier_InstancesProperlyScale.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/ScaleModifier_InstancesProperlyScale.py @@ -19,8 +19,8 @@ import azlmbr.legacy.general as general import azlmbr.math as math sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/ShapeIntersectionFilter_InstancesPlantInAssignedShape.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/ShapeIntersectionFilter_InstancesPlantInAssignedShape.py index 4d904e9623..de1f50e481 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/ShapeIntersectionFilter_InstancesPlantInAssignedShape.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/ShapeIntersectionFilter_InstancesPlantInAssignedShape.py @@ -24,8 +24,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SlopeAlignmentModifierOverrides_InstanceSurfaceAlignment.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SlopeAlignmentModifierOverrides_InstanceSurfaceAlignment.py index cb96575a5d..ee5d79d6d2 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SlopeAlignmentModifierOverrides_InstanceSurfaceAlignment.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SlopeAlignmentModifierOverrides_InstanceSurfaceAlignment.py @@ -22,8 +22,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SlopeAlignmentModifier_InstanceSurfaceAlignment.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SlopeAlignmentModifier_InstanceSurfaceAlignment.py index b358328886..400abf0212 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SlopeAlignmentModifier_InstanceSurfaceAlignment.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SlopeAlignmentModifier_InstanceSurfaceAlignment.py @@ -23,8 +23,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SlopeFilter_ComponentAndOverrides_InstancesPlantOnValidSlope.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SlopeFilter_ComponentAndOverrides_InstancesPlantOnValidSlope.py index 6f3b1d5629..2271ee51ce 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SlopeFilter_ComponentAndOverrides_InstancesPlantOnValidSlope.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SlopeFilter_ComponentAndOverrides_InstancesPlantOnValidSlope.py @@ -24,8 +24,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests")) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SlopeFilter_FilterStageToggle.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SlopeFilter_FilterStageToggle.py index a907c7a0af..d2ba85e41d 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SlopeFilter_FilterStageToggle.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SlopeFilter_FilterStageToggle.py @@ -17,10 +17,11 @@ import azlmbr.paths import azlmbr.editor as editor import azlmbr.entity as EntityId import azlmbr.components as components +import azlmbr.legacy.general as general sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests")) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg class TestSlopeFilterFilterStageToggle(EditorTestHelper): @@ -48,6 +49,8 @@ class TestSlopeFilterFilterStageToggle(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # Create basic vegetation entity position = math.Vector3(512.0, 512.0, 32.0) asset_path = os.path.join("Slices", "PinkFlower.dynamicslice") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceDataRefreshes_RemainsStable.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceDataRefreshes_RemainsStable.py index 5b6a421e49..04e748661b 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceDataRefreshes_RemainsStable.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceDataRefreshes_RemainsStable.py @@ -18,7 +18,7 @@ import azlmbr.math as math sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -from automatedtesting_shared.editor_test_helper import EditorTestHelper +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilterOverrides_MultipleDescriptorOverridesPlantAsExpected.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilterOverrides_MultipleDescriptorOverridesPlantAsExpected.py index b164d34973..c1bf53b03a 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilterOverrides_MultipleDescriptorOverridesPlantAsExpected.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilterOverrides_MultipleDescriptorOverridesPlantAsExpected.py @@ -22,8 +22,8 @@ import azlmbr.paths import azlmbr.surface_data as surface_data sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests")) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilter_BasicSurfaceTagCreation.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilter_BasicSurfaceTagCreation.py index 101b84f4bb..4f58a23a19 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilter_BasicSurfaceTagCreation.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilter_BasicSurfaceTagCreation.py @@ -15,7 +15,7 @@ import sys import azlmbr.surface_data as surface_data sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -from automatedtesting_shared.editor_test_helper import EditorTestHelper +from editor_python_test_tools.editor_test_helper import EditorTestHelper class TestSurfaceMaskFilter_BasicSurfaceTagCreation(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilter_ExclusionList.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilter_ExclusionList.py index 1bec5e46ae..2beb8f17c2 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilter_ExclusionList.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilter_ExclusionList.py @@ -25,8 +25,8 @@ import azlmbr.surface_data as surface_data sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg @@ -103,6 +103,8 @@ class TestExclusiveSurfaceMasksTag(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # 2) Create entity with components "Vegetation Layer Spawner", "Vegetation Asset List", "Box Shape" entity_position = math.Vector3(512.0, 512.0, 32.0) asset_path = os.path.join("Slices", "PurpleFlower.dynamicslice") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilter_InclusionList.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilter_InclusionList.py index fbaecf1972..f721bc4283 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilter_InclusionList.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilter_InclusionList.py @@ -25,8 +25,8 @@ import azlmbr.surface_data as surface_data sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg @@ -104,6 +104,8 @@ class TestInclusiveSurfaceMasksTag(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # 2) Create entity with components "Vegetation Layer Spawner", "Vegetation Asset List", "Box Shape" entity_position = math.Vector3(512.0, 512.0, 32.0) asset_path = os.path.join("Slices", "PurpleFlower.dynamicslice") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SystemSettings_SectorPointDensity.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SystemSettings_SectorPointDensity.py index f1e6a93760..19750994ec 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SystemSettings_SectorPointDensity.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SystemSettings_SectorPointDensity.py @@ -15,10 +15,11 @@ import azlmbr.math as math import azlmbr.paths import azlmbr.editor as editor import azlmbr.bus as bus +import azlmbr.legacy.general as general sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests")) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg @@ -52,6 +53,8 @@ class TestSystemSettingsSectorPointDensity(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # Create basic vegetation entity position = math.Vector3(512.0, 512.0, 32.0) asset_path = os.path.join("Slices", "PinkFlower.dynamicslice") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SystemSettings_SectorSize.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SystemSettings_SectorSize.py index 5e80bd6b33..c4cec19a8f 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SystemSettings_SectorSize.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SystemSettings_SectorSize.py @@ -15,10 +15,11 @@ import azlmbr.math as math import azlmbr.paths import azlmbr.editor as editor import azlmbr.bus as bus +import azlmbr.legacy.general as general sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests")) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg @@ -48,6 +49,8 @@ class TestSystemSettingsSectorSize(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # Create basic vegetation entity position = math.Vector3(512.0, 512.0, 32.0) asset_path = os.path.join("Slices", "PinkFlower.dynamicslice") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/VegetationInstances_DespawnWhenOutOfRange.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/VegetationInstances_DespawnWhenOutOfRange.py index 076dbd950b..c25761d655 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/VegetationInstances_DespawnWhenOutOfRange.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/VegetationInstances_DespawnWhenOutOfRange.py @@ -24,7 +24,7 @@ import azlmbr.legacy.general as general import azlmbr.math as math sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -from automatedtesting_shared.editor_test_helper import EditorTestHelper +from editor_python_test_tools.editor_test_helper import EditorTestHelper from largeworlds.large_worlds_utils import editor_dynveg_test_helper as dynveg diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AltitudeFilter.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AltitudeFilter.py index 6378b36447..65b5198213 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AltitudeFilter.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AltitudeFilter.py @@ -15,7 +15,7 @@ import logging # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra logger = logging.getLogger(__name__) test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AreaComponentSlices.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AreaComponentSlices.py index 014655f966..1353efbf2e 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AreaComponentSlices.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AreaComponentSlices.py @@ -16,7 +16,7 @@ import logging # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip("ly_test_tools") import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra logger = logging.getLogger(__name__) test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AssetListCombiner.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AssetListCombiner.py index c36f36d58c..ad0917ca22 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AssetListCombiner.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AssetListCombiner.py @@ -16,7 +16,7 @@ import logging # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip("ly_test_tools") import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra logger = logging.getLogger(__name__) test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AssetWeightSelector.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AssetWeightSelector.py index cd383581cc..65472df3bc 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AssetWeightSelector.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AssetWeightSelector.py @@ -20,7 +20,7 @@ import logging # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra logger = logging.getLogger(__name__) test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_Debugger.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_Debugger.py index 84709b59a4..45518b71fc 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_Debugger.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_Debugger.py @@ -16,7 +16,7 @@ import logging # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip("ly_test_tools") import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra logger = logging.getLogger(__name__) test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DistanceBetweenFilter.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DistanceBetweenFilter.py index 980d754d2b..3171cc032f 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DistanceBetweenFilter.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DistanceBetweenFilter.py @@ -16,7 +16,7 @@ import logging # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra logger = logging.getLogger(__name__) test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DynVeg_Regressions.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DynVeg_Regressions.py index 4a8831542f..b3cf344b2b 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DynVeg_Regressions.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DynVeg_Regressions.py @@ -15,7 +15,7 @@ import pytest # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra import ly_test_tools.environment.file_system as file_system test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DynamicSliceInstanceSpawner.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DynamicSliceInstanceSpawner.py index 1183c0769c..c5b8046f73 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DynamicSliceInstanceSpawner.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DynamicSliceInstanceSpawner.py @@ -16,7 +16,7 @@ import logging # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra from ly_remote_console.remote_console_commands import RemoteConsole as RemoteConsole logger = logging.getLogger(__name__) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_EmptyInstanceSpawner.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_EmptyInstanceSpawner.py index 32e00cdeb9..a7f221b780 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_EmptyInstanceSpawner.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_EmptyInstanceSpawner.py @@ -12,10 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. import os import pytest import logging + # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra logger = logging.getLogger(__name__) test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_InstanceSpawnerPriority.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_InstanceSpawnerPriority.py index 7ef4185faf..d04b827985 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_InstanceSpawnerPriority.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_InstanceSpawnerPriority.py @@ -21,7 +21,7 @@ import logging # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra logger = logging.getLogger(__name__) test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerBlender.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerBlender.py index 5fa7f04179..2286238364 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerBlender.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerBlender.py @@ -22,14 +22,14 @@ pytest.importorskip("ly_test_tools") import time as time +import editor_python_test_tools.hydra_test_utils as hydra import ly_test_tools.launchers.launcher_helper as launcher_helper -import ly_remote_console.remote_console_commands as remote_console_commands -from ly_remote_console.remote_console_commands import send_command_and_expect_response as send_command_and_expect_response import ly_test_tools.environment.waiter as waiter import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra -import automatedtesting_shared.screenshot_utils as screenshot_utils +import ly_remote_console.remote_console_commands as remote_console_commands +from ly_remote_console.remote_console_commands import send_command_and_expect_response as send_command_and_expect_response +import automatedtesting_shared.screenshot_utils as screenshot_utils from automatedtesting_shared.network_utils import check_for_listening_port diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerBlocker.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerBlocker.py index 94fe4d2e48..6da0cdd6db 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerBlocker.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerBlocker.py @@ -16,7 +16,7 @@ import logging # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra logger = logging.getLogger(__name__) test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerSpawner.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerSpawner.py index ad08d7c214..e74ecc8bd1 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerSpawner.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerSpawner.py @@ -16,7 +16,7 @@ import logging # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip("ly_test_tools") import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra logger = logging.getLogger(__name__) test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_MeshBlocker.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_MeshBlocker.py index 4437865a00..5e8ffe4d50 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_MeshBlocker.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_MeshBlocker.py @@ -16,7 +16,7 @@ import pytest # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra import ly_test_tools.environment.file_system as file_system test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_MeshSurfaceTagEmitter.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_MeshSurfaceTagEmitter.py index 3a7a859b35..77638cb576 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_MeshSurfaceTagEmitter.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_MeshSurfaceTagEmitter.py @@ -16,7 +16,7 @@ import logging # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip("ly_test_tools") import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra logger = logging.getLogger(__name__) test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PhysXColliderSurfaceTagEmitter.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PhysXColliderSurfaceTagEmitter.py index d46c15024a..ca4e30a719 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PhysXColliderSurfaceTagEmitter.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PhysXColliderSurfaceTagEmitter.py @@ -16,7 +16,7 @@ import logging # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip("ly_test_tools") import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra logger = logging.getLogger(__name__) test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PositionModifier.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PositionModifier.py index e25820ed7e..47ff17bfa6 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PositionModifier.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PositionModifier.py @@ -12,10 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. import os import pytest import logging + # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra logger = logging.getLogger(__name__) test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_RotationModifier.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_RotationModifier.py index 1812c3c1b0..518949c0c0 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_RotationModifier.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_RotationModifier.py @@ -16,7 +16,7 @@ import pytest # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip("ly_test_tools") -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra import ly_test_tools.environment.file_system as file_system logger = logging.getLogger(__name__) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_ScaleModifier.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_ScaleModifier.py index d6d9f5e991..6acd95e4f6 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_ScaleModifier.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_ScaleModifier.py @@ -19,7 +19,7 @@ import pytest # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip("ly_test_tools") -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra import ly_test_tools.environment.file_system as file_system test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_ShapeIntersectionFilter.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_ShapeIntersectionFilter.py index 6b58ab23c5..ea90b67a7f 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_ShapeIntersectionFilter.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_ShapeIntersectionFilter.py @@ -12,10 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. import os import pytest import logging + # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra logger = logging.getLogger(__name__) test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SlopeAlignmentModifier.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SlopeAlignmentModifier.py index 3134bafed9..563ac1dcc5 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SlopeAlignmentModifier.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SlopeAlignmentModifier.py @@ -16,9 +16,10 @@ C4814459 - Surface Alignment overrides function as expected import os import pytest + # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip("ly_test_tools") -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra import ly_test_tools.environment.file_system as file_system test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SlopeFilter.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SlopeFilter.py index 991e82caf3..dc0f0e6514 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SlopeFilter.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SlopeFilter.py @@ -16,7 +16,7 @@ import logging # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip("ly_test_tools") import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra logger = logging.getLogger(__name__) test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SurfaceMaskFilter.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SurfaceMaskFilter.py index dfc0878a41..20cab85293 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SurfaceMaskFilter.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SurfaceMaskFilter.py @@ -15,7 +15,7 @@ import pytest # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip("ly_test_tools") -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra import ly_test_tools.environment.file_system as file_system test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SystemSettings.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SystemSettings.py index 8b6e95ea14..adf9a90587 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SystemSettings.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SystemSettings.py @@ -16,7 +16,7 @@ import logging # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip("ly_test_tools") import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra logger = logging.getLogger(__name__) test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientGenerators_Incompatibilities.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientGenerators_Incompatibilities.py index c6f7a3c438..cc9a15bba0 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientGenerators_Incompatibilities.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientGenerators_Incompatibilities.py @@ -17,8 +17,8 @@ import azlmbr.entity as entity import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper class TestGradientGeneratorIncompatibilities(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientModifiers_Incompatibilities.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientModifiers_Incompatibilities.py index 7fb94dab50..b7d12d074a 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientModifiers_Incompatibilities.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientModifiers_Incompatibilities.py @@ -17,8 +17,8 @@ import azlmbr.entity as entity import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper class TestGradientModifiersIncompatibilities(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin.py index 868d9d08e3..c37ee36265 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin.py @@ -33,8 +33,8 @@ import azlmbr.paths import azlmbr.entity as EntityId sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper class TestGradientPreviewSettings(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientPreviewSettings_DefaultPinnedEntityIsSelf.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientPreviewSettings_DefaultPinnedEntityIsSelf.py index 30d224f8c4..5a758b9d89 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientPreviewSettings_DefaultPinnedEntityIsSelf.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientPreviewSettings_DefaultPinnedEntityIsSelf.py @@ -18,8 +18,8 @@ import azlmbr.entity as entity import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper class Scoped: diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSampling_GradientReferencesAddRemoveSuccessfully.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSampling_GradientReferencesAddRemoveSuccessfully.py index d94c197fea..5d4e575e4e 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSampling_GradientReferencesAddRemoveSuccessfully.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSampling_GradientReferencesAddRemoveSuccessfully.py @@ -18,8 +18,8 @@ import azlmbr.paths import azlmbr.entity as EntityId sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper class TestGradientSampling(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSurfaceTagEmitter_ComponentDependencies.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSurfaceTagEmitter_ComponentDependencies.py index 7cdd029f3d..a16e37e0fc 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSurfaceTagEmitter_ComponentDependencies.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSurfaceTagEmitter_ComponentDependencies.py @@ -16,9 +16,10 @@ import azlmbr.bus as bus import azlmbr.entity as entity import azlmbr.paths import azlmbr.editor as editor + sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests")) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper class TestGradientSurfaceTagEmitterDependencies(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully.py index a37ae97361..e150070281 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully.py @@ -18,8 +18,8 @@ import azlmbr.paths import azlmbr.surface_data as surface_data sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper class TestGradientSurfaceTagEmitter(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_ComponentIncompatibleWithExpectedGradients.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_ComponentIncompatibleWithExpectedGradients.py index 31f0ee2693..41860ecaec 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_ComponentIncompatibleWithExpectedGradients.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_ComponentIncompatibleWithExpectedGradients.py @@ -19,8 +19,8 @@ import azlmbr.math as math import azlmbr.entity as EntityId sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper class TestGradientTransform_ComponentIncompatibleWithExpectedGradients(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_ComponentIncompatibleWithSpawners.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_ComponentIncompatibleWithSpawners.py index 0542e5e1b4..e2a7df6cf1 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_ComponentIncompatibleWithSpawners.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_ComponentIncompatibleWithSpawners.py @@ -19,8 +19,8 @@ import azlmbr.math as math import azlmbr.entity as EntityId sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper class TestGradientTransform_ComponentIncompatibleWithSpawners(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange.py index 22518e61be..bd664a9424 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange.py @@ -24,8 +24,8 @@ import azlmbr.paths import azlmbr.entity as EntityId sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper class TestGradientTransformFrequencyZoom(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_RequiresShape.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_RequiresShape.py index 3986076980..e1e901f2f7 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_RequiresShape.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_RequiresShape.py @@ -17,8 +17,8 @@ import azlmbr.entity as entity import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper class TestGradientTransformRequiresShape(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/ImageGradient_ProcessedImageAssignedSuccessfully.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/ImageGradient_ProcessedImageAssignedSuccessfully.py index ccc8c3f101..b4ee512478 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/ImageGradient_ProcessedImageAssignedSuccessfully.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/ImageGradient_ProcessedImageAssignedSuccessfully.py @@ -21,8 +21,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper class TestImageGradient(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/ImageGradient_RequiresShape.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/ImageGradient_RequiresShape.py index 152f256266..dab8e6928a 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/ImageGradient_RequiresShape.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/ImageGradient_RequiresShape.py @@ -17,8 +17,8 @@ import azlmbr.entity as entity import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper class TestImageGradientRequiresShape(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientIncompatibilities.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientIncompatibilities.py index 108bc79afd..1f16dbae97 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientIncompatibilities.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientIncompatibilities.py @@ -19,7 +19,7 @@ import pytest pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientPreviewSettings.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientPreviewSettings.py index fd886945af..6f755accb2 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientPreviewSettings.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientPreviewSettings.py @@ -11,10 +11,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. import os import pytest + # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientSampling.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientSampling.py index ac3ffaff06..315ec11986 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientSampling.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientSampling.py @@ -16,7 +16,7 @@ import logging # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip("ly_test_tools") import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra logger = logging.getLogger(__name__) test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientSurfaceTagEmitter.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientSurfaceTagEmitter.py index 91ae577b62..61e3832b24 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientSurfaceTagEmitter.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientSurfaceTagEmitter.py @@ -16,7 +16,7 @@ import logging # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip("ly_test_tools") import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra logger = logging.getLogger(__name__) test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientTransform.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientTransform.py index ecc4e5a027..7fb690c041 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientTransform.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientTransform.py @@ -17,10 +17,11 @@ the same Entity that provides the ShapeService (e.g. box shape, or reference sha import os import pytest + # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_ImageGradient.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_ImageGradient.py index 8fc582c2c8..d67616e48d 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_ImageGradient.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_ImageGradient.py @@ -11,10 +11,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. import os import pytest + # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/AreaNodes_DependentComponentsAdded.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/AreaNodes_DependentComponentsAdded.py index b8e61ab7f2..d1e0b68ef4 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/AreaNodes_DependentComponentsAdded.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/AreaNodes_DependentComponentsAdded.py @@ -21,8 +21,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID newEntityId = None diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/AreaNodes_EntityCreatedOnNodeAdd.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/AreaNodes_EntityCreatedOnNodeAdd.py index f15301d180..4e429a192b 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/AreaNodes_EntityCreatedOnNodeAdd.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/AreaNodes_EntityCreatedOnNodeAdd.py @@ -21,8 +21,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID newEntityId = None diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/ComponentUpdates_UpdateGraph.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/ComponentUpdates_UpdateGraph.py index d8172c1be3..26062c01f8 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/ComponentUpdates_UpdateGraph.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/ComponentUpdates_UpdateGraph.py @@ -41,8 +41,8 @@ import azlmbr.slice as slice import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper class TestComponentUpdatesUpdateGraph(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/CreateNewGraph.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/CreateNewGraph.py index 86f8f83201..5fed13985d 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/CreateNewGraph.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/CreateNewGraph.py @@ -19,8 +19,8 @@ import azlmbr.legacy.general as general import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID new_root_entity_id = None diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/Edit_DisabledNodeDuplication.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/Edit_DisabledNodeDuplication.py index e25553b64a..7fd3f075e0 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/Edit_DisabledNodeDuplication.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/Edit_DisabledNodeDuplication.py @@ -21,8 +21,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID newEntityId = None diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/Edit_UndoNodeDelete_SliceEntity.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/Edit_UndoNodeDelete_SliceEntity.py index f88ce893ba..27ab6fded3 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/Edit_UndoNodeDelete_SliceEntity.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/Edit_UndoNodeDelete_SliceEntity.py @@ -35,8 +35,8 @@ import azlmbr.slice as slice import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper class TestUndoNodeDeleteSlice(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientMixer_NodeConstruction.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientMixer_NodeConstruction.py index 8883dc0d93..ca3bc04f47 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientMixer_NodeConstruction.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientMixer_NodeConstruction.py @@ -22,8 +22,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID newEntityId = None diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientModifierNodes_EntityCreatedOnNodeAdd.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientModifierNodes_EntityCreatedOnNodeAdd.py index 9419322000..d40b19e7db 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientModifierNodes_EntityCreatedOnNodeAdd.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientModifierNodes_EntityCreatedOnNodeAdd.py @@ -21,8 +21,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID newEntityId = None diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientModifierNodes_EntityRemovedOnNodeDelete.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientModifierNodes_EntityRemovedOnNodeDelete.py index 9fbcb1382f..dc263924d1 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientModifierNodes_EntityRemovedOnNodeDelete.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientModifierNodes_EntityRemovedOnNodeDelete.py @@ -21,7 +21,7 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -from automatedtesting_shared.editor_test_helper import EditorTestHelper +from editor_python_test_tools.editor_test_helper import EditorTestHelper editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID createdEntityId = None diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientNodes_DependentComponentsAdded.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientNodes_DependentComponentsAdded.py index 4315acac62..5e203e1892 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientNodes_DependentComponentsAdded.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientNodes_DependentComponentsAdded.py @@ -21,8 +21,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID newEntityId = None diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientNodes_EntityCreatedOnNodeAdd.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientNodes_EntityCreatedOnNodeAdd.py index f2809b0cf2..6d4a2f58a7 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientNodes_EntityCreatedOnNodeAdd.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientNodes_EntityCreatedOnNodeAdd.py @@ -20,8 +20,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID newEntityId = None diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientNodes_EntityRemovedOnNodeDelete.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientNodes_EntityRemovedOnNodeDelete.py index c6147e8bb4..2b49e3a911 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientNodes_EntityRemovedOnNodeDelete.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GradientNodes_EntityRemovedOnNodeDelete.py @@ -21,7 +21,7 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -from automatedtesting_shared.editor_test_helper import EditorTestHelper +from editor_python_test_tools.editor_test_helper import EditorTestHelper editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID createdEntityId = None diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GraphClosed_OnEntityDelete.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GraphClosed_OnEntityDelete.py index b3eeafced7..d3ad5c1c1e 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GraphClosed_OnEntityDelete.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GraphClosed_OnEntityDelete.py @@ -19,7 +19,7 @@ import azlmbr.legacy.general as general import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -from automatedtesting_shared.editor_test_helper import EditorTestHelper +from editor_python_test_tools.editor_test_helper import EditorTestHelper editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID newRootEntityId = None diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GraphClosed_OnLevelChange.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GraphClosed_OnLevelChange.py index 302cb9dcc0..b7b0008eb2 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GraphClosed_OnLevelChange.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GraphClosed_OnLevelChange.py @@ -18,7 +18,7 @@ import azlmbr.legacy.general as general import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -from automatedtesting_shared.editor_test_helper import EditorTestHelper +from editor_python_test_tools.editor_test_helper import EditorTestHelper editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GraphClosed_TabbedGraph.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GraphClosed_TabbedGraph.py index ea6bbb94ff..efd1cc5a55 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GraphClosed_TabbedGraph.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GraphClosed_TabbedGraph.py @@ -18,7 +18,7 @@ import azlmbr.legacy.general as general import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -from automatedtesting_shared.editor_test_helper import EditorTestHelper +from editor_python_test_tools.editor_test_helper import EditorTestHelper editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GraphUpdates_UpdateComponents.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GraphUpdates_UpdateComponents.py index 4149504aca..f350d37178 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GraphUpdates_UpdateComponents.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/GraphUpdates_UpdateComponents.py @@ -38,10 +38,11 @@ import azlmbr.math as math import azlmbr.slice as slice import azlmbr.paths +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper + sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra import automatedtesting_shared.landscape_canvas_utils as lc -from automatedtesting_shared.editor_test_helper import EditorTestHelper class TestGraphUpdatesUpdateComponents(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/LandscapeCanvasComponent_AddedRemoved.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/LandscapeCanvasComponent_AddedRemoved.py index b6f9457f0e..176429885f 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/LandscapeCanvasComponent_AddedRemoved.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/LandscapeCanvasComponent_AddedRemoved.py @@ -18,8 +18,8 @@ import azlmbr.entity as entity import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/LandscapeCanvas_SliceCreateInstantiate.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/LandscapeCanvas_SliceCreateInstantiate.py index cfa685e875..e0f13adaa9 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/LandscapeCanvas_SliceCreateInstantiate.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/LandscapeCanvas_SliceCreateInstantiate.py @@ -19,8 +19,8 @@ import azlmbr.asset as asset import azlmbr.slice as slice sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests")) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper class TestLandscapeCanvasSliceCreateInstantiate(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/LayerBlender_NodeConstruction.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/LayerBlender_NodeConstruction.py index 6ed9b80dbe..ecc529b9b4 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/LayerBlender_NodeConstruction.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/LayerBlender_NodeConstruction.py @@ -22,8 +22,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID newEntityId = None diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/LayerExtenderNodes_ComponentEntitySync.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/LayerExtenderNodes_ComponentEntitySync.py index d65f86b77f..00fcb5170c 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/LayerExtenderNodes_ComponentEntitySync.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/LayerExtenderNodes_ComponentEntitySync.py @@ -21,8 +21,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID newEntityId = None diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/ShapeNodes_EntityCreatedOnNodeAdd.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/ShapeNodes_EntityCreatedOnNodeAdd.py index e5d3c436c3..bd10e5f4c6 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/ShapeNodes_EntityCreatedOnNodeAdd.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/ShapeNodes_EntityCreatedOnNodeAdd.py @@ -21,8 +21,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID newEntityId = None diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/ShapeNodes_EntityRemovedOnNodeDelete.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/ShapeNodes_EntityRemovedOnNodeDelete.py index db5542a3fd..f71f5ae906 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/ShapeNodes_EntityRemovedOnNodeDelete.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/ShapeNodes_EntityRemovedOnNodeDelete.py @@ -21,7 +21,7 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -from automatedtesting_shared.editor_test_helper import EditorTestHelper +from editor_python_test_tools.editor_test_helper import EditorTestHelper editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID createdEntityId = None diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/SlotConnections_UpdateComponentReferences.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/SlotConnections_UpdateComponentReferences.py index 346358641d..968f39c64d 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/SlotConnections_UpdateComponentReferences.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/SlotConnections_UpdateComponentReferences.py @@ -21,8 +21,8 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra -from automatedtesting_shared.editor_test_helper import EditorTestHelper +import editor_python_test_tools.hydra_editor_utils as hydra +from editor_python_test_tools.editor_test_helper import EditorTestHelper editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID newEntityId = None diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_AreaNodes.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_AreaNodes.py index 46ca74a3df..4805d46e75 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_AreaNodes.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_AreaNodes.py @@ -18,10 +18,11 @@ C13815873 - All Filters/Modifiers/Selectors can be added to/removed from a Layer import os import pytest + # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import automateeditor_python_test_toolsdtesting_shared.hydra_test_utils as hydra test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_EditFunctionality.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_EditFunctionality.py index dcb35e01fb..6899847d81 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_EditFunctionality.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_EditFunctionality.py @@ -16,10 +16,11 @@ C30813586 - Editor remains stable after Undoing deletion of a node on a slice en import os import pytest + # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_GeneralGraphFunctionality.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_GeneralGraphFunctionality.py index edbd86a7a1..09235ca2ae 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_GeneralGraphFunctionality.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_GeneralGraphFunctionality.py @@ -21,7 +21,7 @@ import pytest # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip("ly_test_tools") import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_GradientModifierNodes.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_GradientModifierNodes.py index 20961df4b0..bce57b6da8 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_GradientModifierNodes.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_GradientModifierNodes.py @@ -16,10 +16,11 @@ C18055051 - All Gradient Modifier nodes can be removed from a graph import os import pytest + # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_GradientNodes.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_GradientNodes.py index 83a2a9686c..639bec7827 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_GradientNodes.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_GradientNodes.py @@ -17,10 +17,11 @@ C17461363 - All Gradient nodes can be removed from a graph import os import pytest + # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_GraphComponentSync.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_GraphComponentSync.py index 33fbeeec1b..efeba3b74a 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_GraphComponentSync.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_GraphComponentSync.py @@ -19,10 +19,11 @@ C21333743 - Vegetation Layer Blenders are properly setup when constructing in a import os import pytest + # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_ShapeNodes.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_ShapeNodes.py index b74c2a70bc..3705cdc94e 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_ShapeNodes.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_ShapeNodes.py @@ -16,10 +16,11 @@ C17412059 - All Shape nodes can be removed from a graph import os import pytest + # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automatedtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/large_worlds_utils/editor_dynveg_test_helper.py b/AutomatedTesting/Gem/PythonTests/largeworlds/large_worlds_utils/editor_dynveg_test_helper.py index 6123729b1c..5e4432eafc 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/large_worlds_utils/editor_dynveg_test_helper.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/large_worlds_utils/editor_dynveg_test_helper.py @@ -21,7 +21,7 @@ import azlmbr.areasystem as areasystem import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -import automatedtesting_shared.hydra_editor_utils as hydra +import editor_python_test_tools.hydra_editor_utils as hydra def create_surface_entity(name, center_point, box_size_x, box_size_y, box_size_z): diff --git a/AutomatedTesting/Gem/PythonTests/physics/C100000_RigidBody_EnablingGravityWorksPoC.py b/AutomatedTesting/Gem/PythonTests/physics/C100000_RigidBody_EnablingGravityWorksPoC.py index 04ff07daa2..e0277180ae 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C100000_RigidBody_EnablingGravityWorksPoC.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C100000_RigidBody_EnablingGravityWorksPoC.py @@ -34,8 +34,8 @@ def C100000_RigidBody_EnablingGravityWorksPoC(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -84,5 +84,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C100000_RigidBody_EnablingGravityWorksPoC) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C111111_RigidBody_EnablingGravityWorksUsingNotificationsPoC.py b/AutomatedTesting/Gem/PythonTests/physics/C111111_RigidBody_EnablingGravityWorksUsingNotificationsPoC.py index 031b3121ab..c7dd8debb9 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C111111_RigidBody_EnablingGravityWorksUsingNotificationsPoC.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C111111_RigidBody_EnablingGravityWorksUsingNotificationsPoC.py @@ -34,8 +34,8 @@ def C111111_RigidBody_EnablingGravityWorksUsingNotificationsPoC(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -93,5 +93,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C111111_RigidBody_EnablingGravityWorksUsingNotificationsPoC) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C12712452_ScriptCanvas_CollisionEvents.py b/AutomatedTesting/Gem/PythonTests/physics/C12712452_ScriptCanvas_CollisionEvents.py index e5cee76415..216a75233f 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C12712452_ScriptCanvas_CollisionEvents.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C12712452_ScriptCanvas_CollisionEvents.py @@ -76,14 +76,13 @@ def C12712452_ScriptCanvas_CollisionEvents(): imports.init() - import azlmbr.legacy.general as general import azlmbr.bus import azlmbr.components import azlmbr.entity import azlmbr.physics - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper # Constants TIME_OUT_SECONDS = 3.0 @@ -209,5 +208,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C12712452_ScriptCanvas_CollisionEvents) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C12712453_ScriptCanvas_MultipleRaycastNode.py b/AutomatedTesting/Gem/PythonTests/physics/C12712453_ScriptCanvas_MultipleRaycastNode.py index bcbd0d6e0a..2adf30e65e 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C12712453_ScriptCanvas_MultipleRaycastNode.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C12712453_ScriptCanvas_MultipleRaycastNode.py @@ -81,8 +81,8 @@ def C12712453_ScriptCanvas_MultipleRaycastNode(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -203,6 +203,6 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report # Disabled until Script Canvas merges the new backend #Report.start_test(C12712453_ScriptCanvas_MultipleRaycastNode) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C12712454_ScriptCanvas_OverlapNodeVerification.py b/AutomatedTesting/Gem/PythonTests/physics/C12712454_ScriptCanvas_OverlapNodeVerification.py index 808f1e4c31..94eed900ff 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C12712454_ScriptCanvas_OverlapNodeVerification.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C12712454_ScriptCanvas_OverlapNodeVerification.py @@ -106,9 +106,8 @@ def C12712454_ScriptCanvas_OverlapNodeVerification(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -328,5 +327,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C12712454_ScriptCanvas_OverlapNodeVerification) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C12712455_ScriptCanvas_ShapeCastVerification.py b/AutomatedTesting/Gem/PythonTests/physics/C12712455_ScriptCanvas_ShapeCastVerification.py index a5c827edb9..61f26ebecb 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C12712455_ScriptCanvas_ShapeCastVerification.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C12712455_ScriptCanvas_ShapeCastVerification.py @@ -76,9 +76,8 @@ def C12712455_ScriptCanvas_ShapeCastVerification(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -145,5 +144,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C12712455_ScriptCanvas_ShapeCastVerification) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C12868578_ForceRegion_DirectionHasNoAffectOnMagnitude.py b/AutomatedTesting/Gem/PythonTests/physics/C12868578_ForceRegion_DirectionHasNoAffectOnMagnitude.py index b84adcd246..4745927e89 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C12868578_ForceRegion_DirectionHasNoAffectOnMagnitude.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C12868578_ForceRegion_DirectionHasNoAffectOnMagnitude.py @@ -95,9 +95,8 @@ def C12868578_ForceRegion_DirectionHasNoAffectOnMagnitude(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -291,5 +290,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C12868578_ForceRegion_DirectionHasNoAffectOnMagnitude) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C12868580_ForceRegion_SplineModifiedTransform.py b/AutomatedTesting/Gem/PythonTests/physics/C12868580_ForceRegion_SplineModifiedTransform.py index 481c1fa43c..937fdd85a6 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C12868580_ForceRegion_SplineModifiedTransform.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C12868580_ForceRegion_SplineModifiedTransform.py @@ -83,8 +83,8 @@ def C12868580_ForceRegion_SplineModifiedTransform(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import itertools import azlmbr @@ -175,5 +175,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C12868580_ForceRegion_SplineModifiedTransform) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C12905527_ForceRegion_MagnitudeDeviation.py b/AutomatedTesting/Gem/PythonTests/physics/C12905527_ForceRegion_MagnitudeDeviation.py index a9fb92b4fa..0cb0a2f841 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C12905527_ForceRegion_MagnitudeDeviation.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C12905527_ForceRegion_MagnitudeDeviation.py @@ -63,8 +63,8 @@ def C12905527_ForceRegion_MagnitudeDeviation(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr import azlmbr.legacy.general as general @@ -150,5 +150,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C12905527_ForceRegion_MagnitudeDeviation) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C12905528_ForceRegion_WithNonTriggerCollider.py b/AutomatedTesting/Gem/PythonTests/physics/C12905528_ForceRegion_WithNonTriggerCollider.py index d3fe35b1cd..42565333f7 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C12905528_ForceRegion_WithNonTriggerCollider.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C12905528_ForceRegion_WithNonTriggerCollider.py @@ -50,11 +50,12 @@ def run(): # Helper file Imports import ImportPathHelper as imports + from editor_python_test_tools.editor_entity_utils import EditorEntity + from editor_python_test_tools.utils import Report + imports.init() - from utils import Report - from utils import TestHelper as helper - from utils import Tracer - from editor_entity_utils import EditorEntity + from editor_python_test_tools.utils import TestHelper as helper + from editor_python_test_tools.utils import Tracer helper.init_idle() # 1) Load the empty level diff --git a/AutomatedTesting/Gem/PythonTests/physics/C13351703_COM_NotIncludeTriggerShapes.py b/AutomatedTesting/Gem/PythonTests/physics/C13351703_COM_NotIncludeTriggerShapes.py index d4bbdca52f..828022ccf2 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C13351703_COM_NotIncludeTriggerShapes.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C13351703_COM_NotIncludeTriggerShapes.py @@ -64,9 +64,8 @@ def C13351703_COM_NotIncludeTriggerShapes(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -101,5 +100,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C13351703_COM_NotIncludeTriggerShapes) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C13352089_RigidBodies_MaxAngularVelocity.py b/AutomatedTesting/Gem/PythonTests/physics/C13352089_RigidBodies_MaxAngularVelocity.py index eb3429f852..77d93d9752 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C13352089_RigidBodies_MaxAngularVelocity.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C13352089_RigidBodies_MaxAngularVelocity.py @@ -131,8 +131,8 @@ def C13352089_RigidBodies_MaxAngularVelocity(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.math as lymath import azlmbr.legacy.general as general import azlmbr.bus @@ -288,5 +288,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C13352089_RigidBodies_MaxAngularVelocity) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C13508019_Terrain_TerrainTexturePainterWorks.py b/AutomatedTesting/Gem/PythonTests/physics/C13508019_Terrain_TerrainTexturePainterWorks.py index 943fb4d754..1c580bfbfe 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C13508019_Terrain_TerrainTexturePainterWorks.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C13508019_Terrain_TerrainTexturePainterWorks.py @@ -48,7 +48,8 @@ def C13508019_Terrain_TerrainTexturePainterWorks(): imports.init() - from utils import Report, TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -143,5 +144,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C13508019_Terrain_TerrainTexturePainterWorks) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C13895144_Ragdoll_ChangeLevel.py b/AutomatedTesting/Gem/PythonTests/physics/C13895144_Ragdoll_ChangeLevel.py index db497dabc6..61efe20dbd 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C13895144_Ragdoll_ChangeLevel.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C13895144_Ragdoll_ChangeLevel.py @@ -67,9 +67,8 @@ def C13895144_Ragdoll_ChangeLevel(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general @@ -112,5 +111,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C13895144_Ragdoll_ChangeLevel) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14195074_ScriptCanvas_PostUpdateEvent.py b/AutomatedTesting/Gem/PythonTests/physics/C14195074_ScriptCanvas_PostUpdateEvent.py index 4837de3538..5668082f78 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14195074_ScriptCanvas_PostUpdateEvent.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14195074_ScriptCanvas_PostUpdateEvent.py @@ -70,9 +70,8 @@ def C14195074_ScriptCanvas_PostUpdateEvent(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr import azlmbr.legacy.general as general @@ -190,5 +189,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C14195074_ScriptCanvas_PostUpdateEvent) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14654881_CharacterController_SwitchLevels.py b/AutomatedTesting/Gem/PythonTests/physics/C14654881_CharacterController_SwitchLevels.py index 0958a4bbbb..fd5653b801 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14654881_CharacterController_SwitchLevels.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14654881_CharacterController_SwitchLevels.py @@ -62,8 +62,8 @@ def C14654881_CharacterController_SwitchLevels(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -100,5 +100,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C14654881_CharacterController_SwitchLevels) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14654882_Ragdoll_ragdollAPTest.py b/AutomatedTesting/Gem/PythonTests/physics/C14654882_Ragdoll_ragdollAPTest.py index 2bc620e0c1..03c18a5f1a 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14654882_Ragdoll_ragdollAPTest.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14654882_Ragdoll_ragdollAPTest.py @@ -78,9 +78,8 @@ def C14654882_Ragdoll_ragdollAPTest(): imports.init() - - from utils import TestHelper as helper - from utils import Report + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper helper.init_idle() @@ -137,5 +136,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C14654882_Ragdoll_ragdollAPTest) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14861498_ConfirmError_NoPxMesh.py b/AutomatedTesting/Gem/PythonTests/physics/C14861498_ConfirmError_NoPxMesh.py index 9aac3ae91c..e52bdb7574 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14861498_ConfirmError_NoPxMesh.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14861498_ConfirmError_NoPxMesh.py @@ -57,9 +57,9 @@ def C14861498_ConfirmError_NoPxMesh(): imports.init() - from utils import Report - from utils import TestHelper as helper - from utils import Tracer + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper + from editor_python_test_tools.utils import Tracer import azlmbr.legacy.general as general @@ -92,5 +92,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C14861498_ConfirmError_NoPxMesh) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14861500_DefaultSetting_ColliderShape.py b/AutomatedTesting/Gem/PythonTests/physics/C14861500_DefaultSetting_ColliderShape.py index 43d4d0e905..7a65448dcd 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14861500_DefaultSetting_ColliderShape.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14861500_DefaultSetting_ColliderShape.py @@ -47,9 +47,9 @@ def C14861500_DefaultSetting_ColliderShape(): import ImportPathHelper as imports imports.init() - from utils import Report - from utils import TestHelper as helper - from editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper # Open 3D Engine Imports import azlmbr.legacy.general as general @@ -77,5 +77,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C14861500_DefaultSetting_ColliderShape) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14861501_PhysXCollider_RenderMeshAutoAssigned.py b/AutomatedTesting/Gem/PythonTests/physics/C14861501_PhysXCollider_RenderMeshAutoAssigned.py index a7fc5cf3b5..eae5ea547a 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14861501_PhysXCollider_RenderMeshAutoAssigned.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14861501_PhysXCollider_RenderMeshAutoAssigned.py @@ -55,9 +55,9 @@ def run(): import ImportPathHelper as imports imports.init() - from utils import Report - from utils import TestHelper as helper - from editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper from asset_utils import Asset # Asset paths diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14861502_PhysXCollider_AssetAutoAssigned.py b/AutomatedTesting/Gem/PythonTests/physics/C14861502_PhysXCollider_AssetAutoAssigned.py index 94c1d8e404..6ea81ea2ff 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14861502_PhysXCollider_AssetAutoAssigned.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14861502_PhysXCollider_AssetAutoAssigned.py @@ -54,9 +54,9 @@ def C14861502_PhysXCollider_AssetAutoAssigned(): import ImportPathHelper as imports imports.init() - from utils import Report - from utils import TestHelper as helper - from editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper from asset_utils import Asset # Open 3D Engine Imports @@ -100,5 +100,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C14861502_PhysXCollider_AssetAutoAssigned) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14861504_RenderMeshAsset_WithNoPxAsset.py b/AutomatedTesting/Gem/PythonTests/physics/C14861504_RenderMeshAsset_WithNoPxAsset.py index 0a6962a31c..abc79ba1b0 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14861504_RenderMeshAsset_WithNoPxAsset.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14861504_RenderMeshAsset_WithNoPxAsset.py @@ -59,10 +59,10 @@ def run(): import ImportPathHelper as imports imports.init() - from utils import Report - from utils import TestHelper as helper - from utils import Tracer - from editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper + from editor_python_test_tools.utils import Tracer from asset_utils import Asset # Open 3D Engine Imports diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14902097_ScriptCanvas_PreUpdateEvent.py b/AutomatedTesting/Gem/PythonTests/physics/C14902097_ScriptCanvas_PreUpdateEvent.py index ea62be9768..45557098f7 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14902097_ScriptCanvas_PreUpdateEvent.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14902097_ScriptCanvas_PreUpdateEvent.py @@ -72,9 +72,8 @@ def C14902097_ScriptCanvas_PreUpdateEvent(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr import azlmbr.legacy.general as general @@ -197,5 +196,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C14902097_ScriptCanvas_PreUpdateEvent) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14902098_ScriptCanvas_PostPhysicsUpdate.py b/AutomatedTesting/Gem/PythonTests/physics/C14902098_ScriptCanvas_PostPhysicsUpdate.py index fc3ae2bc18..19caaab4fe 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14902098_ScriptCanvas_PostPhysicsUpdate.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14902098_ScriptCanvas_PostPhysicsUpdate.py @@ -84,9 +84,8 @@ def C14902098_ScriptCanvas_PostPhysicsUpdate(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general @@ -118,5 +117,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C14902098_ScriptCanvas_PostPhysicsUpdate) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14976307_Gravity_SetGravityWorks.py b/AutomatedTesting/Gem/PythonTests/physics/C14976307_Gravity_SetGravityWorks.py index 33a26d9433..342ac6bdbd 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14976307_Gravity_SetGravityWorks.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14976307_Gravity_SetGravityWorks.py @@ -69,9 +69,8 @@ def C14976307_Gravity_SetGravityWorks(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -130,5 +129,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C14976307_Gravity_SetGravityWorks) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14976308_ScriptCanvas_SetKinematicTargetTransform.py b/AutomatedTesting/Gem/PythonTests/physics/C14976308_ScriptCanvas_SetKinematicTargetTransform.py index ea01c71310..815e922a76 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14976308_ScriptCanvas_SetKinematicTargetTransform.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14976308_ScriptCanvas_SetKinematicTargetTransform.py @@ -100,14 +100,13 @@ def C14976308_ScriptCanvas_SetKinematicTargetTransform(): imports.init() - import azlmbr.legacy.general as general import azlmbr.bus import azlmbr.components import azlmbr.math import azlmbr.physics - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import itertools class Entity: @@ -228,5 +227,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C14976308_ScriptCanvas_SetKinematicTargetTransform) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15096732_Material_DefaultLibraryUpdatedAcrossLevels_after.py b/AutomatedTesting/Gem/PythonTests/physics/C15096732_Material_DefaultLibraryUpdatedAcrossLevels_after.py index f637981b1d..76ea9475ff 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15096732_Material_DefaultLibraryUpdatedAcrossLevels_after.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15096732_Material_DefaultLibraryUpdatedAcrossLevels_after.py @@ -108,9 +108,8 @@ def C15096732_Material_DefaultLibraryUpdatedAcrossLevels_after(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -293,5 +292,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C15096732_Material_DefaultLibraryUpdatedAcrossLevels_after) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15096732_Material_DefaultLibraryUpdatedAcrossLevels_before.py b/AutomatedTesting/Gem/PythonTests/physics/C15096732_Material_DefaultLibraryUpdatedAcrossLevels_before.py index fcbc0ff723..748052db56 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15096732_Material_DefaultLibraryUpdatedAcrossLevels_before.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15096732_Material_DefaultLibraryUpdatedAcrossLevels_before.py @@ -101,9 +101,8 @@ def C15096732_Material_DefaultLibraryUpdatedAcrossLevels_before(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -245,5 +244,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C15096732_Material_DefaultLibraryUpdatedAcrossLevels_before) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15096735_Materials_DefaultLibraryConsistency.py b/AutomatedTesting/Gem/PythonTests/physics/C15096735_Materials_DefaultLibraryConsistency.py index f393ddf527..4c7949cc91 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15096735_Materials_DefaultLibraryConsistency.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15096735_Materials_DefaultLibraryConsistency.py @@ -149,8 +149,8 @@ def C15096735_Materials_DefaultLibraryConsistency(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -424,5 +424,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C15096735_Materials_DefaultLibraryConsistency) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15096737_Materials_DefaultMaterialLibraryChanges.py b/AutomatedTesting/Gem/PythonTests/physics/C15096737_Materials_DefaultMaterialLibraryChanges.py index cf849bbea8..cc7dc3c5e2 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15096737_Materials_DefaultMaterialLibraryChanges.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15096737_Materials_DefaultMaterialLibraryChanges.py @@ -115,9 +115,8 @@ def C15096737_Materials_DefaultMaterialLibraryChanges(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus from Physmaterial_Editor import Physmaterial_Editor @@ -301,5 +300,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C15096737_Materials_DefaultMaterialLibraryChanges) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15096740_Material_LibraryUpdatedCorrectly.py b/AutomatedTesting/Gem/PythonTests/physics/C15096740_Material_LibraryUpdatedCorrectly.py index c69b722e27..0f33f0858b 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15096740_Material_LibraryUpdatedCorrectly.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15096740_Material_LibraryUpdatedCorrectly.py @@ -58,9 +58,9 @@ def C15096740_Material_LibraryUpdatedCorrectly(): imports.init() # Helper file Imports - from utils import Report - from utils import TestHelper as helper - from editor_entity_utils import EditorEntity + from editor_python_test_tools.editor_entity_utils import EditorEntity + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper from asset_utils import Asset # Open 3D Engine Imports @@ -107,5 +107,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C15096740_Material_LibraryUpdatedCorrectly) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15308217_NoCrash_LevelSwitch.py b/AutomatedTesting/Gem/PythonTests/physics/C15308217_NoCrash_LevelSwitch.py index 998d21067b..625a8bfb4a 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15308217_NoCrash_LevelSwitch.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15308217_NoCrash_LevelSwitch.py @@ -71,9 +71,8 @@ def C15308217_NoCrash_LevelSwitch(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -114,5 +113,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C15308217_NoCrash_LevelSwitch) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15308221_Material_ComponentsInSyncWithLibrary.py b/AutomatedTesting/Gem/PythonTests/physics/C15308221_Material_ComponentsInSyncWithLibrary.py index a6ddb73438..3f6457f15c 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15308221_Material_ComponentsInSyncWithLibrary.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15308221_Material_ComponentsInSyncWithLibrary.py @@ -114,7 +114,6 @@ def C15308221_Material_ComponentsInSyncWithLibrary(): imports.init() - import azlmbr.legacy.general as general import azlmbr.bus as bus import azlmbr.components @@ -122,8 +121,8 @@ def C15308221_Material_ComponentsInSyncWithLibrary(): import azlmbr.math as lymath from Physmaterial_Editor import Physmaterial_Editor - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper TIMEOUT = 3.0 BOUNCE_TOLERANCE = 0.1 @@ -252,5 +251,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C15308221_Material_ComponentsInSyncWithLibrary) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15425929_Undo_Redo.py b/AutomatedTesting/Gem/PythonTests/physics/C15425929_Undo_Redo.py index f5a1fcebc3..57a0e6a75e 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15425929_Undo_Redo.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15425929_Undo_Redo.py @@ -53,10 +53,9 @@ def C15425929_Undo_Redo(): imports.init() - - from utils import Report - from utils import TestHelper as helper - from utils import Tracer + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper + from editor_python_test_tools.utils import Tracer import azlmbr.legacy.general as general @@ -99,5 +98,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C15425929_Undo_Redo) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15425935_Material_LibraryUpdatedAcrossLevels.py b/AutomatedTesting/Gem/PythonTests/physics/C15425935_Material_LibraryUpdatedAcrossLevels.py index d2db2239c2..f61886ccd0 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15425935_Material_LibraryUpdatedAcrossLevels.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15425935_Material_LibraryUpdatedAcrossLevels.py @@ -122,8 +122,8 @@ def C15425935_Material_LibraryUpdatedAcrossLevels(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -314,5 +314,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C15425935_Material_LibraryUpdatedAcrossLevels) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15556261_PhysXMaterials_CharacterControllerMaterialAssignment.py b/AutomatedTesting/Gem/PythonTests/physics/C15556261_PhysXMaterials_CharacterControllerMaterialAssignment.py index cb38a8a768..99e0dcc669 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15556261_PhysXMaterials_CharacterControllerMaterialAssignment.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15556261_PhysXMaterials_CharacterControllerMaterialAssignment.py @@ -88,8 +88,8 @@ def C15556261_PhysXMaterials_CharacterControllerMaterialAssignment(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -209,5 +209,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C15556261_PhysXMaterials_CharacterControllerMaterialAssignment) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15563573_Material_AddModifyDeleteOnCharacterController.py b/AutomatedTesting/Gem/PythonTests/physics/C15563573_Material_AddModifyDeleteOnCharacterController.py index 8b0fba05b1..4572dd322a 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15563573_Material_AddModifyDeleteOnCharacterController.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15563573_Material_AddModifyDeleteOnCharacterController.py @@ -116,14 +116,13 @@ def C15563573_Material_AddModifyDeleteOnCharacterController(): imports.init() - import azlmbr.legacy.general as general import azlmbr.math as lymath from Physmaterial_Editor import Physmaterial_Editor - from utils import Report - from utils import TestHelper as helper from AddModifyDelete_Utils import Box + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper FORCE_IMPULSE = lymath.Vector3(5.0, 0.0, 0.0) TIMEOUT = 3.0 @@ -205,5 +204,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C15563573_Material_AddModifyDeleteOnCharacterController) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15845879_ForceRegion_HighLinearDampingForce.py b/AutomatedTesting/Gem/PythonTests/physics/C15845879_ForceRegion_HighLinearDampingForce.py index 2eb7759ead..52af7d8be5 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15845879_ForceRegion_HighLinearDampingForce.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15845879_ForceRegion_HighLinearDampingForce.py @@ -65,9 +65,8 @@ def C15845879_ForceRegion_HighLinearDampingForce(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -177,5 +176,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C15845879_ForceRegion_HighLinearDampingForce) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C17411467_AddPhysxRagdollComponent.py b/AutomatedTesting/Gem/PythonTests/physics/C17411467_AddPhysxRagdollComponent.py index a3115ceeab..68efd452b2 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C17411467_AddPhysxRagdollComponent.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C17411467_AddPhysxRagdollComponent.py @@ -53,10 +53,10 @@ def run(): import ImportPathHelper as imports imports.init() - from utils import Report - from utils import TestHelper as helper - from utils import Tracer - from editor_entity_utils import EditorEntity + from editor_python_test_tools.utils import Report + from editor_python_test_tools.editor_entity_utils import EditorEntity + from editor_python_test_tools.utils import TestHelper as helper + from editor_python_test_tools.utils import Tracer helper.init_idle() # 1) Load the level diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243580_Joints_Fixed2BodiesConstrained.py b/AutomatedTesting/Gem/PythonTests/physics/C18243580_Joints_Fixed2BodiesConstrained.py index 76b05a4ce9..b13869ce12 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243580_Joints_Fixed2BodiesConstrained.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243580_Joints_Fixed2BodiesConstrained.py @@ -58,9 +58,8 @@ def C18243580_Joints_Fixed2BodiesConstrained(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -107,5 +106,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C18243580_Joints_Fixed2BodiesConstrained) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243581_Joints_FixedBreakable.py b/AutomatedTesting/Gem/PythonTests/physics/C18243581_Joints_FixedBreakable.py index ffc48f6e3c..19feee575b 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243581_Joints_FixedBreakable.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243581_Joints_FixedBreakable.py @@ -57,9 +57,8 @@ def C18243581_Joints_FixedBreakable(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -106,5 +105,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C18243581_Joints_FixedBreakable) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243582_Joints_FixedLeadFollowerCollide.py b/AutomatedTesting/Gem/PythonTests/physics/C18243582_Joints_FixedLeadFollowerCollide.py index 6c0f98b694..c9c90d35a7 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243582_Joints_FixedLeadFollowerCollide.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243582_Joints_FixedLeadFollowerCollide.py @@ -59,9 +59,8 @@ def C18243582_Joints_FixedLeadFollowerCollide(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -101,5 +100,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C18243582_Joints_FixedLeadFollowerCollide) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243583_Joints_Hinge2BodiesConstrained.py b/AutomatedTesting/Gem/PythonTests/physics/C18243583_Joints_Hinge2BodiesConstrained.py index fd1fb02557..66343534a7 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243583_Joints_Hinge2BodiesConstrained.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243583_Joints_Hinge2BodiesConstrained.py @@ -61,9 +61,8 @@ def C18243583_Joints_Hinge2BodiesConstrained(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -124,5 +123,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C18243583_Joints_Hinge2BodiesConstrained) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243584_Joints_HingeSoftLimitsConstrained.py b/AutomatedTesting/Gem/PythonTests/physics/C18243584_Joints_HingeSoftLimitsConstrained.py index c1ed3328a7..3b335cc5c6 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243584_Joints_HingeSoftLimitsConstrained.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243584_Joints_HingeSoftLimitsConstrained.py @@ -61,9 +61,8 @@ def C18243584_Joints_HingeSoftLimitsConstrained(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -120,5 +119,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C18243584_Joints_HingeSoftLimitsConstrained) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243585_Joints_HingeNoLimitsConstrained.py b/AutomatedTesting/Gem/PythonTests/physics/C18243585_Joints_HingeNoLimitsConstrained.py index 515c51eb0b..289522fcac 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243585_Joints_HingeNoLimitsConstrained.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243585_Joints_HingeNoLimitsConstrained.py @@ -61,9 +61,8 @@ def C18243585_Joints_HingeNoLimitsConstrained(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -120,5 +119,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C18243585_Joints_HingeNoLimitsConstrained) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243586_Joints_HingeLeadFollowerCollide.py b/AutomatedTesting/Gem/PythonTests/physics/C18243586_Joints_HingeLeadFollowerCollide.py index d673885ea1..60b9189c83 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243586_Joints_HingeLeadFollowerCollide.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243586_Joints_HingeLeadFollowerCollide.py @@ -58,9 +58,8 @@ def C18243586_Joints_HingeLeadFollowerCollide(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -100,5 +99,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C18243586_Joints_HingeLeadFollowerCollide) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243587_Joints_HingeBreakable.py b/AutomatedTesting/Gem/PythonTests/physics/C18243587_Joints_HingeBreakable.py index d58d618b99..af6fa8cbac 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243587_Joints_HingeBreakable.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243587_Joints_HingeBreakable.py @@ -59,9 +59,8 @@ def C18243587_Joints_HingeBreakable(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -118,5 +117,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C18243587_Joints_HingeBreakable) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243588_Joints_Ball2BodiesConstrained.py b/AutomatedTesting/Gem/PythonTests/physics/C18243588_Joints_Ball2BodiesConstrained.py index 1ead30c65e..074ca03000 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243588_Joints_Ball2BodiesConstrained.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243588_Joints_Ball2BodiesConstrained.py @@ -60,9 +60,8 @@ def C18243588_Joints_Ball2BodiesConstrained(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -122,5 +121,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C18243588_Joints_Ball2BodiesConstrained) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243589_Joints_BallSoftLimitsConstrained.py b/AutomatedTesting/Gem/PythonTests/physics/C18243589_Joints_BallSoftLimitsConstrained.py index d29c472fcd..e038b33043 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243589_Joints_BallSoftLimitsConstrained.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243589_Joints_BallSoftLimitsConstrained.py @@ -62,9 +62,8 @@ def C18243589_Joints_BallSoftLimitsConstrained(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -123,5 +122,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C18243589_Joints_BallSoftLimitsConstrained) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243590_Joints_BallNoLimitsConstrained.py b/AutomatedTesting/Gem/PythonTests/physics/C18243590_Joints_BallNoLimitsConstrained.py index d3a0c8e82c..ede46fd5c5 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243590_Joints_BallNoLimitsConstrained.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243590_Joints_BallNoLimitsConstrained.py @@ -63,9 +63,8 @@ def C18243590_Joints_BallNoLimitsConstrained(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -121,5 +120,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C18243590_Joints_BallNoLimitsConstrained) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243591_Joints_BallLeadFollowerCollide.py b/AutomatedTesting/Gem/PythonTests/physics/C18243591_Joints_BallLeadFollowerCollide.py index ba8967acab..c3e527956f 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243591_Joints_BallLeadFollowerCollide.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243591_Joints_BallLeadFollowerCollide.py @@ -58,9 +58,8 @@ def C18243591_Joints_BallLeadFollowerCollide(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -100,5 +99,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C18243591_Joints_BallLeadFollowerCollide) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243592_Joints_BallBreakable.py b/AutomatedTesting/Gem/PythonTests/physics/C18243592_Joints_BallBreakable.py index 2b07d63a43..350fccd125 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243592_Joints_BallBreakable.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243592_Joints_BallBreakable.py @@ -58,9 +58,8 @@ def C18243592_Joints_BallBreakable(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -116,5 +115,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C18243592_Joints_BallBreakable) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243593_Joints_GlobalFrameConstrained.py b/AutomatedTesting/Gem/PythonTests/physics/C18243593_Joints_GlobalFrameConstrained.py index 1ebdaf73b3..4580a229ea 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243593_Joints_GlobalFrameConstrained.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243593_Joints_GlobalFrameConstrained.py @@ -62,9 +62,8 @@ def C18243593_Joints_GlobalFrameConstrained(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -129,5 +128,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C18243593_Joints_GlobalFrameConstrained) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18977601_Material_FrictionCombinePriority.py b/AutomatedTesting/Gem/PythonTests/physics/C18977601_Material_FrictionCombinePriority.py index 46f1535bf4..57dfc0f349 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18977601_Material_FrictionCombinePriority.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18977601_Material_FrictionCombinePriority.py @@ -136,8 +136,8 @@ def C18977601_Material_FrictionCombinePriority(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr import azlmbr.legacy.general as general @@ -364,5 +364,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C18977601_Material_FrictionCombinePriority) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18981526_Material_RestitutionCombinePriority.py b/AutomatedTesting/Gem/PythonTests/physics/C18981526_Material_RestitutionCombinePriority.py index 800ad38264..9b7fea1ab9 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18981526_Material_RestitutionCombinePriority.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18981526_Material_RestitutionCombinePriority.py @@ -135,9 +135,8 @@ def C18981526_Material_RestitutionCombinePriority(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr import azlmbr.legacy.general as general @@ -425,5 +424,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C18981526_Material_RestitutionCombinePriority) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C19536274_GetCollisionName_PrintsName.py b/AutomatedTesting/Gem/PythonTests/physics/C19536274_GetCollisionName_PrintsName.py index 8dbee3cd4e..48c947aa1f 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C19536274_GetCollisionName_PrintsName.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C19536274_GetCollisionName_PrintsName.py @@ -50,9 +50,9 @@ def run(): import ImportPathHelper as imports imports.init() - from utils import Report - from utils import TestHelper as helper - from editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.utils import Report + from editor_python_test_tools.editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.utils import TestHelper as helper ACTIVE_STATUS = azlmbr.globals.property.EditorEntityStartStatus_StartActive diff --git a/AutomatedTesting/Gem/PythonTests/physics/C19536277_GetCollisionName_PrintsNothing.py b/AutomatedTesting/Gem/PythonTests/physics/C19536277_GetCollisionName_PrintsNothing.py index 141c9fb4db..66e1302b5b 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C19536277_GetCollisionName_PrintsNothing.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C19536277_GetCollisionName_PrintsNothing.py @@ -50,9 +50,9 @@ def run(): import ImportPathHelper as imports imports.init() - from utils import Report - from utils import TestHelper as helper - from editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.utils import Report + from editor_python_test_tools.editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.utils import TestHelper as helper ACTIVE_STATUS = azlmbr.globals.property.EditorEntityStartStatus_StartActive diff --git a/AutomatedTesting/Gem/PythonTests/physics/C19578018_ShapeColliderWithNoShapeComponent.py b/AutomatedTesting/Gem/PythonTests/physics/C19578018_ShapeColliderWithNoShapeComponent.py index 8910a4ded4..32ece8541c 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C19578018_ShapeColliderWithNoShapeComponent.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C19578018_ShapeColliderWithNoShapeComponent.py @@ -56,9 +56,9 @@ def C19578018_ShapeColliderWithNoShapeComponent(): imports.init() # Helper Imports - from utils import Report - from utils import TestHelper as helper - from editor_entity_utils import EditorEntity + from editor_python_test_tools.utils import Report + from editor_python_test_tools.editor_entity_utils import EditorEntity + from editor_python_test_tools.utils import TestHelper as helper # Open 3D Engine Imports import azlmbr.bus as bus @@ -99,5 +99,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C19578018_ShapeColliderWithNoShapeComponent) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C19578021_ShapeCollider_CanBeAdded.py b/AutomatedTesting/Gem/PythonTests/physics/C19578021_ShapeCollider_CanBeAdded.py index 5c940264ff..0c42f5457d 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C19578021_ShapeCollider_CanBeAdded.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C19578021_ShapeCollider_CanBeAdded.py @@ -51,10 +51,10 @@ def C19578021_ShapeCollider_CanBeAdded(): import ImportPathHelper as imports imports.init() - from utils import Report - from utils import TestHelper as helper - from utils import Tracer - from editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper + from editor_python_test_tools.utils import Tracer # Open 3D Engine Imports import azlmbr.legacy.general as general @@ -97,5 +97,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C19578021_ShapeCollider_CanBeAdded) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C19723164_ShapeColliders_WontCrashEditor.py b/AutomatedTesting/Gem/PythonTests/physics/C19723164_ShapeColliders_WontCrashEditor.py index 3296b32fc9..769f08e3c4 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C19723164_ShapeColliders_WontCrashEditor.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C19723164_ShapeColliders_WontCrashEditor.py @@ -47,9 +47,9 @@ def C19723164_ShapeColliders_WontCrashEditor(): import ImportPathHelper as imports imports.init() - from utils import Report - from utils import TestHelper as helper - from editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper + from editor_python_test_tools.editor_entity_utils import EditorEntity as Entity # Open 3D Engine Imports import azlmbr.legacy.general as general @@ -103,5 +103,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C19723164_ShapeColliders_WontCrashEditor) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain.py b/AutomatedTesting/Gem/PythonTests/physics/C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain.py index b879e37aa9..d8e0a6769c 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain.py @@ -57,8 +57,8 @@ def C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain(): import azlmbr.legacy.general as general import azlmbr.bus - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper # Global time out TIME_OUT = 1.0 @@ -119,5 +119,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C28978033_Ragdoll_WorldBodyBusTests.py b/AutomatedTesting/Gem/PythonTests/physics/C28978033_Ragdoll_WorldBodyBusTests.py index 9f595616e7..8980e68250 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C28978033_Ragdoll_WorldBodyBusTests.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C28978033_Ragdoll_WorldBodyBusTests.py @@ -56,9 +56,9 @@ def C28978033_Ragdoll_WorldBodyBusTests(): import azlmbr.legacy.general as general import azlmbr.bus - from utils import Report - from utils import TestHelper as helper - from utils import vector3_str, aabb_str + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper + from editor_python_test_tools.utils import vector3_str, aabb_str # Global time out TIME_OUT = 1.0 @@ -123,5 +123,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C28978033_Ragdoll_WorldBodyBusTests) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C29032500_EditorComponents_WorldBodyBusWorks.py b/AutomatedTesting/Gem/PythonTests/physics/C29032500_EditorComponents_WorldBodyBusWorks.py index 2dc9a306c7..be541e4bf9 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C29032500_EditorComponents_WorldBodyBusWorks.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C29032500_EditorComponents_WorldBodyBusWorks.py @@ -94,9 +94,9 @@ def C29032500_EditorComponents_WorldBodyBusWorks(): import azlmbr.legacy.general as general import azlmbr.bus import math - from utils import Report - from utils import TestHelper as helper - from utils import vector3_str, aabb_str + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper + from editor_python_test_tools.utils import vector3_str, aabb_str AABB_THRESHOLD = 0.01 # Entities won't move in the simulation @@ -161,5 +161,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C29032500_EditorComponents_WorldBodyBusWorks) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C3510642_Terrain_NotCollideWithTerrain.py b/AutomatedTesting/Gem/PythonTests/physics/C3510642_Terrain_NotCollideWithTerrain.py index 086f045eec..3e3770adb9 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C3510642_Terrain_NotCollideWithTerrain.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C3510642_Terrain_NotCollideWithTerrain.py @@ -74,12 +74,11 @@ def C3510642_Terrain_NotCollideWithTerrain(): imports.init() - import azlmbr.legacy.general as general import azlmbr.bus - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper # Constants TIMEOUT = 2.0 @@ -176,5 +175,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C3510642_Terrain_NotCollideWithTerrain) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C3510644_Collider_CollisionGroups.py b/AutomatedTesting/Gem/PythonTests/physics/C3510644_Collider_CollisionGroups.py index 765f7cbfe0..4ae10288bd 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C3510644_Collider_CollisionGroups.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C3510644_Collider_CollisionGroups.py @@ -100,8 +100,8 @@ def C3510644_Collider_CollisionGroups(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -370,5 +370,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C3510644_Collider_CollisionGroups) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4044455_Material_libraryChangesInstantly.py b/AutomatedTesting/Gem/PythonTests/physics/C4044455_Material_libraryChangesInstantly.py index aae538527a..5f2c40f11e 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4044455_Material_libraryChangesInstantly.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4044455_Material_libraryChangesInstantly.py @@ -182,9 +182,8 @@ def C4044455_Material_libraryChangesInstantly(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -486,5 +485,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4044455_Material_libraryChangesInstantly) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4044456_Material_FrictionCombine.py b/AutomatedTesting/Gem/PythonTests/physics/C4044456_Material_FrictionCombine.py index 80b7c6443f..b71c1e8ede 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4044456_Material_FrictionCombine.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4044456_Material_FrictionCombine.py @@ -100,9 +100,8 @@ def C4044456_Material_FrictionCombine(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr import azlmbr.legacy.general as general @@ -221,5 +220,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4044456_Material_FrictionCombine) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4044457_Material_RestitutionCombine.py b/AutomatedTesting/Gem/PythonTests/physics/C4044457_Material_RestitutionCombine.py index 856a663fe6..1ed2e8086c 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4044457_Material_RestitutionCombine.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4044457_Material_RestitutionCombine.py @@ -105,9 +105,8 @@ def C4044457_Material_RestitutionCombine(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr import azlmbr.legacy.general as general @@ -253,5 +252,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4044457_Material_RestitutionCombine) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4044459_Material_DynamicFriction.py b/AutomatedTesting/Gem/PythonTests/physics/C4044459_Material_DynamicFriction.py index ab4a8c1574..c420250dfa 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4044459_Material_DynamicFriction.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4044459_Material_DynamicFriction.py @@ -91,9 +91,8 @@ def C4044459_Material_DynamicFriction(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr import azlmbr.legacy.general as general @@ -199,5 +198,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4044459_Material_DynamicFriction) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4044460_Material_StaticFriction.py b/AutomatedTesting/Gem/PythonTests/physics/C4044460_Material_StaticFriction.py index 9918c5fac6..4e330002ff 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4044460_Material_StaticFriction.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4044460_Material_StaticFriction.py @@ -89,9 +89,8 @@ def C4044460_Material_StaticFriction(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr import azlmbr.legacy.general as general @@ -196,5 +195,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4044460_Material_StaticFriction) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4044461_Material_Restitution.py b/AutomatedTesting/Gem/PythonTests/physics/C4044461_Material_Restitution.py index a11cfd47f6..af8990d87f 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4044461_Material_Restitution.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4044461_Material_Restitution.py @@ -96,9 +96,8 @@ def C4044461_Material_Restitution(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr import azlmbr.legacy.general as general @@ -238,5 +237,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4044461_Material_Restitution) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4044694_Material_EmptyLibraryUsesDefault.py b/AutomatedTesting/Gem/PythonTests/physics/C4044694_Material_EmptyLibraryUsesDefault.py index 3c3b777a69..a8375114d5 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4044694_Material_EmptyLibraryUsesDefault.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4044694_Material_EmptyLibraryUsesDefault.py @@ -75,15 +75,14 @@ def C4044694_Material_EmptyLibraryUsesDefault(): imports.init() - import azlmbr.legacy.general as general import azlmbr.bus as bus import azlmbr.components import azlmbr.physics import azlmbr.math as lymath - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper FORCE_IMPULSE = lymath.Vector3(5.0, 0.0, 0.0) TIMEOUT = 3.0 @@ -197,5 +196,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4044694_Material_EmptyLibraryUsesDefault) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4044695_PhysXCollider_AddMultipleSurfaceFbx.py b/AutomatedTesting/Gem/PythonTests/physics/C4044695_PhysXCollider_AddMultipleSurfaceFbx.py index cc2caaf3b6..a92927a9db 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4044695_PhysXCollider_AddMultipleSurfaceFbx.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4044695_PhysXCollider_AddMultipleSurfaceFbx.py @@ -60,9 +60,9 @@ def run(): import ImportPathHelper as imports imports.init() - from utils import Report - from utils import TestHelper as helper - from editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper from asset_utils import Asset # Constants diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4044697_Material_PerfaceMaterialValidation.py b/AutomatedTesting/Gem/PythonTests/physics/C4044697_Material_PerfaceMaterialValidation.py index 46a6b04edf..dba759015f 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4044697_Material_PerfaceMaterialValidation.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4044697_Material_PerfaceMaterialValidation.py @@ -116,9 +116,8 @@ def C4044697_Material_PerfaceMaterialValidation(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -310,5 +309,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4044697_Material_PerfaceMaterialValidation) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4888315_Material_AddModifyDeleteOnCollider.py b/AutomatedTesting/Gem/PythonTests/physics/C4888315_Material_AddModifyDeleteOnCollider.py index 49673da217..145a5e1b60 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4888315_Material_AddModifyDeleteOnCollider.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4888315_Material_AddModifyDeleteOnCollider.py @@ -99,13 +99,12 @@ def C4888315_Material_AddModifyDeleteOnCollider(): imports.init() - import azlmbr.legacy.general as general import azlmbr.math as lymath from Physmaterial_Editor import Physmaterial_Editor - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper from AddModifyDelete_Utils import Box FORCE_IMPULSE = lymath.Vector3(5.0, 0.0, 0.0) @@ -184,5 +183,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4888315_Material_AddModifyDeleteOnCollider) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4925577_Materials_MaterialAssignedToTerrain.py b/AutomatedTesting/Gem/PythonTests/physics/C4925577_Materials_MaterialAssignedToTerrain.py index 80a83e0222..59b6a3fdfc 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4925577_Materials_MaterialAssignedToTerrain.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4925577_Materials_MaterialAssignedToTerrain.py @@ -85,9 +85,8 @@ def C4925577_Materials_MaterialAssignedToTerrain(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -313,5 +312,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4925577_Materials_MaterialAssignedToTerrain) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4925579_Material_AddModifyDeleteOnTerrain.py b/AutomatedTesting/Gem/PythonTests/physics/C4925579_Material_AddModifyDeleteOnTerrain.py index 87f94c6dd4..e0425c35be 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4925579_Material_AddModifyDeleteOnTerrain.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4925579_Material_AddModifyDeleteOnTerrain.py @@ -100,13 +100,12 @@ def C4925579_Material_AddModifyDeleteOnTerrain(): imports.init() - import azlmbr.legacy.general as general import azlmbr.math as lymath from Physmaterial_Editor import Physmaterial_Editor - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper from AddModifyDelete_Utils import Box FORCE_IMPULSE = lymath.Vector3(5.0, 0.0, 0.0) @@ -184,5 +183,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4925579_Material_AddModifyDeleteOnTerrain) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4925580_Material_RagdollBonesMaterial.py b/AutomatedTesting/Gem/PythonTests/physics/C4925580_Material_RagdollBonesMaterial.py index abb97da143..9944a033e3 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4925580_Material_RagdollBonesMaterial.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4925580_Material_RagdollBonesMaterial.py @@ -75,13 +75,12 @@ def C4925580_Material_RagdollBonesMaterial(): imports.init() - import azlmbr.legacy.general as general import azlmbr.bus import azlmbr.components import azlmbr.physics - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper # Constants TIME_OUT_SECONDS = 3.0 @@ -202,5 +201,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4925580_Material_RagdollBonesMaterial) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4925582_Material_AddModifyDeleteOnRagdollBones.py b/AutomatedTesting/Gem/PythonTests/physics/C4925582_Material_AddModifyDeleteOnRagdollBones.py index 0a309133a4..ed872ae99e 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4925582_Material_AddModifyDeleteOnRagdollBones.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4925582_Material_AddModifyDeleteOnRagdollBones.py @@ -101,7 +101,6 @@ def C4925582_Material_AddModifyDeleteOnRagdollBones(): imports.init() - import azlmbr.legacy.general as general import azlmbr.bus as bus import azlmbr.components @@ -109,8 +108,8 @@ def C4925582_Material_AddModifyDeleteOnRagdollBones(): import azlmbr.math as lymath from Physmaterial_Editor import Physmaterial_Editor - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper TIMEOUT = 3.0 BOUNCE_TOLERANCE = 0.05 @@ -220,5 +219,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4925582_Material_AddModifyDeleteOnRagdollBones) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976194_RigidBody_PhysXComponentIsValid.py b/AutomatedTesting/Gem/PythonTests/physics/C4976194_RigidBody_PhysXComponentIsValid.py index 90feb352b3..aa059eb224 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976194_RigidBody_PhysXComponentIsValid.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976194_RigidBody_PhysXComponentIsValid.py @@ -62,9 +62,8 @@ def C4976194_RigidBody_PhysXComponentIsValid(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -118,5 +117,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4976194_RigidBody_PhysXComponentIsValid) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976195_RigidBodies_InitialLinearVelocity.py b/AutomatedTesting/Gem/PythonTests/physics/C4976195_RigidBodies_InitialLinearVelocity.py index 287bc75214..c5740b2798 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976195_RigidBodies_InitialLinearVelocity.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976195_RigidBodies_InitialLinearVelocity.py @@ -67,8 +67,8 @@ def C4976195_RigidBodies_InitialLinearVelocity(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -139,5 +139,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4976195_RigidBodies_InitialLinearVelocity) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976197_RigidBodies_InitialAngularVelocity.py b/AutomatedTesting/Gem/PythonTests/physics/C4976197_RigidBodies_InitialAngularVelocity.py index 82b8df29f7..08e171269e 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976197_RigidBodies_InitialAngularVelocity.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976197_RigidBodies_InitialAngularVelocity.py @@ -80,8 +80,8 @@ def C4976197_RigidBodies_InitialAngularVelocity(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -184,5 +184,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4976197_RigidBodies_InitialAngularVelocity) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976199_RigidBodies_LinearDampingObjectMotion.py b/AutomatedTesting/Gem/PythonTests/physics/C4976199_RigidBodies_LinearDampingObjectMotion.py index 1660e71955..2e19b633c4 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976199_RigidBodies_LinearDampingObjectMotion.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976199_RigidBodies_LinearDampingObjectMotion.py @@ -65,8 +65,8 @@ def C4976199_RigidBodies_LinearDampingObjectMotion(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -277,5 +277,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4976199_RigidBodies_LinearDampingObjectMotion) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976200_RigidBody_AngularDampingObjectRotation.py b/AutomatedTesting/Gem/PythonTests/physics/C4976200_RigidBody_AngularDampingObjectRotation.py index e5438cd132..b90b34be53 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976200_RigidBody_AngularDampingObjectRotation.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976200_RigidBody_AngularDampingObjectRotation.py @@ -69,9 +69,9 @@ def C4976200_RigidBody_AngularDampingObjectRotation(): imports.init() - from utils import Report - from utils import TestHelper as helper - from utils import AngleHelper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper + from editor_python_test_tools.utils import AngleHelper import azlmbr.legacy.general as general import azlmbr.bus @@ -292,5 +292,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4976200_RigidBody_AngularDampingObjectRotation) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976201_RigidBody_MassIsAssigned.py b/AutomatedTesting/Gem/PythonTests/physics/C4976201_RigidBody_MassIsAssigned.py index e8086e4965..7fb0ff84ce 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976201_RigidBody_MassIsAssigned.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976201_RigidBody_MassIsAssigned.py @@ -110,13 +110,12 @@ def C4976201_RigidBody_MassIsAssigned(): imports.init() - import azlmbr.legacy.general as general import azlmbr.bus import azlmbr - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper MOVEMENT_TIMEOUT = 7.0 COLLISION_TIMEOUT = 2.0 @@ -381,5 +380,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4976201_RigidBody_MassIsAssigned) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976202_RigidBody_StopsWhenBelowKineticThreshold.py b/AutomatedTesting/Gem/PythonTests/physics/C4976202_RigidBody_StopsWhenBelowKineticThreshold.py index f74119dd28..7d4cf1066e 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976202_RigidBody_StopsWhenBelowKineticThreshold.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976202_RigidBody_StopsWhenBelowKineticThreshold.py @@ -133,12 +133,11 @@ def C4976202_RigidBody_StopsWhenBelowKineticThreshold(): imports.init() - import azlmbr.legacy.general as general import azlmbr.bus - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper helper.init_idle() @@ -334,5 +333,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4976202_RigidBody_StopsWhenBelowKineticThreshold) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976204_Verify_Start_Asleep_Condition.py b/AutomatedTesting/Gem/PythonTests/physics/C4976204_Verify_Start_Asleep_Condition.py index fae8ea9a3a..29fc2ec2a3 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976204_Verify_Start_Asleep_Condition.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976204_Verify_Start_Asleep_Condition.py @@ -71,9 +71,8 @@ def C4976204_Verify_Start_Asleep_Condition(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -120,5 +119,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4976204_Verify_Start_Asleep_Condition) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976206_RigidBodies_GravityEnabledActive.py b/AutomatedTesting/Gem/PythonTests/physics/C4976206_RigidBodies_GravityEnabledActive.py index a8227b6b1f..b97c590a93 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976206_RigidBodies_GravityEnabledActive.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976206_RigidBodies_GravityEnabledActive.py @@ -73,8 +73,8 @@ def C4976206_RigidBodies_GravityEnabledActive(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -152,5 +152,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4976206_RigidBodies_GravityEnabledActive) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976207_PhysXRigidBodies_KinematicBehavior.py b/AutomatedTesting/Gem/PythonTests/physics/C4976207_PhysXRigidBodies_KinematicBehavior.py index 8003f495c8..4481c00fc5 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976207_PhysXRigidBodies_KinematicBehavior.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976207_PhysXRigidBodies_KinematicBehavior.py @@ -70,8 +70,8 @@ def C4976207_PhysXRigidBodies_KinematicBehavior(): import azlmbr.legacy.general as general import azlmbr.bus - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper # Specific wait times in seconds TIME_OUT = 3.0 @@ -139,5 +139,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4976207_PhysXRigidBodies_KinematicBehavior) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976209_RigidBody_ComputesCOM.py b/AutomatedTesting/Gem/PythonTests/physics/C4976209_RigidBody_ComputesCOM.py index 9f67751d67..79ea6e5dc7 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976209_RigidBody_ComputesCOM.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976209_RigidBody_ComputesCOM.py @@ -95,9 +95,8 @@ def C4976209_RigidBody_ComputesCOM(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr import azlmbr.legacy.general as general @@ -181,5 +180,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4976209_RigidBody_ComputesCOM) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976210_COM_ManualSetting.py b/AutomatedTesting/Gem/PythonTests/physics/C4976210_COM_ManualSetting.py index 7cda1bf6f0..451081ba23 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976210_COM_ManualSetting.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976210_COM_ManualSetting.py @@ -77,8 +77,8 @@ def C4976210_COM_ManualSetting(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus import azlmbr @@ -305,5 +305,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4976210_COM_ManualSetting) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976218_RigidBodies_InertiaObjectsNotComputed.py b/AutomatedTesting/Gem/PythonTests/physics/C4976218_RigidBodies_InertiaObjectsNotComputed.py index 289584ef51..63f0d382c3 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976218_RigidBodies_InertiaObjectsNotComputed.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976218_RigidBodies_InertiaObjectsNotComputed.py @@ -47,13 +47,13 @@ def C4976218_RigidBodies_InertiaObjectsNotComputed(): imports.init() - import azlmbr.legacy.general as general import azlmbr.bus as bus import azlmbr.components import azlmbr.physics - from utils import Report, TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper class UpperBox: def __init__(self, name): @@ -167,5 +167,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4976218_RigidBodies_InertiaObjectsNotComputed) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976227_Collider_NewGroup.py b/AutomatedTesting/Gem/PythonTests/physics/C4976227_Collider_NewGroup.py index c9b9dfb89f..8d9dc01396 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976227_Collider_NewGroup.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976227_Collider_NewGroup.py @@ -60,9 +60,8 @@ def C4976227_Collider_NewGroup(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -92,5 +91,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4976227_Collider_NewGroup) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976236_AddPhysxColliderComponent.py b/AutomatedTesting/Gem/PythonTests/physics/C4976236_AddPhysxColliderComponent.py index 8c1527fc89..906c6db55b 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976236_AddPhysxColliderComponent.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976236_AddPhysxColliderComponent.py @@ -55,10 +55,10 @@ def C4976236_AddPhysxColliderComponent(): import ImportPathHelper as imports imports.init() - from utils import Report - from utils import TestHelper as helper - from utils import Tracer - from editor_entity_utils import EditorEntity + from editor_python_test_tools.editor_entity_utils import EditorEntity + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper + from editor_python_test_tools.utils import Tracer from asset_utils import Asset helper.init_idle() @@ -103,5 +103,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4976236_AddPhysxColliderComponent) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976242_Collision_SameCollisionlayerSameCollisiongroup.py b/AutomatedTesting/Gem/PythonTests/physics/C4976242_Collision_SameCollisionlayerSameCollisiongroup.py index 93d1981187..bb6234b69e 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976242_Collision_SameCollisionlayerSameCollisiongroup.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976242_Collision_SameCollisionlayerSameCollisiongroup.py @@ -71,9 +71,8 @@ def C4976242_Collision_SameCollisionlayerSameCollisiongroup(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -196,5 +195,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4976242_Collision_SameCollisionlayerSameCollisiongroup) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976243_Collision_SameCollisionGroupDiffCollisionLayers.py b/AutomatedTesting/Gem/PythonTests/physics/C4976243_Collision_SameCollisionGroupDiffCollisionLayers.py index a4a89fcdec..949ebb2b2a 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976243_Collision_SameCollisionGroupDiffCollisionLayers.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976243_Collision_SameCollisionGroupDiffCollisionLayers.py @@ -75,9 +75,8 @@ def C4976243_Collision_SameCollisionGroupDiffCollisionLayers(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -135,5 +134,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4976243_Collision_SameCollisionGroupDiffCollisionLayers) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976244_Collider_SameGroupSameLayerCollision.py b/AutomatedTesting/Gem/PythonTests/physics/C4976244_Collider_SameGroupSameLayerCollision.py index 2770b0142c..c35b9fab81 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976244_Collider_SameGroupSameLayerCollision.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976244_Collider_SameGroupSameLayerCollision.py @@ -71,8 +71,8 @@ def C4976244_Collider_SameGroupSameLayerCollision(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -192,5 +192,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4976244_Collider_SameGroupSameLayerCollision) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976245_PhysXCollider_CollisionLayerTest.py b/AutomatedTesting/Gem/PythonTests/physics/C4976245_PhysXCollider_CollisionLayerTest.py index c70154f0be..dafb8d9014 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976245_PhysXCollider_CollisionLayerTest.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976245_PhysXCollider_CollisionLayerTest.py @@ -76,8 +76,8 @@ def C4976245_PhysXCollider_CollisionLayerTest(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -230,5 +230,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4976245_PhysXCollider_CollisionLayerTest) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4982593_PhysXCollider_CollisionLayerTest.py b/AutomatedTesting/Gem/PythonTests/physics/C4982593_PhysXCollider_CollisionLayerTest.py index a05550ba90..8d985de402 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4982593_PhysXCollider_CollisionLayerTest.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4982593_PhysXCollider_CollisionLayerTest.py @@ -76,8 +76,8 @@ def C4982593_PhysXCollider_CollisionLayerTest(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -238,5 +238,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4982593_PhysXCollider_CollisionLayerTest) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4982595_Collider_TriggerDisablesCollision.py b/AutomatedTesting/Gem/PythonTests/physics/C4982595_Collider_TriggerDisablesCollision.py index 86d862d547..8746996ca8 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4982595_Collider_TriggerDisablesCollision.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4982595_Collider_TriggerDisablesCollision.py @@ -84,13 +84,12 @@ def C4982595_Collider_TriggerDisablesCollision(): imports.init() - import azlmbr.legacy.general as general import azlmbr.bus import azlmbr.components import azlmbr.physics - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper TIME_OUT_SECONDS = 3.0 SPHERE_RADIUS = 1.0 @@ -242,5 +241,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4982595_Collider_TriggerDisablesCollision) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4982797_Collider_ColliderOffset.py b/AutomatedTesting/Gem/PythonTests/physics/C4982797_Collider_ColliderOffset.py index cbe8d7d47e..2bd4fc5adc 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4982797_Collider_ColliderOffset.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4982797_Collider_ColliderOffset.py @@ -95,8 +95,8 @@ def C4982797_Collider_ColliderOffset(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus import azlmbr @@ -339,5 +339,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4982797_Collider_ColliderOffset) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4982798_Collider_ColliderRotationOffset.py b/AutomatedTesting/Gem/PythonTests/physics/C4982798_Collider_ColliderRotationOffset.py index f64d762b3b..f86890d8bf 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4982798_Collider_ColliderRotationOffset.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4982798_Collider_ColliderRotationOffset.py @@ -96,8 +96,8 @@ def C4982798_Collider_ColliderRotationOffset(): # Internal editor imports - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus import azlmbr @@ -307,5 +307,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4982798_Collider_ColliderRotationOffset) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4982800_PhysXColliderShape_CanBeSelected.py b/AutomatedTesting/Gem/PythonTests/physics/C4982800_PhysXColliderShape_CanBeSelected.py index d38bf780d4..c37ad2b2d2 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4982800_PhysXColliderShape_CanBeSelected.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4982800_PhysXColliderShape_CanBeSelected.py @@ -50,9 +50,9 @@ def C4982800_PhysXColliderShape_CanBeSelected(): import ImportPathHelper as imports imports.init() - from utils import Report - from utils import TestHelper as helper - from editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper # Open 3D Engine Imports import azlmbr.math as math @@ -98,5 +98,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4982800_PhysXColliderShape_CanBeSelected) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4982801_PhysXColliderShape_CanBeSelected.py b/AutomatedTesting/Gem/PythonTests/physics/C4982801_PhysXColliderShape_CanBeSelected.py index 940f774088..19a835da18 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4982801_PhysXColliderShape_CanBeSelected.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4982801_PhysXColliderShape_CanBeSelected.py @@ -50,9 +50,9 @@ def C4982801_PhysXColliderShape_CanBeSelected(): import ImportPathHelper as imports imports.init() - from utils import Report - from utils import TestHelper as helper - from editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper # Open 3D Engine Imports import azlmbr.math as math @@ -110,5 +110,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4982801_PhysXColliderShape_CanBeSelected) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4982802_PhysXColliderShape_CanBeSelected.py b/AutomatedTesting/Gem/PythonTests/physics/C4982802_PhysXColliderShape_CanBeSelected.py index eba549abde..e1365d0887 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4982802_PhysXColliderShape_CanBeSelected.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4982802_PhysXColliderShape_CanBeSelected.py @@ -50,9 +50,9 @@ def C4982802_PhysXColliderShape_CanBeSelected(): import ImportPathHelper as imports imports.init() - from utils import Report - from utils import TestHelper as helper - from editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.editor_entity_utils import EditorEntity as Entity + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper # Open 3D Engine Imports import azlmbr.math as math @@ -110,5 +110,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4982802_PhysXColliderShape_CanBeSelected) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4982803_Enable_PxMesh_Option.py b/AutomatedTesting/Gem/PythonTests/physics/C4982803_Enable_PxMesh_Option.py index da201ddeda..4ae177934a 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4982803_Enable_PxMesh_Option.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4982803_Enable_PxMesh_Option.py @@ -63,9 +63,9 @@ def C4982803_Enable_PxMesh_Option(): import ImportPathHelper as imports imports.init() - from utils import Report - from utils import TestHelper as helper - from editor_entity_utils import EditorEntity + from editor_python_test_tools.editor_entity_utils import EditorEntity + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper from asset_utils import Asset import azlmbr.math as math @@ -146,5 +146,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C4982803_Enable_PxMesh_Option) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5296614_PhysXMaterial_ColliderShape.py b/AutomatedTesting/Gem/PythonTests/physics/C5296614_PhysXMaterial_ColliderShape.py index cca768fb52..9d2a49ac70 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5296614_PhysXMaterial_ColliderShape.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5296614_PhysXMaterial_ColliderShape.py @@ -69,8 +69,8 @@ def C5296614_PhysXMaterial_ColliderShape(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -159,5 +159,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5296614_PhysXMaterial_ColliderShape) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5340400_RigidBody_ManualMomentOfInertia.py b/AutomatedTesting/Gem/PythonTests/physics/C5340400_RigidBody_ManualMomentOfInertia.py index f012fe73c0..7617e41cad 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5340400_RigidBody_ManualMomentOfInertia.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5340400_RigidBody_ManualMomentOfInertia.py @@ -76,11 +76,10 @@ def C5340400_RigidBody_ManualMomentOfInertia(): imports.init() - import azlmbr.legacy.general as general import azlmbr.bus - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper # Specific wait time in seconds TIME_OUT = 3.0 @@ -168,5 +167,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5340400_RigidBody_ManualMomentOfInertia) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5689518_PhysXTerrain_CollidesWithPhysXTerrain.py b/AutomatedTesting/Gem/PythonTests/physics/C5689518_PhysXTerrain_CollidesWithPhysXTerrain.py index 359565402a..0686adf15d 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5689518_PhysXTerrain_CollidesWithPhysXTerrain.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5689518_PhysXTerrain_CollidesWithPhysXTerrain.py @@ -58,8 +58,8 @@ def C5689518_PhysXTerrain_CollidesWithPhysXTerrain(): import azlmbr.legacy.general as general import azlmbr.bus - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper # Global time out TIME_OUT = 1.0 @@ -120,5 +120,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5689518_PhysXTerrain_CollidesWithPhysXTerrain) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5689522_Physxterrain_AddPhysxterrainNoEditorCrash.py b/AutomatedTesting/Gem/PythonTests/physics/C5689522_Physxterrain_AddPhysxterrainNoEditorCrash.py index 10ebcacdb7..ffafeaab34 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5689522_Physxterrain_AddPhysxterrainNoEditorCrash.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5689522_Physxterrain_AddPhysxterrainNoEditorCrash.py @@ -67,12 +67,11 @@ def C5689522_Physxterrain_AddPhysxterrainNoEditorCrash(): imports.init() - import azlmbr.legacy.general as general - from utils import Report - from utils import TestHelper as helper - from utils import Tracer + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper + from editor_python_test_tools.utils import Tracer import azlmbr.bus @@ -113,5 +112,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5689522_Physxterrain_AddPhysxterrainNoEditorCrash) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5689524_MultipleTerrains_CheckWarningInConsole.py b/AutomatedTesting/Gem/PythonTests/physics/C5689524_MultipleTerrains_CheckWarningInConsole.py index b00821343b..2b1a73f1f3 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5689524_MultipleTerrains_CheckWarningInConsole.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5689524_MultipleTerrains_CheckWarningInConsole.py @@ -72,9 +72,9 @@ def C5689524_MultipleTerrains_CheckWarningInConsole(): import azlmbr.legacy.general as general - from utils import Report - from utils import TestHelper as helper - from utils import Tracer + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper + from editor_python_test_tools.utils import Tracer import azlmbr.bus @@ -114,5 +114,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5689524_MultipleTerrains_CheckWarningInConsole) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5689528_Terrain_MultipleTerrainComponents.py b/AutomatedTesting/Gem/PythonTests/physics/C5689528_Terrain_MultipleTerrainComponents.py index f540cae081..265836489d 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5689528_Terrain_MultipleTerrainComponents.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5689528_Terrain_MultipleTerrainComponents.py @@ -69,10 +69,9 @@ def C5689528_Terrain_MultipleTerrainComponents(): imports.init() - - from utils import Report - from utils import TestHelper as helper - from utils import Tracer + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper + from editor_python_test_tools.utils import Tracer import azlmbr.legacy.general as general @@ -111,5 +110,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5689528_Terrain_MultipleTerrainComponents) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5689529_Verify_Terrain_RigidBody_Collider_Mesh.py b/AutomatedTesting/Gem/PythonTests/physics/C5689529_Verify_Terrain_RigidBody_Collider_Mesh.py index 2fbf21fb72..138ae68408 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5689529_Verify_Terrain_RigidBody_Collider_Mesh.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5689529_Verify_Terrain_RigidBody_Collider_Mesh.py @@ -67,9 +67,8 @@ def C5689529_Verify_Terrain_RigidBody_Collider_Mesh(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -114,5 +113,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5689529_Verify_Terrain_RigidBody_Collider_Mesh) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5689531_Warning_TerrainSliceTerrainComponent.py b/AutomatedTesting/Gem/PythonTests/physics/C5689531_Warning_TerrainSliceTerrainComponent.py index c8e5d6873b..7d60a61ec1 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5689531_Warning_TerrainSliceTerrainComponent.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5689531_Warning_TerrainSliceTerrainComponent.py @@ -74,10 +74,9 @@ def C5689531_Warning_TerrainSliceTerrainComponent(): imports.init() - - from utils import Report - from utils import TestHelper as helper - from utils import Tracer + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper + from editor_python_test_tools.utils import Tracer import azlmbr.legacy.general as general @@ -123,5 +122,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5689531_Warning_TerrainSliceTerrainComponent) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5932040_ForceRegion_CubeExertsWorldForce.py b/AutomatedTesting/Gem/PythonTests/physics/C5932040_ForceRegion_CubeExertsWorldForce.py index 87bc4812b2..f01dd4582f 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5932040_ForceRegion_CubeExertsWorldForce.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5932040_ForceRegion_CubeExertsWorldForce.py @@ -74,9 +74,8 @@ def C5932040_ForceRegion_CubeExertsWorldForce(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -191,5 +190,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5932040_ForceRegion_CubeExertsWorldForce) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5932041_PhysXForceRegion_LocalSpaceForceOnRigidBodies.py b/AutomatedTesting/Gem/PythonTests/physics/C5932041_PhysXForceRegion_LocalSpaceForceOnRigidBodies.py index d78f0f386a..095a669541 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5932041_PhysXForceRegion_LocalSpaceForceOnRigidBodies.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5932041_PhysXForceRegion_LocalSpaceForceOnRigidBodies.py @@ -74,9 +74,8 @@ def C5932041_PhysXForceRegion_LocalSpaceForceOnRigidBodies(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -169,5 +168,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5932041_PhysXForceRegion_LocalSpaceForceOnRigidBodies) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5932042_PhysXForceRegion_LinearDamping.py b/AutomatedTesting/Gem/PythonTests/physics/C5932042_PhysXForceRegion_LinearDamping.py index a3f6de6a5f..04cecd45b2 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5932042_PhysXForceRegion_LinearDamping.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5932042_PhysXForceRegion_LinearDamping.py @@ -80,8 +80,8 @@ def C5932042_PhysXForceRegion_LinearDamping(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -276,5 +276,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5932042_PhysXForceRegion_LinearDamping) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5932043_ForceRegion_SimpleDragOnRigidBodies.py b/AutomatedTesting/Gem/PythonTests/physics/C5932043_ForceRegion_SimpleDragOnRigidBodies.py index 2c019b092c..512698ce4b 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5932043_ForceRegion_SimpleDragOnRigidBodies.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5932043_ForceRegion_SimpleDragOnRigidBodies.py @@ -50,7 +50,8 @@ def C5932043_ForceRegion_SimpleDragOnRigidBodies(): imports.init() - from utils import Report, TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -145,5 +146,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5932043_ForceRegion_SimpleDragOnRigidBodies) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5932044_ForceRegion_PointForceOnRigidBody.py b/AutomatedTesting/Gem/PythonTests/physics/C5932044_ForceRegion_PointForceOnRigidBody.py index 4f8121e254..b7257b488b 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5932044_ForceRegion_PointForceOnRigidBody.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5932044_ForceRegion_PointForceOnRigidBody.py @@ -74,9 +74,8 @@ def C5932044_ForceRegion_PointForceOnRigidBody(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -197,5 +196,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5932044_ForceRegion_PointForceOnRigidBody) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5932045_ForceRegion_Spline.py b/AutomatedTesting/Gem/PythonTests/physics/C5932045_ForceRegion_Spline.py index 4cb71ab54c..eca0679921 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5932045_ForceRegion_Spline.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5932045_ForceRegion_Spline.py @@ -79,9 +79,8 @@ def C5932045_ForceRegion_Spline(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import itertools import azlmbr @@ -170,5 +169,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5932045_ForceRegion_Spline) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5959759_RigidBody_ForceRegionSpherePointForce.py b/AutomatedTesting/Gem/PythonTests/physics/C5959759_RigidBody_ForceRegionSpherePointForce.py index 5271bec2ec..6aff0a7145 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5959759_RigidBody_ForceRegionSpherePointForce.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5959759_RigidBody_ForceRegionSpherePointForce.py @@ -47,8 +47,8 @@ def C5959759_RigidBody_ForceRegionSpherePointForce(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -157,5 +157,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5959759_RigidBody_ForceRegionSpherePointForce) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5959760_PhysXForceRegion_PointForceExertion.py b/AutomatedTesting/Gem/PythonTests/physics/C5959760_PhysXForceRegion_PointForceExertion.py index 42020c78b7..89eb1842be 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5959760_PhysXForceRegion_PointForceExertion.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5959760_PhysXForceRegion_PointForceExertion.py @@ -72,8 +72,8 @@ def C5959760_PhysXForceRegion_PointForceExertion(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -230,5 +230,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5959760_PhysXForceRegion_PointForceExertion) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5959761_ForceRegion_PhysAssetExertsPointForce.py b/AutomatedTesting/Gem/PythonTests/physics/C5959761_ForceRegion_PhysAssetExertsPointForce.py index af9af57363..ba0475266b 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5959761_ForceRegion_PhysAssetExertsPointForce.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5959761_ForceRegion_PhysAssetExertsPointForce.py @@ -76,8 +76,8 @@ def C5959761_ForceRegion_PhysAssetExertsPointForce(): import azlmbr.bus as bus import azlmbr.math - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper TIMEOUT = 2.0 @@ -147,5 +147,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5959761_ForceRegion_PhysAssetExertsPointForce) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5959763_ForceRegion_ForceRegionImpulsesCube.py b/AutomatedTesting/Gem/PythonTests/physics/C5959763_ForceRegion_ForceRegionImpulsesCube.py index 2b7bf49278..76130d25eb 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5959763_ForceRegion_ForceRegionImpulsesCube.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5959763_ForceRegion_ForceRegionImpulsesCube.py @@ -50,7 +50,8 @@ def C5959763_ForceRegion_ForceRegionImpulsesCube(): imports.init() - from utils import Report, TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -171,5 +172,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5959763_ForceRegion_ForceRegionImpulsesCube) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5959764_ForceRegion_ForceRegionImpulsesCapsule.py b/AutomatedTesting/Gem/PythonTests/physics/C5959764_ForceRegion_ForceRegionImpulsesCapsule.py index 02bba2f848..f314dae5b7 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5959764_ForceRegion_ForceRegionImpulsesCapsule.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5959764_ForceRegion_ForceRegionImpulsesCapsule.py @@ -50,7 +50,8 @@ def C5959764_ForceRegion_ForceRegionImpulsesCapsule(): imports.init() - from utils import Report, TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -173,5 +174,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5959764_ForceRegion_ForceRegionImpulsesCapsule) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5959765_ForceRegion_AssetGetsImpulsed.py b/AutomatedTesting/Gem/PythonTests/physics/C5959765_ForceRegion_AssetGetsImpulsed.py index 1afd7b4536..ddcba5996b 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5959765_ForceRegion_AssetGetsImpulsed.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5959765_ForceRegion_AssetGetsImpulsed.py @@ -53,7 +53,8 @@ def C5959765_ForceRegion_AssetGetsImpulsed(): imports.init() - from utils import Report, TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -175,5 +176,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5959765_ForceRegion_AssetGetsImpulsed) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5959808_ForceRegion_PositionOffset.py b/AutomatedTesting/Gem/PythonTests/physics/C5959808_ForceRegion_PositionOffset.py index f105c5642e..175f73a420 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5959808_ForceRegion_PositionOffset.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5959808_ForceRegion_PositionOffset.py @@ -133,8 +133,8 @@ def C5959808_ForceRegion_PositionOffset(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.math as azmath @@ -412,5 +412,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5959808_ForceRegion_PositionOffset) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5959809_ForceRegion_RotationalOffset.py b/AutomatedTesting/Gem/PythonTests/physics/C5959809_ForceRegion_RotationalOffset.py index f0379d20f7..1ad53194d3 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5959809_ForceRegion_RotationalOffset.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5959809_ForceRegion_RotationalOffset.py @@ -134,8 +134,8 @@ def C5959809_ForceRegion_RotationalOffset(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.math as azmath @@ -412,5 +412,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5959809_ForceRegion_RotationalOffset) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5959810_ForceRegion_ForceRegionCombinesForces.py b/AutomatedTesting/Gem/PythonTests/physics/C5959810_ForceRegion_ForceRegionCombinesForces.py index e09b58ecdc..212f7cc86b 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5959810_ForceRegion_ForceRegionCombinesForces.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5959810_ForceRegion_ForceRegionCombinesForces.py @@ -74,8 +74,8 @@ def C5959810_ForceRegion_ForceRegionCombinesForces(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -241,5 +241,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5959810_ForceRegion_ForceRegionCombinesForces) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5968759_ForceRegion_ExertsSeveralForcesOnRigidBody.py b/AutomatedTesting/Gem/PythonTests/physics/C5968759_ForceRegion_ExertsSeveralForcesOnRigidBody.py index 3bdb4410ea..4aa0fef642 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5968759_ForceRegion_ExertsSeveralForcesOnRigidBody.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5968759_ForceRegion_ExertsSeveralForcesOnRigidBody.py @@ -67,7 +67,8 @@ def C5968759_ForceRegion_ExertsSeveralForcesOnRigidBody(): import azlmbr.legacy.general as general import azlmbr.bus as bus import azlmbr.physics - from utils import Report, TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper # Constants TIME_OUT = 6.0 # Second to wait before timing out @@ -181,5 +182,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5968759_ForceRegion_ExertsSeveralForcesOnRigidBody) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5968760_ForceRegion_CheckNetForceChange.py b/AutomatedTesting/Gem/PythonTests/physics/C5968760_ForceRegion_CheckNetForceChange.py index 7c7c11f548..ba491c96a7 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5968760_ForceRegion_CheckNetForceChange.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5968760_ForceRegion_CheckNetForceChange.py @@ -70,9 +70,8 @@ def C5968760_ForceRegion_CheckNetForceChange(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -171,5 +170,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C5968760_ForceRegion_CheckNetForceChange) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6032082_Terrain_MultipleResolutionsValid.py b/AutomatedTesting/Gem/PythonTests/physics/C6032082_Terrain_MultipleResolutionsValid.py index d79954d26f..4543b0b8f6 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6032082_Terrain_MultipleResolutionsValid.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6032082_Terrain_MultipleResolutionsValid.py @@ -89,9 +89,8 @@ def C6032082_Terrain_MultipleResolutionsValid(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -217,5 +216,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C6032082_Terrain_MultipleResolutionsValid) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6090546_ForceRegion_SliceFileInstantiates.py b/AutomatedTesting/Gem/PythonTests/physics/C6090546_ForceRegion_SliceFileInstantiates.py index 825b8287d1..557b7e7ec5 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6090546_ForceRegion_SliceFileInstantiates.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6090546_ForceRegion_SliceFileInstantiates.py @@ -72,9 +72,8 @@ def C6090546_ForceRegion_SliceFileInstantiates(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -146,5 +145,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C6090546_ForceRegion_SliceFileInstantiates) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6090547_ForceRegion_ParentChildForceRegions.py b/AutomatedTesting/Gem/PythonTests/physics/C6090547_ForceRegion_ParentChildForceRegions.py index a62a673b9f..a07fd1861b 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6090547_ForceRegion_ParentChildForceRegions.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6090547_ForceRegion_ParentChildForceRegions.py @@ -81,13 +81,12 @@ def C6090547_ForceRegion_ParentChildForceRegions(): imports.init() - import azlmbr.legacy.general as general import azlmbr.bus import azlmbr.math as lymath - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper # Constants TIMEOUT = 3.0 @@ -207,5 +206,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C6090547_ForceRegion_ParentChildForceRegions) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6090550_ForceRegion_WorldSpaceForceNegative.py b/AutomatedTesting/Gem/PythonTests/physics/C6090550_ForceRegion_WorldSpaceForceNegative.py index c85dc6a273..f8da62ebac 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6090550_ForceRegion_WorldSpaceForceNegative.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6090550_ForceRegion_WorldSpaceForceNegative.py @@ -78,12 +78,11 @@ def C6090550_ForceRegion_WorldSpaceForceNegative(): imports.init() - import azlmbr.legacy.general as general import azlmbr.bus - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper helper.init_idle() @@ -251,5 +250,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C6090550_ForceRegion_WorldSpaceForceNegative) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6090551_ForceRegion_LocalSpaceForceNegative.py b/AutomatedTesting/Gem/PythonTests/physics/C6090551_ForceRegion_LocalSpaceForceNegative.py index 45f9b21522..0788b1da66 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6090551_ForceRegion_LocalSpaceForceNegative.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6090551_ForceRegion_LocalSpaceForceNegative.py @@ -78,12 +78,11 @@ def C6090551_ForceRegion_LocalSpaceForceNegative(): imports.init() - import azlmbr.legacy.general as general import azlmbr.bus - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper helper.init_idle() @@ -251,5 +250,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C6090551_ForceRegion_LocalSpaceForceNegative) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6090552_ForceRegion_LinearDampingNegative.py b/AutomatedTesting/Gem/PythonTests/physics/C6090552_ForceRegion_LinearDampingNegative.py index 5751f55b0c..a878819045 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6090552_ForceRegion_LinearDampingNegative.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6090552_ForceRegion_LinearDampingNegative.py @@ -77,12 +77,11 @@ def C6090552_ForceRegion_LinearDampingNegative(): imports.init() - import azlmbr.legacy.general as general import azlmbr.bus - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper helper.init_idle() @@ -250,5 +249,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C6090552_ForceRegion_LinearDampingNegative) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6090553_ForceRegion_SimpleDragForceOnRigidBodies.py b/AutomatedTesting/Gem/PythonTests/physics/C6090553_ForceRegion_SimpleDragForceOnRigidBodies.py index 3c995bca62..43c4335918 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6090553_ForceRegion_SimpleDragForceOnRigidBodies.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6090553_ForceRegion_SimpleDragForceOnRigidBodies.py @@ -72,12 +72,11 @@ def C6090553_ForceRegion_SimpleDragForceOnRigidBodies(): imports.init() - import azlmbr.legacy.general as general import azlmbr.bus - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper # Holds details about the ball class Ball: @@ -182,5 +181,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C6090553_ForceRegion_SimpleDragForceOnRigidBodies) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6090554_ForceRegion_PointForceNegative.py b/AutomatedTesting/Gem/PythonTests/physics/C6090554_ForceRegion_PointForceNegative.py index 0ea8ca2e4b..d7781b6040 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6090554_ForceRegion_PointForceNegative.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6090554_ForceRegion_PointForceNegative.py @@ -78,12 +78,11 @@ def C6090554_ForceRegion_PointForceNegative(): imports.init() - import azlmbr.legacy.general as general import azlmbr.bus - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper helper.init_idle() @@ -251,5 +250,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C6090554_ForceRegion_PointForceNegative) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6090555_ForceRegion_SplineFollowOnRigidBodies.py b/AutomatedTesting/Gem/PythonTests/physics/C6090555_ForceRegion_SplineFollowOnRigidBodies.py index dfa992bc21..b1b76d896d 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6090555_ForceRegion_SplineFollowOnRigidBodies.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6090555_ForceRegion_SplineFollowOnRigidBodies.py @@ -74,9 +74,8 @@ def C6090555_ForceRegion_SplineFollowOnRigidBodies(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr import azlmbr.legacy.general as general @@ -184,5 +183,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C6090555_ForceRegion_SplineFollowOnRigidBodies) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6131473_StaticSlice_OnDynamicSliceSpawn.py b/AutomatedTesting/Gem/PythonTests/physics/C6131473_StaticSlice_OnDynamicSliceSpawn.py index 5e475a4c4c..11281df4eb 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6131473_StaticSlice_OnDynamicSliceSpawn.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6131473_StaticSlice_OnDynamicSliceSpawn.py @@ -67,9 +67,8 @@ def C6131473_StaticSlice_OnDynamicSliceSpawn(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -111,5 +110,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C6131473_StaticSlice_OnDynamicSliceSpawn) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6224408_ScriptCanvas_EntitySpawn.py b/AutomatedTesting/Gem/PythonTests/physics/C6224408_ScriptCanvas_EntitySpawn.py index f88e07bf86..6501e11e68 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6224408_ScriptCanvas_EntitySpawn.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6224408_ScriptCanvas_EntitySpawn.py @@ -69,9 +69,8 @@ def C6224408_ScriptCanvas_EntitySpawn(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus @@ -152,5 +151,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C6224408_ScriptCanvas_EntitySpawn) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6274125_ScriptCanvas_TriggerEvents.py b/AutomatedTesting/Gem/PythonTests/physics/C6274125_ScriptCanvas_TriggerEvents.py index 64baa81140..44c8be9e1e 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6274125_ScriptCanvas_TriggerEvents.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6274125_ScriptCanvas_TriggerEvents.py @@ -75,12 +75,11 @@ def C6274125_ScriptCanvas_TriggerEvents(): imports.init() - import azlmbr.legacy.general as general import azlmbr.bus - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper helper.init_idle() @@ -136,5 +135,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C6274125_ScriptCanvas_TriggerEvents) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6321601_Force_HighValuesDirectionAxes.py b/AutomatedTesting/Gem/PythonTests/physics/C6321601_Force_HighValuesDirectionAxes.py index 2b0168a2fe..c1a51f2887 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6321601_Force_HighValuesDirectionAxes.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6321601_Force_HighValuesDirectionAxes.py @@ -99,10 +99,9 @@ def C6321601_Force_HighValuesDirectionAxes(): imports.init() - - from utils import Report - from utils import TestHelper as helper - from utils import Tracer + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper + from editor_python_test_tools.utils import Tracer import azlmbr.legacy.general as general import azlmbr.bus @@ -256,5 +255,5 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(C6321601_Force_HighValuesDirectionAxes) diff --git a/AutomatedTesting/Gem/PythonTests/physics/JointsHelper.py b/AutomatedTesting/Gem/PythonTests/physics/JointsHelper.py index db07f4e14a..e61118ef5b 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/JointsHelper.py +++ b/AutomatedTesting/Gem/PythonTests/physics/JointsHelper.py @@ -13,7 +13,7 @@ import ImportPathHelper as imports imports.init() -from utils import Report +from editor_python_test_tools.utils import Report import azlmbr.legacy.general as general import azlmbr.bus diff --git a/AutomatedTesting/Gem/PythonTests/physics/UtilTest_Managed_Files.py b/AutomatedTesting/Gem/PythonTests/physics/UtilTest_Managed_Files.py index 94c1335536..bc6697afaf 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/UtilTest_Managed_Files.py +++ b/AutomatedTesting/Gem/PythonTests/physics/UtilTest_Managed_Files.py @@ -22,8 +22,8 @@ def run(): imports.init() - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper helper.init_idle() Report.success(Tests.passed) diff --git a/AutomatedTesting/Gem/PythonTests/physics/UtilTest_Physmaterial_Editor.py b/AutomatedTesting/Gem/PythonTests/physics/UtilTest_Physmaterial_Editor.py index 666b4910a1..5f24f41083 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/UtilTest_Physmaterial_Editor.py +++ b/AutomatedTesting/Gem/PythonTests/physics/UtilTest_Physmaterial_Editor.py @@ -58,9 +58,8 @@ def run(): imports.init() - - from utils import Report - from utils import TestHelper as helper + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general from Physmaterial_Editor import Physmaterial_Editor diff --git a/AutomatedTesting/Gem/PythonTests/physics/UtilTest_Tracer_PicksErrorsAndWarnings.py b/AutomatedTesting/Gem/PythonTests/physics/UtilTest_Tracer_PicksErrorsAndWarnings.py index 0aeb8aa73a..fa904250ea 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/UtilTest_Tracer_PicksErrorsAndWarnings.py +++ b/AutomatedTesting/Gem/PythonTests/physics/UtilTest_Tracer_PicksErrorsAndWarnings.py @@ -39,12 +39,11 @@ def run(): imports.init() - import azlmbr.legacy.general as general - from utils import Report - from utils import TestHelper as helper - from utils import Tracer + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper + from editor_python_test_tools.utils import Tracer helper.init_idle() diff --git a/AutomatedTesting/Gem/PythonTests/scripting/Docking_Pane.py b/AutomatedTesting/Gem/PythonTests/scripting/Docking_Pane.py index 3b54c0de72..25dd83e5e2 100755 --- a/AutomatedTesting/Gem/PythonTests/scripting/Docking_Pane.py +++ b/AutomatedTesting/Gem/PythonTests/scripting/Docking_Pane.py @@ -51,9 +51,9 @@ def Docking_Pane(): imports.init() - from utils import Report - from utils import TestHelper as helper - import pyside_utils + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper + import editor_python_test_tools.pyside_utils as pyside_utils # Open 3D Engine imports import azlmbr.legacy.general as general @@ -114,6 +114,6 @@ if __name__ == "__main__": imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(Docking_Pane) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/Opening_Closing_Pane.py b/AutomatedTesting/Gem/PythonTests/scripting/Opening_Closing_Pane.py index 4ea4d791dd..6100285092 100755 --- a/AutomatedTesting/Gem/PythonTests/scripting/Opening_Closing_Pane.py +++ b/AutomatedTesting/Gem/PythonTests/scripting/Opening_Closing_Pane.py @@ -54,9 +54,9 @@ def Opening_Closing_Pane(): imports.init() - from utils import Report - from utils import TestHelper as helper - import pyside_utils + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper + import editor_python_test_tools.pyside_utils as pyside_utils # Open 3D Engine Imports import azlmbr.legacy.general as general @@ -123,6 +123,6 @@ if __name__ == "__main__": imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(Opening_Closing_Pane) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/Resizing_Pane.py b/AutomatedTesting/Gem/PythonTests/scripting/Resizing_Pane.py index 216ef4fb7d..9262e76cb0 100755 --- a/AutomatedTesting/Gem/PythonTests/scripting/Resizing_Pane.py +++ b/AutomatedTesting/Gem/PythonTests/scripting/Resizing_Pane.py @@ -51,9 +51,9 @@ def Resizing_Pane(): imports.init() - from utils import Report - from utils import TestHelper as helper - import pyside_utils + from editor_python_test_tools.utils import Report + from editor_python_test_tools.utils import TestHelper as helper + import editor_python_test_tools.pyside_utils as pyside_utils # Open 3D Engine imports import azlmbr.legacy.general as general @@ -115,6 +115,6 @@ if __name__ == "__main__": import ImportPathHelper as imports imports.init() - from utils import Report + from editor_python_test_tools.utils import Report Report.start_test(Resizing_Pane) diff --git a/Code/CryEngine/CryCommon/LyShine/IDraw2d.h b/Code/CryEngine/CryCommon/LyShine/IDraw2d.h index e71c8421d3..16fdfceca3 100644 --- a/Code/CryEngine/CryCommon/LyShine/IDraw2d.h +++ b/Code/CryEngine/CryCommon/LyShine/IDraw2d.h @@ -11,7 +11,7 @@ */ #pragma once -#include +#include #include #include #include @@ -115,355 +115,4 @@ public: // member functions //! Implement virtual destructor just for safety. virtual ~IDraw2d() {} - - //! Start a section of 2D drawing function calls. This will set appropriate render state. - // - //! \param deferCalls If true then actual render calls are deferred until the end of the frame - virtual void BeginDraw2d(bool deferCalls = false) = 0; - - //! Start a section of 2D drawing function calls. This will set appropriate render state. - //! This variant allows the viewport size to be specified - // - //! \param viewportSize The size of the viewport being rendered to - //! \param deferCalls If true then actual render calls are deferred until the end of the frame - virtual void BeginDraw2d(AZ::Vector2 viewportSize, bool deferCalls = false) = 0; - - //! End a section of 2D drawing function calls. This will reset some render state. - virtual void EndDraw2d() = 0; - - //! Draw a textured quad with the top left corner at the given position. - // - //! The image is drawn with the color specified by SetShapeColor and the opacity - //! passed as an argument. - //! If rotation is non-zero then the quad is rotated. If the pivot point is - //! provided then the points of the quad are rotated about that point, otherwise - //! they are rotated about the top left corner of the quad. - //! \param texId The texture ID returned by ITexture::GetTextureID() - //! \param position Position of the top left corner of the quad (before rotation) in pixels - //! \param size The width and height of the quad. Use texture width and height to avoid minification, - //! magnification or stretching (assuming the minMaxTexCoords are left to the default) - //! \param opacity The alpha value used when blending - //! \param rotation Angle of rotation in degrees counter-clockwise - //! \param pivotPoint The point about which the quad is rotated - //! \param minMaxTexCoords An optional two component array. The first component is the UV coord for the top left - //! point of the quad and the second is the UV coord of the bottom right point of the quad - //! \param imageOptions Optional struct specifying options that tend to be the same from call to call - virtual void DrawImage(int texId, AZ::Vector2 position, AZ::Vector2 size, float opacity = 1.0f, - float rotation = 0.0f, const AZ::Vector2* pivotPoint = nullptr, const AZ::Vector2* minMaxTexCoords = nullptr, - ImageOptions* imageOptions = nullptr) = 0; - - //! Draw a textured quad where the position specifies the point specified by the alignment. - // - //! Rotation is always around the position. - //! \param texId The texture ID returned by ITexture::GetTextureID() - //! \param position Position align point of the quad (before rotation) in pixels - //! \param size The width and height of the quad. Use texture width and height to avoid minification, - //! magnification or stretching (assuming the minMaxTexCoords are left to the default) - //! \param horizontalAlignment Specifies how the quad is horizontally aligned to the given position - //! \param verticalAlignment Specifies how the quad is vertically aligned to the given position - //! \param opacity The alpha value used when blending - //! \param rotation Angle of rotation in degrees counter-clockwise - //! \param minMaxTexCoords An optional two component array. The first component is the UV coord for the top left - //! point of the quad and the second is the UV coord of the bottom right point of the quad - //! \param imageOptions Optional struct specifying options that tend to be the same from call to call - virtual void DrawImageAligned(int texId, AZ::Vector2 position, AZ::Vector2 size, - HAlign horizontalAlignment, VAlign verticalAlignment, - float opacity = 1.0f, float rotation = 0.0f, const AZ::Vector2* minMaxTexCoords = nullptr, - ImageOptions* imageOptions = nullptr) = 0; - - //! Draw a textured quad where the position, color and uv of each point is specified explicitly - // - //! \param texId The texture ID returned by ITexture::GetTextureID() - //! \param verts An array of 4 vertices, in clockwise order (e.g. top left, top right, bottom right, bottom left) - //! \param blendMode UseDefault means default blend mode (currently GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA) - //! \param pixelRounding Whether and how to round pixel coordinates - //! \param baseState Additional render state to pass to or into value passed to renderer SetState - virtual void DrawQuad(int texId, VertexPosColUV* verts, - int blendMode = UseDefault, - Rounding pixelRounding = Rounding::Nearest, - int baseState = UseDefault) = 0; - - //! Draw a line - // - //! \param start The start position - //! \param end The end position - //! \param color The color of the line - //! \param blendMode UseDefault means default blend mode (currently GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA) - //! \param pixelRounding Whether and how to round pixel coordinates - //! \param baseState Additional render state to pass to or into value passed to renderer SetState - virtual void DrawLine(AZ::Vector2 start, AZ::Vector2 end, AZ::Color color, - int blendMode = UseDefault, - IDraw2d::Rounding pixelRounding = IDraw2d::Rounding::Nearest, - int baseState = UseDefault) = 0; - - //! Draw a line with a texture so it can be dotted or dashed - // - //! \param texId The texture ID returned by ITexture::GetTextureID() - //! \param verts An array of 2 vertices for the start and end points of the line - //! \param blendMode UseDefault means default blend mode (currently GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA) - //! \param pixelRounding Whether and how to round pixel coordinates - //! \param baseState Additional render state to pass to or into value passed to renderer SetState - virtual void DrawLineTextured(int texId, VertexPosColUV* verts, - int blendMode = UseDefault, - IDraw2d::Rounding pixelRounding = IDraw2d::Rounding::Nearest, - int baseState = UseDefault) = 0; - - //! Draw a text string. Only supports ASCII text. - // - //! The font and effect used to render the text are specified in the textOptions structure - //! \param textString A null terminated ASCII text string. May contain \n characters - //! \param position Position of the text in pixels. Alignment values in textOptions affect actual position - //! \param pointSize The size of the font to use - //! \param opacity The opacity (alpha value) to use to draw the text - //! \param textOptions Pointer to an options struct. If null the default options are used - virtual void DrawText(const char* textString, AZ::Vector2 position, float pointSize, - float opacity = 1.0f, TextOptions* textOptions = nullptr) = 0; - - //! Get the width and height (in pixels) that would be used to draw the given text string. - // - //! Pass the same parameter values that would be used to draw the string - virtual AZ::Vector2 GetTextSize(const char* textString, float pointSize, TextOptions* textOptions = nullptr) = 0; - - //! Get the width of the rendering viewport (in pixels). - // - //! If rendering full screen this is the native width from IRenderer - virtual float GetViewportWidth() const = 0; - - //! Get the height of the rendering viewport (in pixels). - // - //! If rendering full screen this is the native width from IRenderer - virtual float GetViewportHeight() const = 0; - - //! Get the default values that would be used if no image options were passed in - // - //! This is a convenient way to initialize the imageOptions struct - virtual const ImageOptions& GetDefaultImageOptions() const = 0; - - //! Get the default values that would be used if no text options were passed in - // - //! This is a convenient way to initialize the textOptions struct - virtual const TextOptions& GetDefaultTextOptions() const = 0; -}; - -//////////////////////////////////////////////////////////////////////////////////////////////////// -//! Helper class for using the IDraw2d interface -//! -//! The Draw2dHelper class is an inline wrapper that provides two convenience features: -//! 1. It automatically calls BeginDraw2d/EndDraw2d in its construction/destruction. -//! 2. It automatically sets member options structures to their defaults and provides set functions -//! to set them. -class Draw2dHelper -{ -public: // member functions - - //! Start a section of 2D drawing function calls. This will set appropriate render state. - Draw2dHelper(bool deferCalls = false) - : m_draw2d(GetDraw2d()) - { - if (m_draw2d) - { - m_draw2d->BeginDraw2d(deferCalls); - m_imageOptions = m_draw2d->GetDefaultImageOptions(); - m_textOptions = m_draw2d->GetDefaultTextOptions(); - } - } - - //! End a section of 2D drawing function calls. This will reset some render state. - ~Draw2dHelper() - { - if (m_draw2d) - { - m_draw2d->EndDraw2d(); - } - } - - //! Draw a textured quad, optional rotation is counter-clockwise in degrees. - // - //! See IDraw2d:DrawImage for parameter descriptions - void DrawImage(int texId, AZ::Vector2 position, AZ::Vector2 size, float opacity = 1.0f, - float rotation = 0.0f, const AZ::Vector2* pivotPoint = nullptr, const AZ::Vector2* minMaxTexCoords = nullptr) - { - if (m_draw2d) - { - m_draw2d->DrawImage(texId, position, size, opacity, rotation, pivotPoint, minMaxTexCoords, &m_imageOptions); - } - } - - //! Draw a textured quad where the position specifies the point specified by the alignment. - // - //! See IDraw2d:DrawImageAligned for parameter descriptions - void DrawImageAligned(int texId, AZ::Vector2 position, AZ::Vector2 size, - IDraw2d::HAlign horizontalAlignment, IDraw2d::VAlign verticalAlignment, - float opacity = 1.0f, float rotation = 0.0f, const AZ::Vector2* minMaxTexCoords = nullptr) - { - if (m_draw2d) - { - m_draw2d->DrawImageAligned(texId, position, size, horizontalAlignment, verticalAlignment, - opacity, rotation, minMaxTexCoords, &m_imageOptions); - } - } - - //! Draw a textured quad where the position, color and uv of each point is specified explicitly - // - //! See IDraw2d:DrawQuad for parameter descriptions - void DrawQuad(int texId, IDraw2d::VertexPosColUV* verts, int blendMode = IDraw2d::UseDefault, - IDraw2d::Rounding pixelRounding = IDraw2d::Rounding::Nearest, - int baseState = IDraw2d::UseDefault) - { - if (m_draw2d) - { - m_draw2d->DrawQuad(texId, verts, blendMode, pixelRounding, baseState); - } - } - - //! Draw a line - // - //! See IDraw2d:DrawLine for parameter descriptions - void DrawLine(AZ::Vector2 start, AZ::Vector2 end, AZ::Color color, int blendMode = IDraw2d::UseDefault, - IDraw2d::Rounding pixelRounding = IDraw2d::Rounding::Nearest, - int baseState = IDraw2d::UseDefault) - { - if (m_draw2d) - { - m_draw2d->DrawLine(start, end, color, blendMode, pixelRounding, baseState); - } - } - - //! Draw a line with a texture so it can be dotted or dashed - // - //! See IDraw2d:DrawLineTextured for parameter descriptions - void DrawLineTextured(int texId, IDraw2d::VertexPosColUV* verts, int blendMode = IDraw2d::UseDefault, - IDraw2d::Rounding pixelRounding = IDraw2d::Rounding::Nearest, - int baseState = IDraw2d::UseDefault) - { - if (m_draw2d) - { - m_draw2d->DrawLineTextured(texId, verts, blendMode, pixelRounding, baseState); - } - } - - //! Draw a text string. Only supports ASCII text. - // - //! See IDraw2d:DrawText for parameter descriptions - void DrawText(const char* textString, AZ::Vector2 position, float pointSize, float opacity = 1.0f) - { - if (m_draw2d) - { - m_draw2d->DrawText(textString, position, pointSize, opacity, &m_textOptions); - } - } - - //! Get the width and height (in pixels) that would be used to draw the given text string. - // - //! See IDraw2d:GetTextSize for parameter descriptions - AZ::Vector2 GetTextSize(const char* textString, float pointSize) - { - if (m_draw2d) - { - return m_draw2d->GetTextSize(textString, pointSize, &m_textOptions); - } - else - { - return AZ::Vector2(0, 0); - } - } - - // State management - - //! Set the blend mode used for images, default is GS_BLSRC_SRCALPHA|GS_BLDST_ONEMINUSSRCALPHA. - void SetImageBlendMode(int mode) { m_imageOptions.blendMode = mode; } - - //! Set the color used for DrawImage and other image drawing. - void SetImageColor(AZ::Vector3 color) { m_imageOptions.color = color; } - - //! Set whether images are rounded to have the points on exact pixel boundaries. - void SetImagePixelRounding(IDraw2d::Rounding round) { m_imageOptions.pixelRounding = round; } - - //! Set the base state (that blend mode etc is combined with) used for images, default is GS_NODEPTHTEST. - void SetImageBaseState(int state) { m_imageOptions.baseState = state; } - - //! Set the text font. - void SetTextFont(IFFont* font) { m_textOptions.font = font; } - - //! Set the text font effect index. - void SetTextEffectIndex(unsigned int effectIndex) { m_textOptions.effectIndex = effectIndex; } - - //! Set the text color. - void SetTextColor(AZ::Vector3 color) { m_textOptions.color = color; } - - //! Set the text alignment. - void SetTextAlignment(IDraw2d::HAlign horizontalAlignment, IDraw2d::VAlign verticalAlignment) - { - m_textOptions.horizontalAlignment = horizontalAlignment; - m_textOptions.verticalAlignment = verticalAlignment; - } - - //! Set a drop shadow for text drawing. An alpha of zero disables drop shadow. - void SetTextDropShadow(AZ::Vector2 offset, AZ::Color color) - { - m_textOptions.dropShadowOffset = offset; - m_textOptions.dropShadowColor = color; - } - - //! Set a rotation for the text. The text rotates around its position (taking into account alignment). - void SetTextRotation(float rotation) - { - m_textOptions.rotation = rotation; - } - - //! Set the base state (that blend mode etc is combined with) used for text, default is GS_NODEPTHTEST. - void SetTextBaseState(int state) { m_textOptions.baseState = state; } - -public: // static member functions - - //! Helper to get the IDraw2d interface - static IDraw2d* GetDraw2d() { return (gEnv && gEnv->pLyShine) ? gEnv->pLyShine->GetDraw2d() : nullptr; } - - //! Get the width of the rendering viewport (in pixels). - static float GetViewportWidth() - { - IDraw2d* draw2d = GetDraw2d(); - return (draw2d) ? draw2d->GetViewportWidth() : 0.0f; - } - - //! Get the height of the rendering viewport (in pixels). - static float GetViewportHeight() - { - IDraw2d* draw2d = GetDraw2d(); - return (draw2d) ? draw2d->GetViewportHeight() : 0.0f; - } - - //! Round the X and Y coordinates of a point using the given rounding policy - template - static T RoundXY(T value, IDraw2d::Rounding roundingType) - { - T result = value; - - switch (roundingType) - { - case IDraw2d::Rounding::None: - // nothing to do - break; - case IDraw2d::Rounding::Nearest: - result.SetX(floor(value.GetX() + 0.5f)); - result.SetY(floor(value.GetY() + 0.5f)); - break; - case IDraw2d::Rounding::Down: - result.SetX(floor(value.GetX())); - result.SetY(floor(value.GetY())); - break; - case IDraw2d::Rounding::Up: - result.SetX(ceil(value.GetX())); - result.SetY(ceil(value.GetY())); - break; - } - - return result; - } - -protected: // attributes - - IDraw2d::ImageOptions m_imageOptions; //!< image options are stored locally and updated by member functions - IDraw2d::TextOptions m_textOptions; //!< text options are stored locally and updated by member functions - IDraw2d* m_draw2d; }; diff --git a/Code/CryEngine/CryCommon/LyShine/IUiRenderer.h b/Code/CryEngine/CryCommon/LyShine/IUiRenderer.h deleted file mode 100644 index 797ea51b87..0000000000 --- a/Code/CryEngine/CryCommon/LyShine/IUiRenderer.h +++ /dev/null @@ -1,79 +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. -* -*/ -#pragma once - -#include - -//////////////////////////////////////////////////////////////////////////////////////////////////// -//! Interface used by UI components to render to the canvas -// -//! The IUiRenderer provides helper functions for UI rendering and also manages state that -//! persists between UI elements when rendering a UI canvas. -//! For example one UI component can turn on stencil test and that affects all UI rendering -//! until it is turned off. -//! -//! This is a singleton class that is accessed via IUiRenderer::Get() which is a shortcut for -//! gEnv->pLyShine()->GetUiRenderer(); -class IUiRenderer -{ -public: // types - - -public: // member functions - - //! Implement virtual destructor for safety. - virtual ~IUiRenderer() {} - - //! Start the rendering of a UI canvas - virtual void BeginCanvasRender(AZ::Vector2 viewportSize) = 0; - - //! End the rendering of a UI canvas - virtual void EndCanvasRender() = 0; - - //! Get the current base state - virtual int GetBaseState() = 0; - - //! Set the base state - virtual void SetBaseState(int state) = 0; - - //! Get the current stencil test reference value - virtual uint32 GetStencilRef() = 0; - - //! Set the stencil test reference value - virtual void SetStencilRef(uint32) = 0; - - //! Increment the current stencil reference value - virtual void IncrementStencilRef() = 0; - - //! Decrement the current stencil reference value - virtual void DecrementStencilRef() = 0; - - //! Get flag that indicates we are rendering into a mask. Used to avoid masks on child mask elements. - virtual bool IsRenderingToMask() = 0; - - //! Set flag that we are rendering into a mask. Used to avoid masks on child mask elements. - virtual void SetIsRenderingToMask(bool isRenderingToMask) = 0; - - //! Push an alpha fade, this is multiplied with any existing alpha fade from parents - virtual void PushAlphaFade(float alphaFadeValue) = 0; - - //! Pop an alpha fade off the stack - virtual void PopAlphaFade() = 0; - - //! Get the current alpha fade value - virtual float GetAlphaFade() const = 0; - -public: // static member functions - - //! Helper function to get the singleton UiRenderer - static IUiRenderer* Get() { return gEnv->pLyShine->GetUiRenderer(); } -}; diff --git a/Code/CryEngine/CryCommon/LyShine/UiSerializeHelpers.h b/Code/CryEngine/CryCommon/LyShine/UiSerializeHelpers.h index 131671e2a5..91b5cc294c 100644 --- a/Code/CryEngine/CryCommon/LyShine/UiSerializeHelpers.h +++ b/Code/CryEngine/CryCommon/LyShine/UiSerializeHelpers.h @@ -20,6 +20,7 @@ #include #include +#include //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Code/CryEngine/CrySystem/SystemInit.cpp b/Code/CryEngine/CrySystem/SystemInit.cpp index 5e43d6a1df..77d4039052 100644 --- a/Code/CryEngine/CrySystem/SystemInit.cpp +++ b/Code/CryEngine/CrySystem/SystemInit.cpp @@ -4094,6 +4094,7 @@ void CSystem::CreateSystemVars() "0 = Suppress Asserts\n" "1 = Log Asserts\n" "2 = Show Assert Dialog\n" + "3 = Crashes the Application on Assert\n" "Note: when set to '0 = Suppress Asserts', assert expressions are still evaluated. To turn asserts into a no-op, undefine AZ_ENABLE_TRACING and recompile.", OnAssertLevelCvarChanged); CSystem::SetAssertLevel(defaultAssertValue); diff --git a/Code/Framework/AzCore/AzCore/Debug/AssetTracking.cpp b/Code/Framework/AzCore/AzCore/Debug/AssetTracking.cpp index 787dcff22d..f238b8a74a 100644 --- a/Code/Framework/AzCore/AzCore/Debug/AssetTracking.cpp +++ b/Code/Framework/AzCore/AzCore/Debug/AssetTracking.cpp @@ -63,13 +63,13 @@ namespace AZ static AssetTrackingImpl* GetSharedInstance(); static ThreadData& GetSharedThreadData(); - using MasterAssets = AZStd::unordered_map, AZStd::equal_to, AZStdAssetTrackingAllocator>; + using PrimaryAssets = AZStd::unordered_map, AZStd::equal_to, AZStdAssetTrackingAllocator>; using ThreadData = ThreadData; using mutex_type = AZStd::mutex; using lock_type = AZStd::lock_guard; mutex_type m_mutex; - MasterAssets m_masterAssets; + PrimaryAssets m_primaryAssets; AssetTreeNodeBase* m_assetRoot = nullptr; AssetAllocationTableBase* m_allocationTable = nullptr; bool m_performingAnalysis = false; @@ -118,7 +118,7 @@ namespace AZ auto& threadData = GetSharedThreadData(); AssetTreeNodeBase* parentAsset = threadData.m_currentAssetStack.empty() ? nullptr : threadData.m_currentAssetStack.back(); AssetTreeNodeBase* childAsset; - AssetMasterInfo* assetMasterInfo; + AssetPrimaryInfo* assetPrimaryInfo; if (!parentAsset) { @@ -128,22 +128,22 @@ namespace AZ { lock_type lock(m_mutex); - // Locate or create the master record for this asset - auto masterItr = m_masterAssets.find(assetId); + // Locate or create the primary record for this asset + auto primaryItr = m_primaryAssets.find(assetId); - if (masterItr != m_masterAssets.end()) + if (primaryItr != m_primaryAssets.end()) { - assetMasterInfo = &masterItr->second; + assetPrimaryInfo = &primaryItr->second; } else { - auto insertResult = m_masterAssets.emplace(assetId, AssetMasterInfo()); - assetMasterInfo = &insertResult.first->second; - assetMasterInfo->m_id = &insertResult.first->first; + auto insertResult = m_primaryAssets.emplace(assetId, AssetPrimaryInfo()); + assetPrimaryInfo = &insertResult.first->second; + assetPrimaryInfo->m_id = &insertResult.first->first; } // Add this asset to the stack for this thread's context - childAsset = parentAsset->FindOrAddChild(assetId, assetMasterInfo); + childAsset = parentAsset->FindOrAddChild(assetId, assetPrimaryInfo); } threadData.m_currentAssetStack.push_back(childAsset); @@ -304,7 +304,7 @@ namespace AZ char* pos = buffer; for (auto itr = assetStack.rbegin(); itr != assetStack.rend(); ++itr) { - pos += azsnprintf(pos, BUFFER_SIZE - (pos - buffer), "%s\n", (*itr)->GetAssetMasterInfo()->m_id->m_id.c_str()); + pos += azsnprintf(pos, BUFFER_SIZE - (pos - buffer), "%s\n", (*itr)->GetAssetPrimaryInfo()->m_id->m_id.c_str()); if (pos >= buffer + BUFFER_SIZE) { diff --git a/Code/Framework/AzCore/AzCore/Debug/AssetTrackingTypes.h b/Code/Framework/AzCore/AzCore/Debug/AssetTrackingTypes.h index e5be75c7d3..00b82d09ef 100644 --- a/Code/Framework/AzCore/AzCore/Debug/AssetTrackingTypes.h +++ b/Code/Framework/AzCore/AzCore/Debug/AssetTrackingTypes.h @@ -79,9 +79,9 @@ namespace AZ AssetTrackingString m_id; }; - // Master information about an asset. + // Primary information about an asset. // Currently just contains the ID of the asset, but in the future may carry additional information about that asset (such as where in code it was initialized). - struct AssetMasterInfo + struct AssetPrimaryInfo { const AssetTrackingId* m_id; }; @@ -90,8 +90,8 @@ namespace AZ class AssetTreeNodeBase { public: - virtual const AssetMasterInfo* GetAssetMasterInfo() const = 0; - virtual AssetTreeNodeBase* FindOrAddChild(const AssetTrackingId& id, const AssetMasterInfo* info) = 0; + virtual const AssetPrimaryInfo* GetAssetPrimaryInfo() const = 0; + virtual AssetTreeNodeBase* FindOrAddChild(const AssetTrackingId& id, const AssetPrimaryInfo* info) = 0; }; // Base class for an asset tree. Implemented by the template AssetTree<>. diff --git a/Code/Framework/AzCore/AzCore/Debug/AssetTrackingTypesImpl.h b/Code/Framework/AzCore/AzCore/Debug/AssetTrackingTypesImpl.h index 91f0a0ef21..711c0cf4eb 100644 --- a/Code/Framework/AzCore/AzCore/Debug/AssetTrackingTypesImpl.h +++ b/Code/Framework/AzCore/AzCore/Debug/AssetTrackingTypesImpl.h @@ -29,18 +29,18 @@ namespace AZ class AssetTreeNode : public AssetTreeNodeBase { public: - AssetTreeNode(const AssetMasterInfo* masterInfo = nullptr, AssetTreeNode* parent = nullptr) : - m_masterInfo(masterInfo), + AssetTreeNode(const AssetPrimaryInfo* primaryInfo = nullptr, AssetTreeNode* parent = nullptr) : + m_primaryinfo(primaryInfo), m_parent(parent) { } - const AssetMasterInfo* GetAssetMasterInfo() const override + const AssetPrimaryInfo* GetAssetPrimaryInfo() const override { - return m_masterInfo; + return m_primaryinfo; } - AssetTreeNodeBase* FindOrAddChild(const AssetTrackingId& id, const AssetMasterInfo* info) override + AssetTreeNodeBase* FindOrAddChild(const AssetTrackingId& id, const AssetPrimaryInfo* info) override { AssetTreeNodeBase* result = nullptr; auto childItr = m_children.find(id); @@ -61,7 +61,7 @@ namespace AZ using AssetMap = AssetTrackingMap; - const AssetMasterInfo* m_masterInfo; + const AssetPrimaryInfo* m_primaryinfo; AssetTreeNode* m_parent; AssetMap m_children; AssetDataT m_data; diff --git a/Code/Framework/AzCore/AzCore/Debug/Trace.cpp b/Code/Framework/AzCore/AzCore/Debug/Trace.cpp index 18db84e326..635db26465 100644 --- a/Code/Framework/AzCore/AzCore/Debug/Trace.cpp +++ b/Code/Framework/AzCore/AzCore/Debug/Trace.cpp @@ -70,6 +70,7 @@ namespace AZ static const char* logVerbosityUID = "sys_LogLevel"; static const int assertLevel_log = 1; static const int assertLevel_nativeUI = 2; + static const int assertLevel_crash = 3; static const int logLevel_errorWarning = 1; static const int logLevel_full = 2; static AZ::EnvironmentVariable> g_ignoredAsserts; @@ -289,8 +290,8 @@ namespace AZ } #if AZ_ENABLE_TRACE_ASSERTS - //display native UI dialogs at verbosity level 2 or higher - if (currentLevel >= assertLevel_nativeUI) + //display native UI dialogs at verbosity level 2 + if (currentLevel == assertLevel_nativeUI) { AZ::NativeUI::AssertAction buttonResult; EBUS_EVENT_RESULT(buttonResult, AZ::NativeUI::NativeUIRequestBus, DisplayAssertDialog, dialogBoxText); @@ -314,7 +315,13 @@ namespace AZ break; } } + else #endif //AZ_ENABLE_TRACE_ASSERTS + // Crash the application directly at assert level 3 + if (currentLevel >= assertLevel_crash) + { + AZ_Crash(); + } } g_alreadyHandlingAssertOrFatal = false; } diff --git a/Code/Framework/AzCore/AzCore/Math/Aabb.cpp b/Code/Framework/AzCore/AzCore/Math/Aabb.cpp index 94e138d88d..3f7cb4ecf5 100644 --- a/Code/Framework/AzCore/AzCore/Math/Aabb.cpp +++ b/Code/Framework/AzCore/AzCore/Math/Aabb.cpp @@ -146,8 +146,8 @@ namespace AZ ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) ->Method("GetTranslated", &Aabb::GetTranslated) ->Method("GetSurfaceArea", &Aabb::GetSurfaceArea) - ->Method("GetTransformedObb", &Aabb::GetTransformedObb) - ->Method("GetTransformedAabb", &Aabb::GetTransformedAabb) + ->Method("GetTransformedObb", static_cast(&Aabb::GetTransformedObb)) + ->Method("GetTransformedAabb", static_cast(&Aabb::GetTransformedAabb)) ->Method("ApplyTransform", &Aabb::ApplyTransform) ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) ->Method("Clone", [](const Aabb& rhs) -> Aabb { return rhs; }) @@ -195,6 +195,20 @@ namespace AZ } + Obb Aabb::GetTransformedObb(const Matrix3x4& matrix3x4) const + { + Matrix3x4 matrixNoScale = matrix3x4; + const AZ::Vector3 scale = matrixNoScale.ExtractScale(); + const AZ::Quaternion rotation = AZ::Quaternion::CreateFromMatrix3x4(matrixNoScale); + + return Obb::CreateFromPositionRotationAndHalfLengths( + matrix3x4 * GetCenter(), + rotation, + 0.5f * scale * GetExtents() + ); + } + + void Aabb::ApplyTransform(const Transform& transform) { Vector3 a, b, axisCoeffs; @@ -224,4 +238,17 @@ namespace AZ m_min = newMin; m_max = newMax; } + + + void Aabb::ApplyMatrix3x4(const Matrix3x4& matrix3x4) + { + const AZ::Vector3 extents = GetExtents(); + const AZ::Vector3 center = matrix3x4 * GetCenter(); + AZ::Vector3 newHalfExtents( + 0.5f * matrix3x4.GetRowAsVector3(0).GetAbs().Dot(extents), + 0.5f * matrix3x4.GetRowAsVector3(1).GetAbs().Dot(extents), + 0.5f * matrix3x4.GetRowAsVector3(2).GetAbs().Dot(extents)); + m_min = center - newHalfExtents; + m_max = center + newHalfExtents; + } } diff --git a/Code/Framework/AzCore/AzCore/Math/Aabb.h b/Code/Framework/AzCore/AzCore/Math/Aabb.h index 0aebd099f4..ef7704533e 100644 --- a/Code/Framework/AzCore/AzCore/Math/Aabb.h +++ b/Code/Framework/AzCore/AzCore/Math/Aabb.h @@ -129,11 +129,21 @@ namespace AZ void ApplyTransform(const Transform& transform); + void ApplyMatrix3x4(const Matrix3x4& matrix3x4); + + void MultiplyByScale(const Vector3& scale); + + //! Transforms an Aabb and returns the resulting Obb. + [[nodiscard]] Obb GetTransformedObb(const Transform& transform) const; + //! Transforms an Aabb and returns the resulting Obb. - class Obb GetTransformedObb(const Transform& transform) const; + [[nodiscard]] Obb GetTransformedObb(const Matrix3x4& matrix3x4) const; + + //! Returns a new AABB containing the transformed AABB. + [[nodiscard]] Aabb GetTransformedAabb(const Transform& transform) const; //! Returns a new AABB containing the transformed AABB. - Aabb GetTransformedAabb(const Transform& transform) const; + [[nodiscard]] Aabb GetTransformedAabb(const Matrix3x4& matrix3x4) const; //! Checks if this aabb is equal to another within a floating point tolerance. bool IsClose(const Aabb& rhs, float tolerance = Constants::Tolerance) const; diff --git a/Code/Framework/AzCore/AzCore/Math/Aabb.inl b/Code/Framework/AzCore/AzCore/Math/Aabb.inl index 5e6a5ae188..13549a30f6 100644 --- a/Code/Framework/AzCore/AzCore/Math/Aabb.inl +++ b/Code/Framework/AzCore/AzCore/Math/Aabb.inl @@ -292,6 +292,14 @@ namespace AZ } + AZ_MATH_INLINE void Aabb::MultiplyByScale(const Vector3& scale) + { + m_min *= scale; + m_max *= scale; + AZ_MATH_ASSERT(IsValid(), "Min must be less than Max"); + } + + AZ_MATH_INLINE Aabb Aabb::GetTransformedAabb(const Transform& transform) const { Aabb aabb = Aabb::CreateFromMinMax(m_min, m_max); @@ -300,6 +308,14 @@ namespace AZ } + AZ_MATH_INLINE Aabb Aabb::GetTransformedAabb(const Matrix3x4& matrix3x4) const + { + Aabb aabb = Aabb::CreateFromMinMax(m_min, m_max); + aabb.ApplyMatrix3x4(matrix3x4); + return aabb; + } + + AZ_MATH_INLINE bool Aabb::IsClose(const Aabb& rhs, float tolerance) const { return m_min.IsClose(rhs.m_min, tolerance) && m_max.IsClose(rhs.m_max, tolerance); diff --git a/Code/Framework/AzCore/Tests/Debug/AssetTracking.cpp b/Code/Framework/AzCore/Tests/Debug/AssetTracking.cpp index a4a152a4f6..92d02a2706 100644 --- a/Code/Framework/AzCore/Tests/Debug/AssetTracking.cpp +++ b/Code/Framework/AzCore/Tests/Debug/AssetTracking.cpp @@ -105,7 +105,7 @@ namespace UnitTest EXPECT_EQ(&rootAsset, &m_env->m_tree.GetRoot()); ASSERT_NE(itr, rootAsset.m_children.end()); - EXPECT_EQ(itr->second.m_masterInfo->m_id->m_id, "TestScopedAllocation.1"); + EXPECT_EQ(itr->second.m_primaryinfo->m_id->m_id, "TestScopedAllocation.1"); EXPECT_EQ(&itr->second, m_env->m_table.FindAllocation(TEST_POINTER)); diff --git a/Code/Framework/AzCore/Tests/Math/AabbTests.cpp b/Code/Framework/AzCore/Tests/Math/AabbTests.cpp index 20a4d2ed85..44cc800616 100644 --- a/Code/Framework/AzCore/Tests/Math/AabbTests.cpp +++ b/Code/Framework/AzCore/Tests/Math/AabbTests.cpp @@ -15,6 +15,7 @@ #include #include #include +#include using namespace AZ; @@ -385,4 +386,77 @@ namespace UnitTest EXPECT_TRUE(aabb.GetMin().IsClose(transAabb.GetMin())); EXPECT_TRUE(aabb.GetMax().IsClose(transAabb.GetMax())); } + + TEST(MATH_AabbTransform, GetTransformedObbMatrix3x4) + { + Vector3 min(-1.0f, -2.0f, -3.0f); + Vector3 max(4.0f, 3.0f, 2.0f); + Aabb aabb = Aabb::CreateFromMinMax(min, max); + + Quaternion rotation(0.46f, 0.26f, 0.58f, 0.62f); + Vector3 translation(5.0f, 7.0f, 9.0f); + + Matrix3x4 matrix3x4 = Matrix3x4::CreateFromQuaternionAndTranslation(rotation, translation); + + matrix3x4.MultiplyByScale(Vector3(0.5f, 1.5f, 2.0f)); + + Obb obb = aabb.GetTransformedObb(matrix3x4); + + EXPECT_THAT(obb.GetRotation(), IsClose(rotation)); + EXPECT_THAT(obb.GetHalfLengths(), IsClose(Vector3(1.25f, 3.75f, 5.0f))); + EXPECT_THAT(obb.GetPosition(), IsClose(Vector3(3.928f, 7.9156f, 9.3708f))); + } + + TEST(MATH_AabbTransform, GetTransformedAabbMatrix3x4) + { + Vector3 min(2.0f, 3.0f, 5.0f); + Vector3 max(6.0f, 5.0f, 11.0f); + Aabb aabb = Aabb::CreateFromMinMax(min, max); + + Quaternion rotation(0.34f, 0.46f, 0.58f, 0.58f); + Vector3 translation(-3.0f, -4.0f, -5.0f); + + Matrix3x4 matrix3x4 = Matrix3x4::CreateFromQuaternionAndTranslation(rotation, translation); + + matrix3x4.MultiplyByScale(Vector3(1.2f, 0.8f, 2.0f)); + + Aabb transformedAabb = aabb.GetTransformedAabb(matrix3x4); + + EXPECT_THAT(transformedAabb.GetMin(), IsClose(Vector3(4.1488f, -0.01216f, -0.31904f))); + EXPECT_THAT(transformedAabb.GetMax(), IsClose(Vector3(16.3216f, 6.54272f, 5.98112f))); + } + + TEST(MATH_AabbTransform, GetTransformedObbFitsInsideTransformedAabb) + { + Vector3 min(4.0f, 3.0f, 1.0f); + Vector3 max(7.0f, 6.0f, 8.0f); + Aabb aabb = Aabb::CreateFromMinMax(min, max); + + Quaternion rotation(0.40f, 0.40f, 0.64f, 0.52f); + Vector3 translation(-2.0f, 4.0f, -3.0f); + + Matrix3x4 matrix3x4 = Matrix3x4::CreateFromQuaternionAndTranslation(rotation, translation); + + matrix3x4.MultiplyByScale(Vector3(2.2f, 0.6f, 1.4f)); + + Aabb transformedAabb = aabb.GetTransformedAabb(matrix3x4); + Obb transformedObb = aabb.GetTransformedObb(matrix3x4); + Aabb aabbContainingTransformedObb = Aabb::CreateFromObb(transformedObb); + + EXPECT_THAT(transformedAabb.GetMin(), IsClose(aabbContainingTransformedObb.GetMin())); + EXPECT_THAT(transformedAabb.GetMax(), IsClose(aabbContainingTransformedObb.GetMax())); + } + + TEST(MATH_AabbTransform, MultiplyByScale) + { + Vector3 min(2.0f, 6.0f, 8.0f); + Vector3 max(6.0f, 9.0f, 10.0f); + Aabb aabb = Aabb::CreateFromMinMax(min, max); + + Vector3 scale(0.5f, 2.0f, 1.5f); + aabb.MultiplyByScale(scale); + + EXPECT_THAT(aabb.GetMin(), IsClose(Vector3(1.0f, 12.0f, 12.0f))); + EXPECT_THAT(aabb.GetMax(), IsClose(Vector3(3.0f, 18.0f, 15.0f))); + } } diff --git a/Code/Framework/AzFramework/Platform/Linux/AzFramework/Asset/AssetSystemComponentHelper_Linux.cpp b/Code/Framework/AzFramework/Platform/Linux/AzFramework/Asset/AssetSystemComponentHelper_Linux.cpp index 1f71b97a57..1ae3945bd6 100644 --- a/Code/Framework/AzFramework/Platform/Linux/AzFramework/Asset/AssetSystemComponentHelper_Linux.cpp +++ b/Code/Framework/AzFramework/Platform/Linux/AzFramework/Asset/AssetSystemComponentHelper_Linux.cpp @@ -29,6 +29,20 @@ namespace AzFramework::AssetSystem::Platform bool LaunchAssetProcessor(AZStd::string_view executableDirectory, AZStd::string_view engineRoot, AZStd::string_view projectPath) { + AZ::IO::FixedMaxPath assetProcessorPath{ executableDirectory }; + assetProcessorPath /= "AssetProcessor"; + + if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) + { + // Check for existence of one under a "bin" directory, i.e. engineRoot is an SDK structure. + assetProcessorPath = AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor"; + + if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) + { + return false; + } + } + pid_t firstChildPid = fork(); if (firstChildPid == 0) { @@ -47,9 +61,6 @@ namespace AzFramework::AssetSystem::Platform pid_t secondChildPid = fork(); if (secondChildPid == 0) { - AZ::IO::FixedMaxPath assetProcessorPath{ executableDirectory }; - assetProcessorPath /= "AssetProcessor"; - AZStd::array args { assetProcessorPath.c_str(), assetProcessorPath.c_str(), "--start-hidden", static_cast(nullptr), static_cast(nullptr), static_cast(nullptr) diff --git a/Code/Framework/AzFramework/Platform/Mac/AzFramework/Asset/AssetSystemComponentHelper_Mac.cpp b/Code/Framework/AzFramework/Platform/Mac/AzFramework/Asset/AssetSystemComponentHelper_Mac.cpp index 43f7599676..6f1f860932 100644 --- a/Code/Framework/AzFramework/Platform/Mac/AzFramework/Asset/AssetSystemComponentHelper_Mac.cpp +++ b/Code/Framework/AzFramework/Platform/Mac/AzFramework/Asset/AssetSystemComponentHelper_Mac.cpp @@ -11,6 +11,7 @@ */ #include +#include #include #include @@ -20,6 +21,7 @@ namespace AzFramework::AssetSystem::Platform { void AllowAssetProcessorToForeground() {} + bool LaunchAssetProcessor(AZStd::string_view executableDirectory, AZStd::string_view engineRoot, AZStd::string_view projectPath) { @@ -29,6 +31,17 @@ namespace AzFramework::AssetSystem::Platform assetProcessorPath /= "../../../AssetProcessor.app"; assetProcessorPath = assetProcessorPath.LexicallyNormal(); + if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) + { + // Check for existence of one under a "bin" directory, i.e. engineRoot is an SDK structure. + assetProcessorPath = AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor.app"; + + if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) + { + return false; + } + } + auto fullLaunchCommand = AZ::IO::FixedMaxPathString::format(R"(open -g "%s" --args --start-hidden)", assetProcessorPath.c_str()); // Add the engine path to the launch command if not empty if (!engineRoot.empty()) diff --git a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp index 3f4dbef22a..b716778cf4 100644 --- a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp +++ b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -67,6 +68,17 @@ namespace AzFramework::AssetSystem::Platform AZ::IO::FixedMaxPath assetProcessorPath{ executableDirectory }; assetProcessorPath /= "AssetProcessor.exe"; + if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) + { + // Check for existence of one under a "bin" directory, i.e. engineRoot is an SDK structure. + assetProcessorPath = AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor.exe"; + + if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) + { + return false; + } + } + auto fullLaunchCommand = AZ::IO::FixedMaxPathString::format(R"("%s" --start-hidden)", assetProcessorPath.c_str()); // Add the engine path to the launch command if not empty diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDocking.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDocking.cpp index 76df971108..6cea9324c4 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDocking.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDocking.cpp @@ -2298,6 +2298,12 @@ namespace AzQtComponents OptimizedSetParent(dock, mainWindow); mainWindow->addDockWidget(Qt::LeftDockWidgetArea, dock); dock->show(); + + // Make sure we listen for events on the dock widget being put into a floating dock window + // because this might be called programmatically, so the dock widget might have never been + // parented to our m_mainWindow initially, so it won't already have an event filter, + // which will prevent the docking functionality from working. + dock->installEventFilter(this); } } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/API/ToolsApplicationAPI.h b/Code/Framework/AzToolsFramework/AzToolsFramework/API/ToolsApplicationAPI.h index f12ab71936..cca5d1b9e4 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/API/ToolsApplicationAPI.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/API/ToolsApplicationAPI.h @@ -815,8 +815,6 @@ namespace AzToolsFramework /// Hide or show the circular dependency error when saving slices virtual void SetShowCircularDependencyError(const bool& /*showCircularDependencyError*/) {} - virtual void SetEditTool(const char* /*tool*/) {} - /// Launches the Lua editor and opens the specified (space separated) files. virtual void LaunchLuaEditor(const char* /*files*/) {} diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp index 0a25d1cf25..abc290a406 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp @@ -140,7 +140,7 @@ namespace AzToolsFramework else { QPixmap pixmap = thumbnail->GetPixmap(size); - painter->drawPixmap(point.x(), point.y(), size.width(), size.height(), pixmap); + painter->drawPixmap(point, pixmap.scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); } return m_iconSize; } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/Thumbnail.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/Thumbnail.cpp index 939ca813b6..2892e4efce 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/Thumbnail.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/Thumbnail.cpp @@ -10,12 +10,14 @@ * */ +#include #include AZ_PUSH_DISABLE_WARNING(4127 4251 4800 4244, "-Wunknown-warning-option") // 4127: conditional expression is constant // 4251: 'QTextCodec::ConverterState::flags': class 'QFlags' needs to have dll-interface to be used by clients of struct 'QTextCodec::ConverterState' // 4800: 'QTextBoundaryFinderPrivate *const ': forcing value to bool 'true' or 'false' (performance warning) // 4244: conversion from 'int' to 'qint8', possible loss of data #include +#include AZ_POP_DISABLE_WARNING namespace AzToolsFramework @@ -80,7 +82,11 @@ namespace AzToolsFramework if (m_state == State::Unloaded) { m_state = State::Loading; - QFuture future = QtConcurrent::run([this](){ LoadThread(); }); + QThreadPool* threadPool; + ThumbnailContextRequestBus::BroadcastResult( + threadPool, + &ThumbnailContextRequestBus::Handler::GetThreadPool); + QFuture future = QtConcurrent::run(threadPool, [this](){ LoadThread(); }); m_watcher.setFuture(future); } } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailContext.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailContext.cpp index 8f6b9c63fd..ae6d7c1178 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailContext.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailContext.cpp @@ -28,10 +28,15 @@ namespace AzToolsFramework : m_missingThumbnail(new MissingThumbnail(thumbnailSize)) , m_loadingThumbnail(new LoadingThumbnail(thumbnailSize)) , m_thumbnailSize(thumbnailSize) + , m_threadPool(this) { + ThumbnailContextRequestBus::Handler::BusConnect(); } - ThumbnailContext::~ThumbnailContext() = default; + ThumbnailContext::~ThumbnailContext() + { + ThumbnailContextRequestBus::Handler::BusDisconnect(); + } bool ThumbnailContext::IsLoading(SharedThumbnailKey key) { @@ -53,6 +58,11 @@ namespace AzToolsFramework AzToolsFramework::AssetBrowser::AssetBrowserViewRequestBus::Broadcast(&AzToolsFramework::AssetBrowser::AssetBrowserViewRequests::Update); } + QThreadPool* ThumbnailContext::GetThreadPool() + { + return &m_threadPool; + } + SharedThumbnail ThumbnailContext::GetThumbnail(SharedThumbnailKey key) { SharedThumbnail thumbnail; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailContext.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailContext.h index 589abad0df..6ba3d637f6 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailContext.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailContext.h @@ -19,6 +19,7 @@ #include #include +#include #endif class QString; @@ -40,6 +41,7 @@ namespace AzToolsFramework */ class ThumbnailContext : public QObject + , public ThumbnailContextRequestBus::Handler { Q_OBJECT public: @@ -58,10 +60,13 @@ namespace AzToolsFramework void UnregisterThumbnailProvider(const char* providerName); void RedrawThumbnail(); - + //! Default context used for most thumbnails static constexpr const char* DefaultContext = "Default"; + // ThumbnailContextRequestBus::Handler interface overrides... + QThreadPool* GetThreadPool() override; + private: struct ProviderCompare { bool operator() (const SharedThumbnailProvider& lhs, const SharedThumbnailProvider& rhs) const @@ -79,6 +84,9 @@ namespace AzToolsFramework SharedThumbnail m_loadingThumbnail; //! Thumbnail size (width and height in pixels) int m_thumbnailSize; + //! There is only a limited number of threads on global threadPool, because there can be many thumbnails rendering at once + //! an individual threadPool is needed to avoid deadlocks + QThreadPool m_threadPool; }; } // namespace Thumbnailer } // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailWidget.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailWidget.cpp index 1aefa6f189..038bfd5da5 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailWidget.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailWidget.cpp @@ -81,6 +81,9 @@ namespace AzToolsFramework int x = (originalWidth - realWidth) / 2; // pixmap needs to be manually scaled to produce smoother result and avoid looking pixelated // using painter.setRenderHint(QPainter::SmoothPixmapTransform); does not seem to work + // Note: there is a potential issue with pixmap.scaled: + // it is multithreaded (using global threadPool) and blocking until finished. + // A deadlock will happen if global threadPool has no free threads available. painter.drawPixmap(QPoint(x, 0), pixmap.scaled(realWidth, realHeight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); } QWidget::paintEvent(event); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailerBus.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailerBus.h index ebc721bb4c..02264e61f8 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailerBus.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailerBus.h @@ -17,11 +17,23 @@ #include class QPixmap; +class QThreadPool; namespace AzToolsFramework { namespace Thumbnailer { + //! Interaction with thumbnail context + class ThumbnailContextRequests + : public AZ::EBusTraits + { + public: + //! Get thread pool for drawing thumbnails + virtual QThreadPool* GetThreadPool() = 0; + }; + + using ThumbnailContextRequestBus = AZ::EBus; + //! Interaction with thumbnailer class ThumbnailerRequests : public AZ::EBusTraits diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/LegacyFramework/Core/EditorFrameworkApplication.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/LegacyFramework/Core/EditorFrameworkApplication.cpp index 8cc6d46da8..0aec36b9b0 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/LegacyFramework/Core/EditorFrameworkApplication.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/LegacyFramework/Core/EditorFrameworkApplication.cpp @@ -192,6 +192,10 @@ namespace LegacyFramework // if we're in console mode, listen for CTRL+C ::SetConsoleCtrlHandler(CTRL_BREAK_HandlerRoutine, true); #endif + + m_ptrCommandLineParser = aznew AzFramework::CommandLine(); + m_ptrCommandLineParser->Parse(m_desc.m_argc, m_desc.m_argv); + // If we don't have one create a serialize context if (GetSerializeContext() == nullptr) { diff --git a/Code/Sandbox/Editor/2DViewport.cpp b/Code/Sandbox/Editor/2DViewport.cpp index e6e62be1f1..d86ea03bdf 100644 --- a/Code/Sandbox/Editor/2DViewport.cpp +++ b/Code/Sandbox/Editor/2DViewport.cpp @@ -20,7 +20,6 @@ #include "2DViewport.h" #include "CryEditDoc.h" #include "DisplaySettings.h" -#include "EditTool.h" #include "GameEngine.h" #include "Settings.h" #include "ViewManager.h" @@ -1117,11 +1116,6 @@ void Q2DViewport::DrawObjects(DisplayContext& dc) GetIEditor()->GetObjectManager()->Display(dc); } - // Display editing tool. - if (GetEditTool()) - { - GetEditTool()->Display(dc); - } dc.PopMatrix(); } diff --git a/Code/Sandbox/Editor/Controls/QRollupCtrl.cpp b/Code/Sandbox/Editor/Controls/QRollupCtrl.cpp deleted file mode 100644 index ea91bdcd62..0000000000 --- a/Code/Sandbox/Editor/Controls/QRollupCtrl.cpp +++ /dev/null @@ -1,588 +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. - * - */ - -#include "EditorDefs.h" - -#include "QRollupCtrl.h" - -// Qt -#include -#include -#include -#include -#include -#include - -////////////////////////////////////////////////////////////////////////// - -class QRollupCtrlButton - : public QToolButton -{ -public: - QRollupCtrlButton(QWidget* parent); - - inline void setSelected(bool b) { selected = b; update(); } - inline bool isSelected() const { return selected; } - - QSize sizeHint() const override; - QSize minimumSizeHint() const override; - -protected: - void paintEvent(QPaintEvent*) override; - -private: - bool selected; -}; - -QRollupCtrlButton::QRollupCtrlButton(QWidget* parent) - : QToolButton(parent) - , selected(true) -{ - setBackgroundRole(QPalette::Window); - setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); - setFocusPolicy(Qt::NoFocus); - - setStyleSheet("* {margin: 2px 5px 2px 5px; border: 1px solid #CBA457;}"); -} - -QSize QRollupCtrlButton::sizeHint() const -{ - QSize iconSize(8, 8); - if (!icon().isNull()) - { - int icone = style()->pixelMetric(QStyle::PM_SmallIconSize); - iconSize += QSize(icone + 2, icone); - } - QSize textSize = fontMetrics().size(Qt::TextShowMnemonic, text()) + QSize(0, 8); - - QSize total(iconSize.width() + textSize.width(), qMax(iconSize.height(), textSize.height())); - return total.expandedTo(QApplication::globalStrut()); -} - -QSize QRollupCtrlButton::minimumSizeHint() const -{ - if (icon().isNull()) - { - return QSize(); - } - int icone = style()->pixelMetric(QStyle::PM_SmallIconSize); - return QSize(icone + 8, icone + 8); -} - -void QRollupCtrlButton::paintEvent(QPaintEvent*) -{ - QStylePainter p(this); - // draw the background manually, not to clash with UI 2.0 style shets - // the numbers here are taken from the stylesheet in the constructor - p.fillRect(QRect(5, 1, width() - 10, height() - 3), QColor(52, 52, 52)); - - { - QStyleOptionToolButton opt; - initStyleOption(&opt); - if (isSelected()) - { - if (opt.state & QStyle::State_MouseOver) - { - opt.state |= QStyle::State_Sunken; - } - opt.state |= QStyle::State_MouseOver; - } - p.drawComplexControl(QStyle::CC_ToolButton, opt); - } - - { - p.setPen(QPen(QColor(132, 128, 125))); - - int top = height() / 2 - 2; - p.drawLine(2, top, 4, top); - p.drawLine(width() - 5, top, width() - 3, top); - - int bottom = !isSelected() ? top + 4 : height(); - p.drawLine(2, bottom, 2, top); - p.drawLine(width() - 3, bottom, width() - 3, top); - - if (!isSelected()) - { - p.drawLine(2, bottom, 4, bottom); - p.drawLine(width() - 5, bottom, width() - 3, bottom); - } - } -} - -////////////////////////////////////////////////////////////////////////// - -QRollupCtrl::Page* QRollupCtrl::page(QWidget* widget) const -{ - if (!widget) - { - return 0; - } - - for (PageList::ConstIterator i = m_pageList.constBegin(); i != m_pageList.constEnd(); ++i) - { - if ((*i).widget == widget) - { - return (Page*)&(*i); - } - } - return 0; -} - -QRollupCtrl::Page* QRollupCtrl::page(int index) -{ - if (index >= 0 && index < m_pageList.size()) - { - return &m_pageList[index]; - } - return 0; -} - -const QRollupCtrl::Page* QRollupCtrl::page(int index) const -{ - if (index >= 0 && index < m_pageList.size()) - { - return &m_pageList.at(index); - } - return 0; -} - -inline void QRollupCtrl::Page::setText(const QString& text) { button->setText(text); } -inline void QRollupCtrl::Page::setIcon(const QIcon& is) { button->setIcon(is); } -inline void QRollupCtrl::Page::setToolTip(const QString& tip) { button->setToolTip(tip); } -inline QString QRollupCtrl::Page::text() const { return button->text(); } -inline QIcon QRollupCtrl::Page::icon() const { return button->icon(); } -inline QString QRollupCtrl::Page::toolTip() const { return button->toolTip(); } - -////////////////////////////////////////////////////////////////////////// - -QRollupCtrl::QRollupCtrl(QWidget* parent) - : QScrollArea(parent) - , m_layout(0) -{ - m_body = new QWidget(this); - m_body->setBackgroundRole(QPalette::Button); - setWidgetResizable(true); - setAlignment(Qt::AlignLeft | Qt::AlignTop); - setWidget(m_body); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - relayout(); -} - -QRollupCtrl::~QRollupCtrl() -{ - foreach(const QRollupCtrl::Page & c, m_pageList) - disconnect(c.widget, &QObject::destroyed, this, &QRollupCtrl::_q_widgetDestroyed); -} - -void QRollupCtrl::readSettings(const QString& qSettingsGroup) -{ - QSettings settings; - settings.beginGroup(qSettingsGroup); - - int i = 0; - foreach(const QRollupCtrl::Page & c, m_pageList) { - QString qObjectName = c.widget->objectName(); - - bool bHidden = settings.value(qObjectName, true).toBool(); - setIndexVisible(i++, !bHidden); - } - - settings.endGroup(); -} - -void QRollupCtrl::writeSettings(const QString& qSettingsGroup) -{ - QSettings settings; - settings.beginGroup(qSettingsGroup); - - for (int i = 0; i < count(); i++) - { - QString qObjectName; - bool bHidden = isPageHidden(i, qObjectName); - - settings.setValue(qObjectName, bHidden); - } -} - -void QRollupCtrl::updateTabs() -{ - for (auto i = m_pageList.constBegin(); i != m_pageList.constEnd(); ++i) - { - QRollupCtrlButton* tB = (*i).button; - QWidget* tW = (*i).sv; - tB->setSelected(tW->isVisible()); - tB->update(); - } -} - -int QRollupCtrl::insertItem(int index, QWidget* widget, const QIcon& icon, const QString& text) -{ - if (!widget) - { - return -1; - } - - auto it = std::find_if(m_pageList.cbegin(), m_pageList.cend(), [widget](const Page& page) { return page.widget == widget; }); - if (it != m_pageList.cend()) - { - return -1; - } - - connect(widget, &QObject::destroyed, this, &QRollupCtrl::_q_widgetDestroyed); - - QRollupCtrl::Page c; - c.widget = widget; - c.button = new QRollupCtrlButton(m_body); - c.button->setContextMenuPolicy(Qt::CustomContextMenu); - connect(c.button, &QRollupCtrlButton::clicked, this, &QRollupCtrl::_q_buttonClicked); - connect(c.button, &QRollupCtrlButton::customContextMenuRequested, this, &QRollupCtrl::_q_custumButtonMenu); - - c.sv = new QFrame(m_body); - c.sv->setObjectName("rollupPaneFrame"); - // c.sv->setFixedHeight(qMax(widget->sizeHint().height(), widget->size().height())); - QVBoxLayout* layout = new QVBoxLayout; - layout->setMargin(3); - layout->addWidget(widget); - c.sv->setLayout(layout); - c.sv->setStyleSheet("QFrame#rollupPaneFrame {margin: 0px 2px 2px 2px; border: 1px solid #84807D; border-top:0px;}"); - c.sv->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - c.sv->show(); - - c.setText(text); - c.setIcon(icon); - - const int numPages = m_pageList.count(); - if (index < 0 || index >= numPages) - { - m_pageList.append(c); - index = numPages - 1; - m_layout->insertWidget(m_layout->count() - 1, c.button); - m_layout->insertWidget(m_layout->count() - 1, c.sv); - } - else - { - m_pageList.insert(index, c); - relayout(); - } - - c.button->show(); - - updateTabs(); - itemInserted(index); - return index; -} - -void QRollupCtrl::_q_buttonClicked() -{ - QObject* tb = sender(); - QWidget* item = 0; - for (auto i = m_pageList.constBegin(); i != m_pageList.constEnd(); ++i) - { - if ((*i).button == tb) - { - item = (*i).widget; - break; - } - } - - if (item) - { - setIndexVisible(indexOf(item), !item->isVisible()); - } -} - -int QRollupCtrl::count() const -{ - return m_pageList.count(); -} - -bool QRollupCtrl::isPageHidden(int index, QString& qObjectName) const -{ - if (index < 0 || index >= m_pageList.size()) - { - return true; - } - const QRollupCtrl::Page& c = m_pageList.at(index); - qObjectName = c.widget->objectName(); - return c.sv->isHidden(); -} - -void QRollupCtrl::setIndexVisible(int index, bool visible) -{ - QRollupCtrl::Page* c = page(index); - if (!c) - { - return; - } - - if (c->sv->isHidden() && visible) - { - c->sv->show(); - } - else if (c->sv->isVisible() && !visible) - { - c->sv->hide(); - } - updateTabs(); -} - -void QRollupCtrl::setWidgetVisible(QWidget* widget, bool visible) -{ - setIndexVisible(indexOf(widget), visible); -} - -void QRollupCtrl::relayout() -{ - delete m_layout; - m_layout = new QVBoxLayout(m_body); - m_layout->setMargin(3); - m_layout->setSpacing(0); - for (QRollupCtrl::PageList::ConstIterator i = m_pageList.constBegin(); i != m_pageList.constEnd(); ++i) - { - m_layout->addWidget((*i).button); - m_layout->addWidget((*i).sv); - } - m_layout->addStretch(); - updateTabs(); -} - -void QRollupCtrl::_q_widgetDestroyed(QObject* object) -{ - // no verification - vtbl corrupted already - QWidget* p = (QWidget*)object; - - QRollupCtrl::Page* c = page(p); - if (!p || !c) - { - return; - } - - m_layout->removeWidget(c->sv); - m_layout->removeWidget(c->button); - c->sv->deleteLater(); // page might still be a child of sv - delete c->button; - - m_pageList.removeOne(*c); -} - -void QRollupCtrl::_q_custumButtonMenu([[maybe_unused]] const QPoint& pos) -{ - QMenu menu; - menu.addAction("Expand All")->setData(-1); - menu.addAction("Collapse All")->setData(-2); - menu.addSeparator(); - for (int i = 0; i < m_pageList.size(); ++i) - { - QRollupCtrl::Page* c = page(i); - QAction* action = menu.addAction(c->button->text()); - action->setCheckable(true); - action->setChecked(c->sv->isVisible()); - action->setData(i); - } - - QAction* action = menu.exec(QCursor::pos()); - if (!action) - { - return; - } - int res = action->data().toInt(); - switch (res) - { - case -1: // fall through - case -2: - expandAllPages(res == -1); - break; - default: - { - QRollupCtrl::Page* c = page(res); - if (c) - { - setIndexVisible(res, !c->sv->isVisible()); - } - } - break; - } -} - -void QRollupCtrl::expandAllPages(bool v) -{ - for (int i = 0; i < m_pageList.size(); i++) - { - setIndexVisible(i, v); - } -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -void QRollupCtrl::clear() -{ - while (!m_pageList.isEmpty()) - { - removeItem(0); - } -} - -void QRollupCtrl::removeItem(QWidget* widget) -{ - auto it = std::find_if(m_pageList.cbegin(), m_pageList.cend(), [widget](const Page& page) { return page.widget == widget; }); - if (it != m_pageList.cend()) - { - removeItem(it - m_pageList.cbegin()); - } -} - -void QRollupCtrl::removeItem(int index) -{ - if (QWidget* w = widget(index)) - { - disconnect(w, &QObject::destroyed, this, &QRollupCtrl::_q_widgetDestroyed); - w->setParent(this); - // destroy internal data - _q_widgetDestroyed(w); - itemRemoved(index); - } -} - -QWidget* QRollupCtrl::widget(int index) const -{ - if (index < 0 || index >= (int) m_pageList.size()) - { - return 0; - } - return m_pageList.at(index).widget; -} - -int QRollupCtrl::indexOf(QWidget* widget) const -{ - QRollupCtrl::Page* c = page(widget); - return c ? m_pageList.indexOf(*c) : -1; -} - -void QRollupCtrl::setItemEnabled(int index, bool enabled) -{ - QRollupCtrl::Page* c = page(index); - if (!c) - { - return; - } - - c->button->setEnabled(enabled); - if (!enabled) - { - int curIndexUp = index; - int curIndexDown = curIndexUp; - const int count = m_pageList.count(); - while (curIndexUp > 0 || curIndexDown < count - 1) - { - if (curIndexDown < count - 1) - { - if (page(++curIndexDown)->button->isEnabled()) - { - index = curIndexDown; - break; - } - } - if (curIndexUp > 0) - { - if (page(--curIndexUp)->button->isEnabled()) - { - index = curIndexUp; - break; - } - } - } - } -} - -void QRollupCtrl::setItemText(int index, const QString& text) -{ - QRollupCtrl::Page* c = page(index); - if (c) - { - c->setText(text); - } -} - -void QRollupCtrl::setItemIcon(int index, const QIcon& icon) -{ - QRollupCtrl::Page* c = page(index); - if (c) - { - c->setIcon(icon); - } -} - -void QRollupCtrl::setItemToolTip(int index, const QString& toolTip) -{ - QRollupCtrl::Page* c = page(index); - if (c) - { - c->setToolTip(toolTip); - } -} - -bool QRollupCtrl::isItemEnabled(int index) const -{ - const QRollupCtrl::Page* c = page(index); - return c && c->button->isEnabled(); -} - -QString QRollupCtrl::itemText(int index) const -{ - const QRollupCtrl::Page* c = page(index); - return (c ? c->text() : QString()); -} - -QIcon QRollupCtrl::itemIcon(int index) const -{ - const QRollupCtrl::Page* c = page(index); - return (c ? c->icon() : QIcon()); -} - -QString QRollupCtrl::itemToolTip(int index) const -{ - const QRollupCtrl::Page* c = page(index); - return (c ? c->toolTip() : QString()); -} - -void QRollupCtrl::changeEvent(QEvent* ev) -{ - if (ev->type() == QEvent::StyleChange) - { - updateTabs(); - } - QFrame::changeEvent(ev); -} - -void QRollupCtrl::showEvent(QShowEvent* ev) -{ - if (isVisible()) - { - updateTabs(); - } - IEditor* pEditor = GetIEditor(); - pEditor->SetEditMode(EEditMode::eEditModeSelect); - QFrame::showEvent(ev); -} - -void QRollupCtrl::itemInserted(int index) -{ - Q_UNUSED(index) -} - -void QRollupCtrl::itemRemoved(int index) -{ - Q_UNUSED(index) -} - - -#include diff --git a/Code/Sandbox/Editor/Controls/QRollupCtrl.h b/Code/Sandbox/Editor/Controls/QRollupCtrl.h deleted file mode 100644 index 3db8bdf860..0000000000 --- a/Code/Sandbox/Editor/Controls/QRollupCtrl.h +++ /dev/null @@ -1,126 +0,0 @@ -#ifndef CRYINCLUDE_EDITOR_CONTROLS_QROLLUPCTRL_H -#define CRYINCLUDE_EDITOR_CONTROLS_QROLLUPCTRL_H - -/* - * 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. - * - */ - - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#endif - -class QVBoxLayout; -class QRollupCtrlButton; - -class QRollupCtrl - : public QScrollArea -{ - Q_OBJECT - Q_PROPERTY(int count READ count) - -public: - explicit QRollupCtrl(QWidget* parent = 0); - ~QRollupCtrl(); - - int addItem(QWidget* widget, const QString& text); - int addItem(QWidget* widget, const QIcon& icon, const QString& text); - int insertItem(int index, QWidget* widget, const QString& text); - int insertItem(int index, QWidget* widget, const QIcon& icon, const QString& text); - - void clear(); - void removeItem(QWidget* widget); - void removeItem(int index); - - void setItemEnabled(int index, bool enabled); - bool isItemEnabled(int index) const; - - void setItemText(int index, const QString& text); - QString itemText(int index) const; - - void setItemIcon(int index, const QIcon& icon); - QIcon itemIcon(int index) const; - - void setItemToolTip(int index, const QString& toolTip); - QString itemToolTip(int index) const; - - QWidget* widget(int index) const; - int indexOf(QWidget* widget) const; - int count() const; - - void readSettings (const QString& qSettingsGroup); - void writeSettings(const QString& qSettingsGroup); - -public slots: - void setIndexVisible(int index, bool visible); - void setWidgetVisible(QWidget* widget, bool visible); - void expandAllPages(bool v); - -protected: - virtual void itemInserted(int index); - virtual void itemRemoved(int index); - void changeEvent(QEvent*) override; - void showEvent(QShowEvent*) override; - -private: - Q_DISABLE_COPY(QRollupCtrl) - - struct Page - { - QRollupCtrlButton* button; - QFrame* sv; - QWidget* widget; - - void setText(const QString& text); - void setIcon(const QIcon& is); - void setToolTip(const QString& tip); - QString text() const; - QIcon icon() const; - QString toolTip() const; - - inline bool operator==(const Page& other) const - { - return widget == other.widget; - } - }; - typedef QList PageList; - - Page* page(QWidget* widget) const; - const Page* page(int index) const; - Page* page(int index); - - void updateTabs(); - void relayout(); - bool isPageHidden(int index, QString& qObjectName) const; - - QWidget* m_body; - PageList m_pageList; - QVBoxLayout* m_layout; - -private slots: - void _q_buttonClicked(); - void _q_widgetDestroyed(QObject*); - void _q_custumButtonMenu(const QPoint&); -}; - - -////////////////////////////////////////////////////////////////////////// - -inline int QRollupCtrl::addItem(QWidget* item, const QString& text) -{ return insertItem(-1, item, QIcon(), text); } -inline int QRollupCtrl::addItem(QWidget* item, const QIcon& iconSet, const QString& text) -{ return insertItem(-1, item, iconSet, text); } -inline int QRollupCtrl::insertItem(int index, QWidget* item, const QString& text) -{ return insertItem(index, item, QIcon(), text); } - -#endif diff --git a/Code/Sandbox/Editor/Controls/ToolButton.cpp b/Code/Sandbox/Editor/Controls/ToolButton.cpp deleted file mode 100644 index b74fe1a330..0000000000 --- a/Code/Sandbox/Editor/Controls/ToolButton.cpp +++ /dev/null @@ -1,171 +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" - -// Editor -#include "CryEditDoc.h" -#include "EditTool.h" -#include "ToolButton.h" - - -QEditorToolButton::QEditorToolButton(QWidget* parent /* = nullptr */) - : QPushButton(parent) - , m_styleSheet(styleSheet()) - , m_toolClass(nullptr) - , m_toolCreated(nullptr) - , m_needDocument(true) -{ - setSizePolicy({ QSizePolicy::Expanding, QSizePolicy::Fixed }); - connect(this, &QAbstractButton::clicked, this, &QEditorToolButton::OnClicked); - GetIEditor()->RegisterNotifyListener(this); -} - -QEditorToolButton::~QEditorToolButton() -{ - GetIEditor()->UnregisterNotifyListener(this); -} - -void QEditorToolButton::SetToolName(const QString& editToolName, const QString& userDataKey, void* userData) -{ - IClassDesc* klass = GetIEditor()->GetClassFactory()->FindClass(editToolName.toUtf8().data()); - if (!klass) - { - Warning(QStringLiteral("Editor Tool %1 not registered.").arg(editToolName).toUtf8().data()); - return; - } - if (klass->SystemClassID() != ESYSTEM_CLASS_EDITTOOL) - { - Warning(QStringLiteral("Class name %1 is not a valid Edit Tool class.").arg(editToolName).toUtf8().data()); - return; - } - - QScopedPointer o(klass->CreateQObject()); - if (!qobject_cast(o.data())) - { - Warning(QStringLiteral("Class name %1 is not a valid Edit Tool class.").arg(editToolName).toUtf8().data()); - return; - } - SetToolClass(o->metaObject(), userDataKey, userData); -} - -////////////////////////////////////////////////////////////////////////// -void QEditorToolButton::SetToolClass(const QMetaObject* toolClass, const QString& userDataKey, void* userData) -{ - m_toolClass = toolClass; - - m_userData = userData; - if (!userDataKey.isEmpty()) - { - m_userDataKey = userDataKey; - } -} - -void QEditorToolButton::OnEditorNotifyEvent(EEditorNotifyEvent event) -{ - switch (event) - { - case eNotify_OnBeginNewScene: - case eNotify_OnBeginLoad: - case eNotify_OnBeginSceneOpen: - { - if (m_needDocument) - { - setEnabled(false); - } - break; - } - - case eNotify_OnEndNewScene: - case eNotify_OnEndLoad: - case eNotify_OnEndSceneOpen: - { - if (m_needDocument) - { - setEnabled(true); - } - break; - } - case eNotify_OnEditToolChange: - { - CEditTool* tool = GetIEditor()->GetEditTool(); - - if (!tool || tool != m_toolCreated || tool->metaObject() != m_toolClass) - { - m_toolCreated = nullptr; - SetSelected(false); - } - } - default: - break; - } -} - -void QEditorToolButton::OnClicked() -{ - if (!m_toolClass) - { - return; - } - - if (m_needDocument && !GetIEditor()->GetDocument()->IsDocumentReady()) - { - return; - } - - CEditTool* tool = GetIEditor()->GetEditTool(); - if (tool && tool->IsMoveToObjectModeAfterEnd() && tool->metaObject() == m_toolClass && tool == m_toolCreated) - { - GetIEditor()->SetEditTool(nullptr); - SetSelected(false); - } - else - { - CEditTool* newTool = qobject_cast(m_toolClass->newInstance()); - if (!newTool) - { - return; - } - - m_toolCreated = newTool; - - SetSelected(true); - - if (m_userData) - { - newTool->SetUserData(m_userDataKey.toUtf8().data(), (void*)m_userData); - } - - update(); - - // Must be last function, can delete this. - GetIEditor()->SetEditTool(newTool); - } -} - -void QEditorToolButton::SetSelected(bool selected) -{ - if (selected) - { - setStyleSheet(QStringLiteral("QPushButton { background-color: palette(highlight); color: palette(highlighted-text); }")); - } - else - { - setStyleSheet(m_styleSheet); - } -} - -#include diff --git a/Code/Sandbox/Editor/Controls/ToolButton.h b/Code/Sandbox/Editor/Controls/ToolButton.h deleted file mode 100644 index f32bd6678d..0000000000 --- a/Code/Sandbox/Editor/Controls/ToolButton.h +++ /dev/null @@ -1,60 +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_CONTROLS_TOOLBUTTON_H -#define CRYINCLUDE_EDITOR_CONTROLS_TOOLBUTTON_H -#pragma once - -// ToolButton.h : header file -// - -#if !defined(Q_MOC_RUN) -#include -#include -#endif - -AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING -class SANDBOX_API QEditorToolButton - : public QPushButton - , public IEditorNotifyListener -{ -AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING - Q_OBJECT - // Construction -public: - QEditorToolButton(QWidget* parent = nullptr); - virtual ~QEditorToolButton(); - - void SetToolClass(const QMetaObject* toolClass, const QString& userDataKey = 0, void* userData = nullptr); - void SetToolName(const QString& editToolName, const QString& userDataKey = 0, void* userData = nullptr); - // Set if this tool button relies on a loaded level / ready document. By default every tool button only works if a level is loaded. - // However some tools are also used without a loaded level (e.g. UI Emulator) - void SetNeedDocument(bool needDocument) { m_needDocument = needDocument; } - - void SetSelected(bool selected); - void OnEditorNotifyEvent(EEditorNotifyEvent event) override; -protected: - void OnClicked(); - - const QString m_styleSheet; - - //! Tool associated with this button. - const QMetaObject* m_toolClass; - CEditTool* m_toolCreated; - QString m_userDataKey; - void* m_userData; - bool m_needDocument; -}; - - -#endif // CRYINCLUDE_EDITOR_CONTROLS_TOOLBUTTON_H diff --git a/Code/Sandbox/Editor/Core/LevelEditorMenuHandler.cpp b/Code/Sandbox/Editor/Core/LevelEditorMenuHandler.cpp index f00085d5ad..aed53d6e8b 100644 --- a/Code/Sandbox/Editor/Core/LevelEditorMenuHandler.cpp +++ b/Code/Sandbox/Editor/Core/LevelEditorMenuHandler.cpp @@ -577,17 +577,6 @@ void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMe modifyMenu.AddAction(ID_MODIFY_LINK); modifyMenu.AddAction(ID_MODIFY_UNLINK); modifyMenu.AddSeparator(); - - auto alignMenu = modifyMenu.AddMenu(tr("Align")); - alignMenu.AddAction(ID_OBJECTMODIFY_ALIGNTOGRID); - alignMenu.AddAction(ID_MODIFY_ALIGNOBJTOSURF); - - auto constrainMenu = modifyMenu.AddMenu(tr("Constrain")); - constrainMenu.AddAction(ID_SELECT_AXIS_X); - constrainMenu.AddAction(ID_SELECT_AXIS_Y); - constrainMenu.AddAction(ID_SELECT_AXIS_Z); - constrainMenu.AddAction(ID_SELECT_AXIS_XY); - constrainMenu.AddAction(ID_SELECT_AXIS_TERRAIN); } auto snapMenu = modifyMenu.AddMenu(tr("Snap")); @@ -609,20 +598,10 @@ void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMe } auto transformModeMenu = modifyMenu.AddMenu(tr("Transform Mode")); - if (!newViewportInteractionModelEnabled) - { - transformModeMenu.AddAction(ID_EDITMODE_SELECT); - } - transformModeMenu.AddAction(ID_EDITMODE_MOVE); transformModeMenu.AddAction(ID_EDITMODE_ROTATE); transformModeMenu.AddAction(ID_EDITMODE_SCALE); - if (!newViewportInteractionModelEnabled) - { - transformModeMenu.AddAction(ID_EDITMODE_SELECTAREA); - } - editMenu.AddSeparator(); // Lock Selection diff --git a/Code/Sandbox/Editor/CryEdit.cpp b/Code/Sandbox/Editor/CryEdit.cpp index 7aefcffb5a..a474706910 100644 --- a/Code/Sandbox/Editor/CryEdit.cpp +++ b/Code/Sandbox/Editor/CryEdit.cpp @@ -95,7 +95,6 @@ AZ_POP_DISABLE_WARNING #include "Core/QtEditorApplication.h" #include "StringDlg.h" -#include "VoxelAligningTool.h" #include "NewLevelDialog.h" #include "GridSettingsDialog.h" #include "LayoutConfigDialog.h" @@ -110,7 +109,6 @@ AZ_POP_DISABLE_WARNING #include "DisplaySettings.h" #include "GameEngine.h" -#include "ObjectCloneTool.h" #include "StartupTraceHandler.h" #include "ThumbnailGenerator.h" #include "ToolsConfigPage.h" @@ -127,7 +125,6 @@ AZ_POP_DISABLE_WARNING #include "AnimationContext.h" #include "GotoPositionDlg.h" -#include "SetVectorDlg.h" #include "ConsoleDialog.h" #include "Controls/ConsoleSCB.h" @@ -153,7 +150,6 @@ AZ_POP_DISABLE_WARNING #include "LevelIndependentFileMan.h" #include "WelcomeScreen/WelcomeScreenDialog.h" #include "Dialogs/DuplicatedObjectsHandlerDlg.h" -#include "EditMode/VertexSnappingModeTool.h" #include "Controls/ReflectedPropertyControl/PropertyCtrl.h" #include "Controls/ReflectedPropertyControl/ReflectedVar.h" @@ -398,34 +394,20 @@ void CCryEditApp::RegisterActionHandlers() ON_COMMAND(ID_EDITMODE_MOVE, OnEditmodeMove) ON_COMMAND(ID_EDITMODE_ROTATE, OnEditmodeRotate) ON_COMMAND(ID_EDITMODE_SCALE, OnEditmodeScale) - ON_COMMAND(ID_EDITMODE_SELECT, OnEditmodeSelect) - ON_COMMAND(ID_EDIT_ESCAPE, OnEditEscape) ON_COMMAND(ID_OBJECTMODIFY_SETAREA, OnObjectSetArea) ON_COMMAND(ID_OBJECTMODIFY_SETHEIGHT, OnObjectSetHeight) - ON_COMMAND(ID_OBJECTMODIFY_VERTEXSNAPPING, OnObjectVertexSnapping) - ON_COMMAND(ID_MODIFY_ALIGNOBJTOSURF, OnAlignToVoxel) ON_COMMAND(ID_OBJECTMODIFY_FREEZE, OnObjectmodifyFreeze) ON_COMMAND(ID_OBJECTMODIFY_UNFREEZE, OnObjectmodifyUnfreeze) - ON_COMMAND(ID_EDITMODE_SELECTAREA, OnEditmodeSelectarea) - ON_COMMAND(ID_SELECT_AXIS_X, OnSelectAxisX) - ON_COMMAND(ID_SELECT_AXIS_Y, OnSelectAxisY) - ON_COMMAND(ID_SELECT_AXIS_Z, OnSelectAxisZ) - ON_COMMAND(ID_SELECT_AXIS_XY, OnSelectAxisXy) ON_COMMAND(ID_UNDO, OnUndo) ON_COMMAND(ID_TOOLBAR_WIDGET_REDO, OnUndo) // Can't use the same ID, because for the menu we can't have a QWidgetAction, while for the toolbar we want one - ON_COMMAND(ID_EDIT_CLONE, OnEditClone) ON_COMMAND(ID_SELECTION_SAVE, OnSelectionSave) ON_COMMAND(ID_IMPORT_ASSET, OnOpenAssetImporter) ON_COMMAND(ID_SELECTION_LOAD, OnSelectionLoad) - ON_COMMAND(ID_MODIFY_ALIGNOBJTOSURF, OnAlignToVoxel) - ON_COMMAND(ID_OBJECTMODIFY_ALIGNTOGRID, OnAlignToGrid) ON_COMMAND(ID_LOCK_SELECTION, OnLockSelection) ON_COMMAND(ID_EDIT_LEVELDATA, OnEditLevelData) ON_COMMAND(ID_FILE_EDITLOGFILE, OnFileEditLogFile) ON_COMMAND(ID_FILE_RESAVESLICES, OnFileResaveSlices) ON_COMMAND(ID_FILE_EDITEDITORINI, OnFileEditEditorini) - ON_COMMAND(ID_SELECT_AXIS_TERRAIN, OnSelectAxisTerrain) - ON_COMMAND(ID_SELECT_AXIS_SNAPTOALL, OnSelectAxisSnapToAll) ON_COMMAND(ID_PREFERENCES, OnPreferences) ON_COMMAND(ID_RELOAD_GEOMETRY, OnReloadGeometry) ON_COMMAND(ID_REDO, OnRedo) @@ -492,7 +474,6 @@ void CCryEditApp::RegisterActionHandlers() ON_COMMAND(ID_VIEW_CYCLE2DVIEWPORT, OnViewCycle2dviewport) #endif ON_COMMAND(ID_DISPLAY_GOTOPOSITION, OnDisplayGotoPosition) - ON_COMMAND(ID_DISPLAY_SETVECTOR, OnDisplaySetVector) ON_COMMAND(ID_SNAPANGLE, OnSnapangle) ON_COMMAND(ID_RULER, OnRuler) ON_COMMAND(ID_ROTATESELECTION_XAXIS, OnRotateselectionXaxis) @@ -524,12 +505,10 @@ void CCryEditApp::RegisterActionHandlers() ON_COMMAND(ID_OPEN_MATERIAL_EDITOR, OnOpenMaterialEditor) ON_COMMAND(ID_GOTO_VIEWPORTSEARCH, OnGotoViewportSearch) - ON_COMMAND(ID_MATERIAL_PICKTOOL, OnMaterialPicktool) ON_COMMAND(ID_DISPLAY_SHOWHELPERS, OnShowHelpers) ON_COMMAND(ID_OPEN_TRACKVIEW, OnOpenTrackView) ON_COMMAND(ID_OPEN_UICANVASEDITOR, OnOpenUICanvasEditor) ON_COMMAND(ID_GOTO_VIEWPORTSEARCH, OnGotoViewportSearch) - ON_COMMAND(ID_MATERIAL_PICKTOOL, OnMaterialPicktool) ON_COMMAND(ID_TERRAIN_TIMEOFDAY, OnTimeOfDay) ON_COMMAND(ID_TERRAIN_TIMEOFDAYBUTTON, OnTimeOfDay) @@ -2739,15 +2718,6 @@ void CCryEditApp::OnEditDelete() ////////////////////////////////////////////////////////////////////////// void CCryEditApp::DeleteSelectedEntities([[maybe_unused]] bool includeDescendants) { - // If Edit tool active cannot delete object. - if (GetIEditor()->GetEditTool()) - { - if (GetIEditor()->GetEditTool()->OnKeyDown(GetIEditor()->GetViewManager()->GetView(0), VK_DELETE, 0, 0)) - { - return; - } - } - GetIEditor()->BeginUndo(); CUndo undo("Delete Selected Object"); GetIEditor()->GetObjectManager()->DeleteSelection(); @@ -2756,75 +2726,6 @@ void CCryEditApp::DeleteSelectedEntities([[maybe_unused]] bool includeDescendant GetIEditor()->SetModifiedModule(eModifiedBrushes); } -void CCryEditApp::OnEditClone() -{ - if (!GetIEditor()->IsNewViewportInteractionModelEnabled()) - { - if (GetIEditor()->GetObjectManager()->GetSelection()->IsEmpty()) - { - QMessageBox::critical(AzToolsFramework::GetActiveWindow(), QString(), - QObject::tr("You have to select objects before you can clone them!")); - return; - } - - // Clear Widget selection - Prevents issues caused by cloning entities while a property in the Reflected Property Editor is being edited. - if (QApplication::focusWidget()) - { - QApplication::focusWidget()->clearFocus(); - } - - CEditTool* tool = GetIEditor()->GetEditTool(); - if (tool && qobject_cast(tool)) - { - ((CObjectCloneTool*)tool)->Accept(); - } - - CObjectCloneTool* cloneTool = new CObjectCloneTool; - GetIEditor()->SetEditTool(cloneTool); - GetIEditor()->SetModifiedFlag(); - GetIEditor()->SetModifiedModule(eModifiedBrushes); - - // Accept the clone operation if users didn't choose to stick duplicated entities to the cursor - // This setting can be changed in the global preference of the editor - if (!gSettings.deepSelectionSettings.bStickDuplicate) - { - cloneTool->Accept(); - GetIEditor()->GetSelection()->FinishChanges(); - } - } -} - -void CCryEditApp::OnEditEscape() -{ - if (!GetIEditor()->IsNewViewportInteractionModelEnabled()) - { - CEditTool* pEditTool = GetIEditor()->GetEditTool(); - // Abort current operation. - if (pEditTool) - { - // If Edit tool active cannot delete object. - CViewport* vp = GetIEditor()->GetActiveView(); - if (GetIEditor()->GetEditTool()->OnKeyDown(vp, VK_ESCAPE, 0, 0)) - { - return; - } - - if (GetIEditor()->GetEditMode() == eEditModeSelectArea) - { - GetIEditor()->SetEditMode(eEditModeSelect); - } - - // Disable current tool. - GetIEditor()->SetEditTool(0); - } - else - { - // Clear selection on escape. - GetIEditor()->ClearSelection(); - } - } -} - void CCryEditApp::OnMoveObject() { //////////////////////////////////////////////////////////////////////// @@ -2843,85 +2744,31 @@ void CCryEditApp::OnSetHeight() ////////////////////////////////////////////////////////////////////////// void CCryEditApp::OnEditmodeMove() { - if (GetIEditor()->IsNewViewportInteractionModelEnabled()) - { - using namespace AzToolsFramework; - EditorTransformComponentSelectionRequestBus::Event( - GetEntityContextId(), - &EditorTransformComponentSelectionRequests::SetTransformMode, - EditorTransformComponentSelectionRequests::Mode::Translation); - } - else - { - GetIEditor()->SetEditMode(eEditModeMove); - } + using namespace AzToolsFramework; + EditorTransformComponentSelectionRequestBus::Event( + GetEntityContextId(), + &EditorTransformComponentSelectionRequests::SetTransformMode, + EditorTransformComponentSelectionRequests::Mode::Translation); } ////////////////////////////////////////////////////////////////////////// void CCryEditApp::OnEditmodeRotate() { - if (GetIEditor()->IsNewViewportInteractionModelEnabled()) - { - using namespace AzToolsFramework; - EditorTransformComponentSelectionRequestBus::Event( - GetEntityContextId(), - &EditorTransformComponentSelectionRequests::SetTransformMode, - EditorTransformComponentSelectionRequests::Mode::Rotation); - } - else - { - GetIEditor()->SetEditMode(eEditModeRotate); - } + using namespace AzToolsFramework; + EditorTransformComponentSelectionRequestBus::Event( + GetEntityContextId(), + &EditorTransformComponentSelectionRequests::SetTransformMode, + EditorTransformComponentSelectionRequests::Mode::Rotation); } ////////////////////////////////////////////////////////////////////////// void CCryEditApp::OnEditmodeScale() { - if (GetIEditor()->IsNewViewportInteractionModelEnabled()) - { - using namespace AzToolsFramework; - EditorTransformComponentSelectionRequestBus::Event( - GetEntityContextId(), - &EditorTransformComponentSelectionRequests::SetTransformMode, - EditorTransformComponentSelectionRequests::Mode::Scale); - } - else - { - GetIEditor()->SetEditMode(eEditModeScale); - } -} - -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnEditmodeSelect() -{ - if (!GetIEditor()->IsNewViewportInteractionModelEnabled()) - { - GetIEditor()->SetEditMode(eEditModeSelect); - } -} - -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnEditmodeSelectarea() -{ - // TODO: Add your command handler code here - GetIEditor()->SetEditMode(eEditModeSelectArea); -} - -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnUpdateEditmodeSelectarea(QAction* action) -{ - Q_ASSERT(action->isCheckable()); - action->setChecked(GetIEditor()->GetEditMode() == eEditModeSelectArea); -} - -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnUpdateEditmodeSelect(QAction* action) -{ - Q_ASSERT(action->isCheckable()); - if (!GetIEditor()->IsNewViewportInteractionModelEnabled()) - { - action->setChecked(GetIEditor()->GetEditMode() == eEditModeSelect); - } + using namespace AzToolsFramework; + EditorTransformComponentSelectionRequestBus::Event( + GetEntityContextId(), + &EditorTransformComponentSelectionRequests::SetTransformMode, + EditorTransformComponentSelectionRequests::Mode::Scale); } ////////////////////////////////////////////////////////////////////////// @@ -2929,19 +2776,12 @@ void CCryEditApp::OnUpdateEditmodeMove(QAction* action) { Q_ASSERT(action->isCheckable()); - if (GetIEditor()->IsNewViewportInteractionModelEnabled()) - { - AzToolsFramework::EditorTransformComponentSelectionRequests::Mode mode; - AzToolsFramework::EditorTransformComponentSelectionRequestBus::EventResult( - mode, AzToolsFramework::GetEntityContextId(), - &AzToolsFramework::EditorTransformComponentSelectionRequests::GetTransformMode); + AzToolsFramework::EditorTransformComponentSelectionRequests::Mode mode; + AzToolsFramework::EditorTransformComponentSelectionRequestBus::EventResult( + mode, AzToolsFramework::GetEntityContextId(), + &AzToolsFramework::EditorTransformComponentSelectionRequests::GetTransformMode); - action->setChecked(mode == AzToolsFramework::EditorTransformComponentSelectionRequests::Mode::Translation); - } - else - { - action->setChecked(GetIEditor()->GetEditMode() == eEditModeMove); - } + action->setChecked(mode == AzToolsFramework::EditorTransformComponentSelectionRequests::Mode::Translation); } ////////////////////////////////////////////////////////////////////////// @@ -2949,20 +2789,12 @@ void CCryEditApp::OnUpdateEditmodeRotate(QAction* action) { Q_ASSERT(action->isCheckable()); - if (GetIEditor()->IsNewViewportInteractionModelEnabled()) - { - AzToolsFramework::EditorTransformComponentSelectionRequests::Mode mode; - AzToolsFramework::EditorTransformComponentSelectionRequestBus::EventResult( - mode, AzToolsFramework::GetEntityContextId(), - &AzToolsFramework::EditorTransformComponentSelectionRequests::GetTransformMode); + AzToolsFramework::EditorTransformComponentSelectionRequests::Mode mode; + AzToolsFramework::EditorTransformComponentSelectionRequestBus::EventResult( + mode, AzToolsFramework::GetEntityContextId(), + &AzToolsFramework::EditorTransformComponentSelectionRequests::GetTransformMode); - action->setChecked(mode == AzToolsFramework::EditorTransformComponentSelectionRequests::Mode::Rotation); - } - else - { - action->setChecked(GetIEditor()->GetEditMode() == eEditModeRotate); - action->setEnabled(true); - } + action->setChecked(mode == AzToolsFramework::EditorTransformComponentSelectionRequests::Mode::Rotation); } ////////////////////////////////////////////////////////////////////////// @@ -2970,28 +2802,12 @@ void CCryEditApp::OnUpdateEditmodeScale(QAction* action) { Q_ASSERT(action->isCheckable()); - if (GetIEditor()->IsNewViewportInteractionModelEnabled()) - { - AzToolsFramework::EditorTransformComponentSelectionRequests::Mode mode; - AzToolsFramework::EditorTransformComponentSelectionRequestBus::EventResult( - mode, AzToolsFramework::GetEntityContextId(), - &AzToolsFramework::EditorTransformComponentSelectionRequests::GetTransformMode); + AzToolsFramework::EditorTransformComponentSelectionRequests::Mode mode; + AzToolsFramework::EditorTransformComponentSelectionRequestBus::EventResult( + mode, AzToolsFramework::GetEntityContextId(), + &AzToolsFramework::EditorTransformComponentSelectionRequests::GetTransformMode); - action->setChecked(mode == AzToolsFramework::EditorTransformComponentSelectionRequests::Mode::Scale); - } - else - { - action->setChecked(GetIEditor()->GetEditMode() == eEditModeScale); - action->setEnabled(true); - } -} - -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnUpdateEditmodeVertexSnapping(QAction* action) -{ - Q_ASSERT(action->isCheckable()); - CEditTool* pEditTool = GetIEditor()->GetEditTool(); - action->setChecked(qobject_cast(pEditTool) != nullptr); + action->setChecked(mode == AzToolsFramework::EditorTransformComponentSelectionRequests::Mode::Scale); } ////////////////////////////////////////////////////////////////////////// @@ -3143,19 +2959,6 @@ void CCryEditApp::OnObjectSetHeight() } } -void CCryEditApp::OnObjectVertexSnapping() -{ - CEditTool* pEditTool = GetIEditor()->GetEditTool(); - if (qobject_cast(pEditTool)) - { - GetIEditor()->SetEditTool(NULL); - } - else - { - GetIEditor()->SetEditTool("EditTool.VertexSnappingMode"); - } -} - void CCryEditApp::OnObjectmodifyFreeze() { // Freeze selection. @@ -3185,101 +2988,6 @@ void CCryEditApp::OnViewSwitchToGame() GetIEditor()->SetInGameMode(inGame); } -void CCryEditApp::OnSelectAxisX() -{ - AxisConstrains axis = (GetIEditor()->GetAxisConstrains() != AXIS_X) ? AXIS_X : AXIS_NONE; - GetIEditor()->SetAxisConstraints(axis); -} - -void CCryEditApp::OnSelectAxisY() -{ - AxisConstrains axis = (GetIEditor()->GetAxisConstrains() != AXIS_Y) ? AXIS_Y : AXIS_NONE; - GetIEditor()->SetAxisConstraints(axis); -} - -void CCryEditApp::OnSelectAxisZ() -{ - AxisConstrains axis = (GetIEditor()->GetAxisConstrains() != AXIS_Z) ? AXIS_Z : AXIS_NONE; - GetIEditor()->SetAxisConstraints(axis); -} - -void CCryEditApp::OnSelectAxisXy() -{ - AxisConstrains axis = (GetIEditor()->GetAxisConstrains() != AXIS_XY) ? AXIS_XY : AXIS_NONE; - GetIEditor()->SetAxisConstraints(axis); -} - -void CCryEditApp::OnUpdateSelectAxisX(QAction* action) -{ - Q_ASSERT(action->isCheckable()); - action->setChecked(GetIEditor()->GetAxisConstrains() == AXIS_X); -} - -void CCryEditApp::OnUpdateSelectAxisXy(QAction* action) -{ - Q_ASSERT(action->isCheckable()); - action->setChecked(GetIEditor()->GetAxisConstrains() == AXIS_XY); -} - -void CCryEditApp::OnUpdateSelectAxisY(QAction* action) -{ - Q_ASSERT(action->isCheckable()); - action->setChecked(GetIEditor()->GetAxisConstrains() == AXIS_Y); -} - -void CCryEditApp::OnUpdateSelectAxisZ(QAction* action) -{ - Q_ASSERT(action->isCheckable()); - action->setChecked(GetIEditor()->GetAxisConstrains() == AXIS_Z); -} - -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnSelectAxisTerrain() -{ - IEditor* editor = GetIEditor(); - bool isAlreadyEnabled = (editor->GetAxisConstrains() == AXIS_TERRAIN) && (editor->IsTerrainAxisIgnoreObjects()); - if (!isAlreadyEnabled) - { - editor->SetAxisConstraints(AXIS_TERRAIN); - editor->SetTerrainAxisIgnoreObjects(true); - } - else - { - // behave like a toggle button - click on the same thing again to disable. - editor->SetAxisConstraints(AXIS_NONE); - } -} - -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnSelectAxisSnapToAll() -{ - IEditor* editor = GetIEditor(); - bool isAlreadyEnabled = (editor->GetAxisConstrains() == AXIS_TERRAIN) && (!editor->IsTerrainAxisIgnoreObjects()); - if (!isAlreadyEnabled) - { - editor->SetAxisConstraints(AXIS_TERRAIN); - editor->SetTerrainAxisIgnoreObjects(false); - } - else - { - // behave like a toggle button - click on the same thing again to disable. - editor->SetAxisConstraints(AXIS_NONE); - } -} - -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnUpdateSelectAxisTerrain(QAction* action) -{ - Q_ASSERT(action->isCheckable()); - action->setChecked(GetIEditor()->GetAxisConstrains() == AXIS_TERRAIN && GetIEditor()->IsTerrainAxisIgnoreObjects()); -} - -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnUpdateSelectAxisSnapToAll(QAction* action) -{ - action->setChecked(GetIEditor()->GetAxisConstrains() == AXIS_TERRAIN && !GetIEditor()->IsTerrainAxisIgnoreObjects()); -} - ////////////////////////////////////////////////////////////////////////// void CCryEditApp::OnExportSelectedObjects() { @@ -3460,57 +3168,8 @@ void CCryEditApp::OnUpdateSelected(QAction* action) action->setEnabled(!GetIEditor()->GetSelection()->IsEmpty()); } -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnAlignToGrid() -{ - CSelectionGroup* sel = GetIEditor()->GetSelection(); - if (!sel->IsEmpty()) - { - CUndo undo("Align To Grid"); - Matrix34 tm; - for (int i = 0; i < sel->GetCount(); i++) - { - CBaseObject* obj = sel->GetObject(i); - tm = obj->GetWorldTM(); - Vec3 snaped = gSettings.pGrid->Snap(tm.GetTranslation()); - tm.SetTranslation(snaped); - obj->SetWorldTM(tm, eObjectUpdateFlags_UserInput); - obj->OnEvent(EVENT_ALIGN_TOGRID); - } - } -} - -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnAlignToVoxel() -{ - CEditTool* pEditTool = GetIEditor()->GetEditTool(); - if (qobject_cast(pEditTool) != nullptr) - { - GetIEditor()->SetEditTool(nullptr); - } - else - { - GetIEditor()->SetEditTool(new CVoxelAligningTool()); - } -} - -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnUpdateAlignToVoxel(QAction* action) -{ - Q_ASSERT(action->isCheckable()); - CEditTool* pEditTool = GetIEditor()->GetEditTool(); - action->setChecked(qobject_cast(pEditTool) != nullptr); - - action->setEnabled(!GetIEditor()->GetSelection()->IsEmpty()); -} - void CCryEditApp::OnShowHelpers() { - CEditTool* pEditTool(GetIEditor()->GetEditTool()); - if (pEditTool && pEditTool->IsNeedSpecificBehaviorForSpaceAcce()) - { - return; - } GetIEditor()->GetDisplaySettings()->DisplayHelpers(!GetIEditor()->GetDisplaySettings()->IsDisplayHelpers()); GetIEditor()->Notify(eNotify_OnDisplayRenderUpdate); } @@ -4668,13 +4327,6 @@ void CCryEditApp::OnDisplayGotoPosition() dlg.exec(); } -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnDisplaySetVector() -{ - CSetVectorDlg dlg; - dlg.exec(); -} - ////////////////////////////////////////////////////////////////////////// void CCryEditApp::OnSnapangle() { @@ -5136,12 +4788,6 @@ void CCryEditApp::OnOpenUICanvasEditor() QtViewPaneManager::instance()->OpenPane(LyViewPane::UiEditor); } -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnMaterialPicktool() -{ - GetIEditor()->SetEditTool("EditTool.PickMaterial"); -} - ////////////////////////////////////////////////////////////////////////// void CCryEditApp::OnTimeOfDay() { @@ -5296,12 +4942,6 @@ void CCryEditApp::OnOpenQuickAccessBar() return; } - CEditTool* pEditTool(GetIEditor()->GetEditTool()); - if (pEditTool && pEditTool->IsNeedSpecificBehaviorForSpaceAcce()) - { - return; - } - QRect geo = m_pQuickAccessBar->geometry(); geo.moveCenter(MainWindow::instance()->geometry().center()); m_pQuickAccessBar->setGeometry(geo); diff --git a/Code/Sandbox/Editor/CryEdit.h b/Code/Sandbox/Editor/CryEdit.h index 94c39991e9..dc18dbcfda 100644 --- a/Code/Sandbox/Editor/CryEdit.h +++ b/Code/Sandbox/Editor/CryEdit.h @@ -224,46 +224,23 @@ public: void OnEditmodeMove(); void OnEditmodeRotate(); void OnEditmodeScale(); - void OnEditmodeSelect(); - void OnEditEscape(); void OnObjectSetArea(); void OnObjectSetHeight(); - void OnObjectVertexSnapping(); - void OnUpdateEditmodeVertexSnapping(QAction* action); - void OnUpdateEditmodeSelect(QAction* action); void OnUpdateEditmodeMove(QAction* action); void OnUpdateEditmodeRotate(QAction* action); void OnUpdateEditmodeScale(QAction* action); void OnObjectmodifyFreeze(); void OnObjectmodifyUnfreeze(); - void OnEditmodeSelectarea(); - void OnUpdateEditmodeSelectarea(QAction* action); - void OnSelectAxisX(); - void OnSelectAxisY(); - void OnSelectAxisZ(); - void OnSelectAxisXy(); - void OnUpdateSelectAxisX(QAction* action); - void OnUpdateSelectAxisXy(QAction* action); - void OnUpdateSelectAxisY(QAction* action); - void OnUpdateSelectAxisZ(QAction* action); void OnUndo(); - void OnEditClone(); void OnSelectionSave(); void OnOpenAssetImporter(); void OnSelectionLoad(); void OnUpdateSelected(QAction* action); - void OnAlignToVoxel(); - void OnAlignToGrid(); - void OnUpdateAlignToVoxel(QAction* action); void OnLockSelection(); void OnEditLevelData(); void OnFileEditLogFile(); void OnFileResaveSlices(); void OnFileEditEditorini(); - void OnSelectAxisTerrain(); - void OnSelectAxisSnapToAll(); - void OnUpdateSelectAxisTerrain(QAction* action); - void OnUpdateSelectAxisSnapToAll(QAction* action); void OnPreferences(); void OnReloadTextures(); void OnReloadGeometry(); @@ -454,7 +431,6 @@ private: void OnToolsScriptHelp(); void OnViewCycle2dviewport(); void OnDisplayGotoPosition(); - void OnDisplaySetVector(); void OnSnapangle(); void OnUpdateSnapangle(QAction* action); void OnRuler(); @@ -491,7 +467,6 @@ private: void OnOpenAudioControlsEditor(); void OnOpenUICanvasEditor(); void OnGotoViewportSearch(); - void OnMaterialPicktool(); void OnTimeOfDay(); void OnChangeGameSpec(UINT nID); void SetGameSpecCheck(ESystemConfigSpec spec, ESystemConfigPlatform platform, int &nCheck, bool &enable); diff --git a/Code/Sandbox/Editor/CryEditDoc.cpp b/Code/Sandbox/Editor/CryEditDoc.cpp index 15269c1496..916317b6bb 100644 --- a/Code/Sandbox/Editor/CryEditDoc.cpp +++ b/Code/Sandbox/Editor/CryEditDoc.cpp @@ -279,9 +279,6 @@ void CCryEditDoc::DeleteContents() // [LY-90904] move this to the EditorVegetationManager component InstanceStatObjEventBus::Broadcast(&InstanceStatObjEventBus::Events::ReleaseData); - GetIEditor()->SetEditTool(0); // Turn off any active edit tools. - GetIEditor()->SetEditMode(eEditModeSelect); - ////////////////////////////////////////////////////////////////////////// // Clear all undo info. ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Sandbox/Editor/CryEditDoc.h b/Code/Sandbox/Editor/CryEditDoc.h index 9f954f31d8..481e9fa046 100644 --- a/Code/Sandbox/Editor/CryEditDoc.h +++ b/Code/Sandbox/Editor/CryEditDoc.h @@ -216,7 +216,6 @@ protected: void OnSliceInstantiationFailed(const AZ::Data::AssetId& sliceAssetId, const AzFramework::SliceInstantiationTicket& /*ticket*/) override; ////////////////////////////////////////////////////////////////////////// - QString m_strMasterCDFolder; bool m_bLoadFailed; QColor m_waterColor; XmlNodeRef m_fogTemplate; diff --git a/Code/Sandbox/Editor/Dialogs/ButtonsPanel.cpp b/Code/Sandbox/Editor/Dialogs/ButtonsPanel.cpp deleted file mode 100644 index 8314361585..0000000000 --- a/Code/Sandbox/Editor/Dialogs/ButtonsPanel.cpp +++ /dev/null @@ -1,123 +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 "ButtonsPanel.h" - -// Qt -#include - -// Editor -#include "Controls/ToolButton.h" - -///////////////////////////////////////////////////////////////////////////// -// CButtonsPanel dialog -CButtonsPanel::CButtonsPanel(QWidget* parent) - : QWidget(parent) -{ -} - -CButtonsPanel::~CButtonsPanel() -{ -} - -////////////////////////////////////////////////////////////////////////// -void CButtonsPanel::AddButton(const SButtonInfo& button) -{ - SButton b; - b.info = button; - m_buttons.push_back(b); -} -////////////////////////////////////////////////////////////////////////// -void CButtonsPanel::AddButton(const QString& name, const QString& toolClass) -{ - SButtonInfo bi; - bi.name = name; - bi.toolClassName = toolClass; - AddButton(bi); -} -////////////////////////////////////////////////////////////////////////// -void CButtonsPanel::AddButton(const QString& name, const QMetaObject* pToolClass) -{ - SButtonInfo bi; - bi.name = name; - bi.pToolClass = pToolClass; - AddButton(bi); -} -////////////////////////////////////////////////////////////////////////// -void CButtonsPanel::ClearButtons() -{ - auto buttons = layout()->findChildren(); - foreach(auto button, buttons) - { - layout()->removeWidget(button); - delete button; - } - m_buttons.clear(); -} - -void CButtonsPanel::UncheckAll() -{ - for (auto& button : m_buttons) - { - button.pButton->SetSelected(false); - } -} - -void CButtonsPanel::OnInitDialog() -{ - auto layout = new QGridLayout(this); - setLayout(layout); - - layout->setMargin(4); - layout->setHorizontalSpacing(4); - layout->setVerticalSpacing(1); - - // Create Buttons. - int index = 0; - for (auto& button : m_buttons) - { - button.pButton = new QEditorToolButton(this); - button.pButton->setObjectName(button.info.name); - button.pButton->setText(button.info.name); - button.pButton->SetNeedDocument(button.info.bNeedDocument); - button.pButton->setToolTip(button.info.toolTip); - - if (button.info.pToolClass) - { - button.pButton->SetToolClass(button.info.pToolClass, button.info.toolUserDataKey, (void*)button.info.toolUserData.c_str()); - } - else if (!button.info.toolClassName.isEmpty()) - { - button.pButton->SetToolName(button.info.toolClassName, button.info.toolUserDataKey, (void*)button.info.toolUserData.c_str()); - } - - layout->addWidget(button.pButton, index / 2, index % 2); - connect(button.pButton, &QEditorToolButton::clicked, this, [&]() { OnButtonPressed(button.info); }); - ++index; - } -} - -void CButtonsPanel::EnableButton(const QString& buttonName, bool enable) -{ - for (auto& button : m_buttons) - { - if (button.pButton->objectName() == buttonName) - { - button.pButton->setEnabled(enable); - } - } -} - -#include diff --git a/Code/Sandbox/Editor/Dialogs/ButtonsPanel.h b/Code/Sandbox/Editor/Dialogs/ButtonsPanel.h deleted file mode 100644 index c214c7625b..0000000000 --- a/Code/Sandbox/Editor/Dialogs/ButtonsPanel.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. - -#ifndef CRYINCLUDE_EDITOR_DIALOGS_BUTTONSPANEL_H -#define CRYINCLUDE_EDITOR_DIALOGS_BUTTONSPANEL_H -#pragma once - -#if !defined(Q_MOC_RUN) -#include -#endif - -class QEditorToolButton; - -///////////////////////////////////////////////////////////////////////////// -// Panel with custom auto arranged buttons -class CButtonsPanel - : public QWidget -{ - Q_OBJECT -public: - - struct SButtonInfo - { - QString name; - QString toolClassName; - QString toolUserDataKey; - std::string toolUserData; - QString toolTip; - bool bNeedDocument; - const QMetaObject* pToolClass; - - SButtonInfo() - : pToolClass(nullptr) - , bNeedDocument(true) {}; - }; - - CButtonsPanel(QWidget* parent); - virtual ~CButtonsPanel(); - - virtual void AddButton(const SButtonInfo& button); - virtual void AddButton(const QString& name, const QString& toolClass); - virtual void AddButton(const QString& name, const QMetaObject* pToolClass); - virtual void EnableButton(const QString& buttonName, bool disable); - virtual void ClearButtons(); - - virtual void OnButtonPressed([[maybe_unused]] const SButtonInfo& button) {}; - virtual void UncheckAll(); - -protected: - void ReleaseGuiButtons(); - - virtual void OnInitDialog(); - - ////////////////////////////////////////////////////////////////////////// - struct SButton - { - SButtonInfo info; - QEditorToolButton* pButton; - SButton() - : pButton(nullptr) {}; - }; - - std::vector m_buttons; -}; - -#endif // CRYINCLUDE_EDITOR_DIALOGS_BUTTONSPANEL_H diff --git a/Code/Sandbox/Editor/EditMode/ObjectMode.cpp b/Code/Sandbox/Editor/EditMode/ObjectMode.cpp deleted file mode 100644 index 3454cfefd3..0000000000 --- a/Code/Sandbox/Editor/EditMode/ObjectMode.cpp +++ /dev/null @@ -1,1525 +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" - -#if defined(AZ_PLATFORM_WINDOWS) -#include -#endif - -#include "ObjectMode.h" - -// Qt -#include - -// AzToolsFramework -#include -#include -#include - -// Editor -#include "Viewport.h" -#include "ViewManager.h" -#include "Settings.h" -#include "Objects/SelectionGroup.h" - -#include "GameEngine.h" -#include "Objects/DisplayContext.h" -#include "Objects/EntityObject.h" -#include "AnimationContext.h" -#include "DeepSelection.h" -#include "SubObjectSelectionReferenceFrameCalculator.h" -#include "ITransformManipulator.h" -#include "SurfaceInfoPicker.h" -#include "RenderViewport.h" -#include "Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.h" - - -////////////////////////////////////////////////////////////////////////// -CObjectMode::CObjectMode(QObject* parent) - : CEditTool(parent) -{ - m_pClassDesc = GetIEditor()->GetClassFactory()->FindClass(OBJECT_MODE_GUID); - SetStatusText(tr("Object Selection")); - - m_openContext = false; - m_commandMode = NothingMode; - m_MouseOverObject = GuidUtil::NullGuid; - - m_pDeepSelection = new CDeepSelection(); - m_bMoveByFaceNormManipShown = false; - m_pHitObject = NULL; - - m_bTransformChanged = false; -} - -////////////////////////////////////////////////////////////////////////// -CObjectMode::~CObjectMode() -{ -} - -void CObjectMode::DrawSelectionPreview(struct DisplayContext& dc, CBaseObject* drawObject) -{ - AABB bbox; - drawObject->GetBoundBox(bbox); - - AZStd::string cleanName = drawObject->GetName().toUtf8().data(); - - // Since we'll be passing this in as a format for a sprintf, need to cleanup any %'s so they display correctly - size_t index = cleanName.find("%", 0); - while (index != std::string::npos) - { - cleanName.insert(index, "%", 1); - - // Increment index past the replacement so it doesn't get picked up again on the next loop - index = cleanName.find("%", index + 2); - } - - // If CGroup/CPrefabObject - if (drawObject->GetChildCount() > 0) - { - // Draw object name label on top of object - Vec3 vTopEdgeCenterPos = bbox.GetCenter(); - - dc.SetColor(gSettings.objectColorSettings.groupHighlight); - vTopEdgeCenterPos(vTopEdgeCenterPos.x, vTopEdgeCenterPos.y, bbox.max.z); - dc.DrawTextLabel(vTopEdgeCenterPos, 1.3f, cleanName.c_str()); - // Draw bounding box wireframe - dc.DrawWireBox(bbox.min, bbox.max); - } - else - { - dc.SetColor(Vec3(1, 1, 1)); - dc.DrawTextLabel(bbox.GetCenter(), 1.5, cleanName.c_str()); - } - - // Object Geometry Highlight - - const float normalizedFloatToUint8 = 255.0f; - - // Default object - ColorB selColor = ColorB(gSettings.objectColorSettings.geometryHighlightColor.red(), gSettings.objectColorSettings.geometryHighlightColor.green(), gSettings.objectColorSettings.geometryHighlightColor.blue(), gSettings.objectColorSettings.fGeomAlpha * normalizedFloatToUint8); - - // In case it is a child object, use a different alpha value - if (drawObject->GetParent()) - { - selColor.a = (uint8)(gSettings.objectColorSettings.fChildGeomAlpha * normalizedFloatToUint8); - } - - // Draw geometry in custom color - SGeometryDebugDrawInfo dd; - dd.tm = drawObject->GetWorldTM(); - dd.color = selColor; - dd.lineColor = selColor; - dd.bExtrude = true; - - if (qobject_cast(drawObject)) - { - dc.DepthTestOff(); - dc.SetColor(gSettings.objectColorSettings.entityHighlight, gSettings.objectColorSettings.fBBoxAlpha * normalizedFloatToUint8); - dc.DrawSolidBox(bbox.min, bbox.max); - dc.DepthTestOn(); - - CEntityObject* entityObj = (CEntityObject*)drawObject; - if (entityObj) - { - entityObj->DrawExtraLightInfo(dc); - } - } - - // Highlight also children objects if this object is opened - for (int gNo = 0; gNo < drawObject->GetChildCount(); ++gNo) - { - if (std::find(m_PreviewGUIDs.begin(), m_PreviewGUIDs.end(), drawObject->GetChild(gNo)->GetId()) == m_PreviewGUIDs.end()) - { - DrawSelectionPreview(dc, drawObject->GetChild(gNo)); - } - } -} - -void CObjectMode::DisplaySelectionPreview(struct DisplayContext& dc) -{ - CViewport* view = dc.view->asCViewport(); - IObjectManager* objMan = GetIEditor()->GetObjectManager(); - - if (!view) - { - return; - } - - QRect rc = view->GetSelectionRectangle(); - - if (GetCommandMode() == SelectMode) - { - if (rc.width() > 1 && rc.height() > 1) - { - GetIEditor()->GetObjectManager()->FindObjectsInRect(view, rc, m_PreviewGUIDs); - - QString selCountStr; - - // Do not include child objects in the count of object candidates - int childNo = 0; - for (int objNo = 0; objNo < m_PreviewGUIDs.size(); ++objNo) - { - if (objMan->FindObject(m_PreviewGUIDs[objNo])) - { - if (objMan->FindObject(m_PreviewGUIDs[objNo])->GetParent()) - { - ++childNo; - } - } - } - - selCountStr = QString::number(m_PreviewGUIDs.size() - childNo); - GetIEditor()->SetStatusText(tr("Selection Candidates Count: %1").arg(selCountStr)); - - // Draw Preview for objects - for (size_t i = 0; i < m_PreviewGUIDs.size(); ++i) - { - CBaseObject* curObj = GetIEditor()->GetObjectManager()->FindObject(m_PreviewGUIDs[i]); - - if (!curObj) - { - continue; - } - - DrawSelectionPreview(dc, curObj); - } - } - } -} - -void CObjectMode::DisplayExtraLightInfo(struct DisplayContext& dc) -{ - if (m_MouseOverObject != GUID_NULL) - { - IObjectManager* objMan = GetIEditor()->GetObjectManager(); - - if (objMan) - { - CBaseObject* hitObj = objMan->FindObject(m_MouseOverObject); - - if (hitObj) - { - if (objMan->IsLightClass(hitObj)) - { - CEntityObject* entityObj = (CEntityObject*)hitObj; - if (entityObj) - { - entityObj->DrawExtraLightInfo(dc); - } - } - } - } - } -} - -////////////////////////////////////////////////////////////////////////// -void CObjectMode::EndEditParams() -{ - CBaseObject* pMouseOverObject = nullptr; - if (!GuidUtil::IsEmpty(m_MouseOverObject)) - { - pMouseOverObject = GetIEditor()->GetObjectManager()->FindObject(m_MouseOverObject); - } - - if (pMouseOverObject) - { - pMouseOverObject->SetHighlight(false); - } -} - -////////////////////////////////////////////////////////////////////////// -void CObjectMode::Display(struct DisplayContext& dc) -{ - // Selection Candidates Preview - DisplaySelectionPreview(dc); - DisplayExtraLightInfo(dc); - - GetIEditor()->GetSelection()->IndicateSnappingVertex(dc); -} - -////////////////////////////////////////////////////////////////////////// -bool CObjectMode::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags) -{ - switch (event) - { - case eMouseLDown: - return OnLButtonDown(view, flags, point); - break; - case eMouseLUp: - return OnLButtonUp(view, flags, point); - break; - case eMouseLDblClick: - return OnLButtonDblClk(view, flags, point); - break; - case eMouseRDown: - return OnRButtonDown(view, flags, point); - break; - case eMouseRUp: - return OnRButtonUp(view, flags, point); - break; - case eMouseMove: - return OnMouseMove(view, flags, point); - break; - case eMouseMDown: - return OnMButtonDown(view, flags, point); - break; - case eMouseLeave: - return OnMouseLeave(view); - break; - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CObjectMode::OnKeyDown([[maybe_unused]] CViewport* view, uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) -{ - if (nChar == VK_ESCAPE) - { - GetIEditor()->ClearSelection(); - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CObjectMode::OnKeyUp([[maybe_unused]] CViewport* view, [[maybe_unused]] uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) -{ - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CObjectMode::OnLButtonDown(CViewport* view, int nFlags, const QPoint& point) -{ - AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Editor); - - if (m_bMoveByFaceNormManipShown) - { - HideMoveByFaceNormGizmo(); - } - - // CPointF ptMarker; - QPoint ptCoord; - - if (GetIEditor()->IsInGameMode() || GetIEditor()->IsInSimulationMode()) - { - // Ignore clicks while in game. - return false; - } - - // Allow interception of mouse clicks for custom behavior. - bool handledExternally = false; - EBUS_EVENT(AzToolsFramework::EditorRequests::Bus, - HandleObjectModeSelection, - AZ::Vector2(static_cast(point.x()), static_cast(point.y())), - nFlags, - handledExternally); - if (handledExternally) - { - return true; - } - - // Save the mouse down position - m_cMouseDownPos = point; - m_bDragThresholdExceeded = false; - - view->ResetSelectionRegion(); - - Vec3 pos = view->SnapToGrid(view->ViewToWorld(point)); - - // Swap X/Y - int unitSize = 1; - float hx = pos.y / unitSize; - float hy = pos.x / unitSize; - float hz = GetIEditor()->GetTerrainElevation(pos.x, pos.y); - - char szNewStatusText[512]; - sprintf_s(szNewStatusText, "Heightmap Coordinates: HX:%g HY:%g HZ:%g", hx, hy, hz); - GetIEditor()->SetStatusText(szNewStatusText); - - // Get control key status. - const bool bAltClick = (Qt::AltModifier & QApplication::queryKeyboardModifiers()); - bool bCtrlClick = (nFlags & MK_CONTROL); - bool bShiftClick = (nFlags & MK_SHIFT); - - bool bAddSelect = bCtrlClick; - bool bUnselect = bAltClick; - bool bNoRemoveSelection = bAddSelect || bUnselect; - - // Check deep selection mode activated - // The Deep selection has two mode. - // The normal mode pops the context menu, another is the cyclic selection on clinking. - const bool bTabPressed = CheckVirtualKey(Qt::Key_Tab); - const bool bZKeyPressed = CheckVirtualKey(Qt::Key_Z); - - CDeepSelection::EDeepSelectionMode dsMode = - (bTabPressed ? (bZKeyPressed ? CDeepSelection::DSM_POP : CDeepSelection::DSM_CYCLE) : CDeepSelection::DSM_NONE); - - bool bLockSelection = GetIEditor()->IsSelectionLocked(); - - int numUnselected = 0; - int numSelected = 0; - - // m_activeAxis = 0; - - HitContext hitInfo; - hitInfo.view = view; - if (bAddSelect || bUnselect) - { - // If adding or removing selection from the object, ignore hitting selection axis. - hitInfo.bIgnoreAxis = true; - } - - if (dsMode == CDeepSelection::DSM_POP) - { - m_pDeepSelection->Reset(true); - m_pDeepSelection->SetMode(dsMode); - hitInfo.pDeepSelection = m_pDeepSelection; - } - else if (dsMode == CDeepSelection::DSM_CYCLE) - { - if (!m_pDeepSelection->OnCycling(point)) - { - // Start of the deep selection cycling mode. - m_pDeepSelection->Reset(false); - m_pDeepSelection->SetMode(dsMode); - hitInfo.pDeepSelection = m_pDeepSelection; - } - } - else - { - if (m_pDeepSelection->GetPreviousMode() == CDeepSelection::DSM_NONE) - { - m_pDeepSelection->Reset(true); - } - - m_pDeepSelection->SetMode(CDeepSelection::DSM_NONE); - hitInfo.pDeepSelection = 0; - } - - if (view->HitTest(point, hitInfo)) - { - if (hitInfo.axis != 0) - { - GetIEditor()->SetAxisConstraints((AxisConstrains)hitInfo.axis); - bLockSelection = true; - } - if (hitInfo.axis != 0) - { - view->SetAxisConstrain(hitInfo.axis); - } - - - ////////////////////////////////////////////////////////////////////////// - // Deep Selection - CheckDeepSelection(hitInfo, view); - } - - CBaseObject* hitObj = hitInfo.object; - - int editMode = GetIEditor()->GetEditMode(); - - Matrix34 userTM = GetIEditor()->GetViewManager()->GetGrid()->GetMatrix(); - - if (hitObj) - { - Matrix34 tm = hitInfo.object->GetWorldTM(); - tm.OrthonormalizeFast(); - view->SetConstructionMatrix(COORDS_LOCAL, tm); - if (hitInfo.object->GetParent()) - { - Matrix34 parentTM = hitInfo.object->GetParent()->GetWorldTM(); - parentTM.OrthonormalizeFast(); - parentTM.SetTranslation(tm.GetTranslation()); - view->SetConstructionMatrix(COORDS_PARENT, parentTM); - } - else - { - Matrix34 parentTM; - parentTM.SetIdentity(); - parentTM.SetTranslation(tm.GetTranslation()); - view->SetConstructionMatrix(COORDS_PARENT, parentTM); - } - userTM.SetTranslation(tm.GetTranslation()); - view->SetConstructionMatrix(COORDS_USERDEFINED, userTM); - - Matrix34 viewTM = view->GetViewTM(); - viewTM.SetTranslation(tm.GetTranslation()); - view->SetConstructionMatrix(COORDS_VIEW, viewTM); - } - else - { - Matrix34 tm; - tm.SetIdentity(); - tm.SetTranslation(pos); - userTM.SetTranslation(pos); - view->SetConstructionMatrix(COORDS_LOCAL, tm); - view->SetConstructionMatrix(COORDS_PARENT, tm); - view->SetConstructionMatrix(COORDS_USERDEFINED, userTM); - } - - if (editMode != eEditModeTool) - { - // Check for Move to position. - if (bCtrlClick && bShiftClick && !hitInfo.object) - { - // Ctrl-Click on terrain will move selected objects to specified location. - MoveSelectionToPos(view, pos, bAltClick, point); - bLockSelection = true; - } - else if (bCtrlClick && bShiftClick && hitInfo.object) - { - const int nPickFlag = CSurfaceInfoPicker::ePOG_All; - view->BeginUndo(); - CSelectionGroup* pSelection = GetIEditor()->GetSelection(); - const int numObjects = pSelection->GetCount(); - for (int objectIndex = 0;objectIndex < numObjects;++objectIndex) - { - CBaseObject* m_curObj = pSelection->GetObject(objectIndex); - CSurfaceInfoPicker::CExcludedObjects excludeObjects; - excludeObjects.Add(m_curObj); - SRayHitInfo hitInfo2; - CSurfaceInfoPicker surfacePicker; - if (surfacePicker.Pick(point, hitInfo2, &excludeObjects, nPickFlag)) - { - m_curObj->SetPos(hitInfo2.vHitPos); - if (bAltClick) - { - Quat nq; - Vec3 zaxis = m_curObj->GetRotation() * Vec3(AZ::Vector3::CreateAxisZ()); - zaxis.Normalize(); - nq.SetRotationV0V1(zaxis, hitInfo2.vHitNormal); - m_curObj->SetRotation(nq * m_curObj->GetRotation()); - } - } - - } - AzToolsFramework::ScopedUndoBatch undo("Transform"); - view->AcceptUndo("Move Selection"); - bLockSelection = true; - } - } - - if (editMode == eEditModeMove) - { - if (!bNoRemoveSelection) - { - SetCommandMode(MoveMode); - } - - if (hitObj && hitObj->IsSelected() && !bNoRemoveSelection) - { - bLockSelection = true; - } - } - else if (editMode == eEditModeRotate) - { - if (!bNoRemoveSelection) - { - SetCommandMode(RotateMode); - } - if (hitObj && hitObj->IsSelected() && !bNoRemoveSelection) - { - bLockSelection = true; - } - } - else if (editMode == eEditModeScale) - { - if (!bNoRemoveSelection) - { - GetIEditor()->GetSelection()->StartScaling(); - SetCommandMode(ScaleMode); - } - - if (hitObj && hitObj->IsSelected() && !bNoRemoveSelection) - { - bLockSelection = true; - } - } - else if (hitObj != 0 && GetIEditor()->GetSelectedObject() == hitObj && !bAddSelect && !bUnselect) - { - bLockSelection = true; - } - - if (!bLockSelection) - { - // If not selection locked. - view->BeginUndo(); - - if (!bNoRemoveSelection) - { - // Current selection should be cleared - numUnselected = GetIEditor()->GetObjectManager()->ClearSelection(); - } - - if (hitObj) - { - numSelected = 1; - - if (!bUnselect) - { - if (hitObj->IsSelected()) - { - bUnselect = true; - } - } - - if (!bUnselect) - { - GetIEditor()->GetObjectManager()->SelectObject(hitObj, true); - } - else - { - GetIEditor()->GetObjectManager()->UnselectObject(hitObj); - } - } - if (view->IsUndoRecording()) - { - // When a designer object is selected, the update of the designer object can cause a change of a edit tool, which will makes this objectmode tool pointer invalid. - // so the update of objects must run on only pure idle time. - // view->AcceptUndo method calls the OnIdle() function in the app, which this is not a right timing to updates all, I think. - Jaesik Hwang. - GetIEditor()->GetObjectManager()->SetSkipUpdate(true); - view->AcceptUndo("Select Object(s)"); - GetIEditor()->GetObjectManager()->SetSkipUpdate(false); - } - - if ((numSelected == 0 || editMode == eEditModeSelect)) - { - // If object is not selected. - // Capture mouse input for this window. - SetCommandMode(SelectMode); - } - } - - if (GetCommandMode() == MoveMode || - GetCommandMode() == RotateMode || - GetCommandMode() == ScaleMode) - { - view->BeginUndo(); - - AzToolsFramework::EntityIdList selectedEntities; - AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult( - selectedEntities, - &AzToolsFramework::ToolsApplicationRequests::Bus::Events::GetSelectedEntities); - } - - ////////////////////////////////////////////////////////////////////////// - // Change cursor, must be before Capture mouse. - ////////////////////////////////////////////////////////////////////////// - SetObjectCursor(view, hitObj, true); - - ////////////////////////////////////////////////////////////////////////// - view->CaptureMouse(); - ////////////////////////////////////////////////////////////////////////// - - UpdateStatusText(); - - m_bTransformChanged = false; - - if (m_pDeepSelection->GetMode() == CDeepSelection::DSM_POP) - { - return OnLButtonUp(view, nFlags, point); - } - - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CObjectMode::OnLButtonUp(CViewport* view, [[maybe_unused]] int nFlags, const QPoint& point) -{ - AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Editor); - - if (GetIEditor()->IsInGameMode() || GetIEditor()->IsInSimulationMode()) - { - // Ignore clicks while in game. - return true; - } - - if (m_bTransformChanged) - { - CSelectionGroup* pSelection = GetIEditor()->GetSelection(); - if (pSelection) - { - pSelection->FinishChanges(); - } - m_bTransformChanged = false; - } - - if (GetCommandMode() == ScaleMode) - { - Vec3 scale; - GetIEditor()->GetSelection()->FinishScaling(GetScale(view, point, scale), - GetIEditor()->GetReferenceCoordSys()); - } - - if (GetCommandMode() == MoveMode) - { - m_bDragThresholdExceeded = false; - } - - // Reset the status bar caption - GetIEditor()->SetStatusText("Ready"); - - ////////////////////////////////////////////////////////////////////////// - if (view->IsUndoRecording()) - { - if (GetCommandMode() == MoveMode) - { - { - AzToolsFramework::ScopedUndoBatch undo("Move"); - } - view->AcceptUndo("Move Selection"); - } - else if (GetCommandMode() == RotateMode) - { - { - AzToolsFramework::ScopedUndoBatch undo("Rotate"); - } - view->AcceptUndo("Rotate Selection"); - } - else if (GetCommandMode() == ScaleMode) - { - { - AzToolsFramework::ScopedUndoBatch undo("Scale"); - } - view->AcceptUndo("Scale Selection"); - } - else - { - view->CancelUndo(); - } - } - ////////////////////////////////////////////////////////////////////////// - - if (GetCommandMode() == SelectMode && (!GetIEditor()->IsSelectionLocked())) - { - const bool bUnselect = (Qt::AltModifier & QApplication::queryKeyboardModifiers()); - QRect selectRect = view->GetSelectionRectangle(); - if (!selectRect.isEmpty()) - { - // Ignore too small rectangles. - if (selectRect.width() > 5 && selectRect.height() > 5) - { - GetIEditor()->GetObjectManager()->SelectObjectsInRect(view, selectRect, !bUnselect); - UpdateStatusText(); - } - } - - if (GetIEditor()->GetEditMode() == eEditModeSelectArea) - { - AABB box; - GetIEditor()->GetSelectedRegion(box); - - ////////////////////////////////////////////////////////////////////////// - GetIEditor()->ClearSelection(); - } - } - // Release the restriction of the cursor - view->ReleaseMouse(); - - if (GetCommandMode() == ScaleMode || GetCommandMode() == MoveMode || GetCommandMode() == RotateMode) - { - AzToolsFramework::EntityIdList selectedEntities; - AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult( - selectedEntities, - &AzToolsFramework::ToolsApplicationRequests::Bus::Events::GetSelectedEntities); - - AzToolsFramework::EditorTransformChangeNotificationBus::Broadcast( - &AzToolsFramework::EditorTransformChangeNotificationBus::Events::OnEntityTransformChanged, - selectedEntities); - } - - if (GetIEditor()->GetEditMode() != eEditModeSelectArea) - { - view->ResetSelectionRegion(); - } - // Reset selected rectangle. - view->SetSelectionRectangle(QRect()); - - // Restore default editor axis constrain. - if (GetIEditor()->GetAxisConstrains() != view->GetAxisConstrain()) - { - view->SetAxisConstrain(GetIEditor()->GetAxisConstrains()); - } - - SetCommandMode(NothingMode); - - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CObjectMode::OnLButtonDblClk(CViewport* view, int nFlags, const QPoint& point) -{ - IEditor* editor = GetIEditor(); - - // If shift clicked, Move the camera to this place. - if (nFlags & MK_SHIFT) - { - // Get the heightmap coordinates for the click position - Vec3 v = view->ViewToWorld(point); - if (!(v.x == 0 && v.y == 0 && v.z == 0)) - { - Matrix34 tm = view->GetViewTM(); - Vec3 p = tm.GetTranslation(); - float height = p.z - editor->GetTerrainElevation(p.x, p.y); - if (height < 1) - { - height = 1; - } - p.x = v.x; - p.y = v.y; - p.z = editor->GetTerrainElevation(p.x, p.y) + height; - tm.SetTranslation(p); - view->SetViewTM(tm); - } - } - else - { - // Check if double clicked on object. - HitContext hitInfo; - view->HitTest(point, hitInfo); - - if (CBaseObject* hitObj = hitInfo.object) - { - // check if the object is an AZ::Entity - if ((hitObj->GetType() == OBJTYPE_AZENTITY)) - { - if (CRenderViewport* renderViewport = viewport_cast(view)) - { - // if we double clicked on an AZ::Entity/Component, build a mouse interaction and send a double - // click event to the EditorInteractionSystemViewportSelectionRequestBus. if we have double clicked - // on a component supporting ComponentMode, we will enter it. note: this is to support entering - // ComponentMode with a double click using the old viewport interaction model - const auto mouseInteraction = renderViewport->BuildMouseInteraction( - Qt::LeftButton, QGuiApplication::queryKeyboardModifiers(), - renderViewport->ViewportToWidget(point)); - - using AzToolsFramework::EditorInteractionSystemViewportSelectionRequestBus; - using AzToolsFramework::ViewportInteraction::MouseInteractionEvent; - using AzToolsFramework::ViewportInteraction::MouseEvent; - - EditorInteractionSystemViewportSelectionRequestBus::Event( - AzToolsFramework::GetEntityContextId(), - &EditorInteractionSystemViewportSelectionRequestBus::Events::InternalHandleMouseViewportInteraction, - MouseInteractionEvent(mouseInteraction, MouseEvent::DoubleClick)); - } - } - - // Fire double click event on hit object. - hitObj->OnEvent(EVENT_DBLCLICK); - } - else - { - if (!editor->IsSelectionLocked()) - { - editor->GetObjectManager()->ClearSelection(); - } - } - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CObjectMode::OnRButtonDown([[maybe_unused]] CViewport* view, [[maybe_unused]] int nFlags, [[maybe_unused]] const QPoint& point) -{ - if (gSettings.viewports.bEnableContextMenu && !GetIEditor()->IsInSimulationMode()) - { - m_openContext = true; - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CObjectMode::OnRButtonUp(CViewport* view, [[maybe_unused]] int nFlags, const QPoint& point) -{ - if (m_openContext) - { - bool selectionLocked = GetIEditor()->IsSelectionLocked(); - - // Check if right clicked on object. - HitContext hitInfo; - hitInfo.bIgnoreAxis = true; // ignore gizmo - view->HitTest(point, hitInfo); - - QPointer object; - - if (selectionLocked) - { - if (hitInfo.object) - { - // Save so we can use this for the context menu later - object = hitInfo.object; - } - } - else - { - Vec3 pos = view->SnapToGrid(view->ViewToWorld(point)); - Matrix34 userTM = GetIEditor()->GetViewManager()->GetGrid()->GetMatrix(); - - if (hitInfo.object) - { - Matrix34 tm = hitInfo.object->GetWorldTM(); - tm.OrthonormalizeFast(); - view->SetConstructionMatrix(COORDS_LOCAL, tm); - if (hitInfo.object->GetParent()) - { - Matrix34 parentTM = hitInfo.object->GetParent()->GetWorldTM(); - parentTM.OrthonormalizeFast(); - parentTM.SetTranslation(tm.GetTranslation()); - view->SetConstructionMatrix(COORDS_PARENT, parentTM); - } - else - { - Matrix34 parentTM; - parentTM.SetIdentity(); - parentTM.SetTranslation(tm.GetTranslation()); - view->SetConstructionMatrix(COORDS_PARENT, parentTM); - } - userTM.SetTranslation(tm.GetTranslation()); - view->SetConstructionMatrix(COORDS_USERDEFINED, userTM); - - Matrix34 viewTM = view->GetViewTM(); - viewTM.SetTranslation(tm.GetTranslation()); - view->SetConstructionMatrix(COORDS_VIEW, viewTM); - - CSelectionGroup* selections = GetIEditor()->GetObjectManager()->GetSelection(); - - // hit object has not been selected - if (!selections->IsContainObject(hitInfo.object)) - { - view->BeginUndo(); - GetIEditor()->GetObjectManager()->ClearSelection(); - GetIEditor()->GetObjectManager()->SelectObject(hitInfo.object, true); - view->AcceptUndo("Select Object(s)"); - } - - // Save so we can use this for the context menu later - object = hitInfo.object; - } - else - { - Matrix34 tm; - tm.SetIdentity(); - tm.SetTranslation(pos); - userTM.SetTranslation(pos); - view->SetConstructionMatrix(COORDS_LOCAL, tm); - view->SetConstructionMatrix(COORDS_PARENT, tm); - view->SetConstructionMatrix(COORDS_USERDEFINED, userTM); - - view->BeginUndo(); - GetIEditor()->GetObjectManager()->ClearSelection(); - view->AcceptUndo("Select Object(s)"); - } - } - - // CRenderViewport hides the cursor when the mouse button is pressed - // and shows it when button is released. If we exec the context menu directly, then we block - // and the cursor stays invisible while the menu is open so instead, we queue it to happen - // after the mouse button release is finished - QTimer::singleShot(0, this, [point, view, object]() - { - QMenu menu(viewport_cast(view)); - - if (object) - { - object->OnContextMenu(&menu); - } - - // Populate global context menu. - int contextMenuFlag = 0; - EBUS_EVENT(AzToolsFramework::EditorEvents::Bus, - PopulateEditorGlobalContextMenu, - &menu, - AZ::Vector2(static_cast(point.x()), static_cast(point.y())), - contextMenuFlag); - - if (!menu.isEmpty()) - { - menu.exec(QCursor::pos()); - } - }); - } - - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CObjectMode::OnMButtonDown(CViewport* view, [[maybe_unused]] int nFlags, const QPoint& point) -{ - if (GetIEditor()->GetGameEngine()->GetSimulationMode()) - { - // Get control key status. - const bool bCtrlClick = (Qt::ControlModifier & QApplication::queryKeyboardModifiers()); - - if (bCtrlClick) - { - // In simulation mode awake objects under the cursor when Ctrl+MButton pressed. - AwakeObjectAtPoint(view, point); - return true; - } - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -void CObjectMode::AwakeObjectAtPoint(CViewport* view, const QPoint& point) -{ - // In simulation mode awake objects under the cursor. - // Check if double clicked on object. - HitContext hitInfo; - view->HitTest(point, hitInfo); - CBaseObject* hitObj = hitInfo.object; - if (hitObj) - { - } -} - -////////////////////////////////////////////////////////////////////////// -void CObjectMode::MoveSelectionToPos(CViewport* view, Vec3& pos, bool align, const QPoint& point) -{ - view->BeginUndo(); - // Find center of selection. - Vec3 center = GetIEditor()->GetSelection()->GetCenter(); - GetIEditor()->GetSelection()->Move(pos - center, CSelectionGroup::eMS_None, true, point); - - if (align) - { - GetIEditor()->GetSelection()->Align(); - } - - // This will capture any entity state changes that occurred - // during the move. - { - AzToolsFramework::ScopedUndoBatch undo("Transform"); - } - - view->AcceptUndo("Move Selection"); -} - -////////////////////////////////////////////////////////////////////////// -bool CObjectMode::OnMouseMove(CViewport* view, int nFlags, const QPoint& point) -{ - AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Editor); - - if (GetIEditor()->IsInGameMode() || GetIEditor()->IsInSimulationMode()) - { - // Ignore while in game. - return true; - } - - // Has the mouse been intentionally moved or could this be a small jump in movement due to right clicking? - if (std::abs(m_prevMousePos.x() - point.x()) > 2 || std::abs(m_prevMousePos.y() - point.y()) > 2) - { - // This was an intentional mouse movement, disable the context menu - m_openContext = false; - } - m_prevMousePos = point; - SetObjectCursor(view, 0); - - // get world/local coordinate system setting. - int coordSys = GetIEditor()->GetReferenceCoordSys(); - - // get current axis constrains. - if (GetCommandMode() == MoveMode) - { - if (!m_bDragThresholdExceeded) - { - int halfLength = gSettings.viewports.nDragSquareSize / 2; - QRect rcDrag(m_cMouseDownPos, QSize(0,0)); - rcDrag.adjust(-halfLength, -halfLength, halfLength, halfLength); - - if (!rcDrag.contains(point)) - { - m_bDragThresholdExceeded = true; - m_lastValidMoveVector = Vec3(0, 0, 0); - } - else - { - return true; - } - } - - GetIEditor()->RestoreUndo(); - - Vec3 v; - //m_cMouseDownPos = point; - CSelectionGroup::EMoveSelectionFlag selectionFlag = CSelectionGroup::eMS_None; - if (view->GetAxisConstrain() == AXIS_TERRAIN) - { - selectionFlag = CSelectionGroup::eMS_FollowTerrain; - Vec3 p1 = view->SnapToGrid(view->ViewToWorld(m_cMouseDownPos)); - Vec3 p2 = view->SnapToGrid(view->ViewToWorld(point)); - v = p2 - p1; - v.z = 0; - m_lastValidMoveVector = v; - } - else - { - Vec3 p1 = view->MapViewToCP(m_cMouseDownPos); - Vec3 p2 = view->MapViewToCP(point); - - if (p1.IsZero() || p2.IsZero()) - { - v = m_lastValidMoveVector; - } - else - { - v = view->GetCPVector(p1, p2); - m_lastValidMoveVector = v; - } - - //Matrix invParent = m_parentConstructionMatrix; - //invParent.Invert(); - //p1 = invParent.TransformVector(p1); - //p2 = invParent.TransformVector(p2); - //v = p2 - p1; - } - - if ((nFlags & MK_CONTROL) && !(nFlags & MK_SHIFT)) - { - selectionFlag = CSelectionGroup::eMS_FollowGeometryPosNorm; - } - - if (!v.IsEquivalent(Vec3(0, 0, 0))) - { - m_bTransformChanged = true; - } - - CTrackViewSequence* pSequence = GetIEditor()->GetAnimation()->GetSequence(); - { - CTrackViewSequenceNoNotificationContext context(pSequence); - GetIEditor()->GetSelection()->Move(v, selectionFlag, coordSys, point); - } - - if (pSequence) - { - pSequence->OnKeysChanged(); - } - - return true; - } - else if (GetCommandMode() == ScaleMode) - { - GetIEditor()->RestoreUndo(); - Vec3 scale; - GetIEditor()->GetSelection()->Scale(GetScale(view, point, scale), coordSys); - if (!scale.IsEquivalent(Vec3(0, 0, 0))) - { - m_bTransformChanged = true; - } - } - else if (GetCommandMode() == SelectMode) - { - // Ignore select when selection locked. - if (GetIEditor()->IsSelectionLocked()) - { - return true; - } - - QRect rc(m_cMouseDownPos, point - QPoint(1, 1)); - if (GetIEditor()->GetEditMode() == eEditModeSelectArea) - { - view->OnDragSelectRectangle(rc, false); - } - else - { - view->SetSelectionRectangle(rc); - } - //else - //OnDragSelectRectangle( CPoint(rc.left,rc.top),CPoint(rc.right,rc.bottom),true ); - } - - if (!(nFlags & MK_RBUTTON || nFlags & MK_MBUTTON)) - { - // Track mouse movements. - HitContext hitInfo; - if (view->HitTest(point, hitInfo)) - { - SetObjectCursor(view, hitInfo.object); - } - - HandleMoveByFaceNormal(hitInfo); - } - - if ((nFlags & MK_MBUTTON) && GetIEditor()->GetGameEngine()->GetSimulationMode()) - { - // Get control key status. - const bool bCtrlClick = (Qt::ControlModifier & QApplication::queryKeyboardModifiers()); - - if (bCtrlClick) - { - // In simulation mode awake objects under the cursor when Ctrl+MButton pressed. - AwakeObjectAtPoint(view, point); - } - } - - UpdateStatusText(); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CObjectMode::OnMouseLeave(CViewport* view) -{ - if (GetIEditor()->IsInGameMode() || GetIEditor()->IsInSimulationMode()) - { - // Ignore while in game. - return true; - } - - m_openContext = false; - SetObjectCursor(view, 0); - - return true; -} - -////////////////////////////////////////////////////////////////////////// -void CObjectMode::SetObjectCursor(CViewport* view, CBaseObject* hitObj, [[maybe_unused]] bool bChangeNow) -{ - EStdCursor cursor = STD_CURSOR_DEFAULT; - QString m_cursorStr; - QString supplementaryCursor = ""; - - CBaseObject* pMouseOverObject = NULL; - if (!GuidUtil::IsEmpty(m_MouseOverObject)) - { - pMouseOverObject = GetIEditor()->GetObjectManager()->FindObject(m_MouseOverObject); - } - - //HCURSOR hPrevCursor = m_hCurrCursor; - if (pMouseOverObject) - { - pMouseOverObject->SetHighlight(false); - } - if (hitObj) - { - m_MouseOverObject = hitObj->GetId(); - } - else - { - m_MouseOverObject = GUID_NULL; - } - pMouseOverObject = hitObj; - bool bHitSelectedObject = false; - if (pMouseOverObject) - { - if (GetCommandMode() != SelectMode && !GetIEditor()->IsSelectionLocked()) - { - if (pMouseOverObject->CanBeHightlighted()) - { - pMouseOverObject->SetHighlight(true); - } - - m_cursorStr = pMouseOverObject->GetName(); - - QString comment(pMouseOverObject->GetComment()); - if (!comment.isEmpty()) - { - m_cursorStr += "\n"; - m_cursorStr += comment; - } - - QString warnings(pMouseOverObject->GetWarningsText()); - if (!warnings.isEmpty()) - { - m_cursorStr += warnings; - } - - cursor = STD_CURSOR_HIT; - if (pMouseOverObject->IsSelected()) - { - bHitSelectedObject = true; - } - - if (pMouseOverObject->GetType() == OBJTYPE_AZENTITY) - { - CComponentEntityObject* componentEntity = static_cast(pMouseOverObject); - - bool isEditorOnly = false; - AzToolsFramework::EditorOnlyEntityComponentRequestBus::EventResult(isEditorOnly, componentEntity->GetAssociatedEntityId(), &AzToolsFramework::EditorOnlyEntityComponentRequests::IsEditorOnlyEntity); - AZ::Entity* entity = nullptr; - AZ::ComponentApplicationBus::BroadcastResult(entity, &AZ::ComponentApplicationBus::Events::FindEntity, componentEntity->GetAssociatedEntityId()); - const bool isInitiallyActive = entity ? entity->IsRuntimeActiveByDefault() : true; - - if (isEditorOnly) - { - supplementaryCursor = "\n[" + QObject::tr("Editor Only") + "]"; - } - else if (!isInitiallyActive) - { - supplementaryCursor = "\n[" + QObject::tr("Inactive") + "]"; - } - } - } - - QString tooltip = pMouseOverObject->GetTooltip(); - if (!tooltip.isEmpty()) - { - m_cursorStr += "\n"; - m_cursorStr += tooltip; - } - ; - } - else - { - m_cursorStr = ""; - cursor = STD_CURSOR_DEFAULT; - } - // Get control key status. - const auto modifiers = QApplication::queryKeyboardModifiers(); - const bool bAltClick = (Qt::AltModifier & modifiers); - const bool bCtrlClick = (Qt::ControlModifier & modifiers); - const bool bShiftClick = (Qt::ShiftModifier & modifiers); - - bool bAddSelect = bCtrlClick && !bShiftClick; - bool bUnselect = bAltClick; - bool bNoRemoveSelection = bAddSelect || bUnselect; - - bool bLockSelection = GetIEditor()->IsSelectionLocked(); - - if (GetCommandMode() == SelectMode || GetCommandMode() == NothingMode) - { - if (bAddSelect) - { - cursor = STD_CURSOR_SEL_PLUS; - } - if (bUnselect) - { - cursor = STD_CURSOR_SEL_MINUS; - } - - if ((bHitSelectedObject && !bNoRemoveSelection) || bLockSelection) - { - int editMode = GetIEditor()->GetEditMode(); - if (editMode == eEditModeMove) - { - cursor = STD_CURSOR_MOVE; - } - else if (editMode == eEditModeRotate) - { - cursor = STD_CURSOR_ROTATE; - } - else if (editMode == eEditModeScale) - { - cursor = STD_CURSOR_SCALE; - } - } - } - else if (GetCommandMode() == MoveMode) - { - cursor = STD_CURSOR_MOVE; - } - else if (GetCommandMode() == RotateMode) - { - cursor = STD_CURSOR_ROTATE; - } - else if (GetCommandMode() == ScaleMode) - { - cursor = STD_CURSOR_SCALE; - } - - AZ::u32 cursorId = static_cast(cursor); - AZStd::string cursorStr = m_cursorStr.toUtf8().data(); - EBUS_EVENT(AzToolsFramework::EditorRequests::Bus, - UpdateObjectModeCursor, - cursorId, - cursorStr); - cursor = static_cast(cursorId); - m_cursorStr = cursorStr.c_str(); - - view->SetCurrentCursor(cursor, m_cursorStr); - view->SetSupplementaryCursorStr(supplementaryCursor); -} - -////////////////////////////////////////////////////////////////////////// -void CObjectMode::RegisterTool(CRegistrationContext& rc) -{ - rc.pClassFactory->RegisterClass(new CQtViewClass("EditTool.ObjectMode", "Select", ESYSTEM_CLASS_EDITTOOL)); -} - -////////////////////////////////////////////////////////////////////////// -void CObjectMode::UpdateStatusText() -{ - QString str; - int nCount = GetIEditor()->GetSelection()->GetCount(); - if (nCount > 0) - { - str = tr("%1 Object(s) Selected").arg(nCount); - } - else - { - str = tr("No Selection"); - } - SetStatusText(str); -} - -////////////////////////////////////////////////////////////////////////// -void CObjectMode::CheckDeepSelection(HitContext& hitContext, CViewport* view) -{ - if (hitContext.pDeepSelection) - { - m_pDeepSelection->CollectCandidate(hitContext.dist, gSettings.deepSelectionSettings.fRange); - } - - if (m_pDeepSelection->GetCandidateObjectCount() > 1) - { - // Deep Selection Pop Mode - if (m_pDeepSelection->GetMode() == CDeepSelection::DSM_POP) - { - // Show a sorted pop-up menu for selecting a bone. - QMenu popUpDeepSelect(qobject_cast(view->qobject())); - - for (int i = 0; i < m_pDeepSelection->GetCandidateObjectCount(); ++i) - { - QAction* action = popUpDeepSelect.addAction(QString(m_pDeepSelection->GetCandidateObject(i)->GetName())); - action->setData(i); - } - - QAction* userSelection = popUpDeepSelect.exec(QCursor::pos()); - if (userSelection) - { - int nSelect = userSelection->data().toInt(); - - // Update HitContext hitInfo. - hitContext.object = m_pDeepSelection->GetCandidateObject(nSelect); - m_pDeepSelection->ExcludeHitTest(nSelect); - } - } - else if (m_pDeepSelection->GetMode() == CDeepSelection::DSM_CYCLE) - { - int selPos = m_pDeepSelection->GetCurrentSelectPos(); - hitContext.object = m_pDeepSelection->GetCandidateObject(selPos + 1); - m_pDeepSelection->ExcludeHitTest(selPos + 1); - } - } -} - -Vec3& CObjectMode::GetScale(const CViewport* view, const QPoint& point, Vec3& OutScale) -{ - float ay = 1.0f - 0.01f * (point.y() - m_cMouseDownPos.y()); - - if (ay < 0.01f) - { - ay = 0.01f; - } - - Vec3 scl(ay, ay, ay); - - int axisConstrain = view->GetAxisConstrain(); - - if (axisConstrain < AXIS_XYZ && GetIEditor()->IsAxisVectorLocked()) - { - axisConstrain = AXIS_XYZ; - } - - switch (axisConstrain) - { - case AXIS_X: - scl(ay, 1, 1); - break; - case AXIS_Y: - scl(1, ay, 1); - break; - case AXIS_Z: - scl(1, 1, ay); - break; - case AXIS_XY: - scl(ay, ay, ay); - break; - case AXIS_XZ: - scl(ay, ay, ay); - break; - case AXIS_YZ: - scl(ay, ay, ay); - break; - case AXIS_XYZ: - scl(ay, ay, ay); - break; - case AXIS_TERRAIN: - scl(ay, ay, ay); - break; - } - ; - - OutScale = scl; - - return OutScale; -} - -////////////////////////////////////////////////////////////////////////// -// This callback is currently called only to handle the case of the 'move by the face normal'. -// Other movements of the object are handled in the 'CObjectMode::OnMouseMove()' method. -void CObjectMode::OnManipulatorDrag(CViewport* view, [[maybe_unused]] ITransformManipulator* pManipulator, QPoint& point0, [[maybe_unused]] QPoint& point1, const Vec3& value) -{ - RefCoordSys coordSys = GetIEditor()->GetReferenceCoordSys(); - int editMode = GetIEditor()->GetEditMode(); - - if (editMode == eEditModeMove) - { - GetIEditor()->RestoreUndo(); - CSelectionGroup* pSelGrp = GetIEditor()->GetSelection(); - - CSelectionGroup::EMoveSelectionFlag selectionFlag = view->GetAxisConstrain() == AXIS_TERRAIN ? CSelectionGroup::eMS_FollowTerrain : CSelectionGroup::eMS_None; - pSelGrp->Move(value, selectionFlag, coordSys, point0); - - if (m_pHitObject) - { - UpdateMoveByFaceNormGizmo(m_pHitObject); - } - } -} - -void CObjectMode::HandleMoveByFaceNormal([[maybe_unused]] HitContext& hitInfo) -{ - const bool bNKeyPressed = CheckVirtualKey(Qt::Key_N); - if (m_bMoveByFaceNormManipShown && !bNKeyPressed) - { - HideMoveByFaceNormGizmo(); - } -} - -void CObjectMode::UpdateMoveByFaceNormGizmo(CBaseObject* pHitObject) -{ - Matrix34 refFrame; - refFrame.SetIdentity(); - SubObjectSelectionReferenceFrameCalculator calculator(SO_ELEM_FACE); - pHitObject->CalculateSubObjectSelectionReferenceFrame(&calculator); - if (calculator.GetFrame(refFrame) == false) - { - HideMoveByFaceNormGizmo(); - } - else - { - ITransformManipulator* pManipulator = GetIEditor()->ShowTransformManipulator(true); - m_bMoveByFaceNormManipShown = true; - m_pHitObject = pHitObject; - - Matrix34 parentTM = pHitObject->GetWorldTM(); - Matrix34 userTM = GetIEditor()->GetViewManager()->GetGrid()->GetMatrix(); - parentTM.SetTranslation(refFrame.GetTranslation()); - userTM.SetTranslation(refFrame.GetTranslation()); - pManipulator->SetTransformation(COORDS_LOCAL, refFrame); - pManipulator->SetTransformation(COORDS_PARENT, parentTM); - pManipulator->SetTransformation(COORDS_USERDEFINED, userTM); - pManipulator->SetAlwaysUseLocal(true); - } -} - -void CObjectMode::HideMoveByFaceNormGizmo() -{ - GetIEditor()->ShowTransformManipulator(false); - m_bMoveByFaceNormManipShown = false; - m_pHitObject = NULL; -} - -#include - diff --git a/Code/Sandbox/Editor/EditMode/ObjectMode.h b/Code/Sandbox/Editor/EditMode/ObjectMode.h deleted file mode 100644 index a7919b2c47..0000000000 --- a/Code/Sandbox/Editor/EditMode/ObjectMode.h +++ /dev/null @@ -1,134 +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 : Object edit mode describe viewport input behavior when operating on objects. - - -#ifndef CRYINCLUDE_EDITOR_EDITMODE_OBJECTMODE_H -#define CRYINCLUDE_EDITOR_EDITMODE_OBJECTMODE_H -#pragma once - -// {87109FED-BDB5-4874-936D-338400079F58} -DEFINE_GUID(OBJECT_MODE_GUID, 0x87109fed, 0xbdb5, 0x4874, 0x93, 0x6d, 0x33, 0x84, 0x0, 0x7, 0x9f, 0x58); - -#include "EditTool.h" - -class CBaseObject; -class CDeepSelection; -/*! -* CObjectMode is an abstract base class for All Editing Tools supported by Editor. -* Edit tools handle specific editing modes in viewports. -*/ -class SANDBOX_API CObjectMode - : public CEditTool -{ - Q_OBJECT -public: - Q_INVOKABLE CObjectMode(QObject* parent = nullptr); - virtual ~CObjectMode(); - - static const GUID& GetClassID() { return OBJECT_MODE_GUID; } - - // Registration function. - static void RegisterTool(CRegistrationContext& rc); - - ////////////////////////////////////////////////////////////////////////// - // CEditTool implementation. - ////////////////////////////////////////////////////////////////////////// - virtual void BeginEditParams([[maybe_unused]] IEditor* ie, [[maybe_unused]] int flags) {}; - virtual void EndEditParams(); - virtual void Display(struct DisplayContext& dc); - virtual void DisplaySelectionPreview(struct DisplayContext& dc); - virtual void DrawSelectionPreview(struct DisplayContext& dc, CBaseObject* drawObject); - void DisplayExtraLightInfo(struct DisplayContext& dc); - - virtual bool MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags); - virtual bool OnKeyDown(CViewport* view, uint32 nChar, uint32 nRepCnt, uint32 nFlags); - virtual bool OnKeyUp(CViewport* view, uint32 nChar, uint32 nRepCnt, uint32 nFlags); - virtual bool OnSetCursor([[maybe_unused]] CViewport* vp) { return false; }; - - virtual void OnManipulatorDrag(CViewport* view, ITransformManipulator* pManipulator, QPoint& p0, QPoint& p1, const Vec3& value) override; - - bool IsUpdateUIPanel() override { return true; } - -protected: - enum ECommandMode - { - NothingMode = 0, - ScrollZoomMode, - SelectMode, - MoveMode, - RotateMode, - ScaleMode, - ScrollMode, - ZoomMode, - }; - - virtual bool OnLButtonDown(CViewport* view, int nFlags, const QPoint& point); - virtual bool OnLButtonDblClk(CViewport* view, int nFlags, const QPoint& point); - virtual bool OnLButtonUp(CViewport* view, int nFlags, const QPoint& point); - virtual bool OnRButtonDown(CViewport* view, int nFlags, const QPoint& point); - virtual bool OnRButtonUp(CViewport* view, int nFlags, const QPoint& point); - virtual bool OnMButtonDown(CViewport* view, int nFlags, const QPoint& point); - virtual bool OnMouseMove(CViewport* view, int nFlags, const QPoint& point); - virtual bool OnMouseLeave(CViewport* view); - - void SetCommandMode(ECommandMode mode) { m_commandMode = mode; } - ECommandMode GetCommandMode() const { return m_commandMode; } - - //! Ctrl-Click in move mode to move selected objects to given pos. - void MoveSelectionToPos(CViewport* view, Vec3& pos, bool align, const QPoint& point); - void SetObjectCursor(CViewport* view, CBaseObject* hitObj, bool bChangeNow = false); - - virtual void DeleteThis() { delete this; }; - - void UpdateStatusText(); - void AwakeObjectAtPoint(CViewport* view, const QPoint& point); - - void HideMoveByFaceNormGizmo(); - void HandleMoveByFaceNormal(HitContext& hitInfo); - void UpdateMoveByFaceNormGizmo(CBaseObject* pHitObject); - -protected: - - bool m_openContext; - -private: - void CheckDeepSelection(HitContext& hitContext, CViewport* view); - Vec3& GetScale(const CViewport* view, const QPoint& point, Vec3& OutScale); - - AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING - QPoint m_cMouseDownPos; - bool m_bDragThresholdExceeded; - ECommandMode m_commandMode; - - GUID m_MouseOverObject; - typedef std::vector TGuidContainer; - TGuidContainer m_PreviewGUIDs; - - _smart_ptr m_pDeepSelection; - - bool m_bMoveByFaceNormManipShown; - CBaseObject* m_pHitObject; - - bool m_bTransformChanged; - - QPoint m_prevMousePos = QPoint(0, 0); - - Vec3 m_lastValidMoveVector = Vec3(0, 0, 0); - AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING -}; - - - -#endif // CRYINCLUDE_EDITOR_EDITMODE_OBJECTMODE_H diff --git a/Code/Sandbox/Editor/EditMode/VertexSnappingModeTool.cpp b/Code/Sandbox/Editor/EditMode/VertexSnappingModeTool.cpp deleted file mode 100644 index a0a5492f55..0000000000 --- a/Code/Sandbox/Editor/EditMode/VertexSnappingModeTool.cpp +++ /dev/null @@ -1,430 +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" - -#if defined(AZ_PLATFORM_WINDOWS) -#include -#endif - -#include "VertexSnappingModeTool.h" - -// Editor -#include "Settings.h" -#include "Viewport.h" -#include "SurfaceInfoPicker.h" -#include "Material/Material.h" -#include "Util/KDTree.h" - - -// {3e008046-9269-41d7-82e2-07ffd7254c10} -DEFINE_GUID(VERTEXSNAPPING_MODE_GUID, 0x3e008046, 0x9269, 0x41d7, 0x82, 0xe2, 0x07, 0xff, 0xd7, 0x25, 0x4c, 0x10); - -bool FindNearestVertex(CBaseObject* pObject, CKDTree* pTree, const Vec3& vWorldRaySrc, const Vec3& vWorldRayDir, Vec3& outPos, Vec3& vOutHitPosOnCube) -{ - Matrix34 worldInvTM = pObject->GetWorldTM().GetInverted(); - Vec3 vRaySrc = worldInvTM.TransformPoint(vWorldRaySrc); - Vec3 vRayDir = worldInvTM.TransformVector(vWorldRayDir); - Vec3 vLocalCameraPos = worldInvTM.TransformPoint(gEnv->pRenderer->GetCamera().GetPosition()); - Vec3 vPos; - Vec3 vHitPosOnCube; - - if (pTree) - { - if (pTree->FindNearestVertex(vRaySrc, vRayDir, gSettings.vertexSnappingSettings.vertexCubeSize, vLocalCameraPos, vPos, vHitPosOnCube)) - { - outPos = pObject->GetWorldTM().TransformPoint(vPos); - vOutHitPosOnCube = pObject->GetWorldTM().TransformPoint(vHitPosOnCube); - return true; - } - } - else - { - // for objects without verts, the pivot is the nearest vertex - // return true if the ray hits the bounding box - outPos = pObject->GetWorldPos(); - - AABB bbox; - pObject->GetBoundBox(bbox); - if (bbox.IsContainPoint(vWorldRaySrc)) - { - // if ray starts inside bounding box, reject cases where pivot is behind the ray - float hitDistAlongRay = vWorldRayDir.Dot(outPos - vWorldRaySrc); - if (hitDistAlongRay >= 0.f) - { - vHitPosOnCube = vWorldRaySrc + (vWorldRayDir * hitDistAlongRay); - return true; - } - } - else if (Intersect::Ray_AABB(vWorldRaySrc, vWorldRayDir, bbox, vOutHitPosOnCube)) - { - return true; - } - } - - return false; -} - -CVertexSnappingModeTool::CVertexSnappingModeTool() -{ - m_modeStatus = eVSS_SelectFirstVertex; - m_bHit = false; -} - -CVertexSnappingModeTool::~CVertexSnappingModeTool() -{ - std::map::iterator ii = m_ObjectKdTreeMap.begin(); - for (; ii != m_ObjectKdTreeMap.end(); ++ii) - { - delete ii->second; - } -} - -const GUID& CVertexSnappingModeTool::GetClassID() -{ - return VERTEXSNAPPING_MODE_GUID; -} - -void CVertexSnappingModeTool::RegisterTool(CRegistrationContext& rc) -{ - rc.pClassFactory->RegisterClass(new CQtViewClass("EditTool.VertexSnappingMode", "Select", ESYSTEM_CLASS_EDITTOOL)); -} - -bool CVertexSnappingModeTool::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags) -{ - CBaseObjectPtr pExcludedObject = NULL; - if (m_modeStatus == eVSS_MoveSelectVertexToAnotherVertex) - { - pExcludedObject = m_SelectionInfo.m_pObject; - } - - m_bHit = HitTest(view, point, pExcludedObject, m_vHitVertex, m_pHitObject, m_Objects); - - if (event == eMouseLDown && m_bHit && m_pHitObject && m_modeStatus == eVSS_SelectFirstVertex) - { - m_modeStatus = eVSS_MoveSelectVertexToAnotherVertex; - m_SelectionInfo.m_pObject = m_pHitObject; - m_SelectionInfo.m_vPos = m_vHitVertex; - - GetIEditor()->BeginUndo(); - m_pHitObject->StoreUndo("Vertex Snapping", true); - - view->SetCapture(); - } - - if (m_modeStatus == eVSS_MoveSelectVertexToAnotherVertex) - { - if (event == eMouseLUp) - { - m_modeStatus = eVSS_SelectFirstVertex; - - GetIEditor()->AcceptUndo("Vertex Snapping"); - view->ReleaseMouse(); - } - else if ((flags & MK_LBUTTON) && event == eMouseMove) - { - Vec3 vOffset = m_SelectionInfo.m_pObject->GetWorldPos() - m_SelectionInfo.m_vPos; - m_SelectionInfo.m_pObject->SetWorldPos(m_vHitVertex + vOffset); - m_SelectionInfo.m_vPos = m_SelectionInfo.m_pObject->GetWorldPos() - vOffset; - } - } - - return true; -} - -bool CVertexSnappingModeTool::HitTest(CViewport* view, const QPoint& point, CBaseObject* pExcludedObj, Vec3& outHitPos, CBaseObjectPtr& pOutHitObject, std::vector& outObjects) -{ - if (gSettings.vertexSnappingSettings.bRenderPenetratedBoundBox) - { - m_DebugBoxes.clear(); - } - - pOutHitObject = NULL; - outObjects.clear(); - - // - // Collect valid objects that mouse is over - // - - CSurfaceInfoPicker picker; - CSurfaceInfoPicker::CExcludedObjects excludedObjects; - if (pExcludedObj) - { - excludedObjects.Add(pExcludedObj); - } - - int nPickFlag = CSurfaceInfoPicker::ePOG_Entity; - - std::vector penetratedObjects; - if (!picker.PickByAABB(point, nPickFlag, view, &excludedObjects, &penetratedObjects)) - { - return false; - } - - for (int i = 0, iCount(penetratedObjects.size()); i < iCount; ++i) - { - CMaterial* pMaterial = penetratedObjects[i]->GetMaterial(); - if (pMaterial) - { - QString matName = pMaterial->GetName(); - if (!QString::compare(matName, "Objects/sky/forest_sky_dome", Qt::CaseInsensitive)) - { - continue; - } - } - outObjects.push_back(penetratedObjects[i]); - } - - // - // Find the best vertex. - // - - Vec3 vWorldRaySrc, vWorldRayDir; - view->ViewToWorldRay(point, vWorldRaySrc, vWorldRayDir); - - std::vector::iterator ii = outObjects.begin(); - float fNearestDist = 3e10f; - Vec3 vNearestPos; - CBaseObjectPtr pNearestObject = NULL; - for (ii = outObjects.begin(); ii != outObjects.end(); ++ii) - { - if (gSettings.vertexSnappingSettings.bRenderPenetratedBoundBox) - { - // add to debug boxes: the penetrated nodes of each object's kd-tree - if (auto pTree = GetKDTree(*ii)) - { - Matrix34 invWorldTM = (*ii)->GetWorldTM().GetInverted(); - int nIndex = m_DebugBoxes.size(); - - Vec3 vLocalRaySrc = invWorldTM.TransformPoint(vWorldRaySrc); - Vec3 vLocalRayDir = invWorldTM.TransformVector(vWorldRayDir); - pTree->GetPenetratedBoxes(vLocalRaySrc, vLocalRayDir, m_DebugBoxes); - for (int i = nIndex; i < m_DebugBoxes.size(); ++i) - { - m_DebugBoxes[i].SetTransformedAABB((*ii)->GetWorldTM(), m_DebugBoxes[i]); - } - } - } - - // find the nearest vertex on this object - Vec3 vPos, vHitPosOnCube; - if (FindNearestVertex(*ii, GetKDTree(*ii), vWorldRaySrc, vWorldRayDir, vPos, vHitPosOnCube)) - { - // is this the best so far? - float fDistance = vHitPosOnCube.GetDistance(vWorldRaySrc); - if (fDistance < fNearestDist) - { - fNearestDist = fDistance; - vNearestPos = vPos; - pNearestObject = *ii; - } - } - } - - if (fNearestDist < 3e10f) - { - outHitPos = vNearestPos; - pOutHitObject = pNearestObject; - } - - // if the mouse is over the object's pivot, use that instead of a vertex - if (pOutHitObject) - { - Vec3 vPivotPos = pOutHitObject->GetWorldPos(); - Vec3 vPivotBox = GetCubeSize(view, pOutHitObject->GetWorldPos()); - AABB pivotAABB(vPivotPos - vPivotBox, vPivotPos + vPivotBox); - Vec3 vPosOnPivotCube; - if (Intersect::Ray_AABB(vWorldRaySrc, vWorldRayDir, pivotAABB, vPosOnPivotCube)) - { - outHitPos = vPivotPos; - return true; - } - } - - return pOutHitObject && pOutHitObject == pNearestObject; -} - -Vec3 CVertexSnappingModeTool::GetCubeSize(IDisplayViewport* pView, const Vec3& pos) const -{ - if (!pView) - { - return Vec3(0, 0, 0); - } - float fScreenFactor = pView->GetScreenScaleFactor(pos); - return gSettings.vertexSnappingSettings.vertexCubeSize * Vec3(fScreenFactor, fScreenFactor, fScreenFactor); -} - -void CVertexSnappingModeTool::Display(struct DisplayContext& dc) -{ - const ColorB SnappedColor(0xFF00FF00); - const ColorB PivotColor(0xFF2020FF); - const ColorB VertexColor(0xFFFFAAAA); - - // draw all objects under mouse - dc.SetColor(VertexColor); - for (int i = 0, iCount(m_Objects.size()); i < iCount; ++i) - { - AABB worldAABB; - m_Objects[i]->GetBoundBox(worldAABB); - if (!dc.view->IsBoundsVisible(worldAABB)) - { - continue; - } - - if (auto pStatObj = m_Objects[i]->GetIStatObj()) - { - DrawVertexCubes(dc, m_Objects[i]->GetWorldTM(), pStatObj); - } - else - { - dc.DrawWireBox(worldAABB.min, worldAABB.max); - } - } - - // draw object being moved - if (m_modeStatus == eVSS_MoveSelectVertexToAnotherVertex && m_SelectionInfo.m_pObject) - { - dc.SetColor(QColor(0xaa, 0xaa, 0xaa)); - if (auto pStatObj = m_SelectionInfo.m_pObject->GetIStatObj()) - { - DrawVertexCubes(dc, m_SelectionInfo.m_pObject->GetWorldTM(), pStatObj); - } - else - { - AABB bounds; - m_SelectionInfo.m_pObject->GetBoundBox(bounds); - dc.DrawWireBox(bounds.min, bounds.max); - } - } - - // draw pivot of hit object - if (m_pHitObject && (!m_bHit || m_bHit && !m_pHitObject->GetWorldPos().IsEquivalent(m_vHitVertex, 0.001f))) - { - dc.SetColor(PivotColor); - dc.DepthTestOff(); - - Vec3 vBoxSize = GetCubeSize(dc.view, m_pHitObject->GetWorldPos()) * 1.2f; - AABB vertexBox(m_pHitObject->GetWorldPos() - vBoxSize, m_pHitObject->GetWorldPos() + vBoxSize); - dc.DrawBall((vertexBox.min + vertexBox.max) * 0.5f, (vertexBox.max.x - vertexBox.min.x) * 0.5f); - - dc.DepthTestOn(); - } - - // draw the vertex (or pivot) that's being hit - if (m_bHit) - { - dc.DepthTestOff(); - dc.SetColor(SnappedColor); - Vec3 vBoxSize = GetCubeSize(dc.view, m_vHitVertex); - if (m_vHitVertex.IsEquivalent(m_pHitObject->GetWorldPos(), 0.001f)) - { - dc.DrawBall(m_vHitVertex, vBoxSize.x * 1.2f); - } - else - { - dc.DrawSolidBox(m_vHitVertex - vBoxSize, m_vHitVertex + vBoxSize); - } - dc.DepthTestOn(); - } - - // draw wireframe of hit object - if (m_pHitObject && m_pHitObject->GetIStatObj()) - { - SGeometryDebugDrawInfo dd; - dd.tm = m_pHitObject->GetWorldTM(); - dd.color = ColorB(250, 0, 250, 30); - dd.lineColor = ColorB(255, 255, 0, 160); - dd.bExtrude = true; - m_pHitObject->GetIStatObj()->DebugDraw(dd); - } - - // draw debug boxes - if (gSettings.vertexSnappingSettings.bRenderPenetratedBoundBox) - { - ColorB boxColor(40, 40, 40); - for (int i = 0, iCount(m_DebugBoxes.size()); i < iCount; ++i) - { - dc.SetColor(boxColor); - boxColor += ColorB(25, 25, 25); - dc.DrawWireBox(m_DebugBoxes[i].min, m_DebugBoxes[i].max); - } - } -} - -void CVertexSnappingModeTool::DrawVertexCubes(DisplayContext& dc, const Matrix34& tm, IStatObj* pStatObj) -{ - if (!pStatObj) - { - return; - } - - IIndexedMesh* pIndexedMesh = pStatObj->GetIndexedMesh(); - if (pIndexedMesh) - { - IIndexedMesh::SMeshDescription md; - pIndexedMesh->GetMeshDescription(md); - for (int k = 0; k < md.m_nVertCount; ++k) - { - Vec3 vPos(0, 0, 0); - if (md.m_pVerts) - { - vPos = md.m_pVerts[k]; - } - else if (md.m_pVertsF16) - { - vPos = md.m_pVertsF16[k].ToVec3(); - } - else - { - continue; - } - vPos = tm.TransformPoint(vPos); - Vec3 vBoxSize = GetCubeSize(dc.view, vPos); - if (!m_bHit || !m_vHitVertex.IsEquivalent(vPos, 0.001f)) - { - dc.DrawSolidBox(vPos - vBoxSize, vPos + vBoxSize); - } - } - } - - for (int i = 0, iSubStatObjNum(pStatObj->GetSubObjectCount()); i < iSubStatObjNum; ++i) - { - IStatObj::SSubObject* pSubObj = pStatObj->GetSubObject(i); - if (pSubObj) - { - DrawVertexCubes(dc, tm * pSubObj->localTM, pSubObj->pStatObj); - } - } -} - -CKDTree* CVertexSnappingModeTool::GetKDTree(CBaseObject* pObject) -{ - auto existingTree = m_ObjectKdTreeMap.find(pObject); - if (existingTree != m_ObjectKdTreeMap.end()) - { - return existingTree->second; - } - - // Don't build a kd-tree for objects without verts - CKDTree* pTree = nullptr; - if (auto pStatObj = pObject->GetIStatObj()) - { - pTree = new CKDTree(); - pTree->Build(pObject->GetIStatObj()); - } - - m_ObjectKdTreeMap[pObject] = pTree; - return pTree; -} - -#include diff --git a/Code/Sandbox/Editor/EditMode/VertexSnappingModeTool.h b/Code/Sandbox/Editor/EditMode/VertexSnappingModeTool.h deleted file mode 100644 index 943f6bceb4..0000000000 --- a/Code/Sandbox/Editor/EditMode/VertexSnappingModeTool.h +++ /dev/null @@ -1,91 +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_EDITMODE_VERTEXSNAPPINGMODETOOL_H -#define CRYINCLUDE_EDITOR_EDITMODE_VERTEXSNAPPINGMODETOOL_H -#pragma once - -#include "EditTool.h" -#include "Objects/BaseObject.h" - -class CKDTree; -struct IDisplayViewport; - -class CVertexSnappingModeTool - : public CEditTool -{ - Q_OBJECT -public: - Q_INVOKABLE CVertexSnappingModeTool(); - ~CVertexSnappingModeTool(); - - static const GUID& GetClassID(); - - static void RegisterTool(CRegistrationContext& rc); - - void Display(DisplayContext& dc); - bool MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags); - -protected: - - void DrawVertexCubes(DisplayContext& dc, const Matrix34& tm, IStatObj* pStatObj); - void DeleteThis(){ delete this; } - Vec3 GetCubeSize(IDisplayViewport* pView, const Vec3& pos) const; - -private: - - using CEditTool::HitTest; - bool HitTest(CViewport* view, const QPoint& point, CBaseObject* pExcludedObj, Vec3& outHitPos, CBaseObjectPtr& pOutHitObject, std::vector& outObjects); - CKDTree* GetKDTree(CBaseObject* pObject); - - enum EVertexSnappingStatus - { - eVSS_SelectFirstVertex, - eVSS_MoveSelectVertexToAnotherVertex - }; - EVertexSnappingStatus m_modeStatus; - - struct SSelectionInfo - { - SSelectionInfo() - { - m_pObject = NULL; - m_vPos = Vec3(0, 0, 0); - } - CBaseObjectPtr m_pObject; - Vec3 m_vPos; - }; - - /// Info on object being moved (when in eVSS_MoveSelectVertexToAnotherVertex mode). - SSelectionInfo m_SelectionInfo; - - /// Objects that mouse is over - std::vector m_Objects; - - /// Position of vertex that mouse is hitting. - /// Invalid when m_bHit is false. - Vec3 m_vHitVertex; - - /// Whether the mouse hit test succeeded - bool m_bHit; - - /// Object that mouse is hitting - CBaseObjectPtr m_pHitObject; - - /// Boxes to render for debug drawing - std::vector m_DebugBoxes; - - /// For each object, a tree containing its vertices. - std::map m_ObjectKdTreeMap; -}; -#endif // CRYINCLUDE_EDITOR_EDITMODE_VERTEXSNAPPINGMODETOOL_H diff --git a/Code/Sandbox/Editor/EditTool.cpp b/Code/Sandbox/Editor/EditTool.cpp deleted file mode 100644 index 31a59aa58f..0000000000 --- a/Code/Sandbox/Editor/EditTool.cpp +++ /dev/null @@ -1,89 +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 "EditTool.h" - -// Editor -#include "Include/IObjectManager.h" -#include "Objects/SelectionGroup.h" - -////////////////////////////////////////////////////////////////////////// -// Class description. -////////////////////////////////////////////////////////////////////////// -class CEditTool_ClassDesc - : public CRefCountClassDesc -{ - virtual ESystemClassID SystemClassID() { return ESYSTEM_CLASS_EDITTOOL; } - virtual REFGUID ClassID() - { - // {0A43AB8E-B1AE-44aa-93B1-229F73D58CA4} - static const GUID guid = { - 0xa43ab8e, 0xb1ae, 0x44aa, { 0x93, 0xb1, 0x22, 0x9f, 0x73, 0xd5, 0x8c, 0xa4 } - }; - return guid; - } - virtual QString ClassName() { return "EditTool.Default"; }; - virtual QString Category() { return "EditTool"; }; -}; -CEditTool_ClassDesc g_stdClassDesc; - -////////////////////////////////////////////////////////////////////////// -CEditTool::CEditTool(QObject* parent) - : QObject(parent) -{ - m_pClassDesc = &g_stdClassDesc; - m_nRefCount = 0; -}; - -////////////////////////////////////////////////////////////////////////// -void CEditTool::SetParentTool(CEditTool* pTool) -{ - m_pParentTool = pTool; -} - -////////////////////////////////////////////////////////////////////////// -CEditTool* CEditTool::GetParentTool() -{ - return m_pParentTool; -} - -////////////////////////////////////////////////////////////////////////// -void CEditTool::Abort() -{ - if (m_pParentTool) - { - GetIEditor()->SetEditTool(m_pParentTool); - } - else - { - GetIEditor()->SetEditTool(0); - } -} - -////////////////////////////////////////////////////////////////////////// -void CEditTool::GetAffectedObjects(DynArray& outAffectedObjects) -{ - CSelectionGroup* pSelection = GetIEditor()->GetObjectManager()->GetSelection(); - if (pSelection == NULL) - { - return; - } - for (int i = 0, iCount(pSelection->GetCount()); i < iCount; ++i) - { - outAffectedObjects.push_back(pSelection->GetObject(i)); - } -} - -#include diff --git a/Code/Sandbox/Editor/EditTool.h b/Code/Sandbox/Editor/EditTool.h deleted file mode 100644 index b9d937ae0d..0000000000 --- a/Code/Sandbox/Editor/EditTool.h +++ /dev/null @@ -1,175 +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_EDITTOOL_H -#define CRYINCLUDE_EDITOR_EDITTOOL_H - -#pragma once - -#if !defined(Q_MOC_RUN) -#include "QtViewPaneManager.h" -#endif - -class CViewport; -struct IClassDesc; -struct ITransformManipulator; -struct HitContext; - -enum EEditToolType -{ - EDIT_TOOL_TYPE_PRIMARY, - EDIT_TOOL_TYPE_SECONDARY, -}; - -/*! - * CEditTool is an abstract base class for All Editing Tools supported by Editor. - * Edit tools handle specific editing modes in viewports. - */ -class SANDBOX_API CEditTool - : public QObject -{ - Q_OBJECT -public: - explicit CEditTool(QObject* parent = nullptr); - - ////////////////////////////////////////////////////////////////////////// - // For reference counting. - ////////////////////////////////////////////////////////////////////////// - void AddRef() { m_nRefCount++; }; - void Release() - { - AZ_Assert(m_nRefCount > 0, "Negative ref count"); - if (--m_nRefCount == 0) - { - DeleteThis(); - } - }; - - //! Returns class description for this tool. - IClassDesc* GetClassDesc() const { return m_pClassDesc; } - - virtual void SetParentTool(CEditTool* pTool); - virtual CEditTool* GetParentTool(); - - virtual EEditToolType GetType() { return EDIT_TOOL_TYPE_PRIMARY; } - virtual EOperationMode GetMode() { return eOperationModeNone; } - - // Abort tool. - virtual void Abort(); - - // Accept tool. - virtual void Accept([[maybe_unused]] bool resetPosition = false) {} - - //! Status text displayed when this tool is active. - void SetStatusText(const QString& text) { m_statusText = text; }; - QString GetStatusText() { return m_statusText; }; - - // Description: - // Activates tool. - // Arguments: - // pPreviousTool - Previously active edit tool. - // Return: - // True if the tool can be activated, - virtual bool Activate([[maybe_unused]] CEditTool* pPreviousTool) { return true; }; - - //! Used to pass user defined data to edit tool from ToolButton. - virtual void SetUserData([[maybe_unused]] const char* key, [[maybe_unused]] void* userData) {}; - - //! Called when user starts using this tool. - //! Flags is comnination of ObjectEditFlags flags. - virtual void BeginEditParams([[maybe_unused]] IEditor* ie, [[maybe_unused]] int flags) {}; - //! Called when user ends using this tool. - virtual void EndEditParams() {}; - - // Called each frame to display tool for given viewport. - virtual void Display(struct DisplayContext& dc) = 0; - - //! Mouse callback sent from viewport. - //! Returns true if event processed by callback, and all other processing for this event should abort. - //! Return false if event was not processed by callback, and other processing for this event should occur. - //! @param view Viewport that sent this callback. - //! @param event Indicate what kind of event occured in viewport. - //! @param point 2D coordinate in viewport where event occured. - //! @param flags Additional flags (MK_LBUTTON,etc..) or from (MouseEventFlags) specified by viewport when calling callback. - virtual bool MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags) = 0; - - //! Called when key in viewport is pressed while using this tool. - //! Returns true if event processed by callback, and all other processing for this event should abort. - //! Returns false if event was not processed by callback, and other processing for this event should occur. - //! @param view Viewport where key was pressed. - //! @param nChar Specifies the virtual key code of the given key. For a list of standard virtual key codes, see Winuser.h - //! @param nRepCnt Specifies the repeat count, that is, the number of times the keystroke is repeated as a result of the user holding down the key. - //! @param nFlags Specifies the scan code, key-transition code, previous key state, and context code, (see WM_KEYDOWN) - virtual bool OnKeyDown([[maybe_unused]] CViewport* view, [[maybe_unused]] uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) { return false; }; - - //! Called when key in viewport is released while using this tool. - //! Returns true if event processed by callback, and all other processing for this event should abort. - //! Returns false if event was not processed by callback, and other processing for this event should occur. - //! @param view Viewport where key was pressed. - //! @param nChar Specifies the virtual key code of the given key. For a list of standard virtual key codes, see Winuser.h - //! @param nRepCnt Specifies the repeat count, that is, the number of times the keystroke is repeated as a result of the user holding down the key. - //! @param nFlags Specifies the scan code, key-transition code, previous key state, and context code, (see WM_KEYDOWN) - virtual bool OnKeyUp([[maybe_unused]] CViewport* view, [[maybe_unused]] uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) { return false; }; - - //! Called when mouse is moved and give oportunity to tool to set it own cursor. - //! @return true if cursor changed. or false otherwise. - virtual bool OnSetCursor([[maybe_unused]] CViewport* vp) { return false; }; - - // Return objects affected by this edit tool. The returned objects usually will be the selected objects. - virtual void GetAffectedObjects(DynArray& outAffectedObjects); - - // Called in response to the dragging of the manipulator in the view. - // Allow edit tool to handle manipulator dragging the way it wants. - virtual void OnManipulatorDrag([[maybe_unused]] CViewport* view, [[maybe_unused]] ITransformManipulator* pManipulator, [[maybe_unused]] QPoint& p0, [[maybe_unused]] QPoint& p1, [[maybe_unused]] const Vec3& value) {} - - virtual void OnManipulatorDrag(CViewport* view, ITransformManipulator* pManipulator, const Vec3& value) - { - // Overload with less boiler-plate - QPoint p0, p1; - OnManipulatorDrag(view, pManipulator, p0, p1, value); - } - - // Called in response to mouse event of the manipulator in the view - virtual void OnManipulatorMouseEvent([[maybe_unused]] CViewport* view, [[maybe_unused]] ITransformManipulator* pManipulator, [[maybe_unused]] EMouseEvent event, [[maybe_unused]] QPoint& point, [[maybe_unused]] int flags, [[maybe_unused]] bool bHitGizmo = false) {} - - virtual bool IsNeedMoveTool() { return false; } - virtual bool IsNeedSpecificBehaviorForSpaceAcce() { return false; } - virtual bool IsNeedToSkipPivotBoxForObjects() { return false; } - virtual bool IsDisplayGrid() { return true; } - virtual bool IsUpdateUIPanel() { return false; } - virtual bool IsMoveToObjectModeAfterEnd() { return true; } - virtual bool IsCircleTypeRotateGizmo() { return false; } - - // Draws object specific helpers for this tool - virtual void DrawObjectHelpers([[maybe_unused]] CBaseObject* pObject, [[maybe_unused]] DisplayContext& dc) {} - - // Hit test against edit tool - virtual bool HitTest([[maybe_unused]] CBaseObject* pObject, [[maybe_unused]] HitContext& hc) { return false; } - -protected: - virtual ~CEditTool() {}; - ////////////////////////////////////////////////////////////////////////// - // Delete edit tool. - ////////////////////////////////////////////////////////////////////////// - virtual void DeleteThis() = 0; - -protected: - AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING - _smart_ptr m_pParentTool; // Pointer to parent edit tool. - AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING - QString m_statusText; - IClassDesc* m_pClassDesc; - int m_nRefCount; -}; - -#endif // CRYINCLUDE_EDITOR_EDITTOOL_H diff --git a/Code/Sandbox/Editor/EditorPreferencesPageGeneral.cpp b/Code/Sandbox/Editor/EditorPreferencesPageGeneral.cpp index b10d564031..a7420b79a4 100644 --- a/Code/Sandbox/Editor/EditorPreferencesPageGeneral.cpp +++ b/Code/Sandbox/Editor/EditorPreferencesPageGeneral.cpp @@ -63,11 +63,6 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize) ->Field("DeepSelectionRange", &DeepSelection::m_deepSelectionRange) ->Field("StickDuplicate", &DeepSelection::m_stickDuplicate); - serialize.Class() - ->Version(1) - ->Field("VertexCubeSize", &VertexSnapping::m_vertexCubeSize) - ->Field("RenderPenetratedBoundBox", &VertexSnapping::m_bRenderPenetratedBoundBox); - serialize.Class() ->Version(1) ->Field("DynamicByDefault", &SliceSettings::m_slicesDynamicByDefault); @@ -78,7 +73,6 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize) ->Field("Messaging", &CEditorPreferencesPage_General::m_messaging) ->Field("Undo", &CEditorPreferencesPage_General::m_undo) ->Field("Deep Selection", &CEditorPreferencesPage_General::m_deepSelection) - ->Field("Vertex Snapping", &CEditorPreferencesPage_General::m_vertexSnapping) ->Field("Slice Settings", &CEditorPreferencesPage_General::m_sliceSettings); @@ -119,12 +113,6 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize) ->Attribute(AZ::Edit::Attributes::Min, 0.0f) ->Attribute(AZ::Edit::Attributes::Max, 1000.0f); - editContext->Class("Vertex Snapping", "") - ->DataElement(AZ::Edit::UIHandlers::SpinBox, &VertexSnapping::m_vertexCubeSize, "Vertex Cube Size", "Vertex Cube Size") - ->Attribute(AZ::Edit::Attributes::Min, 0.0001f) - ->Attribute(AZ::Edit::Attributes::Max, 1.0f) - ->DataElement(AZ::Edit::UIHandlers::CheckBox, &VertexSnapping::m_bRenderPenetratedBoundBox, "Render Penetrated BoundBoxes", "Render Penetrated BoundBoxes"); - editContext->Class("Slices", "") ->DataElement(AZ::Edit::UIHandlers::CheckBox, &SliceSettings::m_slicesDynamicByDefault, "New Slices Dynamic By Default", "When creating slices, they will be set to dynamic by default"); @@ -135,7 +123,6 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize) ->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_messaging, "Messaging", "Messaging") ->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_undo, "Undo", "Undo Preferences") ->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_deepSelection, "Selection", "Selection") - ->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_vertexSnapping, "Vertex Snapping", "Vertex Snapping") ->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_sliceSettings, "Slices", "Slice Settings"); } } @@ -189,10 +176,6 @@ void CEditorPreferencesPage_General::OnApply() gSettings.deepSelectionSettings.fRange = m_deepSelection.m_deepSelectionRange; gSettings.deepSelectionSettings.bStickDuplicate = m_deepSelection.m_stickDuplicate; - //vertex snapping - gSettings.vertexSnappingSettings.vertexCubeSize = m_vertexSnapping.m_vertexCubeSize; - gSettings.vertexSnappingSettings.bRenderPenetratedBoundBox = m_vertexSnapping.m_bRenderPenetratedBoundBox; - //slices gSettings.sliceSettings.dynamicByDefault = m_sliceSettings.m_slicesDynamicByDefault; @@ -236,10 +219,6 @@ void CEditorPreferencesPage_General::InitializeSettings() m_deepSelection.m_deepSelectionRange = gSettings.deepSelectionSettings.fRange; m_deepSelection.m_stickDuplicate = gSettings.deepSelectionSettings.bStickDuplicate; - //vertex snapping - m_vertexSnapping.m_vertexCubeSize = gSettings.vertexSnappingSettings.vertexCubeSize; - m_vertexSnapping.m_bRenderPenetratedBoundBox = gSettings.vertexSnappingSettings.bRenderPenetratedBoundBox; - //slices m_sliceSettings.m_slicesDynamicByDefault = gSettings.sliceSettings.dynamicByDefault; } diff --git a/Code/Sandbox/Editor/EditorPreferencesPageGeneral.h b/Code/Sandbox/Editor/EditorPreferencesPageGeneral.h index d996f410a7..31776e9c10 100644 --- a/Code/Sandbox/Editor/EditorPreferencesPageGeneral.h +++ b/Code/Sandbox/Editor/EditorPreferencesPageGeneral.h @@ -88,14 +88,6 @@ private: bool m_stickDuplicate; }; - struct VertexSnapping - { - AZ_TYPE_INFO(VertexSnapping, "{20F16350-990C-4096-86E3-40D56DDDD702}") - - float m_vertexCubeSize; - bool m_bRenderPenetratedBoundBox; - }; - struct SliceSettings { AZ_TYPE_INFO(SliceSettings, "{8505CCC1-874C-4389-B51A-B9E5FF70CFDA}") @@ -107,7 +99,6 @@ private: Messaging m_messaging; Undo m_undo; DeepSelection m_deepSelection; - VertexSnapping m_vertexSnapping; SliceSettings m_sliceSettings; QIcon m_icon; }; diff --git a/Code/Sandbox/Editor/EditorViewportWidget.cpp b/Code/Sandbox/Editor/EditorViewportWidget.cpp index 977850bc58..86fda8ceae 100644 --- a/Code/Sandbox/Editor/EditorViewportWidget.cpp +++ b/Code/Sandbox/Editor/EditorViewportWidget.cpp @@ -65,7 +65,6 @@ #include "Util/fastlib.h" #include "CryEditDoc.h" #include "GameEngine.h" -#include "EditTool.h" #include "ViewManager.h" #include "Objects/DisplayContext.h" #include "DisplaySettings.h" diff --git a/Code/Sandbox/Editor/Export/ExportManager.cpp b/Code/Sandbox/Editor/Export/ExportManager.cpp index bf5c3aa469..b41872595a 100644 --- a/Code/Sandbox/Editor/Export/ExportManager.cpp +++ b/Code/Sandbox/Editor/Export/ExportManager.cpp @@ -65,7 +65,7 @@ namespace const float kTangentDelta = 0.01f; const float kAspectRatio = 1.777778f; const int kReserveCount = 7; // x,y,z,rot_x,rot_y,rot_z,fov - const QString kMasterCameraName = "MasterCamera"; + const QString kPrimaryCameraName = "PrimaryCamera"; } // namespace @@ -169,10 +169,10 @@ CExportManager::CExportManager() , m_numberOfExportFrames(0) , m_pivotEntityObject(0) , m_bBakedKeysSequenceExport(true) - , m_animTimeExportMasterSequenceCurrentTime(0.0f) + , m_animTimeExportPrimarySequenceCurrentTime(0.0f) , m_animKeyTimeExport(true) , m_soundKeyTimeExport(true) - , m_bExportOnlyMasterCamera(false) + , m_bExportOnlyPrimaryCamera(false) { RegisterExporter(new COBJExporter()); RegisterExporter(new COCMExporter()); @@ -773,14 +773,14 @@ bool CExportManager::ShowFBXExportDialog() return false; } - SetFBXExportSettings(fpsDialog.GetExportCoordsLocalToTheSelectedObject(), fpsDialog.GetExportOnlyMasterCamera(), fpsDialog.GetFPS()); + SetFBXExportSettings(fpsDialog.GetExportCoordsLocalToTheSelectedObject(), fpsDialog.GetExportOnlyPrimaryCamera(), fpsDialog.GetFPS()); return true; } bool CExportManager::ProcessObjectsForExport() { - Export::CObject* pObj = new Export::CObject(kMasterCameraName.toUtf8().data()); + Export::CObject* pObj = new Export::CObject(kPrimaryCameraName.toUtf8().data()); pObj->entityType = Export::eCamera; m_data.m_objects.push_back(pObj); @@ -808,13 +808,13 @@ bool CExportManager::ProcessObjectsForExport() Export::CObject* pObj2 = m_data.m_objects[objectID]; CBaseObject* pObject = 0; - if (QString::compare(pObj2->name, kMasterCameraName) == 0) + if (QString::compare(pObj2->name, kPrimaryCameraName) == 0) { pObject = GetIEditor()->GetObjectManager()->FindObject(GetIEditor()->GetViewManager()->GetCameraObjectId()); } else { - if (m_bExportOnlyMasterCamera && pObj2->entityType != Export::eCameraTarget) + if (m_bExportOnlyPrimaryCamera && pObj2->entityType != Export::eCameraTarget) { continue; } @@ -952,7 +952,7 @@ void CExportManager::FillAnimTimeNode(XmlNodeRef writeNode, CTrackViewAnimNode* if (numAllTracks > 0) { XmlNodeRef objNode = writeNode->createNode(CleanXMLText(pObjectNode->GetName()).toUtf8().data()); - writeNode->setAttr("time", m_animTimeExportMasterSequenceCurrentTime); + writeNode->setAttr("time", m_animTimeExportPrimarySequenceCurrentTime); for (unsigned int trackID = 0; trackID < numAllTracks; ++trackID) { @@ -1020,7 +1020,7 @@ void CExportManager::FillAnimTimeNode(XmlNodeRef writeNode, CTrackViewAnimNode* XmlNodeRef keyNode = subNode->createNode(keyContentName.toUtf8().data()); - float keyGlobalTime = m_animTimeExportMasterSequenceCurrentTime + keyTime; + float keyGlobalTime = m_animTimeExportPrimarySequenceCurrentTime + keyTime; keyNode->setAttr("keyTime", keyGlobalTime); if (keyStartTime > 0) @@ -1123,13 +1123,13 @@ bool CExportManager::AddObjectsFromSequence(CTrackViewSequence* pSequence, XmlNo const QString sequenceName = pSubSequence->GetName(); XmlNodeRef subSeqNode2 = seqNode->createNode(sequenceName.toUtf8().data()); - if (sequenceName == m_animTimeExportMasterSequenceName) + if (sequenceName == m_animTimeExportPrimarySequenceName) { - m_animTimeExportMasterSequenceCurrentTime = sequenceKey.time; + m_animTimeExportPrimarySequenceCurrentTime = sequenceKey.time; } else { - m_animTimeExportMasterSequenceCurrentTime += sequenceKey.time; + m_animTimeExportPrimarySequenceCurrentTime += sequenceKey.time; } AddObjectsFromSequence(pSubSequence, subSeqNode2); @@ -1336,7 +1336,7 @@ bool CExportManager::Export(const char* defaultName, const char* defaultExt, con { m_numberOfExportFrames = pSequence->GetTimeRange().end * m_FBXBakedExportFPS; - if (!m_bExportOnlyMasterCamera) + if (!m_bExportOnlyPrimaryCamera) { AddObjectsFromSequence(pSequence); } @@ -1365,10 +1365,10 @@ bool CExportManager::Export(const char* defaultName, const char* defaultExt, con return returnRes; } -void CExportManager::SetFBXExportSettings(bool bLocalCoordsToSelectedObject, bool bExportOnlyMasterCamera, const float fps) +void CExportManager::SetFBXExportSettings(bool bLocalCoordsToSelectedObject, bool bExportOnlyPrimaryCamera, const float fps) { m_bExportLocalCoords = bLocalCoordsToSelectedObject; - m_bExportOnlyMasterCamera = bExportOnlyMasterCamera; + m_bExportOnlyPrimaryCamera = bExportOnlyPrimaryCamera; m_FBXBakedExportFPS = fps; } @@ -1439,10 +1439,10 @@ void CExportManager::SaveNodeKeysTimeToXML() if (dlg.exec()) { m_animTimeNode = XmlHelpers::CreateXmlNode(pSequence->GetName()); - m_animTimeExportMasterSequenceName = pSequence->GetName(); + m_animTimeExportPrimarySequenceName = pSequence->GetName(); m_data.Clear(); - m_animTimeExportMasterSequenceCurrentTime = 0.0; + m_animTimeExportPrimarySequenceCurrentTime = 0.0; AddObjectsFromSequence(pSequence, m_animTimeNode); diff --git a/Code/Sandbox/Editor/Export/ExportManager.h b/Code/Sandbox/Editor/Export/ExportManager.h index d8edf1d3b1..8904ef08ed 100644 --- a/Code/Sandbox/Editor/Export/ExportManager.h +++ b/Code/Sandbox/Editor/Export/ExportManager.h @@ -171,7 +171,7 @@ private: bool AddObjectsFromSequence(CTrackViewSequence* pSequence, XmlNodeRef seqNode = 0); bool IsDuplicateObjectBeingAdded(const QString& newObject); - void SetFBXExportSettings(bool bLocalCoordsToSelectedObject, bool bExportOnlyMasterCamera, const float fps); + void SetFBXExportSettings(bool bLocalCoordsToSelectedObject, bool bExportOnlyPrimaryCamera, const float fps); bool ProcessObjectsForExport(); bool ShowFBXExportDialog(); @@ -193,13 +193,13 @@ private: float m_FBXBakedExportFPS; bool m_bExportLocalCoords; - bool m_bExportOnlyMasterCamera; + bool m_bExportOnlyPrimaryCamera; int m_numberOfExportFrames; CEntityObject* m_pivotEntityObject; bool m_bBakedKeysSequenceExport; - QString m_animTimeExportMasterSequenceName; - float m_animTimeExportMasterSequenceCurrentTime; + QString m_animTimeExportPrimarySequenceName; + float m_animTimeExportPrimarySequenceCurrentTime; XmlNodeRef m_animTimeNode; bool m_animKeyTimeExport; diff --git a/Code/Sandbox/Editor/FBXExporterDialog.cpp b/Code/Sandbox/Editor/FBXExporterDialog.cpp index 7638680b10..677e6dcfe7 100644 --- a/Code/Sandbox/Editor/FBXExporterDialog.cpp +++ b/Code/Sandbox/Editor/FBXExporterDialog.cpp @@ -55,9 +55,9 @@ bool CFBXExporterDialog::GetExportCoordsLocalToTheSelectedObject() const return m_ui->m_exportLocalCoordsCheckbox->isChecked(); } -bool CFBXExporterDialog::GetExportOnlyMasterCamera() const +bool CFBXExporterDialog::GetExportOnlyPrimaryCamera() const { - return m_ui->m_exportOnlyMasterCameraCheckBox->isChecked(); + return m_ui->m_exportOnlyPrimaryCameraCheckBox->isChecked(); } void CFBXExporterDialog::SetExportLocalCoordsCheckBoxEnable(bool checked) @@ -100,7 +100,7 @@ int CFBXExporterDialog::exec() if (m_bDisplayOnlyFPSSetting) { m_ui->m_exportLocalCoordsCheckbox->setEnabled(false); - m_ui->m_exportOnlyMasterCameraCheckBox->setEnabled(false); + m_ui->m_exportOnlyPrimaryCameraCheckBox->setEnabled(false); } m_ui->m_fpsCombo->addItem("24"); diff --git a/Code/Sandbox/Editor/FBXExporterDialog.h b/Code/Sandbox/Editor/FBXExporterDialog.h index 9978cb4aca..ffa249ca5b 100644 --- a/Code/Sandbox/Editor/FBXExporterDialog.h +++ b/Code/Sandbox/Editor/FBXExporterDialog.h @@ -36,7 +36,7 @@ public: float GetFPS() const; bool GetExportCoordsLocalToTheSelectedObject() const; - bool GetExportOnlyMasterCamera() const; + bool GetExportOnlyPrimaryCamera() const; void SetExportLocalCoordsCheckBoxEnable(bool checked); int exec() override; @@ -44,7 +44,7 @@ public: protected: void OnFPSChange(); void SetExportLocalToTheSelectedObjectCheckBox(); - void SetExportOnlyMasterCameraCheckBox(); + void SetExportOnlyPrimaryCameraCheckBox(); void accept() override; diff --git a/Code/Sandbox/Editor/FBXExporterDialog.ui b/Code/Sandbox/Editor/FBXExporterDialog.ui index 8c02ce1ca9..6b7b93c342 100644 --- a/Code/Sandbox/Editor/FBXExporterDialog.ui +++ b/Code/Sandbox/Editor/FBXExporterDialog.ui @@ -49,9 +49,9 @@ - + - Export Only Master Camera + Export Only Primary Camera diff --git a/Code/Sandbox/Editor/GameExporter.cpp b/Code/Sandbox/Editor/GameExporter.cpp index 5173071024..00836018cf 100644 --- a/Code/Sandbox/Editor/GameExporter.cpp +++ b/Code/Sandbox/Editor/GameExporter.cpp @@ -125,9 +125,6 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE { QDir::setCurrent(pEditor->GetPrimaryCDFolder()); - // Close all Editor tools - pEditor->SetEditTool(0); - QString sLevelPath = Path::AddSlash(pGameEngine->GetLevelPath()); if (subdirectory && subdirectory[0] && strcmp(subdirectory, ".") != 0) { diff --git a/Code/Sandbox/Editor/IEditor.h b/Code/Sandbox/Editor/IEditor.h index 722f2a7c25..90fb8823e7 100644 --- a/Code/Sandbox/Editor/IEditor.h +++ b/Code/Sandbox/Editor/IEditor.h @@ -40,7 +40,6 @@ struct QMetaObject; class CBaseObject; class CCryEditDoc; class CSelectionGroup; -class CEditTool; class CAnimationContext; class CTrackViewSequenceManager; class CGameEngine; @@ -319,17 +318,6 @@ enum EOperationMode eModellingMode // Geometry modeling mode }; -enum EEditMode -{ - eEditModeSelect, - eEditModeSelectArea, - eEditModeMove, - eEditModeRotate, - eEditModeScale, - eEditModeTool, - eEditModeRotateCircle, -}; - //! Mouse events that viewport can send enum EMouseEvent { @@ -620,17 +608,6 @@ struct IEditor virtual void SetOperationMode(EOperationMode mode) = 0; virtual EOperationMode GetOperationMode() = 0; - //! editMode - EEditMode - virtual void SetEditMode(int editMode) = 0; - virtual int GetEditMode() = 0; - //! Assign current edit tool, destroy previously used edit too. - virtual void SetEditTool(CEditTool* tool, bool bStopCurrentTool = true) = 0; - //! Assign current edit tool by class name. - virtual void SetEditTool(const QString& sEditToolName, bool bStopCurrentTool = true) = 0; - //! Reinitializes the current edit tool if one is selected. - virtual void ReinitializeEditTool() = 0; - //! Returns current edit tool. - virtual CEditTool* GetEditTool() = 0; //! Shows/Hides transformation manipulator. //! if bShow is true also returns a valid ITransformManipulator pointer. virtual ITransformManipulator* ShowTransformManipulator(bool bShow) = 0; diff --git a/Code/Sandbox/Editor/IEditorImpl.cpp b/Code/Sandbox/Editor/IEditorImpl.cpp index 399ac45794..561953d729 100644 --- a/Code/Sandbox/Editor/IEditorImpl.cpp +++ b/Code/Sandbox/Editor/IEditorImpl.cpp @@ -54,7 +54,6 @@ AZ_POP_DISABLE_WARNING #include "Export/ExportManager.h" #include "LevelIndependentFileMan.h" #include "Material/MaterialManager.h" -#include "Material/MaterialPickTool.h" #include "TrackView/TrackViewSequenceManager.h" #include "AnimationContext.h" #include "GameEngine.h" @@ -71,13 +70,9 @@ AZ_POP_DISABLE_WARNING #include "Objects/SelectionGroup.h" #include "Objects/ObjectManager.h" -#include "RotateTool.h" -#include "NullEditTool.h" - #include "BackgroundTaskManager.h" #include "BackgroundScheduleManager.h" #include "EditorFileMonitor.h" -#include "EditMode/VertexSnappingModeTool.h" #include "Mission.h" #include "MainStatusBar.h" @@ -149,8 +144,7 @@ namespace const char* CEditorImpl::m_crashLogFileName = "SessionStatus/editor_statuses.json"; CEditorImpl::CEditorImpl() - : m_currEditMode(eEditModeSelect) - , m_operationMode(eOperationModeNone) + : m_operationMode(eOperationModeNone) , m_pSystem(nullptr) , m_pFileUtil(nullptr) , m_pClassFactory(nullptr) @@ -241,18 +235,6 @@ CEditorImpl::CEditorImpl() m_pRuler = new CRuler; m_selectedRegion.min = Vec3(0, 0, 0); m_selectedRegion.max = Vec3(0, 0, 0); - ZeroStruct(m_lastAxis); - m_lastAxis[eEditModeSelect] = AXIS_TERRAIN; - m_lastAxis[eEditModeSelectArea] = AXIS_TERRAIN; - m_lastAxis[eEditModeMove] = AXIS_TERRAIN; - m_lastAxis[eEditModeRotate] = AXIS_Z; - m_lastAxis[eEditModeScale] = AXIS_XY; - ZeroStruct(m_lastCoordSys); - m_lastCoordSys[eEditModeSelect] = COORDS_LOCAL; - m_lastCoordSys[eEditModeSelectArea] = COORDS_LOCAL; - m_lastCoordSys[eEditModeMove] = COORDS_WORLD; - m_lastCoordSys[eEditModeRotate] = COORDS_WORLD; - m_lastCoordSys[eEditModeScale] = COORDS_WORLD; DetectVersion(); RegisterTools(); @@ -262,8 +244,6 @@ CEditorImpl::CEditorImpl() m_pAssetBrowserRequestHandler = nullptr; m_assetEditorRequestsHandler = nullptr; - AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusConnect(); - AZ::IO::SystemFile::CreateDir("SessionStatus"); QFile::setPermissions(m_crashLogFileName, QFileDevice::ReadOther | QFileDevice::WriteOther); } @@ -287,8 +267,6 @@ void CEditorImpl::Initialize() // Activate QT immediately so that its available as soon as CEditorImpl is (and thus GetIEditor()) InitializeEditorCommon(GetIEditor()); - - LoadSettings(); } //The only purpose of that function is to be called at the very begining of the shutdown sequence so that we can instrument and track @@ -303,8 +281,6 @@ void CEditorImpl::OnEarlyExitShutdownSequence() void CEditorImpl::Uninitialize() { - SaveSettings(); - if (m_pSystem) { UninitializeEditorCommonISystem(m_pSystem); @@ -365,8 +341,6 @@ void CEditorImpl::LoadPlugins() CEditorImpl::~CEditorImpl() { - AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusDisconnect(); - gSettings.Save(); m_bExiting = true; // Can't save level after this point (while Crash) SAFE_RELEASE(m_pSourceControl); @@ -451,12 +425,6 @@ void CEditorImpl::RegisterTools() rc.pCommandManager = m_pCommandManager; rc.pClassFactory = m_pClassFactory; - - CObjectMode::RegisterTool(rc); - CMaterialPickTool::RegisterTool(rc); - CVertexSnappingModeTool::RegisterTool(rc); - CRotateTool::RegisterTool(rc); - NullEditTool::RegisterTool(rc); } void CEditorImpl::ExecuteCommand(const char* sCommand, ...) @@ -661,53 +629,6 @@ IMainStatusBar* CEditorImpl::GetMainStatusBar() return MainWindow::instance()->StatusBar(); } -int CEditorImpl::GetEditMode() -{ - return m_currEditMode; -} - -void CEditorImpl::SetEditMode(int editMode) -{ - bool isEditorInGameMode = false; - EBUS_EVENT_RESULT(isEditorInGameMode, AzToolsFramework::EditorEntityContextRequestBus, IsEditorRunningGame); - - if (isEditorInGameMode) - { - if (editMode != eEditModeSelect) - { - if (SelectionContainsComponentEntities()) - { - return; - } - } - } - - if ((EEditMode)editMode == eEditModeRotate) - { - if (GetEditTool() && GetEditTool()->IsCircleTypeRotateGizmo()) - { - editMode = eEditModeRotateCircle; - } - } - - EEditMode newEditMode = (EEditMode)editMode; - if (m_currEditMode == newEditMode) - { - return; - } - - m_currEditMode = newEditMode; - AABB box(Vec3(0, 0, 0), Vec3(0, 0, 0)); - SetSelectedRegion(box); - - if (GetEditTool() && !GetEditTool()->IsNeedMoveTool()) - { - SetEditTool(0, true); - } - - Notify(eNotify_OnEditModeChange); -} - void CEditorImpl::SetOperationMode(EOperationMode mode) { m_operationMode = mode; @@ -719,139 +640,6 @@ EOperationMode CEditorImpl::GetOperationMode() return m_operationMode; } -bool CEditorImpl::HasCorrectEditTool() const -{ - if (!m_pEditTool) - { - return false; - } - - switch (m_currEditMode) - { - case eEditModeRotate: - return qobject_cast(m_pEditTool) != nullptr; - default: - return qobject_cast(m_pEditTool) != nullptr && qobject_cast(m_pEditTool) == nullptr; - } -} - -CEditTool* CEditorImpl::CreateCorrectEditTool() -{ - if (m_currEditMode == eEditModeRotate) - { - CBaseObject* selectedObj = nullptr; - CSelectionGroup* pSelection = GetIEditor()->GetObjectManager()->GetSelection(); - if (pSelection && pSelection->GetCount() > 0) - { - selectedObj = pSelection->GetObject(0); - } - - return (new CRotateTool(selectedObj)); - } - - return (new CObjectMode); -} - -void CEditorImpl::SetEditTool(CEditTool* tool, bool bStopCurrentTool) -{ - CViewport* pViewport = GetIEditor()->GetActiveView(); - if (pViewport) - { - pViewport->SetCurrentCursor(STD_CURSOR_DEFAULT); - } - - if (!tool) - { - if (HasCorrectEditTool()) - { - return; - } - else - { - tool = CreateCorrectEditTool(); - } - } - - if (!tool->Activate(m_pEditTool)) - { - return; - } - - if (bStopCurrentTool) - { - if (m_pEditTool && m_pEditTool != tool) - { - m_pEditTool->EndEditParams(); - SetStatusText("Ready"); - } - } - - m_pEditTool = tool; - if (m_pEditTool) - { - m_pEditTool->BeginEditParams(this, 0); - } - - Notify(eNotify_OnEditToolChange); -} - -void CEditorImpl::ReinitializeEditTool() -{ - if (m_pEditTool) - { - m_pEditTool->EndEditParams(); - m_pEditTool->BeginEditParams(this, 0); - } -} - -void CEditorImpl::SetEditTool(const QString& sEditToolName, [[maybe_unused]] bool bStopCurrentTool) -{ - CEditTool* pTool = GetEditTool(); - if (pTool && pTool->GetClassDesc()) - { - // Check if already selected. - if (QString::compare(pTool->GetClassDesc()->ClassName(), sEditToolName, Qt::CaseInsensitive) == 0) - { - return; - } - } - - IClassDesc* pClass = GetIEditor()->GetClassFactory()->FindClass(sEditToolName.toUtf8().data()); - if (!pClass) - { - Warning("Editor Tool %s not registered.", sEditToolName.toUtf8().data()); - return; - } - if (pClass->SystemClassID() != ESYSTEM_CLASS_EDITTOOL) - { - Warning("Class name %s is not a valid Edit Tool class.", sEditToolName.toUtf8().data()); - return; - } - - QScopedPointer o(pClass->CreateQObject()); - if (CEditTool* pEditTool = qobject_cast(o.data())) - { - GetIEditor()->SetEditTool(pEditTool); - o.take(); - return; - } - else - { - Warning("Class name %s is not a valid Edit Tool class.", sEditToolName.toUtf8().data()); - return; - } -} - -CEditTool* CEditorImpl::GetEditTool() -{ - if (m_isNewViewportInteractionModelEnabled) - { - return nullptr; - } - - return m_pEditTool; -} - ITransformManipulator* CEditorImpl::ShowTransformManipulator(bool bShow) { if (bShow) @@ -885,7 +673,6 @@ ITransformManipulator* CEditorImpl::GetTransformManipulator() void CEditorImpl::SetAxisConstraints(AxisConstrains axisFlags) { m_selectedAxis = axisFlags; - m_lastAxis[m_currEditMode] = m_selectedAxis; m_pViewManager->SetAxisConstrain(axisFlags); SetTerrainAxisIgnoreObjects(false); @@ -911,7 +698,6 @@ bool CEditorImpl::IsTerrainAxisIgnoreObjects() void CEditorImpl::SetReferenceCoordSys(RefCoordSys refCoords) { m_refCoordsSys = refCoords; - m_lastCoordSys[m_currEditMode] = m_refCoordsSys; // Update all views. UpdateViews(eUpdateObjects, NULL); @@ -2041,60 +1827,6 @@ bool CEditorImpl::IsNewViewportInteractionModelEnabled() const return m_isNewViewportInteractionModelEnabled; } -void CEditorImpl::OnStartPlayInEditor() -{ - if (SelectionContainsComponentEntities()) - { - SetEditMode(eEditModeSelect); - } -} - -namespace -{ - const std::vector> s_editModeNames = { - { eEditModeSelect, QStringLiteral("Select") }, - { eEditModeSelectArea, QStringLiteral("SelectArea") }, - { eEditModeMove, QStringLiteral("Move") }, - { eEditModeRotate, QStringLiteral("Rotate") }, - { eEditModeScale, QStringLiteral("Scale") } - }; -} - -void CEditorImpl::LoadSettings() -{ - QSettings settings(QStringLiteral("Amazon"), QStringLiteral("O3DE")); - - settings.beginGroup(QStringLiteral("Editor")); - settings.beginGroup(QStringLiteral("CoordSys")); - - for (const auto& editMode : s_editModeNames) - { - if (settings.contains(editMode.second)) - { - m_lastCoordSys[editMode.first] = static_cast(settings.value(editMode.second).toInt()); - } - } - - settings.endGroup(); // CoordSys - settings.endGroup(); // Editor -} - -void CEditorImpl::SaveSettings() const -{ - QSettings settings(QStringLiteral("Amazon"), QStringLiteral("O3DE")); - - settings.beginGroup(QStringLiteral("Editor")); - settings.beginGroup(QStringLiteral("CoordSys")); - - for (const auto& editMode : s_editModeNames) - { - settings.setValue(editMode.second, static_cast(m_lastCoordSys[editMode.first])); - } - - settings.endGroup(); // CoordSys - settings.endGroup(); // Editor -} - IEditorPanelUtils* CEditorImpl::GetEditorPanelUtils() { return m_panelEditorUtils; diff --git a/Code/Sandbox/Editor/IEditorImpl.h b/Code/Sandbox/Editor/IEditorImpl.h index 4a8d5fa191..a99fa234b9 100644 --- a/Code/Sandbox/Editor/IEditorImpl.h +++ b/Code/Sandbox/Editor/IEditorImpl.h @@ -23,7 +23,6 @@ #include // for shared_ptr #include #include -#include #include #include @@ -86,13 +85,12 @@ namespace AssetDatabase class CEditorImpl : public IEditor - , protected AzToolsFramework::EditorEntityContextNotificationBus::Handler { Q_DECLARE_TR_FUNCTIONS(CEditorImpl) public: CEditorImpl(); - ~CEditorImpl(); + virtual ~CEditorImpl(); void Initialize(); void OnBeginShutdownSequence(); @@ -226,20 +224,6 @@ public: void SetDataModified(); void SetOperationMode(EOperationMode mode); EOperationMode GetOperationMode(); - void SetEditMode(int editMode); - int GetEditMode(); - - //! A correct tool is one that corresponds to the previously set edit mode. - bool HasCorrectEditTool() const; - - //! Returns the edit tool required for the edit mode specified. - CEditTool* CreateCorrectEditTool(); - - void SetEditTool(CEditTool* tool, bool bStopCurrentTool = true) override; - void SetEditTool(const QString& sEditToolName, bool bStopCurrentTool = true) override; - void ReinitializeEditTool() override; - //! Returns current edit tool. - CEditTool* GetEditTool() override; ITransformManipulator* ShowTransformManipulator(bool bShow); ITransformManipulator* GetTransformManipulator(); @@ -360,23 +344,15 @@ public: protected: - ////////////////////////////////////////////////////////////////////////// - // EditorEntityContextNotificationBus implementation - void OnStartPlayInEditor() override; - ////////////////////////////////////////////////////////////////////////// AZStd::string LoadProjectIdFromProjectData(); void DetectVersion(); void RegisterTools(); void SetPrimaryCDFolder(); - void LoadSettings(); - void SaveSettings() const; - //! List of all notify listeners. std::list m_listeners; - EEditMode m_currEditMode; EOperationMode m_operationMode; ISystem* m_pSystem; IFileUtil* m_pFileUtil; @@ -390,8 +366,6 @@ protected: AABB m_selectedRegion; AxisConstrains m_selectedAxis; RefCoordSys m_refCoordsSys; - AxisConstrains m_lastAxis[16]; - RefCoordSys m_lastCoordSys[16]; bool m_bAxisVectorLock; bool m_bUpdates; bool m_bTerrainAxisIgnoreObjects; @@ -400,7 +374,6 @@ protected: CXmlTemplateRegistry m_templateRegistry; CDisplaySettings* m_pDisplaySettings; CShaderEnum* m_pShaderEnum; - _smart_ptr m_pEditTool; CIconManager* m_pIconManager; std::unique_ptr m_pGizmoParameters; QString m_primaryCDFolder; diff --git a/Code/Sandbox/Editor/Include/IObjectManager.h b/Code/Sandbox/Editor/Include/IObjectManager.h index 184a080870..bf1bb97db9 100644 --- a/Code/Sandbox/Editor/Include/IObjectManager.h +++ b/Code/Sandbox/Editor/Include/IObjectManager.h @@ -188,8 +188,6 @@ public: virtual void SetSelection(const QString& name) = 0; //! Removes one of named selections. virtual void RemoveSelection(const QString& name) = 0; - //! Checks for changes to the current selection and makes adjustments accordingly - virtual void CheckAndFixSelection() = 0; //! Delete all objects in current selection group. virtual void DeleteSelection() = 0; diff --git a/Code/Sandbox/Editor/InfoBar.cpp b/Code/Sandbox/Editor/InfoBar.cpp index 60c24fe84e..a1a1f7b055 100644 --- a/Code/Sandbox/Editor/InfoBar.cpp +++ b/Code/Sandbox/Editor/InfoBar.cpp @@ -25,12 +25,13 @@ #include "Objects/SelectionGroup.h" #include "Include/IObjectManager.h" #include "MathConversion.h" -#include "EditTool.h" AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING #include AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING +#include + #include #include "CryPhysicsDeprecation.h" @@ -53,12 +54,7 @@ CInfoBar::CInfoBar(QWidget* parent) { ui->setupUi(this); - m_enabledVector = false; - m_bVectorLock = false; - m_prevEditMode = 0; - m_bSelectionLocked = false; m_bSelectionChanged = false; - m_editTool = 0; m_bDragMode = false; m_prevMoveSpeed = 0; m_currValue = Vec3(-111, +222, -333); //this wasn't initialized. I don't know what a good value is @@ -72,25 +68,14 @@ CInfoBar::CInfoBar(QWidget* parent) OnInitDialog(); - connect(ui->m_vectorLock, &QToolButton::clicked, this, &CInfoBar::OnVectorLock); - connect(ui->m_lockSelection, &QToolButton::clicked, this, &CInfoBar::OnLockSelection); - auto comboBoxTextChanged = static_cast(&QComboBox::currentTextChanged); connect(ui->m_moveSpeed, comboBoxTextChanged, this, &CInfoBar::OnUpdateMoveSpeedText); connect(ui->m_moveSpeed->lineEdit(), &QLineEdit::returnPressed, this, &CInfoBar::OnSpeedComboBoxEnter); - connect(ui->m_posCtrl, &AzQtComponents::VectorInput::valueChanged, this, &CInfoBar::OnVectorChanged); - // Hide some buttons from the expander menu - AzQtComponents::Style::addClass(ui->m_posCtrl, "expanderMenu_hide"); AzQtComponents::Style::addClass(ui->m_physDoStepBtn, "expanderMenu_hide"); AzQtComponents::Style::addClass(ui->m_physSingleStepBtn, "expanderMenu_hide"); - // posCtrl is a VectorInput initialized via UI; as such, we can't construct it to have only 3 elements. - // We can just hide the W element as it is unused. - ui->m_posCtrl->getElements()[3]->setVisible(false); - - connect(ui->m_setVector, &QToolButton::clicked, this, &CInfoBar::OnBnClickedSetVector); connect(ui->m_physicsBtn, &QToolButton::clicked, this, &CInfoBar::OnBnClickedPhysics); connect(ui->m_physSingleStepBtn, &QToolButton::clicked, this, &CInfoBar::OnBnClickedSingleStepPhys); connect(ui->m_physDoStepBtn, &QToolButton::clicked, this, &CInfoBar::OnBnClickedDoStepPhys); @@ -101,12 +86,6 @@ CInfoBar::CInfoBar(QWidget* parent) connect(this, &CInfoBar::ActionTriggered, MainWindow::instance()->GetActionManager(), &ActionManager::ActionTriggered); - connect(ui->m_lockSelection, &QAbstractButton::toggled, ui->m_lockSelection, [this](bool checked) { - ui->m_lockSelection->setToolTip(checked ? tr("Unlock Object Selection") : tr("Lock Object Selection")); - }); - connect(ui->m_vectorLock, &QAbstractButton::toggled, ui->m_vectorLock, [this](bool checked) { - ui->m_vectorLock->setToolTip(checked ? tr("Unlock Axis Vectors") : tr("Lock Axis Vectors")); - }); connect(ui->m_physicsBtn, &QAbstractButton::toggled, ui->m_physicsBtn, [this](bool checked) { ui->m_physicsBtn->setToolTip(checked ? tr("Stop Simulation (Ctrl+P)") : tr("Simulate (Ctrl+P)")); }); @@ -123,27 +102,6 @@ CInfoBar::CInfoBar(QWidget* parent) ui->m_vrBtn->setToolTip(checked ? tr("Disable VR Preview") : tr("Enable VR Preview")); }); - // hide old ui elements that are not valid with the new viewport interaction model - if (GetIEditor()->IsNewViewportInteractionModelEnabled()) - { - ui->m_lockSelection->setVisible(false); - AzQtComponents::Style::addClass(ui->m_lockSelection, "expanderMenu_hide"); - ui->m_posCtrl->setVisible(false); - AzQtComponents::Style::addClass(ui->m_posCtrl, "expanderMenu_hide"); - ui->m_setVector->setVisible(false); - AzQtComponents::Style::addClass(ui->m_setVector, "expanderMenu_hide"); - ui->m_vectorLock->setVisible(false); - AzQtComponents::Style::addClass(ui->m_vectorLock, "expanderMenu_hide"); - - // As we're hiding some of the icons, we have an extra spacer to deal with. - // We cannot set the visibility of separators, so we'll have to take it out. - int separatorIndex = layout()->indexOf(ui->verticalSpacer_2); - QLayoutItem* separator = layout()->takeAt(separatorIndex); - - // takeAt() removes the item from the layout; delete to avoid memory leaks. - delete separator; - } - ui->m_moveSpeed->setValidator(new QDoubleValidator(m_minSpeed, m_maxSpeed, m_numDecimals, ui->m_moveSpeed)); // Save off the move speed here since setting up the combo box can cause it to update values in the background. @@ -209,172 +167,6 @@ void CInfoBar::OnEditorNotifyEvent(EEditorNotifyEvent event) { m_bSelectionChanged = true; } - else if (event == eNotify_OnEditModeChange) - { - int emode = GetIEditor()->GetEditMode(); - switch (emode) - { - case eEditModeMove: - ui->m_setVector->setToolTip(tr("Set Position of Selected Objects")); - break; - case eEditModeRotate: - ui->m_setVector->setToolTip(tr("Set Rotation of Selected Objects")); - break; - case eEditModeScale: - ui->m_setVector->setToolTip(tr("Set Scale of Selected Objects")); - break; - default: - ui->m_setVector->setToolTip(tr("Set Position/Rotation/Scale of Selected Objects (None Selected)")); - break; - } - } -} - -////////////////////////////////////////////////////////////////////////// - -void CInfoBar::OnVectorChanged() -{ - SetVector(GetVector()); - OnVectorUpdate(false); -} - -void CInfoBar::OnVectorUpdate(bool followTerrain) -{ - int emode = GetIEditor()->GetEditMode(); - if (emode != eEditModeMove && emode != eEditModeRotate && emode != eEditModeScale) - { - return; - } - - Vec3 v = GetVector(); - - ITransformManipulator* pManipulator = GetIEditor()->GetTransformManipulator(); - if (pManipulator) - { - CEditTool* pEditTool = GetIEditor()->GetEditTool(); - - if (pEditTool) - { - Vec3 diff = v - m_lastValue; - if (emode == eEditModeMove) - { - //GetIEditor()->RestoreUndo(); - pEditTool->OnManipulatorDrag(GetIEditor()->GetActiveView(), pManipulator, diff); - } - if (emode == eEditModeRotate) - { - diff = DEG2RAD(diff); - //GetIEditor()->RestoreUndo(); - pEditTool->OnManipulatorDrag(GetIEditor()->GetActiveView(), pManipulator, diff); - } - if (emode == eEditModeScale) - { - //GetIEditor()->RestoreUndo(); - pEditTool->OnManipulatorDrag(GetIEditor()->GetActiveView(), pManipulator, diff); - } - } - return; - } - - CSelectionGroup* selection = GetIEditor()->GetObjectManager()->GetSelection(); - if (selection->IsEmpty()) - { - return; - } - - GetIEditor()->RestoreUndo(); - - int referenceCoordSys = GetIEditor()->GetReferenceCoordSys(); - - CBaseObject* obj = GetIEditor()->GetSelectedObject(); - - Matrix34 tm; - AffineParts ap; - if (obj) - { - tm = obj->GetWorldTM(); - ap.SpectralDecompose(tm); - } - - if (emode == eEditModeMove) - { - if (obj) - { - if (referenceCoordSys == COORDS_WORLD) - { - tm.SetTranslation(v); - obj->SetWorldTM(tm); - } - else - { - obj->SetPos(v); - } - } - else - { - GetIEditor()->GetSelection()->MoveTo(v, followTerrain ? CSelectionGroup::eMS_FollowTerrain : CSelectionGroup::eMS_None, referenceCoordSys); - } - } - if (emode == eEditModeRotate) - { - if (obj) - { - AZ::Vector3 av = LYVec3ToAZVec3(v); - AZ::Transform tr = AZ::ConvertEulerDegreesToTransform(av); - Matrix34 lyTransform = AZTransformToLYTransform(tr); - - AffineParts newap; - newap.SpectralDecompose(lyTransform); - - if (referenceCoordSys == COORDS_WORLD) - { - tm = Matrix34::Create(ap.scale, newap.rot, ap.pos); - obj->SetWorldTM(tm); - } - else - { - obj->SetRotation(newap.rot); - } - } - else - { - CBaseObject *refObj; - CSelectionGroup* pGroup = GetIEditor()->GetSelection(); - if (pGroup && pGroup->GetCount() > 0) - { - refObj = pGroup->GetObject(0); - AffineParts ap2; - ap2.SpectralDecompose(refObj->GetWorldTM()); - Vec3 oldEulerRotation = AZVec3ToLYVec3(AZ::ConvertQuaternionToEulerDegrees(LYQuaternionToAZQuaternion(ap2.rot))); - Vec3 diff = v - oldEulerRotation; - GetIEditor()->GetSelection()->Rotate((Ang3)diff, referenceCoordSys); - } - } - } - if (emode == eEditModeScale) - { - if (v.x == 0 || v.y == 0 || v.z == 0) - { - return; - } - - if (obj) - { - if (referenceCoordSys == COORDS_WORLD) - { - tm = Matrix34::Create(v, ap.rot, ap.pos); - obj->SetWorldTM(tm); - } - else - { - obj->SetScale(v); - } - } - else - { - GetIEditor()->GetSelection()->SetScale(v, referenceCoordSys); - } - } } void CInfoBar::IdleUpdate() @@ -399,21 +191,6 @@ void CInfoBar::IdleUpdate() Vec3 marker = GetIEditor()->GetMarkerPosition(); - /* - // Get active viewport. - int hx = marker.x / 2; - int hy = marker.y / 2; - if (m_heightMapX != hx || m_heightMapY != hy) - { - m_heightMapX = hx; - m_heightMapY = hy; - updateUI = true; - } - */ - - RefCoordSys coordSys = GetIEditor()->GetReferenceCoordSys(); - bool bWorldSpace = GetIEditor()->GetReferenceCoordSys() == COORDS_WORLD; - CSelectionGroup* selection = GetIEditor()->GetSelection(); if (selection->GetCount() != m_numSelected) { @@ -421,39 +198,22 @@ void CInfoBar::IdleUpdate() updateUI = true; } - if (GetIEditor()->GetEditTool() != m_editTool) - { - updateUI = true; - m_editTool = GetIEditor()->GetEditTool(); - } - QString str; - if (m_editTool) + if (updateUI) { - str = m_editTool->GetStatusText(); - if (str != m_sLastText) + if (m_numSelected == 0) { - updateUI = true; + str = tr("None Selected"); } - } - - if (updateUI) - { - if (!m_editTool) + else if (m_numSelected == 1) { - if (m_numSelected == 0) - { - str = tr("None Selected"); - } - else if (m_numSelected == 1) - { - str = tr("1 Object Selected"); - } - else - { - str = tr("%1 Objects Selected").arg(m_numSelected); - } + str = tr("1 Object Selected"); } + else + { + str = tr("%1 Objects Selected").arg(m_numSelected); + } + ui->m_statusText->setText(str); m_sLastText = str; } @@ -488,198 +248,11 @@ void CInfoBar::IdleUpdate() } } - bool bSelLocked = GetIEditor()->IsSelectionLocked(); - if (bSelLocked != m_bSelectionLocked) - { - m_bSelectionLocked = bSelLocked; - ui->m_lockSelection->setChecked(m_bSelectionLocked); - } - - - if (GetIEditor()->GetSelection()->IsEmpty()) - { - if (ui->m_lockSelection->isEnabled()) - { - ui->m_lockSelection->setEnabled(false); - } - } - else - { - if (!ui->m_lockSelection->isEnabled()) - { - ui->m_lockSelection->setEnabled(true); - } - } - - ////////////////////////////////////////////////////////////////////////// - // Update vector. - ////////////////////////////////////////////////////////////////////////// - Vec3 v(0, 0, 0); - bool enable = false; - float min = 0, max = 10000; - - int emode = GetIEditor()->GetEditMode(); - ITransformManipulator* pManipulator = GetIEditor()->GetTransformManipulator(); - - if (pManipulator) - { - AffineParts ap; - ap.SpectralDecompose(pManipulator->GetTransformation(coordSys)); - - if (emode == eEditModeMove) - { - v = ap.pos; - enable = true; - - min = -64000; - max = 64000; - } - if (emode == eEditModeRotate) - { - v = Vec3(RAD2DEG(Ang3::GetAnglesXYZ(Matrix33(ap.rot)))); - enable = true; - min = -10000; - max = 10000; - } - if (emode == eEditModeScale) - { - v = ap.scale; - enable = true; - min = -10000; - max = 10000; - } - } - else - { - if (selection->IsEmpty()) - { - // Show marker position. - EnableVector(false); - SetVector(marker); - SetVectorRange(-100000, 100000); - return; - } - - CBaseObject* obj = GetIEditor()->GetSelectedObject(); - if (!obj) - { - CSelectionGroup* pGroup = GetIEditor()->GetSelection(); - if (pGroup && pGroup->GetCount() > 0) - { - obj = pGroup->GetObject(0); - } - } - - if (obj) - { - v = obj->GetWorldPos(); - } - - if (emode == eEditModeMove) - { - if (obj) - { - if (bWorldSpace) - { - v = obj->GetWorldTM().GetTranslation(); - } - else - { - v = obj->GetPos(); - } - } - enable = true; - min = -64000; - max = 64000; - } - if (emode == eEditModeRotate) - { - if (obj) - { - Quat objRot; - if (bWorldSpace) - { - AffineParts ap; - ap.SpectralDecompose(obj->GetWorldTM()); - objRot = ap.rot; - } - else - { - objRot = obj->GetRotation(); - } - - // Always convert objRot to v in order to ensure that the inspector and info bar are always in sync - v = AZVec3ToLYVec3(AZ::ConvertQuaternionToEulerDegrees(LYQuaternionToAZQuaternion(objRot))); - } - enable = true; - min = -10000; - max = 10000; - } - if (emode == eEditModeScale) - { - if (obj) - { - if (bWorldSpace) - { - AffineParts ap; - ap.SpectralDecompose(obj->GetWorldTM()); - v = ap.scale; - } - else - { - v = obj->GetScale(); - } - } - enable = true; - min = -10000; - max = 10000; - } - } - - bool updateDisplayVector = (m_currValue != v); - - // If Edit mode changed. - if (m_prevEditMode != emode) - { - // Scale mode enables vector lock. - SetVectorLock(emode == eEditModeScale); - - // Change undo strings. - QString undoString("Modify Object(s)"); - int mode = GetIEditor()->GetEditMode(); - switch (mode) - { - case eEditModeMove: - undoString = QStringLiteral("Move Object(s)"); - break; - case eEditModeRotate: - undoString = QStringLiteral("Rotate Object(s)"); - break; - case eEditModeScale: - undoString = QStringLiteral("Scale Object(s)"); - break; - } - - // edit mode changed, we must update the number values - updateDisplayVector = true; - } - - SetVectorRange(min, max); - EnableVector(enable); - // if our selection changed, or if our display values are out of date if (m_bSelectionChanged) { - updateDisplayVector = true; m_bSelectionChanged = false; } - - if (updateDisplayVector) - { - SetVector(v); - } - - m_prevEditMode = emode; } inline double Round(double fVal, double fStep) @@ -691,71 +264,6 @@ inline double Round(double fVal, double fStep) return fVal; } -void CInfoBar::SetVector(const Vec3& v) -{ - if (!m_bDragMode) - { - m_lastValue = m_currValue; - } - - if (m_currValue != v) - { - ui->m_posCtrl->setValuebyIndex(v.x, 0); - ui->m_posCtrl->setValuebyIndex(v.y, 1); - ui->m_posCtrl->setValuebyIndex(v.z, 2); - m_currValue = v; - } -} - -Vec3 CInfoBar::GetVector() -{ - Vec3 v; - v.x = ui->m_posCtrl->getElements()[0]->getValue(); - v.y = ui->m_posCtrl->getElements()[1]->getValue(); - v.z = ui->m_posCtrl->getElements()[2]->getValue(); - m_currValue = v; - return v; -} - -void CInfoBar::EnableVector(bool enable) -{ - if (m_enabledVector != enable) - { - m_enabledVector = enable; - ui->m_posCtrl->setEnabled(enable); - ui->m_vectorLock->setEnabled(enable); - ui->m_setVector->setEnabled(enable); - } -} - -void CInfoBar::SetVectorLock(bool bVectorLock) -{ - m_bVectorLock = bVectorLock; - ui->m_vectorLock->setChecked(bVectorLock); - GetIEditor()->SetAxisVectorLock(bVectorLock); -} - -void CInfoBar::SetVectorRange(float min, float max) -{ - // Worth noting that this gets called every IdleUpdate, so it is necessary to make sure - // setting the min/max doesn't result in the Qt event queue being pumped - ui->m_posCtrl->setMinimum(min); - ui->m_posCtrl->setMaximum(max); -} - -void CInfoBar::OnVectorLock() -{ - SetVectorLock(!m_bVectorLock); -} - -void CInfoBar::OnLockSelection() -{ - bool newLockSelectionValue = !m_bSelectionLocked; - m_bSelectionLocked = newLockSelectionValue; - ui->m_lockSelection->setChecked(newLockSelectionValue); - GetIEditor()->LockSelection(newLockSelectionValue); -} - void CInfoBar::OnUpdateMoveSpeedText(const QString& text) { gSettings.cameraMoveSpeed = aznumeric_cast(Round(text.toDouble(), m_speedStep)); @@ -771,12 +279,6 @@ void CInfoBar::OnInitDialog() QFontMetrics metrics({}); int width = metrics.boundingRect("-9999.99").width() * m_fieldWidthMultiplier; - ui->m_posCtrl->setEnabled(false); - ui->m_posCtrl->getElements()[0]->setFixedWidth(width); - ui->m_posCtrl->getElements()[1]->setFixedWidth(width); - ui->m_posCtrl->getElements()[2]->setFixedWidth(width); - ui->m_setVector->setEnabled(false); - ui->m_moveSpeed->setFixedWidth(width); ui->m_physicsBtn->setEnabled(false); @@ -850,12 +352,6 @@ void CInfoBar::OnBnClickedGotoPosition() emit ActionTriggered(ID_DISPLAY_GOTOPOSITION); } -////////////////////////////////////////////////////////////////////////// -void CInfoBar::OnBnClickedSetVector() -{ - emit ActionTriggered(ID_DISPLAY_SETVECTOR); -} - ////////////////////////////////////////////////////////////////////////// void CInfoBar::OnBnClickedMuteAudio() { diff --git a/Code/Sandbox/Editor/InfoBar.h b/Code/Sandbox/Editor/InfoBar.h index 6bf89099fe..6e547d46c6 100644 --- a/Code/Sandbox/Editor/InfoBar.h +++ b/Code/Sandbox/Editor/InfoBar.h @@ -59,24 +59,9 @@ protected: virtual void OnOK() {}; virtual void OnCancel() {}; - void OnVectorUpdate(bool followTerrain); - - // this gets called by stepper or text edit changes - void OnVectorChanged(); - - void SetVector(const Vec3& v); - void SetVectorRange(float min, float max); - Vec3 GetVector(); - void EnableVector(bool enable); - - void SetVectorLock(bool bVectorLock); - void OnBnClickedSyncplayer(); void OnBnClickedGotoPosition(); - void OnVectorLock(); - void OnLockSelection(); - void OnBnClickedSetVector(); void OnSpeedComboBoxEnter(); void OnUpdateMoveSpeedText(const QString&); void OnBnClickedTerrainCollision(); @@ -98,13 +83,10 @@ protected: void EnteredComponentMode(const AZStd::vector& componentModeTypes) override; void LeftComponentMode(const AZStd::vector& componentModeTypes) override; - bool m_enabledVector; - float m_width, m_height; //int m_heightMapX,m_heightMapY; double m_fieldWidthMultiplier = 1.8; - int m_prevEditMode; int m_numSelected; float m_prevMoveSpeed; @@ -117,14 +99,11 @@ protected: // Speed presets float m_speedPresetValues[3] = { 0.1f, 1.0f, 10.0f }; - bool m_bVectorLock; - bool m_bSelectionLocked; bool m_bSelectionChanged; bool m_bDragMode; QString m_sLastText; - CEditTool* m_editTool; Vec3 m_lastValue; Vec3 m_currValue; float m_oldMainVolume; diff --git a/Code/Sandbox/Editor/InfoBar.ui b/Code/Sandbox/Editor/InfoBar.ui index e6d135da4b..84207629df 100644 --- a/Code/Sandbox/Editor/InfoBar.ui +++ b/Code/Sandbox/Editor/InfoBar.ui @@ -57,42 +57,6 @@ - - - - - 0 - 0 - - - - Position - - - - - - - - 0 - 0 - - - - XYZ - - - - :/InfoBar/XYZ-default.svg:/InfoBar/XYZ-default.svg - - - - 22 - 18 - - - - @@ -135,68 +99,6 @@ - - - - Lock Object Selection - - - Lock Selection - - - - :/InfoBar/LockSelection-default.svg:/InfoBar/LockSelection-default.svg - - - - 18 - 18 - - - - true - - - - - - - Lock Scale Axis Vectors - - - Lock Scale - - - - :/InfoBar/LockScale-default.svg:/InfoBar/LockScale-default.svg - - - - 18 - 18 - - - - true - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 1 - 18 - - - - @@ -424,13 +326,6 @@ - - - AzQtComponents::VectorInput - QWidget -
AzQtComponents/Components/Widgets/VectorInput.h
-
-
diff --git a/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h b/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h index e48fb5fec1..b28a80967a 100644 --- a/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h +++ b/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h @@ -20,7 +20,7 @@ class CEditorMock : public IEditor { public: - // GMock does not work with a variadic function (https://github.com/google/googlemock/blob/master/googlemock/docs/FrequentlyAskedQuestions.md) + // GMock does not work with a variadic function void ExecuteCommand(const char* sCommand, ...) override { va_list args; @@ -123,12 +123,6 @@ public: MOCK_METHOD0(GetRuler, CRuler* ()); MOCK_METHOD1(SetOperationMode, void(EOperationMode )); MOCK_METHOD0(GetOperationMode, EOperationMode()); - MOCK_METHOD1(SetEditMode, void(int )); - MOCK_METHOD0(GetEditMode, int()); - MOCK_METHOD2(SetEditTool, void(CEditTool*, bool)); - MOCK_METHOD2(SetEditTool, void(const QString&, bool)); - MOCK_METHOD0(ReinitializeEditTool, void()); - MOCK_METHOD0(GetEditTool, CEditTool* ()); MOCK_METHOD1(ShowTransformManipulator, ITransformManipulator* (bool)); MOCK_METHOD0(GetTransformManipulator, ITransformManipulator* ()); MOCK_METHOD1(SetAxisConstraints, void(AxisConstrains )); diff --git a/Code/Sandbox/Editor/Lib/Tests/test_EditorPythonBindings.cpp b/Code/Sandbox/Editor/Lib/Tests/test_EditorPythonBindings.cpp index 3bb33d623b..6456b95c00 100644 --- a/Code/Sandbox/Editor/Lib/Tests/test_EditorPythonBindings.cpp +++ b/Code/Sandbox/Editor/Lib/Tests/test_EditorPythonBindings.cpp @@ -151,9 +151,6 @@ namespace EditorPythonBindingsUnitTests EXPECT_TRUE(behaviorContext->m_methods.find("get_axis_constraint") != behaviorContext->m_methods.end()); EXPECT_TRUE(behaviorContext->m_methods.find("set_axis_constraint") != behaviorContext->m_methods.end()); - EXPECT_TRUE(behaviorContext->m_methods.find("get_edit_mode") != behaviorContext->m_methods.end()); - EXPECT_TRUE(behaviorContext->m_methods.find("set_edit_mode") != behaviorContext->m_methods.end()); - EXPECT_TRUE(behaviorContext->m_methods.find("get_pak_from_file") != behaviorContext->m_methods.end()); EXPECT_TRUE(behaviorContext->m_methods.find("log") != behaviorContext->m_methods.end()); @@ -200,8 +197,6 @@ namespace EditorPythonBindingsUnitTests EXPECT_TRUE(behaviorBus->m_events.find("OpenFileBox") != behaviorBus->m_events.end()); EXPECT_TRUE(behaviorBus->m_events.find("GetAxisConstraint") != behaviorBus->m_events.end()); EXPECT_TRUE(behaviorBus->m_events.find("SetAxisConstraint") != behaviorBus->m_events.end()); - EXPECT_TRUE(behaviorBus->m_events.find("GetEditMode") != behaviorBus->m_events.end()); - EXPECT_TRUE(behaviorBus->m_events.find("SetEditMode") != behaviorBus->m_events.end()); EXPECT_TRUE(behaviorBus->m_events.find("GetPakFromFile") != behaviorBus->m_events.end()); EXPECT_TRUE(behaviorBus->m_events.find("Log") != behaviorBus->m_events.end()); EXPECT_TRUE(behaviorBus->m_events.find("Undo") != behaviorBus->m_events.end()); diff --git a/Code/Sandbox/Editor/Lib/Tests/test_SetVectorDlg.cpp b/Code/Sandbox/Editor/Lib/Tests/test_SetVectorDlg.cpp deleted file mode 100644 index 18faf6deba..0000000000 --- a/Code/Sandbox/Editor/Lib/Tests/test_SetVectorDlg.cpp +++ /dev/null @@ -1,92 +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. -* -*/ - -#include "EditorDefs.h" -#include -#include - -#include - -using namespace AZ; -using namespace ::testing; - -namespace UnitTest -{ - class TestSetVectorDlg - : public ::testing::Test - { - public: - - }; - - const float SetVectorDlgNearTolerance = 0.0001f; - - TEST_F(TestSetVectorDlg, GetVectorFromString_ThreeParams_Success) - { - QString testStr{ "1,2,3" }; - Vec3 result{ 0, 0, 0 }; - - result = CSetVectorDlg::GetVectorFromString(testStr); - - EXPECT_NEAR(result[0], 1.0f, SetVectorDlgNearTolerance); - EXPECT_NEAR(result[1], 2.0f, SetVectorDlgNearTolerance); - EXPECT_NEAR(result[2], 3.0f, SetVectorDlgNearTolerance); - } - - TEST_F(TestSetVectorDlg, GetVectorFromString_FourParams_ThreeParsed) - { - QString testStr{ "1,2,3,4" }; - Vec3 result{ 0, 0, 0 }; - - result = CSetVectorDlg::GetVectorFromString(testStr); - - EXPECT_NEAR(result[0], 1.0f, SetVectorDlgNearTolerance); - EXPECT_NEAR(result[1], 2.0f, SetVectorDlgNearTolerance); - EXPECT_NEAR(result[2], 3.0f, SetVectorDlgNearTolerance); - } - - TEST_F(TestSetVectorDlg, GetVectorFromString_TwoParams_ThirdZero) - { - QString testStr{ "1,2" }; - Vec3 result{ 0, 0, 0 }; - - result = CSetVectorDlg::GetVectorFromString(testStr); - - EXPECT_NEAR(result[0], 1.0f, SetVectorDlgNearTolerance); - EXPECT_NEAR(result[1], 2.0f, SetVectorDlgNearTolerance); - EXPECT_NEAR(result[2], 0.0f, SetVectorDlgNearTolerance); - } - - TEST_F(TestSetVectorDlg, GetVectorFromString_NoParams_AllZero) - { - QString testStr; - Vec3 result{ 0, 0, 0 }; - - result = CSetVectorDlg::GetVectorFromString(testStr); - - EXPECT_NEAR(result[0], 0.0f, SetVectorDlgNearTolerance); - EXPECT_NEAR(result[1], 0.0f, SetVectorDlgNearTolerance); - EXPECT_NEAR(result[2], 0.0f, SetVectorDlgNearTolerance); - } - - TEST_F(TestSetVectorDlg, GetVectorFromString_BadStrings_AllZero) - { - QString testStr{ "some,illegal,strings" }; - Vec3 resultExpected{ 0, 1, 0 }; - - auto result = CSetVectorDlg::GetVectorFromString(testStr); - - EXPECT_NEAR(result[0], 0.0f, SetVectorDlgNearTolerance); - EXPECT_NEAR(result[1], 0.0f, SetVectorDlgNearTolerance); - EXPECT_NEAR(result[2], 0.0f, SetVectorDlgNearTolerance); - } -} // namespace UnitTest diff --git a/Code/Sandbox/Editor/MainWindow.cpp b/Code/Sandbox/Editor/MainWindow.cpp index 6acd8cfc20..902b04f266 100644 --- a/Code/Sandbox/Editor/MainWindow.cpp +++ b/Code/Sandbox/Editor/MainWindow.cpp @@ -60,7 +60,6 @@ AZ_POP_DISABLE_WARNING // Editor #include "Resource.h" -#include "EditTool.h" #include "Core/LevelEditorMenuHandler.h" #include "ShortcutDispatcher.h" #include "LayoutWnd.h" @@ -270,15 +269,6 @@ namespace return QtViewPaneManager::instance()->IsVisible(viewClassName); } - AZStd::string PyGetStatusText() - { - if (GetIEditor()->GetEditTool()) - { - return AZStd::string(GetIEditor()->GetEditTool()->GetStatusText().toUtf8().data()); - } - return AZStd::string(""); - } - AZStd::vector PyGetViewPaneNames() { const QtViewPanes panes = QtViewPaneManager::instance()->GetRegisteredPanes(); @@ -693,7 +683,6 @@ void MainWindow::closeEvent(QCloseEvent* event) } // Close all edit panels. GetIEditor()->ClearSelection(); - GetIEditor()->SetEditTool(0); GetIEditor()->GetObjectManager()->EndEditParams(); // force clean up of all deferred deletes, so that we don't have any issues with windows from plugins not being deleted yet @@ -761,11 +750,6 @@ void MainWindow::InitActions() am->AddAction(ID_TOOLBAR_SEPARATOR, QString()); - if (!GetIEditor()->IsNewViewportInteractionModelEnabled()) - { - am->AddAction(ID_TOOLBAR_WIDGET_REF_COORD, QString()); - } - am->AddAction(ID_TOOLBAR_WIDGET_UNDO, QString()); am->AddAction(ID_TOOLBAR_WIDGET_REDO, QString()); am->AddAction(ID_TOOLBAR_WIDGET_SNAP_ANGLE, QString()); @@ -1006,18 +990,6 @@ void MainWindow::InitActions() am->AddAction(ID_EDIT_RENAMEOBJECT, tr("Rename Object(s)...")) .SetStatusTip(tr("Rename Object")); - if (!GetIEditor()->IsNewViewportInteractionModelEnabled()) - { - am->AddAction(ID_EDITMODE_SELECT, tr("Select mode")) - .SetIcon(Style::icon("Select")) - .SetApplyHoverEffect() - .SetShortcut(tr("1")) - .SetToolTip(tr("Select mode (1)")) - .SetCheckable(true) - .SetStatusTip(tr("Select object(s)")) - .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateEditmodeSelect); - } - am->AddAction(ID_EDITMODE_MOVE, tr("Move")) .SetIcon(Style::icon("Move")) .SetApplyHoverEffect() @@ -1043,74 +1015,6 @@ void MainWindow::InitActions() .SetStatusTip(tr("Select and scale selected object(s)")) .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateEditmodeScale); - if (!GetIEditor()->IsNewViewportInteractionModelEnabled()) - { - am->AddAction(ID_EDITMODE_SELECTAREA, tr("Select terrain")) - .SetIcon(Style::icon("Select_terrain")) - .SetApplyHoverEffect() - .SetShortcut(tr("5")) - .SetToolTip(tr("Select terrain (5)")) - .SetCheckable(true) - .SetStatusTip(tr("Switch to terrain selection mode")) - .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateEditmodeSelectarea); - am->AddAction(ID_SELECT_AXIS_X, tr("Constrain to X axis")) - .SetIcon(Style::icon("X_axis")) - .SetApplyHoverEffect() - .SetShortcut(tr("Ctrl+1")) - .SetToolTip(tr("Constrain to X axis (Ctrl+1)")) - .SetCheckable(true) - .SetStatusTip(tr("Lock movement on X axis")) - .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSelectAxisX); - am->AddAction(ID_SELECT_AXIS_Y, tr("Constrain to Y axis")) - .SetIcon(Style::icon("Y_axis")) - .SetApplyHoverEffect() - .SetShortcut(tr("Ctrl+2")) - .SetToolTip(tr("Constrain to Y axis (Ctrl+2)")) - .SetCheckable(true) - .SetStatusTip(tr("Lock movement on Y axis")) - .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSelectAxisY); - am->AddAction(ID_SELECT_AXIS_Z, tr("Constrain to Z axis")) - .SetIcon(Style::icon("Z_axis")) - .SetApplyHoverEffect() - .SetShortcut(tr("Ctrl+3")) - .SetToolTip(tr("Constrain to Z axis (Ctrl+3)")) - .SetCheckable(true) - .SetStatusTip(tr("Lock movement on Z axis")) - .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSelectAxisZ); - am->AddAction(ID_SELECT_AXIS_XY, tr("Constrain to XY plane")) - .SetIcon(Style::icon("XY2_copy")) - .SetApplyHoverEffect() - .SetShortcut(tr("Ctrl+4")) - .SetToolTip(tr("Constrain to XY plane (Ctrl+4)")) - .SetCheckable(true) - .SetStatusTip(tr("Lock movement on XY plane")) - .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSelectAxisXy); - am->AddAction(ID_SELECT_AXIS_TERRAIN, tr("Constrain to terrain/geometry")) - .SetIcon(Style::icon("Object_follow_terrain")) - .SetApplyHoverEffect() - .SetShortcut(tr("Ctrl+5")) - .SetToolTip(tr("Constrain to terrain/geometry (Ctrl+5)")) - .SetCheckable(true) - .SetStatusTip(tr("Lock object movement to follow terrain")) - .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSelectAxisTerrain); - am->AddAction(ID_SELECT_AXIS_SNAPTOALL, tr("Follow terrain and snap to objects")) - .SetIcon(Style::icon("Follow_terrain")) - .SetApplyHoverEffect() - .SetShortcut(tr("Ctrl+6")) - .SetToolTip(tr("Follow terrain and snap to objects (Ctrl+6)")) - .SetCheckable(true) - .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSelectAxisSnapToAll); - am->AddAction(ID_OBJECTMODIFY_ALIGNTOGRID, tr("Align to grid")) - .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSelected) - .SetIcon(Style::icon("Align_to_grid")) - .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) - .SetIcon(Style::icon("Align_object_to_surface")) - .SetApplyHoverEffect(); - } - am->AddAction(ID_SNAP_TO_GRID, tr("Snap to grid")) .SetIcon(Style::icon("Grid")) .SetApplyHoverEffect() @@ -1169,7 +1073,6 @@ void MainWindow::InitActions() am->AddAction(ID_CHANGEMOVESPEED_CHANGESTEP, tr("Change Step")) .SetStatusTip(tr("Change Flycam Movement Step")); am->AddAction(ID_DISPLAY_GOTOPOSITION, tr("Go to Position...")); - am->AddAction(ID_DISPLAY_SETVECTOR, tr("Display Set Vector")); am->AddAction(ID_MODIFY_GOTO_SELECTION, tr("Center on Selection")) .SetShortcut(tr("Z")) .SetToolTip(tr("Center on Selection (Z)")) @@ -1459,10 +1362,6 @@ void MainWindow::InitActions() .SetIcon(QIcon(":/MainWindow/toolbars/object_toolbar-03.svg")) .SetApplyHoverEffect() .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSelected); - // vertex snapping not yet supported when the new Viewport Interaction Model is enabled - am->AddAction(ID_OBJECTMODIFY_VERTEXSNAPPING, tr("Vertex snapping")) - .SetIcon(Style::icon("Vertex_snapping")) - .SetApplyHoverEffect(); } // Misc Toolbar Actions @@ -1510,8 +1409,6 @@ void MainWindow::OnEscapeAction() { AzToolsFramework::EditorEvents::Bus::Broadcast( &AzToolsFramework::EditorEvents::OnEscape); - - CCryEditApp::instance()->OnEditEscape(); } } } @@ -1522,62 +1419,6 @@ void MainWindow::InitToolBars() AdjustToolBarIconSize(static_cast(gSettings.gui.nToolbarIconSize)); } -QComboBox* MainWindow::CreateRefCoordComboBox() -{ - // ID_REF_COORDS_SYS; - auto coordSysCombo = new RefCoordComboBox(this); - - connect(this, &MainWindow::ToggleRefCoordSys, coordSysCombo, &RefCoordComboBox::ToggleRefCoordSys); - connect(this, &MainWindow::UpdateRefCoordSys, coordSysCombo, &RefCoordComboBox::UpdateRefCoordSys); - - return coordSysCombo; -} - -RefCoordComboBox::RefCoordComboBox(QWidget* parent) - : QComboBox(parent) -{ - addItems(coordSysList()); - setCurrentIndex(0); - - connect(this, static_cast(&QComboBox::currentIndexChanged), this, [](int index) - { - if (index >= 0 && index < LAST_COORD_SYSTEM) - { - RefCoordSys coordSys = (RefCoordSys)index; - if (GetIEditor()->GetReferenceCoordSys() != index) - { - GetIEditor()->SetReferenceCoordSys(coordSys); - } - } - }); - - UpdateRefCoordSys(); -} - -QStringList RefCoordComboBox::coordSysList() const -{ - static QStringList list = { tr("View"), tr("Local"), tr("Parent"), tr("World"), tr("Custom") }; - return list; -} - -void RefCoordComboBox::UpdateRefCoordSys() -{ - RefCoordSys coordSys = GetIEditor()->GetReferenceCoordSys(); - if (coordSys >= 0 && coordSys < LAST_COORD_SYSTEM) - { - setCurrentIndex(coordSys); - } -} - -void RefCoordComboBox::ToggleRefCoordSys() -{ - QStringList coordSys = coordSysList(); - const int localIndex = coordSys.indexOf(tr("Local")); - const int worldIndex = coordSys.indexOf(tr("World")); - const int newIndex = currentIndex() == localIndex ? worldIndex : localIndex; - setCurrentIndex(newIndex); -} - QToolButton* MainWindow::CreateUndoRedoButton(int command) { // We do either undo or redo below, sort that out here @@ -2542,9 +2383,6 @@ QWidget* MainWindow::CreateToolbarWidget(int actionId) case ID_TOOLBAR_WIDGET_REDO: w = CreateUndoRedoButton(ID_REDO); break; - case ID_TOOLBAR_WIDGET_REF_COORD: - w = CreateRefCoordComboBox(); - break; case ID_TOOLBAR_WIDGET_SNAP_GRID: w = CreateSnapToGridWidget(); break; @@ -2640,7 +2478,6 @@ namespace AzToolsFramework addLegacyGeneral(behaviorContext->Method("exit", PyExit, nullptr, "Exits the editor.")); addLegacyGeneral(behaviorContext->Method("exit_no_prompt", PyExitNoPrompt, nullptr, "Exits the editor without prompting to save first.")); addLegacyGeneral(behaviorContext->Method("report_test_result", PyReportTest, nullptr, "Report test information.")); - addLegacyGeneral(behaviorContext->Method("get_status_text", PyGetStatusText, nullptr, "Gets the status text from the Editor's current edit tool")); } } } diff --git a/Code/Sandbox/Editor/MainWindow.h b/Code/Sandbox/Editor/MainWindow.h index c40d732cee..3e652888fe 100644 --- a/Code/Sandbox/Editor/MainWindow.h +++ b/Code/Sandbox/Editor/MainWindow.h @@ -77,19 +77,6 @@ namespace AzToolsFramework // Subclassing so we can add slots to our toolbar widgets // Using lambdas is crashy since the lamdba doesn't know when the widget is deleted. -class RefCoordComboBox - : public QComboBox -{ - Q_OBJECT -public: - explicit RefCoordComboBox(QWidget* parent); -public Q_SLOTS: - void ToggleRefCoordSys(); - void UpdateRefCoordSys(); -private: - QStringList coordSysList() const; -}; - class UndoRedoToolButton : public QToolButton { @@ -229,8 +216,6 @@ private: QWidget* CreateSnapToGridWidget(); QWidget* CreateSnapToAngleWidget(); - QComboBox* CreateRefCoordComboBox(); - QToolButton* CreateUndoRedoButton(int command); QToolButton* CreateEnvironmentModeButton(); diff --git a/Code/Sandbox/Editor/Material/MaterialPickTool.cpp b/Code/Sandbox/Editor/Material/MaterialPickTool.cpp deleted file mode 100644 index 38e3d0612d..0000000000 --- a/Code/Sandbox/Editor/Material/MaterialPickTool.cpp +++ /dev/null @@ -1,170 +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 "MaterialPickTool.h" - -// Editor -#include "MaterialManager.h" -#include "SurfaceInfoPicker.h" -#include "Viewport.h" - - -#define RENDER_MESH_TEST_DISTANCE 0.2f - -static IClassDesc * s_ToolClass = NULL; - -////////////////////////////////////////////////////////////////////////// -CMaterialPickTool::CMaterialPickTool() -{ - m_pClassDesc = s_ToolClass; - m_statusText = tr("Left Click To Pick Material"); -} - -////////////////////////////////////////////////////////////////////////// -CMaterialPickTool::~CMaterialPickTool() -{ - SetMaterial(0); -} - -////////////////////////////////////////////////////////////////////////// -bool CMaterialPickTool::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags) -{ - if (event == eMouseLDown) - { - if (m_pMaterial) - { - CMaterial* pMtl = GetIEditor()->GetMaterialManager()->FromIMaterial(m_pMaterial); - if (pMtl) - { - GetIEditor()->GetMaterialManager()->SetHighlightedMaterial(0); - GetIEditor()->OpenMaterialLibrary(pMtl); - Abort(); - return true; - } - } - } - else if (event == eMouseMove) - { - return OnMouseMove(view, flags, point); - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialPickTool::Display(DisplayContext& dc) -{ - QPoint mousePoint = QCursor::pos(); - - dc.view->ScreenToClient(mousePoint); - - Vec3 wp = dc.view->ViewToWorld(mousePoint); - - if (m_pMaterial) - { - float color[4] = {1, 1, 1, 1}; - dc.renderer->Draw2dLabel(mousePoint.x() + 12, mousePoint.y ()+ 8, 1.2f, color, false, "%s", m_displayString.toUtf8().data()); - } - - float fScreenScale = dc.view->GetScreenScaleFactor(m_HitInfo.vHitPos) * 0.06f; - - dc.DepthTestOff(); - dc.SetColor(ColorB(0, 0, 255, 255)); - if (!m_HitInfo.vHitNormal.IsZero()) - { - dc.DrawLine(m_HitInfo.vHitPos, m_HitInfo.vHitPos + m_HitInfo.vHitNormal * fScreenScale); - - Vec3 raySrc, rayDir; - dc.view->ViewToWorldRay(mousePoint, raySrc, rayDir); - - Matrix34 tm; - - Vec3 zAxis = m_HitInfo.vHitNormal; - Vec3 xAxis = rayDir.Cross(zAxis); - if (!xAxis.IsZero()) - { - xAxis.Normalize(); - Vec3 yAxis = xAxis.Cross(zAxis).GetNormalized(); - tm.SetFromVectors(xAxis, yAxis, zAxis, m_HitInfo.vHitPos); - - dc.PushMatrix(tm); - dc.DrawCircle(Vec3(0, 0, 0), 0.5f * fScreenScale); - dc.PopMatrix(); - } - } - dc.DepthTestOn(); -} - -////////////////////////////////////////////////////////////////////////// -bool CMaterialPickTool::OnMouseMove(CViewport* view, [[maybe_unused]] UINT nFlags, const QPoint& point) -{ - view->SetCurrentCursor(STD_CURSOR_HIT, ""); - - _smart_ptr pNearestMaterial(NULL); - - m_Mouse2DPosition = point; - - CSurfaceInfoPicker surfacePicker; - int nPickObjectGroupFlag = CSurfaceInfoPicker::ePOG_All; - if (surfacePicker.Pick(point, pNearestMaterial, m_HitInfo, NULL, nPickObjectGroupFlag)) - { - SetMaterial(pNearestMaterial); - return true; - } - - SetMaterial(0); - return false; -} - -const GUID& CMaterialPickTool::GetClassID() -{ - // {FD20F6F2-7B87-4349-A5D4-7533538E357F} - static const GUID guid = { - 0xfd20f6f2, 0x7b87, 0x4349, { 0xa5, 0xd4, 0x75, 0x33, 0x53, 0x8e, 0x35, 0x7f } - }; - return guid; -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialPickTool::RegisterTool(CRegistrationContext& rc) -{ - rc.pClassFactory->RegisterClass(s_ToolClass = new CQtViewClass("EditTool.PickMaterial", "Material", ESYSTEM_CLASS_EDITTOOL)); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialPickTool::SetMaterial(_smart_ptr pMaterial) -{ - if (pMaterial == m_pMaterial) - { - return; - } - - m_pMaterial = pMaterial; - CMaterial* pCMaterial = GetIEditor()->GetMaterialManager()->FromIMaterial(m_pMaterial); - GetIEditor()->GetMaterialManager()->SetHighlightedMaterial(pCMaterial); - - m_displayString = ""; - if (pMaterial) - { - QString sfType; - sfType = QStringLiteral("%1 : %2").arg(pMaterial->GetSurfaceType()->GetId()).arg(pMaterial->GetSurfaceType()->GetName()); - - m_displayString = "\n"; - m_displayString += pMaterial->GetName(); - m_displayString += "\n"; - m_displayString += sfType; - } -} - -#include diff --git a/Code/Sandbox/Editor/Material/MaterialPickTool.h b/Code/Sandbox/Editor/Material/MaterialPickTool.h deleted file mode 100644 index 09c5691315..0000000000 --- a/Code/Sandbox/Editor/Material/MaterialPickTool.h +++ /dev/null @@ -1,57 +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_MATERIAL_MATERIALPICKTOOL_H -#define CRYINCLUDE_EDITOR_MATERIAL_MATERIALPICKTOOL_H -#pragma once - -#include "EditTool.h" - -////////////////////////////////////////////////////////////////////////// -class CMaterialPickTool - : public CEditTool -{ - Q_OBJECT -public: - Q_INVOKABLE CMaterialPickTool(); - - static const GUID& GetClassID(); - - static void RegisterTool(CRegistrationContext& rc); - - ////////////////////////////////////////////////////////////////////////// - // CEditTool implementation - ////////////////////////////////////////////////////////////////////////// - virtual bool MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags); - virtual void Display(DisplayContext& dc); - ////////////////////////////////////////////////////////////////////////// - -protected: - - bool OnMouseMove(CViewport* view, UINT nFlags, const QPoint& point); - void SetMaterial(_smart_ptr pMaterial); - - virtual ~CMaterialPickTool(); - // Delete itself. - void DeleteThis() { delete this; }; - - _smart_ptr m_pMaterial; - QString m_displayString; - QPoint m_Mouse2DPosition; - SRayHitInfo m_HitInfo; -}; - - -#endif // CRYINCLUDE_EDITOR_MATERIAL_MATERIALPICKTOOL_H diff --git a/Code/Sandbox/Editor/NullEditTool.cpp b/Code/Sandbox/Editor/NullEditTool.cpp deleted file mode 100644 index b848ed6364..0000000000 --- a/Code/Sandbox/Editor/NullEditTool.cpp +++ /dev/null @@ -1,37 +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. -* -*/ - -#include "EditorDefs.h" - -#include "NullEditTool.h" - - -NullEditTool::NullEditTool() {} - -const GUID& NullEditTool::GetClassID() -{ - // {65AFF87A-34E0-479B-B062-94B1B867B13D} - static const GUID guid = - { - 0x65AFF87A, 0x34E0, 0x479B,{ 0xB0, 0x62, 0x94, 0xB1, 0xB8, 0x67, 0xB1, 0x3D } - }; - - return guid; -} - -void NullEditTool::RegisterTool(CRegistrationContext& rc) -{ - rc.pClassFactory->RegisterClass( - new CQtViewClass("EditTool.NullEditTool", "Select", ESYSTEM_CLASS_EDITTOOL)); -} - -#include diff --git a/Code/Sandbox/Editor/NullEditTool.h b/Code/Sandbox/Editor/NullEditTool.h deleted file mode 100644 index 44bb4ce76d..0000000000 --- a/Code/Sandbox/Editor/NullEditTool.h +++ /dev/null @@ -1,39 +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. -* -*/ - -#pragma once - -#if !defined(Q_MOC_RUN) -#include "EditTool.h" -#endif - -/// An EditTool that does nothing - it provides the Null-Object pattern. -class SANDBOX_API NullEditTool - : public CEditTool -{ - Q_OBJECT -public: - Q_INVOKABLE NullEditTool(); - virtual ~NullEditTool() = default; - - static const GUID& GetClassID(); - static void RegisterTool(CRegistrationContext& rc); - - // CEditTool - void BeginEditParams([[maybe_unused]] IEditor* ie, [[maybe_unused]] int flags) override {} - void EndEditParams() override {} - void Display([[maybe_unused]] DisplayContext& dc) override {} - bool MouseCallback([[maybe_unused]] CViewport* view, [[maybe_unused]] EMouseEvent event, [[maybe_unused]] QPoint& point, [[maybe_unused]] int flags) override { return false; } - bool OnKeyDown([[maybe_unused]] CViewport* view, [[maybe_unused]] uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) override { return false; } - bool OnKeyUp([[maybe_unused]] CViewport* view, [[maybe_unused]] uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) override { return true; } - void DeleteThis() override { delete this; } -}; \ No newline at end of file diff --git a/Code/Sandbox/Editor/ObjectCloneTool.cpp b/Code/Sandbox/Editor/ObjectCloneTool.cpp deleted file mode 100644 index fd8256f4cb..0000000000 --- a/Code/Sandbox/Editor/ObjectCloneTool.cpp +++ /dev/null @@ -1,336 +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 "ObjectCloneTool.h" - -// Editor -#include "MainWindow.h" -#include "Viewport.h" -#include "ViewManager.h" -#include "Include/IObjectManager.h" -#include "Objects/SelectionGroup.h" -#include "Settings.h" - -////////////////////////////////////////////////////////////////////////// -// Class description. -////////////////////////////////////////////////////////////////////////// -class CObjectCloneTool_ClassDesc - : public CRefCountClassDesc -{ - virtual ESystemClassID SystemClassID() { return ESYSTEM_CLASS_EDITTOOL; } - virtual REFGUID ClassID() - { - // {6A73E865-71DF-4ED0-ABA2-457E66119B35} - static const GUID guid = { - 0x6a73e865, 0x71df, 0x4ed0,{ 0xab, 0xa2, 0x45, 0x7e, 0x66, 0x11, 0x9b, 0x35 } - }; - return guid; - } - virtual QString ClassName() { return "EditTool.Clone"; }; - virtual QString Category() { return "EditTool"; }; -}; -CObjectCloneTool_ClassDesc g_cloneClassDesc; - -////////////////////////////////////////////////////////////////////////// -CObjectCloneTool::CObjectCloneTool() - : m_currentUndoBatch(nullptr) -{ - m_pClassDesc = &g_cloneClassDesc; - m_bSetConstrPlane = true; - - GetIEditor()->SuperBeginUndo(); - - GetIEditor()->BeginUndo(); - m_selection = nullptr; - if (!GetIEditor()->GetSelection()->IsEmpty()) - { - QWaitCursor wait; - CloneSelection(); - m_selection = GetIEditor()->GetSelection(); - m_origin = m_selection->GetCenter(); - } - GetIEditor()->AcceptUndo("Clone"); - GetIEditor()->BeginUndo(); - - if (!gSettings.deepSelectionSettings.bStickDuplicate) - { - SetStatusText("Clone object at the same location"); - } - else - { - SetStatusText("Left click to clone object"); - } -} - -////////////////////////////////////////////////////////////////////////// -CObjectCloneTool::~CObjectCloneTool() -{ - EndUndoBatch(); - - if (GetIEditor()->IsUndoRecording()) - { - GetIEditor()->SuperCancelUndo(); - } -} - -////////////////////////////////////////////////////////////////////////// -void CObjectCloneTool::CloneSelection() -{ - // Allow component application to intercept cloning behavior. - // This is to allow support for "smart" cloning of prefabs, and other contextual features. - AZ_Assert(!m_currentUndoBatch, "CloneSelection undo batch already created."); - EBUS_EVENT_RESULT(m_currentUndoBatch, AzToolsFramework::ToolsApplicationRequests::Bus, BeginUndoBatch, "Clone Selection"); - bool handled = false; - EBUS_EVENT(AzToolsFramework::EditorRequests::Bus, CloneSelection, handled); - if (handled) - { - GetIEditor()->GetObjectManager()->CheckAndFixSelection(); - return; - } - - // This is the legacy case. We're not cloning AZ entities, so abandon the AZ undo batch. - EndUndoBatch(); - - CSelectionGroup selObjects; - CSelectionGroup sel; - - CSelectionGroup* currSelection = GetIEditor()->GetSelection(); - - currSelection->Clone(selObjects); - - GetIEditor()->ClearSelection(); - for (int i = 0; i < selObjects.GetCount(); i++) - { - if (selObjects.GetObject(i)) - { - GetIEditor()->SelectObject(selObjects.GetObject(i)); - } - } - MainWindow::instance()->setFocus(); -} - -////////////////////////////////////////////////////////////////////////// -void CObjectCloneTool::SetConstrPlane(CViewport* view, [[maybe_unused]] const QPoint& point) -{ - Matrix34 originTM; - originTM.SetIdentity(); - CSelectionGroup* selection = GetIEditor()->GetSelection(); - if (selection->GetCount() == 1) - { - originTM = selection->GetObject(0)->GetWorldTM(); - } - else if (selection->GetCount() > 1) - { - originTM = selection->GetObject(0)->GetWorldTM(); - Vec3 center = view->SnapToGrid(originTM.GetTranslation()); - originTM.SetTranslation(center); - } - view->SetConstructionMatrix(COORDS_LOCAL, originTM); -} - -//static Vec3 gP1,gP2; -////////////////////////////////////////////////////////////////////////// -void CObjectCloneTool::Display([[maybe_unused]] DisplayContext& dc) -{ - //dc.SetColor( 1,1,0,1 ); - //dc.DrawBall( gP1,1.1f ); - //dc.DrawBall( gP2,1.1f ); -} - -////////////////////////////////////////////////////////////////////////// -bool CObjectCloneTool::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags) -{ - if (m_selection) - { - // Set construction plane origin to selection origin. - if (m_bSetConstrPlane) - { - SetConstrPlane(view, point); - m_bSetConstrPlane = false; - } - - if (event == eMouseLDown) - { - // Accept group. - Accept(); - GetIEditor()->GetSelection()->FinishChanges(); - return true; - } - if (event == eMouseMove) - { - // Move selection. - CSelectionGroup* selection = GetIEditor()->GetSelection(); - if (selection != m_selection) - { - Abort(); - } - else if (!selection->IsEmpty()) - { - GetIEditor()->RestoreUndo(); - - Vec3 v; - bool followTerrain = false; - - CSelectionGroup* pSelection = GetIEditor()->GetSelection(); - Vec3 selectionCenter = view->SnapToGrid(pSelection->GetCenter()); - - int axis = GetIEditor()->GetAxisConstrains(); - if (axis == AXIS_TERRAIN) - { - bool hitTerrain; - v = view->ViewToWorld(point, &hitTerrain) - selectionCenter; - if (axis == AXIS_TERRAIN) - { - v = view->SnapToGrid(v); - if (hitTerrain) - { - followTerrain = true; - v.z = 0; - } - } - } - else - { - Vec3 p1 = selectionCenter; - Vec3 p2 = view->MapViewToCP(point); - if (p2.IsZero()) - { - return true; - } - - v = view->GetCPVector(p1, p2); - // Snap v offset to grid if its enabled. - view->SnapToGrid(v); - } - - CSelectionGroup::EMoveSelectionFlag selectionFlag = CSelectionGroup::eMS_None; - if (followTerrain) - { - selectionFlag = CSelectionGroup::eMS_FollowTerrain; - } - - // Disable undo recording for these move commands as the only operation we need - // to undo is the creation of the new object. Undo commands are queued so it's - // possible that the object creation could be undone before attempting to undo - // these move operations causing undesired behavior. - bool wasRecording = CUndo::IsRecording(); - if (wasRecording) - { - GetIEditor()->SuspendUndo(); - } - - GetIEditor()->GetSelection()->Move(v, selectionFlag, GetIEditor()->GetReferenceCoordSys(), point); - - if (wasRecording) - { - GetIEditor()->ResumeUndo(); - } - } - } - if (event == eMouseWheel) - { - CSelectionGroup* selection = GetIEditor()->GetSelection(); - if (selection != m_selection) - { - Abort(); - } - else if (!selection->IsEmpty()) - { - double angle = 1; - - if (view->GetViewManager()->GetGrid()->IsAngleSnapEnabled()) - { - angle = view->GetViewManager()->GetGrid()->GetAngleSnap(); - } - - for (int i = 0; i < selection->GetCount(); ++i) - { - CBaseObject* pObj = selection->GetFilteredObject(i); - Quat rot = pObj->GetRotation(); - rot.SetRotationXYZ(Ang3(0, 0, rot.GetRotZ() + DEG2RAD(flags > 0 ? angle * (-1) : angle))); - pObj->SetRotation(rot); - } - GetIEditor()->AcceptUndo("Rotate Selection"); - } - } - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -void CObjectCloneTool::Abort() -{ - EndUndoBatch(); - - // Abort - GetIEditor()->SetEditTool(0); -} - -////////////////////////////////////////////////////////////////////////// -void CObjectCloneTool::Accept(bool resetPosition) -{ - // Close the az undo batch so it can add the appropriate objects to the cry undo stack - EndUndoBatch(); - - if (resetPosition) - { - GetIEditor()->GetSelection()->MoveTo(m_origin, CSelectionGroup::eMS_None, GetIEditor()->GetReferenceCoordSys()); - } - - if (GetIEditor()->IsUndoRecording()) - { - GetIEditor()->SuperAcceptUndo("Clone"); - } - - GetIEditor()->SetEditTool(0); -} - -////////////////////////////////////////////////////////////////////////// -void CObjectCloneTool::EndUndoBatch() -{ - if (m_currentUndoBatch) - { - AzToolsFramework::UndoSystem::URSequencePoint* undoBatch = nullptr; - EBUS_EVENT_RESULT(undoBatch, AzToolsFramework::ToolsApplicationRequests::Bus, GetCurrentUndoBatch); - AZ_Error("ObjectCloneTool", undoBatch == m_currentUndoBatch, "Undo batch is not in sync."); - if (undoBatch == m_currentUndoBatch) - { - EBUS_EVENT(AzToolsFramework::ToolsApplicationRequests::Bus, EndUndoBatch); - } - m_currentUndoBatch = nullptr; - } -} - -////////////////////////////////////////////////////////////////////////// -void CObjectCloneTool::BeginEditParams([[maybe_unused]] IEditor* ie, [[maybe_unused]] int flags) -{ -} - -////////////////////////////////////////////////////////////////////////// -void CObjectCloneTool::EndEditParams() -{ -} - -////////////////////////////////////////////////////////////////////////// -bool CObjectCloneTool::OnKeyDown([[maybe_unused]] CViewport* view, uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) -{ - if (nChar == VK_ESCAPE) - { - Abort(); - } - return false; -} - -#include diff --git a/Code/Sandbox/Editor/ObjectCloneTool.h b/Code/Sandbox/Editor/ObjectCloneTool.h deleted file mode 100644 index f027456a4e..0000000000 --- a/Code/Sandbox/Editor/ObjectCloneTool.h +++ /dev/null @@ -1,81 +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 ObjectCloneTool, edit tool for cloning of objects.. - - -#ifndef CRYINCLUDE_EDITOR_OBJECTCLONETOOL_H -#define CRYINCLUDE_EDITOR_OBJECTCLONETOOL_H - -#pragma once - -#include "EditTool.h" - -class CBaseObject; - -namespace AzToolsFramework -{ - namespace UndoSystem - { - class URSequencePoint; - } -} - -/*! - * CObjectCloneTool, When created duplicate current selection, and manages cloned selection. - * - */ - -class CObjectCloneTool - : public CEditTool -{ - Q_OBJECT -public: - Q_INVOKABLE CObjectCloneTool(); - - ////////////////////////////////////////////////////////////////////////// - // 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(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; }; - ////////////////////////////////////////////////////////////////////////// - - void Accept(bool resetPosition = false); - void Abort(); - -protected: - virtual ~CObjectCloneTool(); - // Delete itself. - void DeleteThis() { delete this; }; - -private: - void CloneSelection(); - void SetConstrPlane(CViewport* view, const QPoint& point); - - CSelectionGroup* m_selection; - Vec3 m_origin; - bool m_bSetConstrPlane; - //bool m_bSetCapture; - - void EndUndoBatch(); - - AzToolsFramework::UndoSystem::URSequencePoint* m_currentUndoBatch; -}; - - -#endif // CRYINCLUDE_EDITOR_OBJECTCLONETOOL_H diff --git a/Code/Sandbox/Editor/Objects/AxisGizmo.cpp b/Code/Sandbox/Editor/Objects/AxisGizmo.cpp index 590b1256ac..40970838c1 100644 --- a/Code/Sandbox/Editor/Objects/AxisGizmo.cpp +++ b/Code/Sandbox/Editor/Objects/AxisGizmo.cpp @@ -24,7 +24,6 @@ #include "RenderHelpers/AxisHelper.h" #include "RenderHelpers/AxisHelperExtended.h" #include "IObjectManager.h" -#include "EditTool.h" ////////////////////////////////////////////////////////////////////////// // CAxisGizmo implementation. @@ -138,36 +137,6 @@ void CAxisGizmo::GetWorldBounds(AABB& bbox) void CAxisGizmo::DrawAxis(DisplayContext& dc) { m_pAxisHelper->SetHighlightAxis(m_highlightAxis); - // Only enable axis planes when editor is in Move mode. - int nEditMode = GetIEditor()->GetEditMode(); - int nModeFlags = 0; - switch (nEditMode) - { - case eEditModeMove: - nModeFlags |= CAxisHelper::MOVE_MODE; - break; - case eEditModeRotate: - nModeFlags |= CAxisHelper::ROTATE_MODE; - nModeFlags &= ~(CAxisHelper::ROTATE_CIRCLE_MODE); - break; - case eEditModeRotateCircle: - nModeFlags |= CAxisHelper::ROTATE_CIRCLE_MODE; - nModeFlags &= ~(CAxisHelper::ROTATE_MODE); - break; - case eEditModeScale: - nModeFlags |= CAxisHelper::SCALE_MODE; - break; - case eEditModeSelect: - nModeFlags |= CAxisHelper::SELECT_MODE; - break; - case eEditModeSelectArea: - nModeFlags |= CAxisHelper::SELECT_MODE; - break; - } - - //nModeFlags |= CAxisHelper::MOVE_MODE | CAxisHelper::ROTATE_MODE | CAxisHelper::SCALE_MODE; - - m_pAxisHelper->SetMode(nModeFlags); Matrix34 tm = GetTransformation(m_bAlwaysUseLocal ? COORDS_LOCAL : GetIEditor()->GetReferenceCoordSys(), dc.view); m_pAxisHelper->DrawAxis(tm, GetIEditor()->GetGlobalGizmoParameters(), dc); @@ -178,21 +147,6 @@ void CAxisGizmo::DrawAxis(DisplayContext& dc) m_pAxisHelper->DrawDome(tm, GetIEditor()->GetGlobalGizmoParameters(), dc, objectBox); } - ////////////////////////////////////////////////////////////////////////// - // Draw extended infinite-axis gizmo - ////////////////////////////////////////////////////////////////////////// - if (!(dc.flags & DISPLAY_2D) && - (nModeFlags == CAxisHelper::MOVE_MODE || - nModeFlags == CAxisHelper::ROTATE_MODE)) - { - bool bClickedShift = CheckVirtualKey(Qt::Key_Shift); - if (bClickedShift && (m_axisGizmoCount == 1 || m_highlightAxis || (m_axisGizmoCount == 2 && m_object && m_object->IsSkipSelectionHelper()))) - { - bool bClickedAlt = CheckVirtualKey(Qt::Key_Menu); - bool bUsePhysicalProxy = !bClickedAlt; - m_pAxisHelperExtended->DrawAxes(dc, tm, bUsePhysicalProxy); - } - } } ////////////////////////////////////////////////////////////////////////// @@ -325,7 +279,7 @@ Matrix34 CAxisGizmo::GetTransformation(RefCoordSys coordSys, IDisplayViewport* v } ////////////////////////////////////////////////////////////////////////// -bool CAxisGizmo::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int nFlags) +bool CAxisGizmo::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, [[maybe_unused]] int nFlags) { AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Editor); @@ -365,28 +319,6 @@ bool CAxisGizmo::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point m_cMouseDownPos = point; m_initPos = GetTransformation(COORDS_WORLD).GetTranslation(); - switch (hc.manipulatorMode) - { - case 1: - view->SetCurrentCursor(STD_CURSOR_MOVE); - GetIEditor()->SetEditMode(eEditModeMove); - break; - case 2: - view->SetCurrentCursor(STD_CURSOR_ROTATE); - GetIEditor()->SetEditMode(eEditModeRotate); - break; - case 3: - view->SetCurrentCursor(STD_CURSOR_SCALE); - GetIEditor()->SetEditMode(eEditModeScale); - break; - } - - CEditTool* pEditTool = view->GetEditTool(); - if (pEditTool) - { - pEditTool->OnManipulatorMouseEvent(view, this, event, point, nFlags); - } - return true; } } @@ -394,158 +326,6 @@ bool CAxisGizmo::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point { if (m_bDragging) { - bool bCallBack = true; - Vec3 vDragValue(0, 0, 0); - // Dragging transform manipulator. - switch (GetIEditor()->GetEditMode()) - { - case eEditModeMove: - { - view->SetCurrentCursor(STD_CURSOR_MOVE); - - if (view->GetAxisConstrain() == AXIS_TERRAIN) - { - if (nFlags & MK_CONTROL) - { - bool bCollideWithTerrain; - Vec3 posOnTerrain = view->ViewToWorld(point, &bCollideWithTerrain, true); - if (!bCollideWithTerrain) - { - return true; - } - vDragValue = posOnTerrain - m_initPos; - } - else - { - Vec3 p1 = view->SnapToGrid(view->ViewToWorld(m_cMouseDownPos)); - Vec3 p2 = view->SnapToGrid(view->ViewToWorld(point)); - vDragValue = p2 - p1; - vDragValue.z = 0; - } - } - else - { - Vec3 p1 = view->MapViewToCP(m_cMouseDownPos); - Vec3 p2 = view->MapViewToCP(point); - if (p1.IsZero() || p2.IsZero()) - { - return true; - } - vDragValue = view->GetCPVector(p1, p2); - } - } - break; - case eEditModeRotate: - { - view->SetCurrentCursor(STD_CURSOR_ROTATE); - - Ang3 ang(0, 0, 0); - float ax = (point.x() - m_cMouseDownPos.x()); - float ay = (point.y() - m_cMouseDownPos.y()); - switch (view->GetAxisConstrain()) - { - case AXIS_X: - ang.x = ay; - break; - case AXIS_Y: - ang.y = ay; - break; - case AXIS_Z: - ang.z = ay; - break; - case AXIS_XY: - ang(ax, ay, 0); - break; - case AXIS_XZ: - ang(ax, 0, ay); - break; - case AXIS_YZ: - ang(0, ay, ax); - break; - case AXIS_TERRAIN: - ang(ax, ay, 0); - break; - } - ; - ang = gSettings.pGrid->SnapAngle(ang); - vDragValue = Vec3(DEG2RAD(ang)); - } - break; - case eEditModeScale: - { - Vec3 scl(0, 0, 0); - float ay = 1.0f - 0.01f * (point.y() - m_cMouseDownPos.y()); - if (ay < 0.01f) - { - ay = 0.01f; - } - scl(ay, ay, ay); - switch (view->GetAxisConstrain()) - { - case AXIS_X: - scl(ay, 1, 1); - break; - case AXIS_Y: - scl(1, ay, 1); - break; - case AXIS_Z: - scl(1, 1, ay); - break; - case AXIS_XY: - scl(ay, ay, ay); - break; - case AXIS_XZ: - scl(ay, ay, ay); - break; - case AXIS_YZ: - scl(ay, ay, ay); - break; - case AXIS_XYZ: - scl(ay, ay, ay); - break; - case AXIS_TERRAIN: - scl(ay, ay, ay); - break; - } - ; - view->SetCurrentCursor(STD_CURSOR_SCALE); - vDragValue = scl; - } - break; - case eEditModeRotateCircle: - { - Matrix34 tm = GetTransformation(m_bAlwaysUseLocal ? COORDS_LOCAL : GetIEditor()->GetReferenceCoordSys()); - Vec3 v0, v1; - Vec3 vHitNormal; - if (m_pAxisHelper->HitTestForRotationCircle(tm, view, m_cMouseDownPos, 0.05f, &v0, &vHitNormal) && m_pAxisHelper->HitTestForRotationCircle(tm, view, point, 2.0f, &v1, &vHitNormal)) - { - Vec3 vDir0 = (v0 - tm.GetTranslation()).GetNormalized(); - Vec3 vDir1 = (v1 - tm.GetTranslation()).GetNormalized(); - - Vec3 vCurlDir = vDir0.Cross(vDir1).GetNormalized(); - if (vHitNormal.Dot(vCurlDir) > 0) - { - vDragValue = Vec3(std::acos(vDir0.Dot(vDir1)), 0, 0); - } - else - { - vDragValue = Vec3(-std::acos(vDir0.Dot(vDir1)), 0, 0); - } - } - else - { - bCallBack = false; - } - } - break; - } - - CEditTool* pEditTool = view->GetEditTool(); - if (pEditTool && bCallBack) - { - pEditTool->OnManipulatorDrag(view, this, m_cMouseDownPos, point, vDragValue); - } - return true; } else @@ -573,12 +353,6 @@ bool CAxisGizmo::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point } bHit = true; } - - CEditTool* pEditTool = view->GetEditTool(); - if (pEditTool) - { - pEditTool->OnManipulatorMouseEvent(view, this, event, point, nFlags, bHit); - } } } else if (event == eMouseLUp) @@ -593,12 +367,6 @@ bool CAxisGizmo::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point { GetIEditor()->SetReferenceCoordSys(m_coordSysBackUp); } - - CEditTool* pEditTool = view->GetEditTool(); - if (pEditTool) - { - pEditTool->OnManipulatorMouseEvent(view, this, event, point, nFlags); - } } } diff --git a/Code/Sandbox/Editor/Objects/BaseObject.cpp b/Code/Sandbox/Editor/Objects/BaseObject.cpp index 36b954315e..a579f303a9 100644 --- a/Code/Sandbox/Editor/Objects/BaseObject.cpp +++ b/Code/Sandbox/Editor/Objects/BaseObject.cpp @@ -39,7 +39,6 @@ #include "ViewManager.h" #include "IEditorImpl.h" #include "GameEngine.h" -#include "EditTool.h" // To use the Andrew's algorithm in order to make convex hull from the points, this header is needed. #include "Util/GeometryUtil.h" @@ -3264,11 +3263,6 @@ ERotationWarningLevel CBaseObject::GetRotationWarningLevel() const bool CBaseObject::IsSkipSelectionHelper() const { - CEditTool* pEditTool(GetIEditor()->GetEditTool()); - if (pEditTool && pEditTool->IsNeedToSkipPivotBoxForObjects()) - { - return true; - } return false; } diff --git a/Code/Sandbox/Editor/Objects/ObjectManager.cpp b/Code/Sandbox/Editor/Objects/ObjectManager.cpp index aff6d51816..96d015e2c1 100644 --- a/Code/Sandbox/Editor/Objects/ObjectManager.cpp +++ b/Code/Sandbox/Editor/Objects/ObjectManager.cpp @@ -22,12 +22,10 @@ #include "Settings.h" #include "DisplaySettings.h" #include "EntityObject.h" -#include "NullEditTool.h" #include "Viewport.h" #include "GizmoManager.h" #include "AxisGizmo.h" #include "ObjectPhysicsManager.h" -#include "EditMode/ObjectMode.h" #include "GameEngine.h" #include "WaitProgress.h" #include "Util/Image.h" @@ -838,8 +836,6 @@ void CObjectManager::Update() QWidget* prevActiveWindow = QApplication::activeWindow(); - CheckAndFixSelection(); - // Restore focus if it changed. if (prevActiveWindow && QApplication::activeWindow() != prevActiveWindow) { @@ -1230,60 +1226,6 @@ void CObjectManager::RemoveSelection(const QString& name) } } -//! Checks the state of the current selection and fixes it if necessary - Used when AZ Code modifies the selection -void CObjectManager::CheckAndFixSelection() -{ - AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Editor); - bool bObjectMode = qobject_cast(GetIEditor()->GetEditTool()) != nullptr; - - if (m_currSelection->GetCount() == 0) - { - // Nothing selected. - EndEditParams(); - if (bObjectMode) - { - GetIEditor()->ShowTransformManipulator(false); - } - } - else if (m_currSelection->GetCount() == 1) - { - if (!m_bSingleSelection) - { - EndEditParams(); - } - - CBaseObject* newSelObject = m_currSelection->GetObject(0); - // Single object selected. - if (m_currEditObject != m_currSelection->GetObject(0)) - { - m_bSelectionChanged = false; - if (!m_currEditObject || (m_currEditObject->metaObject() != newSelObject->metaObject())) - { - // If old object and new objects are of different classes. - EndEditParams(); - } - if (GetIEditor()->GetEditTool() && GetIEditor()->GetEditTool()->IsUpdateUIPanel()) - { - BeginEditParams(newSelObject, OBJECT_EDIT); - } - - //AfxGetMainWnd()->SetFocus(); - } - } - else if (m_currSelection->GetCount() > 1) - { - // Multiple objects are selected. - if (m_bSelectionChanged && bObjectMode) - { - m_bSelectionChanged = false; - m_nLastSelCount = m_currSelection->GetCount(); - EndEditParams(); - - m_currEditObject = m_currSelection->GetObject(0); - } - } -} - void CObjectManager::SelectCurrent() { AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Editor); @@ -1404,8 +1346,6 @@ void CObjectManager::FindDisplayableObjects(DisplayContext& dc, bool bDisplay) pDispayedViewObjects->ClearObjects(); pDispayedViewObjects->Reserve(m_visibleObjects.size()); - CEditTool* pEditTool = GetIEditor()->GetEditTool(); - const bool newViewportInteractionModelEnabled = GetIEditor()->IsNewViewportInteractionModelEnabled(); if (dc.flags & DISPLAY_2D) @@ -1426,11 +1366,6 @@ void CObjectManager::FindDisplayableObjects(DisplayContext& dc, bool bDisplay) { obj->Display(dc); } - - if (pEditTool) - { - pEditTool->DrawObjectHelpers(obj, dc); - } } } } @@ -1476,11 +1411,6 @@ void CObjectManager::FindDisplayableObjects(DisplayContext& dc, bool bDisplay) { obj->Display(dc); } - - if (pEditTool) - { - pEditTool->DrawObjectHelpers(obj, dc); - } } } } @@ -1737,12 +1667,6 @@ bool CObjectManager::HitTestObject(CBaseObject* obj, HitContext& hc) { return false; } - - CEditTool* pEditTool = GetIEditor()->GetEditTool(); - if (pEditTool && pEditTool->HitTest(obj, hc)) - { - return true; - } } return (bSelectionHelperHit || obj->HitTest(hc)); @@ -2742,10 +2666,6 @@ void CObjectManager::SelectObjectInRect(CBaseObject* pObj, CViewport* view, HitC void CObjectManager::EnteredComponentMode(const AZStd::vector& /*componentModeTypes*/) { - // provide an EditTool that does nothing. - // note: will hide rotation gizmo when active (CRotateTool) - GetIEditor()->SetEditTool(new NullEditTool()); - // hide current gizmo for entity (translate/rotate/scale) IGizmoManager* gizmoManager = GetGizmoManager(); const size_t gizmoCount = static_cast(gizmoManager->GetGizmoCount()); @@ -2757,9 +2677,6 @@ void CObjectManager::EnteredComponentMode(const AZStd::vector& /*compo void CObjectManager::LeftComponentMode(const AZStd::vector& /*componentModeTypes*/) { - // return to default EditTool (in whatever transform mode is set) - GetIEditor()->SetEditTool(nullptr); - // show translate/rotate/scale gizmo again if (IGizmoManager* gizmoManager = GetGizmoManager()) { diff --git a/Code/Sandbox/Editor/Objects/ObjectManager.h b/Code/Sandbox/Editor/Objects/ObjectManager.h index eca23bc92b..f13616451e 100644 --- a/Code/Sandbox/Editor/Objects/ObjectManager.h +++ b/Code/Sandbox/Editor/Objects/ObjectManager.h @@ -226,8 +226,6 @@ public: //! Set one of name selections as current selection. void SetSelection(const QString& name); void RemoveSelection(const QString& name); - //! Checks for changes to the current selection and makes adjustments accordingly - void CheckAndFixSelection() override; bool IsObjectDeletionAllowed(CBaseObject* pObject); diff --git a/Code/Sandbox/Editor/PythonEditorEventsBus.h b/Code/Sandbox/Editor/PythonEditorEventsBus.h index f4b2971a17..69ef2671a1 100644 --- a/Code/Sandbox/Editor/PythonEditorEventsBus.h +++ b/Code/Sandbox/Editor/PythonEditorEventsBus.h @@ -139,16 +139,6 @@ namespace AzToolsFramework */ virtual void SetAxisConstraint(AZStd::string_view pConstrain) = 0; - /* - * Gets edit mode. - */ - virtual const char* GetEditMode() = 0; - - /* - * Sets edit mode. - */ - virtual void SetEditMode(AZStd::string_view pEditMode) = 0; - /* * Finds a pak file name for a given file. */ diff --git a/Code/Sandbox/Editor/PythonEditorFuncs.cpp b/Code/Sandbox/Editor/PythonEditorFuncs.cpp index f5de22387c..8f735706fd 100644 --- a/Code/Sandbox/Editor/PythonEditorFuncs.cpp +++ b/Code/Sandbox/Editor/PythonEditorFuncs.cpp @@ -688,68 +688,6 @@ namespace } } - ////////////////////////////////////////////////////////////////////////// - // Edit Mode - ////////////////////////////////////////////////////////////////////////// - const char* PyGetEditMode() - { - int actualEditMode = GetIEditor()->GetEditMode(); - switch (actualEditMode) - { - case eEditModeSelect: - return "SELECT"; - case eEditModeSelectArea: - return "SELECTAREA"; - case eEditModeMove: - return "MOVE"; - case eEditModeRotate: - return "ROTATE"; - case eEditModeScale: - return "SCALE"; - case eEditModeTool: - return "TOOL"; - default: - throw std::logic_error("Invalid edit mode."); - } - } - - void PySetEditMode(AZStd::string_view pEditMode) - { - if (pEditMode == "MOVE") - { - GetIEditor()->SetEditMode(eEditModeMove); - } - else if (pEditMode == "ROTATE") - { - GetIEditor()->SetEditMode(eEditModeRotate); - } - else if (pEditMode == "SCALE") - { - GetIEditor()->SetEditMode(eEditModeScale); - } - else if (pEditMode == "SELECT") - { - GetIEditor()->SetEditMode(eEditModeSelect); - } - else if (pEditMode == "SELECTAREA") - { - GetIEditor()->SetEditMode(eEditModeSelectArea); - } - else if (pEditMode == "TOOL") - { - GetIEditor()->SetEditMode(eEditModeTool); - } - else if (pEditMode == "RULER") - { - CRuler* pRuler = GetIEditor()->GetRuler(); - pRuler->SetActive(!pRuler->IsActive()); - } - else - { - throw std::logic_error("Invalid edit mode."); - } - } - ////////////////////////////////////////////////////////////////////////// const char* PyGetPakFromFile(const char* filename) { @@ -1031,8 +969,6 @@ namespace AzToolsFramework ->Event("OpenFileBox", &EditorLayerPythonRequestBus::Events::OpenFileBox) ->Event("GetAxisConstraint", &EditorLayerPythonRequestBus::Events::GetAxisConstraint) ->Event("SetAxisConstraint", &EditorLayerPythonRequestBus::Events::SetAxisConstraint) - ->Event("GetEditMode", &EditorLayerPythonRequestBus::Events::GetEditMode) - ->Event("SetEditMode", &EditorLayerPythonRequestBus::Events::SetEditMode) ->Event("GetPakFromFile", &EditorLayerPythonRequestBus::Events::GetPakFromFile) ->Event("Log", &EditorLayerPythonRequestBus::Events::Log) ->Event("Undo", &EditorLayerPythonRequestBus::Events::Undo) @@ -1168,16 +1104,6 @@ namespace AzToolsFramework return PySetAxisConstraint(pConstrain); } - const char* PythonEditorComponent::GetEditMode() - { - return PyGetEditMode(); - } - - void PythonEditorComponent::SetEditMode(AZStd::string_view pEditMode) - { - return PySetEditMode(pEditMode); - } - const char* PythonEditorComponent::GetPakFromFile(const char* filename) { return PyGetPakFromFile(filename); @@ -1252,9 +1178,6 @@ namespace AzToolsFramework addLegacyGeneral(behaviorContext->Method("get_axis_constraint", PyGetAxisConstraint, nullptr, "Gets axis.")); addLegacyGeneral(behaviorContext->Method("set_axis_constraint", PySetAxisConstraint, nullptr, "Sets axis.")); - addLegacyGeneral(behaviorContext->Method("get_edit_mode", PyGetEditMode, nullptr, "Gets edit mode.")); - addLegacyGeneral(behaviorContext->Method("set_edit_mode", PySetEditMode, nullptr, "Sets edit mode.")); - addLegacyGeneral(behaviorContext->Method("get_pak_from_file", PyGetPakFromFile, nullptr, "Finds a pak file name for a given file.")); addLegacyGeneral(behaviorContext->Method("log", PyLog, nullptr, "Prints the message to the editor console window.")); diff --git a/Code/Sandbox/Editor/PythonEditorFuncs.h b/Code/Sandbox/Editor/PythonEditorFuncs.h index 37cb6bd551..471f0d581f 100644 --- a/Code/Sandbox/Editor/PythonEditorFuncs.h +++ b/Code/Sandbox/Editor/PythonEditorFuncs.h @@ -95,10 +95,6 @@ namespace AzToolsFramework void SetAxisConstraint(AZStd::string_view pConstrain) override; - const char* GetEditMode() override; - - void SetEditMode(AZStd::string_view pEditMode) override; - const char* GetPakFromFile(const char* filename) override; void Log(const char* pMessage) override; diff --git a/Code/Sandbox/Editor/RenderHelpers/AxisHelperShared.inl b/Code/Sandbox/Editor/RenderHelpers/AxisHelperShared.inl index fa56a21a8b..a6ceaf578f 100644 --- a/Code/Sandbox/Editor/RenderHelpers/AxisHelperShared.inl +++ b/Code/Sandbox/Editor/RenderHelpers/AxisHelperShared.inl @@ -17,7 +17,6 @@ #include "Include/IDisplayViewport.h" #include "Include/HitContext.h" #include "Util/Math.h" -#include "EditTool.h" #include "IObjectManager.h" #include diff --git a/Code/Sandbox/Editor/RenderViewport.cpp b/Code/Sandbox/Editor/RenderViewport.cpp index 213a4ed895..af4cbd46bc 100644 --- a/Code/Sandbox/Editor/RenderViewport.cpp +++ b/Code/Sandbox/Editor/RenderViewport.cpp @@ -66,7 +66,6 @@ #include "Util/fastlib.h" #include "CryEditDoc.h" #include "GameEngine.h" -#include "EditTool.h" #include "ViewManager.h" #include "Objects/DisplayContext.h" #include "DisplaySettings.h" @@ -1948,12 +1947,6 @@ void CRenderViewport::RenderAll() m_entityVisibilityQuery.DisplayVisibility(*debugDisplay); - if (GetEditTool()) - { - // display editing tool - GetEditTool()->Display(displayContext); - } - if (m_manipulatorManager != nullptr) { using namespace AzToolsFramework::ViewportInteraction; @@ -2776,35 +2769,6 @@ void CRenderViewport::OnMouseWheel(Qt::KeyboardModifiers modifiers, short zDelta handled = result != MouseInteractionResult::None; } - else - { - if (m_manipulatorManager == nullptr || m_manipulatorManager->ConsumeViewportMouseWheel(mouseInteraction)) - { - return; - } - - if (AzToolsFramework::ComponentModeFramework::InComponentMode()) - { - AzToolsFramework::EditorInteractionSystemViewportSelectionRequestBus::EventResult( - handled, AzToolsFramework::GetEntityContextId(), - &EditorInteractionSystemViewportSelectionRequestBus::Events::InternalHandleMouseViewportInteraction, - MouseInteractionEvent(mouseInteraction, zDelta)); - } - else - { - ////////////////////////////////////////////////////////////////////////// - // Asks current edit tool to handle mouse callback. - CEditTool* pEditTool = GetEditTool(); - if (pEditTool && (modifiers & Qt::ControlModifier)) - { - QPoint tempPoint(scaledPoint.x(), scaledPoint.y()); - if (pEditTool->MouseCallback(this, eMouseWheel, tempPoint, zDelta)) - { - handled = true; - } - } - } - } if (!handled) { @@ -4337,96 +4301,17 @@ void CRenderViewport::RenderSnappingGrid() { return; } - if (GetIEditor()->GetEditMode() != eEditModeMove - && GetIEditor()->GetEditMode() != eEditModeRotate) - { - return; - } CGrid* pGrid = GetViewManager()->GetGrid(); if (pGrid->IsEnabled() == false && pGrid->IsAngleSnapEnabled() == false) { return; } - if (GetIEditor()->GetEditTool() && !GetIEditor()->GetEditTool()->IsDisplayGrid()) - { - return; - } DisplayContext& dc = m_displayContext; int prevState = dc.GetState(); dc.DepthWriteOff(); - Vec3 p = pSelGroup->GetObject(0)->GetWorldPos(); - - AABB bbox; - pSelGroup->GetObject(0)->GetBoundBox(bbox); - float size = 2 * bbox.GetRadius(); - float alphaMax = 1.0f, alphaMin = 0.2f; - dc.SetLineWidth(3); - - if (GetIEditor()->GetEditMode() == eEditModeMove && pGrid->IsEnabled()) - // Draw the translation grid. - { - Vec3 u = m_constructionPlaneAxisX; - Vec3 v = m_constructionPlaneAxisY; - float step = pGrid->scale * pGrid->size; - const int MIN_STEP_COUNT = 5; - const int MAX_STEP_COUNT = 300; - int nSteps = std::min(std::max(FloatToIntRet(size / step), MIN_STEP_COUNT), MAX_STEP_COUNT); - size = nSteps * step; - for (int i = -nSteps; i <= nSteps; ++i) - { - // Draw u lines. - float alphaCur = alphaMax - fabsf(float(i) / float(nSteps)) * (alphaMax - alphaMin); - dc.DrawLine(p + v * (step * i), p + u * size + v * (step * i), - ColorF(0, 0, 0, alphaCur), ColorF(0, 0, 0, alphaMin)); - dc.DrawLine(p + v * (step * i), p - u * size + v * (step * i), - ColorF(0, 0, 0, alphaCur), ColorF(0, 0, 0, alphaMin)); - // Draw v lines. - dc.DrawLine(p + u * (step * i), p + v * size + u * (step * i), - ColorF(0, 0, 0, alphaCur), ColorF(0, 0, 0, alphaMin)); - dc.DrawLine(p + u * (step * i), p - v * size + u * (step * i), - ColorF(0, 0, 0, alphaCur), ColorF(0, 0, 0, alphaMin)); - } - } - else if (GetIEditor()->GetEditMode() == eEditModeRotate && pGrid->IsAngleSnapEnabled()) - // Draw the rotation grid. - { - int nAxis(GetAxisConstrain()); - if (nAxis == AXIS_X || nAxis == AXIS_Y || nAxis == AXIS_Z) - { - RefCoordSys coordSys = GetIEditor()->GetReferenceCoordSys(); - Vec3 xAxis(1, 0, 0); - Vec3 yAxis(0, 1, 0); - Vec3 zAxis(0, 0, 1); - Vec3 rotAxis; - if (nAxis == AXIS_X) - { - rotAxis = m_constructionMatrix[coordSys].TransformVector(xAxis); - } - else if (nAxis == AXIS_Y) - { - rotAxis = m_constructionMatrix[coordSys].TransformVector(yAxis); - } - else if (nAxis == AXIS_Z) - { - rotAxis = m_constructionMatrix[coordSys].TransformVector(zAxis); - } - Vec3 anotherAxis = m_constructionPlane.n * size; - float step = pGrid->angleSnap; - int nSteps = FloatToIntRet(180.0f / step); - for (int i = 0; i < nSteps; ++i) - { - AngleAxis rot(i* step* gf_PI / 180.0, rotAxis); - Vec3 dir = rot * anotherAxis; - dc.DrawLine(p, p + dir, - ColorF(0, 0, 0, alphaMax), ColorF(0, 0, 0, alphaMin)); - dc.DrawLine(p, p - dir, - ColorF(0, 0, 0, alphaMax), ColorF(0, 0, 0, alphaMin)); - } - } - } dc.SetState(prevState); } diff --git a/Code/Sandbox/Editor/Resource.h b/Code/Sandbox/Editor/Resource.h index afcd0c7a6f..8c4b09ae67 100644 --- a/Code/Sandbox/Editor/Resource.h +++ b/Code/Sandbox/Editor/Resource.h @@ -123,7 +123,6 @@ #define ID_TOOL_SHELVE_LAST 33375 #define ID_EDIT_SELECTALL 33376 #define ID_EDIT_SELECTNONE 33377 -#define ID_OBJECTMODIFY_VERTEXSNAPPING 33384 #define ID_WIREFRAME 33410 #define ID_FILE_GENERATETERRAINTEXTURE 33445 #define ID_GENERATORS_LIGHTING 33446 @@ -142,18 +141,12 @@ #define ID_EDITMODE_ROTATE 33506 #define ID_EDITMODE_SCALE 33507 #define ID_EDITMODE_MOVE 33508 -#define ID_EDITMODE_SELECT 33509 -#define ID_EDITMODE_SELECTAREA 33510 #define ID_SELECTION_DELETE 33512 #define ID_EDIT_ESCAPE 33513 #define ID_OBJECTMODIFY_SETAREA 33514 #define ID_OBJECTMODIFY_SETHEIGHT 33515 #define ID_OBJECTMODIFY_FREEZE 33517 #define ID_OBJECTMODIFY_UNFREEZE 33518 -#define ID_SELECT_AXIS_XY 33520 -#define ID_SELECT_AXIS_X 33521 -#define ID_SELECT_AXIS_Y 33522 -#define ID_SELECT_AXIS_Z 33523 #define ID_UNDO 33524 #define ID_EDIT_CLONE 33525 #define ID_SELECTION_SAVE 33527 @@ -162,7 +155,6 @@ #define ID_EDIT_LEVELDATA 33542 #define ID_FILE_EDITEDITORINI 33543 #define ID_FILE_EDITLOGFILE 33544 -#define ID_SELECT_AXIS_TERRAIN 33545 #define ID_PREFERENCES 33546 #define ID_RELOAD_GEOMETRY 33549 #define ID_REDO 33550 @@ -214,7 +206,6 @@ #define ID_TV_NEXTKEY 33603 #define ID_PLAY_LOOP 33607 #define ID_TERRAIN 33611 -#define ID_OBJECTMODIFY_ALIGNTOGRID 33619 #define ID_PANEL_VEG_EXPORT 33672 #define ID_PANEL_VEG_IMPORT 33673 #define ID_PANEL_VEG_DISTRIBUTE 33674 @@ -227,7 +218,6 @@ #define ID_PANEL_VEG_ADDCATEGORY 33682 #define ID_PANEL_VEG_RENAMECATEGORY 33683 #define ID_PANEL_VEG_REMOVECATEGORY 33684 -#define ID_SELECT_AXIS_SNAPTOALL 33685 #define ID_TOOLS_PREFERENCES 33691 #define ID_EDIT_INVERTSELECTION 33692 #define ID_TOOLTERRAINMODIFY_SMOOTH 33695 @@ -275,13 +265,11 @@ #define ID_GAME_PC_ENABLEMEDIUMSPEC 33961 #define ID_GAME_PC_ENABLEHIGHSPEC 33962 #define ID_GAME_PC_ENABLEVERYHIGHSPEC 33963 -#define ID_MODIFY_ALIGNOBJTOSURF 33968 #define ID_PANEL_VEG_CREATE_SEL 33990 #define ID_TOOLS_UPDATEPROCEDURALVEGETATION 33999 #define ID_DISPLAY_GOTOPOSITION 34004 #define ID_PHYSICS_SIMULATEOBJECTS 34007 #define ID_TERRAIN_TEXTURE_EXPORT 34008 -#define ID_DISPLAY_SETVECTOR 34010 #define ID_TV_SEQUENCE_NEW 34049 #define ID_TV_MODE_DOPESHEET 34052 #define ID_VIEW_LAYOUTS 34053 @@ -405,7 +393,6 @@ #define ID_TOOLBAR_WIDGET_FIRST 50003 #define ID_TOOLBAR_WIDGET_UNDO 50003 #define ID_TOOLBAR_WIDGET_REDO 50004 -#define ID_TOOLBAR_WIDGET_REF_COORD 50006 #define ID_TOOLBAR_WIDGET_SNAP_ANGLE 50007 #define ID_TOOLBAR_WIDGET_SNAP_GRID 50008 #define ID_TOOLBAR_WIDGET_ENVIRONMENT_MODE 50011 diff --git a/Code/Sandbox/Editor/RotateTool.cpp b/Code/Sandbox/Editor/RotateTool.cpp deleted file mode 100644 index e9b12d01af..0000000000 --- a/Code/Sandbox/Editor/RotateTool.cpp +++ /dev/null @@ -1,1059 +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. -* -*/ -#include "EditorDefs.h" - -#include "RotateTool.h" - -// AzToolsFramework -#include - -// Editor -#include "Objects/SelectionGroup.h" -#include "NullEditTool.h" -#include "Viewport.h" -#include "Grid.h" -#include "ViewManager.h" -#include "Objects/BaseObject.h" - - -// This constant is used with GetScreenScaleFactor and was found experimentally. -static const float kViewDistanceScaleFactor = 0.06f; - -const GUID& CRotateTool::GetClassID() -{ - // {A50E5B95-05B9-41A3-8D8E-BDA3E930A396} - static const GUID guid = { - 0xA50E5B95, 0x05B9, 0x41A3, { 0x8D, 0x8E, 0xBD, 0xA3, 0xE9, 0x30, 0xA3, 0x96 } - }; - return guid; -} - -//! This method returns the human readable name of the class. -//! This method returns Category of this class, Category is specifying where this tool class fits best in create panel. -void CRotateTool::RegisterTool(CRegistrationContext& rc) -{ - rc.pClassFactory->RegisterClass(new CQtViewClass("EditTool.Rotate", "Select", ESYSTEM_CLASS_EDITTOOL)); -} - -CRotateTool::CRotateTool(CBaseObject* pObject, QWidget* parent /*= nullptr*/) - : CObjectMode(parent) - , m_initialViewAxisAngleRadians(0.f) - , m_angleToCursor(0.f) - , m_highlightAxis(AxisNone) - , m_draggingMouse(false) - , m_lastPosition(0, 0) - , m_rotationAngles(0, 0, 0) - , m_object(pObject) - , m_bTransformChanged(false) - , m_totalRotationAngle(0.f) - , m_basisAxisRadius(4.f) - , m_viewAxisRadius(5.f) - , m_arcRotationStepRadians(DEG2RAD(5.f)) -{ - m_axes[AxisX] = RotationDrawHelper::Axis(Col_Red, Col_Yellow); - m_axes[AxisY] = RotationDrawHelper::Axis(Col_Green, Col_Yellow); - m_axes[AxisZ] = RotationDrawHelper::Axis(Col_Blue, Col_Yellow); - m_axes[AxisView] = RotationDrawHelper::Axis(Col_White, Col_Yellow); - - if (m_object) - { - m_object->AddEventListener(this); - } - - GetIEditor()->GetObjectManager()->SetSelectCallback(this); -} - -bool CRotateTool::OnSelectObject(CBaseObject* object) -{ - m_object = object; - if (m_object) - { - m_object->AddEventListener(this); - } - return true; -} - -bool CRotateTool::CanSelectObject([[maybe_unused]] CBaseObject* object) -{ - return true; -} - -void CRotateTool::OnObjectEvent(CBaseObject* object, int event) -{ - if (event == CBaseObject::ON_DELETE || event == CBaseObject::ON_UNSELECT) - { - if (m_object && m_object == object) - { - m_object->RemoveEventListener(this); - m_object = nullptr; - } - } -} - -void CRotateTool::Display(DisplayContext& dc) -{ - if (!m_object) - { - return; - } - - const bool visible = - !m_object->IsHidden() - && !m_object->IsFrozen() - && m_object->IsSelected(); - - if (!visible) - { - GetIEditor()->SetEditTool(new NullEditTool()); - return; - } - - RotationDrawHelper::DisplayContextScope displayContextScope(dc); - m_hc.camera = dc.camera; - m_hc.view = dc.view; - m_hc.b2DViewport = static_cast(dc.view)->GetType() != ET_ViewportCamera; - dc.SetLineWidth(m_lineThickness); - - // Calculate the screen space position from which we cast a ray (center of viewport). - int viewportWidth = 0; - int viewportHeight = 0; - dc.view->GetDimensions(&viewportWidth, &viewportHeight); - m_hc.point2d = QPoint(viewportWidth / 2, viewportHeight / 2); - - // Calculate the ray from the camera position to the selection. - dc.view->ViewToWorldRay(m_hc.point2d, m_hc.raySrc, m_hc.rayDir); - - Matrix34 objectTransform = GetTransform(GetIEditor()->GetReferenceCoordSys(), dc.view); - - AffineParts ap; - ap.Decompose(objectTransform); - - Vec3 position = ap.pos; - CSelectionGroup* selection = GetIEditor()->GetSelection(); - if (selection->GetCount() > 1) - { - position = selection->GetCenter(); - } - - float screenScale = GetScreenScale(dc.view, dc.camera); - - // X axis arc - Vec3 cameraViewDir = (m_hc.raySrc - position).GetNormalized(); - float cameraAngle = atan2f(cameraViewDir.y, cameraViewDir.x); - m_axes[AxisX].Draw(dc, position, ap.rot.GetColumn0(), cameraAngle, m_arcRotationStepRadians, m_basisAxisRadius, m_highlightAxis == AxisX, m_object, screenScale); - - // Y axis arc - cameraAngle = atan2f(-cameraViewDir.z, cameraViewDir.x); - m_axes[AxisY].Draw(dc, position, ap.rot.GetColumn1(), cameraAngle, m_arcRotationStepRadians, m_basisAxisRadius, m_highlightAxis == AxisY, m_object, screenScale); - - // View direction axis - Vec3 cameraPos = dc.camera->GetPosition(); - - Vec3 axis = cameraPos - position; - axis.NormalizeSafe(); - - // Z axis arc - cameraAngle = atan2f(axis.y, axis.x); - m_axes[AxisZ].Draw(dc, position, objectTransform.GetColumn2().GetNormalized(), cameraAngle, m_arcRotationStepRadians, m_basisAxisRadius, m_highlightAxis == AxisZ, m_object, screenScale); - - // FIXME: currently, rotating multiple selections using the view axis may result in severe rotation artifacts, it's necessary to make sure - // the calculated rotation angle is smooth. - if (!m_hc.b2DViewport && selection->GetCount() == 1 || m_object->CheckFlags(OBJFLAG_IS_PARTICLE)) - { - // Draw view direction axis - dc.SetColor(m_highlightAxis == AxisView ? Col_Yellow : Col_White); - - cameraViewDir = m_hc.camera->GetViewdir().normalized(); - dc.DrawArc(position, m_viewAxisRadius * GetScreenScale(dc.view, dc.camera), 0, 360.f, RAD2DEG(m_arcRotationStepRadians), cameraViewDir); - } - - // Draw angle decorator - if (RotationControlConfiguration::Get().RotationControl_DrawDecorators) - { - DrawAngleDecorator(dc); - } - - // Display total rotation angle in degrees. - if (!m_hc.b2DViewport && fabs(m_totalRotationAngle) > FLT_EPSILON) - { - QString label; - label = QString::number(RAD2DEG(m_totalRotationAngle), 'f', 2); - - const float textScale = 1.5f; - const ColorF textBackground = ColorF(0.2f, 0.2f, 0.2f, 0.6f); - - if (m_object->CheckFlags(OBJFLAG_IS_PARTICLE)) - { - dc.DrawTextLabel(ap.pos, textScale, label.toUtf8().data()); - } - else - { - dc.DrawTextOn2DBox(ap.pos, label.toUtf8().data(), textScale, Col_White, textBackground); - } - } - - // Draw debug diagnostics - if (RotationControlConfiguration::Get().RotationControl_DebugHitTesting) - { - DrawHitTestGeometry(dc, m_hc); - } - - // Draw debug tracking of the view direction angle - if (RotationControlConfiguration::Get().RotationControl_AngleTracking) - { - DrawViewDirectionAngleTracking(dc, m_hc); - } -} - -void CRotateTool::DrawAngleDecorator(DisplayContext& dc) -{ - if (m_highlightAxis == AxisView) - { - //Vec3 cameraViewDir = dc.view->GetViewTM().GetColumn1().GetNormalized(); - Vec3 cameraViewDir = dc.camera->GetViewMatrix().GetColumn1().GetNormalized(); //Get the viewDir from the camera instead of from the view - // FIXME: The angle and sweep calculation here is incorrect. - float cameraAngle = atan2f(cameraViewDir.y, -cameraViewDir.x); - float angleDelta = (m_angleToCursor - g_PI2 * floor(m_initialViewAxisAngleRadians / g_PI2)) - (m_initialViewAxisAngleRadians - (cameraAngle - (g_PI / 2))); - - RotationDrawHelper::AngleDecorator::Draw(dc, m_object->GetWorldPos(), cameraViewDir, m_initialViewAxisAngleRadians, angleDelta, m_arcRotationStepRadians, m_viewAxisRadius, GetScreenScale(dc.view, dc.camera)); - } - else - { - if (fabs(m_totalRotationAngle) > FLT_EPSILON) - { - float screenScale = GetScreenScale(dc.view, dc.camera); - switch (m_highlightAxis) - { - case AxisX: - RotationDrawHelper::AngleDecorator::Draw(dc, m_object->GetWorldPos(), m_object->GetRotation().GetColumn0(), m_initialViewAxisAngleRadians, m_totalRotationAngle, m_arcRotationStepRadians, m_basisAxisRadius, screenScale); - break; - case AxisY: - RotationDrawHelper::AngleDecorator::Draw(dc, m_object->GetWorldPos(), m_object->GetRotation().GetColumn1(), m_initialViewAxisAngleRadians, m_totalRotationAngle, m_arcRotationStepRadians, m_basisAxisRadius, screenScale); - break; - case AxisZ: - RotationDrawHelper::AngleDecorator::Draw(dc, m_object->GetWorldPos(), m_object->GetRotation().GetColumn2(), m_initialViewAxisAngleRadians, m_totalRotationAngle, m_arcRotationStepRadians, m_basisAxisRadius, screenScale); - break; - default: - break; - } - } - } -} - -bool CRotateTool::HitTest(CBaseObject* object, HitContext& hc) -{ - if (!m_object) - { - return CObjectMode::HitTest(object, hc); - } - m_hc = hc; - m_highlightAxis = AxisNone; - - float screenScale = GetScreenScale(hc.view, hc.camera); - - // Determine intersection with the axis view direction. - CSelectionGroup* selection = GetIEditor()->GetSelection(); - if (!m_hc.b2DViewport && selection->GetCount() == 1 || m_object->CheckFlags(OBJFLAG_IS_PARTICLE)) - { - if (m_axes[AxisView].HitTest(object, hc, m_viewAxisRadius, m_arcRotationStepRadians, hc.camera ? hc.camera->GetViewMatrix().GetInverted().GetColumn1() : hc.view->GetViewTM().GetColumn1(), screenScale)) - { - m_highlightAxis = AxisView; - GetIEditor()->SetAxisConstraints(AXIS_XYZ); - return true; - } - } - - // Determine any intersection with a major axis. - AffineParts ap; - ap.Decompose(GetTransform(GetIEditor()->GetReferenceCoordSys(), hc.view)); - - if (m_axes[AxisX].HitTest(object, hc, m_basisAxisRadius, m_arcRotationStepRadians, ap.rot.GetColumn0(), screenScale)) - { - m_highlightAxis = AxisX; - GetIEditor()->SetAxisConstraints(AXIS_X); - return true; - } - - if (m_axes[AxisY].HitTest(object, hc, m_basisAxisRadius, m_arcRotationStepRadians, ap.rot.GetColumn1(), screenScale)) - { - m_highlightAxis = AxisY; - GetIEditor()->SetAxisConstraints(AXIS_Y); - return true; - } - - if (m_axes[AxisZ].HitTest(object, hc, m_basisAxisRadius, m_arcRotationStepRadians, ap.rot.GetColumn2(), screenScale)) - { - m_highlightAxis = AxisZ; - GetIEditor()->SetAxisConstraints(AXIS_Z); - return true; - } - - return false; -} - -void CRotateTool::DeleteThis() -{ - delete this; -} - -bool CRotateTool::OnKeyDown([[maybe_unused]] CViewport* view, uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) -{ - if (nChar == VK_ESCAPE) - { - GetIEditor()->GetObjectManager()->ClearSelection(); - return true; - } - return false; -} - -Matrix34 CRotateTool::GetTransform(RefCoordSys referenceCoordinateSystem, IDisplayViewport* view) -{ - Matrix34 objectTransform = Matrix34::CreateIdentity(); - if (m_object) - { - switch (referenceCoordinateSystem) - { - case COORDS_VIEW: - if (view) - { - objectTransform = view->GetViewTM(); - } - objectTransform.SetTranslation(m_object->GetWorldTM().GetTranslation()); - break; - case COORDS_LOCAL: - objectTransform = m_object->GetWorldTM(); - break; - case COORDS_PARENT: - if (m_object->GetParent()) - { - Matrix34 parentTM = m_object->GetParent()->GetWorldTM(); - parentTM.SetTranslation(m_object->GetWorldTM().GetTranslation()); - objectTransform = parentTM; - } - else - { - objectTransform.SetTranslation(m_object->GetWorldTM().GetTranslation()); - } - break; - case COORDS_WORLD: - objectTransform.SetTranslation(m_object->GetWorldTM().GetTranslation()); - break; - } - } - return objectTransform; -} - -float CRotateTool::CalculateOrientation(const QPoint& p1, const QPoint& p2, const QPoint& p3) -{ - // Source: https://www.geeksforgeeks.org/orientation-3-ordered-points/ - float c = (p2.y() - p1.y()) * (p3.x() - p2.x()) - (p3.y() - p2.y()) * (p2.x() - p1.x()); - return c > 0 ? 1.0f : -1.0f; -} - -CRotateTool::~CRotateTool() -{ - if (m_object) - { - m_object->RemoveEventListener(this); - } - GetIEditor()->GetObjectManager()->SetSelectCallback(nullptr); -} - -bool CRotateTool::OnLButtonDown(CViewport* view, int nFlags, const QPoint& p) -{ - QPoint point = p; - m_hc.view = view; - m_hc.b2DViewport = view->GetType() != ET_ViewportCamera; - m_hc.point2d = point; - if (nFlags == OBJFLAG_IS_PARTICLE) - { - view->setHitcontext(point, m_hc.raySrc, m_hc.rayDir); - } - else - { - view->ViewToWorldRay(point, m_hc.raySrc, m_hc.rayDir); - } - - if (m_hc.object && m_hc.object != m_object) - { - GetIEditor()->ClearSelection(); - return CObjectMode::OnLButtonDown(view, nFlags, point); - } - - if (m_highlightAxis != AxisNone) - { - view->BeginUndo(); - view->CaptureMouse(); - view->SetCurrentCursor(STD_CURSOR_ROTATE); - - m_draggingMouse = true; - - // Store the starting drag angle when we first click the mouse, we will need this to know - // how much of the rotation we need to apply. - if (m_highlightAxis == AxisView) - { - Vec3 cameraViewDir = m_hc.camera->GetViewdir().GetNormalized(); - float cameraAngle = atan2f(cameraViewDir.y, -cameraViewDir.x); - m_initialViewAxisAngleRadians = m_angleToCursor - cameraAngle - (g_PI / 2); - m_initialViewAxisAngleRadians -= static_cast(g_PI); - } - - m_lastPosition = point; - m_rotationAngles = Ang3(0, 0, 0); - - AzToolsFramework::EntityIdList selectedEntities; - AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult( - selectedEntities, - &AzToolsFramework::ToolsApplicationRequests::Bus::Events::GetSelectedEntities); - - AzToolsFramework::EditorTransformChangeNotificationBus::Broadcast( - &AzToolsFramework::EditorTransformChangeNotificationBus::Events::OnEntityTransformChanging, - selectedEntities); - - return true; - } - - return CObjectMode::OnLButtonDown(view, nFlags, point); -} - -bool CRotateTool::OnLButtonUp(CViewport* view, int nFlags, const QPoint& p) -{ - QPoint point = p; - if (nFlags == OBJFLAG_IS_PARTICLE) - { - view->setHitcontext(point, m_hc.raySrc, m_hc.rayDir); - } - else - { - view->ViewToWorldRay(point, m_hc.raySrc, m_hc.rayDir); - } - - if (m_draggingMouse) - { - // We are no longer dragging the mouse, so we will release it and reset any state variables. - { - AzToolsFramework::ScopedUndoBatch undo("Rotate"); - } - view->AcceptUndo("Rotate Selection"); - view->ReleaseMouse(); - view->SetCurrentCursor(STD_CURSOR_DEFAULT); - - m_draggingMouse = false; - m_totalRotationAngle = 0.f; - m_initialViewAxisAngleRadians = 0.f; - m_angleToCursor = 0.f; - - // Apply the transform changes to the selection. - if (m_bTransformChanged) - { - CSelectionGroup* pSelection = GetIEditor()->GetSelection(); - if (pSelection) - { - pSelection->FinishChanges(); - } - - m_bTransformChanged = false; - - view->ResetSelectionRegion(); - // Reset selected rectangle. - view->SetSelectionRectangle(QRect()); - view->SetAxisConstrain(GetIEditor()->GetAxisConstrains()); - - AzToolsFramework::EntityIdList selectedEntities; - AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult( - selectedEntities, - &AzToolsFramework::ToolsApplicationRequests::Bus::Events::GetSelectedEntities); - - AzToolsFramework::EditorTransformChangeNotificationBus::Broadcast( - &AzToolsFramework::EditorTransformChangeNotificationBus::Events::OnEntityTransformChanged, - selectedEntities); - } - } - - return CObjectMode::OnLButtonUp(view, nFlags, point); -} - -bool CRotateTool::OnMouseMove(CViewport* view, int nFlags, const QPoint& p) -{ - QPoint point = p; - if (!m_object) - { - return CObjectMode::OnMouseMove(view, nFlags, point); - } - - // Prevent the opening of the context menu during a mouse move. - m_openContext = false; - - // We calculate the mouse drag direction vector's angle from the object to the mouse position. - QPoint objectCenter; - if (nFlags != OBJFLAG_IS_PARTICLE) - { - objectCenter = view->WorldToView(GetIEditor()->GetSelection()->GetCenter()); - } - else - if (parent() && parent()->isWidgetType()) - { - QWidget *wParent = static_cast(parent()); - - // HACK: This is only valid for the particle editor and needs refactored. - const QRect rect = wParent->contentsRect(); - objectCenter = view->WorldToViewParticleEditor(m_object->GetWorldPos(), rect.width(), rect.height()); - } - - Vec2 dragDirection = Vec2(point.x() - objectCenter.x(), point.y() - objectCenter.y()); - dragDirection.Normalize(); - - float angleToCursor = (atan2f(dragDirection.y, dragDirection.x)); - m_angleToCursor = angleToCursor - g_PI2 * floor(angleToCursor / g_PI2); - - if (m_draggingMouse) - { - GetIEditor()->RestoreUndo(); - - view->SetCurrentCursor(STD_CURSOR_ROTATE); - - RefCoordSys referenceCoordSys = GetIEditor()->GetReferenceCoordSys(); - - if (m_highlightAxis == AxisView) - { - // Calculate the angular difference between the starting rotation angle, taking into account the camera's angle to ensure a smooth rotation. - Vec3 cameraViewDir = m_hc.camera->GetViewdir(); - float cameraAngle = atan2f(cameraViewDir.y, cameraViewDir.x); - float angleDelta = (m_angleToCursor - g_PI2 * floor(m_initialViewAxisAngleRadians / g_PI2)) - (m_initialViewAxisAngleRadians - (cameraAngle - (g_PI / 2))); - - // Snap the angle is necessary - angleDelta = view->GetViewManager()->GetGrid()->SnapAngle(RAD2DEG(angleDelta)); - - if (nFlags != OBJFLAG_IS_PARTICLE) - { - Matrix34 viewRotation = Matrix34::CreateRotationAA(DEG2RAD(angleDelta), cameraViewDir); - GetIEditor()->GetSelection()->Rotate(viewRotation, COORDS_WORLD); - } - else - { - Quat quatRotation = Quat::CreateRotationAA(DEG2RAD(angleDelta), cameraViewDir); - m_object->SetRotation(quatRotation); - } - - m_bTransformChanged = true; - } - else - if (m_highlightAxis != AxisNone) - { - float distanceMoved = (point - m_lastPosition).manhattanLength(); // screen-space distance dragged - float distanceToCenter = (m_lastPosition - objectCenter).manhattanLength(); // screen-space distance to object center - float roationDelta = RAD2DEG(atan2f(distanceMoved, distanceToCenter)); // unsigned rotation angle - float orientation = CalculateOrientation(objectCenter, m_lastPosition, point); // Calculate if rotation dragging gizmo clockwise or counter-clockwise - - m_lastPosition = point; - - // Calculate orientation of the object's axis towards camera - Vec3 directionToObject = (GetIEditor()->GetSelection()->GetCenter() - m_hc.camera->GetMatrix().GetTranslation()).normalize(); - - float directionX = 1.0f; - float directionY = 1.0f; - float directionZ = 1.0f; - - switch (referenceCoordSys) - { - case COORDS_LOCAL: - directionX = directionToObject.Dot(m_object->GetWorldTM().GetColumn0()) > 0 ? -1.0f : 1.0f; - directionY = directionToObject.Dot(m_object->GetWorldTM().GetColumn1()) > 0 ? -1.0f : 1.0f; - directionZ = directionToObject.Dot(m_object->GetWorldTM().GetColumn2()) > 0 ? -1.0f : 1.0f; - break; - case COORDS_PARENT: - if (m_object->GetParent()) - { - directionX = directionToObject.Dot(m_object->GetParent()->GetWorldTM().GetColumn0()) > 0 ? -1.0f : 1.0f; - directionY = directionToObject.Dot(m_object->GetParent()->GetWorldTM().GetColumn1()) > 0 ? -1.0f : 1.0f; - directionZ = directionToObject.Dot(m_object->GetParent()->GetWorldTM().GetColumn2()) > 0 ? -1.0f : 1.0f; - } - else - { - directionX = directionToObject.Dot(m_object->GetWorldTM().GetColumn0()) > 0 ? -1.0f : 1.0f; - directionY = directionToObject.Dot(m_object->GetWorldTM().GetColumn1()) > 0 ? -1.0f : 1.0f; - directionZ = directionToObject.Dot(m_object->GetWorldTM().GetColumn2()) > 0 ? -1.0f : 1.0f; - } - break; - case COORDS_VIEW: - case COORDS_WORLD: - directionX = directionToObject.Dot(Vec3(1, 0, 0)) > 0 ? -1.0f : 1.0f; - directionY = directionToObject.Dot(Vec3(0, 1, 0)) > 0 ? -1.0f : 1.0f; - directionZ = directionToObject.Dot(Vec3(0, 0, 1)) > 0 ? -1.0f : 1.0f; - break; - } - - switch (m_highlightAxis) - { - case AxisX: - m_rotationAngles.x += roationDelta * directionX * orientation; - break; - case AxisY: - m_rotationAngles.y += roationDelta * directionY * orientation; - break; - case AxisZ: - m_rotationAngles.z += roationDelta * directionZ * orientation; - break; - default: - break; - } - - // Snap the angle if necessary - m_rotationAngles = view->GetViewManager()->GetGrid()->SnapAngle(m_rotationAngles); - - // Compute the total amount rotated - Vec3 vDragValue = Vec3(m_rotationAngles); - m_totalRotationAngle = DEG2RAD(vDragValue.len()); - - // Apply the rotation - if (nFlags != OBJFLAG_IS_PARTICLE) - { - GetIEditor()->GetSelection()->Rotate(m_rotationAngles, referenceCoordSys); - } - else - { - Quat currentRotation = (m_object->GetRotation()); - Quat rotateTM = currentRotation * Quat::CreateRotationXYZ(DEG2RAD(-m_rotationAngles / 50.0f)); - m_object->SetRotation(rotateTM); - } - - m_bTransformChanged = fabs(m_totalRotationAngle) > FLT_EPSILON; - } - } - else - { - // If we are not yet dragging the mouse, do the hit testing to highlight the axis the mouse is over. - m_hc.view = view; - m_hc.b2DViewport = view->GetType() != ET_ViewportCamera; - m_hc.point2d = point; - - if (nFlags != OBJFLAG_IS_PARTICLE) - { - view->ViewToWorldRay(point, m_hc.raySrc, m_hc.rayDir); - } - else - { - view->setHitcontext(point, m_hc.raySrc, m_hc.rayDir); - } - - if (HitTest(m_object, m_hc)) - { - // Display a cursor that makes it clear to the user that he is over an axis that can be rotated. - view->SetCurrentCursor(STD_CURSOR_ROTATE); - } - else - { - // Nothing has been hit, reset the cursor back to default in case it was changed previously. - view->SetCurrentCursor(STD_CURSOR_DEFAULT); - } - } - - // We always consider the rotation tool's OnMove event handled - return true; -} - -float CRotateTool::GetScreenScale(IDisplayViewport* view, CCamera* camera /*=nullptr*/) -{ - Matrix34 objectTransform = GetTransform(GetIEditor()->GetReferenceCoordSys(), view); - - AffineParts ap; - ap.Decompose(objectTransform); - - if (m_object && m_object->CheckFlags(OBJFLAG_IS_PARTICLE)) - { - return view->GetScreenScaleFactor(*camera, ap.pos) * kViewDistanceScaleFactor; - } - - return static_cast(view)->GetScreenScaleFactor(ap.pos) * kViewDistanceScaleFactor; -} - -void CRotateTool::DrawHitTestGeometry(DisplayContext& dc, HitContext& hc) -{ - AffineParts ap; - ap.Decompose(GetTransform(GetIEditor()->GetReferenceCoordSys(), dc.view)); - - Vec3 position = ap.pos; - CSelectionGroup* selection = GetIEditor()->GetSelection(); - if (selection->GetCount() > 1 && !m_object->CheckFlags(OBJFLAG_IS_PARTICLE)) - { - position = selection->GetCenter(); - } - - float screenScale = GetScreenScale(dc.view, dc.camera); - - // Draw debug test surface for each axis. - m_axes[AxisX].DebugDrawHitTestSurface(dc, hc, position, m_basisAxisRadius, m_arcRotationStepRadians, ap.rot.GetColumn0(), screenScale); - m_axes[AxisY].DebugDrawHitTestSurface(dc, hc, position, m_basisAxisRadius, m_arcRotationStepRadians, ap.rot.GetColumn1(), screenScale); - m_axes[AxisZ].DebugDrawHitTestSurface(dc, hc, position, m_basisAxisRadius, m_arcRotationStepRadians, ap.rot.GetColumn2(), screenScale); - - // We don't render the view axis rotation for multiple selection. - if (!hc.b2DViewport && selection->GetCount() == 1) - { - Vec3 cameraViewDir = hc.view->GetViewTM().GetColumn1().GetNormalized(); - m_axes[AxisView].DebugDrawHitTestSurface(dc, hc, position, m_viewAxisRadius, m_arcRotationStepRadians, cameraViewDir, screenScale); - } -} - -void CRotateTool::DrawViewDirectionAngleTracking(DisplayContext& dc, HitContext& hc) -{ - Vec3 a; - Vec3 b; - - // Calculate a basis for the camera view direction. - Vec3 cameraViewDir = hc.view->GetViewTM().GetColumn1().GetNormalized(); - GetBasisVectors(cameraViewDir, a, b); - - // Calculates the camera view direction angle. - float angle = m_angleToCursor; - float cameraAngle = atan2f(cameraViewDir.y, -cameraViewDir.x); - - // Ensures the angle remains camera aligned. - angle -= cameraAngle - (g_PI / 2); - - // The position will be either the object's center or the selection's center. - Vec3 position = GetTransform(GetIEditor()->GetReferenceCoordSys(), dc.view).GetTranslation(); - CSelectionGroup* selection = GetIEditor()->GetSelection(); - if (selection->GetCount() > 1 && !m_object->CheckFlags(OBJFLAG_IS_PARTICLE)) - { - position = selection->GetCenter(); - } - - float screenScale = GetScreenScale(dc.view, dc.camera); - - const float cosAngle = cos(angle); - const float sinAngle = sin(angle); - - // The resulting position will be in a circular orientation based on the resulting angle. - Vec3 p0; - p0.x = position.x + (cosAngle * a.x + sinAngle * b.x) * m_viewAxisRadius * screenScale; - p0.y = position.y + (cosAngle * a.y + sinAngle * b.y) * m_viewAxisRadius * screenScale; - p0.z = position.z + (cosAngle * a.z + sinAngle * b.z) * m_viewAxisRadius * screenScale; - - const float ballRadius = 0.1f * screenScale; - dc.SetColor(Col_Magenta); - dc.DrawBall(p0, ballRadius); -} - -namespace RotationDrawHelper -{ - Axis::Axis(const ColorF& defaultColor, const ColorF& highlightColor) - { - m_colors[StateDefault] = defaultColor; - m_colors[StateHighlight] = highlightColor; - } - - void Axis::Draw(DisplayContext& dc, const Vec3& position, const Vec3& axis, float angleRadians, float angleStepRadians, float radius, bool highlighted, CBaseObject* object, float screenScale) - { - if (static_cast(dc.view)->GetType() != ET_ViewportCamera || object->CheckFlags(OBJFLAG_IS_PARTICLE)) - { - bool set = dc.SetDrawInFrontMode(true); - - // Draw the front facing arc - dc.SetColor(!highlighted ? m_colors[StateDefault] : m_colors[StateHighlight]); - dc.DrawArc(position, radius * screenScale, 0.f, 360.f, RAD2DEG(angleStepRadians), axis); - - dc.SetDrawInFrontMode(set); - } - else - { - // Draw the front facing arc - dc.SetColor(!highlighted ? m_colors[StateDefault] : m_colors[StateHighlight]); - dc.DrawArc(position, radius * screenScale, RAD2DEG(angleRadians) - 90.f, 180.f, RAD2DEG(angleStepRadians), axis); - - // Draw the back side - dc.SetColor(!highlighted ? Col_Gray : m_colors[StateHighlight]); - dc.DrawArc(position, radius * screenScale, RAD2DEG(angleRadians) + 90.f, 180.f, RAD2DEG(angleStepRadians), axis); - } - - static bool drawAxisMidPoint = false; - if (drawAxisMidPoint) - { - const float kBallRadius = 0.085f; - Vec3 a; - Vec3 b; - GetBasisVectors(axis, a, b); - - float cosAngle = cos(angleRadians); - float sinAngle = sin(angleRadians); - - Vec3 offset; - offset.x = position.x + (cosAngle * a.x + sinAngle * b.x) * screenScale * radius; - offset.y = position.y + (cosAngle * a.y + sinAngle * b.y) * screenScale * radius; - offset.z = position.z + (cosAngle * a.z + sinAngle * b.z) * screenScale * radius; - - dc.SetColor(!highlighted ? m_colors[StateDefault] : m_colors[StateHighlight]); - dc.DrawBall(offset, kBallRadius * screenScale); - } - } - - void Axis::GenerateHitTestGeometry([[maybe_unused]] HitContext& hc, const Vec3& position, float radius, float angleStepRadians, const Vec3& axis, float screenScale) - { - m_vertices.clear(); - - // The number of vertices relies on the angleStepRadians, the smaller the angle, the higher the vertex count. - int numVertices = static_cast(std::ceil(g_PI2 / angleStepRadians)); - - Vec3 a; - Vec3 b; - GetBasisVectors(axis, a, b); - - // The geometry is calculated by computing a circle aligned to the specified axis. - float angle = 0.f; - for (int i = 0; i < numVertices; ++i) - { - float cosAngle = cos(angle); - float sinAngle = sin(angle); - - Vec3 p; - p.x = position.x + (cosAngle * a.x + sinAngle * b.x) * radius * screenScale; - p.y = position.y + (cosAngle * a.y + sinAngle * b.y) * radius * screenScale; - p.z = position.z + (cosAngle * a.z + sinAngle * b.z) * radius * screenScale; - m_vertices.push_back(p); - - angle += angleStepRadians; - } - } - - bool Axis::IntersectRayWithQuad(const Ray& ray, Vec3 quad[4], Vec3& contact) - { - contact = Vec3(); - - // Tests ray vs. two quads, the front facing quad and a back facing quad. - // will return true if an intersection occurs and the world space position of the contact. - return (Intersect::Ray_Triangle(ray, quad[0], quad[1], quad[2], contact) || Intersect::Ray_Triangle(ray, quad[0], quad[2], quad[3], contact) || - Intersect::Ray_Triangle(ray, quad[0], quad[2], quad[1], contact) || Intersect::Ray_Triangle(ray, quad[0], quad[3], quad[2], contact)); - } - - bool Axis::HitTest(CBaseObject* object, HitContext& hc, float radius, float angleStepRadians, const Vec3& axis, float screenScale) - { - AffineParts ap; - ap.Decompose(object->GetWorldTM()); - - Vec3 position = ap.pos; - - CSelectionGroup* selection = GetIEditor()->GetSelection(); - if (selection->GetCount() > 1 && !object->CheckFlags(OBJFLAG_IS_PARTICLE)) - { - position = selection->GetCenter(); - } - - // Generate intersection testing geometry - GenerateHitTestGeometry(hc, position, radius, angleStepRadians, axis, screenScale); - - Ray ray; - ray.origin = hc.raySrc; - ray.direction = hc.rayDir; - - // Calculate the face normal with the first two vertices in the intersection geometry. - Vec3 vdir0 = (m_vertices[0] - m_vertices[1]).GetNormalized(); - Vec3 vdir1 = (m_vertices[2] - m_vertices[1]).GetNormalized(); - - Vec3 normal; - if (!hc.b2DViewport) - { - normal = hc.view->GetViewTM().GetColumn1(); - } - else - { - normal = hc.view->GetConstructionPlane()->n; - } - - float shortestDistance = std::numeric_limits::max(); - size_t numVertices = m_vertices.size(); - for (size_t i = 0; i < numVertices; ++i) - { - const Vec3& v0 = m_vertices[i]; - const Vec3& v1 = m_vertices[(i + 1) % numVertices]; - Vec3 right = (v0 - v1).Cross(normal).GetNormalized() * screenScale * m_hitTestWidth; - - // Calculates the quad vertices aligned to the face normal. - Vec3 quad[4]; - quad[0] = v0 + right; - quad[1] = v1 + right; - quad[2] = v1 - right; - quad[3] = v0 - right; - - Vec3 contact; - if (IntersectRayWithQuad(ray, quad, contact)) - { - Vec3 intersectionPoint; - if (PointToLineDistance(v0, v1, contact, intersectionPoint)) - { - // Ensure the intersection is within the quad's extents - float distanceToIntersection = intersectionPoint.GetDistance(contact); - if (distanceToIntersection < shortestDistance) - { - shortestDistance = distanceToIntersection; - } - } - } - } - - // if shortestDistance is less than the maximum possible distance, we have an intersection. - if (shortestDistance < std::numeric_limits::max() - FLT_EPSILON) - { - hc.object = object; - hc.dist = shortestDistance; - return true; - } - - return false; - } - - void Axis::DebugDrawHitTestSurface(DisplayContext& dc, HitContext& hc, const Vec3& position, float radius, float angleStepRadians, const Vec3& axis, float screenScale) - { - // Generate the geometry for rendering. - GenerateHitTestGeometry(hc, position, radius, angleStepRadians, axis, screenScale); - - // Calculate the face normal with the first two vertices in the intersection geometry. - Vec3 vdir0 = (m_vertices[0] - m_vertices[1]).GetNormalized(); - Vec3 vdir1 = (m_vertices[2] - m_vertices[1]).GetNormalized(); - - Vec3 normal; - if (!hc.b2DViewport) - { - normal = hc.view->GetViewTM().GetColumn1(); - } - else - { - normal = hc.view->GetConstructionPlane()->n; - } - - float shortestDistance = std::numeric_limits::max(); - - Ray ray; - ray.origin = hc.raySrc; - ray.direction = hc.rayDir; - - size_t numVertices = m_vertices.size(); - for (size_t i = 0; i < numVertices; ++i) - { - const Vec3& v0 = m_vertices[i]; - const Vec3& v1 = m_vertices[(i + 1) % numVertices]; - Vec3 right = (v0 - v1).Cross(normal).GetNormalized() * screenScale * m_hitTestWidth; - - // Calculates the quad vertices aligned to the face normal. - Vec3 quad[4]; - quad[0] = v0 + right; - quad[1] = v1 + right; - quad[2] = v1 - right; - quad[3] = v0 - right; - - // Draw double sided quad to ensure it is always visible regardless of camera orientation. - dc.DrawQuad(quad[0], quad[1], quad[2], quad[3]); - dc.DrawQuad(quad[3], quad[2], quad[1], quad[0]); - - Vec3 contact; - if (IntersectRayWithQuad(ray, quad, contact)) - { - Vec3 intersectionPoint; - if (PointToLineDistance(v0, v1, contact, intersectionPoint)) - { - // Ensure the intersection is within the quad's extents - float distanceToIntersection = intersectionPoint.GetDistance(contact); - if (distanceToIntersection < shortestDistance) - { - shortestDistance = distanceToIntersection; - - // Highlight the quad at which an intersection occurred. - auto c = dc.GetColor(); - dc.SetColor(Col_Red); - dc.DrawQuad(quad[0], quad[1], quad[2], quad[3]); - dc.DrawQuad(quad[3], quad[2], quad[1], quad[0]); - dc.SetColor(c); - } - } - } - } - } - - - namespace AngleDecorator - { - void Draw(DisplayContext& dc, const Vec3& position, const Vec3& axisToAlign, float startAngleRadians, float sweepAngleRadians, float stepAngleRadians, float radius, float screenScale) - { - float angle = startAngleRadians; - - if (fabs(sweepAngleRadians) < FLT_EPSILON || sweepAngleRadians < stepAngleRadians) - { - return; - } - - if (sweepAngleRadians > g_PI) - { - sweepAngleRadians = g_PI - (fabs(sweepAngleRadians - g_PI)); - stepAngleRadians = -stepAngleRadians; - } - - Vec3 a; - Vec3 b; - GetBasisVectors(axisToAlign, a, b); - - float cosAngle = cos(angle); - float sinAngle = sin(angle); - - // Pre-calculate the first vertex, this is useful for rendering the first handle ball. - Vec3 p0; - p0.x = position.x + (cosAngle * a.x + sinAngle * b.x) * radius * screenScale; - p0.y = position.y + (cosAngle * a.y + sinAngle * b.y) * radius * screenScale; - p0.z = position.z + (cosAngle * a.z + sinAngle * b.z) * radius * screenScale; - - const float ballRadius = 0.1f * screenScale; - - // TODO: colors should be configurable properties - dc.SetColor(0.f, 1.f, 0.f, 1.f); - dc.DrawBall(p0, ballRadius); - - float alpha = 0.5f; - dc.SetColor(0.8f, 0.8f, 0.8f, 0.5f); - - // Number of vertices is defined by stepAngleRadians, the smaller the step the higher vertex count. - int numVertices = static_cast(fabs(sweepAngleRadians / stepAngleRadians)); - if (numVertices >= 2) - { - Vec3 p1; - for (int i = 0; i < numVertices; ++i) - { - // We pre-calculated the first vertex, so we can advance the angle - angle += stepAngleRadians; - - const float cosAngle2 = cos(angle); - const float sinAngle2 = sin(angle); - - p1.x = position.x + (cosAngle2 * a.x + sinAngle2 * b.x) * radius * screenScale; - p1.y = position.y + (cosAngle2 * a.y + sinAngle2 * b.y) * radius * screenScale; - p1.z = position.z + (cosAngle2 * a.z + sinAngle2 * b.z) * radius * screenScale; - - // Draws a triangle from the object's position to p0 and p1. - dc.SetColor(0.8f, 0.8f, 0.8f, alpha); - dc.DrawTri(position, p0, p1); - - alpha += 0.5f * (i / numVertices); - p0 = p1; - } - - // Draw the end handle ball. - dc.SetColor(1.f, 0.f, 0.f, 1.f); - dc.DrawBall(p1, ballRadius); - } - } - } -} - -RotationControlConfiguration::RotationControlConfiguration() -{ - DefineConstIntCVar(RotationControl_DrawDecorators, 0, VF_NULL, "Toggles the display of the angular decorator."); - DefineConstIntCVar(RotationControl_DebugHitTesting, 0, VF_NULL, "Renders the hit testing geometry used for mouse input control."); - DefineConstIntCVar(RotationControl_AngleTracking, 0, VF_NULL, "Displays a sphere aligned to the mouse cursor direction for debugging."); -} - -#include diff --git a/Code/Sandbox/Editor/RotateTool.h b/Code/Sandbox/Editor/RotateTool.h deleted file mode 100644 index d24ff5ff39..0000000000 --- a/Code/Sandbox/Editor/RotateTool.h +++ /dev/null @@ -1,283 +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. -* -*/ -#ifndef CRYINCLUDE_EDITOR_ROTATETOOL_H -#define CRYINCLUDE_EDITOR_ROTATETOOL_H -#pragma once - -#if !defined(Q_MOC_RUN) -#include "EditTool.h" -#include "IObjectManager.h" -#include "EditMode/ObjectMode.h" -#include "Objects/BaseObject.h" // for CBaseObject::EventListener -#include "Objects/DisplayContext.h" -#include "Include/HitContext.h" -#endif - -//! Provides rendering utilities to support CRotateTool -namespace RotationDrawHelper -{ - //! Circle drawing and hit testing functionality over arbitrary axes - class Axis - { - public: - - //! \param defaultColor Color used to draw the camera aligned portion of the axis. - //! \param highlightColor Color used to draw the circle when it is in focus. - Axis(const ColorF& defaultColor = Col_White, const ColorF& highlightColor = Col_Yellow); - - //! Draws an axis aligned circle. - //! \param dc DisplayContext to use for rendering. - //! \param position World space position used as the center of the circle. - //! \param axis The axis by which to align the circle. - //! \param angleRadians The angle towards which the circle will be highlighted. - //! \param radius The radius of the circle. - //! \param highlighted If true it will draw the circle in the specified highlightColor. - void Draw(DisplayContext& dc, const Vec3& position, const Vec3& axis, float angleRadians, float angleStepRadians, float radius, bool highlighted, CBaseObject* object, float screenScale); - - //! Calculates a hit testing mesh (invisible) used for intersection testing. - //! \param object The object selected if hit testing return true. - //! \param hc The HitContext in which the hit object is set if an intersection is true. - //! \param radius The radius for the axis' circle. - //! \param angleStepRadians The angle for the step used to calculate the circle, a smaller angle results in a higher quality circle. - //! \param axis The axis by which to align the intersection geometry. - //! \param screenScale This is an internal parameter used to deduce the view distance ratio in order to scale the tool. - bool HitTest(CBaseObject* object, HitContext& hc, float radius, float angleStepRadians, const Vec3& axis, float screenScale); - - //! Draws the generated hit testing geometry, good for diagnostics and debugging. - //! \param dc DisplayContext to use for rendering. - //! \param hc The HitContext that contains the view direction raycast. - //! \param position World space position used as the center of the circle. - //! \param radius The radius for the axis' circle. - //! \param angleStepRadians The angle for the step used to calculate the circle, a smaller angle results in a higher quality circle. - //! \param axis The axis by which to align the intersection geometry. - //! \param screenScale This is an internal parameter used to deduce the view distance ratio in order to scale the tool. - void DebugDrawHitTestSurface(DisplayContext& dc, HitContext& hc, const Vec3& position, float radius, float angleStepRadians, const Vec3& axis, float screenScale); - - protected: - - enum States - { - StateDefault, - StateHighlight, - StateCount - }; - - ColorF m_colors[StateCount]; - - //! Defines the width of the generated hit testing geometry. - float m_hitTestWidth = 0.4f; - - //! Contains the vertices that make up the ring for the intersection testing geometry. - //! \remark Only contains the center positions, quads are generated by calculating the four vertices offset by m_hitTestWidth. - std::vector m_vertices; - - //! Generates the world space geometry necessary to perform hit testing. - //! \param hc The HitContext data. - //! \param position The world space position around which the geometry will be centered. - //! \param radius The radius of the ring. - //! \param angleStepRadians The angle for the step used to calculate the circle, a smaller angle results in a higher quality circle. - //! \param axis The axis to which the geometry will be aligned to. - //! \param screenScale This is an internal parameter used to deduce the view distance ratio in order to scale the tool. - void GenerateHitTestGeometry(HitContext& hc, const Vec3& position, float radius, float angleStepRadians, const Vec3& axis, float screenScale); - - //! Performs intersection testing between a ray and both sides of a quad - //! \param ray The ray to test (in world space) - //! \param quad An array of four Vec3 points in world space. - //! \param[out] contact The intersection position in world space at which the intersection occurred. - bool IntersectRayWithQuad(const Ray&ray, Vec3 quad[4], Vec3 & contact); - }; - - //! Provides the means to set and restore DisplayContext settings within a given scope. - class DisplayContextScope - { - public: - DisplayContextScope(DisplayContext& dc) - : m_dc(dc) - { - m_dc.DepthTestOff(); - m_dc.CullOff(); - } - - ~DisplayContextScope() - { - m_dc.DepthTestOn(); - m_dc.CullOn(); - } - - DisplayContext& m_dc; - }; - - //! Helper function that draws the representation of the inner angle of a rotation. - namespace AngleDecorator - { - //! \param dc - //! \param position World space position of the center of the decorator. - //! \param axisToAlign Axis to which the decorator will be aligned to. - //! \param startAngleRadians The starting angle from which the rotation will be performed. - //! \param sweepAngleRadians An angle that represents the sweep of the rotation arc. - //! \param angleStepRadians The angle for the step used to calculate the circle, a smaller angle results in a higher quality circle. - //! \param radius The radius of the decorator. - //! \param screenScale This is an internal parameter used to deduce the view distance ratio in order to scale the tool. - void Draw(DisplayContext& dc, const Vec3& position, const Vec3& axisToAlign, float startAngleRadians, float sweepAngleRadians, float stepAngleRadians, float radius, float screenScale); - } -} - -//! Provides rotation manipulation controls. -class SANDBOX_API CRotateTool - : public CObjectMode - , public IObjectSelectCallback - , public CBaseObject::EventListener -{ - Q_OBJECT -public: - Q_INVOKABLE CRotateTool(CBaseObject* pObject = nullptr, QWidget* parent = nullptr); - virtual ~CRotateTool(); - - static const GUID& GetClassID(); - - // Registration function. - static void RegisterTool(CRegistrationContext& rc); - - void Display(DisplayContext& dc) override; - void DrawObjectHelpers([[maybe_unused]] CBaseObject* pObject, [[maybe_unused]] DisplayContext& dc) override {} - bool HitTest(CBaseObject* pObject, HitContext& hc) override; - void DeleteThis() override; - bool OnLButtonDown(CViewport* view, int nFlags, const QPoint& point) override; - bool OnLButtonUp(CViewport* view, int nFlags, const QPoint& point) override; - bool OnMouseMove(CViewport* view, int nFlags, const QPoint& point) override; - -protected: - - //! Utility to calculate the view distance ratio used to scale the tool. - float GetScreenScale(IDisplayViewport* view, CCamera* camera = nullptr); - - enum Axis - { - AxisNone, - AxisX, //! X axis visualization and hit testing - AxisY, //! Y axis visualization and hit testing - AxisZ, //! Z axis visualization and hit testing - AxisView, //! View direction axis, used to rotate along the vector from the camera to the object. - AxisCount - }; - - AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING - //! Axis visualization and hit testing - RotationDrawHelper::Axis m_axes[Axis::AxisCount]; - - //! We record the starting angle when we begin to drag an object - float m_initialViewAxisAngleRadians; - - //! The angle from the object's (or selection's) center to the mouse cursor. - float m_angleToCursor; - - //! Specified which axis is currently selected. - Axis m_highlightAxis; - - //! True when we are using the view direction rotation axis. - bool m_viewAxisRotation; - - //! True when the mouse has been pressed, becomes false on release. - bool m_draggingMouse; - - //! The last mouse position on screen when rotating. - QPoint m_lastPosition; - - //! Cumulative rotation angle in degrees. - Ang3 m_rotationAngles; - - //! The selected object. - CBaseObject* m_object; - - //! True if there has been a change in rotation that affects the object. - bool m_bTransformChanged; - - //! Sum of the total rotation angles. - float m_totalRotationAngle; - - //! Radius used to draw the XYZ axes - float m_basisAxisRadius; - - //! Radius used to draw the view direction axis - float m_viewAxisRadius; - - //! Rotation step controls the quality of the axes, a smaller angle represents a higher number of vertices. - float m_arcRotationStepRadians; - - //! Thickness of for the axis line rendering. - float m_lineThickness = 4.f; - - //! Draws angle decorator for the current rotation axis. - void DrawAngleDecorator(DisplayContext& dc); - - //! Useful for debugging and visualizing hit testing - void DrawHitTestGeometry(DisplayContext& dc, HitContext& hc); - - //! Diagnostic tool to examine view direction angle (follows mouse cursor) - void DrawViewDirectionAngleTracking(DisplayContext& dc, HitContext& hc); - - //! Callback registered to receive Selection callbacks to set m_object - bool OnSelectObject(CBaseObject* object) override; - - //! Callback to check that an object can be selected - bool CanSelectObject(CBaseObject* object) override; - - //! Callback installed on the object, used to determine destruction or deselection. - void OnObjectEvent(CBaseObject* object, int event) override; - - //! Handle key down events. - bool OnKeyDown(CViewport* view, uint32 nChar, uint32 nRepCnt, uint32 nFlags) override; - - //! Retrieves the object's transformation according to the specified reference coordinate system. - Matrix34 GetTransform(RefCoordSys referenceCoordinateSystem, IDisplayViewport* view); - AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING - - //! Calculate orientation of 3 points on screen, return 1.0f if clockwise, -1.0f if counter-clockwise - float CalculateOrientation(const QPoint& p1, const QPoint& p2, const QPoint& p3); - -private: - - AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING - HitContext m_hc; //!< HACK: Cache the hitcontext given that it's values may differ depending on the viewport they are coming from. - AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING -}; - -//! Singleton that holds all the configuration cvars for the different features and debug options -//! used by the CRotationControl -class RotationControlConfiguration -{ -public: - - static RotationControlConfiguration& Get() - { - static RotationControlConfiguration instance; - return instance; - } - - //! If enabled it will draw the inner rotation decorator. - DeclareConstIntCVar(RotationControl_DrawDecorators, 0); - - //! If enabled the hit testing geometry is rendered. - DeclareConstIntCVar(RotationControl_DebugHitTesting, 0); - - //! If enabled a sphere will be drawn to represent the view axis angle to the mouse cursor. - DeclareConstIntCVar(RotationControl_AngleTracking, 0); - -private: - - RotationControlConfiguration(); - RotationControlConfiguration(const RotationControlConfiguration&) = delete; - RotationControlConfiguration& operator = (const RotationControlConfiguration&) = delete; - ~RotationControlConfiguration() {} -}; - -#endif // CRYINCLUDE_EDITOR_ROTATETOOL_H diff --git a/Code/Sandbox/Editor/SetVectorDlg.cpp b/Code/Sandbox/Editor/SetVectorDlg.cpp deleted file mode 100644 index 583f5ff4af..0000000000 --- a/Code/Sandbox/Editor/SetVectorDlg.cpp +++ /dev/null @@ -1,257 +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 "SetVectorDlg.h" - -// Editor -#include "MainWindow.h" -#include "MathConversion.h" -#include "ActionManager.h" -#include "Objects/BaseObject.h" -#include "Objects/SelectionGroup.h" - -AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING -#include "ui_SetVectorDlg.h" -AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING - -///////////////////////////////////////////////////////////////////////////// -// CSetVectorDlg dialog - - -CSetVectorDlg::CSetVectorDlg(QWidget* pParent /*=NULL*/) - : QDialog(pParent) - , m_ui(new Ui::SetVectorDlg) -{ - m_ui->setupUi(this); - - OnInitDialog(); - - connect(m_ui->buttonOk, &QPushButton::clicked, this, &CSetVectorDlg::accept); - connect(m_ui->buttonCancel, &QPushButton::clicked, this, &CSetVectorDlg::reject); -} - -CSetVectorDlg::~CSetVectorDlg() -{ -} - -///////////////////////////////////////////////////////////////////////////// -// CSetVectorDlg message handlers - - -void CSetVectorDlg::OnInitDialog() -{ - QString editModeString; - int emode = GetIEditor()->GetEditMode(); - - if (emode == eEditModeMove) - { - editModeString = tr("Position"); - } - else if (emode == eEditModeRotate) - { - editModeString = tr("Rotation"); - } - else if (emode == eEditModeScale) - { - editModeString = tr("Scale"); - } - - m_ui->label->setText(tr("Enter %1 here:").arg(editModeString)); - - currentVec = GetVectorFromEditor(); - m_ui->edit->setText(QStringLiteral("%1, %2, %3").arg(currentVec.x, 2, 'f', 2).arg(currentVec.y, 2, 'f', 2).arg(currentVec.z, 2, 'f', 2)); -} - -void CSetVectorDlg::accept() -{ - Vec3 newVec = GetVectorFromText(); - SetVector(newVec); - - if (GetIEditor()->GetEditMode() == eEditModeMove && currentVec.GetDistance(newVec) > 10.0f) - { - MainWindow::instance()->GetActionManager()->GetAction(ID_GOTO_SELECTED)->trigger(); - } - QDialog::accept(); -} - -Vec3 CSetVectorDlg::GetVectorFromEditor() -{ - Vec3 v; - int emode = GetIEditor()->GetEditMode(); - CBaseObject* obj = GetIEditor()->GetSelectedObject(); - bool bWorldSpace = GetIEditor()->GetReferenceCoordSys() == COORDS_WORLD; - - if (obj) - { - v = obj->GetWorldPos(); - } - - if (emode == eEditModeMove) - { - if (obj) - { - if (bWorldSpace) - { - v = obj->GetWorldTM().GetTranslation(); - } - else - { - v = obj->GetPos(); - } - } - } - if (emode == eEditModeRotate) - { - if (obj) - { - Quat qrot; - if (bWorldSpace) - { - AffineParts ap; - ap.SpectralDecompose(obj->GetWorldTM()); - qrot = ap.rot; - } - else - { - qrot = obj->GetRotation(); - } - - v = AZVec3ToLYVec3(AZ::ConvertQuaternionToEulerDegrees(LYQuaternionToAZQuaternion(qrot))); - } - } - if (emode == eEditModeScale) - { - if (obj) - { - if (bWorldSpace) - { - AffineParts ap; - ap.SpectralDecompose(obj->GetWorldTM()); - v = ap.scale; - } - else - { - v = obj->GetScale(); - } - } - } - return v; -} - -Vec3 CSetVectorDlg::GetVectorFromText() -{ - return GetVectorFromString(m_ui->edit->text()); -} - -Vec3 CSetVectorDlg::GetVectorFromString(const QString& vecString) -{ - const int maxCoordinates = 3; - float vec[maxCoordinates] = { 0, 0, 0 }; - - const QStringList parts = vecString.split(QRegularExpression("[\\s,;\\t]"), Qt::SkipEmptyParts); - const int checkCoords = AZStd::GetMin(parts.count(), maxCoordinates); - for (int k = 0; k < checkCoords; ++k) - { - vec[k] = parts[k].toDouble(); - } - - return Vec3(vec[0], vec[1], vec[2]); -} - -void CSetVectorDlg::SetVector(const Vec3& v) -{ - int emode = GetIEditor()->GetEditMode(); - if (emode != eEditModeMove && emode != eEditModeRotate && emode != eEditModeScale) - { - return; - } - - int referenceCoordSys = GetIEditor()->GetReferenceCoordSys(); - - CBaseObject* obj = GetIEditor()->GetSelectedObject(); - - Matrix34 tm; - AffineParts ap; - if (obj) - { - tm = obj->GetWorldTM(); - ap.SpectralDecompose(tm); - } - - if (emode == eEditModeMove) - { - if (obj) - { - CUndo undo("Set Position"); - if (referenceCoordSys == COORDS_WORLD) - { - tm.SetTranslation(v); - obj->SetWorldTM(tm, eObjectUpdateFlags_UserInput); - } - else - { - obj->SetPos(v, eObjectUpdateFlags_UserInput); - } - } - } - if (emode == eEditModeRotate) - { - CUndo undo("Set Rotation"); - if (obj) - { - Quat qrot = AZQuaternionToLYQuaternion(AZ::ConvertEulerDegreesToQuaternion(LYVec3ToAZVec3(v))); - if (referenceCoordSys == COORDS_WORLD) - { - tm = Matrix34::Create(ap.scale, qrot, ap.pos); - obj->SetWorldTM(tm, eObjectUpdateFlags_UserInput); - } - else - { - obj->SetRotation(qrot, eObjectUpdateFlags_UserInput); - } - } - else - { - GetIEditor()->GetSelection()->Rotate((Ang3)v, referenceCoordSys); - } - } - if (emode == eEditModeScale) - { - if (v.x == 0 || v.y == 0 || v.z == 0) - { - return; - } - - CUndo undo("Set Scale"); - if (obj) - { - if (referenceCoordSys == COORDS_WORLD) - { - tm = Matrix34::Create(v, ap.rot, ap.pos); - obj->SetWorldTM(tm, eObjectUpdateFlags_UserInput); - } - else - { - obj->SetScale(v, eObjectUpdateFlags_UserInput); - } - } - else - { - GetIEditor()->GetSelection()->Scale(v, referenceCoordSys); - } - } -} - -#include diff --git a/Code/Sandbox/Editor/SetVectorDlg.h b/Code/Sandbox/Editor/SetVectorDlg.h deleted file mode 100644 index e9fd8115e5..0000000000 --- a/Code/Sandbox/Editor/SetVectorDlg.h +++ /dev/null @@ -1,61 +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_SETVECTORDLG_H -#define CRYINCLUDE_EDITOR_SETVECTORDLG_H - -#pragma once -// GotoPositionDlg.h : header file -// - -#if !defined(Q_MOC_RUN) -#include -#endif - -namespace Ui -{ - class SetVectorDlg; -} - -///////////////////////////////////////////////////////////////////////////// -// CSetVectorDlg dialog - -class SANDBOX_API CSetVectorDlg - : public QDialog -{ - Q_OBJECT - // Construction -public: - CSetVectorDlg(QWidget* pParent = NULL); // standard constructor - ~CSetVectorDlg(); - - static Vec3 GetVectorFromString(const QString& vecString); - - // Implementation -protected: - void OnInitDialog(); - void accept() override; - void SetVector(const Vec3& v); - Vec3 GetVectorFromText(); - Vec3 GetVectorFromEditor(); - AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING - Vec3 currentVec; - AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING - -private: - AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING - QScopedPointer m_ui; - AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING -}; - -#endif // CRYINCLUDE_EDITOR_SETVECTORDLG_H diff --git a/Code/Sandbox/Editor/SetVectorDlg.ui b/Code/Sandbox/Editor/SetVectorDlg.ui deleted file mode 100644 index a8ed3cb282..0000000000 --- a/Code/Sandbox/Editor/SetVectorDlg.ui +++ /dev/null @@ -1,55 +0,0 @@ - - - SetVectorDlg - - - - 0 - 0 - 270 - 99 - - - - Set Vector - - - - 29 - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Cancel - - - - - - - Set - - - - - - - - diff --git a/Code/Sandbox/Editor/Settings.cpp b/Code/Sandbox/Editor/Settings.cpp index 0f25b6ac6d..038af33129 100644 --- a/Code/Sandbox/Editor/Settings.cpp +++ b/Code/Sandbox/Editor/Settings.cpp @@ -653,12 +653,6 @@ void SEditorSettings::Save() SaveValue("Settings", "ForceSkyUpdate", gSettings.bForceSkyUpdate); - ////////////////////////////////////////////////////////////////////////// - // Vertex snapping settings - ////////////////////////////////////////////////////////////////////////// - SaveValue("Settings\\VertexSnapping", "VertexCubeSize", vertexSnappingSettings.vertexCubeSize); - SaveValue("Settings\\VertexSnapping", "RenderPenetratedBoundBox", vertexSnappingSettings.bRenderPenetratedBoundBox); - ////////////////////////////////////////////////////////////////////////// // Smart file open settings ////////////////////////////////////////////////////////////////////////// @@ -886,12 +880,6 @@ void SEditorSettings::Load() LoadValue("Settings", "ForceSkyUpdate", gSettings.bForceSkyUpdate); - ////////////////////////////////////////////////////////////////////////// - // Vertex snapping settings - ////////////////////////////////////////////////////////////////////////// - LoadValue("Settings\\VertexSnapping", "VertexCubeSize", vertexSnappingSettings.vertexCubeSize); - LoadValue("Settings\\VertexSnapping", "RenderPenetratedBoundBox", vertexSnappingSettings.bRenderPenetratedBoundBox); - ////////////////////////////////////////////////////////////////////////// // Smart file open settings ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Sandbox/Editor/Settings.h b/Code/Sandbox/Editor/Settings.h index 918647388a..512c6e3942 100644 --- a/Code/Sandbox/Editor/Settings.h +++ b/Code/Sandbox/Editor/Settings.h @@ -119,18 +119,6 @@ struct SDeepSelectionSettings bool bStickDuplicate; }; -////////////////////////////////////////////////////////////////////////// -// Settings for vertex snapping. -////////////////////////////////////////////////////////////////////////// -struct SVertexSnappingSettings -{ - SVertexSnappingSettings() - : vertexCubeSize(0.01f) - , bRenderPenetratedBoundBox(false) {} - float vertexCubeSize; - bool bRenderPenetratedBoundBox; -}; - ////////////////////////////////////////////////////////////////////////// struct SObjectColors { @@ -474,9 +462,6 @@ AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING // Object Highlight Settings SObjectColors objectColorSettings; - - // Vertex Snapping Settings - SVertexSnappingSettings vertexSnappingSettings; AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING SSmartOpenDialogSettings smartOpenSettings; diff --git a/Code/Sandbox/Editor/ToolbarManager.cpp b/Code/Sandbox/Editor/ToolbarManager.cpp index d39dabf034..6977121933 100644 --- a/Code/Sandbox/Editor/ToolbarManager.cpp +++ b/Code/Sandbox/Editor/ToolbarManager.cpp @@ -587,26 +587,13 @@ AmazonToolbar ToolbarManager::GetEditModeToolbar() const t.AddAction(ID_TOOLBAR_SEPARATOR, ORIGINAL_TOOLBAR_VERSION); - if (!GetIEditor()->IsNewViewportInteractionModelEnabled()) - { - t.AddAction(ID_EDITMODE_SELECT, ORIGINAL_TOOLBAR_VERSION); - } - t.AddAction(ID_EDITMODE_MOVE, ORIGINAL_TOOLBAR_VERSION); t.AddAction(ID_EDITMODE_ROTATE, ORIGINAL_TOOLBAR_VERSION); t.AddAction(ID_EDITMODE_SCALE, ORIGINAL_TOOLBAR_VERSION); - t.AddAction(ID_EDITMODE_SELECTAREA, ORIGINAL_TOOLBAR_VERSION); t.AddAction(ID_VIEW_SWITCHTOGAME, TOOLBARS_WITH_PLAY_GAME); t.AddAction(ID_TOOLBAR_SEPARATOR, ORIGINAL_TOOLBAR_VERSION); - t.AddAction(ID_TOOLBAR_WIDGET_REF_COORD, ORIGINAL_TOOLBAR_VERSION); - t.AddAction(ID_SELECT_AXIS_X, ORIGINAL_TOOLBAR_VERSION); - t.AddAction(ID_SELECT_AXIS_Y, ORIGINAL_TOOLBAR_VERSION); - t.AddAction(ID_SELECT_AXIS_Z, ORIGINAL_TOOLBAR_VERSION); - t.AddAction(ID_SELECT_AXIS_XY, ORIGINAL_TOOLBAR_VERSION); - t.AddAction(ID_SELECT_AXIS_TERRAIN, ORIGINAL_TOOLBAR_VERSION); - t.AddAction(ID_SELECT_AXIS_SNAPTOALL, ORIGINAL_TOOLBAR_VERSION); t.AddAction(ID_TOOLBAR_WIDGET_SNAP_GRID, ORIGINAL_TOOLBAR_VERSION); t.AddAction(ID_TOOLBAR_WIDGET_SNAP_ANGLE, ORIGINAL_TOOLBAR_VERSION); t.AddAction(ID_RULER, ORIGINAL_TOOLBAR_VERSION); @@ -623,9 +610,7 @@ 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_ALIGNTOGRID, ORIGINAL_TOOLBAR_VERSION); t.AddAction(ID_OBJECTMODIFY_SETHEIGHT, ORIGINAL_TOOLBAR_VERSION); - t.AddAction(ID_MODIFY_ALIGNOBJTOSURF, ORIGINAL_TOOLBAR_VERSION); if (!GetIEditor()->IsNewViewportInteractionModelEnabled()) { @@ -634,8 +619,6 @@ AmazonToolbar ToolbarManager::GetObjectToolbar() const t.AddAction(ID_EDIT_UNFREEZEALL, ORIGINAL_TOOLBAR_VERSION); } - t.AddAction(ID_OBJECTMODIFY_VERTEXSNAPPING, ORIGINAL_TOOLBAR_VERSION); - return t; } diff --git a/Code/Sandbox/Editor/Viewport.cpp b/Code/Sandbox/Editor/Viewport.cpp index ae2de224cb..1041a4f086 100644 --- a/Code/Sandbox/Editor/Viewport.cpp +++ b/Code/Sandbox/Editor/Viewport.cpp @@ -30,7 +30,6 @@ #include "Util/Ruler.h" #include "PluginManager.h" #include "Include/IRenderListener.h" -#include "EditTool.h" #include "GameEngine.h" #include "Settings.h" @@ -207,8 +206,6 @@ QtViewport::QtViewport(QWidget* parent) GetIEditor()->GetViewManager()->RegisterViewport(this); - m_pLocalEditTool = 0; - m_nCurViewportID = MAX_NUM_VIEWPORTS - 1; m_dropCallback = nullptr; // Leroy@Conffx @@ -232,8 +229,6 @@ QtViewport::QtViewport(QWidget* parent) ////////////////////////////////////////////////////////////////////////// QtViewport::~QtViewport() { - if (m_pLocalEditTool) - m_pLocalEditTool->deleteLater(); delete m_pVisibleObjectsCache; GetIEditor()->GetViewManager()->UnregisterViewport(this); @@ -258,42 +253,6 @@ void QtViewport::GetDimensions(int* pWidth, int* pHeight) const } } -////////////////////////////////////////////////////////////////////////// -CEditTool* QtViewport::GetEditTool() -{ - if (m_pLocalEditTool) - { - return m_pLocalEditTool; - } - return GetIEditor()->GetEditTool(); -} - -////////////////////////////////////////////////////////////////////////// -void QtViewport::SetEditTool(CEditTool* pEditTool, bool bLocalToViewport /*=false */) -{ - if (m_pLocalEditTool == pEditTool) - { - return; - } - - if (m_pLocalEditTool) - { - m_pLocalEditTool->EndEditParams(); - } - m_pLocalEditTool = 0; - - if (bLocalToViewport) - { - m_pLocalEditTool = pEditTool; - m_pLocalEditTool->BeginEditParams(GetIEditor(), 0); - } - else - { - m_pLocalEditTool = 0; - GetIEditor()->SetEditTool(pEditTool); - } -} - ////////////////////////////////////////////////////////////////////////// void QtViewport::RegisterRenderListener(IRenderListener* piListener) { @@ -466,12 +425,6 @@ void QtViewport::Update() m_bAdvancedSelectMode = false; bool bSpaceClick = false; - CEditTool* pEditTool = GetIEditor()->GetEditTool(); - if (pEditTool && pEditTool->IsNeedSpecificBehaviorForSpaceAcce()) - { - bSpaceClick = CheckVirtualKey(Qt::Key_Space); - } - else { bSpaceClick = CheckVirtualKey(Qt::Key_Space) & !CheckVirtualKey(Qt::Key_Shift) /*& !CheckVirtualKey(Qt::Key_Control)*/; } @@ -726,10 +679,6 @@ void QtViewport::OnMouseMove(Qt::KeyboardModifiers modifiers, Qt::MouseButtons b ////////////////////////////////////////////////////////////////////////// void QtViewport::OnSetCursor() { - if (GetEditTool()) - { - GetEditTool()->OnSetCursor(this); - } } ////////////////////////////////////////////////////////////////////////// @@ -803,39 +752,23 @@ void QtViewport::OnRButtonDblClk(Qt::KeyboardModifiers modifiers, const QPoint& } ////////////////////////////////////////////////////////////////////////// -void QtViewport::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +void QtViewport::OnKeyDown([[maybe_unused]] UINT nChar, [[maybe_unused]] UINT nRepCnt, [[maybe_unused]] UINT nFlags) { if (GetIEditor()->IsInGameMode()) { // Ignore key downs while in game. return; } - - if (GetEditTool()) - { - if (GetEditTool()->OnKeyDown(this, nChar, nRepCnt, nFlags)) - { - return; - } - } } ////////////////////////////////////////////////////////////////////////// -void QtViewport::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) +void QtViewport::OnKeyUp([[maybe_unused]] UINT nChar, [[maybe_unused]] UINT nRepCnt, [[maybe_unused]] UINT nFlags) { if (GetIEditor()->IsInGameMode()) { // Ignore key downs while in game. return; } - - if (GetEditTool()) - { - if (GetEditTool()->OnKeyUp(this, nChar, nRepCnt, nFlags)) - { - return; - } - } } ////////////////////////////////////////////////////////////////////////// @@ -1454,28 +1387,6 @@ bool QtViewport::MouseCallback(EMouseEvent event, const QPoint& point, Qt::Keybo } } - ////////////////////////////////////////////////////////////////////////// - // Asks current edit tool to handle mouse callback. - CEditTool* pEditTool = GetEditTool(); - if (pEditTool) - { - if (pEditTool->MouseCallback(this, event, tempPoint, flags)) - { - return true; - } - - // Ask all chain of parent tools if they are handling mouse event. - CEditTool* pParentTool = pEditTool->GetParentTool(); - while (pParentTool) - { - if (pParentTool->MouseCallback(this, event, tempPoint, flags)) - { - return true; - } - pParentTool = pParentTool->GetParentTool(); - } - } - return false; } ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Sandbox/Editor/Viewport.h b/Code/Sandbox/Editor/Viewport.h index acc5a3acfb..9979a3bb0a 100644 --- a/Code/Sandbox/Editor/Viewport.h +++ b/Code/Sandbox/Editor/Viewport.h @@ -45,7 +45,6 @@ struct DisplayContext; class CCryEditDoc; class CLayoutViewPane; class CViewManager; -class CEditTool; class CBaseObjectsCache; struct HitContext; struct IRenderListener; @@ -255,8 +254,6 @@ public: virtual void SetSupplementaryCursorStr(const QString& str) = 0; virtual void SetCursorString(const QString& str) = 0; - virtual CEditTool* GetEditTool() = 0; - virtual void SetFocus() = 0; virtual void Invalidate(BOOL bErase = 1) = 0; @@ -488,10 +485,6 @@ public: void ResetCursor(); void SetSupplementaryCursorStr(const QString& str); - virtual CEditTool* GetEditTool(); - // Assign an edit tool to viewport - virtual void SetEditTool(CEditTool* pEditTool, bool bLocalToViewport = false); - ////////////////////////////////////////////////////////////////////////// // Return visble objects cache. CBaseObjectsCache* GetVisibleObjectsCache() { return m_pVisibleObjectsCache; }; @@ -627,8 +620,6 @@ protected: // Same construction matrix is shared by all viewports. Matrix34 m_constructionMatrix[LAST_COORD_SYSTEM]; - QPointer m_pLocalEditTool; - std::vector m_cRenderListeners; typedef std::vector<_smart_ptr > PostRenderers; diff --git a/Code/Sandbox/Editor/VoxelAligningTool.cpp b/Code/Sandbox/Editor/VoxelAligningTool.cpp deleted file mode 100644 index 1d45dd2d3f..0000000000 --- a/Code/Sandbox/Editor/VoxelAligningTool.cpp +++ /dev/null @@ -1,151 +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 "VoxelAligningTool.h" - -// Editor -#include "SurfaceInfoPicker.h" -#include "Objects/SelectionGroup.h" - -////////////////////////////////////////////////////////////////////////// -CVoxelAligningTool::CVoxelAligningTool() -{ - m_curObj = 0; - m_PreviewMode = ePM_Idle; - - CSelectionGroup* sel = GetIEditor()->GetSelection(); - if (!sel->IsEmpty()) - { - m_curObj = sel->GetObject(0); - m_CurObjTMBeforePreviewMode = m_curObj->GetWorldTM(); - m_q = m_curObj->GetRotation(); - } -} - -////////////////////////////////////////////////////////////////////////// -CVoxelAligningTool::~CVoxelAligningTool() -{ -} - -////////////////////////////////////////////////////////////////////////// -void CVoxelAligningTool::Display([[maybe_unused]] DisplayContext& dc) -{ -} - -////////////////////////////////////////////////////////////////////////// -bool CVoxelAligningTool::MouseCallback([[maybe_unused]] CViewport* view, EMouseEvent event, QPoint& point, int flags) -{ - // Get contrl key status. - bool bCtrlClick = (flags & MK_CONTROL); - bool bShiftClick = (flags & MK_SHIFT); - bool bOnlyCtrlClick = bCtrlClick && !bShiftClick; - - CSelectionGroup* sel = GetIEditor()->GetSelection(); - if (sel->IsEmpty() || m_curObj != sel->GetObject(0)) - { - GetIEditor()->SetEditTool(0); - return true; - } - - if (event == eMouseMove) - { - if (m_PreviewMode == ePM_Idle) - { - if (bOnlyCtrlClick) - { - if (m_curObj) - { - m_CurObjTMBeforePreviewMode = m_curObj->GetWorldTM(); - } - m_PreviewMode = ePM_Previewing; - GetIEditor()->BeginUndo(); - } - } - else if (!bOnlyCtrlClick) - { - if (m_curObj) - { - m_curObj->SetWorldTM(m_CurObjTMBeforePreviewMode); - //m_curObj->SetRotation(m_extraRot); - } - m_PreviewMode = ePM_Idle; - GetIEditor()->CancelUndo(); - } - - if (m_PreviewMode == ePM_Previewing && bOnlyCtrlClick) - { // Preview align to normal - ApplyPickedTM2CurObj(point); - } - } - - if (event == eMouseLDown && m_PreviewMode == ePM_Previewing) - { - m_CurObjTMBeforePreviewMode = m_curObj->GetWorldTM(); - GetIEditor()->AcceptUndo("Surface Normal Aligning"); - GetIEditor()->SetEditTool(NULL); - } - - return true; -} - -////////////////////////////////////////////////////////////////////////// -void CVoxelAligningTool::ApplyPickedTM2CurObj(const QPoint& point, [[maybe_unused]] bool bPickOnlyTerrain) -{ - int nPickFlag = CSurfaceInfoPicker::ePOG_All; - SRayHitInfo hitInfo; - CSurfaceInfoPicker::CExcludedObjects excludeObjects; - if (m_curObj) - { - excludeObjects.Add(m_curObj); - } - CSurfaceInfoPicker surfacePicker; - if (surfacePicker.Pick(point, hitInfo, &excludeObjects, nPickFlag)) - { - m_curObj->SetPos(hitInfo.vHitPos, eObjectUpdateFlags_UserInput); - ApplyRotation(hitInfo.vHitNormal); - } -} - -////////////////////////////////////////////////////////////////////////// -void CVoxelAligningTool::ApplyRotation(Vec3& normal) -{ - Vec3 zaxis = m_q * Vec3(0, 0, 1); - zaxis.Normalize(); - Quat nq; - nq.SetRotationV0V1(zaxis, normal); - m_curObj->SetRotation(nq * m_q, eObjectUpdateFlags_UserInput); -} - -////////////////////////////////////////////////////////////////////////// -void CVoxelAligningTool::BeginEditParams([[maybe_unused]] IEditor* ie, [[maybe_unused]] int flags) -{ -} - -////////////////////////////////////////////////////////////////////////// -void CVoxelAligningTool::EndEditParams() -{ -} - -////////////////////////////////////////////////////////////////////////// -bool CVoxelAligningTool::OnKeyDown([[maybe_unused]] CViewport* view, uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) -{ - if (nChar == VK_ESCAPE) - { - GetIEditor()->SetEditTool(0); - } - return false; -} - -#include diff --git a/Code/Sandbox/Editor/VoxelAligningTool.h b/Code/Sandbox/Editor/VoxelAligningTool.h deleted file mode 100644 index bfa0e19d9a..0000000000 --- a/Code/Sandbox/Editor/VoxelAligningTool.h +++ /dev/null @@ -1,75 +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 VoxelAligningTool, edit tool for cloning of objects.. - - -#ifndef CRYINCLUDE_EDITOR_VOXELALIGNINGTOOL_H -#define CRYINCLUDE_EDITOR_VOXELALIGNINGTOOL_H - -#pragma once - -#if !defined(Q_MOC_RUN) -#include "EditTool.h" -#endif - -class CBaseObject; - -/*! - * CVoxelAligningTool, When created duplicate current selection, and manages cloned selection. - * - */ - -class CVoxelAligningTool - : public CEditTool -{ - Q_OBJECT -public: - Q_INVOKABLE CVoxelAligningTool(); - - ////////////////////////////////////////////////////////////////////////// - // 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(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; }; - ////////////////////////////////////////////////////////////////////////// - -protected: - virtual ~CVoxelAligningTool(); - // Delete itself. - void DeleteThis() { delete this; }; - - void ApplyPickedTM2CurObj(const QPoint& point, bool bPickOnlyTerrain = false); - void ApplyRotation(Vec3& normal); - -private: - - CBaseObject* m_curObj; - Quat m_q; - - enum EPreviewMode - { - ePM_Idle, - ePM_Previewing, - }; - EPreviewMode m_PreviewMode; - Matrix34 m_CurObjTMBeforePreviewMode; -}; - - -#endif // CRYINCLUDE_EDITOR_VOXELALIGNINGTOOL_H diff --git a/Code/Sandbox/Editor/editor_lib_files.cmake b/Code/Sandbox/Editor/editor_lib_files.cmake index 5696931f26..4adf501d45 100644 --- a/Code/Sandbox/Editor/editor_lib_files.cmake +++ b/Code/Sandbox/Editor/editor_lib_files.cmake @@ -10,8 +10,6 @@ # set(FILES - NullEditTool.h - NullEditTool.cpp Translations/editor_en-us.ts Translations/assetbrowser_en-us.ts DPIAware.xml @@ -389,8 +387,6 @@ set(FILES Controls/NumberCtrl.h Controls/PreviewModelCtrl.cpp Controls/PreviewModelCtrl.h - Controls/QRollupCtrl.cpp - Controls/QRollupCtrl.h Controls/SplineCtrl.cpp Controls/SplineCtrl.h Controls/SplineCtrlEx.cpp @@ -401,8 +397,6 @@ set(FILES Controls/TimelineCtrl.h Controls/TimeOfDaySlider.cpp Controls/TimeOfDaySlider.h - Controls/ToolButton.cpp - Controls/ToolButton.h Controls/WndGridHelper.h Controls/ReflectedPropertyControl/PropertyAnimationCtrl.cpp Controls/ReflectedPropertyControl/PropertyAnimationCtrl.h @@ -451,8 +445,6 @@ set(FILES CustomResolutionDlg.cpp CustomResolutionDlg.ui CustomResolutionDlg.h - Dialogs/ButtonsPanel.cpp - Dialogs/ButtonsPanel.h ErrorReportDialog.ui ErrorReportDialog.cpp ErrorReportDialog.h @@ -492,9 +484,6 @@ set(FILES SelectLightAnimationDialog.h SelectSequenceDialog.cpp SelectSequenceDialog.h - SetVectorDlg.cpp - SetVectorDlg.h - SetVectorDlg.ui ShadersDialog.cpp ShadersDialog.h ShadersDialog.ui @@ -533,18 +522,8 @@ set(FILES Dialogs/PythonScriptsDialog.ui Dialogs/Generic/UserOptions.cpp Dialogs/Generic/UserOptions.h - ObjectCloneTool.cpp - ObjectCloneTool.h EditMode/SubObjectSelectionReferenceFrameCalculator.cpp EditMode/SubObjectSelectionReferenceFrameCalculator.h - EditMode/ObjectMode.cpp - EditMode/ObjectMode.h - RotateTool.cpp - RotateTool.h - EditTool.cpp - EditTool.h - VoxelAligningTool.cpp - VoxelAligningTool.h Export/ExportManager.cpp Export/ExportManager.h Export/OBJExporter.cpp @@ -575,7 +554,6 @@ set(FILES Dialogs/DuplicatedObjectsHandlerDlg.h DocMultiArchive.h EditMode/DeepSelection.h - EditMode/VertexSnappingModeTool.h FBXExporterDialog.h FileTypeUtils.h GridUtils.h @@ -639,8 +617,6 @@ set(FILES Material/MaterialLibrary.h Material/MaterialManager.cpp Material/MaterialManager.h - Material/MaterialPickTool.cpp - Material/MaterialPickTool.h MaterialSender.h MaterialSender.cpp Material/MaterialPythonFuncs.h @@ -742,7 +718,6 @@ set(FILES ErrorReportTableModel.h ErrorReportTableModel.cpp EditMode/DeepSelection.cpp - EditMode/VertexSnappingModeTool.cpp FBXExporterDialog.cpp FBXExporterDialog.ui FileTypeUtils.cpp diff --git a/Code/Sandbox/Editor/editor_lib_test_files.cmake b/Code/Sandbox/Editor/editor_lib_test_files.cmake index 27713f4d30..f537169136 100644 --- a/Code/Sandbox/Editor/editor_lib_test_files.cmake +++ b/Code/Sandbox/Editor/editor_lib_test_files.cmake @@ -20,7 +20,6 @@ set(FILES Lib/Tests/test_MainWindowPythonBindings.cpp Lib/Tests/test_MaterialPythonFuncs.cpp Lib/Tests/test_ObjectManagerPythonBindings.cpp - Lib/Tests/test_SetVectorDlg.cpp Lib/Tests/test_TrackViewPythonBindings.cpp Lib/Tests/test_ViewPanePythonBindings.cpp Lib/Tests/test_ViewportTitleDlgPythonBindings.cpp diff --git a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/ComponentEntityEditorPlugin_precompiled.h b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/ComponentEntityEditorPlugin_precompiled.h index 581c453919..12757f5b24 100644 --- a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/ComponentEntityEditorPlugin_precompiled.h +++ b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/ComponentEntityEditorPlugin_precompiled.h @@ -21,7 +21,6 @@ #include #include #include -#include #include ///////////////////////////////////////////////////////////////////////////// diff --git a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.cpp b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.cpp index 4a03dcd7dc..a97bdbf2ab 100644 --- a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.cpp +++ b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.cpp @@ -320,14 +320,6 @@ void CComponentEntityObject::OnSelected() // Invoked when selected via tools application, so we notify sandbox. const bool wasSelected = IsSelected(); GetIEditor()->GetObjectManager()->SelectObject(this); - - // If we get here and we're not already selected in sandbox land it means - // the selection started in AZ land and we need to clear any edit tool - // the user may have selected from the rollup bar - if (GetIEditor()->GetEditTool() && !wasSelected) - { - GetIEditor()->SetEditTool(nullptr); - } } } diff --git a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.h b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.h index 4bf55cfbe6..fa59ec8507 100644 --- a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.h +++ b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.h @@ -24,6 +24,8 @@ #include #include +#include + #include "../Editor/Objects/EntityObject.h" #include #include diff --git a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp index 9c917b25c0..89ef4ead7f 100644 --- a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp +++ b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp @@ -1383,11 +1383,6 @@ void SandboxIntegrationManager::SetShowCircularDependencyError(const bool& showC } ////////////////////////////////////////////////////////////////////////// -void SandboxIntegrationManager::SetEditTool(const char* tool) -{ - GetIEditor()->SetEditTool(tool); -} - void SandboxIntegrationManager::LaunchLuaEditor(const char* files) { CCryEditApp::instance()->OpenLUAEditor(files); diff --git a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.h b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.h index 36767605b2..ea4d2fe32b 100644 --- a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.h +++ b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.h @@ -162,7 +162,6 @@ private: bool GetUndoSliceOverrideSaveValue() override; bool GetShowCircularDependencyError() override; void SetShowCircularDependencyError(const bool& showCircularDependencyError) override; - void SetEditTool(const char* tool) override; void LaunchLuaEditor(const char* files) override; bool IsLevelDocumentOpen() override; AZStd::string GetLevelName() override; diff --git a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/UI/ComponentPalette/ComponentPaletteWindow.cpp b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/UI/ComponentPalette/ComponentPaletteWindow.cpp index 734d490c6c..a1ec03c2b1 100644 --- a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/UI/ComponentPalette/ComponentPaletteWindow.cpp +++ b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/UI/ComponentPalette/ComponentPaletteWindow.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include diff --git a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/UI/Outliner/OutlinerWidget.cpp b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/UI/Outliner/OutlinerWidget.cpp index f735048ed0..fb8084cb6f 100644 --- a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/UI/Outliner/OutlinerWidget.cpp +++ b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/UI/Outliner/OutlinerWidget.cpp @@ -312,19 +312,6 @@ void OutlinerWidget::OnSelectionChanged(const QItemSelection& selected, const QI AzToolsFramework::EntityIdList newlyDeselected; ExtractEntityIdsFromSelection(deselected, newlyDeselected); - CEditTool* tool = GetIEditor()->GetEditTool(); - IClassDesc* classDescription = tool ? tool->GetClassDesc() : nullptr; - - if (classDescription && QString::compare(classDescription->ClassName(), "EditTool.Clone") == 0) - { - // if the user clicks an empty space or selects a different entity in the entity outliner, the clone operation will be accepted. - if ((newlySelected.empty() && !newlyDeselected.empty()) || !newlySelected.empty()) - { - tool->Accept(true); - GetIEditor()->GetSelection()->FinishChanges(); - } - } - AzToolsFramework::ScopedUndoBatch undo("Select Entity"); // initialize the selection command here to store the current selection before diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImporter.cpp index 8bbe62c913..650eb4c935 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImporter.cpp +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImporter.cpp @@ -73,7 +73,7 @@ namespace AZ SerializeContext* serializeContext = azrtti_cast(context); if (serializeContext) { - serializeContext->Class()->Version(1); + serializeContext->Class()->Version(2); // SPEC-5776 } } diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImporter.h b/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImporter.h index 7aa43ca389..5bf9ab84c9 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImporter.h +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImporter.h @@ -51,7 +51,7 @@ namespace AZ AZStd::unique_ptr m_sceneWrapper; AZStd::shared_ptr m_sceneSystem; - bool m_useAssetImporterSDK = false; + bool m_useAssetImporterSDK = true; }; } // namespace FbxSceneBuilder } // namespace SceneAPI diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpAnimationImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpAnimationImporter.cpp index 9522512619..e456f2dbab 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpAnimationImporter.cpp +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpAnimationImporter.cpp @@ -51,6 +51,7 @@ namespace AZ AZ_Warning("AnimationImporter", false, "Animation ticks per second should not be zero, defaulting to %d keyframes for animation.", keysSize); return keysSize; } + const double totalTicks = duration / ticksPerSecond; AZ::u32 numKeys = keysSize; // +1 because the animation is from [0, duration] - we have a keyframe at the end of the duration which needs to be included @@ -422,10 +423,12 @@ namespace AZ // If there is no bone animation on the current node, then generate one here. AZStd::shared_ptr createdAnimationData = AZStd::make_shared(); - createdAnimationData->ReserveKeyFrames( - animation->mDuration + - 1); // +1 because we start at 0 and the last keyframe is at mDuration instead of mDuration-1 - createdAnimationData->SetTimeStepBetweenFrames(1.0 / animation->mTicksPerSecond); + + const size_t numKeyframes = animation->mDuration + 1; // +1 because we start at 0 and the last keyframe is at mDuration instead of mDuration-1 + createdAnimationData->ReserveKeyFrames(numKeyframes); + + const double timeStepBetweenFrames = 1.0 / animation->mTicksPerSecond; + createdAnimationData->SetTimeStepBetweenFrames(timeStepBetweenFrames); // Set every frame of the animation to the start location of the node. aiMatrix4x4 combinedTransform = GetConcatenatedLocalTransform(currentNode); @@ -527,7 +530,7 @@ namespace AZ // are less predictable than just using a fixed time step. // AssImp documentation claims animation->mDuration is the duration of the animation in ticks, but // not all animations we've tested follow that pattern. Sometimes duration is in seconds. - const AZ::u32 numKeyFrames = GetNumKeyFrames( + const size_t numKeyFrames = GetNumKeyFrames( AZStd::max(AZStd::max(anim->mNumScalingKeys, anim->mNumPositionKeys), anim->mNumRotationKeys), animation->mDuration, animation->mTicksPerSecond); @@ -543,8 +546,10 @@ namespace AZ for (AZ::u32 frame = 0; frame < numKeyFrames; ++frame) { const double time = GetTimeForFrame(frame, animation->mTicksPerSecond); - aiVector3D scale = aiVector3D(1.f, 1.f, 1.f), position = aiVector3D(0.f, 0.f, 0.f); - aiQuaternion rotation(1.f, 0.f, 0.f, 0.f); + + aiVector3D scale(1.0f, 1.0f, 1.0f); + aiVector3D position(0.0f, 0.0f, 0.0f); + aiQuaternion rotation(1.0f, 0.0f, 0.0f, 0.0f); if (!SampleKeyFrame(scale, anim->mScalingKeys, anim->mNumScalingKeys, time, lastScaleIndex) || !SampleKeyFrame(position, anim->mPositionKeys, anim->mNumPositionKeys, time, lastPositionIndex) || !SampleKeyFrame(rotation, anim->mRotationKeys, anim->mNumRotationKeys, time, lastRotationIndex)) @@ -553,7 +558,6 @@ namespace AZ } aiMatrix4x4 transform(scale, rotation, position); - DataTypes::MatrixType animTransform = AssImpSDKWrapper::AssImpTypeConverter::ToTransform(transform); context.m_sourceSceneSystem.SwapTransformForUpAxis(animTransform); @@ -618,7 +622,7 @@ namespace AZ AZStd::shared_ptr morphAnimNode = AZStd::make_shared(); - const AZ::u32 numKeyFrames = GetNumKeyFrames(keys.size(), animation->mDuration, animation->mTicksPerSecond); + const size_t numKeyFrames = GetNumKeyFrames(keys.size(), animation->mDuration, animation->mTicksPerSecond); morphAnimNode->ReserveKeyFrames(numKeyFrames); morphAnimNode->SetTimeStepBetweenFrames(s_defaultTimeStepBetweenFrames); @@ -627,7 +631,7 @@ namespace AZ const AZ::u32 maxKeys = keys.size(); AZ::u32 keyIdx = 0; - for (AZ::u32 frame = 0; frame <= numKeyFrames; ++frame) + for (AZ::u32 frame = 0; frame < numKeyFrames; ++frame) { const double time = GetTimeForFrame(frame, animation->mTicksPerSecond); @@ -640,7 +644,6 @@ namespace AZ morphAnimNode->AddKeyFrame(weight); } - const size_t dotIndex = nodeName.find_last_of('.'); nodeName = nodeName.substr(dotIndex + 1); diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpUvMapImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpUvMapImporter.cpp index 6d9189c1de..65e7c00d74 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpUvMapImporter.cpp +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpUvMapImporter.cpp @@ -32,7 +32,7 @@ namespace AZ { namespace FbxSceneBuilder { - const char* AssImpUvMapImporter::m_defaultNodeName = "UVMap"; + const char* AssImpUvMapImporter::m_defaultNodeName = "UV"; AssImpUvMapImporter::AssImpUvMapImporter() { @@ -44,7 +44,7 @@ namespace AZ SerializeContext* serializeContext = azrtti_cast(context); if (serializeContext) { - serializeContext->Class()->Version(2); // LYN-2576 + serializeContext->Class()->Version(3); // LYN-2506 } } @@ -84,7 +84,13 @@ namespace AZ AZStd::shared_ptr uvMap = AZStd::make_shared(); uvMap->ReserveContainerSpace(vertexCount); + AZStd::string name(AZStd::string::format("%s%d", m_defaultNodeName, texCoordIndex)); + if (mesh->mTextureCoordsNames[texCoordIndex].length) + { + name = mesh->mTextureCoordsNames[texCoordIndex].C_Str(); + } + uvMap->SetCustomName(name.c_str()); for (int v = 0; v < mesh->mNumVertices; ++v) diff --git a/Code/Tools/SceneAPI/SceneCore/Export/MtlMaterialExporter.cpp b/Code/Tools/SceneAPI/SceneCore/Export/MtlMaterialExporter.cpp index f364167173..261b7be33f 100644 --- a/Code/Tools/SceneAPI/SceneCore/Export/MtlMaterialExporter.cpp +++ b/Code/Tools/SceneAPI/SceneCore/Export/MtlMaterialExporter.cpp @@ -86,7 +86,7 @@ namespace AZ if (sourceFileExists && !updateMaterial) { - // Don't write to the cache if there's a source material as this will be the master material. + // Don't write to the cache if there's a source material as this will be the primary material. continue; } diff --git a/Code/Tools/SceneAPI/SceneUI/SceneWidgets/SceneGraphWidget.h b/Code/Tools/SceneAPI/SceneUI/SceneWidgets/SceneGraphWidget.h index 4f2406206f..ce01889a63 100644 --- a/Code/Tools/SceneAPI/SceneUI/SceneWidgets/SceneGraphWidget.h +++ b/Code/Tools/SceneAPI/SceneUI/SceneWidgets/SceneGraphWidget.h @@ -84,7 +84,7 @@ namespace AZ NoneCheckable, // No nodes can be checked. OnlyFilterTypesCheckable // Only nodes in the filter type list can be checked. }; - // Updates the tree to include/exclude check boxes and the master selection. Call "BuildTree()" to rebuild the tree. + // Updates the tree to include/exclude check boxes and the primary selection. Call "BuildTree()" to rebuild the tree. virtual void MakeCheckable(CheckableOption option); // Add a type to filter for. Filter types are used to determine if a check box is added and/or to be shown if // the type is an end point. See "IncludeEndPoints" and "MakeCheckable" for more details. diff --git a/Gems/AssetMemoryAnalyzer/Code/Source/AssetMemoryAnalyzer.cpp b/Gems/AssetMemoryAnalyzer/Code/Source/AssetMemoryAnalyzer.cpp index 1083ec876a..ac3ab0dd04 100644 --- a/Gems/AssetMemoryAnalyzer/Code/Source/AssetMemoryAnalyzer.cpp +++ b/Gems/AssetMemoryAnalyzer/Code/Source/AssetMemoryAnalyzer.cpp @@ -308,7 +308,7 @@ namespace AssetMemoryAnalyzer AZStd::function recurse; recurse = [&recurse](AssetInfo* outAsset, AssetTreeNode* inAsset, int depth) { - outAsset->m_id = inAsset->m_masterInfo ? inAsset->m_masterInfo->m_id->m_id.c_str() : nullptr; + outAsset->m_id = inAsset->m_primaryinfo ? inAsset->m_primaryinfo->m_id->m_id.c_str() : nullptr; // For every code point in this asset node, record its allocations for (auto& codePointInfo : inAsset->m_data.m_codePointsToAllocations) diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Tests/TestAssets/temp/128x128_RGBA8.tga.streamingimage b/Gems/Atom/Asset/ImageProcessingAtom/Code/Tests/TestAssets/temp/128x128_RGBA8.tga.streamingimage new file mode 100644 index 0000000000..b867b7cfb1 Binary files /dev/null and b/Gems/Atom/Asset/ImageProcessingAtom/Code/Tests/TestAssets/temp/128x128_RGBA8.tga.streamingimage differ diff --git a/Gems/Atom/Asset/Shader/Code/Source/Editor/AzslShaderBuilderSystemComponent.cpp b/Gems/Atom/Asset/Shader/Code/Source/Editor/AzslShaderBuilderSystemComponent.cpp index d50e5ff719..a0f9f7db22 100644 --- a/Gems/Atom/Asset/Shader/Code/Source/Editor/AzslShaderBuilderSystemComponent.cpp +++ b/Gems/Atom/Asset/Shader/Code/Source/Editor/AzslShaderBuilderSystemComponent.cpp @@ -102,7 +102,7 @@ namespace AZ // Register Shader Resource Group Layout Builder AssetBuilderSDK::AssetBuilderDesc srgLayoutBuilderDescriptor; srgLayoutBuilderDescriptor.m_name = "Shader Resource Group Layout Builder"; - srgLayoutBuilderDescriptor.m_version = 53; // ATOM-15196 + srgLayoutBuilderDescriptor.m_version = 54; // Enable Null Rhi for AutomatedTesting srgLayoutBuilderDescriptor.m_patterns.push_back(AssetBuilderSDK::AssetBuilderPattern("*.azsl", AssetBuilderSDK::AssetBuilderPattern::PatternType::Wildcard)); srgLayoutBuilderDescriptor.m_patterns.push_back(AssetBuilderSDK::AssetBuilderPattern("*.azsli", AssetBuilderSDK::AssetBuilderPattern::PatternType::Wildcard)); @@ -118,7 +118,7 @@ namespace AZ // Register Shader Asset Builder AssetBuilderSDK::AssetBuilderDesc shaderAssetBuilderDescriptor; shaderAssetBuilderDescriptor.m_name = "Shader Asset Builder"; - shaderAssetBuilderDescriptor.m_version = 97; // ATOM-15196 + shaderAssetBuilderDescriptor.m_version = 98; // Enable Null Rhi for AutomatedTesting // .shader file changes trigger rebuilds shaderAssetBuilderDescriptor.m_patterns.push_back(AssetBuilderSDK::AssetBuilderPattern( AZStd::string::format("*.%s", RPI::ShaderSourceData::Extension), AssetBuilderSDK::AssetBuilderPattern::PatternType::Wildcard)); shaderAssetBuilderDescriptor.m_busId = azrtti_typeid(); @@ -133,7 +133,7 @@ namespace AZ shaderVariantAssetBuilderDescriptor.m_name = "Shader Variant Asset Builder"; // Both "Shader Variant Asset Builder" and "Shader Asset Builder" produce ShaderVariantAsset products. If you update // ShaderVariantAsset you will need to update BOTH version numbers, not just "Shader Variant Asset Builder". - shaderVariantAssetBuilderDescriptor.m_version = 18; // ATOM-15196 + shaderVariantAssetBuilderDescriptor.m_version = 19; // Enable Null Rhi for AutomatedTesting shaderVariantAssetBuilderDescriptor.m_patterns.push_back(AssetBuilderSDK::AssetBuilderPattern(AZStd::string::format("*.%s", RPI::ShaderVariantListSourceData::Extension), AssetBuilderSDK::AssetBuilderPattern::PatternType::Wildcard)); shaderVariantAssetBuilderDescriptor.m_busId = azrtti_typeid(); shaderVariantAssetBuilderDescriptor.m_createJobFunction = AZStd::bind(&ShaderVariantAssetBuilder::CreateJobs, &m_shaderVariantAssetBuilder, AZStd::placeholders::_1, AZStd::placeholders::_2); diff --git a/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderVariantAssetBuilder.cpp b/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderVariantAssetBuilder.cpp index 3572fb72ae..02cb8bd242 100644 --- a/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderVariantAssetBuilder.cpp +++ b/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderVariantAssetBuilder.cpp @@ -405,12 +405,20 @@ namespace AZ void ShaderVariantAssetBuilder::ProcessJob(const AssetBuilderSDK::ProcessJobRequest& request, AssetBuilderSDK::ProcessJobResponse& response) const { const auto& jobParameters = request.m_jobDescription.m_jobParameters; + if (jobParameters.find(ShaderVariantLoadErrorParam) != jobParameters.end()) { 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 overridden by game project.", jobParameters.at(ShaderVariantLoadErrorParam).c_str()); + response.m_resultCode = AssetBuilderSDK::ProcessJobResult_Success; + return; + } if (jobParameters.find(ShouldExitEarlyFromProcessJobParam) != jobParameters.end()) { diff --git a/Gems/Atom/Feature/Common/Assets/Materials/ReflectionProbe/ReflectionProbeVisualization.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/ReflectionProbe/ReflectionProbeVisualization.materialtype index e401b42644..214fc02660 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/ReflectionProbe/ReflectionProbeVisualization.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/ReflectionProbe/ReflectionProbeVisualization.materialtype @@ -401,38 +401,6 @@ "step": 0.1 } ], - "ambientOcclusion": [ - { - "id": "enable", - "displayName": "Enable", - "description": "Whether to enable the ambient occlusion feature.", - "type": "Bool", - "defaultValue": false - }, - { - "id": "factor", - "displayName": "Factor", - "description": "Strength factor for scaling the values", - "type": "Float", - "defaultValue": 1.0, - "min": 0.0, - "max": 2.0, - "connection": { - "type": "ShaderInput", - "id": "m_ambientOcclusionFactor" - } - }, - { - "id": "textureMap", - "displayName": "Texture Map", - "description": "Texture map for defining ambient occlusion area.", - "type": "Image", - "connection": { - "type": "ShaderInput", - "id": "m_ambientOcclusionMap" - } - } - ], "emissive": [ { "id": "enable", diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype index e95c82e435..cb66a987ae 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype @@ -49,9 +49,9 @@ "description": "Properties for configuring UV transforms." }, { - "id": "ambientOcclusion", - "displayName": "Ambient Occlusion", - "description": "Properties for baked AO texture." + "id": "occlusion", + "displayName": "Occlusion", + "description": "Properties for baked textures that represent geometric occlusion of light." }, { "id": "emissive", @@ -780,47 +780,89 @@ "step": 0.1 } ], - "ambientOcclusion": [ + "occlusion": [ { - "id": "enable", - "displayName": "Enable", - "description": "Whether to enable the ambient occlusion feature.", + "id": "diffuseTextureMap", + "displayName": "Diffuse AO", + "description": "Texture map for defining occlusion area for diffuse ambient lighting.", + "type": "Image", + "connection": { + "type": "ShaderInput", + "id": "m_diffuseOcclusionMap" + } + }, + { + "id": "diffuseUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Diffuse AO texture map.", "type": "Bool", - "defaultValue": false + "defaultValue": true }, { - "id": "factor", - "displayName": "Factor", - "description": "Strength factor for scaling the values", + "id": "diffuseTextureMapUv", + "displayName": " UV", + "description": "Diffuse AO texture map UV set.", + "type": "Enum", + "enumIsUv": true, + "defaultValue": "Tiled", + "connection": { + "type": "ShaderInput", + "id": "m_diffuseOcclusionMapUvIndex" + } + }, + { + "id": "diffuseFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Diffuse AO", "type": "Float", "defaultValue": 1.0, "min": 0.0, - "max": 2.0, + "softMax": 2.0, "connection": { "type": "ShaderInput", - "id": "m_ambientOcclusionFactor" + "id": "m_diffuseOcclusionFactor" } }, { - "id": "textureMap", - "displayName": "Texture Map", - "description": "Texture map for defining ambient occlusion area.", + "id": "specularTextureMap", + "displayName": "Specular Cavity", + "description": "Texture map for defining occlusion area for specular lighting.", "type": "Image", "connection": { "type": "ShaderInput", - "id": "m_ambientOcclusionMap" + "id": "m_specularOcclusionMap" } }, { - "id": "textureMapUv", - "displayName": "UV", - "description": "Ambient occlusion texture map UV set", + "id": "specularUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Specular Cavity texture map.", + "type": "Bool", + "defaultValue": true + }, + { + "id": "specularTextureMapUv", + "displayName": " UV", + "description": "Specular Cavity texture map UV set.", "type": "Enum", - "enumValues": [ "UV0", "UV1" ], - "defaultValue": "UV0", + "enumIsUv": true, + "defaultValue": "Tiled", "connection": { "type": "ShaderInput", - "id": "m_ambientOcclusionMapUvIndex" + "id": "m_specularOcclusionMapUvIndex" + } + }, + { + "id": "specularFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Specular Cavity", + "type": "Float", + "defaultValue": 1.0, + "min": 0.0, + "softMax": 2.0, + "connection": { + "type": "ShaderInput", + "id": "m_specularOcclusionFactor" } } ], @@ -1641,17 +1683,21 @@ } }, { - // See the comment above for details. "type": "UseTexture", "args": { - "textureProperty": "ambientOcclusion.textureMap", - "dependentProperties": ["ambientOcclusion.textureMapUv"], - "useTextureProperty": "ambientOcclusion.enable", - "shaderTags": [ - "ForwardPass", - "ForwardPass_EDS" - ], - "shaderOption": "o_ambientOcclusion_useTexture" + "textureProperty": "occlusion.diffuseTextureMap", + "useTextureProperty": "occlusion.diffuseUseTexture", + "dependentProperties": ["occlusion.diffuseTextureMapUv", "occlusion.diffuseFactor"], + "shaderOption": "o_diffuseOcclusion_useTexture" + } + }, + { + "type": "UseTexture", + "args": { + "textureProperty": "occlusion.specularTextureMap", + "useTextureProperty": "occlusion.specularUseTexture", + "dependentProperties": ["occlusion.specularTextureMapUv", "occlusion.specularFactor"], + "shaderOption": "o_specularOcclusion_useTexture" } }, { @@ -1712,31 +1758,6 @@ "shaderOption": "o_transmission_useTexture" } }, - { - // Controls visibility for properties in the editor. - // @param actions - a list of actions that are executed in order. visibility will be set when triggerProperty hits the triggerValue. - // @param affectedProperties - the properties that are affected by actions. - "type": "UpdatePropertyVisibility", - "args": { - "actions": [ - { - "triggerProperty": "ambientOcclusion.enable", - "triggerValue": true, - "visibility": "Enabled" - }, - { - "triggerProperty": "ambientOcclusion.enable", - "triggerValue": false, - "visibility": "Disabled" - } - ], - "affectedProperties": [ - "ambientOcclusion.factor", - "ambientOcclusion.textureMap", - "ambientOcclusion.textureMapUv" - ] - } - }, { // Controls visibility for properties in the editor. // @param actions - a list of actions that are executed in order. visibility will be set when triggerProperty hits the triggerValue. diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl index a9d6f243c1..46a96bccb1 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl @@ -213,9 +213,9 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float float3 emissive = GetEmissiveInput(MaterialSrg::m_emissiveMap, MaterialSrg::m_sampler, emissiveUv, MaterialSrg::m_emissiveIntensity, MaterialSrg::m_emissiveColor.rgb, o_emissiveEnabled, o_emissive_useTexture); // ------- Occlusion ------- - - float2 occlusionUv = IN.m_uv[MaterialSrg::m_ambientOcclusionMapUvIndex]; - float occlusion = GetOcclusionInput(MaterialSrg::m_ambientOcclusionMap, MaterialSrg::m_sampler, occlusionUv, MaterialSrg::m_ambientOcclusionFactor, o_ambientOcclusion_useTexture); + + float diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture); + float specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture); // ------- Subsurface ------- @@ -252,7 +252,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor, normal, IN.m_tangent, IN.m_bitangent, anisotropy, - emissive, occlusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode); + emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode); // ------- Opacity ------- diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/OcclusionInput.azsli b/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/OcclusionInput.azsli index 6149934ba5..103745cf56 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/OcclusionInput.azsli +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/OcclusionInput.azsli @@ -12,19 +12,23 @@ #pragma once -// This file provides utilities for common handling of inputs for ambient occlusion maps for PBR materials. +// This file provides utilities for common handling of inputs for baked occlusion maps for PBR materials. // These macros can be used to declare common shader inputs for this feature. // Use the COMMON_SRG_INPUTS_* macro in your material SRG definition, and use the COMMON_OPTIONS_* macro at the global scope in your shader. Then you can pass these variables to the Get*Input() function below. // You can optionally provide a prefix for the set of inputs which corresponds to a prefix string supplied by the .materialtype file. This is common for multi-layered material types. #define COMMON_SRG_INPUTS_OCCLUSION(prefix) \ -float prefix##m_ambientOcclusionFactor; \ -Texture2D prefix##m_ambientOcclusionMap; \ -uint prefix##m_ambientOcclusionMapUvIndex; +float prefix##m_diffuseOcclusionFactor; \ +Texture2D prefix##m_diffuseOcclusionMap; \ +uint prefix##m_diffuseOcclusionMapUvIndex; \ +float prefix##m_specularOcclusionFactor; \ +Texture2D prefix##m_specularOcclusionMap; \ +uint prefix##m_specularOcclusionMapUvIndex; #define COMMON_OPTIONS_OCCLUSION(prefix) \ -option bool prefix##o_ambientOcclusion_useTexture; +option bool prefix##o_diffuseOcclusion_useTexture; \ +option bool prefix##o_specularOcclusion_useTexture; float GetOcclusionInput(Texture2D map, sampler mapSampler, float2 uv, float factor, bool useTexture) { diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl index dc79a94007..621f588a3e 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl @@ -272,6 +272,11 @@ PbrLightingOutput SkinPS_Common(VSOutput IN) float roughness = GetRoughnessInput(MaterialSrg::m_roughnessMap, MaterialSrg::m_sampler, roughnessUv, MaterialSrg::m_roughnessFactor, MaterialSrg::m_roughnessLowerBound, MaterialSrg::m_roughnessUpperBound, o_roughness_useTexture); + // ------- Occlusion ------- + + float diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture); + float specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture); + // ------- Specular ------- float2 specularUv = IN.m_uv[MaterialSrg::m_specularF0MapUvIndex]; @@ -300,7 +305,6 @@ PbrLightingOutput SkinPS_Common(VSOutput IN) float metallic = 0; float3 emissive = float3(0,0,0); - float occlusion = 1; float2 anisotropy = float2(0,0); float clearCoatFactor = 0.0; float clearCoatRoughness = 0.0; @@ -309,7 +313,7 @@ PbrLightingOutput SkinPS_Common(VSOutput IN) PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor, normalWS, tangents[0], bitangents[0], anisotropy, - emissive, occlusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode); + emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode); // ------- Preparing output ------- diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype index 5912bc1484..4ecf9389ba 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype @@ -24,9 +24,9 @@ "description": "Properties related to configuring surface normal." }, { - "id": "ambientOcclusion", - "displayName": "Ambient Occlusion", - "description": "Properties for baked AO texture." + "id": "occlusion", + "displayName": "Occlusion", + "description": "Properties for baked textures that represent geometric occlusion of light." }, { "id": "subsurfaceScattering", @@ -383,48 +383,89 @@ } } ], - - "ambientOcclusion": [ + "occlusion": [ { - "id": "enable", - "displayName": "Enable", - "description": "Whether to enable the ambient occlusion feature.", + "id": "diffuseTextureMap", + "displayName": "Diffuse AO", + "description": "Texture map for defining occlusion area for diffuse ambient lighting.", + "type": "Image", + "connection": { + "type": "ShaderInput", + "id": "m_diffuseOcclusionMap" + } + }, + { + "id": "diffuseUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Diffuse AO texture map.", "type": "Bool", - "defaultValue": false + "defaultValue": true }, { - "id": "textureMap", - "displayName": "Texture Map", - "description": "Texture map for defining ambient occlusion area.", + "id": "diffuseTextureMapUv", + "displayName": " UV", + "description": "Diffuse AO texture map UV set.", + "type": "Enum", + "enumIsUv": true, + "defaultValue": "Tiled", + "connection": { + "type": "ShaderInput", + "id": "m_diffuseOcclusionMapUvIndex" + } + }, + { + "id": "diffuseFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Diffuse AO", + "type": "Float", + "defaultValue": 1.0, + "min": 0.0, + "softMax": 2.0, + "connection": { + "type": "ShaderInput", + "id": "m_diffuseOcclusionFactor" + } + }, + { + "id": "specularTextureMap", + "displayName": "Specular Cavity", + "description": "Texture map for defining occlusion area for specular lighting.", "type": "Image", "connection": { "type": "ShaderInput", - "id": "m_ambientOcclusionMap" + "id": "m_specularOcclusionMap" } }, { - "id": "textureMapUv", - "displayName": "UV", - "description": "Ambient occlusion texture map UV set", + "id": "specularUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Specular Cavity texture map.", + "type": "Bool", + "defaultValue": true + }, + { + "id": "specularTextureMapUv", + "displayName": " UV", + "description": "Specular Cavity texture map UV set.", "type": "Enum", "enumIsUv": true, - "defaultValue": "Unwrapped", + "defaultValue": "Tiled", "connection": { "type": "ShaderInput", - "id": "m_ambientOcclusionMapUvIndex" + "id": "m_specularOcclusionMapUvIndex" } }, { - "id": "factor", - "displayName": "Factor", - "description": "Strength factor for scaling the values", + "id": "specularFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Specular Cavity", "type": "Float", "defaultValue": 1.0, "min": 0.0, - "max": 2.0, + "softMax": 2.0, "connection": { "type": "ShaderInput", - "id": "m_ambientOcclusionFactor" + "id": "m_specularOcclusionFactor" } } ], @@ -1021,9 +1062,21 @@ } }, { - "type": "Lua", + "type": "UseTexture", + "args": { + "textureProperty": "occlusion.diffuseTextureMap", + "useTextureProperty": "occlusion.diffuseUseTexture", + "dependentProperties": ["occlusion.diffuseTextureMapUv", "occlusion.diffuseFactor"], + "shaderOption": "o_diffuseOcclusion_useTexture" + } + }, + { + "type": "UseTexture", "args": { - "file": "StandardPBR_AoState.lua" + "textureProperty": "occlusion.specularTextureMap", + "useTextureProperty": "occlusion.specularUseTexture", + "dependentProperties": ["occlusion.specularTextureMapUv", "occlusion.specularFactor"], + "shaderOption": "o_specularOcclusion_useTexture" } }, { diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype index 3b40d80b67..7610a4c9db 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype @@ -73,9 +73,9 @@ "description": "Properties for configuring gloss clear coat" }, { - "id": "layer1_ambientOcclusion", - "displayName": "Layer 1: Ambient Occlusion", - "description": "Properties for baked AO texture." + "id": "layer1_occlusion", + "displayName": "Layer 1: Occlusion", + "description": "Properties for baked textures for diffuse and specular occlusion of ambient lighting." }, { "id": "layer1_emissive", @@ -126,9 +126,9 @@ "description": "Properties for configuring gloss clear coat" }, { - "id": "layer2_ambientOcclusion", - "displayName": "Layer 2: Ambient Occlusion", - "description": "Properties for baked AO texture." + "id": "layer2_occlusion", + "displayName": "Layer 2: Occlusion", + "description": "Properties for baked textures for diffuse and specular occlusion of ambient lighting." }, { "id": "layer2_emissive", @@ -179,9 +179,9 @@ "description": "Properties for configuring gloss clear coat" }, { - "id": "layer3_ambientOcclusion", - "displayName": "Layer 3: Ambient Occlusion", - "description": "Properties for baked AO texture." + "id": "layer3_occlusion", + "displayName": "Layer 3: Occlusion", + "description": "Properties for baked textures for diffuse and specular occlusion of ambient lighting." }, { "id": "layer3_emissive", @@ -1169,47 +1169,89 @@ } } ], - "layer1_ambientOcclusion": [ + "layer1_occlusion": [ { - "id": "enable", - "displayName": "Enable", - "description": "Whether to enable the ambient occlusion feature.", + "id": "diffuseTextureMap", + "displayName": "Diffuse AO", + "description": "Texture map for defining occlusion area for diffuse ambient lighting.", + "type": "Image", + "connection": { + "type": "ShaderInput", + "id": "m_layer1_m_diffuseOcclusionMap" + } + }, + { + "id": "diffuseUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Diffuse AO texture map.", "type": "Bool", - "defaultValue": false + "defaultValue": true }, { - "id": "textureMap", - "displayName": "Texture Map", - "description": "Texture map for defining ambient occlusion area.", + "id": "diffuseTextureMapUv", + "displayName": " UV", + "description": "Diffuse AO texture map UV set.", + "type": "Enum", + "enumIsUv": true, + "defaultValue": "Tiled", + "connection": { + "type": "ShaderInput", + "id": "m_layer1_m_diffuseOcclusionMapUvIndex" + } + }, + { + "id": "diffuseFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Diffuse AO", + "type": "Float", + "defaultValue": 1.0, + "min": 0.0, + "softMax": 2.0, + "connection": { + "type": "ShaderInput", + "id": "m_layer1_m_diffuseOcclusionFactor" + } + }, + { + "id": "specularTextureMap", + "displayName": "Specular Cavity", + "description": "Texture map for defining occlusion area for specular lighting.", "type": "Image", "connection": { "type": "ShaderInput", - "id": "m_layer1_m_ambientOcclusionMap" + "id": "m_layer1_m_specularOcclusionMap" } }, { - "id": "textureMapUv", - "displayName": "UV", - "description": "Ambient occlusion texture map UV set", + "id": "specularUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Specular Cavity texture map.", + "type": "Bool", + "defaultValue": true + }, + { + "id": "specularTextureMapUv", + "displayName": " UV", + "description": "Specular Cavity texture map UV set.", "type": "Enum", "enumIsUv": true, "defaultValue": "Tiled", "connection": { "type": "ShaderInput", - "id": "m_layer1_m_ambientOcclusionMapUvIndex" + "id": "m_layer1_m_specularOcclusionMapUvIndex" } }, { - "id": "factor", - "displayName": "Factor", - "description": "Strength factor for scaling the values", + "id": "specularFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Specular Cavity", "type": "Float", "defaultValue": 1.0, "min": 0.0, - "max": 2.0, + "softMax": 2.0, "connection": { "type": "ShaderInput", - "id": "m_layer1_m_ambientOcclusionFactor" + "id": "m_layer1_m_specularOcclusionFactor" } } ], @@ -1820,47 +1862,89 @@ } } ], - "layer2_ambientOcclusion": [ + "layer2_occlusion": [ { - "id": "enable", - "displayName": "Enable", - "description": "Whether to enable the ambient occlusion feature.", + "id": "diffuseTextureMap", + "displayName": "Diffuse AO", + "description": "Texture map for defining occlusion area for diffuse ambient lighting.", + "type": "Image", + "connection": { + "type": "ShaderInput", + "id": "m_layer2_m_diffuseOcclusionMap" + } + }, + { + "id": "diffuseUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Diffuse AO texture map.", "type": "Bool", - "defaultValue": false + "defaultValue": true }, { - "id": "textureMap", - "displayName": "Texture Map", - "description": "Texture map for defining ambient occlusion area.", + "id": "diffuseTextureMapUv", + "displayName": " UV", + "description": "Diffuse AO texture map UV set.", + "type": "Enum", + "enumIsUv": true, + "defaultValue": "Tiled", + "connection": { + "type": "ShaderInput", + "id": "m_layer2_m_diffuseOcclusionMapUvIndex" + } + }, + { + "id": "diffuseFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Diffuse AO", + "type": "Float", + "defaultValue": 1.0, + "min": 0.0, + "softMax": 2.0, + "connection": { + "type": "ShaderInput", + "id": "m_layer2_m_diffuseOcclusionFactor" + } + }, + { + "id": "specularTextureMap", + "displayName": "Specular Cavity", + "description": "Texture map for defining occlusion area for specular lighting.", "type": "Image", "connection": { "type": "ShaderInput", - "id": "m_layer2_m_ambientOcclusionMap" + "id": "m_layer2_m_specularOcclusionMap" } }, { - "id": "textureMapUv", - "displayName": "UV", - "description": "Ambient occlusion texture map UV set", + "id": "specularUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Specular Cavity texture map.", + "type": "Bool", + "defaultValue": true + }, + { + "id": "specularTextureMapUv", + "displayName": " UV", + "description": "Specular Cavity texture map UV set.", "type": "Enum", "enumIsUv": true, "defaultValue": "Tiled", "connection": { "type": "ShaderInput", - "id": "m_layer2_m_ambientOcclusionMapUvIndex" + "id": "m_layer2_m_specularOcclusionMapUvIndex" } }, { - "id": "factor", - "displayName": "Factor", - "description": "Strength factor for scaling the values", + "id": "specularFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Specular Cavity", "type": "Float", "defaultValue": 1.0, "min": 0.0, - "max": 2.0, + "softMax": 2.0, "connection": { "type": "ShaderInput", - "id": "m_layer2_m_ambientOcclusionFactor" + "id": "m_layer2_m_specularOcclusionFactor" } } ], @@ -2471,47 +2555,89 @@ } } ], - "layer3_ambientOcclusion": [ + "layer3_occlusion": [ { - "id": "enable", - "displayName": "Enable", - "description": "Whether to enable the ambient occlusion feature.", + "id": "diffuseTextureMap", + "displayName": "Diffuse AO", + "description": "Texture map for defining occlusion area for diffuse ambient lighting.", + "type": "Image", + "connection": { + "type": "ShaderInput", + "id": "m_layer3_m_diffuseOcclusionMap" + } + }, + { + "id": "diffuseUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Diffuse AO texture map.", "type": "Bool", - "defaultValue": false + "defaultValue": true }, { - "id": "textureMap", - "displayName": "Texture Map", - "description": "Texture map for defining ambient occlusion area.", + "id": "diffuseTextureMapUv", + "displayName": " UV", + "description": "Diffuse AO texture map UV set.", + "type": "Enum", + "enumIsUv": true, + "defaultValue": "Tiled", + "connection": { + "type": "ShaderInput", + "id": "m_layer3_m_diffuseOcclusionMapUvIndex" + } + }, + { + "id": "diffuseFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Diffuse AO", + "type": "Float", + "defaultValue": 1.0, + "min": 0.0, + "softMax": 2.0, + "connection": { + "type": "ShaderInput", + "id": "m_layer3_m_diffuseOcclusionFactor" + } + }, + { + "id": "specularTextureMap", + "displayName": "Specular Cavity", + "description": "Texture map for defining occlusion area for specular lighting.", "type": "Image", "connection": { "type": "ShaderInput", - "id": "m_layer3_m_ambientOcclusionMap" + "id": "m_layer3_m_specularOcclusionMap" } }, { - "id": "textureMapUv", - "displayName": "UV", - "description": "Ambient occlusion texture map UV set", + "id": "specularUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Specular Cavity texture map.", + "type": "Bool", + "defaultValue": true + }, + { + "id": "specularTextureMapUv", + "displayName": " UV", + "description": "Specular Cavity texture map UV set.", "type": "Enum", "enumIsUv": true, "defaultValue": "Tiled", "connection": { "type": "ShaderInput", - "id": "m_layer3_m_ambientOcclusionMapUvIndex" + "id": "m_layer3_m_specularOcclusionMapUvIndex" } }, { - "id": "factor", - "displayName": "Factor", - "description": "Strength factor for scaling the values", + "id": "specularFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Specular Cavity", "type": "Float", "defaultValue": 1.0, "min": 0.0, - "max": 2.0, + "softMax": 2.0, "connection": { "type": "ShaderInput", - "id": "m_layer3_m_ambientOcclusionFactor" + "id": "m_layer3_m_specularOcclusionFactor" } } ], @@ -2894,12 +3020,21 @@ } }, { - "type": "Lua", + "type": "UseTexture", "args": { - "file": "StandardPBR_AoState.lua", - "propertyNamePrefix": "layer1_", - "srgNamePrefix": "m_layer1_", - "optionsNamePrefix": "o_layer1_" + "textureProperty": "layer1_occlusion.diffuseTextureMap", + "useTextureProperty": "layer1_occlusion.diffuseUseTexture", + "dependentProperties": ["layer1_occlusion.diffuseTextureMapUv", "layer1_occlusion.diffuseFactor"], + "shaderOption": "o_layer1_o_diffuseOcclusion_useTexture" + } + }, + { + "type": "UseTexture", + "args": { + "textureProperty": "layer1_occlusion.specularTextureMap", + "useTextureProperty": "layer1_occlusion.specularUseTexture", + "dependentProperties": ["layer1_occlusion.specularTextureMapUv", "layer1_occlusion.specularFactor"], + "shaderOption": "o_layer1_o_specularOcclusion_useTexture" } }, { @@ -3022,12 +3157,21 @@ } }, { - "type": "Lua", + "type": "UseTexture", "args": { - "file": "StandardPBR_AoState.lua", - "propertyNamePrefix": "layer2_", - "srgNamePrefix": "m_layer2_", - "optionsNamePrefix": "o_layer2_" + "textureProperty": "layer2_occlusion.diffuseTextureMap", + "useTextureProperty": "layer2_occlusion.diffuseUseTexture", + "dependentProperties": ["layer2_occlusion.diffuseTextureMapUv", "layer2_occlusion.diffuseFactor"], + "shaderOption": "o_layer2_o_diffuseOcclusion_useTexture" + } + }, + { + "type": "UseTexture", + "args": { + "textureProperty": "layer2_occlusion.specularTextureMap", + "useTextureProperty": "layer2_occlusion.specularUseTexture", + "dependentProperties": ["layer2_occlusion.specularTextureMapUv", "layer2_occlusion.specularFactor"], + "shaderOption": "o_layer2_o_specularOcclusion_useTexture" } }, { @@ -3150,12 +3294,21 @@ } }, { - "type": "Lua", + "type": "UseTexture", "args": { - "file": "StandardPBR_AoState.lua", - "propertyNamePrefix": "layer3_", - "srgNamePrefix": "m_layer3_", - "optionsNamePrefix": "o_layer3_" + "textureProperty": "layer3_occlusion.diffuseTextureMap", + "useTextureProperty": "layer3_occlusion.diffuseUseTexture", + "dependentProperties": ["layer3_occlusion.diffuseTextureMapUv", "layer3_occlusion.diffuseFactor"], + "shaderOption": "o_layer3_o_diffuseOcclusion_useTexture" + } + }, + { + "type": "UseTexture", + "args": { + "textureProperty": "layer3_occlusion.specularTextureMap", + "useTextureProperty": "layer3_occlusion.specularUseTexture", + "dependentProperties": ["layer3_occlusion.specularTextureMapUv", "layer3_occlusion.specularFactor"], + "shaderOption": "o_layer3_o_specularOcclusion_useTexture" } }, { diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl index 9e5c29ba34..7669ebb064 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl @@ -268,10 +268,15 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float // ------- Occlusion ------- - float layer1_occlusion = GetOcclusionInput(MaterialSrg::m_layer1_m_ambientOcclusionMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_ambientOcclusionMapUvIndex], MaterialSrg::m_layer1_m_ambientOcclusionFactor, o_layer1_o_ambientOcclusion_useTexture); - float layer2_occlusion = GetOcclusionInput(MaterialSrg::m_layer2_m_ambientOcclusionMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_ambientOcclusionMapUvIndex], MaterialSrg::m_layer2_m_ambientOcclusionFactor, o_layer2_o_ambientOcclusion_useTexture); - float layer3_occlusion = GetOcclusionInput(MaterialSrg::m_layer3_m_ambientOcclusionMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_ambientOcclusionMapUvIndex], MaterialSrg::m_layer3_m_ambientOcclusionFactor, o_layer3_o_ambientOcclusion_useTexture); - float occlusion = BlendLayers(layer1_occlusion, layer2_occlusion, layer3_occlusion, blendMaskValues); + float layer1_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer1_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer1_m_diffuseOcclusionFactor, o_layer1_o_diffuseOcclusion_useTexture); + float layer2_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer2_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer2_m_diffuseOcclusionFactor, o_layer2_o_diffuseOcclusion_useTexture); + float layer3_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer3_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer3_m_diffuseOcclusionFactor, o_layer3_o_diffuseOcclusion_useTexture); + float diffuseAmbientOcclusion = BlendLayers(layer1_diffuseAmbientOcclusion, layer2_diffuseAmbientOcclusion, layer3_diffuseAmbientOcclusion, blendMaskValues); + + float layer1_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer1_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer1_m_specularOcclusionFactor, o_layer1_o_specularOcclusion_useTexture); + float layer2_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer2_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer2_m_specularOcclusionFactor, o_layer2_o_specularOcclusion_useTexture); + float layer3_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer3_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer3_m_specularOcclusionFactor, o_layer3_o_specularOcclusion_useTexture); + float specularOcclusion = BlendLayers(layer1_specularOcclusion, layer2_specularOcclusion, layer3_specularOcclusion, blendMaskValues); // ------- Subsurface ------- @@ -350,7 +355,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor, normalWS, tangents[0], bitangents[0], anisotropy, - emissive, occlusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode); + emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode); // ------- Opacity ------- diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype index 9750d09538..e071a793a5 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype @@ -44,9 +44,9 @@ "description": "Properties for configuring UV transforms." }, { - "id": "ambientOcclusion", - "displayName": "Ambient Occlusion", - "description": "Properties for baked AO texture." + "id": "occlusion", + "displayName": "Occlusion", + "description": "Properties for baked textures that represent geometric occlusion of light." }, { "id": "emissive", @@ -724,47 +724,89 @@ "step": 0.1 } ], - "ambientOcclusion": [ + "occlusion": [ { - "id": "enable", - "displayName": "Enable", - "description": "Whether to enable the ambient occlusion feature.", + "id": "diffuseTextureMap", + "displayName": "Diffuse AO", + "description": "Texture map for defining occlusion area for diffuse ambient lighting.", + "type": "Image", + "connection": { + "type": "ShaderInput", + "id": "m_diffuseOcclusionMap" + } + }, + { + "id": "diffuseUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Diffuse AO texture map.", "type": "Bool", - "defaultValue": false + "defaultValue": true }, { - "id": "textureMap", - "displayName": "Texture Map", - "description": "Texture map for defining ambient occlusion area.", + "id": "diffuseTextureMapUv", + "displayName": " UV", + "description": "Diffuse AO texture map UV set.", + "type": "Enum", + "enumIsUv": true, + "defaultValue": "Tiled", + "connection": { + "type": "ShaderInput", + "id": "m_diffuseOcclusionMapUvIndex" + } + }, + { + "id": "diffuseFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Diffuse AO", + "type": "Float", + "defaultValue": 1.0, + "min": 0.0, + "softMax": 2.0, + "connection": { + "type": "ShaderInput", + "id": "m_diffuseOcclusionFactor" + } + }, + { + "id": "specularTextureMap", + "displayName": "Specular Cavity", + "description": "Texture map for defining occlusion area for specular lighting.", "type": "Image", "connection": { "type": "ShaderInput", - "id": "m_ambientOcclusionMap" + "id": "m_specularOcclusionMap" } }, { - "id": "textureMapUv", - "displayName": "UV", - "description": "Ambient occlusion texture map UV set", + "id": "specularUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Specular Cavity texture map.", + "type": "Bool", + "defaultValue": true + }, + { + "id": "specularTextureMapUv", + "displayName": " UV", + "description": "Specular Cavity texture map UV set.", "type": "Enum", "enumIsUv": true, "defaultValue": "Tiled", "connection": { "type": "ShaderInput", - "id": "m_ambientOcclusionMapUvIndex" + "id": "m_specularOcclusionMapUvIndex" } }, { - "id": "factor", - "displayName": "Factor", - "description": "Strength factor for scaling the values", + "id": "specularFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Specular Cavity", "type": "Float", "defaultValue": 1.0, "min": 0.0, - "max": 2.0, + "softMax": 2.0, "connection": { "type": "ShaderInput", - "id": "m_ambientOcclusionFactor" + "id": "m_specularOcclusionFactor" } } ], @@ -1270,9 +1312,21 @@ } }, { - "type": "Lua", + "type": "UseTexture", + "args": { + "textureProperty": "occlusion.diffuseTextureMap", + "useTextureProperty": "occlusion.diffuseUseTexture", + "dependentProperties": ["occlusion.diffuseTextureMapUv", "occlusion.diffuseFactor"], + "shaderOption": "o_diffuseOcclusion_useTexture" + } + }, + { + "type": "UseTexture", "args": { - "file": "StandardPBR_AoState.lua" + "textureProperty": "occlusion.specularTextureMap", + "useTextureProperty": "occlusion.specularUseTexture", + "dependentProperties": ["occlusion.specularTextureMapUv", "occlusion.specularFactor"], + "shaderOption": "o_specularOcclusion_useTexture" } }, { diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_AoState.lua b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_AoState.lua deleted file mode 100644 index a27817d925..0000000000 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_AoState.lua +++ /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. --- --- ----------------------------------------------------------------------------------------------------- - -function GetMaterialPropertyDependencies() - return {"ambientOcclusion.enable", "ambientOcclusion.textureMap"} -end - -function GetShaderOptionDependencies() - return {"o_ambientOcclusion_useTexture"} -end - -function Process(context) - local enableAo = context:GetMaterialPropertyValue_bool("ambientOcclusion.enable") - local textureMap = context:GetMaterialPropertyValue_image("ambientOcclusion.textureMap") - - context:SetShaderOptionValue_bool("o_ambientOcclusion_useTexture", enableAo and textureMap ~= nil) -end - -function ProcessEditor(context) - local enableAo = context:GetMaterialPropertyValue_bool("ambientOcclusion.enable") - - if(not enableAo) then - context:SetMaterialPropertyVisibility("ambientOcclusion.factor", MaterialPropertyVisibility_Hidden) - context:SetMaterialPropertyVisibility("ambientOcclusion.textureMap", MaterialPropertyVisibility_Hidden) - context:SetMaterialPropertyVisibility("ambientOcclusion.textureMapUv", MaterialPropertyVisibility_Hidden) - else - context:SetMaterialPropertyVisibility("ambientOcclusion.textureMap", MaterialPropertyVisibility_Enabled) - local textureMap = context:GetMaterialPropertyValue_image("ambientOcclusion.textureMap") - if(textureMap == nil) then - context:SetMaterialPropertyVisibility("ambientOcclusion.factor", MaterialPropertyVisibility_Hidden) - context:SetMaterialPropertyVisibility("ambientOcclusion.textureMapUv", MaterialPropertyVisibility_Hidden) - else - context:SetMaterialPropertyVisibility("ambientOcclusion.factor", MaterialPropertyVisibility_Enabled) - context:SetMaterialPropertyVisibility("ambientOcclusion.textureMapUv", MaterialPropertyVisibility_Enabled) - end - end -end diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl index 999db3c5da..c08dc53c6a 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl @@ -212,9 +212,9 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float lightingData.emissiveLighting = GetEmissiveInput(MaterialSrg::m_emissiveMap, MaterialSrg::m_sampler, emissiveUv, MaterialSrg::m_emissiveIntensity, MaterialSrg::m_emissiveColor.rgb, o_emissiveEnabled, o_emissive_useTexture); // ------- Occlusion ------- - - float2 occlusionUv = IN.m_uv[MaterialSrg::m_ambientOcclusionMapUvIndex]; - lightingData.occlusion = GetOcclusionInput(MaterialSrg::m_ambientOcclusionMap, MaterialSrg::m_sampler, occlusionUv, MaterialSrg::m_ambientOcclusionFactor, o_ambientOcclusion_useTexture); + + lightingData.diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture); + lightingData.specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture); // ------- Clearcoat ------- diff --git a/Gems/Atom/Feature/Common/Assets/Passes/OpaqueParent.pass b/Gems/Atom/Feature/Common/Assets/Passes/OpaqueParent.pass index 8131bbdf5d..bd15bdde9f 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/OpaqueParent.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/OpaqueParent.pass @@ -180,6 +180,13 @@ "Attachment": "SpecularF0Output" } }, + { + "LocalSlot": "AlbedoInput", + "AttachmentRef": { + "Pass": "ForwardMSAAPass", + "Attachment": "AlbedoOutput" + } + }, { "LocalSlot": "ClearCoatNormalInput", "AttachmentRef": { diff --git a/Gems/Atom/Feature/Common/Assets/Passes/ReflectionGlobalFullscreen.pass b/Gems/Atom/Feature/Common/Assets/Passes/ReflectionGlobalFullscreen.pass index d77ba74cf9..1b763f86c2 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/ReflectionGlobalFullscreen.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/ReflectionGlobalFullscreen.pass @@ -27,6 +27,12 @@ "SlotType": "Input", "ScopeAttachmentUsage": "Shader" }, + { + // This is needed for the alpha channel which has specularOcclusion factor + "Name": "AlbedoInput", + "SlotType": "Input", + "ScopeAttachmentUsage": "Shader" + }, { "Name": "ClearCoatNormalInput", "SlotType": "Input", diff --git a/Gems/Atom/Feature/Common/Assets/Passes/Reflections.pass b/Gems/Atom/Feature/Common/Assets/Passes/Reflections.pass index 083c6bd16f..97881d3d71 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/Reflections.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/Reflections.pass @@ -17,6 +17,11 @@ "SlotType": "Input", "ScopeAttachmentUsage": "Shader" }, + { + "Name": "AlbedoInput", + "SlotType": "Input", + "ScopeAttachmentUsage": "Shader" + }, { "Name": "ClearCoatNormalInput", "SlotType": "Input", @@ -127,6 +132,13 @@ "Attachment": "SpecularF0Input" } }, + { + "LocalSlot": "AlbedoInput", + "AttachmentRef": { + "Pass": "Parent", + "Attachment": "AlbedoInput" + } + }, { "LocalSlot": "ClearCoatNormalInput", "AttachmentRef": { diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/ForwardPassOutput.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/ForwardPassOutput.azsli index 4185b08571..f0a43d6b1d 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/ForwardPassOutput.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/ForwardPassOutput.azsli @@ -12,19 +12,19 @@ struct ForwardPassOutput { - // m_diffuseColor.a should be encoded with subsurface scattering's strength factor and quality factor if enabled - float4 m_diffuseColor : SV_Target0; - float4 m_specularColor : SV_Target1; - float4 m_albedo : SV_Target2; - float4 m_specularF0 : SV_Target3; - float4 m_normal : SV_Target4; - float4 m_clearCoatNormal : SV_Target5; + float4 m_diffuseColor : SV_Target0; //!< RGB = Diffuse Lighting, A = Blend Alpha (for blended surfaces) OR A = special encoding of surfaceScatteringFactor, m_subsurfaceScatteringQuality, o_enableSubsurfaceScattering + float4 m_specularColor : SV_Target1; //!< RGB = Specular Lighting, A = Unused + float4 m_albedo : SV_Target2; //!< RGB = Surface albedo pre-multiplied by other factors that will be multiplied later by diffuse GI, A = specularOcclusion + float4 m_specularF0 : SV_Target3; //!< RGB = Specular F0, A = roughness + float4 m_normal : SV_Target4; //!< RGB10 = EncodeNormalSignedOctahedron(worldNormal), A2 = multiScatterCompensationEnabled + float4 m_clearCoatNormal : SV_Target5; //!< RG = EncodeNormalSphereMap(clearCoatNormal), B = clearCoatFactor, A = clearCoatRoughness float3 m_scatterDistance : SV_Target6; }; struct ForwardPassOutputWithDepth { - // m_diffuseColor.a should be encoded with subsurface scattering's strength factor and quality factor if enabled + // See above for descriptions of special encodings + float4 m_diffuseColor : SV_Target0; float4 m_specularColor : SV_Target1; float4 m_albedo : SV_Target2; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli index aa5fa05bcf..37cae0acb1 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli @@ -47,8 +47,10 @@ class LightingData // Normal . View float NdotV; + // Occlusion factors // 0 = dark, 1 = light - float occlusion; + float diffuseAmbientOcclusion; + float specularOcclusion; void Init(float3 positionWS, float3 normal, float roughnessLinear); void CalculateMultiscatterCompensation(float3 specularF0, bool enabled); @@ -62,7 +64,8 @@ void LightingData::Init(float3 positionWS, float3 normal, float roughnessLinear) translucentBackLighting = 0; multiScatterCompensation = 1.0f; emissiveLighting = float3(0.0f, 0.0f, 0.0f); - occlusion = 1.0f; + diffuseAmbientOcclusion = 1.0f; + specularOcclusion = 1.0f; dirToCamera = normalize(ViewSrg::m_worldPosition.xyz - positionWS); @@ -79,6 +82,7 @@ void LightingData::CalculateMultiscatterCompensation(float3 specularF0, bool ena void LightingData::FinalizeLighting(float3 transmissionTint) { + specularLighting *= specularOcclusion; specularLighting += emissiveLighting; // Transmitted light diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/StandardLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/StandardLighting.azsli index 31fbbd2138..d0fb78a6d5 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/StandardLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/StandardLighting.azsli @@ -45,8 +45,8 @@ PbrLightingOutput GetPbrLightingOutput(Surface surface, LightingData lightingDat // albedo, specularF0, roughness, and normals for later passes (specular IBL, Diffuse GI, SSR, AO, etc) lightingOutput.m_specularF0 = float4(surface.specularF0, surface.roughnessLinear); - lightingOutput.m_albedo.rgb = surface.albedo * lightingData.diffuseResponse; - lightingOutput.m_albedo.a = lightingData.occlusion; + lightingOutput.m_albedo.rgb = surface.albedo * lightingData.diffuseResponse * lightingData.diffuseAmbientOcclusion; + lightingOutput.m_albedo.a = lightingData.specularOcclusion; lightingOutput.m_normal.rgb = EncodeNormalSignedOctahedron(surface.normal); lightingOutput.m_normal.a = o_specularF0_enableMultiScatterCompensation ? 1.0f : 0.0f; @@ -58,6 +58,3 @@ PbrLightingOutput GetPbrLightingOutput(Surface surface, LightingData lightingDat - - - diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingModel.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingModel.azsli index 581ca2f172..a3a9c9ffd1 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingModel.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingModel.azsli @@ -66,7 +66,8 @@ PbrLightingOutput PbrLighting( VSOutput IN, float3 vtxBitangent, float2 anisotropy, // angle and factor float3 emissive, - float occlusion, + float diffuseAmbientOcclusion, + float specularOcclusion, float4 transmissionTintThickness, float4 transmissionParams, float clearCoatFactor, @@ -108,7 +109,8 @@ PbrLightingOutput PbrLighting( VSOutput IN, lightingData.Init(surface.position, surface.normal, surface.roughnessLinear); lightingData.emissiveLighting = emissive; - lightingData.occlusion = occlusion; + lightingData.diffuseAmbientOcclusion = diffuseAmbientOcclusion; + lightingData.specularOcclusion = specularOcclusion; // Directional light shadow coordinates lightingData.shadowCoords = shadowCoords; @@ -191,7 +193,7 @@ PbrLightingOutput MakeDebugOutput(VSOutput IN, float3 debugColor, float3 normalW PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor, normal, IN.m_tangent, IN.m_bitangent, anisotropy, - emissive, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque); + emissive, occlusion, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque); return lightingOutput; } diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/Ibl.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/Ibl.azsli index f08acd2684..bbb6a33b55 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/Ibl.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/Ibl.azsli @@ -76,7 +76,7 @@ void ApplyIBL(Surface surface, inout LightingData lightingData) // Adjust IBL lighting by exposure. float iblExposureFactor = pow(2.0, SceneSrg::m_iblExposure); - lightingData.diffuseLighting += (iblDiffuse * iblExposureFactor * lightingData.occlusion); + lightingData.diffuseLighting += (iblDiffuse * iblExposureFactor * lightingData.diffuseAmbientOcclusion); lightingData.specularLighting += (iblSpecular * iblExposureFactor); } } diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseComposite.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseComposite.azsl index 9b4e703f89..b3b26c4d42 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseComposite.azsl +++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseComposite.azsl @@ -24,7 +24,7 @@ ShaderResourceGroup PassSrg : SRG_PerPass Texture2DMS m_downsampledProbeIrradiance; Texture2DMS m_downsampledDepth; Texture2DMS m_downsampledNormal; - Texture2DMS m_albedo; // RGB8 = Albedo, A = Occlusion + Texture2DMS m_albedo; // RGB8 = Albedo with pre-multiplied factors, A = Unused here Texture2DMS m_normal; // RGB10 = Normal (Encoded), A2 = Flags Texture2DMS m_depth; @@ -118,7 +118,7 @@ float3 SampleProbeIrradiance(uint sampleIndex, uint2 probeIrradianceCoords, floa } // retrieve irradiance from the global IBL diffuse cubemap -float3 SampleGlobalIBL(uint sampleIndex, uint2 screenCoords, float depth, float3 normal, float3 albedo) +float3 SampleGlobalIBL(uint sampleIndex, uint2 screenCoords, float depth, float3 normal) { uint2 dimensions; uint samples; @@ -160,23 +160,19 @@ PSOutput MainPS(VSOutput IN, in uint sampleIndex : SV_SampleIndex) float4 encodedNormal = PassSrg::m_normal.Load(screenCoords, sampleIndex); float3 normal = DecodeNormalSignedOctahedron(encodedNormal.rgb); float4 albedo = PassSrg::m_albedo.Load(screenCoords, sampleIndex); - float occlusion = albedo.a; float useProbeIrradiance = PassSrg::m_downsampledProbeIrradiance.Load(probeIrradianceCoords, sampleIndex).a; float3 diffuse = float3(0.0f, 0.0f, 0.0f); if (useProbeIrradiance > 0.0f) { float3 irradiance = SampleProbeIrradiance(sampleIndex, probeIrradianceCoords, depth, normal, albedo, ImageScale); - diffuse = (albedo.rgb / PI) * irradiance * occlusion; + diffuse = (albedo.rgb / PI) * irradiance; } else { - float3 irradiance = SampleGlobalIBL(sampleIndex, screenCoords, depth, normal, albedo); + float3 irradiance = SampleGlobalIBL(sampleIndex, screenCoords, depth, normal); diffuse = albedo * irradiance; - // apply ambient occlusion to indirect diffuse - diffuse *= occlusion; - // adjust IBL lighting by exposure. float iblExposureFactor = pow(2.0, SceneSrg::m_iblExposure); diffuse *= iblExposureFactor; diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseComposite_nomsaa.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseComposite_nomsaa.azsl index 74571b5c6a..a5d761d815 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseComposite_nomsaa.azsl +++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseComposite_nomsaa.azsl @@ -27,7 +27,7 @@ ShaderResourceGroup PassSrg : SRG_PerPass Texture2D m_downsampledProbeIrradiance; Texture2D m_downsampledDepth; Texture2D m_downsampledNormal; - Texture2D m_albedo; // RGB8 = Albedo, A = Occlusion + Texture2D m_albedo; // RGB8 = Albedo with pre-multiplied factors, A = Unused here Texture2D m_normal; // RGB10 = Normal (Encoded), A2 = Flags Texture2D m_depth; @@ -121,7 +121,7 @@ float3 SampleProbeIrradiance(uint2 probeIrradianceCoords, float depth, float3 no } // retrieve irradiance from the global IBL diffuse cubemap -float3 SampleGlobalIBL(uint2 screenCoords, float depth, float3 normal, float3 albedo) +float3 SampleGlobalIBL(uint2 screenCoords, float depth, float3 normal) { uint2 dimensions; PassSrg::m_depth.GetDimensions(dimensions.x, dimensions.y); @@ -162,23 +162,19 @@ PSOutput MainPS(VSOutput IN) float4 encodedNormal = PassSrg::m_normal.Load(int3(screenCoords, 0)); float3 normal = DecodeNormalSignedOctahedron(encodedNormal.rgb); float4 albedo = PassSrg::m_albedo.Load(int3(screenCoords, 0)); - float occlusion = albedo.a; float useProbeIrradiance = PassSrg::m_downsampledProbeIrradiance.Load(int3(probeIrradianceCoords,0)).a; float3 diffuse = float3(0.0f, 0.0f, 0.0f); if (useProbeIrradiance > 0.0f) { float3 irradiance = SampleProbeIrradiance(probeIrradianceCoords, depth, normal, albedo, ImageScale); - diffuse = (albedo.rgb / PI) * irradiance * occlusion; + diffuse = (albedo.rgb / PI) * irradiance; } else { - float3 irradiance = SampleGlobalIBL(screenCoords, depth, normal, albedo); + float3 irradiance = SampleGlobalIBL(screenCoords, depth, normal); diffuse = albedo * irradiance; - // apply ambient occlusion to indirect diffuse - diffuse *= occlusion; - // adjust IBL lighting by exposure. float iblExposureFactor = pow(2.0, SceneSrg::m_iblExposure); diffuse *= iblExposureFactor; diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseGlobalFullscreen.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseGlobalFullscreen.azsl index d6a0de8159..dbc134d2ff 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseGlobalFullscreen.azsl +++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseGlobalFullscreen.azsl @@ -21,7 +21,7 @@ ShaderResourceGroup PassSrg : SRG_PerPass { - Texture2DMS m_albedo; // RGB8 = Albedo, A = Occlusion + Texture2DMS m_albedo; // RGB8 = Albedo with pre-multiplied factors, A = Unused here Texture2DMS m_normal; // RGB10 = Normal (Encoded), A2 = Flags Texture2DMS m_depth; } @@ -41,7 +41,7 @@ VSOutput MainVS(VSInput input) } // retrieve irradiance from the global IBL diffuse cubemap -float3 SampleGlobalIBL(uint sampleIndex, uint2 screenCoords, float depth, float3 normal, float3 albedo) +float3 SampleGlobalIBL(uint sampleIndex, uint2 screenCoords, float depth, float3 normal) { uint2 dimensions; uint samples; @@ -76,14 +76,10 @@ PSOutput MainPS(VSOutput IN, in uint sampleIndex : SV_SampleIndex) float4 encodedNormal = PassSrg::m_normal.Load(screenCoords, sampleIndex); float3 normal = DecodeNormalSignedOctahedron(encodedNormal.rgb); float4 albedo = PassSrg::m_albedo.Load(screenCoords, sampleIndex); - float occlusion = albedo.a; - float3 irradiance = SampleGlobalIBL(sampleIndex, screenCoords, depth, normal, albedo); + float3 irradiance = SampleGlobalIBL(sampleIndex, screenCoords, depth, normal); float3 diffuse = albedo * irradiance; - // apply ambient occlusion to indirect diffuse - diffuse *= occlusion; - // adjust IBL lighting by exposure. float iblExposureFactor = pow(2.0, SceneSrg::m_iblExposure); diffuse *= iblExposureFactor; diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseGlobalFullscreen_nomsaa.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseGlobalFullscreen_nomsaa.azsl index fe3523210a..803046efd4 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseGlobalFullscreen_nomsaa.azsl +++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseGlobalFullscreen_nomsaa.azsl @@ -24,7 +24,7 @@ ShaderResourceGroup PassSrg : SRG_PerPass { - Texture2D m_albedo; // RGB8 = Albedo, A = Occlusion + Texture2D m_albedo; // RGB8 = Albedo with pre-multiplied factors, A = Unused here Texture2D m_normal; // RGB10 = Normal (Encoded), A2 = Flags Texture2D m_depth; } @@ -44,7 +44,7 @@ VSOutput MainVS(VSInput input) } // retrieve irradiance from the global IBL diffuse cubemap -float3 SampleGlobalIBL(uint sampleIndex, uint2 screenCoords, float depth, float3 normal, float3 albedo) +float3 SampleGlobalIBL(uint sampleIndex, uint2 screenCoords, float depth, float3 normal) { uint2 dimensions; PassSrg::m_depth.GetDimensions(dimensions.x, dimensions.y); @@ -78,14 +78,10 @@ PSOutput MainPS(VSOutput IN, in uint sampleIndex : SV_SampleIndex) float4 encodedNormal = PassSrg::m_normal.Load(int3(screenCoords, 0)); float3 normal = DecodeNormalSignedOctahedron(encodedNormal.rgb); float4 albedo = PassSrg::m_albedo.Load(int3(screenCoords, 0)); - float occlusion = albedo.a; - float3 irradiance = SampleGlobalIBL(sampleIndex, screenCoords, depth, normal, albedo); + float3 irradiance = SampleGlobalIBL(sampleIndex, screenCoords, depth, normal); float3 diffuse = albedo * irradiance; - // apply ambient occlusion to indirect diffuse - diffuse *= occlusion; - // adjust IBL lighting by exposure. float iblExposureFactor = pow(2.0, SceneSrg::m_iblExposure); diffuse *= iblExposureFactor; diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/Reflections/ReflectionGlobalFullscreen.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/Reflections/ReflectionGlobalFullscreen.azsl index 6e41e5123c..c7837f4130 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/Reflections/ReflectionGlobalFullscreen.azsl +++ b/Gems/Atom/Feature/Common/Assets/Shaders/Reflections/ReflectionGlobalFullscreen.azsl @@ -43,8 +43,9 @@ ShaderResourceGroup PassSrg : SRG_PerPass { Texture2DMS m_depth; - Texture2DMS m_normal; // RGB10 = Normal (Encoded), A2 = Flags + Texture2DMS m_normal; // RGB10 = EncodeNormalSignedOctahedron(worldNormal), A2 = multiScatterCompensationEnabled Texture2DMS m_specularF0; // RGB8 = SpecularF0, A8 = Roughness + Texture2DMS m_albedo; // RGB = Not used here, A = specularOcclusion Texture2DMS m_clearCoatNormal; // R16G16 = Normal (Packed), B16A16 = (factor, perceptual roughness) Texture2DMS m_blendWeight; Texture2D m_brdfMap; @@ -80,6 +81,9 @@ PSOutput MainPS(VSOutput IN, in uint sampleIndex : SV_SampleIndex) float4 encodedNormal = PassSrg::m_normal.Load(IN.m_position.xy, sampleIndex); float3 normal = DecodeNormalSignedOctahedron(encodedNormal.rgb); bool multiScatterCompensationEnabled = (encodedNormal.a > 0.0f); + + float4 albedo = PassSrg::m_albedo.Load(IN.m_position.xy, sampleIndex); + float specularOcclusion = albedo.a; // reconstruct world space position from the depth at this location in screenspace float3 positionWS = ReconstructWorldPositionFromDepth(IN.m_position.xy, sampleIndex).xyz; @@ -136,6 +140,9 @@ PSOutput MainPS(VSOutput IN, in uint sampleIndex : SV_SampleIndex) // apply exposure setting specular *= pow(2.0, SceneSrg::m_iblExposure); + // maybe attenuate the specular + specular *= specularOcclusion; + PSOutput OUT; OUT.m_color = float4(specular, 1.0f); return OUT; diff --git a/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake b/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake index 1b8c0e0987..fd199d59f1 100644 --- a/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake +++ b/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake @@ -41,7 +41,6 @@ set(FILES Materials/Types/StandardMultilayerPBR_Shadowmap_WithPS.azsl Materials/Types/StandardMultilayerPBR_Shadowmap_WithPS.shader Materials/Types/StandardPBR.materialtype - Materials/Types/StandardPBR_AoState.lua Materials/Types/StandardPBR_ClearCoatEnableFeature.lua Materials/Types/StandardPBR_ClearCoatState.lua Materials/Types/StandardPBR_Common.azsli diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h index 7ad8bd8283..eb49859141 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h @@ -145,8 +145,10 @@ namespace AZ const MaterialAssignmentMap& GetMaterialAssignmentMap(const MeshHandle& meshHandle) const override; void ConnectModelChangeEventHandler(const MeshHandle& meshHandle, ModelChangedEvent::Handler& handler) override; - void SetTransform(const MeshHandle& meshHandle, const AZ::Transform& transform) override; + void SetTransform(const MeshHandle& meshHandle, const AZ::Transform& transform, + const AZ::Vector3& nonUniformScale = AZ::Vector3::CreateOne()) override; Transform GetTransform(const MeshHandle& meshHandle) override; + Vector3 GetNonUniformScale(const MeshHandle& meshHandle) override; void SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey) override; RHI::DrawItemSortKey GetSortKey(const MeshHandle& meshHandle) override; diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h index 77e3467fb9..05f2a408b8 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h @@ -62,9 +62,12 @@ namespace AZ //! Connects a handler to any changes to an RPI::Model. Changes include loading and reloading. virtual void ConnectModelChangeEventHandler(const MeshHandle& meshHandle, ModelChangedEvent::Handler& handler) = 0; //! Sets the transform for a given mesh handle. - virtual void SetTransform(const MeshHandle& meshHandle, const AZ::Transform& transform) = 0; + virtual void SetTransform(const MeshHandle& meshHandle, const Transform& transform, + const Vector3& nonUniformScale = Vector3::CreateOne()) = 0; //! Gets the transform for a given mesh handle. virtual Transform GetTransform(const MeshHandle& meshHandle) = 0; + //! Gets the non-uniform scale for a given mesh handle. + virtual Vector3 GetNonUniformScale(const MeshHandle& meshHandle) = 0; //! Sets the sort key for a given mesh handle. virtual void SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey) = 0; //! Gets the sort key for a given mesh handle. diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessor.h index 2344f745f8..ddec9a6a1d 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessor.h @@ -50,8 +50,10 @@ namespace AZ // TransformServiceFeatureProcessorInterface overrides ... ObjectId ReserveObjectId() override; void ReleaseObjectId(ObjectId& id) override; - void SetTransformForId(ObjectId id, const AZ::Transform& transform) override; + void SetTransformForId(ObjectId id, const AZ::Transform& transform, + const AZ::Vector3& nonUniformScale = AZ::Vector3::CreateOne()) override; AZ::Transform GetTransformForId(ObjectId id) const override; + AZ::Vector3 GetNonUniformScaleForId(ObjectId id) const override; private: diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessorInterface.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessorInterface.h index 0b17a9a5a0..bb3606b12b 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessorInterface.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessorInterface.h @@ -13,6 +13,7 @@ #pragma once #include +#include #include namespace AZ @@ -34,11 +35,13 @@ namespace AZ //! Releases an object ID to be used by others. The passed in handle is invalidated. virtual void ReleaseObjectId(ObjectId& id) = 0; - //! Sets the transform for a given id. Id must be one reserved earlier. - virtual void SetTransformForId(ObjectId id, const AZ::Transform& transform) = 0; + //! Sets the transform (and optionally non-uniform scale) for a given id. Id must be one reserved earlier. + virtual void SetTransformForId(ObjectId id, const AZ::Transform& transform, + const AZ::Vector3& nonUniformScale = AZ::Vector3::CreateOne()) = 0; //! Gets the transform for a given id. Id must be one reserved earlier. virtual AZ::Transform GetTransformForId(ObjectId) const = 0; - + //! Gets the non-uniform scale for a given id. Id must be one reserved earlier. + virtual AZ::Vector3 GetNonUniformScaleForId(ObjectId id) const = 0; }; } } diff --git a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h index 6fc1ac0e30..a1a7e94cb0 100644 --- a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h @@ -31,11 +31,12 @@ namespace UnitTest MOCK_CONST_METHOD1(GetModel, AZStd::intrusive_ptr(const MeshHandle&)); MOCK_CONST_METHOD1(GetMaterialAssignmentMap, const AZ::Render::MaterialAssignmentMap&(const MeshHandle&)); MOCK_METHOD2(ConnectModelChangeEventHandler, void(const MeshHandle&, ModelChangedEvent::Handler&)); - MOCK_METHOD2(SetTransform, void(const MeshHandle&, const AZ::Transform&)); + MOCK_METHOD3(SetTransform, void(const MeshHandle&, const AZ::Transform&, const AZ::Vector3&)); MOCK_METHOD2(SetExcludeFromReflectionCubeMaps, void(const MeshHandle&, bool)); MOCK_METHOD2(SetMaterialAssignmentMap, void(const MeshHandle&, const AZ::Data::Instance&)); MOCK_METHOD2(SetMaterialAssignmentMap, void(const MeshHandle&, const AZ::Render::MaterialAssignmentMap&)); - MOCK_METHOD1(GetTransform, AZ::Transform (const MeshHandle&)); + MOCK_METHOD1(GetTransform, AZ::Transform(const MeshHandle&)); + MOCK_METHOD1(GetNonUniformScale, AZ::Vector3(const MeshHandle&)); MOCK_METHOD2(SetSortKey, void (const MeshHandle&, AZ::RHI::DrawItemSortKey)); MOCK_METHOD1(GetSortKey, AZ::RHI::DrawItemSortKey(const MeshHandle&)); MOCK_METHOD2(SetLodOverride, void(const MeshHandle&, AZ::RPI::Cullable::LodOverride)); diff --git a/Gems/Atom/Feature/Common/Code/Source/AuxGeom/AuxGeomDrawQueue.cpp b/Gems/Atom/Feature/Common/Code/Source/AuxGeom/AuxGeomDrawQueue.cpp index dc53498c8b..7845c8f402 100644 --- a/Gems/Atom/Feature/Common/Code/Source/AuxGeom/AuxGeomDrawQueue.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/AuxGeom/AuxGeomDrawQueue.cpp @@ -504,7 +504,7 @@ namespace AZ box.m_faceCullMode = ConvertRPIFaceCullFlag(faceCull); box.m_color = color; box.m_scale = localMatrix3x4.ExtractScale() * extents; - box.m_position = localMatrix3x4.GetTranslation() + center; + box.m_position = matrix3x4 * center; box.m_rotationMatrix = Matrix3x3::CreateFromMatrix3x4(localMatrix3x4); box.m_pointSize = m_pointSize; box.m_viewProjOverrideIndex = viewProjOverrideIndex; diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp index f44a56233e..04175c461f 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp @@ -1238,6 +1238,8 @@ namespace AZ void DirectionalLightFeatureProcessor::SetFilterParameterToPass(LightHandle handle, const RPI::View* cameraView) { + AZ_ATOM_PROFILE_FUNCTION("DirectionalLightFeatureProcessor", "DirectionalLightFeatureProcessor::SetFilterParameterToPass"); + if (handle != m_shadowingLightHandle) { return; diff --git a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp index 5f39c6bc38..37f9360f5d 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp @@ -256,7 +256,7 @@ namespace AZ } } - void MeshFeatureProcessor::SetTransform(const MeshHandle& meshHandle, const AZ::Transform& transform) + void MeshFeatureProcessor::SetTransform(const MeshHandle& meshHandle, const AZ::Transform& transform, const AZ::Vector3& nonUniformScale) { if (meshHandle.IsValid()) { @@ -264,12 +264,12 @@ namespace AZ meshData.m_cullBoundsNeedsUpdate = true; meshData.m_objectSrgNeedsUpdate = true; - m_transformService->SetTransformForId(meshHandle->m_objectId, transform); + m_transformService->SetTransformForId(meshHandle->m_objectId, transform, nonUniformScale); // ray tracing data needs to be updated with the new transform if (m_rayTracingFeatureProcessor) { - m_rayTracingFeatureProcessor->SetMeshTransform(meshHandle->m_objectId, transform); + m_rayTracingFeatureProcessor->SetMeshTransform(meshHandle->m_objectId, transform, nonUniformScale); } } } @@ -287,6 +287,19 @@ namespace AZ } } + Vector3 MeshFeatureProcessor::GetNonUniformScale(const MeshHandle& meshHandle) + { + if (meshHandle.IsValid()) + { + return m_transformService->GetNonUniformScaleForId(meshHandle->m_objectId); + } + else + { + AZ_Assert(false, "Invalid mesh handle"); + return Vector3::CreateOne(); + } + } + void MeshFeatureProcessor::SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey) { if (meshHandle.IsValid()) @@ -845,10 +858,13 @@ namespace AZ AZ_Assert(m_model, "The model has not finished loading yet"); Transform localToWorld = transformService->GetTransformForId(m_objectId); + Vector3 nonUniformScale = transformService->GetNonUniformScaleForId(m_objectId); Vector3 center; float radius; Aabb localAabb = m_model->GetAabb(); + localAabb.MultiplyByScale(nonUniformScale); + localAabb.GetTransformedAabb(localToWorld).GetAsSphere(center, radius); m_cullable.m_cullData.m_boundingSphere = Sphere(center, radius); diff --git a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp index 4aff31c552..2bb2fa2ac2 100644 --- a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp @@ -81,6 +81,7 @@ namespace AZ ->HitGroupIndex(blasIndex) ->Blas(rayTracingSubMesh.m_blas) ->Transform(rayTracingMesh.second.m_transform) + ->NonUniformScale(rayTracingMesh.second.m_nonUniformScale) ; } diff --git a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp index bb8f7ff54d..337d111130 100644 --- a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp @@ -143,7 +143,7 @@ namespace AZ m_meshInfoBufferNeedsUpdate = true; } - void RayTracingFeatureProcessor::SetMeshTransform(const ObjectId objectId, AZ::Transform transform) + void RayTracingFeatureProcessor::SetMeshTransform(const ObjectId objectId, const AZ::Transform transform, const AZ::Vector3 nonUniformScale) { if (!m_rayTracingEnabled) { @@ -154,6 +154,7 @@ namespace AZ if (itMesh != m_meshes.end()) { itMesh->second.m_transform = transform; + itMesh->second.m_nonUniformScale = nonUniformScale; m_revision++; } diff --git a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.h index 9dee35716b..f317f1c096 100644 --- a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.h @@ -68,6 +68,9 @@ namespace AZ // mesh transform AZ::Transform m_transform = AZ::Transform::CreateIdentity(); + // mesh non-uniform scale + AZ::Vector3 m_nonUniformScale = AZ::Vector3::CreateOne(); + // flag indicating if the Blas objects in the sub-meshes are built bool m_blasBuilt = false; }; @@ -85,7 +88,8 @@ namespace AZ //! Sets the ray tracing mesh transform //! This will cause an update to the RayTracing acceleration structure on the next frame - void SetMeshTransform(const ObjectId objectId, const AZ::Transform transform); + void SetMeshTransform(const ObjectId objectId, const AZ::Transform transform, + const AZ::Vector3 nonUniformScale = AZ::Vector3::CreateOne()); //! Retrieves ray tracing data for all meshes in the scene const MeshMap& GetMeshes() const { return m_meshes; } diff --git a/Gems/Atom/Feature/Common/Code/Source/TransformService/TransformServiceFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/TransformService/TransformServiceFeatureProcessor.cpp index a4f255185a..acb6e4a287 100644 --- a/Gems/Atom/Feature/Common/Code/Source/TransformService/TransformServiceFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/TransformService/TransformServiceFeatureProcessor.cpp @@ -210,14 +210,14 @@ namespace AZ } } - void TransformServiceFeatureProcessor::SetTransformForId(ObjectId id, const AZ::Transform& transform) + void TransformServiceFeatureProcessor::SetTransformForId(ObjectId id, const AZ::Transform& transform, const AZ::Vector3& nonUniformScale) { AZ_Error("TransformServiceFeatureProcessor", m_isWriteable, "Transform data cannot be written to during this phase"); AZ_Error("TransformServiceFeatureProcessor", id.IsValid(), "Attempting to set the transform for an invalid handle."); if (id.IsValid()) { AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromTransform(transform); - + matrix3x4.MultiplyByScale(nonUniformScale); matrix3x4.StoreToRowMajorFloat12(m_objectToWorldTransforms.at(id.GetIndex()).m_transform); // Inverse transpose to take the non-uniform scale out of the transform for usage with normals. @@ -228,8 +228,18 @@ namespace AZ AZ::Transform TransformServiceFeatureProcessor::GetTransformForId(ObjectId id) const { - AZ_Error("TransformServiceFeatureProcessor", id.IsValid(), "Attempting to set the transform for an invalid handle."); - return AZ::Transform::CreateFromMatrix3x4( Matrix3x4::CreateFromRowMajorFloat12(m_objectToWorldTransforms.at(id.GetIndex()).m_transform) ); + AZ_Error("TransformServiceFeatureProcessor", id.IsValid(), "Attempting to get the transform for an invalid handle."); + AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromRowMajorFloat12(m_objectToWorldTransforms.at(id.GetIndex()).m_transform); + AZ::Transform transform = AZ::Transform::CreateFromMatrix3x4(matrix3x4); + transform.ExtractScale(); + return transform; + } + + AZ::Vector3 TransformServiceFeatureProcessor::GetNonUniformScaleForId(ObjectId id) const + { + AZ_Error("TransformServiceFeatureProcessor", id.IsValid(), "Attempting to get the non-uniform scale for an invalid handle."); + AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromRowMajorFloat12(m_objectToWorldTransforms.at(id.GetIndex()).m_transform); + return matrix3x4.RetrieveScale(); } } } diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingAccelerationStructure.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingAccelerationStructure.h index 09ba2b1d59..5fde518cb2 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingAccelerationStructure.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingAccelerationStructure.h @@ -111,6 +111,7 @@ namespace AZ uint32_t m_instanceID = 0; uint32_t m_hitGroupIndex = 0; AZ::Transform m_transform = AZ::Transform::CreateIdentity(); + AZ::Vector3 m_nonUniformScale = AZ::Vector3::CreateOne(); RHI::Ptr m_blas; }; using RayTracingTlasInstanceVector = AZStd::vector; @@ -154,6 +155,7 @@ namespace AZ RayTracingTlasDescriptor* InstanceID(uint32_t instanceID); RayTracingTlasDescriptor* HitGroupIndex(uint32_t hitGroupIndex); RayTracingTlasDescriptor* Transform(const AZ::Transform& transform); + RayTracingTlasDescriptor* NonUniformScale(const AZ::Vector3& nonUniformScale); RayTracingTlasDescriptor* Blas(RHI::Ptr& blas); RayTracingTlasDescriptor* InstancesBuffer(RHI::Ptr& tlasInstances); RayTracingTlasDescriptor* NumInstances(uint32_t numInstancesInBuffer); diff --git a/Gems/Atom/RHI/Code/Source/RHI/RayTracingAccelerationStructure.cpp b/Gems/Atom/RHI/Code/Source/RHI/RayTracingAccelerationStructure.cpp index 37e5b316d6..4349761eb5 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/RayTracingAccelerationStructure.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/RayTracingAccelerationStructure.cpp @@ -85,6 +85,13 @@ namespace AZ return this; } + RayTracingTlasDescriptor* RayTracingTlasDescriptor::NonUniformScale(const AZ::Vector3& nonUniformScale) + { + AZ_Assert(m_buildContext, "NonUniformSCale property can only be added to an Instance entry"); + m_buildContext->m_nonUniformScale = nonUniformScale; + return this; + } + RayTracingTlasDescriptor* RayTracingTlasDescriptor::Blas(RHI::Ptr& blas) { AZ_Assert(m_buildContext, "Blas property can only be added to an Instance entry"); diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingTlas.cpp b/Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingTlas.cpp index 77d8d38e42..1342db5690 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingTlas.cpp +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingTlas.cpp @@ -89,8 +89,9 @@ namespace AZ mappedData[i].InstanceID = instance.m_instanceID; mappedData[i].InstanceContributionToHitGroupIndex = instance.m_hitGroupIndex; // convert transform to row-major 3x4 - AZ::Matrix3x4 matrix34 = AZ::Matrix3x4::CreateFromTransform(instance.m_transform); - matrix34.StoreToRowMajorFloat12(&mappedData[i].Transform[0][0]); + AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromTransform(instance.m_transform); + matrix3x4.MultiplyByScale(instance.m_nonUniformScale); + matrix3x4.StoreToRowMajorFloat12(&mappedData[i].Transform[0][0]); mappedData[i].AccelerationStructure = static_cast(blas->GetBuffers().m_blasBuffer.get())->GetMemoryView().GetGpuAddress(); // [GFX TODO][ATOM-5270] Add ray tracing TLAS instance mask support mappedData[i].InstanceMask = 0x1; diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingTlas.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingTlas.cpp index 9720fecb6d..a1346612c9 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingTlas.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingTlas.cpp @@ -92,9 +92,9 @@ namespace AZ mappedData[i].instanceCustomIndex = instance.m_instanceID; mappedData[i].instanceShaderBindingTableRecordOffset = instance.m_hitGroupIndex; - // convert transform to row-major 3x4 - AZ::Matrix3x4 matrix34 = AZ::Matrix3x4::CreateFromTransform(instance.m_transform); - matrix34.StoreToRowMajorFloat12(&mappedData[i].transform.matrix[0][0]); + AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromTransform(instance.m_transform); + matrix3x4.MultiplyByScale(instance.m_nonUniformScale); + matrix3x4.StoreToRowMajorFloat12(&mappedData[i].transform.matrix[0][0]); RayTracingBlas* blas = static_cast(instance.m_blas.get()); VkAccelerationStructureDeviceAddressInfoKHR addressInfo = {}; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Model/Model.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Model/Model.h index 48c33fb0d6..35af200759 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Model/Model.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Model/Model.h @@ -73,12 +73,14 @@ namespace AZ //! [GFX TODO][ATOM-4343 Bake mesh spatial during AP processing] //! //! @param modelTransform a transform that puts the model into the ray's coordinate space + //! @param nonUniformScale Non-uniform scale applied in the model's local frame. //! @param rayStart position where the ray starts //! @param dir direction where the ray ends (does not have to be unit length) //! @param distanceFactor if an intersection is detected, this will be set such that distanceFactor * dir.length == distance to intersection //! @param normal if an intersection is detected, this will be set to the normal at the point of intersection //! @return true if the ray intersects the mesh - bool RayIntersection(const AZ::Transform& modelTransform, const AZ::Vector3& rayStart, const AZ::Vector3& dir, float& distanceFactor, AZ::Vector3& normal) const; + bool RayIntersection(const AZ::Transform& modelTransform, const AZ::Vector3& nonUniformScale, const AZ::Vector3& rayStart, + const AZ::Vector3& dir, float& distanceFactor, AZ::Vector3& normal) const; //! Get available UV names from the model and its lods. const AZStd::unordered_set& GetUvNames() const; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp index 8b49448fb1..15c8aaf528 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp @@ -164,18 +164,22 @@ namespace AZ return false; } - bool Model::RayIntersection(const AZ::Transform& modelTransform, const AZ::Vector3& rayStart, const AZ::Vector3& dir, float& distanceFactor, AZ::Vector3& normal) const + bool Model::RayIntersection(const AZ::Transform& modelTransform, const AZ::Vector3& nonUniformScale, const AZ::Vector3& rayStart, const AZ::Vector3& dir, float& distanceFactor, AZ::Vector3& normal) const { AZ_PROFILE_FUNCTION(Debug::ProfileCategory::AzRender); + const AZ::Vector3 clampedScale = nonUniformScale.GetMax(AZ::Vector3(AZ::MinTransformScale)); + const AZ::Transform inverseTM = modelTransform.GetInverse(); - const AZ::Vector3 raySrcLocal = inverseTM.TransformPoint(rayStart); + const AZ::Vector3 raySrcLocal = inverseTM.TransformPoint(rayStart) / clampedScale; // Instead of just rotating 'dir' we need it to be scaled too, so that 'distanceFactor' will be in the target units rather than object local units. const AZ::Vector3 rayDest = rayStart + dir; - const AZ::Vector3 rayDestLocal = inverseTM.TransformPoint(rayDest); + const AZ::Vector3 rayDestLocal = inverseTM.TransformPoint(rayDest) / clampedScale; const AZ::Vector3 rayDirLocal = rayDestLocal - raySrcLocal; - return LocalRayIntersection(raySrcLocal, rayDirLocal, distanceFactor, normal); + bool result = LocalRayIntersection(raySrcLocal, rayDirLocal, distanceFactor, normal); + normal = (normal * clampedScale).GetNormalized(); + return result; } const AZStd::unordered_set& Model::GetUvNames() const diff --git a/Gems/Atom/TestData/TestData/Materials/ParallaxRock.material b/Gems/Atom/TestData/TestData/Materials/ParallaxRock.material index 4c91053515..f639534bfb 100644 --- a/Gems/Atom/TestData/TestData/Materials/ParallaxRock.material +++ b/Gems/Atom/TestData/TestData/Materials/ParallaxRock.material @@ -4,9 +4,8 @@ "parentMaterial": "Materials/Presets/PBR/default_grid.material", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "TestData/Textures/cc0/Rock030_2K_AmbientOcclusion.jpg" + "occlusion": { + "diffuseTextureMap": "TestData/Textures/cc0/Rock030_2K_AmbientOcclusion.jpg" }, "baseColor": { "textureMap": "TestData/Textures/cc0/Rock030_2K_Color.jpg" diff --git a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material index e84c6296be..8f916ec490 100644 --- a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material +++ b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material @@ -4,11 +4,6 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "layer1_ambientOcclusion": { - "enable": true, - "factor": 1.6399999856948853, - "textureMap": "TestData/Textures/cc0/bark1_disp.jpg" - }, "layer1_baseColor": { "color": [ 0.3495536744594574, @@ -32,6 +27,10 @@ "flipY": true, "textureMap": "TestData/Textures/cc0/bark1_norm.jpg" }, + "layer1_occlusion": { + "diffuseFactor": 1.6399999856948853, + "diffuseTextureMap": "TestData/Textures/cc0/bark1_disp.jpg" + }, "layer1_parallax": { "enable": true, "factor": 0.02500000037252903, @@ -53,10 +52,6 @@ "offsetU": 0.5, "offsetV": 0.25 }, - "layer2_ambientOcclusion": { - "factor": 1.2200000286102296, - "textureMap": "TestData/Textures/cc0/bark1_disp.jpg" - }, "layer2_baseColor": { "textureMap": "TestData/Textures/cc0/Lava004_1K_Color.jpg" }, @@ -76,6 +71,10 @@ "flipY": true, "textureMap": "TestData/Textures/cc0/Lava004_1K_Normal.jpg" }, + "layer2_occlusion": { + "specularFactor": 2.0, + "specularTextureMap": "TestData/Textures/cc0/Tiles009_1K_Displacement.jpg" + }, "layer2_parallax": { "enable": true, "factor": 0.01600000075995922, @@ -88,11 +87,6 @@ "offsetU": 0.5, "offsetV": 0.25 }, - "layer3_ambientOcclusion": { - "enable": true, - "factor": 1.0399999618530274, - "textureMap": "TestData/Textures/cc0/PaintedMetal003_1K_Displacement.jpg" - }, "layer3_baseColor": { "color": [ 0.6315556764602661, @@ -115,6 +109,10 @@ "layer3_normal": { "textureMap": "TestData/Textures/cc0/PaintedMetal003_1K_Normal.jpg" }, + "layer3_occlusion": { + "diffuseFactor": 1.0399999618530274, + "diffuseTextureMap": "TestData/Textures/cc0/PaintedMetal003_1K_Displacement.jpg" + }, "layer3_parallax": { "enable": true, "factor": 0.004999999888241291, diff --git a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_AmbientOcclusion.material b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_AmbientOcclusion.material index 66843b3a2c..efc375dc81 100644 --- a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_AmbientOcclusion.material +++ b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_AmbientOcclusion.material @@ -1,15 +1,12 @@ { "description": "", - "materialType": "Materials\\Types\\StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", + "parentMaterial": "010_OcclusionBase.material", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "factor": 1.25, - "textureMap": "TestData/Textures/TextureHaven/4k_castle_brick_02_red/4k_castle_brick_02_red_ao.png" - }, - "baseColor": { - "textureMap": "TestData/Textures/TextureHaven/4k_castle_brick_02_red/4k_castle_brick_02_red_bc.png" + "occlusion": { + "diffuseFactor": 2.0, + "diffuseTextureMap": "TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg" } } } \ No newline at end of file diff --git a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_BothOcclusion.material b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_BothOcclusion.material new file mode 100644 index 0000000000..cee64dd107 --- /dev/null +++ b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_BothOcclusion.material @@ -0,0 +1,14 @@ +{ + "description": "", + "materialType": "Materials/Types/StandardPBR.materialtype", + "parentMaterial": "010_OcclusionBase.material", + "propertyLayoutVersion": 3, + "properties": { + "occlusion": { + "diffuseFactor": 2.0, + "diffuseTextureMap": "TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg", + "specularFactor": 2.0, + "specularTextureMap": "TestData/Textures/cc0/Tiles009_1K_Displacement.jpg" + } + } +} \ No newline at end of file diff --git a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_OcclusionBase.material b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_OcclusionBase.material new file mode 100644 index 0000000000..9a41a7d191 --- /dev/null +++ b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_OcclusionBase.material @@ -0,0 +1,25 @@ +{ + "description": "", + "materialType": "Materials/Types/StandardPBR.materialtype", + "parentMaterial": "", + "propertyLayoutVersion": 3, + "properties": { + "baseColor": { + "color": [ + 0.06784161180257797, + 0.2073090672492981, + 0.29570457339286806, + 1.0 + ] + }, + "clearCoat": { + "enable": true + }, + "normal": { + "textureMap": "TestData/Textures/cc0/Tiles009_1K_Normal.jpg" + }, + "roughness": { + "factor": 0.0 + } + } +} \ No newline at end of file diff --git a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_SpecularOcclusion.material b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_SpecularOcclusion.material new file mode 100644 index 0000000000..703088d6f8 --- /dev/null +++ b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_SpecularOcclusion.material @@ -0,0 +1,12 @@ +{ + "description": "", + "materialType": "Materials/Types/StandardPBR.materialtype", + "parentMaterial": "010_OcclusionBase.material", + "propertyLayoutVersion": 3, + "properties": { + "occlusion": { + "specularFactor": 2.0, + "specularTextureMap": "TestData/Textures/cc0/Tiles009_1K_Displacement.jpg" + } + } +} \ No newline at end of file diff --git a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/100_UvTiling_AmbientOcclusion.material b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/100_UvTiling_AmbientOcclusion.material index 9eec81823d..e0e4019b8c 100644 --- a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/100_UvTiling_AmbientOcclusion.material +++ b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/100_UvTiling_AmbientOcclusion.material @@ -4,9 +4,8 @@ "parentMaterial": "TestData\\Materials\\StandardPbrTestCases\\UvTilingBase.material", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "TestData/Objects/cube/cube_diff.tif" + "occlusion": { + "diffuseTextureMap": "TestData/Objects/cube/cube_diff.tif" } } } \ No newline at end of file diff --git a/Gems/Atom/TestData/TestData/Materials/Types/AutoBrick_ForwardPass.azsl b/Gems/Atom/TestData/TestData/Materials/Types/AutoBrick_ForwardPass.azsl index f484006fe1..22c96d4737 100644 --- a/Gems/Atom/TestData/TestData/Materials/Types/AutoBrick_ForwardPass.azsl +++ b/Gems/Atom/TestData/TestData/Materials/Types/AutoBrick_ForwardPass.azsl @@ -164,7 +164,8 @@ ForwardPassOutput AutoBrick_ForwardPassPS(VSOutput IN) GetSurfaceShape(IN.m_uv, surfaceDepth, surfaceNormal); const float3 normal = TangentSpaceToWorld(surfaceNormal, normalize(IN.m_normal), normalize(IN.m_tangent), normalize(IN.m_bitangent)); - const float occlusion = 1.0f - surfaceDepth * AutoBrickSrg::m_aoFactor; + const float diffuseAmbientOcclusion = 1.0f - surfaceDepth * AutoBrickSrg::m_aoFactor; + const float specularOcclusion = 1; const float metallic = 0; const float roughness = 1; const float specularF0Factor = 0.5; @@ -179,7 +180,7 @@ ForwardPassOutput AutoBrick_ForwardPassPS(VSOutput IN) PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor, normal, IN.m_tangent, IN.m_bitangent, anisotropy, - emissive, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque); + emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque); OUT.m_diffuseColor = lightingOutput.m_diffuseColor; OUT.m_diffuseColor.w = -1; // Subsurface scattering is disabled diff --git a/Gems/Atom/TestData/TestData/Materials/Types/MinimalPBR_ForwardPass.azsl b/Gems/Atom/TestData/TestData/Materials/Types/MinimalPBR_ForwardPass.azsl index 64903eb1db..206479ee7e 100644 --- a/Gems/Atom/TestData/TestData/Materials/Types/MinimalPBR_ForwardPass.azsl +++ b/Gems/Atom/TestData/TestData/Materials/Types/MinimalPBR_ForwardPass.azsl @@ -77,7 +77,7 @@ ForwardPassOutput MinimalPBR_MainPassPS(VSOutput IN) PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor, normal, IN.m_tangent, IN.m_bitangent, anisotropy, - emissive, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque); + emissive, occlusion, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque); OUT.m_diffuseColor = lightingOutput.m_diffuseColor; OUT.m_diffuseColor.w = -1; // Subsurface scattering is disabled diff --git a/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg b/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg new file mode 100644 index 0000000000..3494ef8a6c --- /dev/null +++ b/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:de6b49c1c4965896a190ed5f40c7d91f9deb942d859fd96264828df768098a83 +size 45257 diff --git a/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Color.jpg b/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Color.jpg new file mode 100644 index 0000000000..bf62c26631 --- /dev/null +++ b/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Color.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0172df6b91bb42bf6c41d18a6fdb7088397663d71f0c2d3ee504a4e91a7e5e98 +size 426462 diff --git a/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Displacement.jpg b/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Displacement.jpg new file mode 100644 index 0000000000..49efd77e18 --- /dev/null +++ b/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Displacement.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9de0bb2f58936658e8bd3599e487cbd6af3394c772d3132cd77a73774cfb5994 +size 230692 diff --git a/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Normal.jpg b/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Normal.jpg new file mode 100644 index 0000000000..c61e7f316b --- /dev/null +++ b/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Normal.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:48a8690b74141da4e7e06cd10b47f0eb787b5333a915cd1e048ab24bec485ad0 +size 759052 diff --git a/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Roughness.jpg b/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Roughness.jpg new file mode 100644 index 0000000000..bef45f0995 --- /dev/null +++ b/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Roughness.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ddd79ef9962100cd5a9eec686bdcfb98db19ab410329e50df53d6781f9d8b441 +size 421004 diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Debug/TraceRecorder.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Debug/TraceRecorder.h new file mode 100644 index 0000000000..a4dba9229e --- /dev/null +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Debug/TraceRecorder.h @@ -0,0 +1,46 @@ +/* + * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or + * its licensors. + * + * For complete copyright and license terms please see the LICENSE at the root of this + * distribution (the "License"). All use of this software is governed by the License, + * or, if provided, by the license below or the license accompanying this file. Do not + * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + */ + +#pragma once + +#include +#include +#include + +namespace AtomToolsFramework +{ + // Records all TraceMessageBus activity to a string + class TraceRecorder : private AZ::Debug::TraceMessageBus::Handler + { + public: + AZ_TYPE_INFO(AtomToolsFramework::TraceRecorder, "{7B49AFD0-D0AB-4CB7-A4B5-6D88D30DCBFD}"); + + TraceRecorder(size_t maxMessageCount = std::numeric_limits::max()); + ~TraceRecorder(); + + //! Get the combined output of all messages + AZStd::string GetDump() const; + + private: + ////////////////////////////////////////////////////////////////////////// + // AZ::Debug::TraceMessageBus::Handler overrides... + bool OnAssert(const char* /*message*/) override; + bool OnException(const char* /*message*/) override; + bool OnError(const char* /*window*/, const char* /*message*/) override; + bool OnWarning(const char* /*window*/, const char* /*message*/) override; + bool OnPrintf(const char* /*window*/, const char* /*message*/) override; + ////////////////////////////////////////////////////////////////////////// + + size_t m_maxMessageCount = std::numeric_limits::max(); + AZStd::list m_messages; + }; +} // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Debug/TraceRecorder.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Debug/TraceRecorder.cpp new file mode 100644 index 0000000000..e08dd3e48a --- /dev/null +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Debug/TraceRecorder.cpp @@ -0,0 +1,81 @@ +/* + * 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 + +namespace AtomToolsFramework +{ + TraceRecorder::TraceRecorder(size_t maxMessageCount) + : m_maxMessageCount(maxMessageCount) + { + AZ::Debug::TraceMessageBus::Handler::BusConnect(); + } + + TraceRecorder::~TraceRecorder() + { + AZ::Debug::TraceMessageBus::Handler::BusDisconnect(); + } + + AZStd::string TraceRecorder::GetDump() const + { + AZStd::string dump; + AZ::StringFunc::Join(dump, m_messages.begin(), m_messages.end(), "\n"); + return dump; + } + + bool TraceRecorder::OnAssert(const char* message) + { + if (m_messages.size() < m_maxMessageCount) + { + m_messages.push_back(AZStd::string::format("Assert: %s", message)); + } + return false; + } + + bool TraceRecorder::OnException(const char* message) + { + if (m_messages.size() < m_maxMessageCount) + { + m_messages.push_back(AZStd::string::format("Exception: %s", message)); + } + return false; + } + + bool TraceRecorder::OnError(const char* /*window*/, const char* message) + { + if (m_messages.size() < m_maxMessageCount) + { + m_messages.push_back(AZStd::string::format("Error: %s", message)); + } + return false; + } + + bool TraceRecorder::OnWarning(const char* /*window*/, const char* message) + { + if (m_messages.size() < m_maxMessageCount) + { + m_messages.push_back(AZStd::string::format("Warning: %s", message)); + } + return false; + } + + bool TraceRecorder::OnPrintf(const char* /*window*/, const char* message) + { + if (m_messages.size() < m_maxMessageCount) + { + m_messages.push_back(AZStd::string::format("%s", message)); + } + return false; + } + +} // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/atomtoolsframework_files.cmake b/Gems/Atom/Tools/AtomToolsFramework/Code/atomtoolsframework_files.cmake index 8c0ca71b78..e8539711f7 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/atomtoolsframework_files.cmake +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/atomtoolsframework_files.cmake @@ -10,6 +10,7 @@ # set(FILES + Include/AtomToolsFramework/Debug/TraceRecorder.h Include/AtomToolsFramework/DynamicProperty/DynamicProperty.h Include/AtomToolsFramework/DynamicProperty/DynamicPropertyGroup.h Include/AtomToolsFramework/Inspector/InspectorWidget.h @@ -21,6 +22,7 @@ set(FILES Include/AtomToolsFramework/Util/MaterialPropertyUtil.h Include/AtomToolsFramework/Util/Util.h Include/AtomToolsFramework/Viewport/RenderViewportWidget.h + Source/Debug/TraceRecorder.cpp Source/DynamicProperty/DynamicProperty.cpp Source/DynamicProperty/DynamicPropertyGroup.cpp Source/Inspector/InspectorWidget.cpp diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocumentSystemComponent.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocumentSystemComponent.cpp index 234afc6e27..2fd1aac211 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocumentSystemComponent.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocumentSystemComponent.cpp @@ -12,32 +12,29 @@ #include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include - +#include +#include #include - +#include +#include +#include #include #include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT #include +#include +#include #include #include -#include -#include AZ_POP_DISABLE_WARNING namespace MaterialEditor @@ -212,11 +209,15 @@ namespace MaterialEditor QString("Would you like to reopen the document:\n%1?").arg(documentPath.c_str()), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { + AtomToolsFramework::TraceRecorder traceRecorder(m_maxMessageBoxLineCount); + bool openResult = false; MaterialDocumentRequestBus::EventResult(openResult, documentId, &MaterialDocumentRequestBus::Events::Open, documentPath); if (!openResult) { - QMessageBox::critical(QApplication::activeWindow(), "Error", QString("Material document could not be opened:\n%1").arg(documentPath.c_str())); + QMessageBox::critical( + QApplication::activeWindow(), QString("Material document could not be opened"), + QString("Failed to open: \n%1\n\n%2").arg(documentPath.c_str()).arg(traceRecorder.GetDump().c_str())); MaterialDocumentSystemRequestBus::Broadcast(&MaterialDocumentSystemRequestBus::Events::CloseDocument, documentId); } } @@ -232,11 +233,15 @@ namespace MaterialEditor QString("Would you like to update the document with these changes:\n%1?").arg(documentPath.c_str()), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { + AtomToolsFramework::TraceRecorder traceRecorder(m_maxMessageBoxLineCount); + bool openResult = false; MaterialDocumentRequestBus::EventResult(openResult, documentId, &MaterialDocumentRequestBus::Events::Rebuild); if (!openResult) { - QMessageBox::critical(QApplication::activeWindow(), "Error", QString("Material document could not be opened:\n%1").arg(documentPath.c_str())); + QMessageBox::critical( + QApplication::activeWindow(), QString("Material document could not be opened"), + QString("Failed to open: \n%1\n\n%2").arg(documentPath.c_str()).arg(traceRecorder.GetDump().c_str())); MaterialDocumentSystemRequestBus::Broadcast(&MaterialDocumentSystemRequestBus::Events::CloseDocument, documentId); } } @@ -308,11 +313,15 @@ namespace MaterialEditor } } + AtomToolsFramework::TraceRecorder traceRecorder(m_maxMessageBoxLineCount); + bool closeResult = true; MaterialDocumentRequestBus::EventResult(closeResult, documentId, &MaterialDocumentRequestBus::Events::Close); if (!closeResult) { - QMessageBox::critical(QApplication::activeWindow(), "Error", QString("Material document could not be closed:\n%1").arg(documentPath.c_str())); + QMessageBox::critical( + QApplication::activeWindow(), QString("Material document could not be closed"), + QString("Failed to close: \n%1\n\n%2").arg(documentPath.c_str()).arg(traceRecorder.GetDump().c_str())); return false; } @@ -370,11 +379,15 @@ namespace MaterialEditor return false; } + AtomToolsFramework::TraceRecorder traceRecorder(m_maxMessageBoxLineCount); + bool result = false; MaterialDocumentRequestBus::EventResult(result, documentId, &MaterialDocumentRequestBus::Events::Save); if (!result) { - QMessageBox::critical(QApplication::activeWindow(), "Error", QString("Material document could not be saved:\n%1").arg(saveMaterialPath.c_str())); + QMessageBox::critical( + QApplication::activeWindow(), QString("Material document could not be saved"), + QString("Failed to save: \n%1\n\n%2").arg(saveMaterialPath.c_str()).arg(traceRecorder.GetDump().c_str())); return false; } @@ -396,11 +409,15 @@ namespace MaterialEditor return false; } + AtomToolsFramework::TraceRecorder traceRecorder(m_maxMessageBoxLineCount); + bool result = false; MaterialDocumentRequestBus::EventResult(result, documentId, &MaterialDocumentRequestBus::Events::SaveAsCopy, saveMaterialPath); if (!result) { - QMessageBox::critical(QApplication::activeWindow(), "Error", QString("Material document could not be saved:\n%1").arg(saveMaterialPath.c_str())); + QMessageBox::critical( + QApplication::activeWindow(), QString("Material document could not be saved"), + QString("Failed to save: \n%1\n\n%2").arg(saveMaterialPath.c_str()).arg(traceRecorder.GetDump().c_str())); return false; } @@ -422,11 +439,15 @@ namespace MaterialEditor return false; } + AtomToolsFramework::TraceRecorder traceRecorder(m_maxMessageBoxLineCount); + bool result = false; MaterialDocumentRequestBus::EventResult(result, documentId, &MaterialDocumentRequestBus::Events::SaveAsChild, saveMaterialPath); if (!result) { - QMessageBox::critical(QApplication::activeWindow(), "Error", QString("Material document could not be saved:\n%1").arg(saveMaterialPath.c_str())); + QMessageBox::critical( + QApplication::activeWindow(), QString("Material document could not be saved"), + QString("Failed to save: \n%1\n\n%2").arg(saveMaterialPath.c_str()).arg(traceRecorder.GetDump().c_str())); return false; } @@ -476,19 +497,27 @@ namespace MaterialEditor } } + AtomToolsFramework::TraceRecorder traceRecorder(m_maxMessageBoxLineCount); + AZ::Uuid documentId = AZ::Uuid::CreateNull(); MaterialDocumentSystemRequestBus::BroadcastResult(documentId, &MaterialDocumentSystemRequestBus::Events::CreateDocument); if (documentId.IsNull()) { - QMessageBox::critical(QApplication::activeWindow(), "Error", QString("Material document could not be created:\n%1").arg(requestedPath.c_str())); + QMessageBox::critical( + QApplication::activeWindow(), QString("Material document could not be created"), + QString("Failed to create: \n%1\n\n%2").arg(requestedPath.c_str()).arg(traceRecorder.GetDump().c_str())); return AZ::Uuid::CreateNull(); } + traceRecorder.GetDump().clear(); + bool openResult = false; MaterialDocumentRequestBus::EventResult(openResult, documentId, &MaterialDocumentRequestBus::Events::Open, requestedPath); if (!openResult) { - QMessageBox::critical(QApplication::activeWindow(), "Error", QString("Material document could not be opened:\n%1").arg(requestedPath.c_str())); + QMessageBox::critical( + QApplication::activeWindow(), QString("Material document could not be opened"), + QString("Failed to open: \n%1\n\n%2").arg(requestedPath.c_str()).arg(traceRecorder.GetDump().c_str())); MaterialDocumentSystemRequestBus::Broadcast(&MaterialDocumentSystemRequestBus::Events::DestroyDocument, documentId); return AZ::Uuid::CreateNull(); } diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocumentSystemComponent.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocumentSystemComponent.h index 933a3351ba..b6c541421d 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocumentSystemComponent.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocumentSystemComponent.h @@ -98,5 +98,6 @@ namespace MaterialEditor AZStd::unordered_set m_documentIdsToRebuild; AZStd::unordered_set m_documentIdsToReopen; AZStd::unique_ptr m_settings; + const size_t m_maxMessageBoxLineCount = 15; }; } diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserInteractions.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserInteractions.cpp deleted file mode 100644 index 39654af211..0000000000 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserInteractions.cpp +++ /dev/null @@ -1,375 +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. -* -*/ - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include - -namespace MaterialEditor -{ - MaterialBrowserInteractions::MaterialBrowserInteractions() - { - using namespace AzToolsFramework::AssetBrowser; - - AssetBrowserInteractionNotificationBus::Handler::BusConnect(); - } - - MaterialBrowserInteractions::~MaterialBrowserInteractions() - { - AssetBrowserInteractionNotificationBus::Handler::BusDisconnect(); - } - - void MaterialBrowserInteractions::AddContextMenuActions(QWidget* caller, QMenu* menu, const AZStd::vector& entries) - { - AssetBrowserEntry* entry = entries.empty() ? nullptr : entries.front(); - if (!entry) - { - return; - } - - m_caller = caller; - QObject::connect(m_caller, &QObject::destroyed, [this]() - { - m_caller = nullptr; - }); - - AddGenericContextMenuActions(caller, menu, entry); - - if (entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Source) - { - const auto source = azalias_cast(entry); - if (AzFramework::StringFunc::Path::IsExtension(entry->GetFullPath().c_str(), MaterialExtension)) - { - AddContextMenuActionsForMaterialSource(caller, menu, source); - } - else if (AzFramework::StringFunc::Path::IsExtension(entry->GetFullPath().c_str(), MaterialTypeExtension)) - { - AddContextMenuActionsForMaterialTypeSource(caller, menu, source); - } - else - { - AddContextMenuActionsForOtherSource(caller, menu, source); - } - } - else if (entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Folder) - { - const auto folder = azalias_cast(entry); - AddContextMenuActionsForFolder(caller, menu, folder); - } - } - - void MaterialBrowserInteractions::AddGenericContextMenuActions([[maybe_unused]] QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) - { - menu->addAction(QObject::tr("Copy Name To Clipboard"), [=]() - { - QApplication::clipboard()->setText(entry->GetName().c_str()); - }); - menu->addAction(QObject::tr("Copy Path To Clipboard"), [=]() - { - QApplication::clipboard()->setText(entry->GetFullPath().c_str()); - }); - } - - void MaterialBrowserInteractions::AddContextMenuActionsForMaterialTypeSource(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* entry) - { - menu->addAction(AzQtComponents::fileBrowserActionName(), [entry]() - { - AzQtComponents::ShowFileOnDesktop(entry->GetFullPath().c_str()); - }); - - menu->addSeparator(); - - menu->addAction("Create Material...", [entry]() - { - const QString defaultPath = AtomToolsFramework::GetUniqueFileInfo( - QString(AZ::IO::FileIOBase::GetInstance()->GetAlias("@devassets@")) + - AZ_CORRECT_FILESYSTEM_SEPARATOR + "Materials" + - AZ_CORRECT_FILESYSTEM_SEPARATOR + "untitled." + - AZ::RPI::MaterialSourceData::Extension).absoluteFilePath(); - - MaterialDocumentSystemRequestBus::Broadcast(&MaterialDocumentSystemRequestBus::Events::CreateDocumentFromFile, - entry->GetFullPath(), AtomToolsFramework::GetSaveFileInfo(defaultPath).absoluteFilePath().toUtf8().constData()); - }); - - AddPerforceMenuActions(caller, menu, entry); - } - - void MaterialBrowserInteractions::AddContextMenuActionsForOtherSource(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* entry) - { - menu->addAction("Open", [entry]() - { - QDesktopServices::openUrl(QUrl::fromLocalFile(entry->GetFullPath().c_str())); - }); - - menu->addAction("Duplicate...", [entry, caller]() - { - const QFileInfo duplicateFileInfo(AtomToolsFramework::GetDuplicationFileInfo(entry->GetFullPath().c_str())); - if (!duplicateFileInfo.absoluteFilePath().isEmpty()) - { - if (QFile::copy(entry->GetFullPath().c_str(), duplicateFileInfo.absoluteFilePath())) - { - QFile::setPermissions(duplicateFileInfo.absoluteFilePath(), QFile::ReadOther | QFile::WriteOther); - - // Auto add file to source control - AzToolsFramework::SourceControlCommandBus::Broadcast(&AzToolsFramework::SourceControlCommandBus::Events::RequestEdit, - duplicateFileInfo.absoluteFilePath().toUtf8().constData(), true, [](bool, const AzToolsFramework::SourceControlFileInfo&) {}); - } - } - }); - - menu->addAction(AzQtComponents::fileBrowserActionName(), [entry]() - { - AzQtComponents::ShowFileOnDesktop(entry->GetFullPath().c_str()); - }); - - AddPerforceMenuActions(caller, menu, entry); - } - - void MaterialBrowserInteractions::AddContextMenuActionsForMaterialSource(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* entry) - { - menu->addAction("Open", [entry]() - { - MaterialDocumentSystemRequestBus::Broadcast(&MaterialDocumentSystemRequestBus::Events::OpenDocument, entry->GetFullPath()); - }); - - menu->addAction("Duplicate...", [entry, caller]() - { - const QFileInfo duplicateFileInfo(AtomToolsFramework::GetDuplicationFileInfo(entry->GetFullPath().c_str())); - if (!duplicateFileInfo.absoluteFilePath().isEmpty()) - { - if (QFile::copy(entry->GetFullPath().c_str(), duplicateFileInfo.absoluteFilePath())) - { - QFile::setPermissions(duplicateFileInfo.absoluteFilePath(), QFile::ReadOther | QFile::WriteOther); - - // Auto add file to source control - AzToolsFramework::SourceControlCommandBus::Broadcast(&AzToolsFramework::SourceControlCommandBus::Events::RequestEdit, - duplicateFileInfo.absoluteFilePath().toUtf8().constData(), true, [](bool, const AzToolsFramework::SourceControlFileInfo&) {}); - } - } - }); - - menu->addAction(AzQtComponents::fileBrowserActionName(), [entry]() - { - AzQtComponents::ShowFileOnDesktop(entry->GetFullPath().c_str()); - }); - - menu->addSeparator(); - - menu->addAction("Create Child Material...", [entry]() - { - const QString defaultPath = AtomToolsFramework::GetUniqueFileInfo( - QString(AZ::IO::FileIOBase::GetInstance()->GetAlias("@devassets@")) + - AZ_CORRECT_FILESYSTEM_SEPARATOR + "Materials" + - AZ_CORRECT_FILESYSTEM_SEPARATOR + "untitled." + - AZ::RPI::MaterialSourceData::Extension).absoluteFilePath(); - - MaterialDocumentSystemRequestBus::Broadcast(&MaterialDocumentSystemRequestBus::Events::CreateDocumentFromFile, - entry->GetFullPath(), AtomToolsFramework::GetSaveFileInfo(defaultPath).absoluteFilePath().toUtf8().constData()); - }); - - menu->addSeparator(); - - QAction* openParentAction = menu->addAction("Open Parent Material", [entry]() - { - AZ_UNUSED(entry); - // ToDo - }); - openParentAction->setEnabled(false); - - AddPerforceMenuActions(caller, menu, entry); - } - - void MaterialBrowserInteractions::AddContextMenuActionsForFolder(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::FolderAssetBrowserEntry* entry) - { - menu->addAction(AzQtComponents::fileBrowserActionName(), [entry]() - { - AzQtComponents::ShowFileOnDesktop(entry->GetFullPath().c_str()); - }); - - QAction* createFolderAction = menu->addAction(QObject::tr("Create new sub folder...")); - QObject::connect(createFolderAction, &QAction::triggered, caller, [caller, entry]() - { - bool ok; - QString newFolderName = QInputDialog::getText(caller, "Enter new folder name", "name:", QLineEdit::Normal, "NewFolder", &ok); - if (ok) - { - if (newFolderName.isEmpty()) - { - QMessageBox msgBox(QMessageBox::Icon::Critical, "Error", "Folder name can't be empty", QMessageBox::Ok, caller); - msgBox.exec(); - } - else - { - AZStd::string newFolderPath; - AzFramework::StringFunc::Path::Join(entry->GetFullPath().c_str(), newFolderName.toUtf8().constData(), newFolderPath); - QDir dir(newFolderPath.c_str()); - if (dir.exists()) - { - QMessageBox::critical(caller, "Error", "Folder with this name already exists"); - return; - } - auto result = dir.mkdir(newFolderPath.c_str()); - if (!result) - { - AZ_Error("MaterialBrowser", false, "Failed to make new folder"); - return; - } - } - } - }); - - menu->addSeparator(); - - QAction* createMaterialAction = menu->addAction(QObject::tr("Create Material...")); - QObject::connect(createMaterialAction, &QAction::triggered, caller, [caller, entry]() - { - CreateMaterialDialog createDialog(entry->GetFullPath().c_str(), caller); - createDialog.adjustSize(); - - if (createDialog.exec() == QDialog::Accepted && - !createDialog.m_materialFileInfo.absoluteFilePath().isEmpty() && - !createDialog.m_materialTypeFileInfo.absoluteFilePath().isEmpty()) - { - MaterialDocumentSystemRequestBus::Broadcast(&MaterialDocumentSystemRequestBus::Events::CreateDocumentFromFile, - createDialog.m_materialTypeFileInfo.absoluteFilePath().toUtf8().constData(), - createDialog.m_materialFileInfo.absoluteFilePath().toUtf8().constData()); - } - }); - } - - void MaterialBrowserInteractions::AddPerforceMenuActions([[maybe_unused]] QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) - { - using namespace AzToolsFramework; - - bool isActive = false; - SourceControlConnectionRequestBus::BroadcastResult(isActive, &SourceControlConnectionRequests::IsActive); - - if (isActive) - { - menu->addSeparator(); - - AZStd::string path = entry->GetFullPath(); - AzFramework::StringFunc::Path::Normalize(path); - - QMenu* sourceControlMenu = menu->addMenu("Source Control"); - - // Update the enabled state of source control menu actions only if menu is shown - QMenu::connect(sourceControlMenu, &QMenu::aboutToShow, [this, path]() - { - SourceControlCommandBus::Broadcast(&SourceControlCommandBus::Events::GetFileInfo, path.c_str(), - [this](bool success, const SourceControlFileInfo& info) { UpdateSourceControlActions(success, info); }); - }); - - // add get latest action - m_getLatestAction = sourceControlMenu->addAction("Get Latest", [path, this]() - { - SourceControlCommandBus::Broadcast(&SourceControlCommandBus::Events::RequestLatest, path.c_str(), - [](bool, const SourceControlFileInfo&) {}); - }); - QObject::connect(m_getLatestAction, &QObject::destroyed, [this]() - { - m_getLatestAction = nullptr; - }); - m_getLatestAction->setEnabled(false); - - // add add action - m_addAction = sourceControlMenu->addAction("Add", [path]() - { - SourceControlCommandBus::Broadcast(&SourceControlCommandBus::Events::RequestEdit, path.c_str(), true, - [path](bool, const SourceControlFileInfo&) - { - SourceControlThumbnailRequestBus::Broadcast(&SourceControlThumbnailRequests::FileStatusChanged, path.c_str()); - }); - }); - QObject::connect(m_addAction, &QObject::destroyed, [this]() - { - m_addAction = nullptr; - }); - m_addAction->setEnabled(false); - - // add checkout action - m_checkOutAction = sourceControlMenu->addAction("Check Out", [path]() - { - SourceControlCommandBus::Broadcast(&SourceControlCommandBus::Events::RequestEdit, path.c_str(), true, - [path](bool, const SourceControlFileInfo&) - { - SourceControlThumbnailRequestBus::Broadcast(&SourceControlThumbnailRequests::FileStatusChanged, path.c_str()); - }); - }); - QObject::connect(m_checkOutAction, &QObject::destroyed, [this]() - { - m_checkOutAction = nullptr; - }); - m_checkOutAction->setEnabled(false); - - // add undo checkout action - m_undoCheckOutAction = sourceControlMenu->addAction("Undo Check Out", [path]() - { - SourceControlCommandBus::Broadcast(&SourceControlCommandBus::Events::RequestRevert, path.c_str(), - [path](bool, const SourceControlFileInfo&) - { - SourceControlThumbnailRequestBus::Broadcast(&SourceControlThumbnailRequests::FileStatusChanged, path.c_str()); - }); - }); - QObject::connect(m_undoCheckOutAction, &QObject::destroyed, [this]() - { - m_undoCheckOutAction = nullptr; - }); - m_undoCheckOutAction->setEnabled(false); - } - } - - void MaterialBrowserInteractions::UpdateSourceControlActions(bool success, AzToolsFramework::SourceControlFileInfo info) - { - if (!success && m_caller) - { - QMessageBox::critical(m_caller, "Error", "Source control operation failed."); - } - if (m_getLatestAction) - { - m_getLatestAction->setEnabled(info.IsManaged() && info.HasFlag(AzToolsFramework::SCF_OutOfDate)); - } - if (m_addAction) - { - m_addAction->setEnabled(!info.IsManaged()); - } - if (m_checkOutAction) - { - m_checkOutAction->setEnabled(info.IsManaged() && info.IsReadOnly() && !info.IsLockedByOther()); - } - if (m_undoCheckOutAction) - { - m_undoCheckOutAction->setEnabled(info.IsManaged() && !info.IsReadOnly()); - } - } -} // namespace MaterialEditor diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.cpp new file mode 100644 index 0000000000..92e02d5b42 --- /dev/null +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.cpp @@ -0,0 +1,358 @@ +/* +* 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 +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include + +namespace MaterialEditor +{ + MaterialEditorBrowserInteractions::MaterialEditorBrowserInteractions() + { + using namespace AzToolsFramework::AssetBrowser; + + AssetBrowserInteractionNotificationBus::Handler::BusConnect(); + } + + MaterialEditorBrowserInteractions::~MaterialEditorBrowserInteractions() + { + AssetBrowserInteractionNotificationBus::Handler::BusDisconnect(); + } + + void MaterialEditorBrowserInteractions::AddContextMenuActions(QWidget* caller, QMenu* menu, const AZStd::vector& entries) + { + AssetBrowserEntry* entry = entries.empty() ? nullptr : entries.front(); + if (!entry) + { + return; + } + + m_caller = caller; + QObject::connect(m_caller, &QObject::destroyed, [this]() + { + m_caller = nullptr; + }); + + AddGenericContextMenuActions(caller, menu, entry); + + if (entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Source) + { + const auto source = azalias_cast(entry); + if (AzFramework::StringFunc::Path::IsExtension(entry->GetFullPath().c_str(), MaterialExtension)) + { + AddContextMenuActionsForMaterialSource(caller, menu, source); + } + else if (AzFramework::StringFunc::Path::IsExtension(entry->GetFullPath().c_str(), MaterialTypeExtension)) + { + AddContextMenuActionsForMaterialTypeSource(caller, menu, source); + } + else + { + AddContextMenuActionsForOtherSource(caller, menu, source); + } + } + else if (entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Folder) + { + const auto folder = azalias_cast(entry); + AddContextMenuActionsForFolder(caller, menu, folder); + } + } + + void MaterialEditorBrowserInteractions::AddGenericContextMenuActions([[maybe_unused]] QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) + { + menu->addAction(QObject::tr("Copy Name To Clipboard"), [=]() + { + QApplication::clipboard()->setText(entry->GetName().c_str()); + }); + menu->addAction(QObject::tr("Copy Path To Clipboard"), [=]() + { + QApplication::clipboard()->setText(entry->GetFullPath().c_str()); + }); + } + + void MaterialEditorBrowserInteractions::AddContextMenuActionsForMaterialTypeSource(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* entry) + { + menu->addAction(AzQtComponents::fileBrowserActionName(), [entry]() + { + AzQtComponents::ShowFileOnDesktop(entry->GetFullPath().c_str()); + }); + + menu->addSeparator(); + + menu->addAction("Create Material...", [entry]() + { + const QString defaultPath = AtomToolsFramework::GetUniqueFileInfo( + QString(AZ::IO::FileIOBase::GetInstance()->GetAlias("@devassets@")) + + AZ_CORRECT_FILESYSTEM_SEPARATOR + "Materials" + + AZ_CORRECT_FILESYSTEM_SEPARATOR + "untitled." + + AZ::RPI::MaterialSourceData::Extension).absoluteFilePath(); + + MaterialDocumentSystemRequestBus::Broadcast(&MaterialDocumentSystemRequestBus::Events::CreateDocumentFromFile, + entry->GetFullPath(), AtomToolsFramework::GetSaveFileInfo(defaultPath).absoluteFilePath().toUtf8().constData()); + }); + + AddPerforceMenuActions(caller, menu, entry); + } + + void MaterialEditorBrowserInteractions::AddContextMenuActionsForOtherSource(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* entry) + { + menu->addAction("Open", [entry]() + { + QDesktopServices::openUrl(QUrl::fromLocalFile(entry->GetFullPath().c_str())); + }); + + menu->addAction("Duplicate...", [entry, caller]() + { + const QFileInfo duplicateFileInfo(AtomToolsFramework::GetDuplicationFileInfo(entry->GetFullPath().c_str())); + if (!duplicateFileInfo.absoluteFilePath().isEmpty()) + { + if (QFile::copy(entry->GetFullPath().c_str(), duplicateFileInfo.absoluteFilePath())) + { + QFile::setPermissions(duplicateFileInfo.absoluteFilePath(), QFile::ReadOther | QFile::WriteOther); + + // Auto add file to source control + AzToolsFramework::SourceControlCommandBus::Broadcast(&AzToolsFramework::SourceControlCommandBus::Events::RequestEdit, + duplicateFileInfo.absoluteFilePath().toUtf8().constData(), true, [](bool, const AzToolsFramework::SourceControlFileInfo&) {}); + } + } + }); + + menu->addAction(AzQtComponents::fileBrowserActionName(), [entry]() + { + AzQtComponents::ShowFileOnDesktop(entry->GetFullPath().c_str()); + }); + + AddPerforceMenuActions(caller, menu, entry); + } + + void MaterialEditorBrowserInteractions::AddContextMenuActionsForMaterialSource(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* entry) + { + menu->addAction("Open", [entry]() + { + MaterialDocumentSystemRequestBus::Broadcast(&MaterialDocumentSystemRequestBus::Events::OpenDocument, entry->GetFullPath()); + }); + + menu->addAction("Duplicate...", [entry, caller]() + { + const QFileInfo duplicateFileInfo(AtomToolsFramework::GetDuplicationFileInfo(entry->GetFullPath().c_str())); + if (!duplicateFileInfo.absoluteFilePath().isEmpty()) + { + if (QFile::copy(entry->GetFullPath().c_str(), duplicateFileInfo.absoluteFilePath())) + { + QFile::setPermissions(duplicateFileInfo.absoluteFilePath(), QFile::ReadOther | QFile::WriteOther); + + // Auto add file to source control + AzToolsFramework::SourceControlCommandBus::Broadcast(&AzToolsFramework::SourceControlCommandBus::Events::RequestEdit, + duplicateFileInfo.absoluteFilePath().toUtf8().constData(), true, [](bool, const AzToolsFramework::SourceControlFileInfo&) {}); + } + } + }); + + menu->addAction(AzQtComponents::fileBrowserActionName(), [entry]() + { + AzQtComponents::ShowFileOnDesktop(entry->GetFullPath().c_str()); + }); + + menu->addSeparator(); + + menu->addAction("Create Child Material...", [entry]() + { + const QString defaultPath = AtomToolsFramework::GetUniqueFileInfo( + QString(AZ::IO::FileIOBase::GetInstance()->GetAlias("@devassets@")) + + AZ_CORRECT_FILESYSTEM_SEPARATOR + "Materials" + + AZ_CORRECT_FILESYSTEM_SEPARATOR + "untitled." + + AZ::RPI::MaterialSourceData::Extension).absoluteFilePath(); + + MaterialDocumentSystemRequestBus::Broadcast(&MaterialDocumentSystemRequestBus::Events::CreateDocumentFromFile, + entry->GetFullPath(), AtomToolsFramework::GetSaveFileInfo(defaultPath).absoluteFilePath().toUtf8().constData()); + }); + + menu->addSeparator(); + + QAction* openParentAction = menu->addAction("Open Parent Material", [entry]() + { + AZ_UNUSED(entry); + // ToDo + }); + openParentAction->setEnabled(false); + + AddPerforceMenuActions(caller, menu, entry); + } + + void MaterialEditorBrowserInteractions::AddContextMenuActionsForFolder(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::FolderAssetBrowserEntry* entry) + { + menu->addAction(AzQtComponents::fileBrowserActionName(), [entry]() + { + AzQtComponents::ShowFileOnDesktop(entry->GetFullPath().c_str()); + }); + + QAction* createFolderAction = menu->addAction(QObject::tr("Create new sub folder...")); + QObject::connect(createFolderAction, &QAction::triggered, caller, [caller, entry]() + { + bool ok; + QString newFolderName = QInputDialog::getText(caller, "Enter new folder name", "name:", QLineEdit::Normal, "NewFolder", &ok); + if (ok) + { + if (newFolderName.isEmpty()) + { + QMessageBox msgBox(QMessageBox::Icon::Critical, "Error", "Folder name can't be empty", QMessageBox::Ok, caller); + msgBox.exec(); + } + else + { + AZStd::string newFolderPath; + AzFramework::StringFunc::Path::Join(entry->GetFullPath().c_str(), newFolderName.toUtf8().constData(), newFolderPath); + QDir dir(newFolderPath.c_str()); + if (dir.exists()) + { + QMessageBox::critical(caller, "Error", "Folder with this name already exists"); + return; + } + auto result = dir.mkdir(newFolderPath.c_str()); + if (!result) + { + AZ_Error("MaterialBrowser", false, "Failed to make new folder"); + return; + } + } + } + }); + } + + void MaterialEditorBrowserInteractions::AddPerforceMenuActions([[maybe_unused]] QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) + { + using namespace AzToolsFramework; + + bool isActive = false; + SourceControlConnectionRequestBus::BroadcastResult(isActive, &SourceControlConnectionRequests::IsActive); + + if (isActive) + { + menu->addSeparator(); + + AZStd::string path = entry->GetFullPath(); + AzFramework::StringFunc::Path::Normalize(path); + + QMenu* sourceControlMenu = menu->addMenu("Source Control"); + + // Update the enabled state of source control menu actions only if menu is shown + QMenu::connect(sourceControlMenu, &QMenu::aboutToShow, [this, path]() + { + SourceControlCommandBus::Broadcast(&SourceControlCommandBus::Events::GetFileInfo, path.c_str(), + [this](bool success, const SourceControlFileInfo& info) { UpdateSourceControlActions(success, info); }); + }); + + // add get latest action + m_getLatestAction = sourceControlMenu->addAction("Get Latest", [path, this]() + { + SourceControlCommandBus::Broadcast(&SourceControlCommandBus::Events::RequestLatest, path.c_str(), + [](bool, const SourceControlFileInfo&) {}); + }); + QObject::connect(m_getLatestAction, &QObject::destroyed, [this]() + { + m_getLatestAction = nullptr; + }); + m_getLatestAction->setEnabled(false); + + // add add action + m_addAction = sourceControlMenu->addAction("Add", [path]() + { + SourceControlCommandBus::Broadcast(&SourceControlCommandBus::Events::RequestEdit, path.c_str(), true, + [path](bool, const SourceControlFileInfo&) + { + SourceControlThumbnailRequestBus::Broadcast(&SourceControlThumbnailRequests::FileStatusChanged, path.c_str()); + }); + }); + QObject::connect(m_addAction, &QObject::destroyed, [this]() + { + m_addAction = nullptr; + }); + m_addAction->setEnabled(false); + + // add checkout action + m_checkOutAction = sourceControlMenu->addAction("Check Out", [path]() + { + SourceControlCommandBus::Broadcast(&SourceControlCommandBus::Events::RequestEdit, path.c_str(), true, + [path](bool, const SourceControlFileInfo&) + { + SourceControlThumbnailRequestBus::Broadcast(&SourceControlThumbnailRequests::FileStatusChanged, path.c_str()); + }); + }); + QObject::connect(m_checkOutAction, &QObject::destroyed, [this]() + { + m_checkOutAction = nullptr; + }); + m_checkOutAction->setEnabled(false); + + // add undo checkout action + m_undoCheckOutAction = sourceControlMenu->addAction("Undo Check Out", [path]() + { + SourceControlCommandBus::Broadcast(&SourceControlCommandBus::Events::RequestRevert, path.c_str(), + [path](bool, const SourceControlFileInfo&) + { + SourceControlThumbnailRequestBus::Broadcast(&SourceControlThumbnailRequests::FileStatusChanged, path.c_str()); + }); + }); + QObject::connect(m_undoCheckOutAction, &QObject::destroyed, [this]() + { + m_undoCheckOutAction = nullptr; + }); + m_undoCheckOutAction->setEnabled(false); + } + } + + void MaterialEditorBrowserInteractions::UpdateSourceControlActions(bool success, AzToolsFramework::SourceControlFileInfo info) + { + if (!success && m_caller) + { + QMessageBox::critical(m_caller, "Error", "Source control operation failed."); + } + if (m_getLatestAction) + { + m_getLatestAction->setEnabled(info.IsManaged() && info.HasFlag(AzToolsFramework::SCF_OutOfDate)); + } + if (m_addAction) + { + m_addAction->setEnabled(!info.IsManaged()); + } + if (m_checkOutAction) + { + m_checkOutAction->setEnabled(info.IsManaged() && info.IsReadOnly() && !info.IsLockedByOther()); + } + if (m_undoCheckOutAction) + { + m_undoCheckOutAction->setEnabled(info.IsManaged() && !info.IsReadOnly()); + } + } +} // namespace MaterialEditor diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserInteractions.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.h similarity index 91% rename from Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserInteractions.h rename to Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.h index 2806cee6d4..7ee3ec833d 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserInteractions.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.h @@ -31,14 +31,14 @@ namespace AzToolsFramework namespace MaterialEditor { - class MaterialBrowserInteractions + class MaterialEditorBrowserInteractions : public AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler { public: - AZ_CLASS_ALLOCATOR(MaterialBrowserInteractions, AZ::SystemAllocator, 0); + AZ_CLASS_ALLOCATOR(MaterialEditorBrowserInteractions, AZ::SystemAllocator, 0); - MaterialBrowserInteractions(); - ~MaterialBrowserInteractions(); + MaterialEditorBrowserInteractions(); + ~MaterialEditorBrowserInteractions(); private: //! AssetBrowserInteractionNotificationBus::Handler overrides... diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindowComponent.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindowComponent.cpp index 6f03510301..a1ff8da635 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindowComponent.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindowComponent.cpp @@ -98,7 +98,7 @@ namespace MaterialEditor void MaterialEditorWindowComponent::CreateMaterialEditorWindow() { - m_materialBrowserInteractions.reset(aznew MaterialBrowserInteractions); + m_materialEditorBrowserInteractions.reset(aznew MaterialEditorBrowserInteractions); m_window.reset(aznew MaterialEditorWindow); m_window->show(); diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindowComponent.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindowComponent.h index f727fcc97c..1ea05d6530 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindowComponent.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindowComponent.h @@ -16,7 +16,7 @@ #include #include -#include +#include #include namespace MaterialEditor @@ -57,6 +57,6 @@ namespace MaterialEditor //////////////////////////////////////////////////////////////////////// AZStd::unique_ptr m_window; - AZStd::unique_ptr m_materialBrowserInteractions; + AZStd::unique_ptr m_materialEditorBrowserInteractions; }; } diff --git a/Gems/Atom/Tools/MaterialEditor/Code/materialeditorwindow_files.cmake b/Gems/Atom/Tools/MaterialEditor/Code/materialeditorwindow_files.cmake index fef3aeefb7..1547dbf48f 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/materialeditorwindow_files.cmake +++ b/Gems/Atom/Tools/MaterialEditor/Code/materialeditorwindow_files.cmake @@ -14,8 +14,8 @@ set(FILES Include/Atom/Window/MaterialEditorWindowNotificationBus.h Include/Atom/Window/MaterialEditorWindowRequestBus.h Include/Atom/Window/MaterialEditorWindowFactoryRequestBus.h - Source/Window/MaterialBrowserInteractions.h - Source/Window/MaterialBrowserInteractions.cpp + Source/Window/MaterialEditorBrowserInteractions.h + Source/Window/MaterialEditorBrowserInteractions.cpp Source/Window/MaterialEditorWindow.h Source/Window/MaterialEditorWindow.cpp Source/Window/MaterialEditorWindowModule.cpp diff --git a/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/Bricks038_8K/bricks038.material b/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/Bricks038_8K/bricks038.material index faf8e1f734..b4b1e10b2e 100644 --- a/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/Bricks038_8K/bricks038.material +++ b/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/Bricks038_8K/bricks038.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Materials/Bricks038_8K/Bricks038_8K_AmbientOcclusion.png" + "occlusion": { + "diffuseTextureMap": "Materials/Bricks038_8K/Bricks038_8K_AmbientOcclusion.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/PaintedPlaster015_8K/PaintedPlaster015.material b/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/PaintedPlaster015_8K/PaintedPlaster015.material index ed0230a3ca..2d622e8263 100644 --- a/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/PaintedPlaster015_8K/PaintedPlaster015.material +++ b/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/PaintedPlaster015_8K/PaintedPlaster015.material @@ -4,10 +4,9 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "factor": 0.30000001192092898, - "textureMap": "Materials/PaintedPlaster015_8K/PaintedPlaster015_8K_AmbientOcclusion.png" + "occlusion": { + "diffuseFactor": 0.30000001192092898, + "diffuseTextureMap": "Materials/PaintedPlaster015_8K/PaintedPlaster015_8K_AmbientOcclusion.png" }, "baseColor": { "textureMap": "Materials/PaintedPlaster015_8K/PaintedPlaster015_8K_BaseColor.png" diff --git a/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/baseboards.material b/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/baseboards.material index 233b35ab46..7e31eaa5b6 100644 --- a/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/baseboards.material +++ b/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/baseboards.material @@ -4,9 +4,6 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "textureMap": "Materials/Bricks038_8K/Bricks038_8K_AmbientOcclusion.png" - }, "baseColor": { "color": [ 0.496940553188324, diff --git a/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/crown.material b/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/crown.material index a5c18d0d8b..121b27c021 100644 --- a/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/crown.material +++ b/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/crown.material @@ -4,9 +4,6 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "textureMap": "Materials/Bricks038_8K/Bricks038_8K_AmbientOcclusion.png" - }, "baseColor": { "color": [ 0.496940553188324, diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_arch.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_arch.material index da72f8a430..770e8b92cf 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_arch.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_arch.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/arch_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/arch_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_background.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_background.material index 5a195fd0b6..1347f71c86 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_background.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_background.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/background_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/background_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_bricks.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_bricks.material index d2089b5537..4671e3906d 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_bricks.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_bricks.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/bricks_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/bricks_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_ceiling.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_ceiling.material index 40e476305d..3c15eb8227 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_ceiling.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_ceiling.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/ceiling_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/ceiling_1k_ao.png" }, "baseColor": { "textureBlendMode": "Lerp", diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columna.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columna.material index 6c89c94021..62ac3e7ed7 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columna.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columna.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/columnA_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/columnA_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columnb.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columnb.material index 0be26ba553..bf1e9aea61 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columnb.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columnb.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/columnB_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/columnB_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columnc.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columnc.material index 2f1512fa4a..9614428cd8 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columnc.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columnc.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/columnC_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/columnC_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtainblue.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtainblue.material index e68bc7a41a..47cd16b0eb 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtainblue.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtainblue.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/curtain_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/curtain_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtaingreen.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtaingreen.material index 85a5ef9775..aba840ce9e 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtaingreen.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtaingreen.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/curtain_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/curtain_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtainred.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtainred.material index 086f34727c..7255e35e88 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtainred.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtainred.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/curtain_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/curtain_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_details.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_details.material index 18bd2a307b..5586d371a8 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_details.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_details.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/details_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/details_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricblue.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricblue.material index fb0490f9a9..23168ff9b5 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricblue.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricblue.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/fabric_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/fabric_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricgreen.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricgreen.material index c6074bf894..5760004e39 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricgreen.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricgreen.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/fabric_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/fabric_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricred.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricred.material index 4215d8dde5..bd3eea7ed3 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricred.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricred.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/fabric_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/fabric_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_flagpole.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_flagpole.material index cbba302103..b649ca13a2 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_flagpole.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_flagpole.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/flagpole_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/flagpole_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_floor.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_floor.material index 2c2abe3931..5cb52480ec 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_floor.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_floor.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/floor_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/floor_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_lion.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_lion.material index 55f44b2f63..32dd098c99 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_lion.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_lion.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/lion_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/lion_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_roof.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_roof.material index a64486309d..fda36db2a3 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_roof.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_roof.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/roof_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/roof_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vase.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vase.material index 867943642e..6538caf94b 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vase.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vase.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/vase_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/vase_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vasehanging.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vasehanging.material index 9e96fb983d..7f090b54da 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vasehanging.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vasehanging.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/vaseHanging_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/vaseHanging_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vaseround.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vaseround.material index ebb4e537f5..78c30d614f 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vaseround.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vaseround.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/vaseRound_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/vaseRound_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_brass.material b/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_brass.material index 61a9974e0b..8b37245ae7 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_brass.material +++ b/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_brass.material @@ -4,9 +4,8 @@ "parentMaterial": "Materials/Presets/PBR/metal_brass.material", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Objects/Lucy/Lucy_ao.tif" + "occlusion": { + "diffuseTextureMap": "Objects/Lucy/Lucy_ao.tif" }, "baseColor": { "color": [ diff --git a/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_stone.material b/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_stone.material index d48cb44721..4f6a9e1292 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_stone.material +++ b/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_stone.material @@ -4,9 +4,8 @@ "parentMaterial": "Materials/Presets/PBR/metal_brass.material", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Objects/Lucy/Lucy_ao.tif" + "occlusion": { + "diffuseTextureMap": "Objects/Lucy/Lucy_ao.tif" }, "baseColor": { "color": [ diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/DirectionalLightComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/DirectionalLightComponentController.cpp index c7d459c596..310e6e6eca 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/DirectionalLightComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/DirectionalLightComponentController.cpp @@ -19,6 +19,9 @@ #include #include #include +#include +#include +#include namespace AZ { @@ -586,9 +589,11 @@ namespace AZ } else { - Camera::ActiveCameraRequestBus::BroadcastResult( - cameraTransform, - &Camera::ActiveCameraRequestBus::Events::GetActiveCameraTransform); + if (const auto& viewportContext = AZ::Interface::Get()->GetDefaultViewportContext()) + { + cameraTransform = viewportContext->GetCameraTransform(); + } + } if (cameraTransform == m_lastCameraTransform) { diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialSystemComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialSystemComponent.cpp index 82f65b205d..94dfb39419 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialSystemComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialSystemComponent.cpp @@ -100,6 +100,7 @@ namespace AZ AzToolsFramework::EditorMenuNotificationBus::Handler::BusConnect(); SetupThumbnails(); + m_materialBrowserInteractions.reset(aznew MaterialBrowserInteractions); } void EditorMaterialSystemComponent::Deactivate() @@ -111,6 +112,7 @@ namespace AZ AzToolsFramework::EditorMenuNotificationBus::Handler::BusDisconnect(); TeardownThumbnails(); + m_materialBrowserInteractions.reset(); if (m_openMaterialEditorAction) { diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialSystemComponent.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialSystemComponent.h index de065f679e..09ad1c1b9c 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialSystemComponent.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialSystemComponent.h @@ -22,6 +22,8 @@ #include +#include + namespace AZ { namespace Render @@ -76,6 +78,8 @@ namespace AZ AzFramework::TargetInfo m_materialEditorTarget; QAction* m_openMaterialEditorAction = nullptr; + + AZStd::unique_ptr m_materialBrowserInteractions; }; } // namespace Render } // namespace AZ diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialBrowserInteractions.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialBrowserInteractions.cpp new file mode 100644 index 0000000000..82fa47a810 --- /dev/null +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialBrowserInteractions.cpp @@ -0,0 +1,54 @@ +/* +* 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 AZ +{ + namespace Render + { + MaterialBrowserInteractions::MaterialBrowserInteractions() + { + AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler::BusConnect(); + } + + MaterialBrowserInteractions::~MaterialBrowserInteractions() + { + AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler::BusDisconnect(); + } + + void MaterialBrowserInteractions::AddSourceFileOpeners(const char* fullSourceFileName, [[maybe_unused]] const AZ::Uuid& sourceUUID, AzToolsFramework::AssetBrowser::SourceFileOpenerList& openers) + { + if (HandlesSource(fullSourceFileName)) + { + openers.push_back( + { + "Material_Editor", + "Open in Material Editor...", + QIcon(), + [&](const char* fullSourceFileNameInCallback, [[maybe_unused]] const AZ::Uuid& sourceUUID) + { + EditorMaterialSystemComponentRequestBus::Broadcast(&EditorMaterialSystemComponentRequestBus::Events::OpenInMaterialEditor, fullSourceFileNameInCallback); + } + }); + } + } + + bool MaterialBrowserInteractions::HandlesSource(AZStd::string_view fileName) const + { + return AZStd::wildcard_match("*.material", fileName.data()); + } + } // namespace Render +} // namespace AZ diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialBrowserInteractions.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialBrowserInteractions.h new file mode 100644 index 0000000000..bd9791d3a5 --- /dev/null +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialBrowserInteractions.h @@ -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. +* +*/ + +#pragma once + +#include +#include + +class QWidget; +class QMenu; +class QAction; + +namespace AzToolsFramework +{ + namespace AssetBrowser + { + class AssetBrowserEntry; + class SourceAssetBrowserEntry; + class FolderAssetBrowserEntry; + } +} + +namespace AZ +{ + namespace Render + { + class MaterialBrowserInteractions + : public AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler + { + public: + AZ_CLASS_ALLOCATOR(MaterialBrowserInteractions, AZ::SystemAllocator, 0); + + MaterialBrowserInteractions(); + ~MaterialBrowserInteractions(); + + private: + //! AssetBrowserInteractionNotificationBus::Handler overrides... + void AddSourceFileOpeners(const char* fullSourceFileName, const AZ::Uuid& sourceUUID, AzToolsFramework::AssetBrowser::SourceFileOpenerList& openers) override; + + bool HandlesSource(AZStd::string_view fileName) const; + }; + } // namespace Render +} // namespace AZ diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp index b9b0759dda..c9aa3a6d5e 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp @@ -137,9 +137,12 @@ namespace AZ AZ::Transform transform = AZ::Transform::CreateIdentity(); AZ::TransformBus::EventResult(transform, GetEntityId(), &AZ::TransformBus::Events::GetWorldTM); + AZ::Vector3 nonUniformScale = AZ::Vector3::CreateOne(); + AZ::NonUniformScaleRequestBus::EventResult(nonUniformScale, GetEntityId(), &AZ::NonUniformScaleRequests::GetScale); + AZ::Vector3 ignoreNormal; - return m_controller.GetModel()->RayIntersection(transform, src, dir, distance, ignoreNormal); + return m_controller.GetModel()->RayIntersection(transform, nonUniformScale, src, dir, distance, ignoreNormal); } bool EditorMeshComponent::SupportsEditorRayIntersect() diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index 88b0e812d2..b0315fdf9c 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -188,6 +188,11 @@ namespace AZ m_meshFeatureProcessor = RPI::Scene::GetFeatureProcessorForEntity(m_entityId); AZ_Error("MeshComponentController", m_meshFeatureProcessor, "Unable to find a MeshFeatureProcessorInterface on the entityId."); + m_cachedNonUniformScale = AZ::Vector3::CreateOne(); + AZ::NonUniformScaleRequestBus::EventResult(m_cachedNonUniformScale, m_entityId, &AZ::NonUniformScaleRequests::GetScale); + AZ::NonUniformScaleRequestBus::Event(m_entityId, &AZ::NonUniformScaleRequests::RegisterScaleChangedEvent, + m_nonUniformScaleChangedHandler); + MeshComponentRequestBus::Handler::BusConnect(m_entityId); TransformNotificationBus::Handler::BusConnect(m_entityId); MaterialReceiverRequestBus::Handler::BusConnect(m_entityId); @@ -209,6 +214,8 @@ namespace AZ MaterialReceiverRequestBus::Handler::BusDisconnect(); MaterialComponentNotificationBus::Handler::BusDisconnect(); + m_nonUniformScaleChangedHandler.Disconnect(); + m_meshFeatureProcessor = nullptr; m_transformInterface = nullptr; m_entityId = AZ::EntityId(AZ::EntityId::InvalidEntityId); @@ -229,7 +236,16 @@ namespace AZ { if (m_meshFeatureProcessor) { - m_meshFeatureProcessor->SetTransform(m_meshHandle, world); + m_meshFeatureProcessor->SetTransform(m_meshHandle, world, m_cachedNonUniformScale); + } + } + + void MeshComponentController::HandleNonUniformScaleChange(const AZ::Vector3& nonUniformScale) + { + m_cachedNonUniformScale = nonUniformScale; + if (m_meshFeatureProcessor) + { + m_meshFeatureProcessor->SetTransform(m_meshHandle, m_transformInterface->GetWorldTM(), m_cachedNonUniformScale); } } @@ -275,8 +291,9 @@ namespace AZ m_meshHandle = m_meshFeatureProcessor->AcquireMesh(m_configuration.m_modelAsset, materials); m_meshFeatureProcessor->ConnectModelChangeEventHandler(m_meshHandle, m_changeEventHandler); - const AZ::Transform& transform = m_transformInterface ? m_transformInterface->GetWorldTM() : Transform::Identity(); - m_meshFeatureProcessor->SetTransform(m_meshHandle, transform); + const AZ::Transform& transform = m_transformInterface ? m_transformInterface->GetWorldTM() : AZ::Transform::CreateIdentity(); + + m_meshFeatureProcessor->SetTransform(m_meshHandle, transform, m_cachedNonUniformScale); m_meshFeatureProcessor->SetSortKey(m_meshHandle, m_configuration.m_sortKey); m_meshFeatureProcessor->SetLodOverride(m_meshHandle, m_configuration.m_lodOverride); m_meshFeatureProcessor->SetExcludeFromReflectionCubeMaps(m_meshHandle, m_configuration.m_excludeFromReflectionCubeMaps); @@ -413,7 +430,16 @@ namespace AZ Aabb MeshComponentController::GetLocalBounds() { const Data::Instance model = GetModel(); - return model ? model->GetAabb() : Aabb::CreateNull(); + if (model) + { + Aabb aabb = model->GetAabb(); + aabb.MultiplyByScale(m_cachedNonUniformScale); + return aabb; + } + else + { + return Aabb::CreateNull(); + } } } // namespace Render } // namespace AZ diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h index 357f1ded6c..afdcfa25c7 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h @@ -14,6 +14,7 @@ #include #include +#include #include @@ -122,17 +123,25 @@ namespace AZ void UnregisterModel(); void RefreshModelRegistration(); + void HandleNonUniformScaleChange(const AZ::Vector3& nonUniformScale); + Render::MeshFeatureProcessorInterface* m_meshFeatureProcessor = nullptr; Render::MeshFeatureProcessorInterface::MeshHandle m_meshHandle; TransformInterface* m_transformInterface = nullptr; AZ::EntityId m_entityId; bool m_isVisible = true; MeshComponentConfig m_configuration; + AZ::Vector3 m_cachedNonUniformScale = AZ::Vector3::CreateOne(); MeshFeatureProcessorInterface::ModelChangedEvent::Handler m_changeEventHandler { [&](Data::Instance model) { HandleModelChange(model); } }; + + AZ::NonUniformScaleChangedEvent::Handler m_nonUniformScaleChangedHandler + { + [&](const AZ::Vector3& nonUniformScale) { HandleNonUniformScaleChange(nonUniformScale); } + }; }; } // namespace Render diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/atomlyintegration_commonfeatures_editor_files.cmake b/Gems/AtomLyIntegration/CommonFeatures/Code/atomlyintegration_commonfeatures_editor_files.cmake index f77b175cd7..fe475da189 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/atomlyintegration_commonfeatures_editor_files.cmake +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/atomlyintegration_commonfeatures_editor_files.cmake @@ -41,6 +41,8 @@ set(FILES Source/Material/EditorMaterialModelUvNameMapInspector.h Source/Material/EditorMaterialSystemComponent.cpp Source/Material/EditorMaterialSystemComponent.h + Source/Material/MaterialBrowserInteractions.h + Source/Material/MaterialBrowserInteractions.cpp Source/Material/MaterialThumbnail.cpp Source/Material/MaterialThumbnail.h Source/Mesh/EditorMeshComponent.h diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Atom/Scripts/Python/DCC_Materials/pbr.material b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Atom/Scripts/Python/DCC_Materials/pbr.material index 4bf22b8762..94fc5a16bd 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Atom/Scripts/Python/DCC_Materials/pbr.material +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Atom/Scripts/Python/DCC_Materials/pbr.material @@ -4,10 +4,9 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "factor": 1.0, - "useTexture": true, - "textureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif" + "occlusion": { + "diffuseFactor": 1.0, + "diffuseTextureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif" }, "baseColor": { "color": [ 1.0, 1.0, 1.0 ], diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/dcc_materials/pbr.material b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/dcc_materials/pbr.material index 4bf22b8762..94fc5a16bd 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/dcc_materials/pbr.material +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/dcc_materials/pbr.material @@ -4,10 +4,9 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "factor": 1.0, - "useTexture": true, - "textureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif" + "occlusion": { + "diffuseFactor": 1.0, + "diffuseTextureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif" }, "baseColor": { "color": [ 1.0, 1.0, 1.0 ], diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/standardPBR.template.material b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/standardPBR.template.material index 5632c6fc0d..cc2c548174 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/standardPBR.template.material +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/standardPBR.template.material @@ -7,10 +7,13 @@ "general": { "texcoord": 0 }, - "ambientOcclusion": { - "factor": 1.0, - "useTexture": false, - "textureMap": "" + "occlusion": { + "diffuseFactor": 1.0, + "diffuseUseTexture": false, + "diffuseTextureMap": "", + "specularFactor": 1.0, + "specularUseTexture": false, + "specularTextureMap": "" }, "baseColor": { "color": [ diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/standardPBR.template.material b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/standardPBR.template.material index 1ac6fb2fcb..78891d6c46 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/standardPBR.template.material +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/standardPBR.template.material @@ -7,10 +7,13 @@ "general": { "texcoord": 0 }, - "ambientOcclusion": { - "factor": 1.0, - "useTexture": false, - "textureMap": "" + "occlusion": { + "diffuseFactor": 1.0, + "diffuseUseTexture": false, + "diffuseTextureMap": "", + "specularFactor": 1.0, + "specularUseTexture": false, + "specularTextureMap": "" }, "baseColor": { "color": [ diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/maya_dcc_materials/standardpbr.template.material b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/maya_dcc_materials/standardpbr.template.material index 4bf22b8762..30d895f9ac 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/maya_dcc_materials/standardpbr.template.material +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/maya_dcc_materials/standardpbr.template.material @@ -4,10 +4,13 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "factor": 1.0, - "useTexture": true, - "textureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif" + "occlusion": { + "diffuseFactor": 1.0, + "diffuseUseTexture": true, + "diffuseTextureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif", + "specularFactor": 1.0, + "specularUseTexture": true, + "specularTextureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif" }, "baseColor": { "color": [ 1.0, 1.0, 1.0 ], diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/stingraypbs_converter/StandardPBR_AllProperties.material b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/stingraypbs_converter/StandardPBR_AllProperties.material index 4bf22b8762..00ff63829f 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/stingraypbs_converter/StandardPBR_AllProperties.material +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/stingraypbs_converter/StandardPBR_AllProperties.material @@ -4,10 +4,13 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "factor": 1.0, - "useTexture": true, - "textureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif" + "occlusion": { + "diffuseFactor": 1.0, + "diffuseUseTexture": false, + "diffuseTextureMap": "", + "specularFactor": 1.0, + "specularUseTexture": false, + "specularTextureMap": "" }, "baseColor": { "color": [ 1.0, 1.0, 1.0 ], diff --git a/Gems/Blast/Code/Source/Family/ActorRenderManager.cpp b/Gems/Blast/Code/Source/Family/ActorRenderManager.cpp index deb6362ee3..74bba48d3c 100644 --- a/Gems/Blast/Code/Source/Family/ActorRenderManager.cpp +++ b/Gems/Blast/Code/Source/Family/ActorRenderManager.cpp @@ -74,10 +74,7 @@ namespace Blast { if (m_chunkActors[chunkId]) { - auto transform = m_chunkActors[chunkId]->GetWorldBody()->GetTransform(); - // Multiply by scale because the transform on the world body does not store scale - transform.MultiplyByScale(m_scale); - m_meshFeatureProcessor->SetTransform(m_chunkMeshHandles[chunkId], transform); + m_meshFeatureProcessor->SetTransform(m_chunkMeshHandles[chunkId], m_chunkActors[chunkId]->GetWorldBody()->GetTransform(), m_scale); } } } diff --git a/Gems/Blast/Code/Tests/ActorRenderManagerTest.cpp b/Gems/Blast/Code/Tests/ActorRenderManagerTest.cpp index 4036023397..114721a095 100644 --- a/Gems/Blast/Code/Tests/ActorRenderManagerTest.cpp +++ b/Gems/Blast/Code/Tests/ActorRenderManagerTest.cpp @@ -114,7 +114,7 @@ namespace Blast // ActorRenderManager::SyncMeshes { - EXPECT_CALL(*m_mockMeshFeatureProcessor, SetTransform(_, _)) + EXPECT_CALL(*m_mockMeshFeatureProcessor, SetTransform(_, _, _)) .Times(aznumeric_cast(m_actorFactory->m_mockActors[0]->GetChunkIndices().size())); actorRenderManager->SyncMeshes(); } diff --git a/Gems/Blast/Editor/Scripts/bootstrap.py b/Gems/Blast/Editor/Scripts/bootstrap.py index 8614cb7d1d..3837383a89 100755 --- a/Gems/Blast/Editor/Scripts/bootstrap.py +++ b/Gems/Blast/Editor/Scripts/bootstrap.py @@ -9,5 +9,5 @@ remove or modify any license notices. This file is distributed on an "AS IS" BAS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. """ -# LYN-652 to re-enable the next line +# LYN-652 to re-enable once the Blast gem tests are stable # import asset_builder_blast diff --git a/Gems/Camera/Code/Source/Camera_precompiled.h b/Gems/Camera/Code/Source/Camera_precompiled.h index 028ff586c6..2016c4b411 100644 --- a/Gems/Camera/Code/Source/Camera_precompiled.h +++ b/Gems/Camera/Code/Source/Camera_precompiled.h @@ -26,7 +26,6 @@ // Editor ///////////////////////////////////////////////////////////////////////////// #include -#include #include ///////////////////////////////////////////////////////////////////////////// diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/MotionData/NonUniformMotionData.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/MotionData/NonUniformMotionData.cpp index fbe8a78cba..8a58300b88 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/MotionData/NonUniformMotionData.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/MotionData/NonUniformMotionData.cpp @@ -258,8 +258,16 @@ namespace EMotionFX } else if (!timeValues.empty()) { - if (!AZ::IsClose(timeValues.front(), startTime, AZ::Constants::FloatEpsilon) || !AZ::IsClose(timeValues.back(), endTime, AZ::Constants::FloatEpsilon)) + if (!AZ::IsClose(timeValues.front(), startTime, AZ::Constants::FloatEpsilon)) { + AZ_Error("EMotionFX", false, "No keyframe present at the start of the animation (%f). The first keyframe is at %f.", + startTime, timeValues.front()); + return false; + } + if (!AZ::IsClose(timeValues.back(), endTime, AZ::Constants::FloatEpsilon)) + { + AZ_Error("EMotionFX", false, "No keyframe present at the end of the animation (%f). The last keyframe is at %f.", + endTime, timeValues.back()); return false; } } @@ -271,14 +279,25 @@ namespace EMotionFX { for (const JointData& jointData : m_jointData) { - if ((jointData.m_positionTrack.m_times.size() != jointData.m_positionTrack.m_values.size()) || (jointData.m_rotationTrack.m_times.size() != jointData.m_rotationTrack.m_values.size())) + if (jointData.m_positionTrack.m_times.size() != jointData.m_positionTrack.m_values.size()) + { + AZ_Error("EMotionFX", false, "Number of position keyframe times (%d) does not match the number of keyframe values (%d).", + jointData.m_positionTrack.m_times.size(), jointData.m_positionTrack.m_values.size()); + return false; + } + + if (jointData.m_rotationTrack.m_times.size() != jointData.m_rotationTrack.m_values.size()) { + AZ_Error("EMotionFX", false, "Number of rotation keyframe times (%d) does not match the number of keyframe values (%d).", + jointData.m_rotationTrack.m_times.size(), jointData.m_rotationTrack.m_values.size()); return false; } #ifndef EMFX_SCALE_DISABLED if (jointData.m_scaleTrack.m_times.size() != jointData.m_scaleTrack.m_values.size()) { + AZ_Error("EMotionFX", false, "Number of scale keyframe times (%d) does not match the number of keyframe values (%d).", + jointData.m_scaleTrack.m_times.size(), jointData.m_scaleTrack.m_values.size()); return false; } @@ -288,7 +307,8 @@ namespace EMotionFX } #endif - if (!VerifyKeyTrackTimeIntegrity(jointData.m_positionTrack.m_times) || !VerifyKeyTrackTimeIntegrity(jointData.m_rotationTrack.m_times)) + if (!VerifyKeyTrackTimeIntegrity(jointData.m_positionTrack.m_times) || + !VerifyKeyTrackTimeIntegrity(jointData.m_rotationTrack.m_times)) { return false; } @@ -300,7 +320,8 @@ namespace EMotionFX bool firstCheck = true; for (const JointData& jointData : m_jointData) { - if (!VerifyStartEndTimeIntegrity(jointData.m_positionTrack.m_times, firstCheck, startTime, endTime) || !VerifyStartEndTimeIntegrity(jointData.m_rotationTrack.m_times, firstCheck, startTime, endTime)) + if (!VerifyStartEndTimeIntegrity(jointData.m_positionTrack.m_times, firstCheck, startTime, endTime) || + !VerifyStartEndTimeIntegrity(jointData.m_rotationTrack.m_times, firstCheck, startTime, endTime)) { return false; } @@ -317,6 +338,8 @@ namespace EMotionFX { if (morphData.m_track.m_times.size() != morphData.m_track.m_values.size()) { + AZ_Error("EMotionFX", false, "Number of morph keyframe times (%d) does not match the number of keyframe values (%d).", + morphData.m_track.m_times.size(), morphData.m_track.m_values.size()); return false; } @@ -333,7 +356,17 @@ namespace EMotionFX for (const FloatData& floatData : m_floatData) { - if (floatData.m_track.m_times.size() != floatData.m_track.m_values.size() || !VerifyStartEndTimeIntegrity(floatData.m_track.m_times, firstCheck, startTime, endTime) || !VerifyKeyTrackTimeIntegrity(floatData.m_track.m_times)) + if (floatData.m_track.m_times.size() != floatData.m_track.m_values.size()) + { + AZ_Error("EMotionFX", false, "Number of float keyframe times (%d) does not match the number of keyframe values (%d).", + floatData.m_track.m_times.size(), floatData.m_track.m_values.size()); + return false; + } + if (!VerifyStartEndTimeIntegrity(floatData.m_track.m_times, firstCheck, startTime, endTime)) + { + return false; + } + if (!VerifyKeyTrackTimeIntegrity(floatData.m_track.m_times)) { return false; } @@ -657,6 +690,8 @@ namespace EMotionFX { if (curTime < prevKeyTime) { + AZ_Error("EMotionFX", false, "Keyframe times need to be ascending. Current keyframe time (%f) is smaller than the previous (%f).", + curTime, prevKeyTime); return false; } prevKeyTime = curTime; diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/DockWidgetPlugin.cpp b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/DockWidgetPlugin.cpp index 6b8b22f78c..c10e3b06e2 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/DockWidgetPlugin.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/DockWidgetPlugin.cpp @@ -119,9 +119,7 @@ namespace EMStudio mDock->setFeatures(features); - // mDock->setFloating( true ); mainWindow->addDockWidget(Qt::RightDockWidgetArea, mDock); - mainWindow->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North); // put tabs on top? return mDock; } @@ -139,4 +137,4 @@ namespace EMStudio return widget; } -} // namespace EMStudio \ No newline at end of file +} // namespace EMStudio diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/MainWindow.cpp b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/MainWindow.cpp index 5adec5e0a4..496b6b8e94 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/MainWindow.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/MainWindow.cpp @@ -1866,6 +1866,12 @@ namespace EMStudio // add each layout in the remove menu for (uint32 i = 0; i < numLayoutNames; ++i) { + // User cannot remove the default layout. This layout is referenced in the qrc file, removing it will + // cause compiling issue too. + if (mLayoutNames[i] == "AnimGraph") + { + continue; + } QAction* action = removeMenu->addAction(mLayoutNames[i].c_str()); connect(action, &QAction::triggered, this, &MainWindow::OnRemoveLayout); } diff --git a/Gems/Gestures/Code/CMakeLists.txt b/Gems/Gestures/Code/CMakeLists.txt index fe0fd9d98b..c05b39b72c 100644 --- a/Gems/Gestures/Code/CMakeLists.txt +++ b/Gems/Gestures/Code/CMakeLists.txt @@ -20,6 +20,9 @@ ly_add_target( PUBLIC Include BUILD_DEPENDENCIES + PUBLIC + Gem::Atom_RPI.Public + AZ::AtomCore PRIVATE Legacy::CryCommon ) diff --git a/Gems/Gestures/Code/Include/Gestures/IGestureRecognizer.h b/Gems/Gestures/Code/Include/Gestures/IGestureRecognizer.h index 3f71cd4b62..4b5b7726d8 100644 --- a/Gems/Gestures/Code/Include/Gestures/IGestureRecognizer.h +++ b/Gems/Gestures/Code/Include/Gestures/IGestureRecognizer.h @@ -19,6 +19,9 @@ #include #include +#include +#include + //////////////////////////////////////////////////////////////////////////////////////////////////// namespace Gestures { @@ -184,8 +187,16 @@ namespace Gestures return; } - const AZ::Vector2 eventScreenPositionPixels = positionData2D->ConvertToScreenSpaceCoordinates(static_cast(gEnv->pRenderer->GetWidth()), - static_cast(gEnv->pRenderer->GetHeight())); + auto atomViewportRequests = AZ::Interface::Get(); + AZ::RPI::ViewportContextPtr viewportContext = atomViewportRequests->GetDefaultViewportContext(); + if (viewportContext == nullptr) + { + return; + } + + AzFramework::WindowSize windowSize = viewportContext->GetViewportSize(); + const AZ::Vector2 eventScreenPositionPixels = positionData2D->ConvertToScreenSpaceCoordinates(static_cast(windowSize.m_width), + static_cast(windowSize.m_height)); if (inputChannel.IsStateBegan()) { o_hasBeenConsumed = OnPressedEvent(eventScreenPositionPixels, pointerIndex); @@ -225,8 +236,16 @@ namespace Gestures //////////////////////////////////////////////////////////////////////////////////////////////// inline void IRecognizer::UpdateNormalizedPositionAndDeltaFromScreenPosition(const AZ::Vector2& screenPositionPixels) { - const AZ::Vector2 normalizedPosition(screenPositionPixels.GetX() / static_cast(gEnv->pRenderer->GetWidth()), - screenPositionPixels.GetY() / static_cast(gEnv->pRenderer->GetHeight())); + auto atomViewportRequests = AZ::Interface::Get(); + AZ::RPI::ViewportContextPtr viewportContext = atomViewportRequests->GetDefaultViewportContext(); + if (viewportContext == nullptr) + { + return; + } + + AzFramework::WindowSize windowSize = viewportContext->GetViewportSize(); + const AZ::Vector2 normalizedPosition(screenPositionPixels.GetX() / static_cast(windowSize.m_width), + screenPositionPixels.GetY() / static_cast(windowSize.m_height)); AzFramework::InputChannel::PositionData2D::UpdateNormalizedPositionAndDelta(normalizedPosition); } } diff --git a/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYCommonMenu.cpp b/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYCommonMenu.cpp index c157189400..6a00990ffa 100644 --- a/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYCommonMenu.cpp +++ b/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYCommonMenu.cpp @@ -539,8 +539,8 @@ namespace ImGui { int assertLevelValue = gAssertLevelCVAR->GetIVal(); int dragIntVal = assertLevelValue; - ImGui::Text("sys_asserts: %d ( 0-off | 1-log | 2-popup )", assertLevelValue); - ImGui::SliderInt("##sys_asserts", &dragIntVal, 0, 2); + ImGui::Text("sys_asserts: %d ( 0-off | 1-log | 2-popup | 3-crash )", assertLevelValue); + ImGui::SliderInt("##sys_asserts", &dragIntVal, 0, 3); if (dragIntVal != assertLevelValue) { gAssertLevelCVAR->Set(dragIntVal); diff --git a/Gems/LyShine/Code/Editor/ViewportDragInteraction.h b/Gems/LyShine/Code/Editor/ViewportDragInteraction.h index f7574900a2..477720d0a2 100644 --- a/Gems/LyShine/Code/Editor/ViewportDragInteraction.h +++ b/Gems/LyShine/Code/Editor/ViewportDragInteraction.h @@ -12,7 +12,7 @@ #pragma once #include -#include +#include //! Abstract base class for drag interactions in the UI Editor viewport window. class ViewportDragInteraction diff --git a/Gems/LyShine/Code/Editor/ViewportHelpers.h b/Gems/LyShine/Code/Editor/ViewportHelpers.h index d128603171..9a1aadead5 100644 --- a/Gems/LyShine/Code/Editor/ViewportHelpers.h +++ b/Gems/LyShine/Code/Editor/ViewportHelpers.h @@ -11,6 +11,8 @@ */ #pragma once +#include + namespace ViewportHelpers { //------------------------------------------------------------------------------- diff --git a/Gems/LyShine/Code/Editor/ViewportIcon.cpp b/Gems/LyShine/Code/Editor/ViewportIcon.cpp index 5ce2bf37f7..1e137fe91b 100644 --- a/Gems/LyShine/Code/Editor/ViewportIcon.cpp +++ b/Gems/LyShine/Code/Editor/ViewportIcon.cpp @@ -12,25 +12,34 @@ #include "UiCanvasEditor_precompiled.h" #include "EditorCommon.h" +#include + +#include +#include ViewportIcon::ViewportIcon(const char* textureFilename) - : m_texture(gEnv->pRenderer->EF_LoadTexture(textureFilename, FT_DONT_STREAM)) { + m_image = CDraw2d::LoadTexture(textureFilename); } ViewportIcon::~ViewportIcon() { - gEnv->pRenderer->RemoveTexture(m_texture->GetTextureID()); } AZ::Vector2 ViewportIcon::GetTextureSize() const { - return AZ::Vector2(aznumeric_cast(m_texture->GetWidth()), aznumeric_cast(m_texture->GetHeight())); + if (m_image) + { + AZ::RHI::Size size = m_image->GetDescriptor().m_size; + return AZ::Vector2(size.m_width, size.m_height); + } + + return AZ::Vector2(0.0f, 0.0f); } void ViewportIcon::DrawImageAligned(Draw2dHelper& draw2d, AZ::Vector2& pivot, float opacity) { - draw2d.DrawImageAligned(m_texture->GetTextureID(), + draw2d.DrawImageAligned(m_image, pivot, GetTextureSize(), IDraw2d::HAlign::Center, @@ -43,7 +52,7 @@ void ViewportIcon::DrawImageTiled(Draw2dHelper& draw2d, IDraw2d::VertexPosColUV* // Use default blending and rounding modes int blendMode = GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA; IDraw2d::Rounding rounding = IDraw2d::Rounding::Nearest; - draw2d.DrawQuad(m_texture->GetTextureID(), verts, blendMode, rounding); + draw2d.DrawQuad(m_image, verts, blendMode, rounding); } void ViewportIcon::DrawAxisAlignedBoundingBox(Draw2dHelper& draw2d, AZ::Vector2 bound0, AZ::Vector2 bound1) @@ -73,7 +82,7 @@ void ViewportIcon::DrawAxisAlignedBoundingBox(Draw2dHelper& draw2d, AZ::Vector2 verts[0].uv = AZ::Vector2(0.0f, 0.5f); verts[1].uv = AZ::Vector2(endTexCoordU, 0.5f); - draw2d.DrawLineTextured(m_texture->GetTextureID(), verts); + draw2d.DrawLineTextured(m_image, verts); } // bound0 @@ -89,7 +98,7 @@ void ViewportIcon::DrawAxisAlignedBoundingBox(Draw2dHelper& draw2d, AZ::Vector2 verts[0].uv = AZ::Vector2(0.0f, 0.5f); verts[1].uv = AZ::Vector2(endTexCoordV, 0.5f); - draw2d.DrawLineTextured(m_texture->GetTextureID(), verts); + draw2d.DrawLineTextured(m_image, verts); } // bound0 @@ -105,7 +114,7 @@ void ViewportIcon::DrawAxisAlignedBoundingBox(Draw2dHelper& draw2d, AZ::Vector2 verts[0].uv = AZ::Vector2(0.0f, 0.5f); verts[1].uv = AZ::Vector2(endTexCoordU, 0.5f); - draw2d.DrawLineTextured(m_texture->GetTextureID(), verts); + draw2d.DrawLineTextured(m_image, verts); } // bound0 @@ -121,7 +130,7 @@ void ViewportIcon::DrawAxisAlignedBoundingBox(Draw2dHelper& draw2d, AZ::Vector2 verts[0].uv = AZ::Vector2(0.0f, 0.5f); verts[1].uv = AZ::Vector2(endTexCoordV, 0.5f); - draw2d.DrawLineTextured(m_texture->GetTextureID(), verts); + draw2d.DrawLineTextured(m_image, verts); } } @@ -189,7 +198,7 @@ void ViewportIcon::Draw(Draw2dHelper& draw2d, AZ::Vector2 anchorPos, const AZ::M verts[3].position = originPos - widthVec * originRatio.GetX() + heightVec * (1.0f - originRatio.GetY()); } - draw2d.DrawQuad(m_texture->GetTextureID(), verts); + draw2d.DrawQuad(m_image, verts); } void ViewportIcon::DrawAnchorLines(Draw2dHelper& draw2d, AZ::Vector2 anchorPos, AZ::Vector2 targetPos, const AZ::Matrix4x4& transform, @@ -252,7 +261,7 @@ void ViewportIcon::DrawDistanceLine(Draw2dHelper& draw2d, AZ::Vector2 start, AZ: verts[1].color = dottedColor; verts[1].uv = AZ::Vector2(endTexCoordU, 0.5f); - draw2d.DrawLineTextured(m_texture->GetTextureID(), verts); + draw2d.DrawLineTextured(m_image, verts); // Now draw the text rotated to match the angle of the line and slightly offset from the center point @@ -379,7 +388,7 @@ void ViewportIcon::DrawElementRectOutline([[maybe_unused]] Draw2dHelper& draw2d, float rectHeight = heightVec.GetLength(); // the outline "width" will be based on the texture height - int textureHeight = m_texture->GetHeight(); + float textureHeight = GetTextureSize().GetY(); if (textureHeight <= 0) { return; // should never happen - avoiding possible divide by zero later @@ -464,6 +473,7 @@ void ViewportIcon::DrawElementRectOutline([[maybe_unused]] Draw2dHelper& draw2d, 5, 1, 7, 1, 7, 3, // right quad }; +#ifdef LYSHINE_ATOM_TODO IRenderer* renderer = gEnv->pRenderer; renderer->SetTexture(m_texture->GetTextureID()); @@ -472,4 +482,7 @@ void ViewportIcon::DrawElementRectOutline([[maybe_unused]] Draw2dHelper& draw2d, // This will end up using DrawIndexedPrimitive to render the quad renderer->DrawDynVB(vertices, indicies, NUM_VERTS, NUM_INDICES, prtTriangleList); +#else + // LYSHINE_ATOM_TODO - add option in Draw2d to draw indexed primitive for this textured element outline +#endif } diff --git a/Gems/LyShine/Code/Editor/ViewportIcon.h b/Gems/LyShine/Code/Editor/ViewportIcon.h index 5f72c7562a..85fd2fe068 100644 --- a/Gems/LyShine/Code/Editor/ViewportIcon.h +++ b/Gems/LyShine/Code/Editor/ViewportIcon.h @@ -11,6 +11,8 @@ */ #pragma once +#include + class ViewportIcon { public: @@ -48,6 +50,5 @@ public: void DrawElementRectOutline(Draw2dHelper& draw2d, AZ::EntityId entityId, AZ::Color color); private: - - ITexture* m_texture; + AZ::Data::Instance m_image; }; diff --git a/Gems/LyShine/Code/Editor/ViewportWidget.cpp b/Gems/LyShine/Code/Editor/ViewportWidget.cpp index c805d45bef..2b1ea16c97 100644 --- a/Gems/LyShine/Code/Editor/ViewportWidget.cpp +++ b/Gems/LyShine/Code/Editor/ViewportWidget.cpp @@ -21,6 +21,7 @@ #include #include +#include #include "LyShine.h" #include "UiRenderer.h" @@ -277,6 +278,8 @@ void ViewportWidget::InitUiRenderer() // Only one viewport/renderer is currently supported in the UI Editor CLyShine* lyShine = static_cast(gEnv->pLyShine); lyShine->SetUiRendererForEditor(m_uiRenderer); + + m_draw2d = AZStd::make_shared(GetViewportContext()); } ViewportInteraction* ViewportWidget::GetViewportInteraction() @@ -914,7 +917,7 @@ void ViewportWidget::RenderEditMode(float deltaTime) return; // this can happen if a render happens during a restart } - Draw2dHelper draw2d; // sets and resets 2D draw mode in constructor/destructor + Draw2dHelper draw2d(m_draw2d.get()); // sets and resets 2D draw mode in constructor/destructor QTreeWidgetItemRawPtrQList selection = m_editorWindow->GetHierarchy()->selectedItems(); @@ -1142,7 +1145,7 @@ void ViewportWidget::RenderPreviewMode(float deltaTime) AZ::Vector2 topLeftInViewportSpace = CanvasHelpers::GetViewportPoint(canvasEntityId, AZ::Vector2(0.0f, 0.0f)); AZ::Vector2 bottomRightInViewportSpace = CanvasHelpers::GetViewportPoint(canvasEntityId, canvasSize); AZ::Vector2 sizeInViewportSpace = bottomRightInViewportSpace - topLeftInViewportSpace; - Draw2dHelper draw2d; + Draw2dHelper draw2d(m_draw2d.get()) int texId = gEnv->pRenderer->GetBlackTextureId(); draw2d.DrawImage(texId, topLeftInViewportSpace, sizeInViewportSpace); #endif diff --git a/Gems/LyShine/Code/Editor/ViewportWidget.h b/Gems/LyShine/Code/Editor/ViewportWidget.h index e506a26d88..4d15f3dea4 100644 --- a/Gems/LyShine/Code/Editor/ViewportWidget.h +++ b/Gems/LyShine/Code/Editor/ViewportWidget.h @@ -25,6 +25,7 @@ class RulerWidget; class QMimeData; class UiRenderer; +class CDraw2d; class ViewportWidget : public AtomToolsFramework::RenderViewportWidget @@ -201,4 +202,5 @@ private: // data bool m_fontTextureHasChanged = false; AZStd::shared_ptr m_uiRenderer; + AZStd::shared_ptr m_draw2d; }; diff --git a/Gems/LyShine/Code/Include/LyShine/Draw2d.h b/Gems/LyShine/Code/Include/LyShine/Draw2d.h new file mode 100644 index 0000000000..ec636c3e3b --- /dev/null +++ b/Gems/LyShine/Code/Include/LyShine/Draw2d.h @@ -0,0 +1,517 @@ +/* +* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +* its licensors. +* +* For complete copyright and license terms please see the LICENSE at the root of this +* distribution (the "License"). All use of this software is governed by the License, +* or, if provided, by the license below or the license accompanying this file. Do not +* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* +*/ +#pragma once + +#include +#include + +#include +#include +#include +#include + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//! Implementation of IDraw2d interface for 2D drawing in screen space +// +//! The CDraw2d class implements the IDraw2d interface for drawing 2D images, shapes and text. +//! Positions and sizes are specified in pixels in the associated 2D viewport. +class CDraw2d + : public IDraw2d // LYSHINE_ATOM_TODO - keep around until gEnv->pLyShine is replaced by bus interface + , public AZ::Render::Bootstrap::NotificationBus::Handler +{ +public: // member functions + + //! Constructor, constructed by the LyShine class + CDraw2d(AZ::RPI::ViewportContextPtr viewportContext = nullptr); + + // IDraw2d + + ~CDraw2d() override; + + // ~IDraw2d + + //! Draw a textured quad with the top left corner at the given position. + // + //! The image is drawn with the color specified by SetShapeColor and the opacity + //! passed as an argument. + //! If rotation is non-zero then the quad is rotated. If the pivot point is + //! provided then the points of the quad are rotated about that point, otherwise + //! they are rotated about the top left corner of the quad. + //! \param texId The texture ID returned by ITexture::GetTextureID() + //! \param position Position of the top left corner of the quad (before rotation) in pixels + //! \param size The width and height of the quad. Use texture width and height to avoid minification, + //! magnification or stretching (assuming the minMaxTexCoords are left to the default) + //! \param opacity The alpha value used when blending + //! \param rotation Angle of rotation in degrees counter-clockwise + //! \param pivotPoint The point about which the quad is rotated + //! \param minMaxTexCoords An optional two component array. The first component is the UV coord for the top left + //! point of the quad and the second is the UV coord of the bottom right point of the quad + //! \param imageOptions Optional struct specifying options that tend to be the same from call to call + void DrawImage(AZ::Data::Instance image, AZ::Vector2 position, AZ::Vector2 size, float opacity = 1.0f, + float rotation = 0.0f, const AZ::Vector2* pivotPoint = nullptr, const AZ::Vector2* minMaxTexCoords = nullptr, + ImageOptions* imageOptions = nullptr); + + //! Draw a textured quad where the position specifies the point specified by the alignment. + // + //! Rotation is always around the position. + //! \param texId The texture ID returned by ITexture::GetTextureID() + //! \param position Position align point of the quad (before rotation) in pixels + //! \param size The width and height of the quad. Use texture width and height to avoid minification, + //! magnification or stretching (assuming the minMaxTexCoords are left to the default) + //! \param horizontalAlignment Specifies how the quad is horizontally aligned to the given position + //! \param verticalAlignment Specifies how the quad is vertically aligned to the given position + //! \param opacity The alpha value used when blending + //! \param rotation Angle of rotation in degrees counter-clockwise + //! \param minMaxTexCoords An optional two component array. The first component is the UV coord for the top left + //! point of the quad and the second is the UV coord of the bottom right point of the quad + //! \param imageOptions Optional struct specifying options that tend to be the same from call to call + void DrawImageAligned(AZ::Data::Instance image, AZ::Vector2 position, AZ::Vector2 size, + HAlign horizontalAlignment, VAlign verticalAlignment, + float opacity = 1.0f, float rotation = 0.0f, const AZ::Vector2* minMaxTexCoords = nullptr, + ImageOptions* imageOptions = nullptr); + + //! Draw a textured quad where the position, color and uv of each point is specified explicitly + // + //! \param texId The texture ID returned by ITexture::GetTextureID() + //! \param verts An array of 4 vertices, in clockwise order (e.g. top left, top right, bottom right, bottom left) + //! \param blendMode UseDefault means default blend mode (currently GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA) + //! \param pixelRounding Whether and how to round pixel coordinates + //! \param baseState Additional render state to pass to or into value passed to renderer SetState + virtual void DrawQuad(AZ::Data::Instance image, + VertexPosColUV* verts, + int blendMode = UseDefault, + Rounding pixelRounding = Rounding::Nearest, + int baseState = UseDefault); + + //! Draw a line + // + //! \param start The start position + //! \param end The end position + //! \param color The color of the line + //! \param blendMode UseDefault means default blend mode (currently GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA) + //! \param pixelRounding Whether and how to round pixel coordinates + //! \param baseState Additional render state to pass to or into value passed to renderer SetState + virtual void DrawLine(AZ::Vector2 start, AZ::Vector2 end, AZ::Color color, + int blendMode = UseDefault, + IDraw2d::Rounding pixelRounding = IDraw2d::Rounding::Nearest, + int baseState = UseDefault); + + //! Draw a line with a texture so it can be dotted or dashed + // + //! \param texId The texture ID returned by ITexture::GetTextureID() + //! \param verts An array of 2 vertices for the start and end points of the line + //! \param blendMode UseDefault means default blend mode (currently GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA) + //! \param pixelRounding Whether and how to round pixel coordinates + //! \param baseState Additional render state to pass to or into value passed to renderer SetState + virtual void DrawLineTextured(AZ::Data::Instance image, + VertexPosColUV* verts, + int blendMode = UseDefault, + IDraw2d::Rounding pixelRounding = IDraw2d::Rounding::Nearest, + int baseState = UseDefault); + //! Draw a text string. Only supports ASCII text. + // + //! The font and effect used to render the text are specified in the textOptions structure + //! \param textString A null terminated ASCII text string. May contain \n characters + //! \param position Position of the text in pixels. Alignment values in textOptions affect actual position + //! \param pointSize The size of the font to use + //! \param opacity The opacity (alpha value) to use to draw the text + //! \param textOptions Pointer to an options struct. If null the default options are used + void DrawText(const char* textString, AZ::Vector2 position, float pointSize, + float opacity = 1.0f, TextOptions* textOptions = nullptr); + + //! Get the width and height (in pixels) that would be used to draw the given text string. + // + //! Pass the same parameter values that would be used to draw the string + AZ::Vector2 GetTextSize(const char* textString, float pointSize, TextOptions* textOptions = nullptr); + + //! Get the width of the rendering viewport (in pixels). + float GetViewportWidth() const; + + //! Get the height of the rendering viewport (in pixels). + float GetViewportHeight() const; + + //! Get the default values that would be used if no image options were passed in + // + //! This is a convenient way to initialize the imageOptions struct + virtual const ImageOptions& GetDefaultImageOptions() const; + + //! Get the default values that would be used if no text options were passed in + // + //! This is a convenient way to initialize the textOptions struct + virtual const TextOptions& GetDefaultTextOptions() const; + + //! Render the primitives that have been deferred + void RenderDeferredPrimitives(); + + //! Specify whether to defer future primitives or render them right away + void SetDeferPrimitives(bool deferPrimitives); + + //! Return whether future primitives will be deferred or rendered right away + bool GetDeferPrimitives(); + +private: + + AZ_DISABLE_COPY_MOVE(CDraw2d); + + // AZ::Render::Bootstrap::NotificationBus overrides + void OnBootstrapSceneReady(AZ::RPI::Scene* bootstrapScene) override; + +public: // static member functions + + //! Given a position and size and an alignment return the top left corner of the aligned quad + static AZ::Vector2 Align(AZ::Vector2 position, AZ::Vector2 size, HAlign horizontalAlignment, VAlign verticalAlignment); + + //! Helper to load a texture + static AZ::Data::Instance LoadTexture(const AZStd::string& pathName); + +protected: // types and constants + + enum + { + MAX_VERTICES_IN_PRIM = 6 + }; + + // Cached shader data + struct Draw2dShaderData + { + AZ::RHI::ShaderInputImageIndex m_imageInputIndex; + AZ::RHI::ShaderInputConstantIndex m_viewProjInputIndex; + }; + + class DeferredPrimitive + { + public: + virtual ~DeferredPrimitive() {}; + virtual void Draw(AZ::RHI::Ptr dynamicDraw, + const Draw2dShaderData& shaderData, + AZ::RPI::ViewportContextPtr viewportContext) const = 0; + }; + + class DeferredQuad + : public DeferredPrimitive + { + public: + ~DeferredQuad() override {}; + void Draw(AZ::RHI::Ptr dynamicDraw, + const Draw2dShaderData& shaderData, + AZ::RPI::ViewportContextPtr viewportContext) const override; + + AZ::Vector2 m_points[4]; + AZ::Vector2 m_texCoords[4]; + uint32 m_packedColors[4]; + AZ::Data::Instance m_image; + int m_state; + }; + + class DeferredLine + : public DeferredPrimitive + { + public: + ~DeferredLine() override {}; + void Draw(AZ::RHI::Ptr dynamicDraw, + const Draw2dShaderData& shaderData, + AZ::RPI::ViewportContextPtr viewportContext) const override; + + AZ::Data::Instance m_image; + AZ::Vector2 m_points[2]; + AZ::Vector2 m_texCoords[2]; + uint32 m_packedColors[2]; + int m_state; + }; + + class DeferredText + : public DeferredPrimitive + { + public: + ~DeferredText() override {}; + void Draw(AZ::RHI::Ptr dynamicDraw, + const Draw2dShaderData& shaderData, + AZ::RPI::ViewportContextPtr viewportContext) const override; + + STextDrawContext m_fontContext; + IFFont* m_font; + AZ::Vector2 m_position; + std::string m_string; + }; + +protected: // member functions + + //! Rotate an array of points around the z-axis at the pivot point. + // + //! Angle is in degrees counter-clockwise + void RotatePointsAboutPivot(AZ::Vector2* points, int numPoints, AZ::Vector2 pivot, float angle) const; + + //! Helper function to render a text string + void DrawTextInternal(const char* textString, IFFont* font, unsigned int effectIndex, + AZ::Vector2 position, float pointSize, AZ::Color color, float rotation, + HAlign horizontalAlignment, VAlign verticalAlignment, int baseState); + + //! Draw or defer a quad + void DrawOrDeferQuad(const DeferredQuad* quad); + + //! Draw or defer a line + void DrawOrDeferLine(const DeferredLine* line); + + //! Get specified viewport context or default viewport context if not specified + AZ::RPI::ViewportContextPtr GetViewportContext() const; + +protected: // attributes + + ImageOptions m_defaultImageOptions; //!< The default image options used if nullptr is passed + TextOptions m_defaultTextOptions; //!< The default text options used if nullptr is passed + + //! True if the actual render of the primitives should be deferred to a RenderDeferredPrimitives call + bool m_deferCalls; + + std::vector m_deferredPrimitives; + + AZ::RPI::ViewportContextPtr m_viewportContext; + AZ::RHI::Ptr m_dynamicDraw; + Draw2dShaderData m_shaderData; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//! Helper class for using the IDraw2d interface +//! +//! The Draw2dHelper class is an inline wrapper that provides the convenience feature of +//! automatically setting member options structures to their defaults and providing set functions. +class Draw2dHelper +{ +public: // member functions + + //! Start a section of 2D drawing function calls that will render to the default viewport + Draw2dHelper(bool deferCalls = false) + { + InitCommon(nullptr, deferCalls); + } + + //! Start a section of 2D drawing function calls that will render to the viewport + //! associated with the specified Draw2d object + Draw2dHelper(CDraw2d* draw2d, bool deferCalls = false) + { + InitCommon(draw2d, deferCalls); + } + + void InitCommon(CDraw2d* draw2d, bool deferCalls) + { + m_draw2d = draw2d; + + if (!m_draw2d) + { + // Set to default which is the game's draw 2d object + m_draw2d = GetDefaultDraw2d(); + } + + if (m_draw2d) + { + m_previousDeferCalls = m_draw2d->GetDeferPrimitives(); + m_draw2d->SetDeferPrimitives(deferCalls); + m_imageOptions = m_draw2d->GetDefaultImageOptions(); + m_textOptions = m_draw2d->GetDefaultTextOptions(); + } + } + + //! End a section of 2D drawing function calls. + ~Draw2dHelper() + { + if (m_draw2d) + { + m_draw2d->SetDeferPrimitives(m_previousDeferCalls); + } + } + + //! Draw a textured quad, optional rotation is counter-clockwise in degrees. + // + //! See IDraw2d:DrawImage for parameter descriptions + void DrawImage(AZ::Data::Instance image, AZ::Vector2 position, AZ::Vector2 size, float opacity = 1.0f, + float rotation = 0.0f, const AZ::Vector2* pivotPoint = nullptr, const AZ::Vector2* minMaxTexCoords = nullptr) + { + if (m_draw2d) + { + m_draw2d->DrawImage(image, position, size, opacity, rotation, pivotPoint, minMaxTexCoords, &m_imageOptions); + } + } + + //! Draw a textured quad where the position specifies the point specified by the alignment. + // + //! See IDraw2d:DrawImageAligned for parameter descriptions + void DrawImageAligned(AZ::Data::Instance image, AZ::Vector2 position, AZ::Vector2 size, + IDraw2d::HAlign horizontalAlignment, IDraw2d::VAlign verticalAlignment, + float opacity = 1.0f, float rotation = 0.0f, const AZ::Vector2* minMaxTexCoords = nullptr) + { + if (m_draw2d) + { + m_draw2d->DrawImageAligned(image, position, size, horizontalAlignment, verticalAlignment, + opacity, rotation, minMaxTexCoords, &m_imageOptions); + } + } + + //! Draw a textured quad where the position, color and uv of each point is specified explicitly + // + //! See IDraw2d:DrawQuad for parameter descriptions + void DrawQuad(AZ::Data::Instance image, IDraw2d::VertexPosColUV* verts, int blendMode = IDraw2d::UseDefault, + IDraw2d::Rounding pixelRounding = IDraw2d::Rounding::Nearest, + int baseState = IDraw2d::UseDefault) + { + if (m_draw2d) + { + m_draw2d->DrawQuad(image, verts, blendMode, pixelRounding, baseState); + } + } + + //! Draw a line + // + //! See IDraw2d:DrawLine for parameter descriptions + void DrawLine(AZ::Vector2 start, AZ::Vector2 end, AZ::Color color, int blendMode = IDraw2d::UseDefault, + IDraw2d::Rounding pixelRounding = IDraw2d::Rounding::Nearest, + int baseState = IDraw2d::UseDefault) + { + if (m_draw2d) + { + m_draw2d->DrawLine(start, end, color, blendMode, pixelRounding, baseState); + } + } + + //! Draw a line with a texture so it can be dotted or dashed + // + //! See IDraw2d:DrawLineTextured for parameter descriptions + void DrawLineTextured(AZ::Data::Instance image, IDraw2d::VertexPosColUV* verts, int blendMode = IDraw2d::UseDefault, + IDraw2d::Rounding pixelRounding = IDraw2d::Rounding::Nearest, + int baseState = IDraw2d::UseDefault) + { + if (m_draw2d) + { + m_draw2d->DrawLineTextured(image, verts, blendMode, pixelRounding, baseState); + } + } + + //! Draw a text string. Only supports ASCII text. + // + //! See IDraw2d:DrawText for parameter descriptions + void DrawText(const char* textString, AZ::Vector2 position, float pointSize, float opacity = 1.0f) + { + if (m_draw2d) + { + m_draw2d->DrawText(textString, position, pointSize, opacity, &m_textOptions); + } + } + + //! Get the width and height (in pixels) that would be used to draw the given text string. + // + //! See IDraw2d:GetTextSize for parameter descriptions + AZ::Vector2 GetTextSize(const char* textString, float pointSize) + { + if (m_draw2d) + { + return m_draw2d->GetTextSize(textString, pointSize, &m_textOptions); + } + else + { + return AZ::Vector2(0, 0); + } + } + + // State management + + //! Set the blend mode used for images, default is GS_BLSRC_SRCALPHA|GS_BLDST_ONEMINUSSRCALPHA. + void SetImageBlendMode(int mode) { m_imageOptions.blendMode = mode; } + + //! Set the color used for DrawImage and other image drawing. + void SetImageColor(AZ::Vector3 color) { m_imageOptions.color = color; } + + //! Set whether images are rounded to have the points on exact pixel boundaries. + void SetImagePixelRounding(IDraw2d::Rounding round) { m_imageOptions.pixelRounding = round; } + + //! Set the base state (that blend mode etc is combined with) used for images, default is GS_NODEPTHTEST. + void SetImageBaseState(int state) { m_imageOptions.baseState = state; } + + //! Set the text font. + void SetTextFont(IFFont* font) { m_textOptions.font = font; } + + //! Set the text font effect index. + void SetTextEffectIndex(unsigned int effectIndex) { m_textOptions.effectIndex = effectIndex; } + + //! Set the text color. + void SetTextColor(AZ::Vector3 color) { m_textOptions.color = color; } + + //! Set the text alignment. + void SetTextAlignment(IDraw2d::HAlign horizontalAlignment, IDraw2d::VAlign verticalAlignment) + { + m_textOptions.horizontalAlignment = horizontalAlignment; + m_textOptions.verticalAlignment = verticalAlignment; + } + + //! Set a drop shadow for text drawing. An alpha of zero disables drop shadow. + void SetTextDropShadow(AZ::Vector2 offset, AZ::Color color) + { + m_textOptions.dropShadowOffset = offset; + m_textOptions.dropShadowColor = color; + } + + //! Set a rotation for the text. The text rotates around its position (taking into account alignment). + void SetTextRotation(float rotation) + { + m_textOptions.rotation = rotation; + } + + //! Set the base state (that blend mode etc is combined with) used for text, default is GS_NODEPTHTEST. + void SetTextBaseState(int state) { m_textOptions.baseState = state; } + +public: // static member functions + + //! Helper to get the default IDraw2d interface + static CDraw2d* GetDefaultDraw2d() + { + if (gEnv && gEnv->pLyShine) // LYSHINE_ATOM_TODO - remove pLyShine and use bus interface + { + IDraw2d* draw2d = gEnv->pLyShine->GetDraw2d(); + return reinterpret_cast(draw2d); + } + + return nullptr; + } + + //! Round the X and Y coordinates of a point using the given rounding policy + template + static T RoundXY(T value, IDraw2d::Rounding roundingType) + { + T result = value; + + switch (roundingType) + { + case IDraw2d::Rounding::None: + // nothing to do + break; + case IDraw2d::Rounding::Nearest: + result.SetX(floor(value.GetX() + 0.5f)); + result.SetY(floor(value.GetY() + 0.5f)); + break; + case IDraw2d::Rounding::Down: + result.SetX(floor(value.GetX())); + result.SetY(floor(value.GetY())); + break; + case IDraw2d::Rounding::Up: + result.SetX(ceil(value.GetX())); + result.SetY(ceil(value.GetY())); + break; + } + + return result; + } + +protected: // attributes + + IDraw2d::ImageOptions m_imageOptions; //!< image options are stored locally and updated by member functions + IDraw2d::TextOptions m_textOptions; //!< text options are stored locally and updated by member functions + CDraw2d* m_draw2d; + bool m_previousDeferCalls; +}; diff --git a/Gems/LyShine/Code/Source/Draw2d.cpp b/Gems/LyShine/Code/Source/Draw2d.cpp index 4beba0b1eb..cd15475039 100644 --- a/Gems/LyShine/Code/Source/Draw2d.cpp +++ b/Gems/LyShine/Code/Source/Draw2d.cpp @@ -10,17 +10,24 @@ * */ #include "LyShine_precompiled.h" -#include "Draw2d.h" #include "IFont.h" -#include "IRenderer.h" + +#include #include +#include + +#include +#include +#include +#include +#include +#include +#include static const int g_defaultBlendState = GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA; static const int g_defaultBaseState = GS_NODEPTHTEST; -static const int g_2dModeNotStarted = -1; - //////////////////////////////////////////////////////////////////////////////////////////////////// // LOCAL STATIC FUNCTIONS //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -37,9 +44,9 @@ static AZ::u32 PackARGB8888(const AZ::Color& color) //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// -CDraw2d::CDraw2d() +CDraw2d::CDraw2d(AZ::RPI::ViewportContextPtr viewportContext) : m_deferCalls(false) - , m_nestLevelAtWhichStarted2dMode(g_2dModeNotStarted) + , m_viewportContext(viewportContext) { // These default options are set here and never change. They are stored so that if a null options // structure is passed into the draw functions then this default one can be used instead @@ -57,78 +64,75 @@ CDraw2d::CDraw2d() m_defaultTextOptions.dropShadowColor.Set(0.0f, 0.0f, 0.0f, 0.0f); m_defaultTextOptions.rotation = 0.0f; m_defaultTextOptions.baseState = g_defaultBaseState; -} -//////////////////////////////////////////////////////////////////////////////////////////////////// -CDraw2d::~CDraw2d() -{ + AZ::Render::Bootstrap::NotificationBus::Handler::BusConnect(); } //////////////////////////////////////////////////////////////////////////////////////////////////// -void CDraw2d::BeginDraw2d(bool deferCalls) +CDraw2d::~CDraw2d() { - IRenderer* renderer = gEnv->pRenderer; - AZ::Vector2 viewportSize( - static_cast(renderer->GetOverlayWidth()), - static_cast(renderer->GetOverlayHeight())); - BeginDraw2d(viewportSize, deferCalls); + AZ::Render::Bootstrap::NotificationBus::Handler::BusDisconnect(); } //////////////////////////////////////////////////////////////////////////////////////////////////// -void CDraw2d::BeginDraw2d(AZ::Vector2 viewportSize, bool deferCalls) +void CDraw2d::OnBootstrapSceneReady([[maybe_unused]] AZ::RPI::Scene* bootstrapScene) { - // So that nested calls to BeginDraw2d/EndDraw2d do not end 2D drawmode prematurely we only - // switch to 2D mode once and do not do it again until the corresponding call to EndDraw2d - // is processed. - // It may seem overkill to allow nested calls rather than just asserting in that case. But - // a) it is more flexible to do so - // b) it can be useful to draw some debug primitives in deferred mode while rendering a - // canvas in non-deferred mode for example - - // Push the current state of the m_deferCalls onto a stack to support nested calls - m_deferCallsFlagStack.push(m_deferCalls); + // At this point the RPI is ready for use - m_deferCalls = deferCalls; + // Load the shader to be used for 2d drawing + const char* shaderFilepath = "Shaders/SimpleTextured.azshader"; + AZ::Data::Instance shader = AZ::RPI::LoadShader(shaderFilepath); - // if this is the outermost call with non-deferred rendering then switch to 2D mode - if (!m_deferCalls && m_nestLevelAtWhichStarted2dMode == g_2dModeNotStarted) + // Set scene to be associated with the dynamic draw context + AZ::RPI::ScenePtr scene; + if (m_viewportContext) { - IRenderer* renderer = gEnv->pRenderer; - - renderer->SetCullMode(R_CULL_DISABLE); - - renderer->Set2DMode(static_cast(viewportSize.GetX()), static_cast(viewportSize.GetY()), m_backupSceneMatrices); - - renderer->SetColorOp(eCO_MODULATE, eCO_MODULATE, DEF_TEXARG0, DEF_TEXARG0); - renderer->SetState(g_defaultBlendState | g_defaultBaseState); - - // remember the nesting level that we turned on 2D mode so we can turn it off as - // we unwind the stack - m_nestLevelAtWhichStarted2dMode = m_deferCallsFlagStack.size(); + // Use scene associated with the specified viewport context + scene = m_viewportContext->GetRenderScene(); } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// -void CDraw2d::EndDraw2d() -{ - // if we are ending a non-deferred series of calls and we turned on 2D draw mode when we started - // this series then turn it off. - if (!m_deferCalls && m_nestLevelAtWhichStarted2dMode == m_deferCallsFlagStack.size()) + else { - IRenderer* renderer = gEnv->pRenderer; - renderer->Unset2DMode(m_backupSceneMatrices); - m_nestLevelAtWhichStarted2dMode = -1; + // No viewport context specified, use default scene + scene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); } - - // unwind the nesting stack - m_deferCalls = m_deferCallsFlagStack.top(); - m_deferCallsFlagStack.pop(); + AZ_Assert(scene != nullptr, "Attempting to create a DynamicDrawContext for a viewport context that has not been associated with a scene yet."); + + // Create and initialize a DynamicDrawContext for 2d drawing + m_dynamicDraw = AZ::RPI::DynamicDrawInterface::Get()->CreateDynamicDrawContext(scene.get()); + AZ::RPI::ShaderOptionList shaderOptions; + shaderOptions.push_back(AZ::RPI::ShaderOption(AZ::Name("o_useColorChannels"), AZ::Name("true"))); + shaderOptions.push_back(AZ::RPI::ShaderOption(AZ::Name("o_clamp"), AZ::Name("false"))); + m_dynamicDraw->InitShaderWithVariant(shader, &shaderOptions); + m_dynamicDraw->InitVertexFormat( + { {"POSITION", AZ::RHI::Format::R32G32B32_FLOAT}, + {"COLOR", AZ::RHI::Format::B8G8R8A8_UNORM}, + {"TEXCOORD0", AZ::RHI::Format::R32G32_FLOAT} }); + m_dynamicDraw->AddDrawStateOptions(AZ::RPI::DynamicDrawContext::DrawStateOptions::PrimitiveType + | AZ::RPI::DynamicDrawContext::DrawStateOptions::BlendMode); + m_dynamicDraw->EndInit(); + + AZ::RHI::TargetBlendState targetBlendState; + targetBlendState.m_enable = true; + targetBlendState.m_blendSource = AZ::RHI::BlendFactor::AlphaSource; + targetBlendState.m_blendDest = AZ::RHI::BlendFactor::AlphaSourceInverse; + m_dynamicDraw->SetTarget0BlendState(targetBlendState); + + // Cache draw srg input indices for later use + static const char textureIndexName[] = "m_texture"; + static const char worldToProjIndexName[] = "m_worldToProj"; + AZ::Data::Instance drawSrg = m_dynamicDraw->NewDrawSrg(); + const AZ::RHI::ShaderResourceGroupLayout* layout = drawSrg->GetAsset()->GetLayout(); + m_shaderData.m_imageInputIndex = layout->FindShaderInputImageIndex(AZ::Name(textureIndexName)); + AZ_Error("Draw2d", m_shaderData.m_imageInputIndex.IsValid(), "Failed to find shader input constant %s.", + textureIndexName); + m_shaderData.m_viewProjInputIndex = layout->FindShaderInputConstantIndex(AZ::Name(worldToProjIndexName)); + AZ_Error("Draw2d", m_shaderData.m_viewProjInputIndex.IsValid(), "Failed to find shader input constant %s.", + worldToProjIndexName); } - //////////////////////////////////////////////////////////////////////////////////////////////////// // Draw a textured quad with the top left corner at the given position. -void CDraw2d::DrawImage(int texId, AZ::Vector2 position, AZ::Vector2 size, float opacity, +void CDraw2d::DrawImage(AZ::Data::Instance image, AZ::Vector2 position, AZ::Vector2 size, float opacity, float rotation, const AZ::Vector2* pivotPoint, const AZ::Vector2* minMaxTexCoords, ImageOptions* imageOptions) { @@ -169,7 +173,7 @@ void CDraw2d::DrawImage(int texId, AZ::Vector2 position, AZ::Vector2 size, float quad.m_texCoords[3].Set(0.0f, 1.0f); } - quad.m_texId = texId; + quad.m_image = image; // add the blendMode flags to the base state quad.m_state = blendMode | actualImageOptions->baseState; @@ -185,17 +189,17 @@ void CDraw2d::DrawImage(int texId, AZ::Vector2 position, AZ::Vector2 size, float } //////////////////////////////////////////////////////////////////////////////////////////////////// -void CDraw2d::DrawImageAligned(int texId, AZ::Vector2 position, AZ::Vector2 size, +void CDraw2d::DrawImageAligned(AZ::Data::Instance image, AZ::Vector2 position, AZ::Vector2 size, HAlign horizontalAlignment, VAlign verticalAlignment, float opacity, float rotation, const AZ::Vector2* minMaxTexCoords, ImageOptions* imageOptions) { AZ::Vector2 alignedPosition = Align(position, size, horizontalAlignment, verticalAlignment); - DrawImage(texId, alignedPosition, size, opacity, rotation, &position, minMaxTexCoords, imageOptions); + DrawImage(image, alignedPosition, size, opacity, rotation, &position, minMaxTexCoords, imageOptions); } //////////////////////////////////////////////////////////////////////////////////////////////////// -void CDraw2d::DrawQuad(int texId, VertexPosColUV* verts, int blendMode, Rounding pixelRounding, int baseState) +void CDraw2d::DrawQuad(AZ::Data::Instance image, VertexPosColUV* verts, int blendMode, Rounding pixelRounding, int baseState) { int actualBlendMode = (blendMode == -1) ? g_defaultBlendState : blendMode; int actualBaseState = (baseState == -1) ? g_defaultBaseState : baseState; @@ -208,7 +212,7 @@ void CDraw2d::DrawQuad(int texId, VertexPosColUV* verts, int blendMode, Rounding quad.m_texCoords[i] = verts[i].uv; quad.m_packedColors[i] = PackARGB8888(verts[i].color); } - quad.m_texId = texId; + quad.m_image = image; // add the blendMode flags to the base state quad.m_state = actualBlendMode | actualBaseState; @@ -221,9 +225,7 @@ void CDraw2d::DrawLine(AZ::Vector2 start, AZ::Vector2 end, AZ::Color color, int { int actualBaseState = (baseState == -1) ? g_defaultBaseState : baseState; - IRenderer* renderer = gEnv->pRenderer; - - int texId = renderer->GetWhiteTextureId(); + auto image = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::White); int actualBlendMode = (blendMode == -1) ? g_defaultBlendState : blendMode; @@ -231,7 +233,7 @@ void CDraw2d::DrawLine(AZ::Vector2 start, AZ::Vector2 end, AZ::Color color, int uint32 packedColor = PackARGB8888(color); DeferredLine line; - line.m_texId = texId; + line.m_image = image; line.m_points[0] = Draw2dHelper::RoundXY(start, pixelRounding); line.m_points[1] = Draw2dHelper::RoundXY(end, pixelRounding); @@ -250,7 +252,7 @@ void CDraw2d::DrawLine(AZ::Vector2 start, AZ::Vector2 end, AZ::Color color, int //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// -void CDraw2d::DrawLineTextured(int texId, VertexPosColUV* verts, int blendMode, Rounding pixelRounding, int baseState) +void CDraw2d::DrawLineTextured(AZ::Data::Instance image, VertexPosColUV* verts, int blendMode, Rounding pixelRounding, int baseState) { int actualBaseState = (baseState == -1) ? g_defaultBaseState : baseState; @@ -258,7 +260,7 @@ void CDraw2d::DrawLineTextured(int texId, VertexPosColUV* verts, int blendMode, // define line DeferredLine line; - line.m_texId = texId; + line.m_image = image; for (int i = 0; i < 2; ++i) { @@ -327,15 +329,19 @@ AZ::Vector2 CDraw2d::GetTextSize(const char* textString, float pointSize, TextOp //////////////////////////////////////////////////////////////////////////////////////////////////// float CDraw2d::GetViewportWidth() const { - IRenderer* renderer = gEnv->pRenderer; - return (float)renderer->GetOverlayWidth(); + auto windowContext = GetViewportContext()->GetWindowContext(); + const AZ::RHI::Viewport& viewport = windowContext->GetViewport(); + const float viewWidth = viewport.m_maxX - viewport.m_minX; + return viewWidth; } //////////////////////////////////////////////////////////////////////////////////////////////////// float CDraw2d::GetViewportHeight() const { - IRenderer* renderer = gEnv->pRenderer; - return (float)renderer->GetOverlayHeight(); + auto windowContext = GetViewportContext()->GetWindowContext(); + const AZ::RHI::Viewport& viewport = windowContext->GetViewport(); + const float viewHeight = viewport.m_maxY - viewport.m_minY; + return viewHeight; } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -353,27 +359,28 @@ const CDraw2d::TextOptions& CDraw2d::GetDefaultTextOptions() const //////////////////////////////////////////////////////////////////////////////////////////////////// void CDraw2d::RenderDeferredPrimitives() { - IRenderer* renderer = gEnv->pRenderer; - - // Set up the 2D drawing state - renderer->SetCullMode(R_CULL_DISABLE); - - renderer->Set2DMode(renderer->GetOverlayWidth(), renderer->GetOverlayHeight(), m_backupSceneMatrices); - renderer->SetColorOp(eCO_MODULATE, eCO_MODULATE, DEF_TEXARG0, DEF_TEXARG0); - renderer->SetState(g_defaultBlendState | g_defaultBaseState); - // Draw and delete the deferred primitives + AZ::RPI::ViewportContextPtr viewportContext = GetViewportContext(); for (auto primIter : m_deferredPrimitives) { - primIter->Draw(); + primIter->Draw(m_dynamicDraw, m_shaderData, viewportContext); delete primIter; } // clear the list of deferred primitives m_deferredPrimitives.clear(); +} - // Reset the render state - renderer->Unset2DMode(m_backupSceneMatrices); +//////////////////////////////////////////////////////////////////////////////////////////////////// +void CDraw2d::SetDeferPrimitives(bool deferPrimitives) +{ + m_deferCalls = deferPrimitives; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// +bool CDraw2d::GetDeferPrimitives() +{ + return m_deferCalls; } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -414,6 +421,30 @@ AZ::Vector2 CDraw2d::Align(AZ::Vector2 position, AZ::Vector2 size, return result; } +//////////////////////////////////////////////////////////////////////////////////////////////////// +AZ::Data::Instance CDraw2d::LoadTexture(const AZStd::string& pathName) +{ + AZStd::string sourceRelativePath(pathName); + AZStd::string cacheRelativePath = sourceRelativePath + ".streamingimage"; + + // The file may not be in the AssetCatalog at this point if it is still processing or doesn't exist on disk. + // Use GenerateAssetIdTEMP instead of GetAssetIdByPath so that it will return a valid AssetId anyways + AZ::Data::AssetId streamingImageAssetId; + AZ::Data::AssetCatalogRequestBus::BroadcastResult( + streamingImageAssetId, &AZ::Data::AssetCatalogRequestBus::Events::GenerateAssetIdTEMP, + sourceRelativePath.c_str()); + streamingImageAssetId.m_subId = AZ::RPI::StreamingImageAsset::GetImageAssetSubId(); + + auto streamingImageAsset = AZ::Data::AssetManager::Instance().FindOrCreateAsset(streamingImageAssetId, AZ::Data::AssetLoadBehavior::PreLoad); + AZ::Data::Instance image = AZ::RPI::StreamingImage::FindOrCreate(streamingImageAsset); + if (!image) + { + AZ_Error("Draw2d", false, "Failed to find or create an image instance from image asset '%s'", streamingImageAsset.GetHint().c_str()); + } + + return image; +} + //////////////////////////////////////////////////////////////////////////////////////////////////// // PROTECTED MEMBER FUNCTIONS //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -542,7 +573,7 @@ void CDraw2d::DrawOrDeferQuad(const DeferredQuad* quad) } else { - quad->Draw(); + quad->Draw(m_dynamicDraw, m_shaderData, GetViewportContext()); } } @@ -557,16 +588,33 @@ void CDraw2d::DrawOrDeferLine(const DeferredLine* line) } else { - line->Draw(); + line->Draw(m_dynamicDraw, m_shaderData, GetViewportContext()); } } +//////////////////////////////////////////////////////////////////////////////////////////////////// +AZ::RPI::ViewportContextPtr CDraw2d::GetViewportContext() const +{ + if (!m_viewportContext) + { + // Return the default viewport context + auto viewContextManager = AZ::Interface::Get(); + return viewContextManager->GetDefaultViewportContext(); + } + + // Return the user specified viewport context + return m_viewportContext; + +} + //////////////////////////////////////////////////////////////////////////////////////////////////// // CDraw2d::DeferredQuad //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// -void CDraw2d::DeferredQuad::Draw() const +void CDraw2d::DeferredQuad::Draw(AZ::RHI::Ptr dynamicDraw, + const Draw2dShaderData& shaderData, + AZ::RPI::ViewportContextPtr viewportContext) const { const int32 NUM_VERTS = 6; @@ -585,17 +633,41 @@ void CDraw2d::DeferredQuad::Draw() const vertices[i].st = Vec2(m_texCoords[j].GetX(), m_texCoords[j].GetY()); } - IRenderer* renderer = gEnv->pRenderer; - renderer->SetTexture(m_texId); + // Set up per draw SRG + AZ::Data::Instance drawSrg = dynamicDraw->NewDrawSrg(); - // Set the render state, can't rely on this being right because font rendering changes it - renderer->SetColorOp(eCO_MODULATE, eCO_MODULATE, DEF_TEXARG0, DEF_TEXARG0); + // Set texture + const AZ::RHI::ImageView* imageView = m_image ? m_image->GetImageView() : nullptr; + if (!imageView) + { + // Default to white texture + auto image = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::White); + imageView = image->GetImageView(); + } - // set the desired render state - renderer->SetState(m_state); + if (imageView) + { + drawSrg->SetImageView(shaderData.m_imageInputIndex, imageView, 0); + } - // This will end up using DrawPrimitive to render the quad - renderer->DrawDynVB(vertices, nullptr, NUM_VERTS, 0, prtTriangleList); + // Set projection matrix + auto windowContext = viewportContext->GetWindowContext(); + const AZ::RHI::Viewport& viewport = windowContext->GetViewport(); + const float viewX = viewport.m_minX; + const float viewY = viewport.m_minY; + const float viewWidth = viewport.m_maxX - viewport.m_minX; + const float viewHeight = viewport.m_maxY - viewport.m_minY; + const float zf = viewport.m_minZ; + const float zn = viewport.m_maxZ; + AZ::Matrix4x4 modelViewProjMat; + AZ::MakeOrthographicMatrixRH(modelViewProjMat, viewX, viewX + viewWidth, viewY + viewHeight, viewY, zn, zf); + drawSrg->SetConstant(shaderData.m_viewProjInputIndex, modelViewProjMat); + + drawSrg->Compile(); + + // Add the primitive to the dynamic draw context for drawing + dynamicDraw->SetPrimitiveType(AZ::RHI::PrimitiveTopology::TriangleList); + dynamicDraw->DrawLinear(vertices, NUM_VERTS, drawSrg); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -603,7 +675,9 @@ void CDraw2d::DeferredQuad::Draw() const //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// -void CDraw2d::DeferredLine::Draw() const +void CDraw2d::DeferredLine::Draw(AZ::RHI::Ptr dynamicDraw, + const Draw2dShaderData& shaderData, + AZ::RPI::ViewportContextPtr viewportContext) const { const float z = 1.0f; // depth test disabled, if writing Z this will write at far plane @@ -618,15 +692,41 @@ void CDraw2d::DeferredLine::Draw() const vertices[i].st = Vec2(m_texCoords[i].GetX(), m_texCoords[i].GetY()); } - IRenderer* renderer = gEnv->pRenderer; - renderer->SetTexture(m_texId); + // Set up per draw SRG + AZ::Data::Instance drawSrg = dynamicDraw->NewDrawSrg(); + + // Set texture + const AZ::RHI::ImageView* imageView = m_image ? m_image->GetImageView() : nullptr; + if (!imageView) + { + // Default to white texture + auto image = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::White); + imageView = image->GetImageView(); + } - // Set the render state, can't rely on this being right because font rendering changes it - renderer->SetColorOp(eCO_MODULATE, eCO_MODULATE, DEF_TEXARG0, DEF_TEXARG0); - renderer->SetState(m_state); + if (imageView) + { + drawSrg->SetImageView(shaderData.m_imageInputIndex, imageView, 0); + } - // This will end up using DrawPrimitive to render the quad - renderer->DrawDynVB(vertices, nullptr, NUM_VERTS, 0, prtLineList); + // Set projection matrix + auto windowContext = viewportContext->GetWindowContext(); + const AZ::RHI::Viewport& viewport = windowContext->GetViewport(); + const float viewX = viewport.m_minX; + const float viewY = viewport.m_minY; + const float viewWidth = viewport.m_maxX - viewport.m_minX; + const float viewHeight = viewport.m_maxY - viewport.m_minY; + const float zf = viewport.m_minZ; + const float zn = viewport.m_maxZ; + AZ::Matrix4x4 modelViewProjMat; + AZ::MakeOrthographicMatrixRH(modelViewProjMat, viewX, viewX + viewWidth, viewY + viewHeight, viewY, zn, zf); + drawSrg->SetConstant(shaderData.m_viewProjInputIndex, modelViewProjMat); + + drawSrg->Compile(); + + // Add the primitive to the dynamic draw context for drawing + dynamicDraw->SetPrimitiveType(AZ::RHI::PrimitiveTopology::LineList); + dynamicDraw->DrawLinear(vertices, NUM_VERTS, drawSrg); } @@ -635,7 +735,9 @@ void CDraw2d::DeferredLine::Draw() const //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// -void CDraw2d::DeferredText::Draw() const +void CDraw2d::DeferredText::Draw([[maybe_unused]] AZ::RHI::Ptr dynamicDraw, + [[maybe_unused]] const Draw2dShaderData& shaderData, + [[maybe_unused]] AZ::RPI::ViewportContextPtr viewportContext) const { m_font->DrawString(m_position.GetX(), m_position.GetY(), m_string.c_str(), true, m_fontContext); } diff --git a/Gems/LyShine/Code/Source/Draw2d.h b/Gems/LyShine/Code/Source/Draw2d.h deleted file mode 100644 index a62dc22937..0000000000 --- a/Gems/LyShine/Code/Source/Draw2d.h +++ /dev/null @@ -1,189 +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. -* -*/ -#pragma once - -#include -#include -#include - -//////////////////////////////////////////////////////////////////////////////////////////////////// -//! Implementation of IDraw2d interface for 2D drawing in screen space -// -//! The CDraw2d class implements the IDraw2d interface for drawing 2D images, shapes and text. -//! Positions and sizes are specified in pixels in the current 2D viewport. -class CDraw2d - : public IDraw2d -{ -public: // member functions - - //! Constructor, constructed by the LyShine class - CDraw2d(); - - // IDraw2d - - ~CDraw2d() override; - - //! Start a section of 2D drawing function calls. This will set appropriate render state. - void BeginDraw2d(bool deferCalls = false) override; - - //! Start a section of 2D drawing function calls. This will set appropriate render state. - //! This variant allows the viewport size to be specified - void BeginDraw2d(AZ::Vector2 viewportSize, bool deferCalls = false) override; - - //! End a section of 2D drawing function calls. This will reset some render state. - void EndDraw2d() override; - - //! Draw a textured quad, optional rotation is counter-clockwise in degrees. - void DrawImage(int texId, AZ::Vector2 position, AZ::Vector2 size, float opacity = 1.0f, - float rotation = 0.0f, const AZ::Vector2* pivotPoint = nullptr, const AZ::Vector2* minMaxTexCoords = nullptr, - ImageOptions* imageOptions = nullptr) override; - - //! Draw a textured quad where the position specifies the point specified by the alignment. Rotation is around that point. - void DrawImageAligned(int texId, AZ::Vector2 position, AZ::Vector2 size, - HAlign horizontalAlignment, VAlign verticalAlignment, - float opacity = 1.0f, float rotation = 0.0f, const AZ::Vector2* minMaxTexCoords = nullptr, - ImageOptions* imageOptions = nullptr) override; - - //! Draw a textured quad where the position, color and uv of each point is specified explicitly - void DrawQuad(int texId, VertexPosColUV* verts, int blendMode, Rounding pixelRounding, int baseState) override; - - //! Draw a line - void DrawLine(AZ::Vector2 start, AZ::Vector2 end, AZ::Color color, int blendMode, Rounding pixelRounding, int baseState) override; - - //! Draw a line textured - void DrawLineTextured(int texId, VertexPosColUV* verts, int blendMode, Rounding pixelRounding, int baseState) override; - - //! Draw a text string. Only supports ASCII text. - void DrawText(const char* textString, AZ::Vector2 position, float pointSize, - float opacity = 1.0f, TextOptions* textOptions = nullptr) override; - - //! Get the width and height (in pixels) that would be used to draw the given text string. - AZ::Vector2 GetTextSize(const char* textString, float pointSize, TextOptions* textOptions = nullptr) override; - - //! Get the width of the rendering viewport (in pixels). - float GetViewportWidth() const override; - - //! Get the height of the rendering viewport (in pixels). - float GetViewportHeight() const override; - - //! Get the default values that would be used if no image options were passed in - const ImageOptions& GetDefaultImageOptions() const override; - - //! Get the default values that would be used if no text options were passed in - const TextOptions& GetDefaultTextOptions() const override; - - // ~IDraw2d - - //! Render the primitives that have been deferred - void RenderDeferredPrimitives(); - -private: - - AZ_DISABLE_COPY_MOVE(CDraw2d); - -public: // static member functions - - //! Given a position and size and an alignment return the top left corner of the aligned quad - static AZ::Vector2 Align(AZ::Vector2 position, AZ::Vector2 size, HAlign horizontalAlignment, VAlign verticalAlignment); - -protected: // types and constants - - enum - { - MAX_VERTICES_IN_PRIM = 6 - }; - - class DeferredPrimitive - { - public: - virtual ~DeferredPrimitive() {}; - virtual void Draw() const = 0; - }; - - class DeferredQuad - : public DeferredPrimitive - { - public: - ~DeferredQuad() override {}; - void Draw() const override; - - AZ::Vector2 m_points[4]; - AZ::Vector2 m_texCoords[4]; - uint32 m_packedColors[4]; - int m_texId; - int m_state; - }; - - class DeferredLine - : public DeferredPrimitive - { - public: - ~DeferredLine() override {}; - void Draw() const override; - - int m_texId; - AZ::Vector2 m_points[2]; - AZ::Vector2 m_texCoords[2]; - uint32 m_packedColors[2]; - int m_state; - }; - - class DeferredText - : public DeferredPrimitive - { - public: - ~DeferredText() override {}; - void Draw() const override; - - STextDrawContext m_fontContext; - IFFont* m_font; - AZ::Vector2 m_position; - std::string m_string; - }; - -protected: // member functions - - //! Rotate an array of points around the z-axis at the pivot point. - // - //! Angle is in degrees counter-clockwise - void RotatePointsAboutPivot(AZ::Vector2* points, int numPoints, AZ::Vector2 pivot, float angle) const; - - //! Helper function to render a text string - void DrawTextInternal(const char* textString, IFFont* font, unsigned int effectIndex, - AZ::Vector2 position, float pointSize, AZ::Color color, float rotation, - HAlign horizontalAlignment, VAlign verticalAlignment, int baseState); - - //! Draw or defer a quad - void DrawOrDeferQuad(const DeferredQuad* quad); - - //! Draw or defer a line - void DrawOrDeferLine(const DeferredLine* line); - -protected: // attributes - - ImageOptions m_defaultImageOptions; //!< The default image options used if nullptr is passed - TextOptions m_defaultTextOptions; //!< The default text options used if nullptr is passed - - bool m_deferCalls; //!< True if the actual render of the primitives should be deferred until end of frame - - std::vector m_deferredPrimitives; - - //! These two data members allows nested calls to BeginDraw2d/EndDraw2d. We will begin 2D mode only on the - //! outermost call to BeginDraw2d with deferCalls set to false and will end 2D mode on the corresposnding - //! call to EndDraw2d. The stack is used to detect that corresponding call and we need the level it occurred - //! to know when to end 2D mode. - int m_nestLevelAtWhichStarted2dMode; - std::stack m_deferCallsFlagStack; - -private: - TransformationMatrices m_backupSceneMatrices; -}; diff --git a/Gems/LyShine/Code/Source/LyShine.cpp b/Gems/LyShine/Code/Source/LyShine.cpp index cfea0cbdf7..286e756ffa 100644 --- a/Gems/LyShine/Code/Source/LyShine.cpp +++ b/Gems/LyShine/Code/Source/LyShine.cpp @@ -13,8 +13,6 @@ #include "LyShine.h" -#include "Draw2d.h" - #include "UiCanvasComponent.h" #include "UiCanvasManager.h" #include "LyShineDebug.h" @@ -55,6 +53,7 @@ #include #include #include +#include #if defined(LYSHINE_INTERNAL_UNIT_TEST) #include "TextMarkup.h" @@ -455,7 +454,6 @@ void CLyShine::Render() // Render all the canvases loaded in game m_uiCanvasManager->RenderLoadedCanvases(); -#ifdef LYSHINE_ATOM_TODO // convert cursor support to use Atom m_draw2d->RenderDeferredPrimitives(); // Don't render the UI cursor when in edit mode. For example during UI Preview mode a script could turn on the @@ -466,7 +464,6 @@ void CLyShine::Render() { RenderUiCursor(); } -#endif GetUiRenderer()->EndUiFrameRender(); @@ -687,9 +684,11 @@ void CLyShine::RenderUiCursor() const AZ::Vector2 position = GetUiCursorPosition(); const AZ::Vector2 dimensions(static_cast(m_uiCursorTexture->GetWidth()), static_cast(m_uiCursorTexture->GetHeight())); +#ifdef LYSHINE_ATOM_TODO // Convert cursor to Atom image m_draw2d->BeginDraw2d(); m_draw2d->DrawImage(m_uiCursorTexture->GetTextureID(), position, dimensions); m_draw2d->EndDraw2d(); +#endif } #ifndef _RELEASE diff --git a/Gems/LyShine/Code/Source/LyShineDebug.cpp b/Gems/LyShine/Code/Source/LyShineDebug.cpp index f1ce411d83..5ea01c5c1e 100644 --- a/Gems/LyShine/Code/Source/LyShineDebug.cpp +++ b/Gems/LyShine/Code/Source/LyShineDebug.cpp @@ -12,8 +12,9 @@ #include "LyShine_precompiled.h" #include "LyShineDebug.h" #include "IConsole.h" -#include -#include "IRenderer.h" +#include + +#include #include #include @@ -105,15 +106,24 @@ static bool g_deferDrawsToEndOfFrame = false; //////////////////////////////////////////////////////////////////////////////////////////////////// #if !defined(_RELEASE) +#ifdef LYSHINE_ATOM_TODO static int Create2DTexture(int width, int height, byte* data, ETEX_Format format) { IRenderer* renderer = gEnv->pRenderer; return renderer->DownLoadToVideoMemory(data, width, height, format, format, 1); } #endif +#endif + +static AZ::Vector2 GetTextureSize(AZ::Data::Instance image) +{ + AZ::RHI::Size size = image->GetDescriptor().m_size; + return AZ::Vector2(size.m_width, size.m_height); +} //////////////////////////////////////////////////////////////////////////////////////////////////// #if !defined(_RELEASE) +#ifdef LYSHINE_ATOM_TODO static void FillTextureRectWithCheckerboard(uint32* data, int textureWidth, int textureHeight, int minX, int minY, [[maybe_unused]] int rectWidth, int rectHeight, int tileWidth, int tileHeight, uint32* colors, bool varyAlpha) @@ -139,11 +149,13 @@ static void FillTextureRectWithCheckerboard(uint32* data, int textureWidth, int } } #endif +#endif //////////////////////////////////////////////////////////////////////////////////////////////////// #if !defined(_RELEASE) -static ITexture* CreateMonoTestTexture() +static AZ::Data::Instance CreateMonoTestTexture() { +#ifdef LYSHINE_ATOM_TODO const int width = 32; const int height = 32; uint32 data[width * height]; @@ -172,13 +184,18 @@ static ITexture* CreateMonoTestTexture() int textureId = Create2DTexture(width, height, (uint8*)data, eTF_R8G8B8A8); return gEnv->pRenderer->EF_GetTextureByID(textureId); +#else + auto whiteTexture = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::White); + return whiteTexture; +#endif } #endif //////////////////////////////////////////////////////////////////////////////////////////////////// #if !defined(_RELEASE) -static ITexture* CreateColorTestTexture() +static AZ::Data::Instance CreateColorTestTexture() { +#ifdef LYSHINE_ATOM_TODO const int width = 32; const int height = 32; uint32 data[width * height]; @@ -207,13 +224,18 @@ static ITexture* CreateColorTestTexture() int textureId = Create2DTexture(width, height, (uint8*)data, eTF_R8G8B8A8); return gEnv->pRenderer->EF_GetTextureByID(textureId); +#else + auto whiteTexture = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::White); + return whiteTexture; +#endif } #endif //////////////////////////////////////////////////////////////////////////////////////////////////// #if !defined(_RELEASE) -static ITexture* CreateMonoAlphaTestTexture() +static AZ::Data::Instance CreateMonoAlphaTestTexture() { +#ifdef LYSHINE_ATOM_TODO const int width = 32; const int height = 32; uint32 data[width * height]; @@ -242,13 +264,18 @@ static ITexture* CreateMonoAlphaTestTexture() int textureId = Create2DTexture(width, height, (uint8*)data, eTF_R8G8B8A8); return gEnv->pRenderer->EF_GetTextureByID(textureId); +#else + auto whiteTexture = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::White); + return whiteTexture; +#endif } #endif //////////////////////////////////////////////////////////////////////////////////////////////////// #if !defined(_RELEASE) -static ITexture* CreateColorAlphaTestTexture() +static AZ::Data::Instance CreateColorAlphaTestTexture() { +#ifdef LYSHINE_ATOM_TODO const int width = 32; const int height = 32; uint32 data[width * height]; @@ -277,14 +304,18 @@ static ITexture* CreateColorAlphaTestTexture() int textureId = Create2DTexture(width, height, (uint8*)data, eTF_R8G8B8A8); return gEnv->pRenderer->EF_GetTextureByID(textureId); +#else + auto whiteTexture = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::White); + return whiteTexture; +#endif } #endif //////////////////////////////////////////////////////////////////////////////////////////////////// #if !defined(_RELEASE) -static ITexture* GetMonoTestTexture() +static AZ::Data::Instance GetMonoTestTexture() { - static ITexture* testImageMono = nullptr; + static AZ::Data::Instance testImageMono = nullptr; if (!testImageMono) { @@ -297,9 +328,9 @@ static ITexture* GetMonoTestTexture() //////////////////////////////////////////////////////////////////////////////////////////////////// #if !defined(_RELEASE) -static ITexture* GetColorTestTexture() +static AZ::Data::Instance GetColorTestTexture() { - static ITexture* testImageColor = nullptr; + static AZ::Data::Instance testImageColor = nullptr; if (!testImageColor) { @@ -312,9 +343,9 @@ static ITexture* GetColorTestTexture() //////////////////////////////////////////////////////////////////////////////////////////////////// #if !defined(_RELEASE) -static ITexture* GetMonoAlphaTestTexture() +static AZ::Data::Instance GetMonoAlphaTestTexture() { - static ITexture* testImageMonoAlpha = nullptr; + static AZ::Data::Instance testImageMonoAlpha = nullptr; if (!testImageMonoAlpha) { @@ -327,9 +358,9 @@ static ITexture* GetMonoAlphaTestTexture() //////////////////////////////////////////////////////////////////////////////////////////////////// #if !defined(_RELEASE) -static ITexture* GetColorAlphaTestTexture() +static AZ::Data::Instance GetColorAlphaTestTexture() { - static ITexture* testImageColorAlpha = nullptr; + static AZ::Data::Instance testImageColorAlpha = nullptr; if (!testImageColorAlpha) { @@ -347,14 +378,12 @@ static void DebugDrawColoredBox(AZ::Vector2 pos, AZ::Vector2 size, AZ::Color col IDraw2d::HAlign horizontalAlignment = IDraw2d::HAlign::Left, IDraw2d::VAlign verticalAlignment = IDraw2d::VAlign::Top) { - IDraw2d* draw2d = Draw2dHelper::GetDraw2d(); - IRenderer* renderer = gEnv->pRenderer; + CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d(); IDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions(); - int whiteTextureId = renderer->GetWhiteTextureId(); - imageOptions.color = color.GetAsVector3(); - draw2d->DrawImageAligned(whiteTextureId, pos, size, horizontalAlignment, verticalAlignment, + auto whiteTexture = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::White); + draw2d->DrawImageAligned(whiteTexture, pos, size, horizontalAlignment, verticalAlignment, color.GetA(), 0.0f, nullptr, &imageOptions); } #endif @@ -364,7 +393,7 @@ static void DebugDrawColoredBox(AZ::Vector2 pos, AZ::Vector2 size, AZ::Color col static void DebugDrawStringWithSizeBox(IFFont* font, unsigned int effectIndex, const char* sizeString, const char* testString, AZ::Vector2 pos, float spacing, float size) { - IDraw2d* draw2d = Draw2dHelper::GetDraw2d(); + CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d(); IDraw2d::TextOptions textOptions = draw2d->GetDefaultTextOptions(); if (font) @@ -398,9 +427,7 @@ static void DebugDrawStringWithSizeBox(IFFont* font, unsigned int effectIndex, c #if !defined(_RELEASE) static void DebugDraw2dFontSizes(IFFont* font, unsigned int effectIndex, const char* fontName) { - IDraw2d* draw2d = Draw2dHelper::GetDraw2d(); - - draw2d->BeginDraw2d(g_deferDrawsToEndOfFrame); + CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d(); float xOffset = 20.0f; float yOffset = 20.0f; @@ -463,8 +490,6 @@ static void DebugDraw2dFontSizes(IFFont* font, unsigned int effectIndex, const c yOffset += 55.0f; DebugDrawStringWithSizeBox(font, effectIndex, "Size 49", testString, AZ::Vector2(xOffset, yOffset), xSpacing, 49); - - draw2d->EndDraw2d(); } #endif @@ -524,7 +549,7 @@ static void DebugDrawAlignedTextWithOriginBox(AZ::Vector2 pos, #if !defined(_RELEASE) static void DebugDraw2dFontAlignment() { - IDraw2d* draw2d = Draw2dHelper::GetDraw2d(); + CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d(); float w = draw2d->GetViewportWidth(); float yPos = 20; @@ -591,7 +616,7 @@ static void DebugDraw2dFontAlignment() #if !defined(_RELEASE) static AZ::Vector2 DebugDrawFontColorTestBox(AZ::Vector2 pos, const char* string, AZ::Vector3 color, float opacity) { - IDraw2d* draw2d = Draw2dHelper::GetDraw2d(); + CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d(); float pointSize = 32.0f; const float spacing = 6.0f; @@ -626,9 +651,7 @@ static AZ::Vector2 DebugDrawFontColorTestBox(AZ::Vector2 pos, const char* string #if !defined(_RELEASE) static void DebugDraw2dFontColorAndOpacity() { - IDraw2d* draw2d = Draw2dHelper::GetDraw2d(); - - draw2d->BeginDraw2d(g_deferDrawsToEndOfFrame); + CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d(); AZ::Vector2 size; AZ::Vector2 pos(20.0f, 20.0f); @@ -659,8 +682,6 @@ static void DebugDraw2dFontColorAndOpacity() draw2d->DrawText("Opacity=0.25f", pos, 24.0f); pos.SetX(pos.GetX() + 200.0f); draw2d->DrawText("Opacity=0.00f", pos, 24.0f); - - draw2d->EndDraw2d(); } #endif @@ -668,16 +689,11 @@ static void DebugDraw2dFontColorAndOpacity() #if !defined(_RELEASE) static void DebugDraw2dImageRotations() { - IDraw2d* draw2d = Draw2dHelper::GetDraw2d(); - - ITexture* texture = GetMonoTestTexture(); - int texId = texture->GetTextureID(); + CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d(); - draw2d->BeginDraw2d(g_deferDrawsToEndOfFrame); + AZ::Data::Instance texture = GetMonoTestTexture(); - float width = (float)texture->GetWidth(); - float height = (float)texture->GetHeight(); - AZ::Vector2 size(width, height); + AZ::Vector2 size = GetTextureSize(texture); float row = 20.0f; float xSpacing = size.GetX() * 2.0f; @@ -690,7 +706,7 @@ static void DebugDraw2dImageRotations() for (int i = 0; i < 10; ++i) { AZ::Vector2 pos(xStart + xSpacing * i, row); - draw2d->DrawImage(texId, pos, size, 1.0f, 45.0f * i); + draw2d->DrawImage(texture, pos, size, 1.0f, 45.0f * i); DebugDrawColoredBox(AZ::Vector2(pos.GetX() - 2, pos.GetY() - 2), AZ::Vector2(5, 5), posBoxColor); } @@ -703,7 +719,7 @@ static void DebugDraw2dImageRotations() { AZ::Vector2 pos(xStart + xSpacing * i, row); AZ::Vector2 pivot = pos + pivotOffset; - draw2d->DrawImage(texId, pos, size, 1.0f, 45.0f * i, &pivot); + draw2d->DrawImage(texture, pos, size, 1.0f, 45.0f * i, &pivot); DebugDrawColoredBox(AZ::Vector2(pos.GetX() - 2, pos.GetY() - 2), AZ::Vector2(5, 5), posBoxColor); DebugDrawColoredBox(AZ::Vector2(pivot.GetX() - 2, pivot.GetY() - 2), AZ::Vector2(5, 5), pivotBoxColor); } @@ -715,11 +731,9 @@ static void DebugDraw2dImageRotations() for (int i = 0; i < 10; ++i) { AZ::Vector2 pos(xStart + xSpacing * i + size.GetX() * 0.5f, row + size.GetY() * 0.5f); - draw2d->DrawImageAligned(texId, pos, size, IDraw2d::HAlign::Center, IDraw2d::VAlign::Center, 1.0f, 45.0f * i); + draw2d->DrawImageAligned(texture, pos, size, IDraw2d::HAlign::Center, IDraw2d::VAlign::Center, 1.0f, 45.0f * i); DebugDrawColoredBox(AZ::Vector2(pos.GetX() - 2, pos.GetY() - 2), AZ::Vector2(5, 5), posBoxColor); } - - draw2d->EndDraw2d(); } #endif @@ -727,22 +741,17 @@ static void DebugDraw2dImageRotations() #if !defined(_RELEASE) static void DebugDraw2dImageColor() { - IDraw2d* draw2d = Draw2dHelper::GetDraw2d(); + CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d(); - ITexture* texture = GetMonoAlphaTestTexture(); - int texId = texture->GetTextureID(); + AZ::Data::Instance texture = GetMonoAlphaTestTexture(); IDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions(); - draw2d->BeginDraw2d(g_deferDrawsToEndOfFrame); - draw2d->DrawText( "Testing image colors, image is black and white, top row is opacity=1, bottom row is opacity = 0.5", AZ::Vector2(20, 20), 16); - float width = texture->GetWidth() * 2.0f; - float height = texture->GetHeight() * 2.0f; - AZ::Vector2 size(width, height); + AZ::Vector2 size = GetTextureSize(texture) * 2.0f; float xStart = 20.0f; float yStart = 50.0f; @@ -755,14 +764,12 @@ static void DebugDraw2dImageColor() // Draw the image with this color imageOptions.color = g_colorVec3[color]; - draw2d->DrawImage(texId, pos, size, 1.0f, 0.0f, 0, 0, &imageOptions); + draw2d->DrawImage(texture, pos, size, 1.0f, 0.0f, 0, 0, &imageOptions); // draw below with half opacity to test combination of color and opacity pos.SetY(pos.GetY() + ySpacing); - draw2d->DrawImage(texId, pos, size, 0.5f, 0.0f, 0, 0, &imageOptions); + draw2d->DrawImage(texture, pos, size, 0.5f, 0.0f, 0, 0, &imageOptions); } - - draw2d->EndDraw2d(); } #endif @@ -770,24 +777,20 @@ static void DebugDraw2dImageColor() #if !defined(_RELEASE) static void DebugDraw2dImageBlendMode() { - IDraw2d* draw2d = Draw2dHelper::GetDraw2d(); - IRenderer* renderer = gEnv->pRenderer; + CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d(); - int whiteTextureId = renderer->GetWhiteTextureId(); + auto whiteTexture = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::White); - ITexture* texture = GetColorAlphaTestTexture(); - int texId = texture->GetTextureID(); + AZ::Data::Instance texture = GetColorAlphaTestTexture(); IDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions(); - draw2d->BeginDraw2d(g_deferDrawsToEndOfFrame); - draw2d->DrawText("Testing blend modes, src blend changes across x-axis, dst blend changes across y axis", AZ::Vector2(20, 20), 16); - float width = (float)texture->GetWidth(); - float height = (float)texture->GetHeight(); - AZ::Vector2 size(width, height); + AZ::Vector2 size = GetTextureSize(texture); + float width = size.GetX(); + float height = size.GetY(); float xStart = 20.0f; float yStart = 60.0f; @@ -824,16 +827,14 @@ static void DebugDraw2dImageBlendMode() AZ::Vector2(0.0f, 1.0f) }, }; - draw2d->DrawQuad(whiteTextureId, verts); + draw2d->DrawQuad(whiteTexture, verts); // Draw the image with this color imageOptions.blendMode = g_srcBlendModes[srcIndex] | g_dstBlendModes[dstIndex]; - draw2d->DrawImage(texId, pos, size, 1.0f, 0.0f, 0, 0, &imageOptions); + draw2d->DrawImage(texture, pos, size, 1.0f, 0.0f, 0, 0, &imageOptions); } } - - draw2d->EndDraw2d(); } #endif @@ -841,20 +842,17 @@ static void DebugDraw2dImageBlendMode() #if !defined(_RELEASE) static void DebugDraw2dImageUVs() { - IDraw2d* draw2d = Draw2dHelper::GetDraw2d(); + CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d(); - ITexture* texture = GetColorTestTexture(); - int texId = texture->GetTextureID(); + AZ::Data::Instance texture = GetColorTestTexture(); IDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions(); - draw2d->BeginDraw2d(g_deferDrawsToEndOfFrame); - draw2d->DrawText( "Testing DrawImage with minMaxTexCoords. Full image, top left quadrant, middle section, full flipped", AZ::Vector2(20, 20), 16); - AZ::Vector2 size((float)texture->GetWidth() * 2.0f, (float)texture->GetHeight() * 2.0f); + AZ::Vector2 size = GetTextureSize(texture) * 2.0f; float xStart = 20.0f; float yStart = 50.0f; @@ -867,27 +865,25 @@ static void DebugDraw2dImageUVs() // full image minMaxTexCoords[0] = AZ::Vector2(0, 0); minMaxTexCoords[1] = AZ::Vector2(1, 1); - draw2d->DrawImage(texId, pos, size, 1.0f, 0.0f, 0, minMaxTexCoords); + draw2d->DrawImage(texture, pos, size, 1.0f, 0.0f, 0, minMaxTexCoords); // top left quadrant of image pos.SetX(pos.GetX() + xSpacing); minMaxTexCoords[0] = AZ::Vector2(0, 0); minMaxTexCoords[1] = AZ::Vector2(0.5, 0.5); - draw2d->DrawImage(texId, pos, size, 1.0f, 0.0f, 0, minMaxTexCoords); + draw2d->DrawImage(texture, pos, size, 1.0f, 0.0f, 0, minMaxTexCoords); // middle of image pos.SetX(pos.GetX() + xSpacing); minMaxTexCoords[0] = AZ::Vector2(0.25, 0.25); minMaxTexCoords[1] = AZ::Vector2(0.75, 0.75); - draw2d->DrawImage(texId, pos, size, 1.0f, 0.0f, 0, minMaxTexCoords); + draw2d->DrawImage(texture, pos, size, 1.0f, 0.0f, 0, minMaxTexCoords); // flip of image pos.SetX(pos.GetX() + xSpacing); minMaxTexCoords[0] = AZ::Vector2(0.0, 1.0); minMaxTexCoords[1] = AZ::Vector2(1.0, 0.0); - draw2d->DrawImage(texId, pos, size, 1.0f, 0.0f, 0, minMaxTexCoords); - - draw2d->EndDraw2d(); + draw2d->DrawImage(texture, pos, size, 1.0f, 0.0f, 0, minMaxTexCoords); } #endif @@ -895,18 +891,15 @@ static void DebugDraw2dImageUVs() #if !defined(_RELEASE) static void DebugDraw2dImagePixelRounding() { - IDraw2d* draw2d = Draw2dHelper::GetDraw2d(); + CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d(); - ITexture* texture = GetColorTestTexture(); - int texId = texture->GetTextureID(); + AZ::Data::Instance texture = GetColorTestTexture(); IDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions(); - draw2d->BeginDraw2d(g_deferDrawsToEndOfFrame); - draw2d->DrawText("Testing DrawImage pixel rounding options", AZ::Vector2(20, 20), 16); - AZ::Vector2 size((float)texture->GetWidth(), (float)texture->GetHeight()); + AZ::Vector2 size = GetTextureSize(texture); float xStart = 20.0f; float yStart = 50.0f; @@ -929,11 +922,9 @@ static void DebugDraw2dImagePixelRounding() imageOptions.pixelRounding = roundings[j]; - draw2d->DrawImage(texId, pos, size, 1.0f, 0.0f, 0, 0, &imageOptions); + draw2d->DrawImage(texture, pos, size, 1.0f, 0.0f, 0, 0, &imageOptions); } } - - draw2d->EndDraw2d(); } #endif @@ -941,12 +932,10 @@ static void DebugDraw2dImagePixelRounding() #if !defined(_RELEASE) static void DebugDraw2dLineBasic() { - IDraw2d* draw2d = Draw2dHelper::GetDraw2d(); + CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d(); IDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions(); - draw2d->BeginDraw2d(g_deferDrawsToEndOfFrame); - draw2d->DrawText("Testing DrawLine", AZ::Vector2(20, 20), 16); AZ::Vector2 center = AZ::Vector2(draw2d->GetViewportWidth() * 0.5f, draw2d->GetViewportHeight() * 0.5f); @@ -963,8 +952,6 @@ static void DebugDraw2dLineBasic() draw2d->DrawLine(center, center + AZ::Vector2(-offset, -offset), AZ::Color(0.0f, 0.0f, 1.0f, 1.0f)); draw2d->DrawLine(center, center + AZ::Vector2(0, -offset), AZ::Color(1.0f, 0.0f, 1.0f, 1.0f)); draw2d->DrawLine(center, center + AZ::Vector2(offset, -offset), AZ::Color(0.0f, 0.0f, 0.0f, 1.0f)); - - draw2d->EndDraw2d(); } #endif @@ -1436,13 +1423,17 @@ void LyShineDebug::RenderDebug() #if !defined(_RELEASE) #ifndef EXCLUDE_DOCUMENTATION_PURPOSE - if (!Draw2dHelper::GetDraw2d()) + CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d(); + if (!draw2d) { return; } g_deferDrawsToEndOfFrame = (CV_r_DebugUIDraw2dDefer) ? true : false; + // Set whether to defer draws or render immediately during scope of this helper + Draw2dHelper draw2dHelper(g_deferDrawsToEndOfFrame); + if (CV_r_DebugUIDraw2dFont) { switch (CV_r_DebugUIDraw2dFont) diff --git a/Gems/LyShine/Code/Source/UiCanvasComponent.cpp b/Gems/LyShine/Code/Source/UiCanvasComponent.cpp index f386d5756b..2af773734c 100644 --- a/Gems/LyShine/Code/Source/UiCanvasComponent.cpp +++ b/Gems/LyShine/Code/Source/UiCanvasComponent.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -2224,13 +2225,13 @@ void UiCanvasComponent::DebugReportDrawCalls(AZ::IO::HandleType fileHandle, LySh } //////////////////////////////////////////////////////////////////////////////////////////////////// -void UiCanvasComponent::DebugDisplayElemBounds(IDraw2d* draw2d) const +void UiCanvasComponent::DebugDisplayElemBounds(CDraw2d* draw2d) const { DebugDisplayChildElemBounds(draw2d, m_rootElement); } //////////////////////////////////////////////////////////////////////////////////////////////////// -void UiCanvasComponent::DebugDisplayChildElemBounds(IDraw2d* draw2d, const AZ::EntityId entity) const +void UiCanvasComponent::DebugDisplayChildElemBounds(CDraw2d* draw2d, const AZ::EntityId entity) const { AZ::u64 time = AZStd::GetTimeUTCMilliSecond(); uint32 fractionsOfOneSecond = time % 1000; diff --git a/Gems/LyShine/Code/Source/UiCanvasComponent.h b/Gems/LyShine/Code/Source/UiCanvasComponent.h index 6e59a0899f..3e7171c642 100644 --- a/Gems/LyShine/Code/Source/UiCanvasComponent.h +++ b/Gems/LyShine/Code/Source/UiCanvasComponent.h @@ -42,6 +42,7 @@ namespace AZ } struct SDepthTexture; +class CDraw2d; //////////////////////////////////////////////////////////////////////////////////////////////////// class UiCanvasComponent @@ -287,8 +288,8 @@ public: // member functions void DebugReportDrawCalls(AZ::IO::HandleType fileHandle, LyShineDebug::DebugInfoDrawCallReport& reportInfo, void* context) const; - void DebugDisplayElemBounds(IDraw2d* draw2d) const; - void DebugDisplayChildElemBounds(IDraw2d* draw2d, const AZ::EntityId entity) const; + void DebugDisplayElemBounds(CDraw2d* draw2d) const; + void DebugDisplayChildElemBounds(CDraw2d* draw2d, const AZ::EntityId entity) const; #endif public: // static member functions diff --git a/Gems/LyShine/Code/Source/UiCanvasManager.cpp b/Gems/LyShine/Code/Source/UiCanvasManager.cpp index 380095a289..6575a1d2f0 100644 --- a/Gems/LyShine/Code/Source/UiCanvasManager.cpp +++ b/Gems/LyShine/Code/Source/UiCanvasManager.cpp @@ -11,6 +11,7 @@ */ #include "LyShine_precompiled.h" #include "UiCanvasManager.h" +#include #include "UiCanvasFileObject.h" #include "UiCanvasComponent.h" @@ -33,6 +34,8 @@ #include #include +#include + #ifndef _RELEASE #include #endif @@ -998,16 +1001,15 @@ void UiCanvasManager::DebugDisplayCanvasData(int setting) const { bool onlyShowEnabledCanvases = (setting == 2) ? true : false; - IDraw2d* draw2d = Draw2dHelper::GetDraw2d(); - - draw2d->BeginDraw2d(false); + CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d(); float xOffset = 20.0f; float yOffset = 20.0f; const int elementNameFieldLength = 20; - int blackTexture = gEnv->pRenderer->GetBlackTextureId(); + auto blackTexture = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::Black); + float textOpacity = 1.0f; float backgroundRectOpacity = 0.75f; @@ -1152,21 +1154,17 @@ void UiCanvasManager::DebugDisplayCanvasData(int setting) const totalEnabledIntrs, totalEnabledUpdates); WriteLine(buffer, red); - - draw2d->EndDraw2d(); } //////////////////////////////////////////////////////////////////////////////////////////////////// void UiCanvasManager::DebugDisplayDrawCallData() const { - IDraw2d* draw2d = Draw2dHelper::GetDraw2d(); - - draw2d->BeginDraw2d(false); + CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d(); float xOffset = 20.0f; float yOffset = 20.0f; - int blackTexture = gEnv->pRenderer->GetBlackTextureId(); + auto blackTexture = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::Black); float textOpacity = 1.0f; float backgroundRectOpacity = 0.75f; const float lineSpacing = 20.0f; @@ -1293,8 +1291,6 @@ void UiCanvasManager::DebugDisplayDrawCallData() const totalDueToMaxVerts, totalDueToTextures); WriteLine(buffer, red); - - draw2d->EndDraw2d(); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1492,9 +1488,7 @@ void UiCanvasManager::DebugReportDrawCalls(const AZStd::string& name) const //////////////////////////////////////////////////////////////////////////////////////////////////// void UiCanvasManager::DebugDisplayElemBounds(int canvasIndexFilter) const { - IDraw2d* draw2d = Draw2dHelper::GetDraw2d(); - - draw2d->BeginDraw2d(false); + CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d(); int canvasIndex = 0; for (auto canvas : m_loadedCanvases) @@ -1515,8 +1509,6 @@ void UiCanvasManager::DebugDisplayElemBounds(int canvasIndexFilter) const ++canvasIndex; // only increments for enabled canvases so index matches "ui_DisplayCanvasData 2" } - - draw2d->EndDraw2d(); } #endif diff --git a/Gems/LyShine/Code/Source/UiFaderComponent.cpp b/Gems/LyShine/Code/Source/UiFaderComponent.cpp index 96690db7c9..3259da0480 100644 --- a/Gems/LyShine/Code/Source/UiFaderComponent.cpp +++ b/Gems/LyShine/Code/Source/UiFaderComponent.cpp @@ -11,6 +11,7 @@ */ #include "LyShine_precompiled.h" #include "UiFaderComponent.h" +#include #include #include diff --git a/Gems/LyShine/Code/Source/UiImageComponent.cpp b/Gems/LyShine/Code/Source/UiImageComponent.cpp index b5b407c421..02ea1467dc 100644 --- a/Gems/LyShine/Code/Source/UiImageComponent.cpp +++ b/Gems/LyShine/Code/Source/UiImageComponent.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include #include #include diff --git a/Gems/LyShine/Code/Source/UiImageSequenceComponent.cpp b/Gems/LyShine/Code/Source/UiImageSequenceComponent.cpp index 518be03751..e6cbef8386 100644 --- a/Gems/LyShine/Code/Source/UiImageSequenceComponent.cpp +++ b/Gems/LyShine/Code/Source/UiImageSequenceComponent.cpp @@ -12,7 +12,7 @@ #include "LyShine_precompiled.h" #include "UiImageSequenceComponent.h" -#include +#include #include #include #include diff --git a/Gems/LyShine/Code/Source/UiMaskComponent.cpp b/Gems/LyShine/Code/Source/UiMaskComponent.cpp index df49673858..f7452108e7 100644 --- a/Gems/LyShine/Code/Source/UiMaskComponent.cpp +++ b/Gems/LyShine/Code/Source/UiMaskComponent.cpp @@ -11,6 +11,7 @@ */ #include "LyShine_precompiled.h" #include "UiMaskComponent.h" +#include #include #include @@ -23,7 +24,6 @@ #include #include #include -#include //////////////////////////////////////////////////////////////////////////////////////////////////// // PUBLIC MEMBER FUNCTIONS diff --git a/Gems/LyShine/Code/Source/UiTextComponent.cpp b/Gems/LyShine/Code/Source/UiTextComponent.cpp index a718cc8e53..b1092ab92f 100644 --- a/Gems/LyShine/Code/Source/UiTextComponent.cpp +++ b/Gems/LyShine/Code/Source/UiTextComponent.cpp @@ -28,11 +28,11 @@ #include #include #include +#include #include #include "UiSerialize.h" -#include "Draw2d.h" #include "TextMarkup.h" #include "UiTextComponentOffsetsSelector.h" #include "StringUtfUtils.h" diff --git a/Gems/LyShine/Code/lyshine_static_files.cmake b/Gems/LyShine/Code/lyshine_static_files.cmake index 140debff84..8491a66030 100644 --- a/Gems/LyShine/Code/lyshine_static_files.cmake +++ b/Gems/LyShine/Code/lyshine_static_files.cmake @@ -11,7 +11,7 @@ set(FILES Source/Draw2d.cpp - Source/Draw2d.h + Include/LyShine/Draw2d.h Source/LyShine.cpp Source/LyShine.h Source/LyShineDebug.cpp diff --git a/Gems/LyShineExamples/Code/CMakeLists.txt b/Gems/LyShineExamples/Code/CMakeLists.txt index ccf49ba467..372bfa948b 100644 --- a/Gems/LyShineExamples/Code/CMakeLists.txt +++ b/Gems/LyShineExamples/Code/CMakeLists.txt @@ -23,6 +23,7 @@ ly_add_target( PUBLIC Legacy::CryCommon Gem::LmbrCentral + Gem::LyShine.Static ) ly_add_target( diff --git a/Gems/LyShineExamples/Code/Source/UiCustomImageComponent.cpp b/Gems/LyShineExamples/Code/Source/UiCustomImageComponent.cpp index 4ff8128d47..80750efe7f 100644 --- a/Gems/LyShineExamples/Code/Source/UiCustomImageComponent.cpp +++ b/Gems/LyShineExamples/Code/Source/UiCustomImageComponent.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include #include #include diff --git a/Gems/SceneProcessing/Code/Source/Generation/Components/MeshOptimizer/MeshOptimizerComponent.cpp b/Gems/SceneProcessing/Code/Source/Generation/Components/MeshOptimizer/MeshOptimizerComponent.cpp index 64ea69f4e4..464ac1e334 100644 --- a/Gems/SceneProcessing/Code/Source/Generation/Components/MeshOptimizer/MeshOptimizerComponent.cpp +++ b/Gems/SceneProcessing/Code/Source/Generation/Components/MeshOptimizer/MeshOptimizerComponent.cpp @@ -102,6 +102,7 @@ namespace AZ::SceneGenerationComponents MeshOptimizerComponent::MeshOptimizerComponent() { + BindToCall(&MeshOptimizerComponent::OptimizeMeshes); } void MeshOptimizerComponent::Reflect(AZ::ReflectContext* context) @@ -109,7 +110,7 @@ namespace AZ::SceneGenerationComponents auto* serializeContext = azrtti_cast(context); if (serializeContext) { - serializeContext->Class()->Version(1); + serializeContext->Class()->Version(2); } } diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/NodePalette/NodePaletteModel.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/NodePalette/NodePaletteModel.cpp index 4154c3982e..2edc950e6f 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/NodePalette/NodePaletteModel.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/NodePalette/NodePaletteModel.cpp @@ -57,7 +57,7 @@ namespace { if (excludeAttributeData) { - AZ::u64 exclusionFlags = AZ::Script::Attributes::ExcludeFlags::List | AZ::Script::Attributes::ExcludeFlags::ListOnly | AZ::ScriptCanvasAttributes::VariableCreationForbidden; + AZ::u64 exclusionFlags = AZ::Script::Attributes::ExcludeFlags::List | AZ::Script::Attributes::ExcludeFlags::ListOnly; if (typeId == AzToolsFramework::Components::EditorComponentBase::TYPEINFO_Uuid()) { @@ -143,11 +143,6 @@ namespace { return; } - - if (!ScriptCanvas::Data::IsAllowedBehaviorClassVariableType(behaviorClass->m_typeId)) - { - return; - } } const auto isExposableOutcome = ScriptCanvas::IsExposable(method); @@ -479,38 +474,24 @@ namespace continue; } - // Only bind Behavior Classes marked with the Scope type of Launcher + if (auto excludeFromPointer = AZ::FindAttribute(AZ::Script::Attributes::ExcludeFrom, behaviorClass->m_attributes)) + { + AZ::Script::Attributes::ExcludeFlags excludeFlags{}; + AZ::AttributeReader(nullptr, excludeFromPointer).Read(excludeFlags); + + if ((excludeFlags & (AZ::Script::Attributes::ExcludeFlags::List | AZ::Script::Attributes::ExcludeFlags::ListOnly)) != 0) + { + continue; + } + } + if (!AZ::Internal::IsInScope(behaviorClass->m_attributes, AZ::Script::Attributes::ScopeFlags::Launcher)) { - continue; // skip this class + continue; } // Objects and Object methods { - bool canCreate = serializeContext->FindClassData(behaviorClass->m_typeId) != nullptr && - !HasAttribute(behaviorClass, AZ::ScriptCanvasAttributes::VariableCreationForbidden); - - // In order to create variables, the class must have full memory support - canCreate = canCreate && - (behaviorClass->m_allocate - && behaviorClass->m_cloner - && behaviorClass->m_mover - && behaviorClass->m_destructor - && behaviorClass->m_deallocate); - - if (canCreate) - { - // Do not allow variable creation for data that derives from AZ::Component - for (auto base : behaviorClass->m_baseClasses) - { - if (AZ::Component::TYPEINFO_Uuid() == base) - { - canCreate = false; - break; - } - } - } - AZStd::string categoryPath; AZStd::string translationContext = ScriptCanvasEditor::TranslationHelper::GetContextName(ScriptCanvasEditor::TranslationContextGroup::ClassMethod, behaviorClass->m_name); @@ -530,17 +511,14 @@ namespace } } - if (canCreate) - { - auto dataRegistry = ScriptCanvas::GetDataRegistry(); - ScriptCanvas::Data::Type type = dataRegistry->m_typeIdTraitMap[ScriptCanvas::Data::eType::BehaviorContextObject].m_dataTraits.GetSCType(behaviorClass->m_typeId); + auto dataRegistry = ScriptCanvas::GetDataRegistry(); + ScriptCanvas::Data::Type type = dataRegistry->m_typeIdTraitMap[ScriptCanvas::Data::eType::BehaviorContextObject].m_dataTraits.GetSCType(behaviorClass->m_typeId); - if (type.IsValid()) + if (type.IsValid()) + { + if (dataRegistry->m_creatableTypes.contains(type)) { - if (!AZ::FindAttribute(AZ::ScriptCanvasAttributes::AllowInternalCreation, behaviorClass->m_attributes)) - { - ScriptCanvasEditor::VariablePaletteRequestBus::Broadcast(&ScriptCanvasEditor::VariablePaletteRequests::RegisterVariableType, type); - } + ScriptCanvasEditor::VariablePaletteRequestBus::Broadcast(&ScriptCanvasEditor::VariablePaletteRequests::RegisterVariableType, type); } } diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/VariablePaletteTableView.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/VariablePaletteTableView.cpp index a05468d565..9bec796f53 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/VariablePaletteTableView.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/VariablePaletteTableView.cpp @@ -122,8 +122,8 @@ namespace ScriptCanvasEditor for (const AZ::Uuid& objectId : objectTypes) { - // Verify whether this is an allowed BC variable type - if (!ScriptCanvas::Data::IsAllowedBehaviorClassVariableType(objectId)) + ScriptCanvas::Data::Type type = dataRegistry->m_typeIdTraitMap[ScriptCanvas::Data::eType::BehaviorContextObject].m_dataTraits.GetSCType(objectId); + if (!type.IsValid() || !dataRegistry->m_creatableTypes.contains(type)) { continue; } diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/SlotConfigurations.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/SlotConfigurations.cpp index bc6445e6e3..17dd68c084 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/SlotConfigurations.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/SlotConfigurations.cpp @@ -105,11 +105,9 @@ namespace ScriptCanvas void DataSlotConfiguration::SetType(const AZ::BehaviorParameter& typeDesc) { - auto dataRegistry = GetDataRegistry(); Data::Type scType = !AZ::BehaviorContextHelper::IsStringParameter(typeDesc) ? Data::FromAZType(typeDesc.m_typeId) : Data::Type::String(); - auto typeIter = dataRegistry->m_creatableTypes.find(scType); - - if (typeIter != dataRegistry->m_creatableTypes.end()) + auto dataRegistry = GetDataRegistry(); + if (dataRegistry->IsUseableInSlot(scType)) { m_datum.SetType(scType); } diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Data/Data.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Data/Data.cpp index e71c97e89a..2653b1495f 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Data/Data.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Data/Data.cpp @@ -389,29 +389,6 @@ namespace ScriptCanvas return AZ::Utils::IsVectorContainerType(ToAZType(type)); } - bool IsAllowedBehaviorClassVariableType(const AZ::Uuid& id) - { - AZ::BehaviorContext* behaviorContext = nullptr; - AZ::ComponentApplicationBus::BroadcastResult(behaviorContext, &AZ::ComponentApplicationRequests::GetBehaviorContext); - AZ_Assert(behaviorContext, "Unable to retrieve behavior context."); - - const auto& classIterator = behaviorContext->m_typeToClassMap.find(id); - if (classIterator != behaviorContext->m_typeToClassMap.end()) - { - AZ::BehaviorClass* behaviorClass = classIterator->second; - if (behaviorClass->FindAttribute(AZ::ScriptCanvasAttributes::VariableCreationForbidden)) - { - return false; - } - } - else - { - return false; - } - - return true; - } - bool IsSetContainerType(const AZ::Uuid& type) { return AZ::Utils::IsSetContainerType(type); diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Data/Data.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Data/Data.h index 64dc8999f7..59530d934d 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Data/Data.h +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Data/Data.h @@ -197,8 +197,6 @@ namespace ScriptCanvas bool IsVectorContainerType(const AZ::Uuid& type); bool IsVectorContainerType(const Type& type); - bool IsAllowedBehaviorClassVariableType(const AZ::Uuid& id); - AZStd::vector GetContainedTypes(const AZ::Uuid& type); AZStd::vector GetContainedTypes(const Type& type); AZStd::pair GetOutcomeTypes(const AZ::Uuid& type); diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Data/DataRegistry.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Data/DataRegistry.cpp index 85cdf56458..9068ba0172 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Data/DataRegistry.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Data/DataRegistry.cpp @@ -105,14 +105,24 @@ namespace ScriptCanvas AZ_Error("Script Canvas", it.second, "Cannot register a second Trait struct with the same ScriptCanvas type(%u)", it.first->first); } - void DataRegistry::RegisterType(const AZ::TypeId& typeId, TypeProperties typeProperties) + void DataRegistry::RegisterType(const AZ::TypeId& typeId, TypeProperties typeProperties, Createability registration) { Data::Type behaviorContextType = Data::FromAZType(typeId); if (behaviorContextType.GetType() == Data::eType::BehaviorContextObject && !behaviorContextType.GetAZType().IsNull()) { - if (m_creatableTypes.find(behaviorContextType) == m_creatableTypes.end()) + if (registration == Createability::SlotAndVariable) { - m_creatableTypes[behaviorContextType] = typeProperties; + if (m_creatableTypes.find(behaviorContextType) == m_creatableTypes.end()) + { + m_creatableTypes[behaviorContextType] = typeProperties; + } + } + else if (registration == Createability::SlotOnly) + { + if (m_slottableTypes.find(behaviorContextType) == m_slottableTypes.end()) + { + m_slottableTypes[behaviorContextType] = typeProperties; + } } } } @@ -125,4 +135,15 @@ namespace ScriptCanvas m_creatableTypes.erase(behaviorContextType); } } -} \ No newline at end of file + + bool DataRegistry::IsUseableInSlot(const Data::Type& scType) const + { + return m_creatableTypes.contains(scType) || m_slottableTypes.contains(scType); + } + + bool DataRegistry::IsUseableInSlot(const AZ::TypeId& typeId) const + { + Data::Type scType = Data::FromAZType(typeId); + return IsUseableInSlot(scType); + } +} diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Data/DataRegistry.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Data/DataRegistry.h index 57a67c79d9..c4837ebd27 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Data/DataRegistry.h +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Data/DataRegistry.h @@ -34,11 +34,21 @@ namespace ScriptCanvas AZ_TYPE_INFO(DataRegistry, "{41049FA8-EA56-401F-9720-6FE9028A1C01}"); AZ_CLASS_ALLOCATOR(DataRegistry, AZ::SystemAllocator, 0); - void RegisterType(const AZ::TypeId& typeId, TypeProperties typeProperties); + enum class Createability + { + None, + SlotAndVariable, + SlotOnly, + }; + void RegisterType(const AZ::TypeId& typeId, TypeProperties typeProperties, Createability registration); void UnregisterType(const AZ::TypeId& typeId); + bool IsUseableInSlot(const AZ::TypeId& typeId) const; + bool IsUseableInSlot(const Data::Type& type) const; + AZStd::unordered_map m_typeIdTraitMap; // Creates a mapping of the Data::eType TypeId to the trait structure AZStd::unordered_map m_creatableTypes; + AZStd::unordered_map m_slottableTypes; }; void InitDataRegistry(); diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/UnitTesting/UnitTestBusSender.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/UnitTesting/UnitTestBusSender.cpp index e6ab482ef4..9cac7bd021 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/UnitTesting/UnitTestBusSender.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/UnitTesting/UnitTestBusSender.cpp @@ -388,9 +388,8 @@ namespace ScriptCanvas { AZ::ScriptCanvasAttributes::HiddenIndices uniqueIdIndex = { 0 }; - auto builder = behaviorContext->Class("Unit Testing") - ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) - ; + auto builder = behaviorContext->Class("Unit Testing"); + builder->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common); builder->Method("Add Failure", &EventSender::AddFailure, { { {"", "", behaviorContext->MakeDefaultValue(UniqueId)}, {"Report", "additional notes for the test report"} } }) ->Attribute(AZ::ScriptCanvasAttributes::HiddenParameterIndex, uniqueIdIndex) diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/SystemComponent.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/SystemComponent.h index 3d5acfbee1..3c00562505 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/SystemComponent.h +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/SystemComponent.h @@ -22,6 +22,7 @@ #include #include #include +#include namespace AZ { @@ -65,6 +66,8 @@ namespace ScriptCanvas inline bool IsAnyScriptInterpreted() const { return true; } + AZStd::pair GetCreatibility(AZ::SerializeContext* serializeContext, AZ::BehaviorClass* behaviorClass); + // SystemRequestBus::Handler... bool IsScriptUnitTestingInProgress() override; void MarkScriptUnitTestBegin() override; diff --git a/Gems/ScriptCanvas/Code/Source/SystemComponent.cpp b/Gems/ScriptCanvas/Code/Source/SystemComponent.cpp index bbcbde5c6c..dd0c340357 100644 --- a/Gems/ScriptCanvas/Code/Source/SystemComponent.cpp +++ b/Gems/ScriptCanvas/Code/Source/SystemComponent.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -285,6 +284,72 @@ namespace ScriptCanvas m_ownedObjectsByAddress.erase(object); } + AZStd::pair SystemComponent::GetCreatibility(AZ::SerializeContext* serializeContext, AZ::BehaviorClass* behaviorClass) + { + TypeProperties typeProperties; + + bool canCreate{}; + // BehaviorContext classes with the ExcludeFrom attribute with a value of the ExcludeFlags::List is not creatable + const AZ::u64 exclusionFlags = AZ::Script::Attributes::ExcludeFlags::List; + auto excludeClassAttributeData = azrtti_cast*>(AZ::FindAttribute(AZ::Script::Attributes::ExcludeFrom, behaviorClass->m_attributes)); + + const AZ::u64 flags = excludeClassAttributeData ? excludeClassAttributeData->Get(nullptr) : 0; + bool listOnly = ((flags & AZ::Script::Attributes::ExcludeFlags::ListOnly) == AZ::Script::Attributes::ExcludeFlags::ListOnly); // ListOnly exclusions may create variables + canCreate = listOnly || (!excludeClassAttributeData || (!(flags & exclusionFlags))); + canCreate = canCreate && (serializeContext->FindClassData(behaviorClass->m_typeId)); + canCreate = canCreate && !ScriptCanvasSystemComponentCpp::IsDeprecated(behaviorClass->m_attributes); + + if (canCreate) + { + for (auto base : behaviorClass->m_baseClasses) + { + if (AZ::Component::TYPEINFO_Uuid() == base) + { + canCreate = false; + break; // only out of the for : base classes loop. DO NOT break out of the parent loop. + } + } + } + + // Assets are not safe enough for variable creation, yet. They can be created with one Az type (Data::Asset), but set to nothing. + // When read back in, they will (if lucky) just be Data::Asset, which breaks type safety at best, and requires a lot of sanity checking. + // This is NOT blacked at the createable types or BehaviorContext level, since they could be used to at least pass information through, + // and may be used other scripting contexts. + AZ::IRttiHelper* rttiHelper = behaviorClass->m_azRtti; + if (rttiHelper && rttiHelper->GetGenericTypeId() == azrtti_typeid()) + { + canCreate = false; + } + + if (AZ::FindAttribute(AZ::ScriptCanvasAttributes::AllowInternalCreation, behaviorClass->m_attributes)) + { + canCreate = true; + typeProperties.m_isTransient = true; + } + + // create able variables must have full memory support + canCreate = canCreate && + (behaviorClass->m_allocate + && behaviorClass->m_cloner + && behaviorClass->m_mover + && behaviorClass->m_destructor + && behaviorClass->m_deallocate) && + AZStd::none_of(behaviorClass->m_baseClasses.begin(), behaviorClass->m_baseClasses.end(), [](const AZ::TypeId& base) { return azrtti_typeid() == base; }); + + if (!canCreate) + { + return { DataRegistry::Createability::None , TypeProperties{} }; + } + else if (!AZ::FindAttribute(AZ::ScriptCanvasAttributes::VariableCreationForbidden, behaviorClass->m_attributes)) + { + return { DataRegistry::Createability::SlotAndVariable, typeProperties }; + } + else + { + return { DataRegistry::Createability::SlotOnly, typeProperties }; + } + } + void SystemComponent::RegisterCreatableTypes() { AZ::SerializeContext* serializeContext{}; @@ -297,40 +362,11 @@ namespace ScriptCanvas auto dataRegistry = ScriptCanvas::GetDataRegistry(); for (const auto& classIter : behaviorContext->m_classes) { - TypeProperties typeProperties; - - bool canCreate{}; - const AZ::BehaviorClass* behaviorClass = classIter.second; - // BehaviorContext classes with the ExcludeFrom attribute with a value of the ExcludeFlags::List is not creatable - const AZ::u64 exclusionFlags = AZ::Script::Attributes::ExcludeFlags::List; - auto excludeClassAttributeData = azrtti_cast*>(AZ::FindAttribute(AZ::Script::Attributes::ExcludeFrom, behaviorClass->m_attributes)); - - const AZ::u64 flags = excludeClassAttributeData ? excludeClassAttributeData->Get(nullptr) : 0; - bool listOnly = ((flags & AZ::Script::Attributes::ExcludeFlags::ListOnly) == AZ::Script::Attributes::ExcludeFlags::ListOnly); // ListOnly exclusions may create variables - - canCreate = listOnly || (!excludeClassAttributeData || (!(flags & exclusionFlags))); - canCreate = canCreate && (serializeContext->FindClassData(behaviorClass->m_typeId)); - canCreate = canCreate && !ScriptCanvasSystemComponentCpp::IsDeprecated(behaviorClass->m_attributes); - - if (AZ::FindAttribute(AZ::ScriptCanvasAttributes::AllowInternalCreation, behaviorClass->m_attributes)) - { - canCreate = true; - typeProperties.m_isTransient = true; - } - - // create able variables must have full memory support - canCreate = canCreate && - ( behaviorClass->m_allocate - && behaviorClass->m_cloner - && behaviorClass->m_mover - && behaviorClass->m_destructor - && behaviorClass->m_deallocate) && - AZStd::none_of(behaviorClass->m_baseClasses.begin(), behaviorClass->m_baseClasses.end(), [](const AZ::TypeId& base) { return azrtti_typeid() == base; }); - - if (canCreate) - { - dataRegistry->RegisterType(behaviorClass->m_typeId, typeProperties); - } + auto createability = GetCreatibility(serializeContext, classIter.second); + if (createability.first != DataRegistry::Createability::None) + { + dataRegistry->RegisterType(classIter.second->m_typeId, createability.second, createability.first); + } } } @@ -339,33 +375,19 @@ namespace ScriptCanvas auto dataRegistry = ScriptCanvas::GetDataRegistry(); if (!dataRegistry) { + AZ_Warning("ScriptCanvas", false, "Data registry not available. Can't register new class."); + return; } + AZ::SerializeContext* serializeContext{}; AZ::ComponentApplicationBus::BroadcastResult(serializeContext, &AZ::ComponentApplicationRequests::GetSerializeContext); - AZ_Assert(serializeContext, "Serialize Context should not be missing at this point"); + AZ_Assert(serializeContext, "Serialize Context missing. Can't register new class."); - TypeProperties typeProperties; - - // BehaviorContext classes with the ExcludeFrom attribute with a value of the ExcludeFlags::List is not creatable - const AZ::u64 exclusionFlags = AZ::Script::Attributes::ExcludeFlags::List; - auto excludeClassAttributeData = azrtti_cast*>(AZ::FindAttribute(AZ::Script::Attributes::ExcludeFrom, behaviorClass->m_attributes)); - bool canCreate = !excludeClassAttributeData || !(excludeClassAttributeData->Get(nullptr) & exclusionFlags); - canCreate = canCreate && (serializeContext->FindClassData(behaviorClass->m_typeId) || AZ::FindAttribute(AZ::ScriptCanvasAttributes::AllowInternalCreation, behaviorClass->m_attributes)); - canCreate = canCreate && !ScriptCanvasSystemComponentCpp::IsDeprecated(behaviorClass->m_attributes); - - // create able variables must have full memory support - canCreate = canCreate && - (behaviorClass->m_allocate - && behaviorClass->m_cloner - && behaviorClass->m_mover - && behaviorClass->m_destructor - && behaviorClass->m_deallocate) && - AZStd::none_of(behaviorClass->m_baseClasses.begin(), behaviorClass->m_baseClasses.end(), [](const AZ::TypeId& base) { return azrtti_typeid() == base; }); - - if (canCreate) + auto createability = GetCreatibility(serializeContext, behaviorClass); + if (createability.first != DataRegistry::Createability::None) { - dataRegistry->RegisterType(behaviorClass->m_typeId, typeProperties); + dataRegistry->RegisterType(behaviorClass->m_typeId, createability.second, createability.first); } } diff --git a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake index bd6f8276f7..49628ef456 100644 --- a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake +++ b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake @@ -35,7 +35,7 @@ ly_associate_package(PACKAGE_NAME PVRTexTool-4.24.0-rev4-multiplatform TARG ly_associate_package(PACKAGE_NAME AWSGameLiftServerSDK-3.4.1-rev1-linux TARGETS AWSGameLiftServerSDK PACKAGE_HASH a8149a95bd100384af6ade97e2b21a56173740d921e6c3da8188cd51554d39af) ly_associate_package(PACKAGE_NAME freetype-2.10.4.14-linux TARGETS freetype PACKAGE_HASH 9ad246873067717962c6b780d28a5ce3cef3321b73c9aea746a039c798f52e93) ly_associate_package(PACKAGE_NAME tiff-4.2.0.15-linux TARGETS tiff PACKAGE_HASH ae92b4d3b189c42ef644abc5cac865d1fb2eb7cb5622ec17e35642b00d1a0a76) -ly_associate_package(PACKAGE_NAME AWSNativeSDK-1.7.167-rev3-linux TARGETS AWSNativeSDK PACKAGE_HASH e69c55682638dc1e7fa571a61a82c8a69d395c74a008543a5188f4bd2b6b10c4) +ly_associate_package(PACKAGE_NAME AWSNativeSDK-1.7.167-rev4-linux TARGETS AWSNativeSDK PACKAGE_HASH b4db38de49d35a5f7500aed7f4aee5ec511dd3b584ee06fe9097885690191a5d) ly_associate_package(PACKAGE_NAME Lua-5.3.5-rev5-linux TARGETS Lua PACKAGE_HASH 1adc812abe3dd0dbb2ca9756f81d8f0e0ba45779ac85bf1d8455b25c531a38b0) ly_associate_package(PACKAGE_NAME PhysX-4.1.0.25992954-rev1-linux TARGETS PhysX PACKAGE_HASH e3ca36106a8dbf1524709f8bb82d520920ebd3ff3a92672d382efff406c75ee3) ly_associate_package(PACKAGE_NAME etc2comp-9cd0f9cae0-rev1-linux TARGETS etc2comp PACKAGE_HASH 9283aa5db5bb7fb90a0ddb7a9f3895317c8ebe8044943124bbb3673a41407430) diff --git a/cmake/LYPython.cmake b/cmake/LYPython.cmake index 14ea19a96a..ff5132097c 100644 --- a/cmake/LYPython.cmake +++ b/cmake/LYPython.cmake @@ -268,6 +268,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) ly_pip_install_local_package_editable(${LY_ROOT_FOLDER}/Tools/LyTestTools ly-test-tools) ly_pip_install_local_package_editable(${LY_ROOT_FOLDER}/Tools/RemoteConsole/ly_remote_console ly-remote-console) + ly_pip_install_local_package_editable(${LY_ROOT_FOLDER}/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools editor-python-test-tools) endif() endif() diff --git a/cmake/PAL.cmake b/cmake/PAL.cmake index 5131005c72..c7adb660f0 100644 --- a/cmake/PAL.cmake +++ b/cmake/PAL.cmake @@ -63,10 +63,12 @@ function(ly_get_absolute_pal_filename out_name in_name) set(full_name ${in_name}) if (NOT EXISTS ${full_name}) string(REGEX MATCH "${repo_dir}/(.*)/Platform/([^/]*)/?(.*)$" match ${full_name}) - if(${CMAKE_MATCH_2} IN_LIST PAL_RESTRICTED_PLATFORMS) - set(full_name ${repo_dir}/restricted/${CMAKE_MATCH_2}/${CMAKE_MATCH_1}) - if(NOT "${CMAKE_MATCH_3}" STREQUAL "") - string(APPEND full_name "/" ${CMAKE_MATCH_3}) + if(PAL_RESTRICTED_PLATFORMS) + if("${CMAKE_MATCH_2}" IN_LIST PAL_RESTRICTED_PLATFORMS) + set(full_name ${repo_dir}/restricted/${CMAKE_MATCH_2}/${CMAKE_MATCH_1}) + if(NOT "${CMAKE_MATCH_3}" STREQUAL "") + string(APPEND full_name "/" ${CMAKE_MATCH_3}) + endif() endif() endif() endif() diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index 286f449acd..105b208338 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -265,6 +265,44 @@ function(ly_setup_others) REGEX "runtime" EXCLUDE ) + # Registry + install(DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR}/bin/$/Registry + DESTINATION ./bin/$ + ) + install(DIRECTORY + # This one will change soon, Engine/Registry files will be relocated to Registry + ${CMAKE_SOURCE_DIR}/Engine/Registry + DESTINATION ./Engine + ) + install(FILES + ${CMAKE_SOURCE_DIR}/AssetProcessorPlatformConfig.setreg + DESTINATION ./Registry + ) + + # Qt Binaries + set(QT_BIN_DIRS bearer iconengines imageformats platforms styles translations) + foreach(qt_dir ${QT_BIN_DIRS}) + install(DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR}/bin/$/${qt_dir} + DESTINATION ./bin/$ + ) + endforeach() + + # Templates + install(DIRECTORY + ${CMAKE_SOURCE_DIR}/Templates + DESTINATION . + ) + + # Misc + install(FILES + ${CMAKE_SOURCE_DIR}/ctest_pytest.ini + ${CMAKE_SOURCE_DIR}/LICENSE.txt + ${CMAKE_SOURCE_DIR}/README.md + DESTINATION . + ) + endfunction() diff --git a/scripts/build/Jenkins/Jenkinsfile b/scripts/build/Jenkins/Jenkinsfile index 662ddc7454..fe60d9236c 100644 --- a/scripts/build/Jenkins/Jenkinsfile +++ b/scripts/build/Jenkins/Jenkinsfile @@ -337,14 +337,16 @@ def PreBuildCommonSteps(Map pipelineConfig, String repositoryName, String projec } def Build(Map options, String platform, String type, String workspace) { - def command = "${options.BUILD_ENTRY_POINT} --platform ${platform} --type ${type}" - dir("${workspace}/${ENGINE_REPOSITORY_NAME}") { - if (env.IS_UNIX) { - sh label: "Running ${platform} ${type}", - script: "${options.PYTHON_DIR}/python.sh -u ${command}" - } else { - bat label: "Running ${platform} ${type}", - script: "${options.PYTHON_DIR}/python.cmd -u ${command}".replace('/','\\') + timeout(time: env.TIMEOUT, unit: 'MINUTES', activity: true) { + def command = "${options.BUILD_ENTRY_POINT} --platform ${platform} --type ${type}" + dir("${workspace}/${ENGINE_REPOSITORY_NAME}") { + if (env.IS_UNIX) { + sh label: "Running ${platform} ${type}", + script: "${options.PYTHON_DIR}/python.sh -u ${command}" + } else { + bat label: "Running ${platform} ${type}", + script: "${options.PYTHON_DIR}/python.cmd -u ${command}".replace('/','\\') + } } } } @@ -360,7 +362,10 @@ def TestMetrics(Map options, String workspace, String branchName, String repoNam userRemoteConfigs: [[url: "${env.MARS_REPO}", name: 'mars', credentialsId: "${env.GITHUB_USER}"]] ] withCredentials([usernamePassword(credentialsId: "${env.SERVICE_USER}", passwordVariable: 'apitoken', usernameVariable: 'username')]) { - def command = "${options.PYTHON_DIR}/python.cmd -u mars/scripts/python/ctest_test_metric_scraper.py -e jenkins.creds.user ${username} -e jenkins.creds.pass ${apitoken} ${cmakeBuildDir} ${branchName} %BUILD_NUMBER% AR ${configuration} ${repoName} " + def command = "${options.PYTHON_DIR}/python.cmd -u mars/scripts/python/ctest_test_metric_scraper.py " + + "-e jenkins.creds.user ${username} -e jenkins.creds.pass ${apitoken} " + + "-e jenkins.base_url ${env.JENKINS_URL} " + + "${cmakeBuildDir} ${branchName} %BUILD_NUMBER% AR ${configuration} ${repoName} " bat label: "Publishing ${buildJobName} Test Metrics", script: command } @@ -499,43 +504,41 @@ try { envVars['IS_UNIX'] = 1 } withEnv(GetEnvStringList(envVars)) { - timeout(time: envVars['TIMEOUT'], unit: 'MINUTES', activity: true) { - try { - def build_job_name = build_job.key - - CreateSetupStage(pipelineConfig, repositoryName, projectName, pipelineName, branchName, platform.key, build_job.key, envVars).call() - - if(build_job.value.steps) { //this is a pipe with many steps so create all the build stages - build_job.value.steps.each { build_step -> - build_job_name = build_step - CreateBuildStage(pipelineConfig, platform.key, build_step, envVars).call() - } - } else { - CreateBuildStage(pipelineConfig, platform.key, build_job.key, envVars).call() - } + try { + def build_job_name = build_job.key + + CreateSetupStage(pipelineConfig, repositoryName, projectName, pipelineName, branchName, platform.key, build_job.key, envVars).call() - if (env.MARS_REPO && platform.key == 'Windows' && build_job_name.startsWith('test')) { - def output_directory = platform.value.build_types[build_job_name].PARAMETERS.OUTPUT_DIRECTORY - def configuration = platform.value.build_types[build_job_name].PARAMETERS.CONFIGURATION - CreateTestMetricsStage(pipelineConfig, branchName, envVars, build_job_name, output_directory, configuration).call() + if(build_job.value.steps) { //this is a pipe with many steps so create all the build stages + build_job.value.steps.each { build_step -> + build_job_name = build_step + CreateBuildStage(pipelineConfig, platform.key, build_step, envVars).call() } + } else { + CreateBuildStage(pipelineConfig, platform.key, build_job.key, envVars).call() } - catch(Exception e) { - // https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Result.java - // {SUCCESS,UNSTABLE,FAILURE,NOT_BUILT,ABORTED} - def currentResult = envVars['ON_FAILURE_MARK'] ?: 'FAILURE' - if (currentResult == 'FAILURE') { - currentBuild.result = 'FAILURE' - error "FAILURE: ${e}" - } else if (currentResult == 'UNSTABLE') { - currentBuild.result = 'UNSTABLE' - unstable(message: "UNSTABLE: ${e}") - } + + if (env.MARS_REPO && platform.key == 'Windows' && build_job_name.startsWith('test')) { + def output_directory = platform.value.build_types[build_job_name].PARAMETERS.OUTPUT_DIRECTORY + def configuration = platform.value.build_types[build_job_name].PARAMETERS.CONFIGURATION + CreateTestMetricsStage(pipelineConfig, branchName, envVars, build_job_name, output_directory, configuration).call() } - finally { - CreateTeardownStage(envVars).call() + } + catch(Exception e) { + // https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Result.java + // {SUCCESS,UNSTABLE,FAILURE,NOT_BUILT,ABORTED} + def currentResult = envVars['ON_FAILURE_MARK'] ?: 'FAILURE' + if (currentResult == 'FAILURE') { + currentBuild.result = 'FAILURE' + error "FAILURE: ${e}" + } else if (currentResult == 'UNSTABLE') { + currentBuild.result = 'UNSTABLE' + unstable(message: "UNSTABLE: ${e}") } } + finally { + CreateTeardownStage(envVars).call() + } } } }