diff --git a/Assets/Editor/Icons/AssetBrowser/TreeBranch_First.svg b/Assets/Editor/Icons/AssetBrowser/TreeBranch_First.svg
new file mode 100644
index 0000000000..f1d36d3e41
--- /dev/null
+++ b/Assets/Editor/Icons/AssetBrowser/TreeBranch_First.svg
@@ -0,0 +1,7 @@
+
diff --git a/Assets/Editor/Icons/AssetBrowser/TreeBranch_Last.svg b/Assets/Editor/Icons/AssetBrowser/TreeBranch_Last.svg
new file mode 100644
index 0000000000..9fc9fe52c2
--- /dev/null
+++ b/Assets/Editor/Icons/AssetBrowser/TreeBranch_Last.svg
@@ -0,0 +1,5 @@
+
diff --git a/Assets/Editor/Icons/AssetBrowser/TreeBranch_Middle.svg b/Assets/Editor/Icons/AssetBrowser/TreeBranch_Middle.svg
new file mode 100644
index 0000000000..7a61db38e0
--- /dev/null
+++ b/Assets/Editor/Icons/AssetBrowser/TreeBranch_Middle.svg
@@ -0,0 +1,6 @@
+
diff --git a/Assets/Editor/Icons/AssetBrowser/TreeBranch_OneChild.svg b/Assets/Editor/Icons/AssetBrowser/TreeBranch_OneChild.svg
new file mode 100644
index 0000000000..c6fb977c52
--- /dev/null
+++ b/Assets/Editor/Icons/AssetBrowser/TreeBranch_OneChild.svg
@@ -0,0 +1,6 @@
+
diff --git a/Assets/Editor/Translation/scriptcanvas_en_us.ts b/Assets/Editor/Translation/scriptcanvas_en_us.ts
index 937f6a4d96..7b8361c879 100644
--- a/Assets/Editor/Translation/scriptcanvas_en_us.ts
+++ b/Assets/Editor/Translation/scriptcanvas_en_us.ts
@@ -8098,7 +8098,7 @@
COLOR_FROMVALUES_PARAM0_TOOLTIP
- The Red value of hte Color [0, 255]
+ The Red value of the Color [0.0-1.0]
COLOR_FROMVALUES_PARAM1_NAME
@@ -8107,7 +8107,7 @@
COLOR_FROMVALUES_PARAM1_TOOLTIP
- The Green value of the Color [0, 255]
+ The Green value of the Color [0.0-1.0]
COLOR_FROMVALUES_PARAM2_NAME
@@ -8116,7 +8116,7 @@
COLOR_FROMVALUES_PARAM2_TOOLTIP
- The Blue value of the Color [0, 255]
+ The Blue value of the Color [0.0-1.0]
COLOR_FROMVALUES_PARAM3_NAME
@@ -8125,7 +8125,7 @@
COLOR_FROMVALUES_PARAM3_TOOLTIP
- The Alpha value of the Color [0, 255]
+ The Alpha value of the Color [0.0-1.0]
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/CMakeLists.txt b/AutomatedTesting/Gem/PythonTests/Atom/CMakeLists.txt
similarity index 75%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/CMakeLists.txt
rename to AutomatedTesting/Gem/PythonTests/Atom/CMakeLists.txt
index 117c710824..02aaa42597 100644
--- a/AutomatedTesting/Gem/PythonTests/atom_renderer/CMakeLists.txt
+++ b/AutomatedTesting/Gem/PythonTests/Atom/CMakeLists.txt
@@ -13,9 +13,9 @@
if(PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_BUILD_TESTS_SUPPORTED AND AutomatedTesting IN_LIST LY_PROJECTS)
ly_add_pytest(
- NAME AutomatedTesting::AtomRenderer_HydraTests_Main
+ NAME AutomatedTesting::Atom_TestSuite_Main
TEST_SUITE main
- PATH ${CMAKE_CURRENT_LIST_DIR}/test_Atom_MainSuite.py
+ PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Main.py
TEST_SERIAL
TIMEOUT 600
RUNTIME_DEPENDENCIES
@@ -26,9 +26,9 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_BUILD_TESTS_SUPPORTED AND AutomatedT
Atom
)
ly_add_pytest(
- NAME AutomatedTesting::AtomRenderer_HydraTests_MainOptimized
+ NAME AutomatedTesting::Atom_TestSuite_Main_Optimized
TEST_SUITE main
- PATH ${CMAKE_CURRENT_LIST_DIR}/test_Atom_MainSuite_Optimized.py
+ PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Main_Optimized.py
TEST_SERIAL
TIMEOUT 600
RUNTIME_DEPENDENCIES
@@ -39,9 +39,9 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_BUILD_TESTS_SUPPORTED AND AutomatedT
Atom
)
ly_add_pytest(
- NAME AutomatedTesting::AtomRenderer_HydraTests_Sandbox
+ NAME AutomatedTesting::Atom_TestSuite_Sandbox
TEST_SUITE sandbox
- PATH ${CMAKE_CURRENT_LIST_DIR}/test_Atom_SandboxSuite.py
+ PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Sandbox.py
TEST_SERIAL
TIMEOUT 400
RUNTIME_DEPENDENCIES
@@ -52,12 +52,12 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_BUILD_TESTS_SUPPORTED AND AutomatedT
Atom
)
ly_add_pytest(
- NAME AutomatedTesting::AtomRenderer_HydraTests_GPUTests
+ NAME AutomatedTesting::Atom_TestSuite_Main_GPU
TEST_SUITE main
TEST_REQUIRES gpu
TEST_SERIAL
TIMEOUT 1200
- PATH ${CMAKE_CURRENT_LIST_DIR}/test_Atom_GPUTests.py
+ PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Main_GPU.py
RUNTIME_DEPENDENCIES
AssetProcessor
AutomatedTesting.Assets
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py b/AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Main.py
similarity index 94%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py
rename to AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Main.py
index 16e281e494..4c5716d365 100644
--- a/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py
+++ b/AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Main.py
@@ -13,10 +13,10 @@ import pytest
import ly_test_tools.environment.file_system as file_system
import editor_python_test_tools.hydra_test_utils as hydra
-from atom_renderer.atom_utils.atom_constants import LIGHT_TYPES
+from Atom.atom_utils.atom_constants import LIGHT_TYPES
logger = logging.getLogger(__name__)
-TEST_DIRECTORY = os.path.join(os.path.dirname(__file__), "atom_hydra_scripts")
+TEST_DIRECTORY = os.path.join(os.path.dirname(__file__), "tests")
@pytest.mark.parametrize("project", ["AutomatedTesting"])
@@ -38,24 +38,24 @@ class TestAtomEditorComponentsMain(object):
7. Exposure Control
8. Directional Light
9. DepthOfField
- 10. Decal (Atom)
+ 10. Decal
"""
cfg_args = [level]
expected_lines = [
- # Decal (Atom) Component
- "Decal (Atom) Entity successfully created",
- "Decal (Atom)_test: Component added to the entity: True",
- "Decal (Atom)_test: Component removed after UNDO: True",
- "Decal (Atom)_test: Component added after REDO: True",
- "Decal (Atom)_test: Entered game mode: True",
- "Decal (Atom)_test: Exit game mode: True",
- "Decal (Atom) Controller|Configuration|Material: SUCCESS",
- "Decal (Atom)_test: Entity is hidden: True",
- "Decal (Atom)_test: Entity is shown: True",
- "Decal (Atom)_test: Entity deleted: True",
- "Decal (Atom)_test: UNDO entity deletion works: True",
- "Decal (Atom)_test: REDO entity deletion works: True",
+ # Decal Component
+ "Decal Entity successfully created",
+ "Decal_test: Component added to the entity: True",
+ "Decal_test: Component removed after UNDO: True",
+ "Decal_test: Component added after REDO: True",
+ "Decal_test: Entered game mode: True",
+ "Decal_test: Exit game mode: True",
+ "Decal Controller|Configuration|Material: SUCCESS",
+ "Decal_test: Entity is hidden: True",
+ "Decal_test: Entity is shown: True",
+ "Decal_test: Entity deleted: True",
+ "Decal_test: UNDO entity deletion works: True",
+ "Decal_test: REDO entity deletion works: True",
# DepthOfField Component
"DepthOfField Entity successfully created",
"DepthOfField_test: Component added to the entity: True",
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_GPUTests.py b/AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Main_GPU.py
similarity index 98%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_GPUTests.py
rename to AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Main_GPU.py
index e62ab5e5dc..249b9c7096 100644
--- a/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_GPUTests.py
+++ b/AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Main_GPU.py
@@ -3,8 +3,6 @@ Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
-
-Tests that require a GPU in order to run.
"""
import datetime
@@ -22,7 +20,7 @@ import editor_python_test_tools.hydra_test_utils as hydra
logger = logging.getLogger(__name__)
DEFAULT_SUBFOLDER_PATH = 'user/PythonTests/Automated/Screenshots'
-TEST_DIRECTORY = os.path.join(os.path.dirname(__file__), "atom_hydra_scripts")
+TEST_DIRECTORY = os.path.join(os.path.dirname(__file__), "tests")
def golden_images_directory():
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite_Optimized.py b/AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Main_Optimized.py
similarity index 56%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite_Optimized.py
rename to AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Main_Optimized.py
index e206e77d60..47b2204d56 100644
--- a/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite_Optimized.py
+++ b/AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Main_Optimized.py
@@ -15,32 +15,32 @@ from ly_test_tools.o3de.editor_test import EditorSharedTest, EditorTestSuite
class TestAutomation(EditorTestSuite):
class AtomEditorComponents_DecalAdded(EditorSharedTest):
- from atom_renderer.atom_hydra_scripts import hydra_AtomEditorComponents_DecalAdded as test_module
+ from Atom.tests import hydra_AtomEditorComponents_DecalAdded as test_module
class AtomEditorComponents_DepthOfFieldAdded(EditorSharedTest):
- from atom_renderer.atom_hydra_scripts import hydra_AtomEditorComponents_DepthOfFieldAdded as test_module
+ from Atom.tests import hydra_AtomEditorComponents_DepthOfFieldAdded as test_module
class AtomEditorComponents_DirectionalLightAdded(EditorSharedTest):
- from atom_renderer.atom_hydra_scripts import hydra_AtomEditorComponents_DirectionalLightAdded as test_module
+ from Atom.tests import hydra_AtomEditorComponents_DirectionalLightAdded as test_module
class AtomEditorComponents_ExposureControlAdded(EditorSharedTest):
- from atom_renderer.atom_hydra_scripts import hydra_AtomEditorComponents_ExposureControlAdded as test_module
+ from Atom.tests import hydra_AtomEditorComponents_ExposureControlAdded as test_module
class AtomEditorComponents_GlobalSkylightIBLAdded(EditorSharedTest):
- from atom_renderer.atom_hydra_scripts import hydra_AtomEditorComponents_GlobalSkylightIBLAdded as test_module
+ from Atom.tests import hydra_AtomEditorComponents_GlobalSkylightIBLAdded as test_module
class AtomEditorComponents_PhysicalSkyAdded(EditorSharedTest):
- from atom_renderer.atom_hydra_scripts import hydra_AtomEditorComponents_PhysicalSkyAdded as test_module
+ from Atom.tests import hydra_AtomEditorComponents_PhysicalSkyAdded as test_module
class AtomEditorComponents_PostFXRadiusWeightModifierAdded(EditorSharedTest):
- from atom_renderer.atom_hydra_scripts import (
+ from Atom.tests import (
hydra_AtomEditorComponents_PostFXRadiusWeightModifierAdded as test_module)
class AtomEditorComponents_LightAdded(EditorSharedTest):
- from atom_renderer.atom_hydra_scripts import hydra_AtomEditorComponents_LightAdded as test_module
+ from Atom.tests import hydra_AtomEditorComponents_LightAdded as test_module
class AtomEditorComponents_DisplayMapperAdded(EditorSharedTest):
- from atom_renderer.atom_hydra_scripts import hydra_AtomEditorComponents_DisplayMapperAdded as test_module
+ from Atom.tests import hydra_AtomEditorComponents_DisplayMapperAdded as test_module
class ShaderAssetBuilder_RecompilesShaderAsChainOfDependenciesChanges(EditorSharedTest):
- from .atom_hydra_scripts import hydra_ShaderAssetBuilder_RecompilesShaderAsChainOfDependenciesChanges as test_module
+ from Atom.tests import hydra_ShaderAssetBuilder_RecompilesShaderAsChainOfDependenciesChanges as test_module
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_SandboxSuite.py b/AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Sandbox.py
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_SandboxSuite.py
rename to AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Sandbox.py
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/__init__.py b/AutomatedTesting/Gem/PythonTests/Atom/__init__.py
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/__init__.py
rename to AutomatedTesting/Gem/PythonTests/Atom/__init__.py
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_utils/__init__.py b/AutomatedTesting/Gem/PythonTests/Atom/atom_utils/__init__.py
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_utils/__init__.py
rename to AutomatedTesting/Gem/PythonTests/Atom/atom_utils/__init__.py
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_utils/atom_component_helper.py b/AutomatedTesting/Gem/PythonTests/Atom/atom_utils/atom_component_helper.py
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_utils/atom_component_helper.py
rename to AutomatedTesting/Gem/PythonTests/Atom/atom_utils/atom_component_helper.py
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_utils/atom_constants.py b/AutomatedTesting/Gem/PythonTests/Atom/atom_utils/atom_constants.py
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_utils/atom_constants.py
rename to AutomatedTesting/Gem/PythonTests/Atom/atom_utils/atom_constants.py
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_utils/benchmark_utils.py b/AutomatedTesting/Gem/PythonTests/Atom/atom_utils/benchmark_utils.py
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_utils/benchmark_utils.py
rename to AutomatedTesting/Gem/PythonTests/Atom/atom_utils/benchmark_utils.py
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_utils/material_editor_utils.py b/AutomatedTesting/Gem/PythonTests/Atom/atom_utils/material_editor_utils.py
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_utils/material_editor_utils.py
rename to AutomatedTesting/Gem/PythonTests/Atom/atom_utils/material_editor_utils.py
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_utils/screenshot_utils.py b/AutomatedTesting/Gem/PythonTests/Atom/atom_utils/screenshot_utils.py
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_utils/screenshot_utils.py
rename to AutomatedTesting/Gem/PythonTests/Atom/atom_utils/screenshot_utils.py
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/AreaLight_1.ppm b/AutomatedTesting/Gem/PythonTests/Atom/golden_images/AreaLight_1.ppm
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/AreaLight_1.ppm
rename to AutomatedTesting/Gem/PythonTests/Atom/golden_images/AreaLight_1.ppm
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/AreaLight_2.ppm b/AutomatedTesting/Gem/PythonTests/Atom/golden_images/AreaLight_2.ppm
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/AreaLight_2.ppm
rename to AutomatedTesting/Gem/PythonTests/Atom/golden_images/AreaLight_2.ppm
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/AreaLight_3.ppm b/AutomatedTesting/Gem/PythonTests/Atom/golden_images/AreaLight_3.ppm
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/AreaLight_3.ppm
rename to AutomatedTesting/Gem/PythonTests/Atom/golden_images/AreaLight_3.ppm
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/AreaLight_4.ppm b/AutomatedTesting/Gem/PythonTests/Atom/golden_images/AreaLight_4.ppm
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/AreaLight_4.ppm
rename to AutomatedTesting/Gem/PythonTests/Atom/golden_images/AreaLight_4.ppm
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/AreaLight_5.ppm b/AutomatedTesting/Gem/PythonTests/Atom/golden_images/AreaLight_5.ppm
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/AreaLight_5.ppm
rename to AutomatedTesting/Gem/PythonTests/Atom/golden_images/AreaLight_5.ppm
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/AtomBasicLevelSetup.ppm b/AutomatedTesting/Gem/PythonTests/Atom/golden_images/AtomBasicLevelSetup.ppm
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/AtomBasicLevelSetup.ppm
rename to AutomatedTesting/Gem/PythonTests/Atom/golden_images/AtomBasicLevelSetup.ppm
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/SpotLight_1.ppm b/AutomatedTesting/Gem/PythonTests/Atom/golden_images/SpotLight_1.ppm
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/SpotLight_1.ppm
rename to AutomatedTesting/Gem/PythonTests/Atom/golden_images/SpotLight_1.ppm
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/SpotLight_2.ppm b/AutomatedTesting/Gem/PythonTests/Atom/golden_images/SpotLight_2.ppm
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/SpotLight_2.ppm
rename to AutomatedTesting/Gem/PythonTests/Atom/golden_images/SpotLight_2.ppm
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/SpotLight_3.ppm b/AutomatedTesting/Gem/PythonTests/Atom/golden_images/SpotLight_3.ppm
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/SpotLight_3.ppm
rename to AutomatedTesting/Gem/PythonTests/Atom/golden_images/SpotLight_3.ppm
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/SpotLight_4.ppm b/AutomatedTesting/Gem/PythonTests/Atom/golden_images/SpotLight_4.ppm
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/SpotLight_4.ppm
rename to AutomatedTesting/Gem/PythonTests/Atom/golden_images/SpotLight_4.ppm
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/SpotLight_5.ppm b/AutomatedTesting/Gem/PythonTests/Atom/golden_images/SpotLight_5.ppm
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/SpotLight_5.ppm
rename to AutomatedTesting/Gem/PythonTests/Atom/golden_images/SpotLight_5.ppm
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/SpotLight_6.ppm b/AutomatedTesting/Gem/PythonTests/Atom/golden_images/SpotLight_6.ppm
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/golden_images/SpotLight_6.ppm
rename to AutomatedTesting/Gem/PythonTests/Atom/golden_images/SpotLight_6.ppm
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/TestAssets/ShaderAssetBuilder/DependencyValidation.azsl.txt b/AutomatedTesting/Gem/PythonTests/Atom/tests/TestAssets/ShaderAssetBuilder/DependencyValidation.azsl.txt
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/TestAssets/ShaderAssetBuilder/DependencyValidation.azsl.txt
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/TestAssets/ShaderAssetBuilder/DependencyValidation.azsl.txt
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/TestAssets/ShaderAssetBuilder/DependencyValidation.shader.txt b/AutomatedTesting/Gem/PythonTests/Atom/tests/TestAssets/ShaderAssetBuilder/DependencyValidation.shader.txt
similarity index 93%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/TestAssets/ShaderAssetBuilder/DependencyValidation.shader.txt
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/TestAssets/ShaderAssetBuilder/DependencyValidation.shader.txt
index b0eac1783e..4439ec0352 100644
--- a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/TestAssets/ShaderAssetBuilder/DependencyValidation.shader.txt
+++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/TestAssets/ShaderAssetBuilder/DependencyValidation.shader.txt
@@ -2,7 +2,7 @@
{
"Source" : "DependencyValidation.azsl",
- "DepthStencilState" : {
+ "DepthStencilState" : {
"Depth" : { "Enable" : false, "CompareFunc" : "GreaterEqual" }
},
@@ -22,5 +22,5 @@
}
]
}
-
+
}
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/TestAssets/ShaderAssetBuilder/Test1Color.azsli.txt b/AutomatedTesting/Gem/PythonTests/Atom/tests/TestAssets/ShaderAssetBuilder/Test1Color.azsli.txt
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/TestAssets/ShaderAssetBuilder/Test1Color.azsli.txt
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/TestAssets/ShaderAssetBuilder/Test1Color.azsli.txt
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/TestAssets/ShaderAssetBuilder/Test2Color.azsli.txt b/AutomatedTesting/Gem/PythonTests/Atom/tests/TestAssets/ShaderAssetBuilder/Test2Color.azsli.txt
similarity index 93%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/TestAssets/ShaderAssetBuilder/Test2Color.azsli.txt
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/TestAssets/ShaderAssetBuilder/Test2Color.azsli.txt
index 2ef946b947..565493a0ab 100644
--- a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/TestAssets/ShaderAssetBuilder/Test2Color.azsli.txt
+++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/TestAssets/ShaderAssetBuilder/Test2Color.azsli.txt
@@ -12,5 +12,5 @@
float4 GetTest2Color(float4 color)
{
- return color * 0.5;
+ return color * 0.5;
}
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/TestAssets/ShaderAssetBuilder/Test3Color.azsli.txt b/AutomatedTesting/Gem/PythonTests/Atom/tests/TestAssets/ShaderAssetBuilder/Test3Color.azsli.txt
similarity index 92%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/TestAssets/ShaderAssetBuilder/Test3Color.azsli.txt
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/TestAssets/ShaderAssetBuilder/Test3Color.azsli.txt
index 73b0cca434..7c1ff2be42 100644
--- a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/TestAssets/ShaderAssetBuilder/Test3Color.azsli.txt
+++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/TestAssets/ShaderAssetBuilder/Test3Color.azsli.txt
@@ -12,5 +12,5 @@
float4 GetTest3Color(float4 color)
{
- return color * 0.13;
+ return color * 0.13;
}
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/__init__.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/__init__.py
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/__init__.py
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/__init__.py
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_AddedToEntity.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_AddedToEntity.py
similarity index 99%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_AddedToEntity.py
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_AddedToEntity.py
index a2e950e1dc..602e7564b3 100644
--- a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_AddedToEntity.py
+++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_AddedToEntity.py
@@ -184,7 +184,7 @@ def run():
material_asset = asset.AssetCatalogRequestBus(
bus.Broadcast, "GetAssetIdByPath", material_asset_path, math.Uuid(), False)
ComponentTests(
- "Decal (Atom)", lambda entity_obj: verify_set_property(
+ "Decal", lambda entity_obj: verify_set_property(
entity_obj, "Controller|Configuration|Material", material_asset))
# Directional Light Component
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_DecalAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_DecalAdded.py
similarity index 99%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_DecalAdded.py
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_DecalAdded.py
index d68e1f5844..fa02b75fe2 100644
--- a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_DecalAdded.py
+++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_DecalAdded.py
@@ -73,7 +73,7 @@ def AtomEditorComponents_Decal_AddedToEntity():
# Test steps begin.
# 1. Create a Decal entity with no components.
- decal_name = "Decal (Atom)"
+ decal_name = "Decal"
decal_entity = EditorEntity.create_editor_entity_at(math.Vector3(512.0, 512.0, 34.0), decal_name)
Report.critical_result(Tests.decal_creation, decal_entity.exists())
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_DepthOfFieldAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_DepthOfFieldAdded.py
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_DepthOfFieldAdded.py
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_DepthOfFieldAdded.py
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_DirectionalLightAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_DirectionalLightAdded.py
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_DirectionalLightAdded.py
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_DirectionalLightAdded.py
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_DisplayMapperAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_DisplayMapperAdded.py
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_DisplayMapperAdded.py
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_DisplayMapperAdded.py
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_ExposureControlAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_ExposureControlAdded.py
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_ExposureControlAdded.py
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_ExposureControlAdded.py
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_GlobalSkylightIBLAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_GlobalSkylightIBLAdded.py
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_GlobalSkylightIBLAdded.py
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_GlobalSkylightIBLAdded.py
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_LightAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_LightAdded.py
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_LightAdded.py
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_LightAdded.py
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_LightComponent.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_LightComponent.py
similarity index 99%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_LightComponent.py
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_LightComponent.py
index 6da922bd9f..751f425916 100644
--- a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_LightComponent.py
+++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_LightComponent.py
@@ -17,7 +17,7 @@ import azlmbr.legacy.general as general
sys.path.append(os.path.join(azlmbr.paths.devassets, "Gem", "PythonTests"))
import editor_python_test_tools.hydra_editor_utils as hydra
-from atom_renderer.atom_utils.atom_constants import LIGHT_TYPES
+from Atom.atom_utils.atom_constants import LIGHT_TYPES
LIGHT_TYPE_PROPERTY = 'Controller|Configuration|Light type'
SPHERE_AND_SPOT_DISK_LIGHT_PROPERTIES = [
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_PhysicalSkyAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_PhysicalSkyAdded.py
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_PhysicalSkyAdded.py
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_PhysicalSkyAdded.py
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_PostFXRadiusWeightModifierAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_PostFXRadiusWeightModifierAdded.py
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomEditorComponents_PostFXRadiusWeightModifierAdded.py
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_PostFXRadiusWeightModifierAdded.py
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomMaterialEditor_BasicTests.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomMaterialEditor_BasicTests.py
similarity index 99%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomMaterialEditor_BasicTests.py
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomMaterialEditor_BasicTests.py
index 1e250e5b9f..88a1ef4c7b 100644
--- a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomMaterialEditor_BasicTests.py
+++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomMaterialEditor_BasicTests.py
@@ -18,7 +18,7 @@ import azlmbr.paths
sys.path.append(os.path.join(azlmbr.paths.devassets, "Gem", "PythonTests"))
-import atom_renderer.atom_utils.material_editor_utils as material_editor
+import Atom.atom_utils.material_editor_utils as material_editor
NEW_MATERIAL = "test_material.material"
NEW_MATERIAL_1 = "test_material_1.material"
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_GPUTest_AtomFeatureIntegrationBenchmark.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_GPUTest_AtomFeatureIntegrationBenchmark.py
similarity index 98%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_GPUTest_AtomFeatureIntegrationBenchmark.py
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_GPUTest_AtomFeatureIntegrationBenchmark.py
index 7e7087fb42..4f7edeba75 100644
--- a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_GPUTest_AtomFeatureIntegrationBenchmark.py
+++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_GPUTest_AtomFeatureIntegrationBenchmark.py
@@ -14,7 +14,7 @@ sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "P
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.editor_test_helper import EditorTestHelper
-from atom_renderer.atom_utils.benchmark_utils import BenchmarkHelper
+from Atom.atom_utils.benchmark_utils import BenchmarkHelper
SCREEN_WIDTH = 1280
SCREEN_HEIGHT = 720
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_GPUTest_BasicLevelSetup.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_GPUTest_BasicLevelSetup.py
similarity index 99%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_GPUTest_BasicLevelSetup.py
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_GPUTest_BasicLevelSetup.py
index 24ebbdff63..62a122a723 100644
--- a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_GPUTest_BasicLevelSetup.py
+++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_GPUTest_BasicLevelSetup.py
@@ -21,7 +21,7 @@ sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "P
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.editor_test_helper import EditorTestHelper
-from atom_renderer.atom_utils.screenshot_utils import ScreenshotHelper
+from Atom.atom_utils.screenshot_utils import ScreenshotHelper
SCREEN_WIDTH = 1280
SCREEN_HEIGHT = 720
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_GPUTest_LightComponent.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_GPUTest_LightComponent.py
similarity index 99%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_GPUTest_LightComponent.py
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_GPUTest_LightComponent.py
index 5c019dc3f3..4a3ae8c85d 100644
--- a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_GPUTest_LightComponent.py
+++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_GPUTest_LightComponent.py
@@ -17,7 +17,7 @@ import azlmbr.legacy.general as general
sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests"))
import editor_python_test_tools.hydra_editor_utils as hydra
-from atom_renderer.atom_utils import atom_component_helper, atom_constants, screenshot_utils
+from Atom.atom_utils import atom_component_helper, atom_constants, screenshot_utils
from editor_python_test_tools.editor_test_helper import EditorTestHelper
helper = EditorTestHelper(log_prefix="Atom_EditorTestHelper")
diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_ShaderAssetBuilder_RecompilesShaderAsChainOfDependenciesChanges.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_ShaderAssetBuilder_RecompilesShaderAsChainOfDependenciesChanges.py
similarity index 100%
rename from AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_ShaderAssetBuilder_RecompilesShaderAsChainOfDependenciesChanges.py
rename to AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_ShaderAssetBuilder_RecompilesShaderAsChainOfDependenciesChanges.py
diff --git a/AutomatedTesting/Gem/PythonTests/CMakeLists.txt b/AutomatedTesting/Gem/PythonTests/CMakeLists.txt
index 7fd3b3a241..466a4b1679 100644
--- a/AutomatedTesting/Gem/PythonTests/CMakeLists.txt
+++ b/AutomatedTesting/Gem/PythonTests/CMakeLists.txt
@@ -18,7 +18,7 @@ include(${pal_dir}/PAL_traits_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
add_subdirectory(assetpipeline)
## Atom Renderer ##
-add_subdirectory(atom_renderer)
+add_subdirectory(Atom)
## Physics ##
add_subdirectory(Physics)
diff --git a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/CMakeLists.txt b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/CMakeLists.txt
index 4a26500ee2..52682e70bb 100644
--- a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/CMakeLists.txt
+++ b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/CMakeLists.txt
@@ -17,5 +17,14 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
AZ::AssetProcessorBatch
AZ::AssetProcessor
)
+
+ ly_add_pytest(
+ NAME AssetPipelineTests.Fbx_Tests
+ PATH ${CMAKE_CURRENT_LIST_DIR}/fbx_test/fbx_test.py
+ TEST_SUITE sandbox
+ RUNTIME_DEPENDENCIES
+ AZ::AssetProcessorBatch
+ AZ::AssetProcessor
+ )
endif()
diff --git a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/fbx_tests.py b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/fbx_tests.py
index 2b90f53fc3..5cb61da68e 100755
--- a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/fbx_tests.py
+++ b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/fbx_tests.py
@@ -34,11 +34,13 @@ logger = logging.getLogger(__name__)
targetProjects = ["AutomatedTesting"]
@pytest.fixture
+@pytest.mark.SUITE_sandbox
def local_resources(request, workspace, ap_setup_fixture):
ap_setup_fixture["tests_dir"] = os.path.dirname(os.path.realpath(__file__))
@dataclass
+@pytest.mark.SUITE_sandbox
class BlackboxAssetTest:
test_name: str
asset_folder: str
@@ -338,9 +340,11 @@ blackbox_fbx_special_tests = [
@pytest.mark.usefixtures("local_resources")
@pytest.mark.parametrize("project", targetProjects)
@pytest.mark.assetpipeline
+@pytest.mark.SUITE_sandbox
class TestsFBX_AllPlatforms(object):
@pytest.mark.BAT
+ @pytest.mark.SUITE_sandbox
@pytest.mark.parametrize("blackbox_param", blackbox_fbx_tests)
def test_FBXBlackboxTest_SourceFiles_Processed_ResultInExpectedProducts(self, workspace,
ap_setup_fixture, asset_processor, project,
@@ -359,6 +363,7 @@ class TestsFBX_AllPlatforms(object):
asset_processor, project, blackbox_param)
@pytest.mark.BAT
+ @pytest.mark.SUITE_sandbox
@pytest.mark.parametrize("blackbox_param", blackbox_fbx_special_tests)
def test_FBXBlackboxTest_AssetInfoModified_AssetReprocessed_ResultInExpectedProducts(self,
workspace, ap_setup_fixture,
diff --git a/Code/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp b/Code/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp
index 18946c7874..9fe4cfd0d2 100644
--- a/Code/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp
+++ b/Code/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp
@@ -141,6 +141,10 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent)
m_ui->m_assetBrowserTreeViewWidget, &AzAssetBrowser::AssetBrowserTreeView::ClearTypeFilter, m_ui->m_searchWidget,
&AzAssetBrowser::SearchWidget::ClearTypeFilter);
+ connect(
+ this, &AzAssetBrowserWindow::SizeChangedSignal, m_ui->m_assetBrowserTableViewWidget,
+ &AzAssetBrowser::AssetBrowserTableView::UpdateSizeSlot);
+
m_ui->m_assetBrowserTreeViewWidget->SetName("AssetBrowserTreeView_main");
}
@@ -164,6 +168,25 @@ QObject* AzAssetBrowserWindow::createListenerForShowAssetEditorEvent(QObject* pa
return listener;
}
+void AzAssetBrowserWindow::resizeEvent(QResizeEvent* resizeEvent)
+{
+ // leftLayout is the parent of the tableView
+ // rightLayout is the parent of the preview window.
+ // Workaround: When docking windows this event keeps holding the old size of the widgets instead of the new one
+ // but the resizeEvent holds the new size of the whole widget
+ // So we have to save the proportions somehow
+ const QWidget* leftLayout = m_ui->m_leftLayout;
+ const QVBoxLayout* rightLayout = m_ui->m_rightLayout;
+
+ const float oldLeftLayoutWidth = aznumeric_cast(leftLayout->geometry().width());
+ const float oldWidth = aznumeric_cast(leftLayout->geometry().width() + rightLayout->geometry().width());
+
+ const float newWidth = oldLeftLayoutWidth * aznumeric_cast(resizeEvent->size().width()) / oldWidth;
+
+ emit SizeChangedSignal(aznumeric_cast(newWidth));
+ QWidget::resizeEvent(resizeEvent);
+}
+
void AzAssetBrowserWindow::OnInitViewToggleButton()
{
CreateSwitchViewMenu();
diff --git a/Code/Editor/AzAssetBrowser/AzAssetBrowserWindow.h b/Code/Editor/AzAssetBrowser/AzAssetBrowserWindow.h
index bf742b0cf2..753f000300 100644
--- a/Code/Editor/AzAssetBrowser/AzAssetBrowserWindow.h
+++ b/Code/Editor/AzAssetBrowser/AzAssetBrowserWindow.h
@@ -53,9 +53,17 @@ public:
static QObject* createListenerForShowAssetEditorEvent(QObject* parent);
+
+Q_SIGNALS:
+ void SizeChangedSignal(int newWidth);
+
+protected:
+ void resizeEvent(QResizeEvent* resizeEvent) override;
+
private:
void OnInitViewToggleButton();
void UpdateDisplayInfo();
+
protected slots:
void CreateSwitchViewMenu();
void SetExpandedAssetBrowserMode();
diff --git a/Code/Editor/CMakeLists.txt b/Code/Editor/CMakeLists.txt
index 5158ebc6d5..5884795413 100644
--- a/Code/Editor/CMakeLists.txt
+++ b/Code/Editor/CMakeLists.txt
@@ -254,4 +254,35 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
ly_add_googletest(
NAME Legacy::EditorLib.Tests
)
+
+ ly_add_target(
+ NAME EditorLib.Camera.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
+ NAMESPACE Legacy
+ FILES_CMAKE
+ Lib/Tests/Camera/editor_lib_camera_test_files.cmake
+ INCLUDE_DIRECTORIES
+ PRIVATE
+ .
+ BUILD_DEPENDENCIES
+ PRIVATE
+ AZ::AzCore
+ AZ::AzTest
+ AZ::AzToolsFramework
+ AZ::AzTestShared
+ Legacy::EditorLib
+ Gem::Camera.Editor
+ Gem::AtomToolsFramework.Static
+ RUNTIME_DEPENDENCIES
+ Legacy::EditorLib
+ )
+
+ ly_add_source_properties(
+ SOURCES Lib/Tests/Camera/test_EditorCamera.cpp
+ PROPERTY COMPILE_DEFINITIONS
+ VALUES CAMERA_EDITOR_MODULE="$"
+ )
+
+ ly_add_googletest(
+ NAME Legacy::EditorLib.Camera.Tests
+ )
endif()
diff --git a/Code/Editor/Core/QtEditorApplication_linux.cpp b/Code/Editor/Core/QtEditorApplication_linux.cpp
index 175bef0238..2fd4ef629e 100644
--- a/Code/Editor/Core/QtEditorApplication_linux.cpp
+++ b/Code/Editor/Core/QtEditorApplication_linux.cpp
@@ -9,7 +9,7 @@
#include "QtEditorApplication.h"
#ifdef PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
-#include
+#include
#endif
namespace Editor
@@ -19,7 +19,7 @@ namespace Editor
if (GetIEditor()->IsInGameMode())
{
#ifdef PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
- AzFramework::LinuxXcbEventHandlerBus::Broadcast(&AzFramework::LinuxXcbEventHandler::HandleXcbEvent, static_cast(message));
+ AzFramework::XcbEventHandlerBus::Broadcast(&AzFramework::XcbEventHandler::HandleXcbEvent, static_cast(message));
#endif
return true;
}
diff --git a/Code/Editor/EditorModularViewportCameraComposer.cpp b/Code/Editor/EditorModularViewportCameraComposer.cpp
index 498d6f3353..600f2089e6 100644
--- a/Code/Editor/EditorModularViewportCameraComposer.cpp
+++ b/Code/Editor/EditorModularViewportCameraComposer.cpp
@@ -9,9 +9,11 @@
#include
#include
+#include
#include
#include
#include
+#include
#include
namespace SandboxEditor
@@ -34,10 +36,12 @@ namespace SandboxEditor
: m_viewportId(viewportId)
{
EditorModularViewportCameraComposerNotificationBus::Handler::BusConnect(viewportId);
+ Camera::EditorCameraNotificationBus::Handler::BusConnect();
}
EditorModularViewportCameraComposer::~EditorModularViewportCameraComposer()
{
+ Camera::EditorCameraNotificationBus::Handler::BusDisconnect();
EditorModularViewportCameraComposerNotificationBus::Handler::BusDisconnect();
}
@@ -91,7 +95,7 @@ namespace SandboxEditor
cameras.AddCamera(m_firstPersonPanCamera);
cameras.AddCamera(m_firstPersonTranslateCamera);
cameras.AddCamera(m_firstPersonScrollCamera);
- cameras.AddCamera(m_orbitCamera);
+ cameras.AddCamera(m_pivotCamera);
});
return controller;
@@ -128,8 +132,8 @@ namespace SandboxEditor
m_firstPersonRotateCamera->SetActivationBeganFn(hideCursor);
m_firstPersonRotateCamera->SetActivationEndedFn(showCursor);
- m_firstPersonPanCamera =
- AZStd::make_shared(SandboxEditor::CameraFreePanChannelId(), AzFramework::LookPan);
+ m_firstPersonPanCamera = AZStd::make_shared(
+ SandboxEditor::CameraFreePanChannelId(), AzFramework::LookPan, AzFramework::TranslatePivot);
m_firstPersonPanCamera->m_panSpeedFn = []
{
@@ -148,8 +152,8 @@ namespace SandboxEditor
const auto translateCameraInputChannelIds = BuildTranslateCameraInputChannelIds();
- m_firstPersonTranslateCamera =
- AZStd::make_shared(AzFramework::LookTranslation, translateCameraInputChannelIds);
+ m_firstPersonTranslateCamera = AZStd::make_shared(
+ translateCameraInputChannelIds, AzFramework::LookTranslation, AzFramework::TranslatePivot);
m_firstPersonTranslateCamera->m_translateSpeedFn = []
{
@@ -168,10 +172,10 @@ namespace SandboxEditor
return SandboxEditor::CameraScrollSpeed();
};
- m_orbitCamera = AZStd::make_shared(SandboxEditor::CameraOrbitChannelId());
+ m_pivotCamera = AZStd::make_shared(SandboxEditor::CameraPivotChannelId());
- m_orbitCamera->SetLookAtFn(
- [viewportId = m_viewportId](const AZ::Vector3& position, const AZ::Vector3& direction) -> AZStd::optional
+ m_pivotCamera->SetPivotFn(
+ [viewportId = m_viewportId]([[maybe_unused]] const AZ::Vector3& position, [[maybe_unused]] const AZ::Vector3& direction)
{
AZStd::optional lookAtAfterInterpolation;
AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult(
@@ -179,108 +183,114 @@ namespace SandboxEditor
&AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::LookAtAfterInterpolation);
// initially attempt to use the last set look at point after an interpolation has finished
- if (lookAtAfterInterpolation.has_value())
+ // note: ignore this if it is the same location as the camera (e.g. after go to position)
+ if (lookAtAfterInterpolation.has_value() && !lookAtAfterInterpolation->IsClose(position))
{
return *lookAtAfterInterpolation;
}
- const float RayDistance = 1000.0f;
- AzFramework::RenderGeometry::RayRequest ray;
- ray.m_startWorldPosition = position;
- ray.m_endWorldPosition = position + direction * RayDistance;
- ray.m_onlyVisible = true;
+ // otherwise fall back to the selected entity pivot
+ AZStd::optional entityPivot;
+ AzToolsFramework::EditorTransformComponentSelectionRequestBus::EventResult(
+ entityPivot, AzToolsFramework::GetEntityContextId(),
+ &AzToolsFramework::EditorTransformComponentSelectionRequestBus::Events::GetManipulatorTransform);
- AzFramework::RenderGeometry::RayResult renderGeometryIntersectionResult;
- AzFramework::RenderGeometry::IntersectorBus::EventResult(
- renderGeometryIntersectionResult, AzToolsFramework::GetEntityContextId(),
- &AzFramework::RenderGeometry::IntersectorBus::Events::RayIntersect, ray);
-
- // attempt a ray intersection with any visible mesh and return the intersection position if successful
- if (renderGeometryIntersectionResult)
- {
- return renderGeometryIntersectionResult.m_worldPosition;
- }
-
- // if there is no selection or no intersection, fallback to default camera orbit behavior (ground plane
- // intersection)
- return {};
+ // finally just use the identity
+ return entityPivot.value_or(AZ::Transform::CreateIdentity()).GetTranslation();
});
- m_orbitRotateCamera = AZStd::make_shared(SandboxEditor::CameraOrbitLookChannelId());
+ m_pivotRotateCamera = AZStd::make_shared(SandboxEditor::CameraPivotLookChannelId());
- m_orbitRotateCamera->m_rotateSpeedFn = []
+ m_pivotRotateCamera->m_rotateSpeedFn = []
{
return SandboxEditor::CameraRotateSpeed();
};
- m_orbitRotateCamera->m_invertYawFn = []
+ m_pivotRotateCamera->m_invertYawFn = []
{
- return SandboxEditor::CameraOrbitYawRotationInverted();
+ return SandboxEditor::CameraPivotYawRotationInverted();
};
- m_orbitTranslateCamera =
- AZStd::make_shared(AzFramework::OrbitTranslation, translateCameraInputChannelIds);
+ m_pivotTranslateCamera = AZStd::make_shared(
+ translateCameraInputChannelIds, AzFramework::LookTranslation, AzFramework::TranslateOffset);
- m_orbitTranslateCamera->m_translateSpeedFn = []
+ m_pivotTranslateCamera->m_translateSpeedFn = []
{
return SandboxEditor::CameraTranslateSpeed();
};
- m_orbitTranslateCamera->m_boostMultiplierFn = []
+ m_pivotTranslateCamera->m_boostMultiplierFn = []
{
return SandboxEditor::CameraBoostMultiplier();
};
- m_orbitDollyScrollCamera = AZStd::make_shared();
+ m_pivotDollyScrollCamera = AZStd::make_shared();
- m_orbitDollyScrollCamera->m_scrollSpeedFn = []
+ m_pivotDollyScrollCamera->m_scrollSpeedFn = []
{
return SandboxEditor::CameraScrollSpeed();
};
- m_orbitDollyMoveCamera =
- AZStd::make_shared(SandboxEditor::CameraOrbitDollyChannelId());
+ m_pivotDollyMoveCamera = AZStd::make_shared(SandboxEditor::CameraPivotDollyChannelId());
- m_orbitDollyMoveCamera->m_cursorSpeedFn = []
+ m_pivotDollyMoveCamera->m_motionSpeedFn = []
{
return SandboxEditor::CameraDollyMotionSpeed();
};
- m_orbitPanCamera = AZStd::make_shared(SandboxEditor::CameraOrbitPanChannelId(), AzFramework::OrbitPan);
+ m_pivotPanCamera = AZStd::make_shared(
+ SandboxEditor::CameraPivotPanChannelId(), AzFramework::LookPan, AzFramework::TranslateOffset);
- m_orbitPanCamera->m_panSpeedFn = []
+ m_pivotPanCamera->m_panSpeedFn = []
{
return SandboxEditor::CameraPanSpeed();
};
- m_orbitPanCamera->m_invertPanXFn = []
+ m_pivotPanCamera->m_invertPanXFn = []
{
return SandboxEditor::CameraPanInvertedX();
};
- m_orbitPanCamera->m_invertPanYFn = []
+ m_pivotPanCamera->m_invertPanYFn = []
{
return SandboxEditor::CameraPanInvertedY();
};
- m_orbitCamera->m_orbitCameras.AddCamera(m_orbitRotateCamera);
- m_orbitCamera->m_orbitCameras.AddCamera(m_orbitTranslateCamera);
- m_orbitCamera->m_orbitCameras.AddCamera(m_orbitDollyScrollCamera);
- m_orbitCamera->m_orbitCameras.AddCamera(m_orbitDollyMoveCamera);
- m_orbitCamera->m_orbitCameras.AddCamera(m_orbitPanCamera);
+ m_pivotCamera->m_pivotCameras.AddCamera(m_pivotRotateCamera);
+ m_pivotCamera->m_pivotCameras.AddCamera(m_pivotTranslateCamera);
+ m_pivotCamera->m_pivotCameras.AddCamera(m_pivotDollyScrollCamera);
+ m_pivotCamera->m_pivotCameras.AddCamera(m_pivotDollyMoveCamera);
+ m_pivotCamera->m_pivotCameras.AddCamera(m_pivotPanCamera);
}
void EditorModularViewportCameraComposer::OnEditorModularViewportCameraComposerSettingsChanged()
{
const auto translateCameraInputChannelIds = BuildTranslateCameraInputChannelIds();
m_firstPersonTranslateCamera->SetTranslateCameraInputChannelIds(translateCameraInputChannelIds);
- m_orbitTranslateCamera->SetTranslateCameraInputChannelIds(translateCameraInputChannelIds);
-
m_firstPersonPanCamera->SetPanInputChannelId(SandboxEditor::CameraFreePanChannelId());
- m_orbitPanCamera->SetPanInputChannelId(SandboxEditor::CameraOrbitPanChannelId());
m_firstPersonRotateCamera->SetRotateInputChannelId(SandboxEditor::CameraFreeLookChannelId());
- m_orbitRotateCamera->SetRotateInputChannelId(SandboxEditor::CameraOrbitLookChannelId());
- m_orbitCamera->SetOrbitInputChannelId(SandboxEditor::CameraOrbitChannelId());
- m_orbitDollyMoveCamera->SetDollyInputChannelId(SandboxEditor::CameraOrbitDollyChannelId());
+
+ m_pivotCamera->SetPivotInputChannelId(SandboxEditor::CameraPivotChannelId());
+ m_pivotTranslateCamera->SetTranslateCameraInputChannelIds(translateCameraInputChannelIds);
+ m_pivotPanCamera->SetPanInputChannelId(SandboxEditor::CameraPivotPanChannelId());
+ m_pivotRotateCamera->SetRotateInputChannelId(SandboxEditor::CameraPivotLookChannelId());
+ m_pivotDollyMoveCamera->SetDollyInputChannelId(SandboxEditor::CameraPivotDollyChannelId());
+ }
+
+ void EditorModularViewportCameraComposer::OnViewportViewEntityChanged(const AZ::EntityId& viewEntityId)
+ {
+ if (viewEntityId.IsValid())
+ {
+ AZ::Transform worldFromLocal = AZ::Transform::CreateIdentity();
+ AZ::TransformBus::EventResult(worldFromLocal, viewEntityId, &AZ::TransformBus::Events::GetWorldTM);
+
+ AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event(
+ m_viewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::SetReferenceFrame, worldFromLocal);
+ }
+ else
+ {
+ AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event(
+ m_viewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::ClearReferenceFrame);
+ }
}
} // namespace SandboxEditor
diff --git a/Code/Editor/EditorModularViewportCameraComposer.h b/Code/Editor/EditorModularViewportCameraComposer.h
index cb223d39e6..e691ca1c89 100644
--- a/Code/Editor/EditorModularViewportCameraComposer.h
+++ b/Code/Editor/EditorModularViewportCameraComposer.h
@@ -10,13 +10,16 @@
#include
#include
+#include
#include
#include
namespace SandboxEditor
{
//! Type responsible for building the editor's modular viewport camera controller.
- class EditorModularViewportCameraComposer : private EditorModularViewportCameraComposerNotificationBus::Handler
+ class EditorModularViewportCameraComposer
+ : private EditorModularViewportCameraComposerNotificationBus::Handler
+ , private Camera::EditorCameraNotificationBus::Handler
{
public:
SANDBOX_API explicit EditorModularViewportCameraComposer(AzFramework::ViewportId viewportId);
@@ -32,16 +35,19 @@ namespace SandboxEditor
// EditorModularViewportCameraComposerNotificationBus overrides ...
void OnEditorModularViewportCameraComposerSettingsChanged() override;
+ // EditorCameraNotificationBus overrides ...
+ void OnViewportViewEntityChanged(const AZ::EntityId& viewEntityId) override;
+
AZStd::shared_ptr m_firstPersonRotateCamera;
AZStd::shared_ptr m_firstPersonPanCamera;
AZStd::shared_ptr m_firstPersonTranslateCamera;
AZStd::shared_ptr m_firstPersonScrollCamera;
- AZStd::shared_ptr m_orbitCamera;
- AZStd::shared_ptr m_orbitRotateCamera;
- AZStd::shared_ptr m_orbitTranslateCamera;
- AZStd::shared_ptr m_orbitDollyScrollCamera;
- AZStd::shared_ptr m_orbitDollyMoveCamera;
- AZStd::shared_ptr m_orbitPanCamera;
+ AZStd::shared_ptr m_pivotCamera;
+ AZStd::shared_ptr m_pivotRotateCamera;
+ AZStd::shared_ptr m_pivotTranslateCamera;
+ AZStd::shared_ptr m_pivotDollyScrollCamera;
+ AZStd::shared_ptr m_pivotDollyMoveCamera;
+ AZStd::shared_ptr m_pivotPanCamera;
AzFramework::ViewportId m_viewportId;
};
diff --git a/Code/Editor/EditorPreferencesPageViewportCamera.cpp b/Code/Editor/EditorPreferencesPageViewportCamera.cpp
index 368d2769f8..55b631e1f6 100644
--- a/Code/Editor/EditorPreferencesPageViewportCamera.cpp
+++ b/Code/Editor/EditorPreferencesPageViewportCamera.cpp
@@ -61,7 +61,7 @@ static AZStd::vector GetEditorInputNames()
void CEditorPreferencesPage_ViewportCamera::Reflect(AZ::SerializeContext& serialize)
{
serialize.Class()
- ->Version(2)
+ ->Version(3)
->Field("TranslateSpeed", &CameraMovementSettings::m_translateSpeed)
->Field("RotateSpeed", &CameraMovementSettings::m_rotateSpeed)
->Field("BoostMultiplier", &CameraMovementSettings::m_boostMultiplier)
@@ -73,12 +73,12 @@ void CEditorPreferencesPage_ViewportCamera::Reflect(AZ::SerializeContext& serial
->Field("TranslateSmoothing", &CameraMovementSettings::m_translateSmoothing)
->Field("TranslateSmoothness", &CameraMovementSettings::m_translateSmoothness)
->Field("CaptureCursorLook", &CameraMovementSettings::m_captureCursorLook)
- ->Field("OrbitYawRotationInverted", &CameraMovementSettings::m_orbitYawRotationInverted)
+ ->Field("PivotYawRotationInverted", &CameraMovementSettings::m_pivotYawRotationInverted)
->Field("PanInvertedX", &CameraMovementSettings::m_panInvertedX)
->Field("PanInvertedY", &CameraMovementSettings::m_panInvertedY);
serialize.Class()
- ->Version(1)
+ ->Version(2)
->Field("TranslateForward", &CameraInputSettings::m_translateForwardChannelId)
->Field("TranslateBackward", &CameraInputSettings::m_translateBackwardChannelId)
->Field("TranslateLeft", &CameraInputSettings::m_translateLeftChannelId)
@@ -86,12 +86,12 @@ void CEditorPreferencesPage_ViewportCamera::Reflect(AZ::SerializeContext& serial
->Field("TranslateUp", &CameraInputSettings::m_translateUpChannelId)
->Field("TranslateDown", &CameraInputSettings::m_translateDownChannelId)
->Field("Boost", &CameraInputSettings::m_boostChannelId)
- ->Field("Orbit", &CameraInputSettings::m_orbitChannelId)
+ ->Field("Pivot", &CameraInputSettings::m_pivotChannelId)
->Field("FreeLook", &CameraInputSettings::m_freeLookChannelId)
->Field("FreePan", &CameraInputSettings::m_freePanChannelId)
- ->Field("OrbitLook", &CameraInputSettings::m_orbitLookChannelId)
- ->Field("OrbitDolly", &CameraInputSettings::m_orbitDollyChannelId)
- ->Field("OrbitPan", &CameraInputSettings::m_orbitPanChannelId);
+ ->Field("PivotLook", &CameraInputSettings::m_pivotLookChannelId)
+ ->Field("PivotDolly", &CameraInputSettings::m_pivotDollyChannelId)
+ ->Field("PivotPan", &CameraInputSettings::m_pivotPanChannelId);
serialize.Class()
->Version(1)
@@ -143,8 +143,8 @@ void CEditorPreferencesPage_ViewportCamera::Reflect(AZ::SerializeContext& serial
->Attribute(AZ::Edit::Attributes::Min, minValue)
->Attribute(AZ::Edit::Attributes::Visibility, &CameraMovementSettings::TranslateSmoothingVisibility)
->DataElement(
- AZ::Edit::UIHandlers::CheckBox, &CameraMovementSettings::m_orbitYawRotationInverted, "Camera Orbit Yaw Inverted",
- "Inverted yaw rotation while orbiting")
+ AZ::Edit::UIHandlers::CheckBox, &CameraMovementSettings::m_pivotYawRotationInverted, "Camera Pivot Yaw Inverted",
+ "Inverted yaw rotation while pivoting")
->DataElement(
AZ::Edit::UIHandlers::CheckBox, &CameraMovementSettings::m_panInvertedX, "Invert Pan X",
"Invert direction of pan in local X axis")
@@ -185,8 +185,8 @@ void CEditorPreferencesPage_ViewportCamera::Reflect(AZ::SerializeContext& serial
"Key/button to move the camera more quickly")
->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames)
->DataElement(
- AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_orbitChannelId, "Orbit",
- "Key/button to begin the camera orbit behavior")
+ AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_pivotChannelId, "Pivot",
+ "Key/button to begin the camera pivot behavior")
->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames)
->DataElement(
AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_freeLookChannelId, "Free Look",
@@ -196,16 +196,16 @@ void CEditorPreferencesPage_ViewportCamera::Reflect(AZ::SerializeContext& serial
AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_freePanChannelId, "Free Pan", "Key/button to begin camera free pan")
->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames)
->DataElement(
- AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_orbitLookChannelId, "Orbit Look",
- "Key/button to begin camera orbit look")
+ AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_pivotLookChannelId, "Pivot Look",
+ "Key/button to begin camera pivot look")
->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames)
->DataElement(
- AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_orbitDollyChannelId, "Orbit Dolly",
- "Key/button to begin camera orbit dolly")
+ AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_pivotDollyChannelId, "Pivot Dolly",
+ "Key/button to begin camera pivot dolly")
->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames)
->DataElement(
- AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_orbitPanChannelId, "Orbit Pan",
- "Key/button to begin camera orbit pan")
+ AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_pivotPanChannelId, "Pivot Pan",
+ "Key/button to begin camera pivot pan")
->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames);
editContext->Class("Viewport Preferences", "Viewport Preferences")
@@ -264,7 +264,7 @@ void CEditorPreferencesPage_ViewportCamera::OnApply()
SandboxEditor::SetCameraTranslateSmoothness(m_cameraMovementSettings.m_translateSmoothness);
SandboxEditor::SetCameraTranslateSmoothingEnabled(m_cameraMovementSettings.m_translateSmoothing);
SandboxEditor::SetCameraCaptureCursorForLook(m_cameraMovementSettings.m_captureCursorLook);
- SandboxEditor::SetCameraOrbitYawRotationInverted(m_cameraMovementSettings.m_orbitYawRotationInverted);
+ SandboxEditor::SetCameraPivotYawRotationInverted(m_cameraMovementSettings.m_pivotYawRotationInverted);
SandboxEditor::SetCameraPanInvertedX(m_cameraMovementSettings.m_panInvertedX);
SandboxEditor::SetCameraPanInvertedY(m_cameraMovementSettings.m_panInvertedY);
@@ -275,12 +275,12 @@ void CEditorPreferencesPage_ViewportCamera::OnApply()
SandboxEditor::SetCameraTranslateUpChannelId(m_cameraInputSettings.m_translateUpChannelId);
SandboxEditor::SetCameraTranslateDownChannelId(m_cameraInputSettings.m_translateDownChannelId);
SandboxEditor::SetCameraTranslateBoostChannelId(m_cameraInputSettings.m_boostChannelId);
- SandboxEditor::SetCameraOrbitChannelId(m_cameraInputSettings.m_orbitChannelId);
+ SandboxEditor::SetCameraPivotChannelId(m_cameraInputSettings.m_pivotChannelId);
SandboxEditor::SetCameraFreeLookChannelId(m_cameraInputSettings.m_freeLookChannelId);
SandboxEditor::SetCameraFreePanChannelId(m_cameraInputSettings.m_freePanChannelId);
- SandboxEditor::SetCameraOrbitLookChannelId(m_cameraInputSettings.m_orbitLookChannelId);
- SandboxEditor::SetCameraOrbitDollyChannelId(m_cameraInputSettings.m_orbitDollyChannelId);
- SandboxEditor::SetCameraOrbitPanChannelId(m_cameraInputSettings.m_orbitPanChannelId);
+ SandboxEditor::SetCameraPivotLookChannelId(m_cameraInputSettings.m_pivotLookChannelId);
+ SandboxEditor::SetCameraPivotDollyChannelId(m_cameraInputSettings.m_pivotDollyChannelId);
+ SandboxEditor::SetCameraPivotPanChannelId(m_cameraInputSettings.m_pivotPanChannelId);
SandboxEditor::EditorModularViewportCameraComposerNotificationBus::Broadcast(
&SandboxEditor::EditorModularViewportCameraComposerNotificationBus::Events::OnEditorModularViewportCameraComposerSettingsChanged);
@@ -299,7 +299,7 @@ void CEditorPreferencesPage_ViewportCamera::InitializeSettings()
m_cameraMovementSettings.m_translateSmoothness = SandboxEditor::CameraTranslateSmoothness();
m_cameraMovementSettings.m_translateSmoothing = SandboxEditor::CameraTranslateSmoothingEnabled();
m_cameraMovementSettings.m_captureCursorLook = SandboxEditor::CameraCaptureCursorForLook();
- m_cameraMovementSettings.m_orbitYawRotationInverted = SandboxEditor::CameraOrbitYawRotationInverted();
+ m_cameraMovementSettings.m_pivotYawRotationInverted = SandboxEditor::CameraPivotYawRotationInverted();
m_cameraMovementSettings.m_panInvertedX = SandboxEditor::CameraPanInvertedX();
m_cameraMovementSettings.m_panInvertedY = SandboxEditor::CameraPanInvertedY();
@@ -310,10 +310,10 @@ void CEditorPreferencesPage_ViewportCamera::InitializeSettings()
m_cameraInputSettings.m_translateUpChannelId = SandboxEditor::CameraTranslateUpChannelId().GetName();
m_cameraInputSettings.m_translateDownChannelId = SandboxEditor::CameraTranslateDownChannelId().GetName();
m_cameraInputSettings.m_boostChannelId = SandboxEditor::CameraTranslateBoostChannelId().GetName();
- m_cameraInputSettings.m_orbitChannelId = SandboxEditor::CameraOrbitChannelId().GetName();
+ m_cameraInputSettings.m_pivotChannelId = SandboxEditor::CameraPivotChannelId().GetName();
m_cameraInputSettings.m_freeLookChannelId = SandboxEditor::CameraFreeLookChannelId().GetName();
m_cameraInputSettings.m_freePanChannelId = SandboxEditor::CameraFreePanChannelId().GetName();
- m_cameraInputSettings.m_orbitLookChannelId = SandboxEditor::CameraOrbitLookChannelId().GetName();
- m_cameraInputSettings.m_orbitDollyChannelId = SandboxEditor::CameraOrbitDollyChannelId().GetName();
- m_cameraInputSettings.m_orbitPanChannelId = SandboxEditor::CameraOrbitPanChannelId().GetName();
+ m_cameraInputSettings.m_pivotLookChannelId = SandboxEditor::CameraPivotLookChannelId().GetName();
+ m_cameraInputSettings.m_pivotDollyChannelId = SandboxEditor::CameraPivotDollyChannelId().GetName();
+ m_cameraInputSettings.m_pivotPanChannelId = SandboxEditor::CameraPivotPanChannelId().GetName();
}
diff --git a/Code/Editor/EditorPreferencesPageViewportCamera.h b/Code/Editor/EditorPreferencesPageViewportCamera.h
index 31a728599f..01dc4664f6 100644
--- a/Code/Editor/EditorPreferencesPageViewportCamera.h
+++ b/Code/Editor/EditorPreferencesPageViewportCamera.h
@@ -54,7 +54,7 @@ private:
float m_translateSmoothness;
bool m_translateSmoothing;
bool m_captureCursorLook;
- bool m_orbitYawRotationInverted;
+ bool m_pivotYawRotationInverted;
bool m_panInvertedX;
bool m_panInvertedY;
@@ -80,12 +80,12 @@ private:
AZStd::string m_translateUpChannelId;
AZStd::string m_translateDownChannelId;
AZStd::string m_boostChannelId;
- AZStd::string m_orbitChannelId;
+ AZStd::string m_pivotChannelId;
AZStd::string m_freeLookChannelId;
AZStd::string m_freePanChannelId;
- AZStd::string m_orbitLookChannelId;
- AZStd::string m_orbitDollyChannelId;
- AZStd::string m_orbitPanChannelId;
+ AZStd::string m_pivotLookChannelId;
+ AZStd::string m_pivotDollyChannelId;
+ AZStd::string m_pivotPanChannelId;
};
CameraMovementSettings m_cameraMovementSettings;
diff --git a/Code/Editor/EditorViewportSettings.cpp b/Code/Editor/EditorViewportSettings.cpp
index 063ec125ba..fe8efecd17 100644
--- a/Code/Editor/EditorViewportSettings.cpp
+++ b/Code/Editor/EditorViewportSettings.cpp
@@ -28,7 +28,7 @@ namespace SandboxEditor
constexpr AZStd::string_view CameraRotateSpeedSetting = "/Amazon/Preferences/Editor/Camera/RotateSpeed";
constexpr AZStd::string_view CameraScrollSpeedSetting = "/Amazon/Preferences/Editor/Camera/DollyScrollSpeed";
constexpr AZStd::string_view CameraDollyMotionSpeedSetting = "/Amazon/Preferences/Editor/Camera/DollyMotionSpeed";
- constexpr AZStd::string_view CameraOrbitYawRotationInvertedSetting = "/Amazon/Preferences/Editor/Camera/YawRotationInverted";
+ constexpr AZStd::string_view CameraPivotYawRotationInvertedSetting = "/Amazon/Preferences/Editor/Camera/YawRotationInverted";
constexpr AZStd::string_view CameraPanInvertedXSetting = "/Amazon/Preferences/Editor/Camera/PanInvertedX";
constexpr AZStd::string_view CameraPanInvertedYSetting = "/Amazon/Preferences/Editor/Camera/PanInvertedY";
constexpr AZStd::string_view CameraPanSpeedSetting = "/Amazon/Preferences/Editor/Camera/PanSpeed";
@@ -44,12 +44,12 @@ namespace SandboxEditor
constexpr AZStd::string_view CameraTranslateUpIdSetting = "/Amazon/Preferences/Editor/Camera/CameraTranslateUpId";
constexpr AZStd::string_view CameraTranslateDownIdSetting = "/Amazon/Preferences/Editor/Camera/CameraTranslateUpDownId";
constexpr AZStd::string_view CameraTranslateBoostIdSetting = "/Amazon/Preferences/Editor/Camera/TranslateBoostId";
- constexpr AZStd::string_view CameraOrbitIdSetting = "/Amazon/Preferences/Editor/Camera/OrbitId";
+ constexpr AZStd::string_view CameraPivotIdSetting = "/Amazon/Preferences/Editor/Camera/PivotId";
constexpr AZStd::string_view CameraFreeLookIdSetting = "/Amazon/Preferences/Editor/Camera/FreeLookId";
constexpr AZStd::string_view CameraFreePanIdSetting = "/Amazon/Preferences/Editor/Camera/FreePanId";
- constexpr AZStd::string_view CameraOrbitLookIdSetting = "/Amazon/Preferences/Editor/Camera/OrbitLookId";
- constexpr AZStd::string_view CameraOrbitDollyIdSetting = "/Amazon/Preferences/Editor/Camera/OrbitDollyId";
- constexpr AZStd::string_view CameraOrbitPanIdSetting = "/Amazon/Preferences/Editor/Camera/OrbitPanId";
+ constexpr AZStd::string_view CameraPivotLookIdSetting = "/Amazon/Preferences/Editor/Camera/PivotLookId";
+ constexpr AZStd::string_view CameraPivotDollyIdSetting = "/Amazon/Preferences/Editor/Camera/PivotDollyId";
+ constexpr AZStd::string_view CameraPivotPanIdSetting = "/Amazon/Preferences/Editor/Camera/PivotPanId";
template
void SetRegistry(const AZStd::string_view setting, T&& value)
@@ -239,14 +239,14 @@ namespace SandboxEditor
SetRegistry(CameraDollyMotionSpeedSetting, speed);
}
- bool CameraOrbitYawRotationInverted()
+ bool CameraPivotYawRotationInverted()
{
- return GetRegistry(CameraOrbitYawRotationInvertedSetting, false);
+ return GetRegistry(CameraPivotYawRotationInvertedSetting, false);
}
- void SetCameraOrbitYawRotationInverted(const bool inverted)
+ void SetCameraPivotYawRotationInverted(const bool inverted)
{
- SetRegistry(CameraOrbitYawRotationInvertedSetting, inverted);
+ SetRegistry(CameraPivotYawRotationInvertedSetting, inverted);
}
bool CameraPanInvertedX()
@@ -403,14 +403,14 @@ namespace SandboxEditor
SetRegistry(CameraTranslateBoostIdSetting, cameraTranslateBoostId);
}
- AzFramework::InputChannelId CameraOrbitChannelId()
+ AzFramework::InputChannelId CameraPivotChannelId()
{
- return AzFramework::InputChannelId(GetRegistry(CameraOrbitIdSetting, AZStd::string("keyboard_key_modifier_alt_l")).c_str());
+ return AzFramework::InputChannelId(GetRegistry(CameraPivotIdSetting, AZStd::string("keyboard_key_modifier_alt_l")).c_str());
}
- void SetCameraOrbitChannelId(AZStd::string_view cameraOrbitId)
+ void SetCameraPivotChannelId(AZStd::string_view cameraPivotId)
{
- SetRegistry(CameraOrbitIdSetting, cameraOrbitId);
+ SetRegistry(CameraPivotIdSetting, cameraPivotId);
}
AzFramework::InputChannelId CameraFreeLookChannelId()
@@ -433,33 +433,33 @@ namespace SandboxEditor
SetRegistry(CameraFreePanIdSetting, cameraFreePanId);
}
- AzFramework::InputChannelId CameraOrbitLookChannelId()
+ AzFramework::InputChannelId CameraPivotLookChannelId()
{
- return AzFramework::InputChannelId(GetRegistry(CameraOrbitLookIdSetting, AZStd::string("mouse_button_left")).c_str());
+ return AzFramework::InputChannelId(GetRegistry(CameraPivotLookIdSetting, AZStd::string("mouse_button_left")).c_str());
}
- void SetCameraOrbitLookChannelId(AZStd::string_view cameraOrbitLookId)
+ void SetCameraPivotLookChannelId(AZStd::string_view cameraPivotLookId)
{
- SetRegistry(CameraOrbitLookIdSetting, cameraOrbitLookId);
+ SetRegistry(CameraPivotLookIdSetting, cameraPivotLookId);
}
- AzFramework::InputChannelId CameraOrbitDollyChannelId()
+ AzFramework::InputChannelId CameraPivotDollyChannelId()
{
- return AzFramework::InputChannelId(GetRegistry(CameraOrbitDollyIdSetting, AZStd::string("mouse_button_right")).c_str());
+ return AzFramework::InputChannelId(GetRegistry(CameraPivotDollyIdSetting, AZStd::string("mouse_button_right")).c_str());
}
- void SetCameraOrbitDollyChannelId(AZStd::string_view cameraOrbitDollyId)
+ void SetCameraPivotDollyChannelId(AZStd::string_view cameraPivotDollyId)
{
- SetRegistry(CameraOrbitDollyIdSetting, cameraOrbitDollyId);
+ SetRegistry(CameraPivotDollyIdSetting, cameraPivotDollyId);
}
- AzFramework::InputChannelId CameraOrbitPanChannelId()
+ AzFramework::InputChannelId CameraPivotPanChannelId()
{
- return AzFramework::InputChannelId(GetRegistry(CameraOrbitPanIdSetting, AZStd::string("mouse_button_middle")).c_str());
+ return AzFramework::InputChannelId(GetRegistry(CameraPivotPanIdSetting, AZStd::string("mouse_button_middle")).c_str());
}
- void SetCameraOrbitPanChannelId(AZStd::string_view cameraOrbitPanId)
+ void SetCameraPivotPanChannelId(AZStd::string_view cameraPivotPanId)
{
- SetRegistry(CameraOrbitPanIdSetting, cameraOrbitPanId);
+ SetRegistry(CameraPivotPanIdSetting, cameraPivotPanId);
}
} // namespace SandboxEditor
diff --git a/Code/Editor/EditorViewportSettings.h b/Code/Editor/EditorViewportSettings.h
index 20d397a29e..d1271017c6 100644
--- a/Code/Editor/EditorViewportSettings.h
+++ b/Code/Editor/EditorViewportSettings.h
@@ -71,8 +71,8 @@ namespace SandboxEditor
SANDBOX_API float CameraDollyMotionSpeed();
SANDBOX_API void SetCameraDollyMotionSpeed(float speed);
- SANDBOX_API bool CameraOrbitYawRotationInverted();
- SANDBOX_API void SetCameraOrbitYawRotationInverted(bool inverted);
+ SANDBOX_API bool CameraPivotYawRotationInverted();
+ SANDBOX_API void SetCameraPivotYawRotationInverted(bool inverted);
SANDBOX_API bool CameraPanInvertedX();
SANDBOX_API void SetCameraPanInvertedX(bool inverted);
@@ -119,8 +119,8 @@ namespace SandboxEditor
SANDBOX_API AzFramework::InputChannelId CameraTranslateBoostChannelId();
SANDBOX_API void SetCameraTranslateBoostChannelId(AZStd::string_view cameraTranslateBoostId);
- SANDBOX_API AzFramework::InputChannelId CameraOrbitChannelId();
- SANDBOX_API void SetCameraOrbitChannelId(AZStd::string_view cameraOrbitId);
+ SANDBOX_API AzFramework::InputChannelId CameraPivotChannelId();
+ SANDBOX_API void SetCameraPivotChannelId(AZStd::string_view cameraPivotId);
SANDBOX_API AzFramework::InputChannelId CameraFreeLookChannelId();
SANDBOX_API void SetCameraFreeLookChannelId(AZStd::string_view cameraFreeLookId);
@@ -128,12 +128,12 @@ namespace SandboxEditor
SANDBOX_API AzFramework::InputChannelId CameraFreePanChannelId();
SANDBOX_API void SetCameraFreePanChannelId(AZStd::string_view cameraFreePanId);
- SANDBOX_API AzFramework::InputChannelId CameraOrbitLookChannelId();
- SANDBOX_API void SetCameraOrbitLookChannelId(AZStd::string_view cameraOrbitLookId);
+ SANDBOX_API AzFramework::InputChannelId CameraPivotLookChannelId();
+ SANDBOX_API void SetCameraPivotLookChannelId(AZStd::string_view cameraPivotLookId);
- SANDBOX_API AzFramework::InputChannelId CameraOrbitDollyChannelId();
- SANDBOX_API void SetCameraOrbitDollyChannelId(AZStd::string_view cameraOrbitDollyId);
+ SANDBOX_API AzFramework::InputChannelId CameraPivotDollyChannelId();
+ SANDBOX_API void SetCameraPivotDollyChannelId(AZStd::string_view cameraPivotDollyId);
- SANDBOX_API AzFramework::InputChannelId CameraOrbitPanChannelId();
- SANDBOX_API void SetCameraOrbitPanChannelId(AZStd::string_view cameraOrbitPanId);
+ SANDBOX_API AzFramework::InputChannelId CameraPivotPanChannelId();
+ SANDBOX_API void SetCameraPivotPanChannelId(AZStd::string_view cameraPivotPanId);
} // namespace SandboxEditor
diff --git a/Code/Editor/EditorViewportWidget.cpp b/Code/Editor/EditorViewportWidget.cpp
index 5b5b52d28f..dad6734428 100644
--- a/Code/Editor/EditorViewportWidget.cpp
+++ b/Code/Editor/EditorViewportWidget.cpp
@@ -2428,7 +2428,7 @@ void EditorViewportWidget::RestoreViewportAfterGameMode()
}
else
{
- AZ_Error("CryLegacy", false, "Not restoring the editor viewport camera is currently unsupported");
+ AZ_Warning("CryLegacy", false, "Not restoring the editor viewport camera is currently unsupported");
SetViewTM(preGameModeViewTM);
}
}
diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Platform/Android/tool_dependencies_android.cmake b/Code/Editor/Lib/Tests/Camera/editor_lib_camera_test_files.cmake
similarity index 85%
rename from Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Platform/Android/tool_dependencies_android.cmake
rename to Code/Editor/Lib/Tests/Camera/editor_lib_camera_test_files.cmake
index 5bf4d7cb7e..69d3e37f2d 100644
--- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Platform/Android/tool_dependencies_android.cmake
+++ b/Code/Editor/Lib/Tests/Camera/editor_lib_camera_test_files.cmake
@@ -6,5 +6,6 @@
#
#
-set(GEM_DEPENDENCIES
+set(FILES
+ test_EditorCamera.cpp
)
diff --git a/Code/Editor/Lib/Tests/Camera/test_EditorCamera.cpp b/Code/Editor/Lib/Tests/Camera/test_EditorCamera.cpp
new file mode 100644
index 0000000000..affe5794cc
--- /dev/null
+++ b/Code/Editor/Lib/Tests/Camera/test_EditorCamera.cpp
@@ -0,0 +1,225 @@
+/*
+ * Copyright (c) Contributors to the Open 3D Engine Project.
+ * For complete copyright and license terms please see the LICENSE at the root of this distribution.
+ *
+ * SPDX-License-Identifier: Apache-2.0 OR MIT
+ *
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace UnitTest
+{
+ class EditorCameraTestEnvironment : public AZ::Test::GemTestEnvironment
+ {
+ // AZ::Test::GemTestEnvironment overrides ...
+ void AddGemsAndComponents() override;
+ };
+
+ void EditorCameraTestEnvironment::AddGemsAndComponents()
+ {
+ AddDynamicModulePaths({ CAMERA_EDITOR_MODULE });
+ AddComponentDescriptors({ AzToolsFramework::Components::TransformComponent::CreateDescriptor() });
+ }
+
+ class EditorCameraFixture : public ::testing::Test
+ {
+ public:
+ AtomToolsFramework::ModularCameraViewportContext* m_cameraViewportContextView = nullptr;
+ AZStd::unique_ptr m_editorModularViewportCameraComposer;
+ AZStd::unique_ptr m_editorLibHandle;
+ AzFramework::ViewportControllerListPtr m_controllerList;
+ AZStd::unique_ptr m_entity;
+
+ static const AzFramework::ViewportId TestViewportId;
+
+ void SetUp() override
+ {
+ m_editorLibHandle = AZ::DynamicModuleHandle::Create("EditorLib");
+ [[maybe_unused]] const bool loaded = m_editorLibHandle->Load(true);
+ AZ_Assert(loaded, "EditorLib could not be loaded");
+
+ m_controllerList = AZStd::make_shared();
+ m_controllerList->RegisterViewportContext(TestViewportId);
+
+ m_entity = AZStd::make_unique();
+ m_entity->Init();
+ m_entity->CreateComponent();
+ m_entity->Activate();
+
+ m_editorModularViewportCameraComposer = AZStd::make_unique(TestViewportId);
+
+ auto controller = m_editorModularViewportCameraComposer->CreateModularViewportCameraController();
+ // set some overrides for the test
+ controller->SetCameraViewportContextBuilderCallback(
+ [this](AZStd::unique_ptr& cameraViewportContext) mutable
+ {
+ cameraViewportContext = AZStd::make_unique();
+ m_cameraViewportContextView = cameraViewportContext.get();
+ });
+
+ m_controllerList->Add(controller);
+ }
+
+ void TearDown() override
+ {
+ m_editorModularViewportCameraComposer.reset();
+ m_cameraViewportContextView = nullptr;
+ m_entity.reset();
+ m_editorLibHandle = {};
+ }
+ };
+
+ const AzFramework::ViewportId EditorCameraFixture::TestViewportId = AzFramework::ViewportId(1337);
+
+ TEST_F(EditorCameraFixture, ModularViewportCameraControllerReferenceFrameUpdatedWhenViewportEntityisChanged)
+ {
+ // Given
+ const auto entityTransform = AZ::Transform::CreateFromQuaternionAndTranslation(
+ AZ::Quaternion::CreateRotationX(AZ::DegToRad(90.0f)), AZ::Vector3(10.0f, 5.0f, -2.0f));
+ AZ::TransformBus::Event(m_entity->GetId(), &AZ::TransformBus::Events::SetWorldTM, entityTransform);
+
+ // When
+ // imitate viewport entity changing
+ Camera::EditorCameraNotificationBus::Broadcast(
+ &Camera::EditorCameraNotificationBus::Events::OnViewportViewEntityChanged, m_entity->GetId());
+
+ // ensure the viewport updates after the viewport view entity change
+ const float deltaTime = 1.0f / 60.0f;
+ m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(deltaTime), AZ::ScriptTimePoint() });
+
+ // retrieve updated camera transform
+ const AZ::Transform cameraTransform = m_cameraViewportContextView->GetCameraTransform();
+
+ // Then
+ // camera transform matches that of the entity
+ EXPECT_THAT(cameraTransform, IsClose(entityTransform));
+ }
+
+ TEST_F(EditorCameraFixture, ReferenceFrameRemainsIdentityAfterExternalCameraTransformChangeWhenNotSet)
+ {
+ // Given
+ m_cameraViewportContextView->SetCameraTransform(AZ::Transform::CreateTranslation(AZ::Vector3(10.0f, 20.0f, 30.0f)));
+
+ // When
+ AZ::Transform referenceFrame = AZ::Transform::CreateTranslation(AZ::Vector3(1.0f, 2.0f, 3.0f));
+ AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult(
+ referenceFrame, TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::GetReferenceFrame);
+
+ // Then
+ // reference frame is still the identity
+ EXPECT_THAT(referenceFrame, IsClose(AZ::Transform::CreateIdentity()));
+ }
+
+ TEST_F(EditorCameraFixture, ExternalCameraTransformChangeWhenReferenceFrameIsSetUpdatesReferenceFrame)
+ {
+ // Given
+ const AZ::Transform referenceFrame = AZ::Transform::CreateFromQuaternionAndTranslation(
+ AZ::Quaternion::CreateRotationX(AZ::DegToRad(90.0f)), AZ::Vector3(1.0f, 2.0f, 3.0f));
+ AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event(
+ TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::SetReferenceFrame, referenceFrame);
+
+ const AZ::Transform nextTransform = AZ::Transform::CreateTranslation(AZ::Vector3(10.0f, 20.0f, 30.0f));
+ m_cameraViewportContextView->SetCameraTransform(nextTransform);
+
+ // When
+ AZ::Transform currentReferenceFrame = AZ::Transform::CreateTranslation(AZ::Vector3(1.0f, 2.0f, 3.0f));
+ AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult(
+ currentReferenceFrame, TestViewportId,
+ &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::GetReferenceFrame);
+
+ // Then
+ EXPECT_THAT(currentReferenceFrame, IsClose(nextTransform));
+ }
+
+ TEST_F(EditorCameraFixture, ReferenceFrameReturnedToIdentityAfterClear)
+ {
+ // Given
+ const AZ::Transform referenceFrame = AZ::Transform::CreateFromQuaternionAndTranslation(
+ AZ::Quaternion::CreateRotationX(AZ::DegToRad(90.0f)), AZ::Vector3(1.0f, 2.0f, 3.0f));
+ AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event(
+ TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::SetReferenceFrame, referenceFrame);
+
+ // When
+ AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event(
+ TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::ClearReferenceFrame);
+
+ AZ::Transform currentReferenceFrame = AZ::Transform::CreateTranslation(AZ::Vector3(1.0f, 2.0f, 3.0f));
+ AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult(
+ currentReferenceFrame, TestViewportId,
+ &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::GetReferenceFrame);
+
+ // Then
+ EXPECT_THAT(currentReferenceFrame, IsClose(AZ::Transform::CreateIdentity()));
+ }
+
+ TEST_F(EditorCameraFixture, InterpolateToTransform)
+ {
+ // When
+ AZ::Transform transformToInterpolateTo = AZ::Transform::CreateFromQuaternionAndTranslation(
+ AZ::Quaternion::CreateRotationZ(AZ::DegToRad(90.0f)), AZ::Vector3(20.0f, 40.0f, 60.0f));
+ AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event(
+ TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::InterpolateToTransform,
+ transformToInterpolateTo, 0.0f);
+
+ // simulate interpolation
+ m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(0.5f), AZ::ScriptTimePoint() });
+ m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(0.5f), AZ::ScriptTimePoint() });
+
+ const auto finalTransform = m_cameraViewportContextView->GetCameraTransform();
+
+ // Then
+ EXPECT_THAT(finalTransform, IsClose(transformToInterpolateTo));
+ }
+
+ TEST_F(EditorCameraFixture, InterpolateToTransformWithReferenceSpaceSet)
+ {
+ // Given
+ const AZ::Transform referenceFrame = AZ::Transform::CreateFromQuaternionAndTranslation(
+ AZ::Quaternion::CreateRotationX(AZ::DegToRad(90.0f)), AZ::Vector3(1.0f, 2.0f, 3.0f));
+ AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event(
+ TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::SetReferenceFrame, referenceFrame);
+
+ AZ::Transform transformToInterpolateTo = AZ::Transform::CreateFromQuaternionAndTranslation(
+ AZ::Quaternion::CreateRotationZ(AZ::DegToRad(90.0f)), AZ::Vector3(20.0f, 40.0f, 60.0f));
+
+ // When
+ AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event(
+ TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::InterpolateToTransform,
+ transformToInterpolateTo, 0.0f);
+
+ // simulate interpolation
+ m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(0.5f), AZ::ScriptTimePoint() });
+ m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(0.5f), AZ::ScriptTimePoint() });
+
+ AZ::Transform currentReferenceFrame = AZ::Transform::CreateTranslation(AZ::Vector3(1.0f, 2.0f, 3.0f));
+ AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult(
+ currentReferenceFrame, TestViewportId,
+ &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::GetReferenceFrame);
+
+ const auto finalTransform = m_cameraViewportContextView->GetCameraTransform();
+
+ // Then
+ EXPECT_THAT(finalTransform, IsClose(transformToInterpolateTo));
+ EXPECT_THAT(currentReferenceFrame, IsClose(AZ::Transform::CreateIdentity()));
+ }
+} // namespace UnitTest
+
+// required to support running integration tests with the Camera Gem
+AZTEST_EXPORT int AZ_UNIT_TEST_HOOK_NAME(int argc, char** argv)
+{
+ ::testing::InitGoogleMock(&argc, argv);
+ AZ::Test::printUnusedParametersWarning(argc, argv);
+ AZ::Test::addTestEnvironments({ new UnitTest::EditorCameraTestEnvironment() });
+ int result = RUN_ALL_TESTS();
+ return result;
+}
+
+IMPLEMENT_TEST_EXECUTABLE_MAIN();
diff --git a/Code/Editor/Lib/Tests/test_ModularViewportCameraController.cpp b/Code/Editor/Lib/Tests/test_ModularViewportCameraController.cpp
index ce5564c7f6..157291cfc2 100644
--- a/Code/Editor/Lib/Tests/test_ModularViewportCameraController.cpp
+++ b/Code/Editor/Lib/Tests/test_ModularViewportCameraController.cpp
@@ -58,28 +58,6 @@ namespace UnitTest
return true;
}
- class TestModularCameraViewportContextImpl : public AtomToolsFramework::ModularCameraViewportContext
- {
- public:
- AZ::Transform GetCameraTransform() const override
- {
- return m_cameraTransform;
- }
-
- void SetCameraTransform(const AZ::Transform& transform) override
- {
- m_cameraTransform = transform;
- }
-
- void ConnectViewMatrixChangedHandler(AZ::RPI::ViewportContext::MatrixChangedEvent::Handler&) override
- {
- // noop
- }
-
- private:
- AZ::Transform m_cameraTransform = AZ::Transform::CreateIdentity();
- };
-
class ModularViewportCameraControllerFixture : public AllocatorsTestFixture
{
public:
@@ -146,7 +124,7 @@ namespace UnitTest
controller->SetCameraViewportContextBuilderCallback(
[this](AZStd::unique_ptr& cameraViewportContext)
{
- cameraViewportContext = AZStd::make_unique();
+ cameraViewportContext = AZStd::make_unique();
m_cameraViewportContextView = cameraViewportContext.get();
});
diff --git a/Code/Framework/AzCore/AzCore/Component/Entity.cpp b/Code/Framework/AzCore/AzCore/Component/Entity.cpp
index 00c1895261..0fe201d448 100644
--- a/Code/Framework/AzCore/AzCore/Component/Entity.cpp
+++ b/Code/Framework/AzCore/AzCore/Component/Entity.cpp
@@ -207,12 +207,6 @@ namespace AZ
ActivateComponent(**it);
}
- // Cache the transform interface to the transform interface
- // Generally this pattern is not recommended unless for component event buses
- // As we have a guarantee (by design) that components can't change during active state)
- // Even though technically they can connect disconnect from the bus.
- m_transform = TransformBus::FindFirstHandler(m_id);
-
SetState(State::Active);
EBUS_EVENT_ID(m_id, EntityBus, OnEntityActivated, m_id);
@@ -655,6 +649,16 @@ namespace AZ
m_stateEvent.Signal(oldState, m_state);
}
+ void Entity::SetSpawnTicketId(u32 spawnTicketId)
+ {
+ m_spawnTicketId = spawnTicketId;
+ }
+
+ u32 Entity::GetSpawnTicketId() const
+ {
+ return m_spawnTicketId;
+ }
+
void Entity::OnNameChanged() const
{
EBUS_EVENT_ID(GetId(), EntityBus, OnEntityNameChanged, m_name);
@@ -1320,6 +1324,19 @@ namespace AZ
return *processSignature;
}
+ AZ::TransformInterface* Entity::GetTransform() const
+ {
+ // Lazy evaluation of the cached entity transform.
+ if(!m_transform)
+ {
+ // Generally this pattern is not recommended unless for component event buses
+ // As we have a guarantee (by design) that components can't change during active state)
+ // Even though technically they can connect disconnect from the bus.
+ m_transform = TransformBus::FindFirstHandler(m_id);
+ }
+ return m_transform;
+ }
+
//=========================================================================
// MakeId
// Ids must be unique across a project at authoring time. Runtime doesn't matter
diff --git a/Code/Framework/AzCore/AzCore/Component/Entity.h b/Code/Framework/AzCore/AzCore/Component/Entity.h
index 7ec63a56ac..c2bde375bb 100644
--- a/Code/Framework/AzCore/AzCore/Component/Entity.h
+++ b/Code/Framework/AzCore/AzCore/Component/Entity.h
@@ -133,6 +133,14 @@ namespace AZ
//! @return The state of the entity. For example, the entity has been initialized, the entity is active, and so on.
State GetState() const { return m_state; }
+ //! Gets the ticket id used to spawn the entity.
+ //! @return the ticket id used to spawn the entity. If entity is not spawned, the id will be 0.
+ u32 GetSpawnTicketId() const;
+
+ //! Sets the ticket id used to spawn the entity. The ticket id in the entity will remain 0 unless it's set using this function.
+ //! @param spawnTicketId the ticket id used to spawn the entity.
+ void SetSpawnTicketId(u32 spawnTicketId);
+
//! Connects an entity state event handler to the entity.
//! All state changes will be signaled through this event.
//! @param handler reference to the EntityStateEvent handler to attach to the entities state event.
@@ -354,10 +362,9 @@ namespace AZ
//! @return The Process Signature of the local machine.
static AZ::u32 GetProcessSignature();
- /// @cond EXCLUDE_DOCS
- //! @deprecated Use the TransformBus to communicate with the TransformInterface.
- inline TransformInterface* GetTransform() const { return m_transform; }
- /// @endcond
+ //! Gets the TransformInterface for the entity.
+ //! @return The TransformInterface for the entity.
+ TransformInterface* GetTransform() const;
//! Sorts an entity's components based on the dependencies between components.
//! If all dependencies are met, the required services can be activated
@@ -406,11 +413,13 @@ namespace AZ
//! A cached pointer to the transform interface.
//! We recommend using AZ::TransformBus and caching locally instead of accessing
//! the transform interface directly through this pointer.
- TransformInterface* m_transform;
+ mutable TransformInterface* m_transform;
//! A user-friendly name for the entity. This makes error messages easier to read.
AZStd::string m_name;
+ u32 m_spawnTicketId = 0;
+
//! The state of the entity.
State m_state;
diff --git a/Code/Framework/AzCore/AzCore/IO/FileReader.cpp b/Code/Framework/AzCore/AzCore/IO/FileReader.cpp
new file mode 100644
index 0000000000..94118cdfe4
--- /dev/null
+++ b/Code/Framework/AzCore/AzCore/IO/FileReader.cpp
@@ -0,0 +1,200 @@
+/*
+ * Copyright (c) Contributors to the Open 3D Engine Project.
+ * For complete copyright and license terms please see the LICENSE at the root of this distribution.
+ *
+ * SPDX-License-Identifier: Apache-2.0 OR MIT
+ *
+ */
+
+#include
+#include
+#include
+
+namespace AZ::IO
+{
+ FileReader::FileReader() = default;
+
+ FileReader::FileReader(AZ::IO::FileIOBase* fileIoBase, const char* filePath)
+ {
+ Open(fileIoBase, filePath);
+ }
+
+ FileReader::~FileReader()
+ {
+ Close();
+ }
+
+ FileReader::FileReader(FileReader&& other)
+ {
+ AZStd::swap(m_file, other.m_file);
+ AZStd::swap(m_fileIoBase, other.m_fileIoBase);
+ }
+
+ FileReader& FileReader::operator=(FileReader&& other)
+ {
+ // Close the current file and take over other file
+ Close();
+ m_file = AZStd::move(other.m_file);
+ m_fileIoBase = AZStd::move(other.m_fileIoBase);
+ other.m_file = AZStd::monostate{};
+ other.m_fileIoBase = {};
+
+ return *this;
+ }
+
+ bool FileReader::Open(AZ::IO::FileIOBase* fileIoBase, const char* filePath)
+ {
+ // Close file if the FileReader has an instance open
+ Close();
+
+ if (fileIoBase != nullptr)
+ {
+ AZ::IO::HandleType fileHandle;
+ if (fileIoBase->Open(filePath, IO::OpenMode::ModeRead, fileHandle))
+ {
+ m_file = fileHandle;
+ m_fileIoBase = fileIoBase;
+ return true;
+ }
+ }
+ else
+ {
+ AZ::IO::SystemFile file;
+ if (file.Open(filePath, IO::SystemFile::OpenMode::SF_OPEN_READ_ONLY))
+ {
+ m_file = AZStd::move(file);
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ bool FileReader::IsOpen() const
+ {
+ if (auto fileHandle = AZStd::get_if(&m_file); fileHandle != nullptr)
+ {
+ return *fileHandle != AZ::IO::InvalidHandle;
+ }
+ else if (auto systemFile = AZStd::get_if(&m_file); systemFile != nullptr)
+ {
+ return systemFile->IsOpen();
+ }
+
+ return false;
+ }
+
+ void FileReader::Close()
+ {
+ if (auto fileHandle = AZStd::get_if(&m_file); fileHandle != nullptr)
+ {
+ if (AZ::IO::FileIOBase* fileIo = m_fileIoBase; fileIo != nullptr)
+ {
+ fileIo->Close(*fileHandle);
+ }
+ }
+
+ m_file = AZStd::monostate{};
+ m_fileIoBase = {};
+ }
+
+ auto FileReader::Length() const -> SizeType
+ {
+ if (auto fileHandle = AZStd::get_if(&m_file); fileHandle != nullptr)
+ {
+ if (SizeType fileSize{}; m_fileIoBase->Size(*fileHandle, fileSize))
+ {
+ return fileSize;
+ }
+ }
+ else if (auto systemFile = AZStd::get_if(&m_file); systemFile != nullptr)
+ {
+ return systemFile->Length();
+ }
+
+ return 0;
+ }
+
+ auto FileReader::Read(SizeType byteSize, void* buffer) -> SizeType
+ {
+ if (auto fileHandle = AZStd::get_if(&m_file); fileHandle != nullptr)
+ {
+ if (SizeType bytesRead{}; m_fileIoBase->Read(*fileHandle, buffer, byteSize, false, &bytesRead))
+ {
+ return bytesRead;
+ }
+ }
+ else if (auto systemFile = AZStd::get_if(&m_file); systemFile != nullptr)
+ {
+ return systemFile->Read(byteSize, buffer);
+ }
+
+ return 0;
+ }
+
+ auto FileReader::Tell() const -> SizeType
+ {
+ if (auto fileHandle = AZStd::get_if(&m_file); fileHandle != nullptr)
+ {
+ if (SizeType fileOffset{}; m_fileIoBase->Tell(*fileHandle, fileOffset))
+ {
+ return fileOffset;
+ }
+ }
+ else if (auto systemFile = AZStd::get_if(&m_file); systemFile != nullptr)
+ {
+ return systemFile->Tell();
+ }
+
+ return 0;
+ }
+
+ bool FileReader::Seek(AZ::s64 offset, SeekType type)
+ {
+ if (auto fileHandle = AZStd::get_if(&m_file); fileHandle != nullptr)
+ {
+ return m_fileIoBase->Seek(*fileHandle, offset, type);
+ }
+ else if (auto systemFile = AZStd::get_if(&m_file); systemFile != nullptr)
+ {
+ systemFile->Seek(offset, static_cast(type));
+ return true;
+ }
+
+ return false;
+ }
+
+ bool FileReader::Eof() const
+ {
+ if (auto fileHandle = AZStd::get_if(&m_file); fileHandle != nullptr)
+ {
+ return m_fileIoBase->Eof(*fileHandle);
+ }
+ else if (auto systemFile = AZStd::get_if(&m_file); systemFile != nullptr)
+ {
+ return systemFile->Eof();
+ }
+
+ return false;
+ }
+
+ bool FileReader::GetFilePath(AZ::IO::FixedMaxPath& filePath) const
+ {
+ if (auto fileHandle = AZStd::get_if(&m_file); fileHandle != nullptr)
+ {
+ AZ::IO::FixedMaxPathString& pathStringRef = filePath.Native();
+ if (m_fileIoBase->GetFilename(*fileHandle, pathStringRef.data(), pathStringRef.capacity()))
+ {
+ pathStringRef.resize_no_construct(AZStd::char_traits::length(pathStringRef.data()));
+ return true;
+ }
+ }
+ else if (auto systemFile = AZStd::get_if(&m_file); systemFile != nullptr)
+ {
+ filePath = systemFile->Name();
+ return true;
+ }
+
+ return false;
+ }
+}
diff --git a/Code/Framework/AzCore/AzCore/IO/FileReader.h b/Code/Framework/AzCore/AzCore/IO/FileReader.h
new file mode 100644
index 0000000000..4fdb18b2b2
--- /dev/null
+++ b/Code/Framework/AzCore/AzCore/IO/FileReader.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) Contributors to the Open 3D Engine Project.
+ * For complete copyright and license terms please see the LICENSE at the root of this distribution.
+ *
+ * SPDX-License-Identifier: Apache-2.0 OR MIT
+ *
+ */
+#pragma once
+
+#include
+#include
+#include
+
+namespace AZ::IO
+{
+ class FileIOBase;
+ enum class SeekType : AZ::u32;
+
+ //! Structure which encapsulates delegates File Read operations
+ //! to either the FileIOBase or SystemFile classes based if a FileIOBase* instance has been supplied
+ //! to the FileSystemReader class
+ //! the SettingsRegistry option to use FileIO
+ class FileReader
+ {
+ using HandleType = AZ::u32;
+ using FileHandleType = AZStd::variant;
+ public:
+ using SizeType = AZ::u64;
+
+ //! Creates FileReader instance in the default state with no file opend
+ FileReader();
+ ~FileReader();
+
+ //! Creates a new FileReader instance and attempts to open the file at the supplied path
+ //! Uses the FileIOBase instance if supplied
+ //! @param fileIOBase pointer to fileIOBase instance
+ //! @param null-terminated filePath to open
+ FileReader(AZ::IO::FileIOBase* fileIoBase, const char* filePath);
+
+ //! Takes ownership of the supplied FileReader handle
+ FileReader(FileReader&& other);
+
+ //! Moves ownership of FileReader handle to this instance
+ FileReader& operator=(FileReader&& other);
+
+ //! Opens a File using the FileIOBase instance if non-nullptr
+ //! Otherwise fall back to use SystemFile
+ //! @param fileIOBase pointer to fileIOBase instance
+ //! @param null-terminated filePath to open
+ //! @return true if the File is opened successfully
+ bool Open(AZ::IO::FileIOBase* fileIoBase, const char* filePath);
+
+ //! Returns true if a file is currently open
+ //! @return true if the file is open
+ bool IsOpen() const;
+
+ //! Closes the File
+ void Close();
+
+ //! Retrieve the length of the OpenFile
+ SizeType Length() const;
+
+ //! Attempts to read up to byte size bytes into the supplied buffer
+ //! @param byteSize - Maximum number of bytes to read
+ //! @param buffer - Buffer to read bytes into
+ //! @returns the number of bytes read if the file is open, otherwise 0
+ SizeType Read(SizeType byteSize, void* buffer);
+
+ //! Returns the current file offset
+ //! @returns file offset if the file is open, otherwise 0
+ SizeType Tell() const;
+
+ //! Seeks within the open file to the offset supplied
+ //! @param offset File offset to seek to
+ //! @param type parameter to indicate the reference point to start the seek from
+ //! @returns true if the file is open and the seek succeeded
+ bool Seek(AZ::s64 offset, SeekType type);
+
+ //! Returns true if the file is open and in the EOF state
+ bool Eof() const;
+
+ //! Store the file path of the open file into the output file path parameter
+ //! The filePath reference is left unmodified, if the path was not stored
+ //! @return true if the filePath was stored
+ bool GetFilePath(AZ::IO::FixedMaxPath& filePath) const;
+
+ private:
+
+ FileHandleType m_file;
+ AZ::IO::FileIOBase* m_fileIoBase{};
+ };
+}
diff --git a/Code/Framework/AzCore/AzCore/IO/SystemFile.cpp b/Code/Framework/AzCore/AzCore/IO/SystemFile.cpp
index 5bff79b422..651abb89fe 100644
--- a/Code/Framework/AzCore/AzCore/IO/SystemFile.cpp
+++ b/Code/Framework/AzCore/AzCore/IO/SystemFile.cpp
@@ -160,12 +160,12 @@ void SystemFile::Seek(SeekSizeType offset, SeekMode mode)
Platform::Seek(m_handle, this, offset, mode);
}
-SystemFile::SizeType SystemFile::Tell()
+SystemFile::SizeType SystemFile::Tell() const
{
return Platform::Tell(m_handle, this);
}
-bool SystemFile::Eof()
+bool SystemFile::Eof() const
{
return Platform::Eof(m_handle, this);
}
diff --git a/Code/Framework/AzCore/AzCore/IO/SystemFile.h b/Code/Framework/AzCore/AzCore/IO/SystemFile.h
index 8a5b2b2521..551ce89ce7 100644
--- a/Code/Framework/AzCore/AzCore/IO/SystemFile.h
+++ b/Code/Framework/AzCore/AzCore/IO/SystemFile.h
@@ -72,9 +72,9 @@ namespace AZ
/// Seek in current file.
void Seek(SeekSizeType offset, SeekMode mode);
/// Get the cursor position in the current file.
- SizeType Tell();
+ SizeType Tell() const;
/// Is the cursor at the end of the file?
- bool Eof();
+ bool Eof() const;
/// Get the time the file was last modified.
AZ::u64 ModificationTime();
/// Read data from a file synchronous. Return number of bytes actually read in the buffer.
diff --git a/Code/Framework/AzCore/AzCore/Math/Transform.cpp b/Code/Framework/AzCore/AzCore/Math/Transform.cpp
index 5cb09fe9a8..1701820bae 100644
--- a/Code/Framework/AzCore/AzCore/Math/Transform.cpp
+++ b/Code/Framework/AzCore/AzCore/Math/Transform.cpp
@@ -353,6 +353,7 @@ namespace AZ
Method("CreateFromMatrix3x3AndTranslation", &Transform::CreateFromMatrix3x3AndTranslation)->
Method("CreateUniformScale", &Transform::CreateUniformScale)->
Method("CreateTranslation", &Transform::CreateTranslation)->
+ Method("CreateLookAt", &Transform::CreateLookAt)->
Method("ConstructFromValuesNumeric", &Internal::ConstructTransformFromValues);
}
}
diff --git a/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryImpl.cpp b/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryImpl.cpp
index 7ef1fa661d..92f546815e 100644
--- a/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryImpl.cpp
+++ b/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryImpl.cpp
@@ -10,6 +10,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -1116,118 +1117,6 @@ namespace AZ
}
}
- //! Structure which encapsulates Commands to either the FileIOBase or SystemFile classes based on
- //! the SettingsRegistry option to use FileIO
- struct SettingsRegistryFileReader
- {
- using FileHandleType = AZStd::variant;
-
- SettingsRegistryFileReader() = default;
- SettingsRegistryFileReader(bool useFileIo, const char* filePath)
- {
- Open(useFileIo, filePath);
- }
-
- ~SettingsRegistryFileReader()
- {
- if (auto fileHandle = AZStd::get_if(&m_file); fileHandle != nullptr)
- {
- if (AZ::IO::FileIOBase* fileIo = AZ::IO::FileIOBase::GetInstance(); fileIo != nullptr)
- {
- fileIo->Close(*fileHandle);
- }
- }
- }
-
- bool Open(bool useFileIo, const char* filePath)
- {
- Close();
- if (AZ::IO::FileIOBase* fileIo = useFileIo ? AZ::IO::FileIOBase::GetInstance() : nullptr; fileIo != nullptr)
- {
- AZ::IO::HandleType fileHandle;
- if (fileIo->Open(filePath, IO::OpenMode::ModeRead, fileHandle))
- {
- m_file = fileHandle;
- return true;
- }
- }
- else
- {
- AZ::IO::SystemFile file;
- if (file.Open(filePath, IO::SystemFile::OpenMode::SF_OPEN_READ_ONLY))
- {
- m_file = AZStd::move(file);
- return true;
- }
- }
-
- return false;
- }
-
- bool IsOpen() const
- {
- if (auto fileHandle = AZStd::get_if(&m_file); fileHandle != nullptr)
- {
- return *fileHandle != AZ::IO::InvalidHandle;
- }
- else if (auto systemFile = AZStd::get_if(&m_file); systemFile != nullptr)
- {
- return systemFile->IsOpen();
- }
-
- return false;
- }
-
- void Close()
- {
- if (auto fileHandle = AZStd::get_if(&m_file); fileHandle != nullptr)
- {
- if (AZ::IO::FileIOBase* fileIo = AZ::IO::FileIOBase::GetInstance(); fileIo != nullptr)
- {
- fileIo->Close(*fileHandle);
- }
- }
-
- m_file = AZStd::monostate{};
- }
-
- u64 Length() const
- {
- if (auto fileHandle = AZStd::get_if(&m_file); fileHandle != nullptr)
- {
- if (u64 fileSize{}; AZ::IO::FileIOBase::GetInstance()->Size(*fileHandle, fileSize))
- {
- return fileSize;
- }
- }
- else if (auto systemFile = AZStd::get_if(&m_file); systemFile != nullptr)
- {
- return systemFile->Length();
- }
-
- return 0;
- }
-
- AZ::IO::SizeType Read(AZ::IO::SizeType byteSize, void* buffer)
- {
- if (auto fileHandle = AZStd::get_if(&m_file); fileHandle != nullptr)
- {
- if (AZ::u64 bytesRead{}; AZ::IO::FileIOBase::GetInstance()->Read(*fileHandle, buffer, byteSize, false, &bytesRead))
- {
- return bytesRead;
- }
- }
- else if (auto systemFile = AZStd::get_if(&m_file); systemFile != nullptr)
- {
- return systemFile->Read(byteSize, buffer);
- }
-
- return 0;
- }
-
- FileHandleType m_file;
- };
-
bool SettingsRegistryImpl::MergeSettingsFileInternal(const char* path, Format format, AZStd::string_view rootKey,
AZStd::vector& scratchBuffer)
{
@@ -1236,7 +1125,7 @@ namespace AZ
Pointer pointer(AZ_SETTINGS_REGISTRY_HISTORY_KEY "/-");
- SettingsRegistryFileReader fileReader(m_useFileIo, path);
+ FileReader fileReader(m_useFileIo ? AZ::IO::FileIOBase::GetInstance(): nullptr, path);
if (!fileReader.IsOpen())
{
AZ_Error("Settings Registry", false, R"(Unable to open registry file "%s".)", path);
diff --git a/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.cpp b/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.cpp
index 5290c9b02a..da7110e36e 100644
--- a/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.cpp
+++ b/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.cpp
@@ -6,6 +6,8 @@
*
*/
+#include
+#include
#include
#include
#include
@@ -388,8 +390,36 @@ namespace AZ::SettingsRegistryMergeUtils
const ConfigParserSettings& configParserSettings)
{
auto configPath = FindEngineRoot(registry) / filePath;
- IO::SystemFile configFile;
- if (!configFile.Open(configPath.c_str(), IO::SystemFile::OpenMode::SF_OPEN_READ_ONLY))
+ IO::FileReader configFile;
+ bool configFileOpened{};
+ switch (configParserSettings.m_fileReaderClass)
+ {
+ case ConfigParserSettings::FileReaderClass::UseFileIOIfAvailableFallbackToSystemFile:
+ {
+ auto fileIo = AZ::IO::FileIOBase::GetInstance();
+ configFileOpened = configFile.Open(fileIo, configPath.c_str());
+ break;
+ }
+ case ConfigParserSettings::FileReaderClass::UseSystemFileOnly:
+ {
+ configFileOpened = configFile.Open(nullptr, configPath.c_str());
+ break;
+ }
+ case ConfigParserSettings::FileReaderClass::UseFileIOOnly:
+ {
+ auto fileIo = AZ::IO::FileIOBase::GetInstance();
+ if (fileIo == nullptr)
+ {
+ return false;
+ }
+ configFileOpened = configFile.Open(fileIo, configPath.c_str());
+ break;
+ }
+ default:
+ AZ_Error("SettingsRegistryMergeUtils", false, "An Invalid FileReaderClass enum value has been supplied");
+ return false;
+ }
+ if (!configFileOpened)
{
AZ_Warning("SettingsRegistryMergeUtils", false, R"(Unable to open file "%s")", configPath.c_str());
return false;
@@ -480,7 +510,7 @@ namespace AZ::SettingsRegistryMergeUtils
AZ_Error("SettingsRegistryMergeUtils", false,
R"(The config file "%s" contains a line which is longer than the max line length of %zu.)" "\n"
R"(Parsing will halt. The line content so far is:)" "\n"
- R"("%.*s")" "\n", configFile.Name(), configBuffer.max_size(),
+ R"("%.*s")" "\n", configPath.c_str(), configBuffer.max_size(),
aznumeric_cast(configBuffer.size()), configBuffer.data());
configFileParsed = false;
break;
diff --git a/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.h b/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.h
index 02346c2ba1..daa64c0343 100644
--- a/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.h
+++ b/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.h
@@ -155,6 +155,15 @@ namespace AZ::SettingsRegistryMergeUtils
//! structure which is forwarded to the SettingsRegistryInterface MergeCommandLineArgument function
//! The structure contains a functor which returns true if a character is a valid delimiter
SettingsRegistryInterface::CommandLineArgumentSettings m_commandLineSettings;
+
+ //! enumeration to indicate if AZ::IO::FileIOBase should be used to open the config file over AZ::IO::SystemFile
+ enum class FileReaderClass
+ {
+ UseFileIOIfAvailableFallbackToSystemFile,
+ UseSystemFileOnly,
+ UseFileIOOnly
+ };
+ FileReaderClass m_fileReaderClass = FileReaderClass::UseFileIOIfAvailableFallbackToSystemFile;
};
//! Loads basic configuration files which have structures similar to Windows INI files
//! It is inspired by the Python configparser module: https://docs.python.org/3.10/library/configparser.html
diff --git a/Code/Framework/AzCore/AzCore/azcore_files.cmake b/Code/Framework/AzCore/AzCore/azcore_files.cmake
index 6c498c3335..aa07959997 100644
--- a/Code/Framework/AzCore/AzCore/azcore_files.cmake
+++ b/Code/Framework/AzCore/AzCore/azcore_files.cmake
@@ -166,6 +166,8 @@ set(FILES
IO/FileIO.cpp
IO/FileIO.h
IO/FileIOEventBus.h
+ IO/FileReader.cpp
+ IO/FileReader.h
IO/IOUtils.h
IO/IOUtils.cpp
IO/IStreamer.h
diff --git a/Code/Framework/AzCore/Tests/IO/FileReaderTests.cpp b/Code/Framework/AzCore/Tests/IO/FileReaderTests.cpp
new file mode 100644
index 0000000000..691b3f2821
--- /dev/null
+++ b/Code/Framework/AzCore/Tests/IO/FileReaderTests.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) Contributors to the Open 3D Engine Project.
+ * For complete copyright and license terms please see the LICENSE at the root of this distribution.
+ *
+ * SPDX-License-Identifier: Apache-2.0 OR MIT
+ *
+ */
+#include
+#include
+#include
+
+namespace UnitTest
+{
+ template
+ class FileReaderTestFixture
+ : public ScopedAllocatorSetupFixture
+ {
+ public:
+ void SetUp() override
+ {
+ if constexpr (AZStd::is_same_v)
+ {
+ m_fileIo = AZStd::make_unique();
+ }
+ }
+
+ void TearDown() override
+ {
+ m_fileIo.reset();
+ }
+
+ protected:
+ AZStd::unique_ptr m_fileIo{};
+ };
+
+ using FileIOTypes = ::testing::Types;
+
+ TYPED_TEST_CASE(FileReaderTestFixture, FileIOTypes);
+
+ TYPED_TEST(FileReaderTestFixture, ConstructorWithFilePath_OpensFileSuccessfully)
+ {
+ AZ::IO::FileReader fileReader(this->m_fileIo.get(), AZ::IO::SystemFile::GetNullFilename());
+ EXPECT_TRUE(fileReader.IsOpen());
+ }
+
+ TYPED_TEST(FileReaderTestFixture, Open_OpensFileSucessfully)
+ {
+ AZ::IO::FileReader fileReader;
+ fileReader.Open(this->m_fileIo.get(), AZ::IO::SystemFile::GetNullFilename());
+ EXPECT_TRUE(fileReader.IsOpen());
+ }
+
+ TYPED_TEST(FileReaderTestFixture, Eof_OnNULDeviceFile_Succeeds)
+ {
+ AZ::IO::FileReader fileReader(this->m_fileIo.get(), AZ::IO::SystemFile::GetNullFilename());
+ EXPECT_TRUE(fileReader.Eof());
+ }
+
+ TYPED_TEST(FileReaderTestFixture, GetFilePath_ReturnsNULDeviceFilename_Succeeds)
+ {
+ AZ::IO::FileReader fileReader(this->m_fileIo.get(), AZ::IO::SystemFile::GetNullFilename());
+ AZ::IO::FixedMaxPath filePath;
+ EXPECT_TRUE(fileReader.GetFilePath(filePath));
+ AZ::IO::FixedMaxPath nulFilename{ AZ::IO::SystemFile::GetNullFilename() };
+ if (this->m_fileIo)
+ {
+ EXPECT_TRUE(this->m_fileIo->ResolvePath(nulFilename, nulFilename));
+ }
+ EXPECT_EQ(nulFilename, filePath);
+ }
+
+} // namespace UnitTest
diff --git a/Code/Framework/AzCore/Tests/azcoretests_files.cmake b/Code/Framework/AzCore/Tests/azcoretests_files.cmake
index d4d107f094..c36d37d874 100644
--- a/Code/Framework/AzCore/Tests/azcoretests_files.cmake
+++ b/Code/Framework/AzCore/Tests/azcoretests_files.cmake
@@ -37,6 +37,7 @@ set(FILES
FileIOBaseTestTypes.h
Geometry2DUtils.cpp
Interface.cpp
+ IO/FileReaderTests.cpp
IO/Path/PathTests.cpp
IPC.cpp
Jobs.cpp
diff --git a/Code/Framework/AzFramework/AzFramework/Entity/GameEntityContextBus.h b/Code/Framework/AzFramework/AzFramework/Entity/GameEntityContextBus.h
index b5ca37df6e..f8e4dfa98b 100644
--- a/Code/Framework/AzFramework/AzFramework/Entity/GameEntityContextBus.h
+++ b/Code/Framework/AzFramework/AzFramework/Entity/GameEntityContextBus.h
@@ -91,15 +91,6 @@ namespace AzFramework
*/
virtual void DestroyGameEntity(const AZ::EntityId& /*id*/) = 0;
- /**
- * Destroys an entity only in slice mode (when prefabs are disabled). This request is only added as a stop-gap solution
- * to prevent the editor from crashing when prefabs are enabled and must only be called through the BehaviorContext binding
- * for 'DestroyGameEntity'. No code should be written to directly call this method. This will be removed soon.
- *
- * @param id The ID of the entity to destroy.
- */
- virtual void DestroyGameEntityOnlyInSliceMode(const AZ::EntityId& /*id*/) = 0;
-
/**
* Destroys an entity and all of its descendants.
* The entity and its descendants are immediately deactivated and will be
@@ -108,15 +99,6 @@ namespace AzFramework
*/
virtual void DestroyGameEntityAndDescendants(const AZ::EntityId& /*id*/) = 0;
- /**
- * Destroys an entity and its descendants only in slice mode (when prefabs are disabled). This request is only added as a stop-gap
- * solution to prevent the editor from crashing when prefabs are enabled and must only be called through the BehaviorContext
- * binding for 'DestroyGameEntityAndDescendants'.No code should be written to directly call this method. This will be removed soon.
- *
- * @param id The ID of the entity to destroy.
- */
- virtual void DestroyGameEntityAndDescendantsOnlyInSliceMode(const AZ::EntityId& /*id*/) = 0;
-
/**
* Activates the game entity.
* @param id The ID of the entity to activate.
diff --git a/Code/Framework/AzFramework/AzFramework/Entity/GameEntityContextComponent.cpp b/Code/Framework/AzFramework/AzFramework/Entity/GameEntityContextComponent.cpp
index a97281b9c1..aa7e03577a 100644
--- a/Code/Framework/AzFramework/AzFramework/Entity/GameEntityContextComponent.cpp
+++ b/Code/Framework/AzFramework/AzFramework/Entity/GameEntityContextComponent.cpp
@@ -11,9 +11,10 @@
#include
#include
#include
+#include
#include
#include
-#include
+#include
#include "GameEntityContextComponent.h"
@@ -47,9 +48,9 @@ namespace AzFramework
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
->Event("CreateGameEntity", &GameEntityContextRequestBus::Events::CreateGameEntityForBehaviorContext)
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
- ->Event("DestroyGameEntity", &GameEntityContextRequestBus::Events::DestroyGameEntityOnlyInSliceMode)
+ ->Event("DestroyGameEntity", &GameEntityContextRequestBus::Events::DestroyGameEntity)
->Event(
- "DestroyGameEntityAndDescendants", &GameEntityContextRequestBus::Events::DestroyGameEntityAndDescendantsOnlyInSliceMode)
+ "DestroyGameEntityAndDescendants", &GameEntityContextRequestBus::Events::DestroyGameEntityAndDescendants)
->Event("ActivateGameEntity", &GameEntityContextRequestBus::Events::ActivateGameEntity)
->Event("DeactivateGameEntity", &GameEntityContextRequestBus::Events::DeactivateGameEntity)
->Attribute(AZ::ScriptCanvasAttributes::DeactivatesInputEntity, true)
@@ -249,23 +250,6 @@ namespace AzFramework
DestroyGameEntityInternal(id, false);
}
- void GameEntityContextComponent::DestroyGameEntityOnlyInSliceMode(const AZ::EntityId& id)
- {
- bool isPrefabSystemEnabled = false;
- AzFramework::ApplicationRequests::Bus::BroadcastResult(
- isPrefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
- if (!isPrefabSystemEnabled)
- {
- DestroyGameEntityInternal(id, false);
- }
- else
- {
- AZ_Error(
- "GameEntityContextComponent", false,
- "Destroying a game entity is temporarily disabled until the Spawnable system can support this.");
- }
- }
-
//=========================================================================
// GameEntityContextComponent::DestroyGameEntityAndDescendantsById
//=========================================================================
@@ -274,24 +258,6 @@ namespace AzFramework
DestroyGameEntityInternal(id, true);
}
-
- void GameEntityContextComponent::DestroyGameEntityAndDescendantsOnlyInSliceMode(const AZ::EntityId& id)
- {
- bool isPrefabSystemEnabled = false;
- AzFramework::ApplicationRequests::Bus::BroadcastResult(
- isPrefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
- if (!isPrefabSystemEnabled)
- {
- DestroyGameEntityInternal(id, true);
- }
- else
- {
- AZ_Error(
- "GameEntityContextComponent", false,
- "Destroying a game entity and its descendants is temporarily disabled until the Spawnable system can support this.");
- }
- }
-
//=========================================================================
// GameEntityContextComponent::DestroyGameEntityInternal
//=========================================================================
@@ -319,6 +285,28 @@ namespace AzFramework
EBUS_EVENT_RESULT(currentEntity, AZ::ComponentApplicationBus, FindEntity, *entityIdIter);
if (currentEntity)
{
+ bool isPrefabSystemEnabled = false;
+ AzFramework::ApplicationRequests::Bus::BroadcastResult(
+ isPrefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
+ if (isPrefabSystemEnabled)
+ {
+ if (currentEntity->GetSpawnTicketId() > 0)
+ {
+ SpawnableEntitiesDefinition* spawnableEntitiesInterface = SpawnableEntitiesInterface::Get();
+ AZ_Assert(spawnableEntitiesInterface != nullptr, "SpawnableEntitiesInterface is not found.");
+ spawnableEntitiesInterface->RetrieveEntitySpawnTicket(
+ currentEntity->GetSpawnTicketId(),
+ [spawnableEntitiesInterface, currentEntity](EntitySpawnTicket* entitySpawnTicket)
+ {
+ if (entitySpawnTicket != nullptr)
+ {
+ spawnableEntitiesInterface->DespawnEntity(currentEntity->GetId(), *entitySpawnTicket);
+ }
+ });
+ return;
+ }
+ }
+
if (currentEntity->GetState() == AZ::Entity::State::Active)
{
// Deactivate the entity, we'll destroy it as soon as it is safe.
diff --git a/Code/Framework/AzFramework/AzFramework/Entity/GameEntityContextComponent.h b/Code/Framework/AzFramework/AzFramework/Entity/GameEntityContextComponent.h
index b9a4ea0da1..f837bed14e 100644
--- a/Code/Framework/AzFramework/AzFramework/Entity/GameEntityContextComponent.h
+++ b/Code/Framework/AzFramework/AzFramework/Entity/GameEntityContextComponent.h
@@ -90,11 +90,6 @@ namespace AzFramework
}
private:
- //////////////////////////////////////////////////////////////////////////
- // GameEntityContextRequestBus
- void DestroyGameEntityOnlyInSliceMode(const AZ::EntityId&) override;
- void DestroyGameEntityAndDescendantsOnlyInSliceMode(const AZ::EntityId&) override;
- /////////////////////////////////////////////////////////////////////////
AzFramework::EntityVisibilityBoundsUnionSystem m_entityVisibilityBoundsUnionSystem;
};
diff --git a/Code/Framework/AzFramework/AzFramework/Input/Channels/InputChannelId.cpp b/Code/Framework/AzFramework/AzFramework/Input/Channels/InputChannelId.cpp
index cc6154f20c..496d89d767 100644
--- a/Code/Framework/AzFramework/AzFramework/Input/Channels/InputChannelId.cpp
+++ b/Code/Framework/AzFramework/AzFramework/Input/Channels/InputChannelId.cpp
@@ -28,34 +28,10 @@ namespace AzFramework
}
}
- ////////////////////////////////////////////////////////////////////////////////////////////////
- InputChannelId::InputChannelId(const char* name)
- : m_crc32(name)
- {
- memset(m_name, 0, AZ_ARRAY_SIZE(m_name));
- azstrncpy(m_name, NAME_BUFFER_SIZE, name, MAX_NAME_LENGTH);
- }
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- InputChannelId::InputChannelId(const InputChannelId& other)
- : m_crc32(other.m_crc32)
- {
- memset(m_name, 0, AZ_ARRAY_SIZE(m_name));
- azstrcpy(m_name, NAME_BUFFER_SIZE, other.m_name);
- }
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- InputChannelId& InputChannelId::operator=(const InputChannelId& other)
- {
- azstrcpy(m_name, NAME_BUFFER_SIZE, other.m_name);
- m_crc32 = other.m_crc32;
- return *this;
- }
-
////////////////////////////////////////////////////////////////////////////////////////////////
const char* InputChannelId::GetName() const
{
- return m_name;
+ return m_name.c_str();
}
////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/Code/Framework/AzFramework/AzFramework/Input/Channels/InputChannelId.h b/Code/Framework/AzFramework/AzFramework/Input/Channels/InputChannelId.h
index 5c1c58d6b1..a4d8ac83eb 100644
--- a/Code/Framework/AzFramework/AzFramework/Input/Channels/InputChannelId.h
+++ b/Code/Framework/AzFramework/AzFramework/Input/Channels/InputChannelId.h
@@ -11,6 +11,7 @@
#include
#include
#include
+#include
////////////////////////////////////////////////////////////////////////////////////////////////////
namespace AzFramework
@@ -22,8 +23,7 @@ namespace AzFramework
public:
////////////////////////////////////////////////////////////////////////////////////////////
// Constants
- static const int NAME_BUFFER_SIZE = 64;
- static const int MAX_NAME_LENGTH = NAME_BUFFER_SIZE - 1;
+ static constexpr int MAX_NAME_LENGTH = 64;
////////////////////////////////////////////////////////////////////////////////////////////
// Allocator
@@ -39,21 +39,28 @@ namespace AzFramework
////////////////////////////////////////////////////////////////////////////////////////////
//! Constructor
- //! \param[in] name Name of the input channel (will be truncated if exceeds MAX_NAME_LENGTH)
- explicit InputChannelId(const char* name = "");
+ //! \param[in] name Name of the input channel (will be ignored if exceeds MAX_NAME_LENGTH)
+ explicit constexpr InputChannelId(AZStd::string_view name = "")
+ : m_name(name)
+ , m_crc32(name)
+ {
+ }
- ////////////////////////////////////////////////////////////////////////////////////////////
- //! Copy constructor
- //! \param[in] other Another instance of the class to copy from
- InputChannelId(const InputChannelId& other);
-
- ////////////////////////////////////////////////////////////////////////////////////////////
- //! Copy assignment operator
- //! \param[in] other Another instance of the class to copy from
- InputChannelId& operator=(const InputChannelId& other);
-
- ////////////////////////////////////////////////////////////////////////////////////////////
- //! Default destructor
+ constexpr InputChannelId(const InputChannelId& other) = default;
+ constexpr InputChannelId(InputChannelId&& other) = default;
+ constexpr InputChannelId& operator=(const InputChannelId& other)
+ {
+ m_name = other.m_name;
+ m_crc32 = other.m_crc32;
+ return *this;
+ }
+ constexpr InputChannelId& operator=(InputChannelId&& other)
+ {
+ m_name = AZStd::move(other.m_name);
+ m_crc32 = AZStd::move(other.m_crc32);
+ other.m_crc32 = 0;
+ return *this;
+ }
~InputChannelId() = default;
////////////////////////////////////////////////////////////////////////////////////////////
@@ -77,7 +84,7 @@ namespace AzFramework
private:
////////////////////////////////////////////////////////////////////////////////////////////
// Variables
- char m_name[NAME_BUFFER_SIZE]; //!< Name of the input channel
+ AZStd::fixed_string m_name; //!< Name of the input channel
AZ::Crc32 m_crc32; //!< Crc32 of the input channel
};
} // namespace AzFramework
diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/Gamepad/InputDeviceGamepad.cpp b/Code/Framework/AzFramework/AzFramework/Input/Devices/Gamepad/InputDeviceGamepad.cpp
index 95886c6871..51aa008519 100644
--- a/Code/Framework/AzFramework/AzFramework/Input/Devices/Gamepad/InputDeviceGamepad.cpp
+++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/Gamepad/InputDeviceGamepad.cpp
@@ -28,91 +28,6 @@ namespace AzFramework
return (inputDeviceId.GetNameCrc32() == IdForIndex0.GetNameCrc32());
}
- ////////////////////////////////////////////////////////////////////////////////////////////////
- const InputChannelId InputDeviceGamepad::Button::A("gamepad_button_a");
- const InputChannelId InputDeviceGamepad::Button::B("gamepad_button_b");
- const InputChannelId InputDeviceGamepad::Button::X("gamepad_button_x");
- const InputChannelId InputDeviceGamepad::Button::Y("gamepad_button_y");
- const InputChannelId InputDeviceGamepad::Button::L1("gamepad_button_l1");
- const InputChannelId InputDeviceGamepad::Button::R1("gamepad_button_r1");
- const InputChannelId InputDeviceGamepad::Button::L3("gamepad_button_l3");
- const InputChannelId InputDeviceGamepad::Button::R3("gamepad_button_r3");
- const InputChannelId InputDeviceGamepad::Button::DU("gamepad_button_d_up");
- const InputChannelId InputDeviceGamepad::Button::DD("gamepad_button_d_down");
- const InputChannelId InputDeviceGamepad::Button::DL("gamepad_button_d_left");
- const InputChannelId InputDeviceGamepad::Button::DR("gamepad_button_d_right");
- const InputChannelId InputDeviceGamepad::Button::Start("gamepad_button_start");
- const InputChannelId InputDeviceGamepad::Button::Select("gamepad_button_select");
- const AZStd::array InputDeviceGamepad::Button::All =
- {{
- A,
- B,
- X,
- Y,
- L1,
- R1,
- L3,
- R3,
- DU,
- DD,
- DL,
- DR,
- Start,
- Select
- }};
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- const InputChannelId InputDeviceGamepad::Trigger::L2("gamepad_trigger_l2");
- const InputChannelId InputDeviceGamepad::Trigger::R2("gamepad_trigger_r2");
- const AZStd::array InputDeviceGamepad::Trigger::All =
- {{
- L2,
- R2
- }};
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- const InputChannelId InputDeviceGamepad::ThumbStickAxis2D::L("gamepad_thumbstick_l");
- const InputChannelId InputDeviceGamepad::ThumbStickAxis2D::R("gamepad_thumbstick_r");
- const AZStd::array InputDeviceGamepad::ThumbStickAxis2D::All =
- {{
- L,
- R
- }};
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- const InputChannelId InputDeviceGamepad::ThumbStickAxis1D::LX("gamepad_thumbstick_l_x");
- const InputChannelId InputDeviceGamepad::ThumbStickAxis1D::LY("gamepad_thumbstick_l_y");
- const InputChannelId InputDeviceGamepad::ThumbStickAxis1D::RX("gamepad_thumbstick_r_x");
- const InputChannelId InputDeviceGamepad::ThumbStickAxis1D::RY("gamepad_thumbstick_r_y");
- const AZStd::array InputDeviceGamepad::ThumbStickAxis1D::All =
- {{
- LX,
- LY,
- RX,
- RY
- }};
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- const InputChannelId InputDeviceGamepad::ThumbStickDirection::LU("gamepad_thumbstick_l_up");
- const InputChannelId InputDeviceGamepad::ThumbStickDirection::LD("gamepad_thumbstick_l_down");
- const InputChannelId InputDeviceGamepad::ThumbStickDirection::LL("gamepad_thumbstick_l_left");
- const InputChannelId InputDeviceGamepad::ThumbStickDirection::LR("gamepad_thumbstick_l_right");
- const InputChannelId InputDeviceGamepad::ThumbStickDirection::RU("gamepad_thumbstick_r_up");
- const InputChannelId InputDeviceGamepad::ThumbStickDirection::RD("gamepad_thumbstick_r_down");
- const InputChannelId InputDeviceGamepad::ThumbStickDirection::RL("gamepad_thumbstick_r_left");
- const InputChannelId InputDeviceGamepad::ThumbStickDirection::RR("gamepad_thumbstick_r_right");
- const AZStd::array InputDeviceGamepad::ThumbStickDirection::All =
- {{
- LU,
- LD,
- LL,
- LR,
- RU,
- RD,
- RL,
- RR
- }};
-
////////////////////////////////////////////////////////////////////////////////////////////////
void InputDeviceGamepad::Reflect(AZ::ReflectContext* context)
{
diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/Gamepad/InputDeviceGamepad.h b/Code/Framework/AzFramework/AzFramework/Input/Devices/Gamepad/InputDeviceGamepad.h
index f4fddbb24e..286b4f0df3 100644
--- a/Code/Framework/AzFramework/AzFramework/Input/Devices/Gamepad/InputDeviceGamepad.h
+++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/Gamepad/InputDeviceGamepad.h
@@ -59,75 +59,115 @@ namespace AzFramework
//! All the input channel ids that identify game-pad digital button input
struct Button
{
- static const InputChannelId A; //!< The bottom diamond face button
- static const InputChannelId B; //!< The right diamond face button
- static const InputChannelId X; //!< The left diamond face button
- static const InputChannelId Y; //!< The top diamond face button
- static const InputChannelId L1; //!< The top-left shoulder bumper button
- static const InputChannelId R1; //!< The top-right shoulder bumper button
- static const InputChannelId L3; //!< The left thumb-stick click button
- static const InputChannelId R3; //!< The right thumb-stick click button
- static const InputChannelId DU; //!< The up directional pad button
- static const InputChannelId DD; //!< The down directional pad button
- static const InputChannelId DL; //!< The left directional pad button
- static const InputChannelId DR; //!< The right directional pad button
- static const InputChannelId Start; //!< The start/pause/options button
- static const InputChannelId Select; //!< The select/back button
+ static constexpr inline InputChannelId A{"gamepad_button_a"}; //!< The bottom diamond face button
+ static constexpr inline InputChannelId B{"gamepad_button_b"}; //!< The right diamond face button
+ static constexpr inline InputChannelId X{"gamepad_button_x"}; //!< The left diamond face button
+ static constexpr inline InputChannelId Y{"gamepad_button_y"}; //!< The top diamond face button
+ static constexpr inline InputChannelId L1{"gamepad_button_l1"}; //!< The top-left shoulder bumper button
+ static constexpr inline InputChannelId R1{"gamepad_button_r1"}; //!< The top-right shoulder bumper button
+ static constexpr inline InputChannelId L3{"gamepad_button_l3"}; //!< The left thumb-stick click button
+ static constexpr inline InputChannelId R3{"gamepad_button_r3"}; //!< The right thumb-stick click button
+ static constexpr inline InputChannelId DU{"gamepad_button_d_up"}; //!< The up directional pad button
+ static constexpr inline InputChannelId DD{"gamepad_button_d_down"}; //!< The down directional pad button
+ static constexpr inline InputChannelId DL{"gamepad_button_d_left"}; //!< The left directional pad button
+ static constexpr inline InputChannelId DR{"gamepad_button_d_right"}; //!< The right directional pad button
+ static constexpr inline InputChannelId Start{"gamepad_button_start"}; //!< The start/pause/options button
+ static constexpr inline InputChannelId Select{"gamepad_button_select"}; //!< The select/back button
//!< All digital game-pad button ids
- static const AZStd::array All;
+ static constexpr inline AZStd::array All
+ {
+ A,
+ B,
+ X,
+ Y,
+ L1,
+ R1,
+ L3,
+ R3,
+ DU,
+ DD,
+ DL,
+ DR,
+ Start,
+ Select
+ };
};
////////////////////////////////////////////////////////////////////////////////////////////
//! All the input channel ids that identify game-pad analog trigger input
struct Trigger
{
- static const InputChannelId L2; //!< The bottom-left shoulder trigger
- static const InputChannelId R2; //!< The bottom-right shoulder trigger
+ static constexpr inline InputChannelId L2{"gamepad_trigger_l2"}; //!< The bottom-left shoulder trigger
+ static constexpr inline InputChannelId R2{"gamepad_trigger_r2"}; //!< The bottom-right shoulder trigger
//!< All analog game-pad trigger ids
- static const AZStd::array All;
+ static constexpr inline AZStd::array All
+ {
+ L2,
+ R2
+ };
};
////////////////////////////////////////////////////////////////////////////////////////////
//! All the input channel ids that identify game-pad thumb-stick 2D axis input
struct ThumbStickAxis2D
{
- static const InputChannelId L; //!< The left-hand thumb-stick
- static const InputChannelId R; //!< The right-hand thumb-stick
+ static constexpr inline InputChannelId L{"gamepad_thumbstick_l"}; //!< The left-hand thumb-stick
+ static constexpr inline InputChannelId R{"gamepad_thumbstick_r"}; //!< The right-hand thumb-stick
//!< All game-pad thumb-stick 2D axis input channel ids
- static const AZStd::array All;
+ static constexpr inline AZStd::array All
+ {
+ L,
+ R
+ };
};
////////////////////////////////////////////////////////////////////////////////////////////
//! All the input channel ids that identify game-pad thumb-stick 1D axis input
struct ThumbStickAxis1D
{
- static const InputChannelId LX; //!< X-axis of the left-hand thumb-stick
- static const InputChannelId LY; //!< Y-axis of the left-hand thumb-stick
- static const InputChannelId RX; //!< X-axis of the right-hand thumb-stick
- static const InputChannelId RY; //!< Y-axis of the right-hand thumb-stick
+ static constexpr inline InputChannelId LX{"gamepad_thumbstick_l_x"}; //!< X-axis of the left-hand thumb-stick
+ static constexpr inline InputChannelId LY{"gamepad_thumbstick_l_y"}; //!< Y-axis of the left-hand thumb-stick
+ static constexpr inline InputChannelId RX{"gamepad_thumbstick_r_x"}; //!< X-axis of the right-hand thumb-stick
+ static constexpr inline InputChannelId RY{"gamepad_thumbstick_r_y"}; //!< Y-axis of the right-hand thumb-stick
//!< All game-pad thumb-stick 1D axis input channel ids
- static const AZStd::array All;
+ static constexpr inline AZStd::array All
+ {
+ LX,
+ LY,
+ RX,
+ RY
+ };
};
////////////////////////////////////////////////////////////////////////////////////////////
//! All the input channel ids that identify game-pad thumb-stick directional input
struct ThumbStickDirection
{
- static const InputChannelId LU; //!< Up on the left-hand thumb-stick
- static const InputChannelId LD; //!< Down on the left-hand thumb-stick
- static const InputChannelId LL; //!< Left on the left-hand thumb-stick
- static const InputChannelId LR; //!< Right on the left-hand thumb-stick
- static const InputChannelId RU; //!< Up on the left-hand thumb-stick
- static const InputChannelId RD; //!< Down on the left-hand thumb-stick
- static const InputChannelId RL; //!< Left on the left-hand thumb-stick
- static const InputChannelId RR; //!< Right on the left-hand thumb-stick
+ static constexpr inline InputChannelId LU{"gamepad_thumbstick_l_up"}; //!< Up on the left-hand thumb-stick
+ static constexpr inline InputChannelId LD{"gamepad_thumbstick_l_down"}; //!< Down on the left-hand thumb-stick
+ static constexpr inline InputChannelId LL{"gamepad_thumbstick_l_left"}; //!< Left on the left-hand thumb-stick
+ static constexpr inline InputChannelId LR{"gamepad_thumbstick_l_right"}; //!< Right on the left-hand thumb-stick
+ static constexpr inline InputChannelId RU{"gamepad_thumbstick_r_up"}; //!< Up on the left-hand thumb-stick
+ static constexpr inline InputChannelId RD{"gamepad_thumbstick_r_down"}; //!< Down on the left-hand thumb-stick
+ static constexpr inline InputChannelId RL{"gamepad_thumbstick_r_left"}; //!< Left on the left-hand thumb-stick
+ static constexpr inline InputChannelId RR{"gamepad_thumbstick_r_right"}; //!< Right on the left-hand thumb-stick
//!< All game-pad thumb-stick directional input channel ids
- static const AZStd::array All;
+ static constexpr inline AZStd::array All
+ {
+ LU,
+ LD,
+ LL,
+ LR,
+ RU,
+ RD,
+ RL,
+ RR
+ };
};
////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.cpp b/Code/Framework/AzFramework/AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.cpp
index dd84fd9633..d1117ea895 100644
--- a/Code/Framework/AzFramework/AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.cpp
+++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.cpp
@@ -24,279 +24,6 @@ namespace AzFramework
return (inputDeviceId.GetNameCrc32() == Id.GetNameCrc32());
}
- ////////////////////////////////////////////////////////////////////////////////////////////////
- // Alphanumeric Keys
- const InputChannelId InputDeviceKeyboard::Key::Alphanumeric0("keyboard_key_alphanumeric_0");
- const InputChannelId InputDeviceKeyboard::Key::Alphanumeric1("keyboard_key_alphanumeric_1");
- const InputChannelId InputDeviceKeyboard::Key::Alphanumeric2("keyboard_key_alphanumeric_2");
- const InputChannelId InputDeviceKeyboard::Key::Alphanumeric3("keyboard_key_alphanumeric_3");
- const InputChannelId InputDeviceKeyboard::Key::Alphanumeric4("keyboard_key_alphanumeric_4");
- const InputChannelId InputDeviceKeyboard::Key::Alphanumeric5("keyboard_key_alphanumeric_5");
- const InputChannelId InputDeviceKeyboard::Key::Alphanumeric6("keyboard_key_alphanumeric_6");
- const InputChannelId InputDeviceKeyboard::Key::Alphanumeric7("keyboard_key_alphanumeric_7");
- const InputChannelId InputDeviceKeyboard::Key::Alphanumeric8("keyboard_key_alphanumeric_8");
- const InputChannelId InputDeviceKeyboard::Key::Alphanumeric9("keyboard_key_alphanumeric_9");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericA("keyboard_key_alphanumeric_A");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericB("keyboard_key_alphanumeric_B");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericC("keyboard_key_alphanumeric_C");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericD("keyboard_key_alphanumeric_D");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericE("keyboard_key_alphanumeric_E");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericF("keyboard_key_alphanumeric_F");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericG("keyboard_key_alphanumeric_G");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericH("keyboard_key_alphanumeric_H");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericI("keyboard_key_alphanumeric_I");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericJ("keyboard_key_alphanumeric_J");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericK("keyboard_key_alphanumeric_K");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericL("keyboard_key_alphanumeric_L");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericM("keyboard_key_alphanumeric_M");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericN("keyboard_key_alphanumeric_N");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericO("keyboard_key_alphanumeric_O");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericP("keyboard_key_alphanumeric_P");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericQ("keyboard_key_alphanumeric_Q");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericR("keyboard_key_alphanumeric_R");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericS("keyboard_key_alphanumeric_S");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericT("keyboard_key_alphanumeric_T");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericU("keyboard_key_alphanumeric_U");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericV("keyboard_key_alphanumeric_V");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericW("keyboard_key_alphanumeric_W");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericX("keyboard_key_alphanumeric_X");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericY("keyboard_key_alphanumeric_Y");
- const InputChannelId InputDeviceKeyboard::Key::AlphanumericZ("keyboard_key_alphanumeric_Z");
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- // Edit (and escape) Keys
- const InputChannelId InputDeviceKeyboard::Key::EditBackspace("keyboard_key_edit_backspace");
- const InputChannelId InputDeviceKeyboard::Key::EditCapsLock("keyboard_key_edit_capslock");
- const InputChannelId InputDeviceKeyboard::Key::EditEnter("keyboard_key_edit_enter");
- const InputChannelId InputDeviceKeyboard::Key::EditSpace("keyboard_key_edit_space");
- const InputChannelId InputDeviceKeyboard::Key::EditTab("keyboard_key_edit_tab");
- const InputChannelId InputDeviceKeyboard::Key::Escape("keyboard_key_escape");
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- // Function Keys
- const InputChannelId InputDeviceKeyboard::Key::Function01("keyboard_key_function_F01");
- const InputChannelId InputDeviceKeyboard::Key::Function02("keyboard_key_function_F02");
- const InputChannelId InputDeviceKeyboard::Key::Function03("keyboard_key_function_F03");
- const InputChannelId InputDeviceKeyboard::Key::Function04("keyboard_key_function_F04");
- const InputChannelId InputDeviceKeyboard::Key::Function05("keyboard_key_function_F05");
- const InputChannelId InputDeviceKeyboard::Key::Function06("keyboard_key_function_F06");
- const InputChannelId InputDeviceKeyboard::Key::Function07("keyboard_key_function_F07");
- const InputChannelId InputDeviceKeyboard::Key::Function08("keyboard_key_function_F08");
- const InputChannelId InputDeviceKeyboard::Key::Function09("keyboard_key_function_F09");
- const InputChannelId InputDeviceKeyboard::Key::Function10("keyboard_key_function_F10");
- const InputChannelId InputDeviceKeyboard::Key::Function11("keyboard_key_function_F11");
- const InputChannelId InputDeviceKeyboard::Key::Function12("keyboard_key_function_F12");
- const InputChannelId InputDeviceKeyboard::Key::Function13("keyboard_key_function_F13");
- const InputChannelId InputDeviceKeyboard::Key::Function14("keyboard_key_function_F14");
- const InputChannelId InputDeviceKeyboard::Key::Function15("keyboard_key_function_F15");
- const InputChannelId InputDeviceKeyboard::Key::Function16("keyboard_key_function_F16");
- const InputChannelId InputDeviceKeyboard::Key::Function17("keyboard_key_function_F17");
- const InputChannelId InputDeviceKeyboard::Key::Function18("keyboard_key_function_F18");
- const InputChannelId InputDeviceKeyboard::Key::Function19("keyboard_key_function_F19");
- const InputChannelId InputDeviceKeyboard::Key::Function20("keyboard_key_function_F20");
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- // Modifier Keys
- const InputChannelId InputDeviceKeyboard::Key::ModifierAltL("keyboard_key_modifier_alt_l");
- const InputChannelId InputDeviceKeyboard::Key::ModifierAltR("keyboard_key_modifier_alt_r");
- const InputChannelId InputDeviceKeyboard::Key::ModifierCtrlL("keyboard_key_modifier_ctrl_l");
- const InputChannelId InputDeviceKeyboard::Key::ModifierCtrlR("keyboard_key_modifier_ctrl_r");
- const InputChannelId InputDeviceKeyboard::Key::ModifierShiftL("keyboard_key_modifier_shift_l");
- const InputChannelId InputDeviceKeyboard::Key::ModifierShiftR("keyboard_key_modifier_shift_r");
- const InputChannelId InputDeviceKeyboard::Key::ModifierSuperL("keyboard_key_modifier_super_l");
- const InputChannelId InputDeviceKeyboard::Key::ModifierSuperR("keyboard_key_modifier_super_r");
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- // Navigation Keys
- const InputChannelId InputDeviceKeyboard::Key::NavigationArrowDown("keyboard_key_navigation_arrow_down");
- const InputChannelId InputDeviceKeyboard::Key::NavigationArrowLeft("keyboard_key_navigation_arrow_left");
- const InputChannelId InputDeviceKeyboard::Key::NavigationArrowRight("keyboard_key_navigation_arrow_right");
- const InputChannelId InputDeviceKeyboard::Key::NavigationArrowUp("keyboard_key_navigation_arrow_up");
- const InputChannelId InputDeviceKeyboard::Key::NavigationDelete("keyboard_key_navigation_delete");
- const InputChannelId InputDeviceKeyboard::Key::NavigationEnd("keyboard_key_navigation_end");
- const InputChannelId InputDeviceKeyboard::Key::NavigationHome("keyboard_key_navigation_home");
- const InputChannelId InputDeviceKeyboard::Key::NavigationInsert("keyboard_key_navigation_insert");
- const InputChannelId InputDeviceKeyboard::Key::NavigationPageDown("keyboard_key_navigation_page_down");
- const InputChannelId InputDeviceKeyboard::Key::NavigationPageUp("keyboard_key_navigation_page_up");
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- // Numpad Keys
- const InputChannelId InputDeviceKeyboard::Key::NumLock("keyboard_key_num_lock");
- const InputChannelId InputDeviceKeyboard::Key::NumPad0("keyboard_key_numpad_0");
- const InputChannelId InputDeviceKeyboard::Key::NumPad1("keyboard_key_numpad_1");
- const InputChannelId InputDeviceKeyboard::Key::NumPad2("keyboard_key_numpad_2");
- const InputChannelId InputDeviceKeyboard::Key::NumPad3("keyboard_key_numpad_3");
- const InputChannelId InputDeviceKeyboard::Key::NumPad4("keyboard_key_numpad_4");
- const InputChannelId InputDeviceKeyboard::Key::NumPad5("keyboard_key_numpad_5");
- const InputChannelId InputDeviceKeyboard::Key::NumPad6("keyboard_key_numpad_6");
- const InputChannelId InputDeviceKeyboard::Key::NumPad7("keyboard_key_numpad_7");
- const InputChannelId InputDeviceKeyboard::Key::NumPad8("keyboard_key_numpad_8");
- const InputChannelId InputDeviceKeyboard::Key::NumPad9("keyboard_key_numpad_9");
- const InputChannelId InputDeviceKeyboard::Key::NumPadAdd("keyboard_key_numpad_add");
- const InputChannelId InputDeviceKeyboard::Key::NumPadDecimal("keyboard_key_numpad_decimal");
- const InputChannelId InputDeviceKeyboard::Key::NumPadDivide("keyboard_key_numpad_divide");
- const InputChannelId InputDeviceKeyboard::Key::NumPadEnter("keyboard_key_numpad_enter");
- const InputChannelId InputDeviceKeyboard::Key::NumPadMultiply("keyboard_key_numpad_multiply");
- const InputChannelId InputDeviceKeyboard::Key::NumPadSubtract("keyboard_key_numpad_subtract");
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- // Punctuation Keys
- const InputChannelId InputDeviceKeyboard::Key::PunctuationApostrophe("keyboard_key_punctuation_apostrophe");
- const InputChannelId InputDeviceKeyboard::Key::PunctuationBackslash("keyboard_key_punctuation_backslash");
- const InputChannelId InputDeviceKeyboard::Key::PunctuationBracketL("keyboard_key_punctuation_bracket_l");
- const InputChannelId InputDeviceKeyboard::Key::PunctuationBracketR("keyboard_key_punctuation_bracket_r");
- const InputChannelId InputDeviceKeyboard::Key::PunctuationComma("keyboard_key_punctuation_comma");
- const InputChannelId InputDeviceKeyboard::Key::PunctuationEquals("keyboard_key_punctuation_equals");
- const InputChannelId InputDeviceKeyboard::Key::PunctuationHyphen("keyboard_key_punctuation_hyphen");
- const InputChannelId InputDeviceKeyboard::Key::PunctuationPeriod("keyboard_key_punctuation_period");
- const InputChannelId InputDeviceKeyboard::Key::PunctuationSemicolon("keyboard_key_punctuation_semicolon");
- const InputChannelId InputDeviceKeyboard::Key::PunctuationSlash("keyboard_key_punctuation_slash");
- const InputChannelId InputDeviceKeyboard::Key::PunctuationTilde("keyboard_key_punctuation_tilde");
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- // Supplementary ISO Key
- const InputChannelId InputDeviceKeyboard::Key::SupplementaryISO("keyboard_key_supplementary_iso");
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- // Windows System Keys
- const InputChannelId InputDeviceKeyboard::Key::WindowsSystemPause("keyboard_key_windows_system_pause");
- const InputChannelId InputDeviceKeyboard::Key::WindowsSystemPrint("keyboard_key_windows_system_print");
- const InputChannelId InputDeviceKeyboard::Key::WindowsSystemScrollLock("keyboard_key_windows_system_scroll_lock");
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- const AZStd::array InputDeviceKeyboard::Key::All =
- {{
- // Alphanumeric Keys
- Alphanumeric0,
- Alphanumeric1,
- Alphanumeric2,
- Alphanumeric3,
- Alphanumeric4,
- Alphanumeric5,
- Alphanumeric6,
- Alphanumeric7,
- Alphanumeric8,
- Alphanumeric9,
- AlphanumericA,
- AlphanumericB,
- AlphanumericC,
- AlphanumericD,
- AlphanumericE,
- AlphanumericF,
- AlphanumericG,
- AlphanumericH,
- AlphanumericI,
- AlphanumericJ,
- AlphanumericK,
- AlphanumericL,
- AlphanumericM,
- AlphanumericN,
- AlphanumericO,
- AlphanumericP,
- AlphanumericQ,
- AlphanumericR,
- AlphanumericS,
- AlphanumericT,
- AlphanumericU,
- AlphanumericV,
- AlphanumericW,
- AlphanumericX,
- AlphanumericY,
- AlphanumericZ,
-
- // Edit (and escape) Keys
- EditBackspace,
- EditCapsLock,
- EditEnter,
- EditSpace,
- EditTab,
- Escape,
-
- // Function Keys
- Function01,
- Function02,
- Function03,
- Function04,
- Function05,
- Function06,
- Function07,
- Function08,
- Function09,
- Function10,
- Function11,
- Function12,
- Function13,
- Function14,
- Function15,
- Function16,
- Function17,
- Function18,
- Function19,
- Function20,
-
- // Modifier Keys
- ModifierAltL,
- ModifierAltR,
- ModifierCtrlL,
- ModifierCtrlR,
- ModifierShiftL,
- ModifierShiftR,
- ModifierSuperL,
- ModifierSuperR,
-
- // Navigation Keys
- NavigationArrowDown,
- NavigationArrowLeft,
- NavigationArrowRight,
- NavigationArrowUp,
- NavigationDelete,
- NavigationEnd,
- NavigationHome,
- NavigationInsert,
- NavigationPageDown,
- NavigationPageUp,
-
- // Numpad Keys
- NumLock,
- NumPad0,
- NumPad1,
- NumPad2,
- NumPad3,
- NumPad4,
- NumPad5,
- NumPad6,
- NumPad7,
- NumPad8,
- NumPad9,
- NumPadAdd,
- NumPadDecimal,
- NumPadDivide,
- NumPadEnter,
- NumPadMultiply,
- NumPadSubtract,
-
- // Punctuation Keys
- PunctuationApostrophe,
- PunctuationBackslash,
- PunctuationBracketL,
- PunctuationBracketR,
- PunctuationComma,
- PunctuationEquals,
- PunctuationHyphen,
- PunctuationPeriod,
- PunctuationSemicolon,
- PunctuationSlash,
- PunctuationTilde,
-
- // Supplementary ISO Key
- SupplementaryISO,
-
- // Windows System Keys
- WindowsSystemPause,
- WindowsSystemPrint,
- WindowsSystemScrollLock
- }};
-
////////////////////////////////////////////////////////////////////////////////////////////////
ModifierKeyMask GetCorrespondingModifierKeyMask(const InputChannelId& channelId)
{
diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h b/Code/Framework/AzFramework/AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h
index 5588f94d69..e3c21ec326 100644
--- a/Code/Framework/AzFramework/AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h
+++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h
@@ -94,137 +94,268 @@ namespace AzFramework
struct Key
{
// Alphanumeric Keys
- static const InputChannelId Alphanumeric0; //!< The 0 key
- static const InputChannelId Alphanumeric1; //!< The 1 key
- static const InputChannelId Alphanumeric2; //!< The 2 key
- static const InputChannelId Alphanumeric3; //!< The 3 key
- static const InputChannelId Alphanumeric4; //!< The 4 key
- static const InputChannelId Alphanumeric5; //!< The 5 key
- static const InputChannelId Alphanumeric6; //!< The 6 key
- static const InputChannelId Alphanumeric7; //!< The 7 key
- static const InputChannelId Alphanumeric8; //!< The 8 key
- static const InputChannelId Alphanumeric9; //!< The 9 key
- static const InputChannelId AlphanumericA; //!< The A key
- static const InputChannelId AlphanumericB; //!< The B key
- static const InputChannelId AlphanumericC; //!< The C key
- static const InputChannelId AlphanumericD; //!< The D key
- static const InputChannelId AlphanumericE; //!< The E key
- static const InputChannelId AlphanumericF; //!< The F key
- static const InputChannelId AlphanumericG; //!< The G key
- static const InputChannelId AlphanumericH; //!< The H key
- static const InputChannelId AlphanumericI; //!< The I key
- static const InputChannelId AlphanumericJ; //!< The J key
- static const InputChannelId AlphanumericK; //!< The K key
- static const InputChannelId AlphanumericL; //!< The L key
- static const InputChannelId AlphanumericM; //!< The M key
- static const InputChannelId AlphanumericN; //!< The N key
- static const InputChannelId AlphanumericO; //!< The O key
- static const InputChannelId AlphanumericP; //!< The P key
- static const InputChannelId AlphanumericQ; //!< The Q key
- static const InputChannelId AlphanumericR; //!< The R key
- static const InputChannelId AlphanumericS; //!< The S key
- static const InputChannelId AlphanumericT; //!< The T key
- static const InputChannelId AlphanumericU; //!< The U key
- static const InputChannelId AlphanumericV; //!< The V key
- static const InputChannelId AlphanumericW; //!< The W key
- static const InputChannelId AlphanumericX; //!< The X key
- static const InputChannelId AlphanumericY; //!< The Y key
- static const InputChannelId AlphanumericZ; //!< The Z key
+ static constexpr inline InputChannelId Alphanumeric0{"keyboard_key_alphanumeric_0"}; //!< The 0 key
+ static constexpr inline InputChannelId Alphanumeric1{"keyboard_key_alphanumeric_1"}; //!< The 1 key
+ static constexpr inline InputChannelId Alphanumeric2{"keyboard_key_alphanumeric_2"}; //!< The 2 key
+ static constexpr inline InputChannelId Alphanumeric3{"keyboard_key_alphanumeric_3"}; //!< The 3 key
+ static constexpr inline InputChannelId Alphanumeric4{"keyboard_key_alphanumeric_4"}; //!< The 4 key
+ static constexpr inline InputChannelId Alphanumeric5{"keyboard_key_alphanumeric_5"}; //!< The 5 key
+ static constexpr inline InputChannelId Alphanumeric6{"keyboard_key_alphanumeric_6"}; //!< The 6 key
+ static constexpr inline InputChannelId Alphanumeric7{"keyboard_key_alphanumeric_7"}; //!< The 7 key
+ static constexpr inline InputChannelId Alphanumeric8{"keyboard_key_alphanumeric_8"}; //!< The 8 key
+ static constexpr inline InputChannelId Alphanumeric9{"keyboard_key_alphanumeric_9"}; //!< The 9 key
+ static constexpr inline InputChannelId AlphanumericA{"keyboard_key_alphanumeric_A"}; //!< The A key
+ static constexpr inline InputChannelId AlphanumericB{"keyboard_key_alphanumeric_B"}; //!< The B key
+ static constexpr inline InputChannelId AlphanumericC{"keyboard_key_alphanumeric_C"}; //!< The C key
+ static constexpr inline InputChannelId AlphanumericD{"keyboard_key_alphanumeric_D"}; //!< The D key
+ static constexpr inline InputChannelId AlphanumericE{"keyboard_key_alphanumeric_E"}; //!< The E key
+ static constexpr inline InputChannelId AlphanumericF{"keyboard_key_alphanumeric_F"}; //!< The F key
+ static constexpr inline InputChannelId AlphanumericG{"keyboard_key_alphanumeric_G"}; //!< The G key
+ static constexpr inline InputChannelId AlphanumericH{"keyboard_key_alphanumeric_H"}; //!< The H key
+ static constexpr inline InputChannelId AlphanumericI{"keyboard_key_alphanumeric_I"}; //!< The I key
+ static constexpr inline InputChannelId AlphanumericJ{"keyboard_key_alphanumeric_J"}; //!< The J key
+ static constexpr inline InputChannelId AlphanumericK{"keyboard_key_alphanumeric_K"}; //!< The K key
+ static constexpr inline InputChannelId AlphanumericL{"keyboard_key_alphanumeric_L"}; //!< The L key
+ static constexpr inline InputChannelId AlphanumericM{"keyboard_key_alphanumeric_M"}; //!< The M key
+ static constexpr inline InputChannelId AlphanumericN{"keyboard_key_alphanumeric_N"}; //!< The N key
+ static constexpr inline InputChannelId AlphanumericO{"keyboard_key_alphanumeric_O"}; //!< The O key
+ static constexpr inline InputChannelId AlphanumericP{"keyboard_key_alphanumeric_P"}; //!< The P key
+ static constexpr inline InputChannelId AlphanumericQ{"keyboard_key_alphanumeric_Q"}; //!< The Q key
+ static constexpr inline InputChannelId AlphanumericR{"keyboard_key_alphanumeric_R"}; //!< The R key
+ static constexpr inline InputChannelId AlphanumericS{"keyboard_key_alphanumeric_S"}; //!< The S key
+ static constexpr inline InputChannelId AlphanumericT{"keyboard_key_alphanumeric_T"}; //!< The T key
+ static constexpr inline InputChannelId AlphanumericU{"keyboard_key_alphanumeric_U"}; //!< The U key
+ static constexpr inline InputChannelId AlphanumericV{"keyboard_key_alphanumeric_V"}; //!< The V key
+ static constexpr inline InputChannelId AlphanumericW{"keyboard_key_alphanumeric_W"}; //!< The W key
+ static constexpr inline InputChannelId AlphanumericX{"keyboard_key_alphanumeric_X"}; //!< The X key
+ static constexpr inline InputChannelId AlphanumericY{"keyboard_key_alphanumeric_Y"}; //!< The Y key
+ static constexpr inline InputChannelId AlphanumericZ{"keyboard_key_alphanumeric_Z"}; //!< The Z key
- // Edit (and escape) Keys
- static const InputChannelId EditBackspace; //!< The backspace key
- static const InputChannelId EditCapsLock; //!< The caps lock key
- static const InputChannelId EditEnter; //!< The enter/return key
- static const InputChannelId EditSpace; //!< The spacebar key
- static const InputChannelId EditTab; //!< The tab key
- static const InputChannelId Escape; //!< The escape key
+ // Edit {and escape} Keys
+ static constexpr inline InputChannelId EditBackspace{"keyboard_key_edit_backspace"}; //!< The backspace key
+ static constexpr inline InputChannelId EditCapsLock{"keyboard_key_edit_capslock"}; //!< The caps lock key
+ static constexpr inline InputChannelId EditEnter{"keyboard_key_edit_enter"}; //!< The enter/return key
+ static constexpr inline InputChannelId EditSpace{"keyboard_key_edit_space"}; //!< The spacebar key
+ static constexpr inline InputChannelId EditTab{"keyboard_key_edit_tab"}; //!< The tab key
+ static constexpr inline InputChannelId Escape{"keyboard_key_escape"}; //!< The escape key
// Function Keys
- static const InputChannelId Function01; //!< The F1 key
- static const InputChannelId Function02; //!< The F2 key
- static const InputChannelId Function03; //!< The F3 key
- static const InputChannelId Function04; //!< The F4 key
- static const InputChannelId Function05; //!< The F5 key
- static const InputChannelId Function06; //!< The F6 key
- static const InputChannelId Function07; //!< The F7 key
- static const InputChannelId Function08; //!< The F8 key
- static const InputChannelId Function09; //!< The F9 key
- static const InputChannelId Function10; //!< The F10 key
- static const InputChannelId Function11; //!< The F11 key
- static const InputChannelId Function12; //!< The F12 key
- static const InputChannelId Function13; //!< The F13 key
- static const InputChannelId Function14; //!< The F14 key
- static const InputChannelId Function15; //!< The F15 key
- static const InputChannelId Function16; //!< The F16 key
- static const InputChannelId Function17; //!< The F17 key
- static const InputChannelId Function18; //!< The F18 key
- static const InputChannelId Function19; //!< The F19 key
- static const InputChannelId Function20; //!< The F20 key
+ static constexpr inline InputChannelId Function01{"keyboard_key_function_F01"}; //!< The F1 key
+ static constexpr inline InputChannelId Function02{"keyboard_key_function_F02"}; //!< The F2 key
+ static constexpr inline InputChannelId Function03{"keyboard_key_function_F03"}; //!< The F3 key
+ static constexpr inline InputChannelId Function04{"keyboard_key_function_F04"}; //!< The F4 key
+ static constexpr inline InputChannelId Function05{"keyboard_key_function_F05"}; //!< The F5 key
+ static constexpr inline InputChannelId Function06{"keyboard_key_function_F06"}; //!< The F6 key
+ static constexpr inline InputChannelId Function07{"keyboard_key_function_F07"}; //!< The F7 key
+ static constexpr inline InputChannelId Function08{"keyboard_key_function_F08"}; //!< The F8 key
+ static constexpr inline InputChannelId Function09{"keyboard_key_function_F09"}; //!< The F9 key
+ static constexpr inline InputChannelId Function10{"keyboard_key_function_F10"}; //!< The F10 key
+ static constexpr inline InputChannelId Function11{"keyboard_key_function_F11"}; //!< The F11 key
+ static constexpr inline InputChannelId Function12{"keyboard_key_function_F12"}; //!< The F12 key
+ static constexpr inline InputChannelId Function13{"keyboard_key_function_F13"}; //!< The F13 key
+ static constexpr inline InputChannelId Function14{"keyboard_key_function_F14"}; //!< The F14 key
+ static constexpr inline InputChannelId Function15{"keyboard_key_function_F15"}; //!< The F15 key
+ static constexpr inline InputChannelId Function16{"keyboard_key_function_F16"}; //!< The F16 key
+ static constexpr inline InputChannelId Function17{"keyboard_key_function_F17"}; //!< The F17 key
+ static constexpr inline InputChannelId Function18{"keyboard_key_function_F18"}; //!< The F18 key
+ static constexpr inline InputChannelId Function19{"keyboard_key_function_F19"}; //!< The F19 key
+ static constexpr inline InputChannelId Function20{"keyboard_key_function_F20"}; //!< The F20 key
// Modifier Keys
- static const InputChannelId ModifierAltL; //!< The left alt/option key
- static const InputChannelId ModifierAltR; //!< The right alt/option key
- static const InputChannelId ModifierCtrlL; //!< The left control key
- static const InputChannelId ModifierCtrlR; //!< The right control key
- static const InputChannelId ModifierShiftL; //!< The left shift key
- static const InputChannelId ModifierShiftR; //!< The right shift key
- static const InputChannelId ModifierSuperL; //!< The left super (windows or apple) key
- static const InputChannelId ModifierSuperR; //!< The right super (windows or apple) key
+ static constexpr inline InputChannelId ModifierAltL{"keyboard_key_modifier_alt_l"}; //!< The left alt/option key
+ static constexpr inline InputChannelId ModifierAltR{"keyboard_key_modifier_alt_r"}; //!< The right alt/option key
+ static constexpr inline InputChannelId ModifierCtrlL{"keyboard_key_modifier_ctrl_l"}; //!< The left control key
+ static constexpr inline InputChannelId ModifierCtrlR{"keyboard_key_modifier_ctrl_r"}; //!< The right control key
+ static constexpr inline InputChannelId ModifierShiftL{"keyboard_key_modifier_shift_l"}; //!< The left shift key
+ static constexpr inline InputChannelId ModifierShiftR{"keyboard_key_modifier_shift_r"}; //!< The right shift key
+ static constexpr inline InputChannelId ModifierSuperL{"keyboard_key_modifier_super_l"}; //!< The left super {windows or apple} key
+ static constexpr inline InputChannelId ModifierSuperR{"keyboard_key_modifier_super_r"}; //!< The right super {windows or apple} key
// Navigation Keys
- static const InputChannelId NavigationArrowDown; //!< The down arrow key
- static const InputChannelId NavigationArrowLeft; //!< The left arrow key
- static const InputChannelId NavigationArrowRight; //!< The right arrow key
- static const InputChannelId NavigationArrowUp; //!< The up arrow key
- static const InputChannelId NavigationDelete; //!< The delete key
- static const InputChannelId NavigationEnd; //!< The end key
- static const InputChannelId NavigationHome; //!< The home key
- static const InputChannelId NavigationInsert; //!< The insert key
- static const InputChannelId NavigationPageDown; //!< The page down key
- static const InputChannelId NavigationPageUp; //!< The page up key
+ static constexpr inline InputChannelId NavigationArrowDown{"keyboard_key_navigation_arrow_down"}; //!< The down arrow key
+ static constexpr inline InputChannelId NavigationArrowLeft{"keyboard_key_navigation_arrow_left"}; //!< The left arrow key
+ static constexpr inline InputChannelId NavigationArrowRight{"keyboard_key_navigation_arrow_right"}; //!< The right arrow key
+ static constexpr inline InputChannelId NavigationArrowUp{"keyboard_key_navigation_arrow_up"}; //!< The up arrow key
+ static constexpr inline InputChannelId NavigationDelete{"keyboard_key_navigation_delete"}; //!< The delete key
+ static constexpr inline InputChannelId NavigationEnd{"keyboard_key_navigation_end"}; //!< The end key
+ static constexpr inline InputChannelId NavigationHome{"keyboard_key_navigation_home"}; //!< The home key
+ static constexpr inline InputChannelId NavigationInsert{"keyboard_key_navigation_insert"}; //!< The insert key
+ static constexpr inline InputChannelId NavigationPageDown{"keyboard_key_navigation_page_down"}; //!< The page down key
+ static constexpr inline InputChannelId NavigationPageUp{"keyboard_key_navigation_page_up"}; //!< The page up key
// Numpad Keys
- static const InputChannelId NumLock; //!< The num lock key (the clear key on apple keyboards)
- static const InputChannelId NumPad0; //!< The numpad 0 key
- static const InputChannelId NumPad1; //!< The numpad 1 key
- static const InputChannelId NumPad2; //!< The numpad 2 key
- static const InputChannelId NumPad3; //!< The numpad 3 key
- static const InputChannelId NumPad4; //!< The numpad 4 key
- static const InputChannelId NumPad5; //!< The numpad 5 key
- static const InputChannelId NumPad6; //!< The numpad 6 key
- static const InputChannelId NumPad7; //!< The numpad 7 key
- static const InputChannelId NumPad8; //!< The numpad 8 key
- static const InputChannelId NumPad9; //!< The numpad 9 key
- static const InputChannelId NumPadAdd; //!< The numpad add key
- static const InputChannelId NumPadDecimal; //!< The numpad decimal key
- static const InputChannelId NumPadDivide; //!< The numpad divide key
- static const InputChannelId NumPadEnter; //!< The numpad enter key
- static const InputChannelId NumPadMultiply; //!< The numpad multiply key
- static const InputChannelId NumPadSubtract; //!< The numpad subtract key
+ static constexpr inline InputChannelId NumLock{"keyboard_key_num_lock"}; //!< The num lock key {the clear key on apple keyboards}
+ static constexpr inline InputChannelId NumPad0{"keyboard_key_numpad_0"}; //!< The numpad 0 key
+ static constexpr inline InputChannelId NumPad1{"keyboard_key_numpad_1"}; //!< The numpad 1 key
+ static constexpr inline InputChannelId NumPad2{"keyboard_key_numpad_2"}; //!< The numpad 2 key
+ static constexpr inline InputChannelId NumPad3{"keyboard_key_numpad_3"}; //!< The numpad 3 key
+ static constexpr inline InputChannelId NumPad4{"keyboard_key_numpad_4"}; //!< The numpad 4 key
+ static constexpr inline InputChannelId NumPad5{"keyboard_key_numpad_5"}; //!< The numpad 5 key
+ static constexpr inline InputChannelId NumPad6{"keyboard_key_numpad_6"}; //!< The numpad 6 key
+ static constexpr inline InputChannelId NumPad7{"keyboard_key_numpad_7"}; //!< The numpad 7 key
+ static constexpr inline InputChannelId NumPad8{"keyboard_key_numpad_8"}; //!< The numpad 8 key
+ static constexpr inline InputChannelId NumPad9{"keyboard_key_numpad_9"}; //!< The numpad 9 key
+ static constexpr inline InputChannelId NumPadAdd{"keyboard_key_numpad_add"}; //!< The numpad add key
+ static constexpr inline InputChannelId NumPadDecimal{"keyboard_key_numpad_decimal"}; //!< The numpad decimal key
+ static constexpr inline InputChannelId NumPadDivide{"keyboard_key_numpad_divide"}; //!< The numpad divide key
+ static constexpr inline InputChannelId NumPadEnter{"keyboard_key_numpad_enter"}; //!< The numpad enter key
+ static constexpr inline InputChannelId NumPadMultiply{"keyboard_key_numpad_multiply"}; //!< The numpad multiply key
+ static constexpr inline InputChannelId NumPadSubtract{"keyboard_key_numpad_subtract"}; //!< The numpad subtract key
// Punctuation Keys
- static const InputChannelId PunctuationApostrophe; //!< The apostrophe key
- static const InputChannelId PunctuationBackslash; //!< The backslash key
- static const InputChannelId PunctuationBracketL; //!< The left bracket key
- static const InputChannelId PunctuationBracketR; //!< The right bracket key
- static const InputChannelId PunctuationComma; //!< The comma key
- static const InputChannelId PunctuationEquals; //!< The equals key
- static const InputChannelId PunctuationHyphen; //!< The hyphen/underscore key
- static const InputChannelId PunctuationPeriod; //!< The period key
- static const InputChannelId PunctuationSemicolon; //!< The semicolon key
- static const InputChannelId PunctuationSlash; //!< The (forward) slash key
- static const InputChannelId PunctuationTilde; //!< The tilde/grave key
+ static constexpr inline InputChannelId PunctuationApostrophe{"keyboard_key_punctuation_apostrophe"}; //!< The apostrophe key
+ static constexpr inline InputChannelId PunctuationBackslash{"keyboard_key_punctuation_backslash"}; //!< The backslash key
+ static constexpr inline InputChannelId PunctuationBracketL{"keyboard_key_punctuation_bracket_l"}; //!< The left bracket key
+ static constexpr inline InputChannelId PunctuationBracketR{"keyboard_key_punctuation_bracket_r"}; //!< The right bracket key
+ static constexpr inline InputChannelId PunctuationComma{"keyboard_key_punctuation_comma"}; //!< The comma key
+ static constexpr inline InputChannelId PunctuationEquals{"keyboard_key_punctuation_equals"}; //!< The equals key
+ static constexpr inline InputChannelId PunctuationHyphen{"keyboard_key_punctuation_hyphen"}; //!< The hyphen/underscore key
+ static constexpr inline InputChannelId PunctuationPeriod{"keyboard_key_punctuation_period"}; //!< The period key
+ static constexpr inline InputChannelId PunctuationSemicolon{"keyboard_key_punctuation_semicolon"}; //!< The semicolon key
+ static constexpr inline InputChannelId PunctuationSlash{"keyboard_key_punctuation_slash"}; //!< The {forward} slash key
+ static constexpr inline InputChannelId PunctuationTilde{"keyboard_key_punctuation_tilde"}; //!< The tilde/grave key
// Supplementary ISO Key
- static const InputChannelId SupplementaryISO; //!< The supplementary ISO layout key
+ static constexpr inline InputChannelId SupplementaryISO{"keyboard_key_supplementary_iso"}; //!< The supplementary ISO layout key
// Windows System Keys
- static const InputChannelId WindowsSystemPause; //!< The windows pause key
- static const InputChannelId WindowsSystemPrint; //!< The windows print key
- static const InputChannelId WindowsSystemScrollLock; //!< The windows scroll lock key
+ static constexpr inline InputChannelId WindowsSystemPause{"keyboard_key_windows_system_pause"}; //!< The windows pause key
+ static constexpr inline InputChannelId WindowsSystemPrint{"keyboard_key_windows_system_print"}; //!< The windows print key
+ static constexpr inline InputChannelId WindowsSystemScrollLock{"keyboard_key_windows_system_scroll_lock"}; //!< The windows scroll lock key
//!< All keyboard key ids
- static const AZStd::array All;
+ static constexpr inline AZStd::array All
+ {
+ // Alphanumeric Keys
+ Alphanumeric0,
+ Alphanumeric1,
+ Alphanumeric2,
+ Alphanumeric3,
+ Alphanumeric4,
+ Alphanumeric5,
+ Alphanumeric6,
+ Alphanumeric7,
+ Alphanumeric8,
+ Alphanumeric9,
+ AlphanumericA,
+ AlphanumericB,
+ AlphanumericC,
+ AlphanumericD,
+ AlphanumericE,
+ AlphanumericF,
+ AlphanumericG,
+ AlphanumericH,
+ AlphanumericI,
+ AlphanumericJ,
+ AlphanumericK,
+ AlphanumericL,
+ AlphanumericM,
+ AlphanumericN,
+ AlphanumericO,
+ AlphanumericP,
+ AlphanumericQ,
+ AlphanumericR,
+ AlphanumericS,
+ AlphanumericT,
+ AlphanumericU,
+ AlphanumericV,
+ AlphanumericW,
+ AlphanumericX,
+ AlphanumericY,
+ AlphanumericZ,
+
+ // Edit (and escape) Keys
+ EditBackspace,
+ EditCapsLock,
+ EditEnter,
+ EditSpace,
+ EditTab,
+ Escape,
+
+ // Function Keys
+ Function01,
+ Function02,
+ Function03,
+ Function04,
+ Function05,
+ Function06,
+ Function07,
+ Function08,
+ Function09,
+ Function10,
+ Function11,
+ Function12,
+ Function13,
+ Function14,
+ Function15,
+ Function16,
+ Function17,
+ Function18,
+ Function19,
+ Function20,
+
+ // Modifier Keys
+ ModifierAltL,
+ ModifierAltR,
+ ModifierCtrlL,
+ ModifierCtrlR,
+ ModifierShiftL,
+ ModifierShiftR,
+ ModifierSuperL,
+ ModifierSuperR,
+
+ // Navigation Keys
+ NavigationArrowDown,
+ NavigationArrowLeft,
+ NavigationArrowRight,
+ NavigationArrowUp,
+ NavigationDelete,
+ NavigationEnd,
+ NavigationHome,
+ NavigationInsert,
+ NavigationPageDown,
+ NavigationPageUp,
+
+ // Numpad Keys
+ NumLock,
+ NumPad0,
+ NumPad1,
+ NumPad2,
+ NumPad3,
+ NumPad4,
+ NumPad5,
+ NumPad6,
+ NumPad7,
+ NumPad8,
+ NumPad9,
+ NumPadAdd,
+ NumPadDecimal,
+ NumPadDivide,
+ NumPadEnter,
+ NumPadMultiply,
+ NumPadSubtract,
+
+ // Punctuation Keys
+ PunctuationApostrophe,
+ PunctuationBackslash,
+ PunctuationBracketL,
+ PunctuationBracketR,
+ PunctuationComma,
+ PunctuationEquals,
+ PunctuationHyphen,
+ PunctuationPeriod,
+ PunctuationSemicolon,
+ PunctuationSlash,
+ PunctuationTilde,
+
+ // Supplementary ISO Key
+ SupplementaryISO,
+
+ // Windows System Keys
+ WindowsSystemPause,
+ WindowsSystemPrint,
+ WindowsSystemScrollLock
+ };
};
////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/Motion/InputDeviceMotion.cpp b/Code/Framework/AzFramework/AzFramework/Input/Devices/Motion/InputDeviceMotion.cpp
index 34c72f20d2..c144f63d2c 100644
--- a/Code/Framework/AzFramework/AzFramework/Input/Devices/Motion/InputDeviceMotion.cpp
+++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/Motion/InputDeviceMotion.cpp
@@ -23,44 +23,6 @@ namespace AzFramework
return (inputDeviceId.GetNameCrc32() == Id.GetNameCrc32());
}
- ////////////////////////////////////////////////////////////////////////////////////////////////
- const InputChannelId InputDeviceMotion::Acceleration::Gravity("motion_acceleration_gravity");
- const InputChannelId InputDeviceMotion::Acceleration::Raw("motion_acceleration_raw");
- const InputChannelId InputDeviceMotion::Acceleration::User("motion_acceleration_user");
- const AZStd::array InputDeviceMotion::Acceleration::All =
- {{
- Gravity,
- Raw,
- User
- }};
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- const InputChannelId InputDeviceMotion::RotationRate::Raw("motion_rotation_rate_raw");
- const InputChannelId InputDeviceMotion::RotationRate::Unbiased("motion_rotation_rate_unbiased");
- const AZStd::array InputDeviceMotion::RotationRate::All =
- {{
- Raw,
- Unbiased
- }};
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- const InputChannelId InputDeviceMotion::MagneticField::North("motion_magnetic_field_north");
- const InputChannelId InputDeviceMotion::MagneticField::Raw("motion_magnetic_field_raw");
- const InputChannelId InputDeviceMotion::MagneticField::Unbiased("motion_magnetic_field_unbiased");
- const AZStd::array InputDeviceMotion::MagneticField::All =
- {{
- North,
- Raw,
- Unbiased
- }};
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- const InputChannelId InputDeviceMotion::Orientation::Current("motion_orientation_current");
- const AZStd::array InputDeviceMotion::Orientation::All =
- {{
- Current
- }};
-
////////////////////////////////////////////////////////////////////////////////////////////////
void InputDeviceMotion::Reflect(AZ::ReflectContext* context)
{
diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/Motion/InputDeviceMotion.h b/Code/Framework/AzFramework/AzFramework/Input/Devices/Motion/InputDeviceMotion.h
index 1e020a6e02..872bd1cfa0 100644
--- a/Code/Framework/AzFramework/AzFramework/Input/Devices/Motion/InputDeviceMotion.h
+++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/Motion/InputDeviceMotion.h
@@ -44,12 +44,17 @@ namespace AzFramework
//! - InputMotionSensorRequests::SetInputChannelEnabled
struct Acceleration
{
- static const InputChannelId Gravity;
- static const InputChannelId Raw;
- static const InputChannelId User;
+ static constexpr inline InputChannelId Gravity{"motion_acceleration_gravity"};
+ static constexpr inline InputChannelId Raw{"motion_acceleration_raw"};
+ static constexpr inline InputChannelId User{"motion_acceleration_user"};
//!< All acceleration input channel ids
- static const AZStd::array All;
+ static constexpr inline AZStd::array All
+ {
+ Gravity,
+ Raw,
+ User
+ };
};
////////////////////////////////////////////////////////////////////////////////////////////
@@ -60,11 +65,15 @@ namespace AzFramework
//! - InputMotionSensorRequests::SetInputChannelEnabled
struct RotationRate
{
- static const InputChannelId Raw;
- static const InputChannelId Unbiased;
+ static constexpr inline InputChannelId Raw{"motion_rotation_rate_raw"};
+ static constexpr inline InputChannelId Unbiased{"motion_rotation_rate_unbiased"};
//!< All rotation rate input channel ids
- static const AZStd::array All;
+ static constexpr inline AZStd::array All
+ {
+ Raw,
+ Unbiased
+ };
};
////////////////////////////////////////////////////////////////////////////////////////////
@@ -75,12 +84,17 @@ namespace AzFramework
//! - InputMotionSensorRequests::SetInputChannelEnabled
struct MagneticField
{
- static const InputChannelId North;
- static const InputChannelId Raw;
- static const InputChannelId Unbiased;
+ static constexpr inline InputChannelId North{"motion_magnetic_field_north"};
+ static constexpr inline InputChannelId Raw{"motion_magnetic_field_raw"};
+ static constexpr inline InputChannelId Unbiased{"motion_magnetic_field_unbiased"};
//!< All magnetic field input channel ids
- static const AZStd::array All;
+ static constexpr inline AZStd::array All
+ {
+ North,
+ Raw,
+ Unbiased
+ };
};
////////////////////////////////////////////////////////////////////////////////////////////
@@ -91,10 +105,13 @@ namespace AzFramework
//! - InputMotionSensorRequests::SetInputChannelEnabled
struct Orientation
{
- static const InputChannelId Current;
+ static constexpr inline InputChannelId Current{"motion_orientation_current"};
//!< All orientation input channel ids
- static const AZStd::array All;
+ static constexpr inline AZStd::array All
+ {
+ Current
+ };
};
////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/Mouse/InputDeviceMouse.cpp b/Code/Framework/AzFramework/AzFramework/Input/Devices/Mouse/InputDeviceMouse.cpp
index 2cc4573bce..e9af4cc4ce 100644
--- a/Code/Framework/AzFramework/AzFramework/Input/Devices/Mouse/InputDeviceMouse.cpp
+++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/Mouse/InputDeviceMouse.cpp
@@ -33,35 +33,6 @@ namespace AzFramework
return (inputDeviceId.GetNameCrc32() == Id.GetNameCrc32());
}
- ////////////////////////////////////////////////////////////////////////////////////////////////
- const InputChannelId InputDeviceMouse::Button::Left("mouse_button_left");
- const InputChannelId InputDeviceMouse::Button::Right("mouse_button_right");
- const InputChannelId InputDeviceMouse::Button::Middle("mouse_button_middle");
- const InputChannelId InputDeviceMouse::Button::Other1("mouse_button_other1");
- const InputChannelId InputDeviceMouse::Button::Other2("mouse_button_other2");
- const AZStd::array InputDeviceMouse::Button::All =
- {{
- Left,
- Right,
- Middle,
- Other1,
- Other2
- }};
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- const InputChannelId InputDeviceMouse::Movement::X("mouse_delta_x");
- const InputChannelId InputDeviceMouse::Movement::Y("mouse_delta_y");
- const InputChannelId InputDeviceMouse::Movement::Z("mouse_delta_z");
- const AZStd::array InputDeviceMouse::Movement::All =
- {{
- X,
- Y,
- Z
- }};
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- const InputChannelId InputDeviceMouse::SystemCursorPosition("mouse_system_cursor_position");
-
////////////////////////////////////////////////////////////////////////////////////////////////
void InputDeviceMouse::Reflect(AZ::ReflectContext* context)
{
diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/Mouse/InputDeviceMouse.h b/Code/Framework/AzFramework/AzFramework/Input/Devices/Mouse/InputDeviceMouse.h
index 99fe5b820c..3b35e03f1b 100644
--- a/Code/Framework/AzFramework/AzFramework/Input/Devices/Mouse/InputDeviceMouse.h
+++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/Mouse/InputDeviceMouse.h
@@ -66,14 +66,21 @@ namespace AzFramework
//! been implemented for windows simply to provide for backwards compatibility with CryInput.
struct Button
{
- static const InputChannelId Left; //!< The left mouse button
- static const InputChannelId Right; //!< The right mouse button
- static const InputChannelId Middle; //!< The middle mouse button
- static const InputChannelId Other1; //!< DEPRECATED: the x1 mouse button
- static const InputChannelId Other2; //!< DEPRECATED: the x2 mouse button
+ static constexpr inline InputChannelId Left{"mouse_button_left"}; //!< The left mouse button
+ static constexpr inline InputChannelId Right{"mouse_button_right"}; //!< The right mouse button
+ static constexpr inline InputChannelId Middle{"mouse_button_middle"}; //!< The middle mouse button
+ static constexpr inline InputChannelId Other1{"mouse_button_other1"}; //!< DEPRECATED: the x1 mouse button
+ static constexpr inline InputChannelId Other2{"mouse_button_other2"}; //!< DEPRECATED: the x2 mouse button
//!< All mouse button ids
- static const AZStd::array All;
+ static constexpr inline AZStd::array All
+ {
+ Left,
+ Right,
+ Middle,
+ Other1,
+ Other2
+ };
};
////////////////////////////////////////////////////////////////////////////////////////////
@@ -82,12 +89,17 @@ namespace AzFramework
//! directly correlate to the mouse position (which is queried directly from the system).
struct Movement
{
- static const InputChannelId X; //!< Raw horizontal mouse movement over the last frame
- static const InputChannelId Y; //!< Raw vertical mouse movement over the last frame
- static const InputChannelId Z; //!< Raw mouse wheel movement over the last frame
+ static constexpr inline InputChannelId X{"mouse_delta_x"}; //!< Raw horizontal mouse movement over the last frame
+ static constexpr inline InputChannelId Y{"mouse_delta_y"}; //!< Raw vertical mouse movement over the last frame
+ static constexpr inline InputChannelId Z{"mouse_delta_z"}; //!< Raw mouse wheel movement over the last frame
//!< All mouse movement ids
- static const AZStd::array All;
+ static constexpr inline AZStd::array All
+ {
+ X,
+ Y,
+ Z
+ };
};
////////////////////////////////////////////////////////////////////////////////////////////
@@ -96,7 +108,7 @@ namespace AzFramework
//! the system cursor is hidden or visible. When the system cursor has been constrained to
//! the active window values will be in the [0.0, 1.0] range, but not when unconstrained.
//! See also InputSystemCursorRequests::SetSystemCursorState and GetSystemCursorState.
- static const InputChannelId SystemCursorPosition;
+ static constexpr inline InputChannelId SystemCursorPosition{"mouse_system_cursor_position"};
////////////////////////////////////////////////////////////////////////////////////////////
// Allocator
diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/Touch/InputDeviceTouch.cpp b/Code/Framework/AzFramework/AzFramework/Input/Devices/Touch/InputDeviceTouch.cpp
index 07d10090a3..be850e9289 100644
--- a/Code/Framework/AzFramework/AzFramework/Input/Devices/Touch/InputDeviceTouch.cpp
+++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/Touch/InputDeviceTouch.cpp
@@ -24,31 +24,6 @@ namespace AzFramework
return (inputDeviceId.GetNameCrc32() == Id.GetNameCrc32());
}
- ////////////////////////////////////////////////////////////////////////////////////////////////
- const InputChannelId InputDeviceTouch::Touch::Index0("touch_index_0");
- const InputChannelId InputDeviceTouch::Touch::Index1("touch_index_1");
- const InputChannelId InputDeviceTouch::Touch::Index2("touch_index_2");
- const InputChannelId InputDeviceTouch::Touch::Index3("touch_index_3");
- const InputChannelId InputDeviceTouch::Touch::Index4("touch_index_4");
- const InputChannelId InputDeviceTouch::Touch::Index5("touch_index_5");
- const InputChannelId InputDeviceTouch::Touch::Index6("touch_index_6");
- const InputChannelId InputDeviceTouch::Touch::Index7("touch_index_7");
- const InputChannelId InputDeviceTouch::Touch::Index8("touch_index_8");
- const InputChannelId InputDeviceTouch::Touch::Index9("touch_index_9");
- const AZStd::array InputDeviceTouch::Touch::All =
- {{
- Index0,
- Index1,
- Index2,
- Index3,
- Index4,
- Index5,
- Index6,
- Index7,
- Index8,
- Index9
- }};
-
////////////////////////////////////////////////////////////////////////////////////////////////
void InputDeviceTouch::Reflect(AZ::ReflectContext* context)
{
diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/Touch/InputDeviceTouch.h b/Code/Framework/AzFramework/AzFramework/Input/Devices/Touch/InputDeviceTouch.h
index 6e069c44ba..d21834c22a 100644
--- a/Code/Framework/AzFramework/AzFramework/Input/Devices/Touch/InputDeviceTouch.h
+++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/Touch/InputDeviceTouch.h
@@ -38,19 +38,31 @@ namespace AzFramework
//! track is arbitrary, but ten seems to be more than sufficient for most game applications.
struct Touch
{
- static const InputChannelId Index0; //!< Touch index 0
- static const InputChannelId Index1; //!< Touch index 1
- static const InputChannelId Index2; //!< Touch index 2
- static const InputChannelId Index3; //!< Touch index 3
- static const InputChannelId Index4; //!< Touch index 4
- static const InputChannelId Index5; //!< Touch index 5
- static const InputChannelId Index6; //!< Touch index 6
- static const InputChannelId Index7; //!< Touch index 7
- static const InputChannelId Index8; //!< Touch index 8
- static const InputChannelId Index9; //!< Touch index 9
+ static constexpr inline InputChannelId Index0{"touch_index_0"}; //!< Touch index 0
+ static constexpr inline InputChannelId Index1{"touch_index_1"}; //!< Touch index 1
+ static constexpr inline InputChannelId Index2{"touch_index_2"}; //!< Touch index 2
+ static constexpr inline InputChannelId Index3{"touch_index_3"}; //!< Touch index 3
+ static constexpr inline InputChannelId Index4{"touch_index_4"}; //!< Touch index 4
+ static constexpr inline InputChannelId Index5{"touch_index_5"}; //!< Touch index 5
+ static constexpr inline InputChannelId Index6{"touch_index_6"}; //!< Touch index 6
+ static constexpr inline InputChannelId Index7{"touch_index_7"}; //!< Touch index 7
+ static constexpr inline InputChannelId Index8{"touch_index_8"}; //!< Touch index 8
+ static constexpr inline InputChannelId Index9{"touch_index_9"}; //!< Touch index 9
//!< All touch input channel ids
- static const AZStd::array All;
+ static constexpr inline AZStd::array All
+ {
+ Index0,
+ Index1,
+ Index2,
+ Index3,
+ Index4,
+ Index5,
+ Index6,
+ Index7,
+ Index8,
+ Index9
+ };
};
////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard.cpp b/Code/Framework/AzFramework/AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard.cpp
index bc23826ebc..f3024f11ab 100644
--- a/Code/Framework/AzFramework/AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard.cpp
+++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard.cpp
@@ -23,17 +23,6 @@ namespace AzFramework
return (inputDeviceId.GetNameCrc32() == Id.GetNameCrc32());
}
- ////////////////////////////////////////////////////////////////////////////////////////////////
- const InputChannelId InputDeviceVirtualKeyboard::Command::EditEnter("virtual_keyboard_edit_enter");
- const InputChannelId InputDeviceVirtualKeyboard::Command::EditClear("virtual_keyboard_edit_clear");
- const InputChannelId InputDeviceVirtualKeyboard::Command::NavigationBack("virtual_keyboard_navigation_back");
- const AZStd::array InputDeviceVirtualKeyboard::Command::All =
- {{
- EditClear,
- EditEnter,
- NavigationBack
- }};
-
////////////////////////////////////////////////////////////////////////////////////////////////
void InputDeviceVirtualKeyboard::Reflect(AZ::ReflectContext* context)
{
diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard.h b/Code/Framework/AzFramework/AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard.h
index 43e2815875..6f62c3ec61 100644
--- a/Code/Framework/AzFramework/AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard.h
+++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard.h
@@ -39,17 +39,22 @@ namespace AzFramework
struct Command
{
//!< The clear command used to indicate the user wants to clear the active text field
- static const InputChannelId EditClear;
+ static constexpr inline InputChannelId EditClear{"virtual_keyboard_edit_enter"};
//!< The enter/return/close command used to indicate the user has finished text editing
- static const InputChannelId EditEnter;
+ static constexpr inline InputChannelId EditEnter{"virtual_keyboard_edit_clear"};
//!< The back command used to indicate the user wants to navigate 'backwards'.
//!< This is specific to android devices, and does not have an ios equivalent.
- static const InputChannelId NavigationBack;
+ static constexpr inline InputChannelId NavigationBack{"virtual_keyboard_navigation_back"};
//!< All virtual keyboard command ids
- static const AZStd::array All;
+ static constexpr inline AZStd::array All
+ {
+ EditClear,
+ EditEnter,
+ NavigationBack
+ };
};
////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesInterface.cpp b/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesInterface.cpp
index 75fca39574..171d626b27 100644
--- a/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesInterface.cpp
+++ b/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesInterface.cpp
@@ -283,8 +283,12 @@ namespace AzFramework
: m_payload(rhs.m_payload)
, m_id(rhs.m_id)
{
+ auto manager = SpawnableEntitiesInterface::Get();
+ AZ_Assert(manager, "SpawnableEntitiesInterface has no implementation.");
rhs.m_payload = nullptr;
rhs.m_id = 0;
+ AZStd::scoped_lock lock(manager->m_entitySpawnTicketMapMutex);
+ manager->m_entitySpawnTicketMap.insert_or_assign(rhs.m_id, this);
}
EntitySpawnTicket::EntitySpawnTicket(AZ::Data::Asset spawnable)
@@ -294,6 +298,8 @@ namespace AzFramework
AZStd::pair result = manager->CreateTicket(AZStd::move(spawnable));
m_id = result.first;
m_payload = result.second;
+ AZStd::scoped_lock lock(manager->m_entitySpawnTicketMapMutex);
+ manager->m_entitySpawnTicketMap.insert_or_assign(m_id, this);
}
EntitySpawnTicket::~EntitySpawnTicket()
@@ -304,6 +310,8 @@ namespace AzFramework
AZ_Assert(manager, "Attempting to destroy an entity spawn ticket while the SpawnableEntitiesInterface has no implementation.");
manager->DestroyTicket(m_payload);
m_payload = nullptr;
+ AZStd::scoped_lock lock(manager->m_entitySpawnTicketMapMutex);
+ manager->m_entitySpawnTicketMap.erase(m_id);
m_id = 0;
}
}
@@ -312,17 +320,23 @@ namespace AzFramework
{
if (this != &rhs)
{
+ auto manager = SpawnableEntitiesInterface::Get();
+ AZ_Assert(manager, "Attempting to destroy an entity spawn ticket while the SpawnableEntitiesInterface has no implementation.");
if (m_payload)
{
- auto manager = SpawnableEntitiesInterface::Get();
- AZ_Assert(manager, "Attempting to destroy an entity spawn ticket while the SpawnableEntitiesInterface has no implementation.");
manager->DestroyTicket(m_payload);
}
+
+ Id previousId = m_id;
m_id = rhs.m_id;
rhs.m_id = 0;
m_payload = rhs.m_payload;
rhs.m_payload = nullptr;
+
+ AZStd::scoped_lock lock(manager->m_entitySpawnTicketMapMutex);
+ manager->m_entitySpawnTicketMap.erase(previousId);
+ manager->m_entitySpawnTicketMap.insert_or_assign(m_id, this);
}
return *this;
}
diff --git a/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesInterface.h b/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesInterface.h
index 6901fc7116..74a17020df 100644
--- a/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesInterface.h
+++ b/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesInterface.h
@@ -154,7 +154,7 @@ namespace AzFramework
public:
friend class SpawnableEntitiesDefinition;
- using Id = uint64_t;
+ using Id = uint32_t;
EntitySpawnTicket() = default;
EntitySpawnTicket(const EntitySpawnTicket&) = delete;
@@ -176,6 +176,7 @@ namespace AzFramework
using EntitySpawnCallback = AZStd::function;
using EntityPreInsertionCallback = AZStd::function;
using EntityDespawnCallback = AZStd::function;
+ using RetrieveEntitySpawnTicketCallback = AZStd::function;
using ReloadSpawnableCallback = AZStd::function;
using ListEntitiesCallback = AZStd::function;
using ListIndicesEntitiesCallback = AZStd::function;
@@ -220,12 +221,21 @@ namespace AzFramework
struct DespawnAllEntitiesOptionalArgs final
{
//! Callback that's called when despawning entities has completed. This can be triggered from a different thread than the one that
- //! made the function call to despawn. The returned list of entities contains all the newly created entities.
+ //! made the function call to despawn.
EntityDespawnCallback m_completionCallback;
//! The priority at which this call will be executed.
SpawnablePriority m_priority { SpawnablePriority_Default };
};
+ struct DespawnEntityOptionalArgs final
+ {
+ //! Callback that's called when despawning entity has completed. This can be triggered from a different thread than the one that
+ //! made the function call to despawn.
+ EntityDespawnCallback m_completionCallback;
+ //! The priority at which this call will be executed.
+ SpawnablePriority m_priority{ SpawnablePriority_Default };
+ };
+
struct ReloadSpawnableOptionalArgs final
{
//! Callback that's called when respawning entities has completed. This can be triggered from a different thread than the one that
@@ -291,9 +301,17 @@ namespace AzFramework
EntitySpawnTicket& ticket, AZStd::vector entityIndices, SpawnEntitiesOptionalArgs optionalArgs = {}) = 0;
//! Removes all entities in the provided list from the environment.
//! @param ticket The ticket previously used to spawn entities with.
- //! @param priority The priority at which this call will be executed.
//! @param optionalArgs Optional additional arguments, see DespawnAllEntitiesOptionalArgs.
virtual void DespawnAllEntities(EntitySpawnTicket& ticket, DespawnAllEntitiesOptionalArgs optionalArgs = {}) = 0;
+ //! Removes the entity with the provided id from the spawned list of entities.
+ //! @param entityId the id of entity to despawn.
+ //! @param ticket The ticket previously used to spawn entities with.
+ //! @param optionalArgs Optional additional arguments, see DespawnEntityOptionalArgs.
+ virtual void DespawnEntity(AZ::EntityId entityId, EntitySpawnTicket& ticket, DespawnEntityOptionalArgs optionalArgs = {}) = 0;
+ //! Gets the EntitySpawnTicket associated with the entitySpawnTicketId.
+ //! @param entitySpawnTicketId the id of EntitySpawnTicket to get.
+ //! @param callback The callback to execute upon retrieving the ticket.
+ virtual void RetrieveEntitySpawnTicket(EntitySpawnTicket::Id entitySpawnTicketId, RetrieveEntitySpawnTicketCallback callback) = 0;
//! Removes all entities in the provided list from the environment and reconstructs the entities from the provided spawnable.
//! @param ticket Holds the information on the entities to reload.
//! @param priority The priority at which this call will be executed.
@@ -361,6 +379,9 @@ namespace AzFramework
{
return reinterpret_cast(ticket->m_payload);
}
+
+ AZStd::unordered_map m_entitySpawnTicketMap;
+ AZStd::recursive_mutex m_entitySpawnTicketMapMutex;
};
using SpawnableEntitiesInterface = AZ::Interface;
diff --git a/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesManager.cpp b/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesManager.cpp
index 5fa072a451..ef7351aabb 100644
--- a/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesManager.cpp
+++ b/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesManager.cpp
@@ -85,6 +85,35 @@ namespace AzFramework
QueueRequest(ticket, optionalArgs.m_priority, AZStd::move(queueEntry));
}
+ void SpawnableEntitiesManager::DespawnEntity(AZ::EntityId entityId, EntitySpawnTicket& ticket, DespawnEntityOptionalArgs optionalArgs)
+ {
+ AZ_Assert(ticket.IsValid(), "Ticket provided to DespawnEntity hasn't been initialized.");
+
+ DespawnEntityCommand queueEntry;
+ queueEntry.m_ticketId = ticket.GetId();
+ queueEntry.m_entityId = entityId;
+ queueEntry.m_completionCallback = AZStd::move(optionalArgs.m_completionCallback);
+ QueueRequest(ticket, optionalArgs.m_priority, AZStd::move(queueEntry));
+ }
+
+ void SpawnableEntitiesManager::RetrieveEntitySpawnTicket(EntitySpawnTicket::Id entitySpawnTicketId, RetrieveEntitySpawnTicketCallback callback)
+ {
+ if (entitySpawnTicketId == 0)
+ {
+ AZ_Assert(false, "Ticket id provided to RetrieveEntitySpawnTicket is invalid.");
+ return;
+ }
+
+ AZStd::scoped_lock lock(m_entitySpawnTicketMapMutex);
+ auto entitySpawnTicketIterator = m_entitySpawnTicketMap.find(entitySpawnTicketId);
+ if (entitySpawnTicketIterator == m_entitySpawnTicketMap.end())
+ {
+ AZ_Assert(false, "The EntitySpawnTicket corresponding to id '%lu' cannot be found", entitySpawnTicketId);
+ return;
+ }
+ callback(entitySpawnTicketIterator->second);
+ }
+
void SpawnableEntitiesManager::ReloadSpawnable(
EntitySpawnTicket& ticket, AZ::Data::Asset spawnable, ReloadSpawnableOptionalArgs optionalArgs)
{
@@ -223,12 +252,13 @@ namespace AzFramework
return queue.m_delayed.empty() ? CommandQueueStatus::NoCommandsLeft : CommandQueueStatus::HasCommandsLeft;
}
- AZStd::pair SpawnableEntitiesManager::CreateTicket(AZ::Data::Asset&& spawnable)
+ AZStd::pair SpawnableEntitiesManager::CreateTicket(AZ::Data::Asset&& spawnable)
{
- static AZStd::atomic_uint64_t idCounter { 1 };
+ static AZStd::atomic_uint32_t idCounter { 1 };
auto result = aznew Ticket();
result->m_spawnable = AZStd::move(spawnable);
+
return AZStd::make_pair(idCounter++, result);
}
@@ -339,6 +369,7 @@ namespace AzFramework
// Add to the game context, now the entities are active
for (auto it = ticket.m_spawnedEntities.begin() + spawnedEntitiesInitialCount; it != ticket.m_spawnedEntities.end(); ++it)
{
+ (*it)->SetSpawnTicketId(request.m_ticketId);
GameEntityContextRequestBus::Broadcast(&GameEntityContextRequestBus::Events::AddGameEntity, *it);
}
@@ -420,6 +451,7 @@ namespace AzFramework
// Add to the game context, now the entities are active
for (auto it = ticket.m_spawnedEntities.begin() + spawnedEntitiesInitialCount; it != ticket.m_spawnedEntities.end(); ++it)
{
+ (*it)->SetSpawnTicketId(request.m_ticketId);
GameEntityContextRequestBus::Broadcast(&GameEntityContextRequestBus::Events::AddGameEntity, *it);
}
@@ -447,8 +479,10 @@ namespace AzFramework
{
if (entity != nullptr)
{
+ // Setting it to 0 is needed to avoid the infite loop between GameEntityContext and SpawnableEntitiesManager.
+ entity->SetSpawnTicketId(0);
GameEntityContextRequestBus::Broadcast(
- &GameEntityContextRequestBus::Events::DestroyGameEntityAndDescendants, entity->GetId());
+ &GameEntityContextRequestBus::Events::DestroyGameEntity, entity->GetId());
}
}
@@ -469,6 +503,40 @@ namespace AzFramework
}
}
+ bool SpawnableEntitiesManager::ProcessRequest(DespawnEntityCommand& request)
+ {
+ Ticket& ticket = *request.m_ticket;
+ if (request.m_requestId == ticket.m_currentRequestId)
+ {
+ AZStd::vector& spawnedEntities = request.m_ticket->m_spawnedEntities;
+ for (auto entityIterator = spawnedEntities.begin(); entityIterator != spawnedEntities.end(); ++entityIterator)
+ {
+ if (*entityIterator != nullptr && (*entityIterator)->GetId() == request.m_entityId)
+ {
+ // Setting it to 0 is needed to avoid the infite loop between GameEntityContext and SpawnableEntitiesManager.
+ (*entityIterator)->SetSpawnTicketId(0);
+ GameEntityContextRequestBus::Broadcast(
+ &GameEntityContextRequestBus::Events::DestroyGameEntity, (*entityIterator)->GetId());
+ AZStd::iter_swap(entityIterator, spawnedEntities.rbegin());
+ spawnedEntities.pop_back();
+ break;
+ }
+ }
+
+ if (request.m_completionCallback)
+ {
+ request.m_completionCallback(request.m_ticketId);
+ }
+
+ ticket.m_currentRequestId++;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
bool SpawnableEntitiesManager::ProcessRequest(ReloadSpawnableCommand& request)
{
Ticket& ticket = *request.m_ticket;
@@ -482,8 +550,10 @@ namespace AzFramework
{
if (entity != nullptr)
{
+ // Setting it to 0 is needed to avoid the infite loop between GameEntityContext and SpawnableEntitiesManager.
+ entity->SetSpawnTicketId(0);
GameEntityContextRequestBus::Broadcast(
- &GameEntityContextRequestBus::Events::DestroyGameEntityAndDescendants, entity->GetId());
+ &GameEntityContextRequestBus::Events::DestroyGameEntity, entity->GetId());
}
}
@@ -636,8 +706,10 @@ namespace AzFramework
{
if (entity != nullptr)
{
+ // Setting it to 0 is needed to avoid the infite loop between GameEntityContext and SpawnableEntitiesManager.
+ entity->SetSpawnTicketId(0);
GameEntityContextRequestBus::Broadcast(
- &GameEntityContextRequestBus::Events::DestroyGameEntityAndDescendants, entity->GetId());
+ &GameEntityContextRequestBus::Events::DestroyGameEntity, entity->GetId());
}
}
delete request.m_ticket;
diff --git a/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesManager.h b/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesManager.h
index 69985f8aa9..c3de5be003 100644
--- a/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesManager.h
+++ b/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesManager.h
@@ -57,6 +57,8 @@ namespace AzFramework
void SpawnEntities(
EntitySpawnTicket& ticket, AZStd::vector entityIndices, SpawnEntitiesOptionalArgs optionalArgs = {}) override;
void DespawnAllEntities(EntitySpawnTicket& ticket, DespawnAllEntitiesOptionalArgs optionalArgs = {}) override;
+ void DespawnEntity(AZ::EntityId entityId, EntitySpawnTicket& ticket, DespawnEntityOptionalArgs optionalArgs = {}) override;
+ void RetrieveEntitySpawnTicket(EntitySpawnTicket::Id entitySpawnTicketId, RetrieveEntitySpawnTicketCallback callback) override;
void ReloadSpawnable(
EntitySpawnTicket& ticket, AZ::Data::Asset spawnable, ReloadSpawnableOptionalArgs optionalArgs = {}) override;
@@ -132,6 +134,14 @@ namespace AzFramework
EntitySpawnTicket::Id m_ticketId;
uint32_t m_requestId;
};
+ struct DespawnEntityCommand
+ {
+ EntityDespawnCallback m_completionCallback;
+ Ticket* m_ticket;
+ AZ::EntityId m_entityId;
+ EntitySpawnTicket::Id m_ticketId;
+ uint32_t m_requestId;
+ };
struct ReloadSpawnableCommand
{
AZ::Data::Asset m_spawnable;
@@ -176,8 +186,16 @@ namespace AzFramework
};
using Requests = AZStd::variant<
- SpawnAllEntitiesCommand, SpawnEntitiesCommand, DespawnAllEntitiesCommand, ReloadSpawnableCommand, ListEntitiesCommand,
- ListIndicesEntitiesCommand, ClaimEntitiesCommand, BarrierCommand, DestroyTicketCommand>;
+ SpawnAllEntitiesCommand,
+ SpawnEntitiesCommand,
+ DespawnAllEntitiesCommand,
+ DespawnEntityCommand,
+ ReloadSpawnableCommand,
+ ListEntitiesCommand,
+ ListIndicesEntitiesCommand,
+ ClaimEntitiesCommand,
+ BarrierCommand,
+ DestroyTicketCommand>;
struct Queue
{
@@ -199,6 +217,7 @@ namespace AzFramework
bool ProcessRequest(SpawnAllEntitiesCommand& request);
bool ProcessRequest(SpawnEntitiesCommand& request);
bool ProcessRequest(DespawnAllEntitiesCommand& request);
+ bool ProcessRequest(DespawnEntityCommand& request);
bool ProcessRequest(ReloadSpawnableCommand& request);
bool ProcessRequest(ListEntitiesCommand& request);
bool ProcessRequest(ListIndicesEntitiesCommand& request);
diff --git a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp
index 18667ac153..a3eb4d8329 100644
--- a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp
+++ b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp
@@ -17,15 +17,6 @@
namespace AzFramework
{
- AZ_CVAR(
- float,
- ed_cameraSystemDefaultPlaneHeight,
- 34.0f,
- nullptr,
- AZ::ConsoleFunctorFlags::Null,
- "The default height of the ground plane to do intersection tests against when orbiting");
- AZ_CVAR(float, ed_cameraSystemMinOrbitDistance, 10.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
- AZ_CVAR(float, ed_cameraSystemMaxOrbitDistance, 50.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
AZ_CVAR(
bool,
ed_cameraSystemUseCursor,
@@ -135,8 +126,8 @@ namespace AzFramework
camera.m_pitch = eulerAngles.GetX();
camera.m_yaw = eulerAngles.GetZ();
- // note: m_lookDist is negative so we must invert it here
- camera.m_lookAt = transform.GetTranslation() + (camera.Rotation().GetBasisY() * -camera.m_lookDist);
+ camera.m_pivot = transform.GetTranslation();
+ camera.m_offset = AZ::Vector3::CreateZero();
}
bool CameraSystem::HandleEvents(const InputEvent& event)
@@ -320,14 +311,8 @@ namespace AzFramework
nextCamera.m_pitch -= float(cursorDelta.m_y) * rotateSpeed * Invert(m_invertPitchFn());
nextCamera.m_yaw -= float(cursorDelta.m_x) * rotateSpeed * Invert(m_invertYawFn());
- const auto clampRotation = [](const float angle)
- {
- return AZStd::fmod(angle + AZ::Constants::TwoPi, AZ::Constants::TwoPi);
- };
-
- nextCamera.m_yaw = clampRotation(nextCamera.m_yaw);
- // clamp pitch to be +/-90 degrees
- nextCamera.m_pitch = AZ::GetClamp(nextCamera.m_pitch, -AZ::Constants::HalfPi, AZ::Constants::HalfPi);
+ nextCamera.m_yaw = WrapYawRotation(nextCamera.m_yaw);
+ nextCamera.m_pitch = ClampPitchRotation(nextCamera.m_pitch);
return nextCamera;
}
@@ -337,9 +322,10 @@ namespace AzFramework
m_rotateChannelId = rotateChannelId;
}
- PanCameraInput::PanCameraInput(const InputChannelId& panChannelId, PanAxesFn panAxesFn)
+ PanCameraInput::PanCameraInput(const InputChannelId& panChannelId, PanAxesFn panAxesFn, TranslationDeltaFn translationDeltaFn)
: m_panAxesFn(AZStd::move(panAxesFn))
, m_panChannelId(panChannelId)
+ , m_translationDeltaFn(translationDeltaFn)
{
m_panSpeedFn = []() constexpr
{
@@ -375,11 +361,11 @@ namespace AzFramework
const auto panAxes = m_panAxesFn(nextCamera);
const float panSpeed = m_panSpeedFn();
- const auto deltaPanX = float(cursorDelta.m_x) * panAxes.m_horizontalAxis * panSpeed;
- const auto deltaPanY = float(cursorDelta.m_y) * panAxes.m_verticalAxis * panSpeed;
+ const auto deltaPanX = aznumeric_cast(cursorDelta.m_x) * panAxes.m_horizontalAxis * panSpeed;
+ const auto deltaPanY = aznumeric_cast(cursorDelta.m_y) * panAxes.m_verticalAxis * panSpeed;
- nextCamera.m_lookAt += deltaPanX * Invert(m_invertPanXFn());
- nextCamera.m_lookAt += deltaPanY * -Invert(m_invertPanYFn());
+ m_translationDeltaFn(nextCamera, deltaPanX * Invert(m_invertPanXFn()));
+ m_translationDeltaFn(nextCamera, deltaPanY * -Invert(m_invertPanYFn()));
return nextCamera;
}
@@ -426,8 +412,11 @@ namespace AzFramework
}
TranslateCameraInput::TranslateCameraInput(
- TranslationAxesFn translationAxesFn, const TranslateCameraInputChannelIds& translateCameraInputChannelIds)
+ const TranslateCameraInputChannelIds& translateCameraInputChannelIds,
+ TranslationAxesFn translationAxesFn,
+ TranslationDeltaFn translateDeltaFn)
: m_translationAxesFn(AZStd::move(translationAxesFn))
+ , m_translateDeltaFn(AZStd::move(translateDeltaFn))
, m_translateCameraInputChannelIds(translateCameraInputChannelIds)
{
m_translateSpeedFn = []() constexpr
@@ -497,32 +486,32 @@ namespace AzFramework
if ((m_translation & TranslationType::Forward) == TranslationType::Forward)
{
- nextCamera.m_lookAt += axisY * speed * deltaTime;
+ m_translateDeltaFn(nextCamera, axisY * speed * deltaTime);
}
if ((m_translation & TranslationType::Backward) == TranslationType::Backward)
{
- nextCamera.m_lookAt -= axisY * speed * deltaTime;
+ m_translateDeltaFn(nextCamera, -axisY * speed * deltaTime);
}
if ((m_translation & TranslationType::Left) == TranslationType::Left)
{
- nextCamera.m_lookAt -= axisX * speed * deltaTime;
+ m_translateDeltaFn(nextCamera, -axisX * speed * deltaTime);
}
if ((m_translation & TranslationType::Right) == TranslationType::Right)
{
- nextCamera.m_lookAt += axisX * speed * deltaTime;
+ m_translateDeltaFn(nextCamera, axisX * speed * deltaTime);
}
if ((m_translation & TranslationType::Up) == TranslationType::Up)
{
- nextCamera.m_lookAt += axisZ * speed * deltaTime;
+ m_translateDeltaFn(nextCamera, axisZ * speed * deltaTime);
}
if ((m_translation & TranslationType::Down) == TranslationType::Down)
{
- nextCamera.m_lookAt -= axisZ * speed * deltaTime;
+ m_translateDeltaFn(nextCamera, -axisZ * speed * deltaTime);
}
if (Ending())
@@ -544,16 +533,20 @@ namespace AzFramework
m_translateCameraInputChannelIds = translateCameraInputChannelIds;
}
- OrbitCameraInput::OrbitCameraInput(const InputChannelId& orbitChannelId)
- : m_orbitChannelId(orbitChannelId)
+ PivotCameraInput::PivotCameraInput(const InputChannelId& pivotChannelId)
+ : m_pivotChannelId(pivotChannelId)
{
+ m_pivotFn = []([[maybe_unused]] const AZ::Vector3& position, [[maybe_unused]] const AZ::Vector3& direction)
+ {
+ return AZ::Vector3::CreateZero();
+ };
}
- bool OrbitCameraInput::HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, const float scrollDelta)
+ bool PivotCameraInput::HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, const float scrollDelta)
{
if (const auto* input = AZStd::get_if(&event))
{
- if (input->m_channelId == m_orbitChannelId)
+ if (input->m_channelId == m_pivotChannelId)
{
if (input->m_state == InputChannel::State::Began)
{
@@ -568,85 +561,46 @@ namespace AzFramework
if (Active())
{
- return m_orbitCameras.HandleEvents(event, cursorDelta, scrollDelta);
+ return m_pivotCameras.HandleEvents(event, cursorDelta, scrollDelta);
}
return !Idle();
}
- Camera OrbitCameraInput::StepCamera(
+ Camera PivotCameraInput::StepCamera(
const Camera& targetCamera, const ScreenVector& cursorDelta, const float scrollDelta, const float deltaTime)
{
Camera nextCamera = targetCamera;
if (Beginning())
{
- const auto hasLookAt = [&nextCamera, &targetCamera, &lookAtFn = m_lookAtFn]
- {
- if (lookAtFn)
- {
- // pass through the camera's position and look vector for use in the lookAt function
- if (const auto lookAt = lookAtFn(targetCamera.Translation(), targetCamera.Rotation().GetBasisY()))
- {
- // default to internal look at behavior if the look at point matches the camera translation
- if (targetCamera.m_lookAt.IsClose(*lookAt))
- {
- return false;
- }
-
- auto transform = AZ::Transform::CreateLookAt(targetCamera.m_lookAt, *lookAt);
- nextCamera.m_lookDist = -lookAt->GetDistance(targetCamera.m_lookAt);
- UpdateCameraFromTransform(nextCamera, transform);
-
- return true;
- }
- }
- return false;
- }();
-
- if (!hasLookAt)
- {
- float hit_distance = 0.0f;
- AZ::Plane::CreateFromNormalAndPoint(AZ::Vector3::CreateAxisZ(), AZ::Vector3::CreateAxisZ(ed_cameraSystemDefaultPlaneHeight))
- .CastRay(targetCamera.Translation(), targetCamera.Rotation().GetBasisY(), hit_distance);
-
- if (hit_distance > 0.0f)
- {
- hit_distance = AZStd::min(hit_distance, ed_cameraSystemMaxOrbitDistance);
- nextCamera.m_lookDist = -hit_distance;
- nextCamera.m_lookAt = targetCamera.Translation() + targetCamera.Rotation().GetBasisY() * hit_distance;
- }
- else
- {
- nextCamera.m_lookDist = -ed_cameraSystemMinOrbitDistance;
- nextCamera.m_lookAt =
- targetCamera.Translation() + targetCamera.Rotation().GetBasisY() * ed_cameraSystemMinOrbitDistance;
- }
- }
+ nextCamera.m_pivot = m_pivotFn(targetCamera.Translation(), targetCamera.Rotation().GetBasisY());
+ nextCamera.m_offset = nextCamera.View().TransformPoint(targetCamera.Translation());
}
if (Active())
{
- nextCamera = m_orbitCameras.StepCamera(nextCamera, cursorDelta, scrollDelta, deltaTime);
+ MovePivotDetached(nextCamera, m_pivotFn(targetCamera.Translation(), targetCamera.Rotation().GetBasisY()));
+ nextCamera = m_pivotCameras.StepCamera(nextCamera, cursorDelta, scrollDelta, deltaTime);
}
if (Ending())
{
- m_orbitCameras.Reset();
+ m_pivotCameras.Reset();
- nextCamera.m_lookAt = nextCamera.Translation();
- nextCamera.m_lookDist = 0.0f;
+ nextCamera.m_pivot = nextCamera.Translation();
+ nextCamera.m_offset = AZ::Vector3::CreateZero();
}
return nextCamera;
}
- void OrbitCameraInput::SetOrbitInputChannelId(const InputChannelId& orbitChanneId)
+ void PivotCameraInput::SetPivotInputChannelId(const InputChannelId& pivotChanneId)
{
- m_orbitChannelId = orbitChanneId;
+ m_pivotChannelId = pivotChanneId;
}
- OrbitDollyScrollCameraInput::OrbitDollyScrollCameraInput()
+ PivotDollyScrollCameraInput::PivotDollyScrollCameraInput()
{
m_scrollSpeedFn = []() constexpr
{
@@ -654,7 +608,7 @@ namespace AzFramework
};
}
- bool OrbitDollyScrollCameraInput::HandleEvents(
+ bool PivotDollyScrollCameraInput::HandleEvents(
const InputEvent& event, [[maybe_unused]] const ScreenVector& cursorDelta, [[maybe_unused]] const float scrollDelta)
{
if (const auto* scroll = AZStd::get_if(&event))
@@ -665,46 +619,61 @@ namespace AzFramework
return !Idle();
}
- Camera OrbitDollyScrollCameraInput::StepCamera(
+ static Camera PivotDolly(const Camera& targetCamera, const float delta)
+ {
+ Camera nextCamera = targetCamera;
+
+ const auto pivotDirection = targetCamera.m_offset.GetNormalized();
+ nextCamera.m_offset -= pivotDirection * delta;
+ const auto pivotDot = targetCamera.m_offset.Dot(nextCamera.m_offset);
+ const auto distance = nextCamera.m_offset.GetLength() * AZ::GetSign(pivotDot);
+
+ const auto minDistance = 0.01f;
+ if (distance < minDistance || pivotDot < 0.0f)
+ {
+ nextCamera.m_offset = pivotDirection * minDistance;
+ }
+
+ return nextCamera;
+ }
+
+ Camera PivotDollyScrollCameraInput::StepCamera(
const Camera& targetCamera,
[[maybe_unused]] const ScreenVector& cursorDelta,
const float scrollDelta,
[[maybe_unused]] const float deltaTime)
{
- Camera nextCamera = targetCamera;
- nextCamera.m_lookDist = AZ::GetMin(nextCamera.m_lookDist + scrollDelta * m_scrollSpeedFn(), 0.0f);
+ const auto nextCamera = PivotDolly(targetCamera, aznumeric_cast(scrollDelta) * m_scrollSpeedFn());
EndActivation();
return nextCamera;
}
- OrbitDollyCursorMoveCameraInput::OrbitDollyCursorMoveCameraInput(const InputChannelId& dollyChannelId)
+ PivotDollyMotionCameraInput::PivotDollyMotionCameraInput(const InputChannelId& dollyChannelId)
: m_dollyChannelId(dollyChannelId)
{
- m_cursorSpeedFn = []() constexpr
+ m_motionSpeedFn = []() constexpr
{
return 0.01f;
};
}
- bool OrbitDollyCursorMoveCameraInput::HandleEvents(
+ bool PivotDollyMotionCameraInput::HandleEvents(
const InputEvent& event, [[maybe_unused]] const ScreenVector& cursorDelta, [[maybe_unused]] const float scrollDelta)
{
HandleActivationEvents(event, m_dollyChannelId, cursorDelta, m_clickDetector, *this);
return CameraInputUpdatingAfterMotion(*this);
}
- Camera OrbitDollyCursorMoveCameraInput::StepCamera(
+ Camera PivotDollyMotionCameraInput::StepCamera(
const Camera& targetCamera,
const ScreenVector& cursorDelta,
[[maybe_unused]] const float scrollDelta,
[[maybe_unused]] const float deltaTime)
{
- Camera nextCamera = targetCamera;
- nextCamera.m_lookDist = AZ::GetMin(nextCamera.m_lookDist + float(cursorDelta.m_y) * m_cursorSpeedFn(), 0.0f);
- return nextCamera;
+ return PivotDolly(targetCamera, aznumeric_cast(cursorDelta.m_y) * m_motionSpeedFn());
}
- void OrbitDollyCursorMoveCameraInput::SetDollyInputChannelId(const InputChannelId& dollyChannelId)
+ void PivotDollyMotionCameraInput::SetDollyInputChannelId(const InputChannelId& dollyChannelId)
{
m_dollyChannelId = dollyChannelId;
}
@@ -739,7 +708,7 @@ namespace AzFramework
const auto translation_basis = LookTranslation(nextCamera);
const auto axisY = translation_basis.GetBasisY();
- nextCamera.m_lookAt += axisY * scrollDelta * m_scrollSpeedFn();
+ nextCamera.m_pivot += axisY * scrollDelta * m_scrollSpeedFn();
EndActivation();
@@ -790,13 +759,13 @@ namespace AzFramework
{
const float moveRate = AZStd::exp2(cameraProps.m_translateSmoothnessFn());
const float moveTime = AZStd::exp2(-moveRate * deltaTime);
- camera.m_lookDist = AZ::Lerp(targetCamera.m_lookDist, currentCamera.m_lookDist, moveTime);
- camera.m_lookAt = targetCamera.m_lookAt.Lerp(currentCamera.m_lookAt, moveTime);
+ camera.m_pivot = targetCamera.m_pivot.Lerp(currentCamera.m_pivot, moveTime);
+ camera.m_offset = targetCamera.m_offset.Lerp(currentCamera.m_offset, moveTime);
}
else
{
- camera.m_lookDist = targetCamera.m_lookDist;
- camera.m_lookAt = targetCamera.m_lookAt;
+ camera.m_pivot = targetCamera.m_pivot;
+ camera.m_offset = targetCamera.m_offset;
}
return camera;
diff --git a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h
index 69e8b66434..c44d951292 100644
--- a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h
+++ b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h
@@ -29,17 +29,15 @@ namespace AzFramework
//! @note Order of rotation is Z, Y, X.
AZ::Vector3 EulerAngles(const AZ::Matrix3x3& orientation);
- //! A simple camera representation using spherical coordinates as input (pitch, yaw and look distance).
+ //! A simple camera representation using spherical coordinates as input (pitch, yaw, pivot and offset).
//! The cameras transform and view can be obtained through accessor functions that use the internal
//! spherical coordinates to calculate the position and orientation.
struct Camera
{
- AZ::Vector3 m_lookAt = AZ::Vector3::CreateZero(); //!< Position of camera when m_lookDist is zero,
- //!< or position of m_lookAt when m_lookDist is greater
- //!< than zero.
- float m_yaw{ 0.0 }; //!< Yaw rotation of camera (stored in radians) usually clamped to 0-360 degrees (0-2Pi radians).
- float m_pitch{ 0.0 }; //!< Pitch rotation of the camera (stored in radians) usually clamped to +/-90 degrees (-Pi/2 - Pi/2 radians).
- float m_lookDist{ 0.0 }; //!< Zero gives first person free look, otherwise orbit about m_lookAt
+ AZ::Vector3 m_pivot = AZ::Vector3::CreateZero(); //!< Pivot point to rotate about (modified in world space).
+ AZ::Vector3 m_offset = AZ::Vector3::CreateZero(); //!< Offset relative to pivot (modified in camera space).
+ float m_yaw = 0.0f; //!< Yaw rotation of camera (stored in radians) usually clamped to 0-360 degrees (0-2Pi radians).
+ float m_pitch = 0.0f; //!< Pitch rotation of the camera (stored in radians) usually clamped to +/-90 degrees (-Pi/2 - Pi/2 radians).
//! View camera transform (V in model-view-projection matrix (MVP)).
AZ::Transform View() const;
@@ -51,6 +49,15 @@ namespace AzFramework
AZ::Vector3 Translation() const;
};
+ //! Helper to allow the pivot to be positioned without altering the camera's position.
+ inline void MovePivotDetached(Camera& camera, const AZ::Vector3& pivot)
+ {
+ const auto& view = camera.View();
+ const auto delta = view.TransformPoint(pivot) - view.TransformPoint(camera.m_pivot);
+ camera.m_offset -= delta;
+ camera.m_pivot = pivot;
+ }
+
inline AZ::Transform Camera::View() const
{
return Transform().GetInverse();
@@ -58,8 +65,8 @@ namespace AzFramework
inline AZ::Transform Camera::Transform() const
{
- return AZ::Transform::CreateTranslation(m_lookAt) * AZ::Transform::CreateRotationZ(m_yaw) *
- AZ::Transform::CreateRotationX(m_pitch) * AZ::Transform::CreateTranslation(AZ::Vector3::CreateAxisY(m_lookDist));
+ return AZ::Transform::CreateTranslation(m_pivot) * AZ::Transform::CreateRotationZ(m_yaw) * AZ::Transform::CreateRotationX(m_pitch) *
+ AZ::Transform::CreateTranslation(m_offset);
}
inline AZ::Matrix3x3 Camera::Rotation() const
@@ -279,21 +286,37 @@ namespace AzFramework
public:
bool HandleEvents(const InputEvent& event);
Camera StepCamera(const Camera& targetCamera, float deltaTime);
- bool HandlingEvents() const
- {
- return m_handlingEvents;
- }
+ bool HandlingEvents() const;
Cameras m_cameras; //!< Represents a collection of camera inputs that together provide a camera controller.
private:
- ScreenVector m_motionDelta; //!< The delta used for look/orbit/pan (rotation + translation) - two dimensional.
+ ScreenVector m_motionDelta; //!< The delta used for look/pivot/pan (rotation + translation) - two dimensional.
CursorState m_cursorState; //!< The current and previous position of the cursor (used to calculate movement delta).
float m_scrollDelta = 0.0f; //!< The delta used for dolly/movement (translation) - one dimensional.
bool m_handlingEvents = false; //!< Is the camera system currently handling events (events are consumed and not propagated).
};
- //! A camera input to handle motion deltas that can rotate or orbit the camera.
+ inline bool CameraSystem::HandlingEvents() const
+ {
+ return m_handlingEvents;
+ }
+
+ //! Clamps pitch to be +/-90 degrees (-Pi/2, Pi/2).
+ //! @param pitch Pitch angle in radians.
+ inline float ClampPitchRotation(const float pitch)
+ {
+ return AZ::GetClamp(pitch, -AZ::Constants::HalfPi, AZ::Constants::HalfPi);
+ }
+
+ //! Ensures yaw wraps between 0 and 360 degrees (0, 2Pi).
+ //! @param yaw Yaw angle in radians.
+ inline float WrapYawRotation(const float yaw)
+ {
+ return AZStd::fmod(yaw + AZ::Constants::TwoPi, AZ::Constants::TwoPi);
+ }
+
+ //! A camera input to handle motion deltas that can rotate or pivot the camera.
class RotateCameraInput : public CameraInput
{
public:
@@ -332,8 +355,8 @@ namespace AzFramework
return { orientation.GetBasisX(), orientation.GetBasisZ() };
}
- //! PanAxes to use while in 'orbit' camera behavior.
- inline PanAxes OrbitPan(const Camera& camera)
+ //! PanAxes to use while in 'pivot' camera behavior.
+ inline PanAxes PivotPan(const Camera& camera)
{
const AZ::Matrix3x3 orientation = camera.Rotation();
@@ -347,11 +370,23 @@ namespace AzFramework
return { basisX, basisY };
}
+ using TranslationDeltaFn = AZStd::function;
+
+ inline void TranslatePivot(Camera& camera, const AZ::Vector3& delta)
+ {
+ camera.m_pivot += delta;
+ }
+
+ inline void TranslateOffset(Camera& camera, const AZ::Vector3& delta)
+ {
+ camera.m_offset += camera.View().TransformVector(delta);
+ }
+
//! A camera input to handle motion deltas that can pan the camera (translate in two axes).
class PanCameraInput : public CameraInput
{
public:
- PanCameraInput(const InputChannelId& panChannelId, PanAxesFn panAxesFn);
+ PanCameraInput(const InputChannelId& panChannelId, PanAxesFn panAxesFn, TranslationDeltaFn translationDeltaFn);
// CameraInput overrides ...
bool HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override;
@@ -365,6 +400,7 @@ namespace AzFramework
private:
PanAxesFn m_panAxesFn; //!< Builder for the particular pan axes (provided in the constructor).
+ TranslationDeltaFn m_translationDeltaFn; //!< How to apply the translation delta to the camera offset or pivot.
InputChannelId m_panChannelId; //!< Input channel to begin the pan camera input.
ClickDetector m_clickDetector; //!< Used to determine when a sufficient motion delta has occurred after an initial discrete input
//!< event has started (press and move event).
@@ -385,8 +421,8 @@ namespace AzFramework
return AZ::Matrix3x3::CreateFromColumns(basisX, basisY, basisZ);
}
- //! TranslationAxes to use while in 'orbit' camera behavior.
- inline AZ::Matrix3x3 OrbitTranslation(const Camera& camera)
+ //! TranslationAxes to use while in 'pivot' camera behavior.
+ inline AZ::Matrix3x3 PivotTranslation(const Camera& camera)
{
const AZ::Matrix3x3 orientation = camera.Rotation();
@@ -417,8 +453,10 @@ namespace AzFramework
class TranslateCameraInput : public CameraInput
{
public:
- explicit TranslateCameraInput(
- TranslationAxesFn translationAxesFn, const TranslateCameraInputChannelIds& translateCameraInputChannelIds);
+ TranslateCameraInput(
+ const TranslateCameraInputChannelIds& translateCameraInputChannelIds,
+ TranslationAxesFn translationAxesFn,
+ TranslationDeltaFn translateDeltaFn);
// CameraInput overrides ...
bool HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override;
@@ -492,15 +530,16 @@ namespace AzFramework
TranslationType m_translation = TranslationType::Nil; //!< Types of translation the camera input is under.
TranslationAxesFn m_translationAxesFn; //!< Builder for translation axes.
+ TranslationDeltaFn m_translateDeltaFn; //!< How to apply the translation delta to the camera offset or pivot.
TranslateCameraInputChannelIds m_translateCameraInputChannelIds; //!< Input channel ids that map to internal translation types.
bool m_boost = false; //!< Is the translation speed currently being multiplied/scaled upwards.
};
- //! A camera input to handle discrete scroll events that can modify the camera look distance.
- class OrbitDollyScrollCameraInput : public CameraInput
+ //! A camera input to handle discrete scroll events that can modify the camera pivot distance.
+ class PivotDollyScrollCameraInput : public CameraInput
{
public:
- OrbitDollyScrollCameraInput();
+ PivotDollyScrollCameraInput();
// CameraInput overrides ...
bool HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override;
@@ -509,11 +548,11 @@ namespace AzFramework
AZStd::function m_scrollSpeedFn;
};
- //! A camera input to handle motion deltas that can modify the camera look distance.
- class OrbitDollyCursorMoveCameraInput : public CameraInput
+ //! A camera input to handle motion deltas that can modify the camera pivot distance.
+ class PivotDollyMotionCameraInput : public CameraInput
{
public:
- explicit OrbitDollyCursorMoveCameraInput(const InputChannelId& dollyChannelId);
+ explicit PivotDollyMotionCameraInput(const InputChannelId& dollyChannelId);
// CameraInput overrides ...
bool HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override;
@@ -521,7 +560,7 @@ namespace AzFramework
void SetDollyInputChannelId(const InputChannelId& dollyChannelId);
- AZStd::function m_cursorSpeedFn;
+ AZStd::function m_motionSpeedFn;
private:
InputChannelId m_dollyChannelId; //!< Input channel to begin the dolly cursor camera input.
@@ -544,36 +583,36 @@ namespace AzFramework
//! A camera input that doubles as its own set of camera inputs.
//! It is 'exclusive', so does not overlap with other sibling camera inputs - it runs its own set of camera inputs as 'children'.
- class OrbitCameraInput : public CameraInput
+ class PivotCameraInput : public CameraInput
{
public:
- using LookAtFn = AZStd::function(const AZ::Vector3& position, const AZ::Vector3& direction)>;
+ using PivotFn = AZStd::function;
- explicit OrbitCameraInput(const InputChannelId& orbitChannelId);
+ explicit PivotCameraInput(const InputChannelId& pivotChannelId);
// CameraInput overrides ...
bool HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override;
Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override;
bool Exclusive() const override;
- void SetOrbitInputChannelId(const InputChannelId& orbitChanneId);
+ void SetPivotInputChannelId(const InputChannelId& pivotChanneId);
- Cameras m_orbitCameras; //!< The camera inputs to run when this camera input is active (only these will run as it is exclusive).
+ Cameras m_pivotCameras; //!< The camera inputs to run when this camera input is active (only these will run as it is exclusive).
- //! Override the default behavior for how a look-at point is calculated.
- void SetLookAtFn(const LookAtFn& lookAtFn);
+ //! Override the default behavior for how a pivot point is calculated.
+ void SetPivotFn(PivotFn pivotFn);
private:
- InputChannelId m_orbitChannelId; //!< Input channel to begin the orbit camera input.
- LookAtFn m_lookAtFn; //!< The look-at behavior to use for this orbit camera (how is the look-at point calculated/retrieved).
+ InputChannelId m_pivotChannelId; //!< Input channel to begin the pivot camera input.
+ PivotFn m_pivotFn; //!< The pivot position to use for this pivot camera (how is the pivot point calculated/retrieved).
};
- inline void OrbitCameraInput::SetLookAtFn(const LookAtFn& lookAtFn)
+ inline void PivotCameraInput::SetPivotFn(PivotFn pivotFn)
{
- m_lookAtFn = lookAtFn;
+ m_pivotFn = AZStd::move(pivotFn);
}
- inline bool OrbitCameraInput::Exclusive() const
+ inline bool PivotCameraInput::Exclusive() const
{
return true;
}
diff --git a/Code/Framework/AzFramework/AzFramework/Viewport/ScreenGeometry.h b/Code/Framework/AzFramework/AzFramework/Viewport/ScreenGeometry.h
index c0fa1ad631..1529d760e5 100644
--- a/Code/Framework/AzFramework/AzFramework/Viewport/ScreenGeometry.h
+++ b/Code/Framework/AzFramework/AzFramework/Viewport/ScreenGeometry.h
@@ -8,11 +8,10 @@
#pragma once
-#include
-#include
-#include
-#include
#include
+#include
+#include
+#include
namespace AZ
{
@@ -27,7 +26,11 @@ namespace AzFramework
AZ_TYPE_INFO(ScreenPoint, "{8472B6C2-527F-44FC-87F8-C226B1A57A97}");
ScreenPoint() = default;
- ScreenPoint(int x, int y) : m_x(x), m_y(y) {}
+ ScreenPoint(int x, int y)
+ : m_x(x)
+ , m_y(y)
+ {
+ }
int m_x; //!< X screen position.
int m_y; //!< Y screen position.
@@ -42,7 +45,11 @@ namespace AzFramework
AZ_TYPE_INFO(ScreenVector, "{1EAA2C62-8FDB-4A28-9FE3-1FA4F1418894}");
ScreenVector() = default;
- ScreenVector(int x, int y) : m_x(x), m_y(y) {}
+ ScreenVector(int x, int y)
+ : m_x(x)
+ , m_y(y)
+ {
+ }
int m_x; //!< X screen delta.
int m_y; //!< Y screen delta.
@@ -71,14 +78,14 @@ namespace AzFramework
inline const ScreenPoint operator+(const ScreenPoint& lhs, const ScreenVector& rhs)
{
- ScreenPoint result{lhs};
+ ScreenPoint result{ lhs };
result += rhs;
return result;
}
inline const ScreenPoint operator-(const ScreenPoint& lhs, const ScreenVector& rhs)
{
- ScreenPoint result{lhs};
+ ScreenPoint result{ lhs };
result -= rhs;
return result;
}
@@ -99,14 +106,14 @@ namespace AzFramework
inline const ScreenVector operator+(const ScreenVector& lhs, const ScreenVector& rhs)
{
- ScreenVector result{lhs};
+ ScreenVector result{ lhs };
result += rhs;
return result;
}
inline const ScreenVector operator-(const ScreenVector& lhs, const ScreenVector& rhs)
{
- ScreenVector result{lhs};
+ ScreenVector result{ lhs };
result -= rhs;
return result;
}
@@ -131,23 +138,25 @@ namespace AzFramework
return !operator==(lhs, rhs);
}
+ inline ScreenVector& operator*=(ScreenVector& lhs, const float rhs)
+ {
+ lhs.m_x = aznumeric_cast(AZStd::lround(aznumeric_cast(lhs.m_x) * rhs));
+ lhs.m_y = aznumeric_cast(AZStd::lround(aznumeric_cast(lhs.m_y) * rhs));
+ return lhs;
+ }
+
+ inline const ScreenVector operator*(const ScreenVector& lhs, const float rhs)
+ {
+ ScreenVector result{ lhs };
+ result *= rhs;
+ return result;
+ }
+
inline float ScreenVectorLength(const ScreenVector& screenVector)
{
return aznumeric_cast(AZStd::sqrt(screenVector.m_x * screenVector.m_x + screenVector.m_y * screenVector.m_y));
}
- inline ScreenPoint ScreenPointFromNDC(const AZ::Vector3& screenNDC, const AZ::Vector2& viewportSize)
- {
- return ScreenPoint(
- aznumeric_caster(AZStd::round(screenNDC.GetX() * viewportSize.GetX())),
- aznumeric_caster(AZStd::round((1.0f - screenNDC.GetY()) * viewportSize.GetY())));
- }
-
- inline AZ::Vector2 NDCFromScreenPoint(const ScreenPoint& screenPoint, const AZ::Vector2& viewportSize)
- {
- return AZ::Vector2(aznumeric_cast(screenPoint.m_x), viewportSize.GetY() - aznumeric_cast(screenPoint.m_y)) / viewportSize;
- }
-
//! Return an AZ::Vector2 from a ScreenPoint.
inline AZ::Vector2 Vector2FromScreenPoint(const ScreenPoint& screenPoint)
{
diff --git a/Code/Framework/AzFramework/AzFramework/Viewport/ViewportScreen.cpp b/Code/Framework/AzFramework/AzFramework/Viewport/ViewportScreen.cpp
index a94b806ad3..afd16a6c23 100644
--- a/Code/Framework/AzFramework/AzFramework/Viewport/ViewportScreen.cpp
+++ b/Code/Framework/AzFramework/AzFramework/Viewport/ViewportScreen.cpp
@@ -23,7 +23,7 @@ namespace AzFramework
// y-up, z into the screen, x-left
//
// x -> -x
- // y -> z
+ // y -> z
// z -> y
//
// the same transform can be used to go to/from z-up - the only difference is the order of
@@ -37,15 +37,15 @@ namespace AzFramework
// yaw = AZ::Matrix4x4::CreateRotationZ(AZ::DegToRad(180.0f));
// conversion = pitch * yaw
return AZ::Matrix4x4::CreateFromColumns(
- AZ::Vector4(-1.0f, 0.0f, 0.0f, 0.0f), AZ::Vector4(0.0f, 0.0f, 1.0f, .0f),
- AZ::Vector4(0.0f, 1.0f, 0.0f, 0.0f), AZ::Vector4(0.0f, 0.0f, 0.0f, 1.0f));
+ AZ::Vector4(-1.0f, 0.0f, 0.0f, 0.0f), AZ::Vector4(0.0f, 0.0f, 1.0f, 0.0f), AZ::Vector4(0.0f, 1.0f, 0.0f, 0.0f),
+ AZ::Vector4(0.0f, 0.0f, 0.0f, 1.0f));
}
AZ::Matrix4x4 CameraTransform(const CameraState& cameraState)
{
return AZ::Matrix4x4::CreateFromColumns(
- AZ::Vector3ToVector4(cameraState.m_side), AZ::Vector3ToVector4(cameraState.m_forward),
- AZ::Vector3ToVector4(cameraState.m_up), AZ::Vector3ToVector4(cameraState.m_position, 1.0f));
+ AZ::Vector3ToVector4(cameraState.m_side), AZ::Vector3ToVector4(cameraState.m_forward), AZ::Vector3ToVector4(cameraState.m_up),
+ AZ::Vector3ToVector4(cameraState.m_position, 1.0f));
}
AZ::Matrix4x4 CameraView(const CameraState& cameraState)
@@ -63,8 +63,7 @@ namespace AzFramework
AZ::Matrix4x4 CameraProjection(const CameraState& cameraState)
{
return AZ::Matrix4x4::CreateProjection(
- cameraState.VerticalFovRadian(), AspectRatio(cameraState.m_viewportSize), cameraState.m_nearClip,
- cameraState.m_farClip);
+ cameraState.VerticalFovRadian(), AspectRatio(cameraState.m_viewportSize), cameraState.m_nearClip, cameraState.m_farClip);
}
AZ::Matrix4x4 InverseCameraProjection(const CameraState& cameraState)
@@ -93,12 +92,11 @@ namespace AzFramework
const auto cameraWorldTransform = AZ::Transform::CreateFromMatrix3x3AndTranslation(
AZ::Matrix3x3::CreateFromMatrix4x4(worldFromView), worldFromView.GetTranslation());
return AZ::ViewFrustumAttributes(
- cameraWorldTransform, AspectRatio(cameraState.m_viewportSize), cameraState.m_fovOrZoom,
- cameraState.m_nearClip, cameraState.m_farClip);
+ cameraWorldTransform, AspectRatio(cameraState.m_viewportSize), cameraState.m_fovOrZoom, cameraState.m_nearClip,
+ cameraState.m_farClip);
}
- AZ::Vector3 WorldToScreenNDC(
- const AZ::Vector3& worldPosition, const AZ::Matrix4x4& cameraView, const AZ::Matrix4x4& cameraProjection)
+ AZ::Vector3 WorldToScreenNdc(const AZ::Vector3& worldPosition, const AZ::Matrix4x4& cameraView, const AZ::Matrix4x4& cameraProjection)
{
// transform the world space position to clip space
const auto clipSpacePosition = cameraProjection * cameraView * AZ::Vector3ToVector4(worldPosition, 1.0f);
@@ -108,25 +106,24 @@ namespace AzFramework
return (AZ::Vector4ToVector3(ndcPosition) + AZ::Vector3::CreateOne()) * 0.5f;
}
-
ScreenPoint WorldToScreen(
- const AZ::Vector3& worldPosition, const AZ::Matrix4x4& cameraView, const AZ::Matrix4x4& cameraProjection,
+ const AZ::Vector3& worldPosition,
+ const AZ::Matrix4x4& cameraView,
+ const AZ::Matrix4x4& cameraProjection,
const AZ::Vector2& viewportSize)
{
- const auto ndcNormalizedPosition = WorldToScreenNDC(worldPosition, cameraView, cameraProjection);
+ const auto ndcNormalizedPosition = WorldToScreenNdc(worldPosition, cameraView, cameraProjection);
// scale ndc position by screen dimensions to return screen position
- return ScreenPointFromNDC(ndcNormalizedPosition, viewportSize);
+ return ScreenPointFromNdc(AZ::Vector3ToVector2(ndcNormalizedPosition), viewportSize);
}
ScreenPoint WorldToScreen(const AZ::Vector3& worldPosition, const CameraState& cameraState)
{
- return WorldToScreen(
- worldPosition, CameraView(cameraState), CameraProjection(cameraState), cameraState.m_viewportSize);
+ return WorldToScreen(worldPosition, CameraView(cameraState), CameraProjection(cameraState), cameraState.m_viewportSize);
}
- AZ::Vector3 ScreenNDCToWorld(
- const AZ::Vector2& normalizedScreenPosition, const AZ::Matrix4x4& inverseCameraView,
- const AZ::Matrix4x4& inverseCameraProjection)
+ AZ::Vector3 ScreenNdcToWorld(
+ const AZ::Vector2& normalizedScreenPosition, const AZ::Matrix4x4& inverseCameraView, const AZ::Matrix4x4& inverseCameraProjection)
{
// convert screen space coordinates from <0, 1> to <-1,1> range
const auto ndcPosition = normalizedScreenPosition * 2.0f - AZ::Vector2::CreateOne();
@@ -142,18 +139,19 @@ namespace AzFramework
}
AZ::Vector3 ScreenToWorld(
- const ScreenPoint& screenPosition, const AZ::Matrix4x4& inverseCameraView,
- const AZ::Matrix4x4& inverseCameraProjection, const AZ::Vector2& viewportSize)
+ const ScreenPoint& screenPosition,
+ const AZ::Matrix4x4& inverseCameraView,
+ const AZ::Matrix4x4& inverseCameraProjection,
+ const AZ::Vector2& viewportSize)
{
- const auto normalizedScreenPosition = NDCFromScreenPoint(screenPosition, viewportSize);
+ const auto normalizedScreenPosition = NdcFromScreenPoint(screenPosition, viewportSize);
- return ScreenNDCToWorld(normalizedScreenPosition, inverseCameraView, inverseCameraProjection);
+ return ScreenNdcToWorld(normalizedScreenPosition, inverseCameraView, inverseCameraProjection);
}
AZ::Vector3 ScreenToWorld(const ScreenPoint& screenPosition, const CameraState& cameraState)
{
return ScreenToWorld(
- screenPosition, InverseCameraView(cameraState), InverseCameraProjection(cameraState),
- cameraState.m_viewportSize);
+ screenPosition, InverseCameraView(cameraState), InverseCameraProjection(cameraState), cameraState.m_viewportSize);
}
} // namespace AzFramework
diff --git a/Code/Framework/AzFramework/AzFramework/Viewport/ViewportScreen.h b/Code/Framework/AzFramework/AzFramework/Viewport/ViewportScreen.h
index 87bad66eab..8a6c0249b2 100644
--- a/Code/Framework/AzFramework/AzFramework/Viewport/ViewportScreen.h
+++ b/Code/Framework/AzFramework/AzFramework/Viewport/ViewportScreen.h
@@ -8,26 +8,42 @@
#pragma once
+#include
#include
+#include
+#include
namespace AZ
{
class Frustum;
class Matrix4x4;
- class Vector3;
struct ViewFrustumAttributes;
} // namespace AZ
namespace AzFramework
{
struct CameraState;
- struct ScreenPoint;
struct ViewportInfo;
- //! Projects a position in world space to screen space normalized device coordinates for the given camera.
- AZ::Vector3 WorldToScreenNDC(
- const AZ::Vector3& worldPosition, const AZ::Matrix4x4& cameraView, const AZ::Matrix4x4& cameraProjection);
+ //! Returns a position in screen space (in the range [0-viewportSize.x, 0-viewportSize.y]) from normalized device
+ //! coordinates (in the range 0.0-1.0).
+ inline ScreenPoint ScreenPointFromNdc(const AZ::Vector2& screenNdc, const AZ::Vector2& viewportSize)
+ {
+ return ScreenPoint(
+ aznumeric_cast(AZStd::lround(screenNdc.GetX() * viewportSize.GetX())),
+ aznumeric_cast(AZStd::lround((1.0f - screenNdc.GetY()) * viewportSize.GetY())));
+ }
+ //! Returns a position in normalized device coordinates (in the range [0.0-1.0, 0.0-1.0]) from a
+ //! screen space position (in the range [0-viewportSize.x, 0-viewportSize.y]).
+ inline AZ::Vector2 NdcFromScreenPoint(const ScreenPoint& screenPoint, const AZ::Vector2& viewportSize)
+ {
+ return AZ::Vector2(aznumeric_cast(screenPoint.m_x), viewportSize.GetY() - aznumeric_cast(screenPoint.m_y)) /
+ viewportSize;
+ }
+
+ //! Projects a position in world space to screen space normalized device coordinates for the given camera.
+ AZ::Vector3 WorldToScreenNdc(const AZ::Vector3& worldPosition, const AZ::Matrix4x4& cameraView, const AZ::Matrix4x4& cameraProjection);
//! Projects a position in world space to screen space for the given camera.
ScreenPoint WorldToScreen(const AZ::Vector3& worldPosition, const CameraState& cameraState);
@@ -35,7 +51,9 @@ namespace AzFramework
//! Overload of WorldToScreen that accepts camera values that can be precomputed if this function
//! is called many times in a loop.
ScreenPoint WorldToScreen(
- const AZ::Vector3& worldPosition, const AZ::Matrix4x4& cameraView, const AZ::Matrix4x4& cameraProjection,
+ const AZ::Vector3& worldPosition,
+ const AZ::Matrix4x4& cameraView,
+ const AZ::Matrix4x4& cameraProjection,
const AZ::Vector2& viewportSize);
//! Unprojects a position in screen space pixel coordinates to world space.
@@ -45,14 +63,15 @@ namespace AzFramework
//! Overload of ScreenToWorld that accepts camera values that can be precomputed if this function
//! is called many times in a loop.
AZ::Vector3 ScreenToWorld(
- const ScreenPoint& screenPosition, const AZ::Matrix4x4& inverseCameraView,
- const AZ::Matrix4x4& inverseCameraProjection, const AZ::Vector2& viewportSize);
+ const ScreenPoint& screenPosition,
+ const AZ::Matrix4x4& inverseCameraView,
+ const AZ::Matrix4x4& inverseCameraProjection,
+ const AZ::Vector2& viewportSize);
//! Unprojects a position in screen space normalized device coordinates to world space.
//! Note: The position returned will be on the near clip plane of the camera in world space.
- AZ::Vector3 ScreenNDCToWorld(
- const AZ::Vector2& ndcPosition, const AZ::Matrix4x4& inverseCameraView,
- const AZ::Matrix4x4& inverseCameraProjection);
+ AZ::Vector3 ScreenNdcToWorld(
+ const AZ::Vector2& ndcPosition, const AZ::Matrix4x4& inverseCameraView, const AZ::Matrix4x4& inverseCameraProjection);
//! Returns the camera projection for the current camera state.
AZ::Matrix4x4 CameraProjection(const CameraState& cameraState);
diff --git a/Code/Framework/AzFramework/CMakeLists.txt b/Code/Framework/AzFramework/CMakeLists.txt
index 6f6e47855e..f6851f0ab8 100644
--- a/Code/Framework/AzFramework/CMakeLists.txt
+++ b/Code/Framework/AzFramework/CMakeLists.txt
@@ -95,4 +95,4 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
endif()
-endif()
\ No newline at end of file
+endif()
diff --git a/Code/Framework/AzFramework/Platform/Linux/AzFramework/Application/Application_Linux_xcb.cpp b/Code/Framework/AzFramework/Platform/Common/Xcb/AzFramework/XcbApplication.cpp
similarity index 54%
rename from Code/Framework/AzFramework/Platform/Linux/AzFramework/Application/Application_Linux_xcb.cpp
rename to Code/Framework/AzFramework/Platform/Common/Xcb/AzFramework/XcbApplication.cpp
index aaab67b2a1..7cbd9ae0e2 100644
--- a/Code/Framework/AzFramework/Platform/Linux/AzFramework/Application/Application_Linux_xcb.cpp
+++ b/Code/Framework/AzFramework/Platform/Common/Xcb/AzFramework/XcbApplication.cpp
@@ -6,29 +6,26 @@
*
*/
-#include
-#include
-#include "Application_Linux_xcb.h"
+#include
+#include
-////////////////////////////////////////////////////////////////////////////////////////////////////
namespace AzFramework
{
-#if PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
////////////////////////////////////////////////////////////////////////////////////////////////
- class LinuxXcbConnectionManagerImpl
- : public LinuxXcbConnectionManagerBus::Handler
+ class XcbConnectionManagerImpl
+ : public XcbConnectionManagerBus::Handler
{
public:
- LinuxXcbConnectionManagerImpl()
+ XcbConnectionManagerImpl()
{
m_xcbConnection = xcb_connect(nullptr, nullptr);
- AZ_Error("ApplicationLinux", m_xcbConnection != nullptr, "Unable to connect to X11 Server.");
- LinuxXcbConnectionManagerBus::Handler::BusConnect();
+ AZ_Error("Application", m_xcbConnection != nullptr, "Unable to connect to X11 Server.");
+ XcbConnectionManagerBus::Handler::BusConnect();
}
- ~LinuxXcbConnectionManagerImpl()
+ ~XcbConnectionManagerImpl() override
{
- LinuxXcbConnectionManagerBus::Handler::BusDisconnect();
+ XcbConnectionManagerBus::Handler::BusDisconnect();
xcb_disconnect(m_xcbConnection);
}
@@ -42,53 +39,51 @@ namespace AzFramework
};
////////////////////////////////////////////////////////////////////////////////////////////////
- ApplicationLinux_xcb::ApplicationLinux_xcb()
+ XcbApplication::XcbApplication()
{
LinuxLifecycleEvents::Bus::Handler::BusConnect();
- m_xcbConnectionManager = AZStd::make_unique();
- if (LinuxXcbConnectionManagerInterface::Get() == nullptr)
+ m_xcbConnectionManager = AZStd::make_unique();
+ if (XcbConnectionManagerInterface::Get() == nullptr)
{
- LinuxXcbConnectionManagerInterface::Register(m_xcbConnectionManager.get());
+ XcbConnectionManagerInterface::Register(m_xcbConnectionManager.get());
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
- ApplicationLinux_xcb::~ApplicationLinux_xcb()
+ XcbApplication::~XcbApplication()
{
- if (LinuxXcbConnectionManagerInterface::Get() == m_xcbConnectionManager.get())
+ if (XcbConnectionManagerInterface::Get() == m_xcbConnectionManager.get())
{
- LinuxXcbConnectionManagerInterface::Unregister(m_xcbConnectionManager.get());
+ XcbConnectionManagerInterface::Unregister(m_xcbConnectionManager.get());
}
m_xcbConnectionManager.reset();
LinuxLifecycleEvents::Bus::Handler::BusDisconnect();
}
////////////////////////////////////////////////////////////////////////////////////////////////
- void ApplicationLinux_xcb::PumpSystemEventLoopOnce()
+ void XcbApplication::PumpSystemEventLoopOnce()
{
if (xcb_connection_t* xcbConnection = m_xcbConnectionManager->GetXcbConnection())
{
if (xcb_generic_event_t* event = xcb_poll_for_event(xcbConnection))
{
- LinuxXcbEventHandlerBus::Broadcast(&LinuxXcbEventHandlerBus::Events::HandleXcbEvent, event);
+ XcbEventHandlerBus::Broadcast(&XcbEventHandlerBus::Events::HandleXcbEvent, event);
free(event);
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
- void ApplicationLinux_xcb::PumpSystemEventLoopUntilEmpty()
+ void XcbApplication::PumpSystemEventLoopUntilEmpty()
{
if (xcb_connection_t* xcbConnection = m_xcbConnectionManager->GetXcbConnection())
{
while (xcb_generic_event_t* event = xcb_poll_for_event(xcbConnection))
{
- LinuxXcbEventHandlerBus::Broadcast(&LinuxXcbEventHandlerBus::Events::HandleXcbEvent, event);
+ XcbEventHandlerBus::Broadcast(&XcbEventHandlerBus::Events::HandleXcbEvent, event);
free(event);
}
}
}
-#endif // PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
-
} // namespace AzFramework
diff --git a/Code/Framework/AzFramework/Platform/Linux/AzFramework/Application/Application_Linux_xcb.h b/Code/Framework/AzFramework/Platform/Common/Xcb/AzFramework/XcbApplication.h
similarity index 61%
rename from Code/Framework/AzFramework/Platform/Linux/AzFramework/Application/Application_Linux_xcb.h
rename to Code/Framework/AzFramework/Platform/Common/Xcb/AzFramework/XcbApplication.h
index fbd7f165d3..f27b5dd680 100644
--- a/Code/Framework/AzFramework/Platform/Linux/AzFramework/Application/Application_Linux_xcb.h
+++ b/Code/Framework/AzFramework/Platform/Common/Xcb/AzFramework/XcbApplication.h
@@ -5,27 +5,24 @@
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
+
#pragma once
#include
#include
+#include
-////////////////////////////////////////////////////////////////////////////////////////////////////
namespace AzFramework
{
-
-#if PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- class ApplicationLinux_xcb
+ class XcbApplication
: public Application::Implementation
, public LinuxLifecycleEvents::Bus::Handler
{
public:
////////////////////////////////////////////////////////////////////////////////////////////
- AZ_CLASS_ALLOCATOR(ApplicationLinux_xcb, AZ::SystemAllocator, 0);
- ApplicationLinux_xcb();
- ~ApplicationLinux_xcb() override;
+ AZ_CLASS_ALLOCATOR(XcbApplication, AZ::SystemAllocator, 0);
+ XcbApplication();
+ ~XcbApplication() override;
////////////////////////////////////////////////////////////////////////////////////////////
// Application::Implementation
@@ -33,9 +30,6 @@ namespace AzFramework
void PumpSystemEventLoopUntilEmpty() override;
private:
- AZStd::unique_ptr m_xcbConnectionManager;
+ AZStd::unique_ptr m_xcbConnectionManager;
};
-
-#endif // PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
-
} // namespace AzFramework
diff --git a/Code/Framework/AzFramework/Platform/Common/Xcb/AzFramework/XcbConnectionManager.h b/Code/Framework/AzFramework/Platform/Common/Xcb/AzFramework/XcbConnectionManager.h
new file mode 100644
index 0000000000..daa5bf35af
--- /dev/null
+++ b/Code/Framework/AzFramework/Platform/Common/Xcb/AzFramework/XcbConnectionManager.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) Contributors to the Open 3D Engine Project.
+ * For complete copyright and license terms please see the LICENSE at the root of this distribution.
+ *
+ * SPDX-License-Identifier: Apache-2.0 OR MIT
+ *
+ */
+
+#pragma once
+
+#include
+#include
+#include
+
+#include
+
+namespace AzFramework
+{
+ class XcbConnectionManager
+ {
+ public:
+ AZ_RTTI(XcbConnectionManager, "{1F756E14-8D74-42FD-843C-4863307710DB}");
+
+ virtual ~XcbConnectionManager() = default;
+
+ virtual xcb_connection_t* GetXcbConnection() const = 0;
+ };
+
+ class XcbConnectionManagerBusTraits
+ : public AZ::EBusTraits
+ {
+ public:
+ //////////////////////////////////////////////////////////////////////////
+ // EBusTraits overrides
+ static constexpr AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
+ static constexpr AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
+ //////////////////////////////////////////////////////////////////////////
+ };
+
+ using XcbConnectionManagerBus = AZ::EBus