diff --git a/Assets/Editor/Presets/GeomCache/game.cbc b/Assets/Editor/Presets/GeomCache/game.cbc
deleted file mode 100644
index 9b98f3460f..0000000000
--- a/Assets/Editor/Presets/GeomCache/game.cbc
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/Assets/Editor/Presets/GeomCache/game_lz4hc.cbc b/Assets/Editor/Presets/GeomCache/game_lz4hc.cbc
deleted file mode 100644
index dbd0499175..0000000000
--- a/Assets/Editor/Presets/GeomCache/game_lz4hc.cbc
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/Assets/Editor/Presets/GeomCache/game_z_up.cbc b/Assets/Editor/Presets/GeomCache/game_z_up.cbc
deleted file mode 100644
index ec2555a3e3..0000000000
--- a/Assets/Editor/Presets/GeomCache/game_z_up.cbc
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/Assets/Editor/Presets/GeomCache/game_z_up_lz4hc.cbc b/Assets/Editor/Presets/GeomCache/game_z_up_lz4hc.cbc
deleted file mode 100644
index c2e30a6386..0000000000
--- a/Assets/Editor/Presets/GeomCache/game_z_up_lz4hc.cbc
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/Assets/Editor/Presets/GeomCache/prerendered.cbc b/Assets/Editor/Presets/GeomCache/prerendered.cbc
deleted file mode 100644
index c09785111d..0000000000
--- a/Assets/Editor/Presets/GeomCache/prerendered.cbc
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/Assets/Editor/Presets/GeomCache/prerendered_z_up.cbc b/Assets/Editor/Presets/GeomCache/prerendered_z_up.cbc
deleted file mode 100644
index e42a915e58..0000000000
--- a/Assets/Editor/Presets/GeomCache/prerendered_z_up.cbc
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/Assets/Editor/Presets/GeomCache/rigids_only.cbc b/Assets/Editor/Presets/GeomCache/rigids_only.cbc
deleted file mode 100644
index e8620bc11e..0000000000
--- a/Assets/Editor/Presets/GeomCache/rigids_only.cbc
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/Assets/Editor/Presets/GeomCache/rigids_only_z_up.cbc b/Assets/Editor/Presets/GeomCache/rigids_only_z_up.cbc
deleted file mode 100644
index d1f8bc2db3..0000000000
--- a/Assets/Editor/Presets/GeomCache/rigids_only_z_up.cbc
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/Assets/Editor/Presets/GeomCache/uncompressed.cbc b/Assets/Editor/Presets/GeomCache/uncompressed.cbc
deleted file mode 100644
index e21d52d9d1..0000000000
--- a/Assets/Editor/Presets/GeomCache/uncompressed.cbc
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/Assets/Editor/Presets/GeomCache/uncompressed_z_up.cbc b/Assets/Editor/Presets/GeomCache/uncompressed_z_up.cbc
deleted file mode 100644
index 273ce1fbb1..0000000000
--- a/Assets/Editor/Presets/GeomCache/uncompressed_z_up.cbc
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/Assets/Engine/EngineAssets/GeomCaches/defaultGeomCache.abc b/Assets/Engine/EngineAssets/GeomCaches/defaultGeomCache.abc
deleted file mode 100644
index 8ca759d342..0000000000
--- a/Assets/Engine/EngineAssets/GeomCaches/defaultGeomCache.abc
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:9c36d7bc993ddf616f478115a123efabda5b4b833a4e6524312f43c228ae0902
-size 487003
diff --git a/Assets/Engine/EngineAssets/GeomCaches/defaultGeomCache.cbc b/Assets/Engine/EngineAssets/GeomCaches/defaultGeomCache.cbc
deleted file mode 100644
index 3c99ab1627..0000000000
--- a/Assets/Engine/EngineAssets/GeomCaches/defaultGeomCache.cbc
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/Assets/Engine/EngineAssets/GeomCaches/defaultGeomCache.ma b/Assets/Engine/EngineAssets/GeomCaches/defaultGeomCache.ma
deleted file mode 100644
index 65aade11a0..0000000000
--- a/Assets/Engine/EngineAssets/GeomCaches/defaultGeomCache.ma
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:96a21446422b834ea90a5d38eaaca309fdee31dc3cc03c0e9c094b39ec3a459d
-size 4715164
diff --git a/Assets/Engine/EngineAssets/GeomCaches/defaultGeomCache.mtl b/Assets/Engine/EngineAssets/GeomCaches/defaultGeomCache.mtl
deleted file mode 100644
index 05dfe70b09..0000000000
--- a/Assets/Engine/EngineAssets/GeomCaches/defaultGeomCache.mtl
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/AutomatedTesting/Gem/PythonTests/physics/C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain.py b/AutomatedTesting/Gem/PythonTests/physics/C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain.py
index d8e0a6769c..60fa9dc44d 100755
--- a/AutomatedTesting/Gem/PythonTests/physics/C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain.py
+++ b/AutomatedTesting/Gem/PythonTests/physics/C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain.py
@@ -20,7 +20,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
class Tests():
enter_game_mode = ("Entered game mode", "Failed to enter game mode")
find_cylinder = ("Cylinder entity found", "Cylinder entity not found")
- find_terrain = ("Terrain found", "Terrain not found")
+ create_terrain = ("Terrain entity created successfully", "Failed to create Terrain Entity")
+ find_terrain = ("Terrain entity found", "Terrain entity not found")
+ add_physx_shape_collider = ("Added PhysX Shape Collider", "Failed to add PhysX Shape Collider")
+ add_box_shape = ("Added Box Shape", "Failed to add Box Shape")
cylinder_above_terrain = ("Cylinder position above ground", "Cylinder is not above the ground")
time_out = ("No time out occurred", "A time out occurred, please validate level setup")
touched_ground = ("Touched ground before time out", "Did not touch ground before time out")
@@ -40,11 +43,12 @@ def C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain():
Once game mode is entered, the cylinder should fall toward and collide with the terrain.
Steps:
- 1) Open level and enter game mode
- 2) Retrieve entities and positions
- 3) Wait for cylinder to collide with terrain OR time out
- 4) Exit game mode
- 5) Close the editor
+ 1) Open level and create terrain Entity.
+ 2) Enter Game Mode.
+ 3) Retrieve entities and positions
+ 4) Wait for cylinder to collide with terrain OR time out
+ 5) Exit game mode
+ 6) Close the editor
:return:
"""
@@ -54,29 +58,48 @@ def C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain():
import ImportPathHelper as imports
imports.init()
-
+ from editor_python_test_tools.editor_entity_utils import EditorEntity
import azlmbr.legacy.general as general
import azlmbr.bus
+ import azlmbr.math as math
from editor_python_test_tools.utils import Report
from editor_python_test_tools.utils import TestHelper as helper
# Global time out
TIME_OUT = 1.0
- # 1) Open level / Enter game mode
+ # 1) Open level
helper.init_idle()
helper.open_level("Physics", "C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain")
+
+ # Create terrain entity
+ terrain = EditorEntity.create_editor_entity_at([30.0, 30.0, 33.96], "Terrain")
+ Report.result(Tests.create_terrain, terrain.id.IsValid())
+
+ terrain.add_component("PhysX Shape Collider")
+ Report.result(Tests.add_physx_shape_collider, terrain.has_component("PhysX Shape Collider"))
+
+ box_shape_component = terrain.add_component("Box Shape")
+ Report.result(Tests.add_box_shape, terrain.has_component("Box Shape"))
+
+ box_shape_component.set_component_property_value("Box Shape|Box Configuration|Dimensions",
+ math.Vector3(1024.0, 1024.0, 0.01))
+
+ # 2)Enter game mode
helper.enter_game_mode(Tests.enter_game_mode)
- # 2) Retrieve entities and positions
+ # 3) Retrieve entities and positions
cylinder_id = general.find_game_entity("PhysX_Cylinder")
Report.critical_result(Tests.find_cylinder, cylinder_id.IsValid())
+
+
+ terrain_id = general.find_game_entity("Terrain")
+ Report.critical_result(Tests.find_terrain, terrain_id.IsValid())
- terrain_id = general.find_game_entity("PhysX_Terrain")
- Report.critical_result(Tests.find_terrain, terrain_id.IsValid())
- cylinder_pos = azlmbr.components.TransformBus(azlmbr.bus.Event, "GetWorldTM", cylinder_id).GetPosition()
- terrain_pos = azlmbr.components.TransformBus(azlmbr.bus.Event, "GetWorldTM", terrain_id).GetPosition()
+ cylinder_pos = azlmbr.components.TransformBus(azlmbr.bus.Event, "GetWorldTranslation", cylinder_id)
+ #Cylinder position is 64,84,35
+ terrain_pos = azlmbr.components.TransformBus(azlmbr.bus.Event, "GetWorldTranslation", terrain_id)
Report.info_vector3(cylinder_pos, "Cylinder:")
Report.info_vector3(terrain_pos, "Terrain:")
Report.critical_result(
@@ -104,13 +127,13 @@ def C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain():
handler.connect(cylinder_id)
handler.add_callback("OnCollisionBegin", on_collision_begin)
- # 3) Wait for the cylinder to hit the ground OR time out
+ # 4) Wait for the cylinder to hit the ground OR time out
test_completed = helper.wait_for_condition((lambda: TouchGround.value), TIME_OUT)
Report.critical_result(Tests.time_out, test_completed)
Report.result(Tests.touched_ground, TouchGround.value)
- # 4) Exit game mode
+ # 5) Exit game mode
helper.exit_game_mode(Tests.exit_game_mode)
diff --git a/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Main.py b/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Main.py
index 67e855a00e..f81445fe03 100644
--- a/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Main.py
+++ b/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Main.py
@@ -34,4 +34,61 @@ class TestAutomation(TestAutomationBase):
def test_C111111_RigidBody_EnablingGravityWorksUsingNotificationsPoC(self, request, workspace, editor, launcher_platform):
from . import C111111_RigidBody_EnablingGravityWorksUsingNotificationsPoC as test_module
+ self._run_test(request, workspace, editor, test_module)
+
+ @revert_physics_config
+ def test_C5932041_PhysXForceRegion_LocalSpaceForceOnRigidBodies(self, request, workspace, editor, launcher_platform):
+ from . import C5932041_PhysXForceRegion_LocalSpaceForceOnRigidBodies as test_module
+ self._run_test(request, workspace, editor, test_module)
+
+ @revert_physics_config
+ def test_C4044459_Material_DynamicFriction(self, request, workspace, editor, launcher_platform):
+ from . import C4044459_Material_DynamicFriction as test_module
+ self._run_test(request, workspace, editor, test_module)
+
+ @revert_physics_config
+ def test_C15425929_Undo_Redo(self, request, workspace, editor, launcher_platform):
+ from . import C15425929_Undo_Redo as test_module
+ self._run_test(request, workspace, editor, test_module)
+
+ @revert_physics_config
+ def test_C4976243_Collision_SameCollisionGroupDiffCollisionLayers(self, request, workspace, editor,
+ launcher_platform):
+ from . import C4976243_Collision_SameCollisionGroupDiffCollisionLayers as test_module
+ self._run_test(request, workspace, editor, test_module)
+
+ @revert_physics_config
+ def test_C14654881_CharacterController_SwitchLevels(self, request, workspace, editor, launcher_platform):
+ from . import C14654881_CharacterController_SwitchLevels as test_module
+ self._run_test(request, workspace, editor, test_module)
+
+ def test_C17411467_AddPhysxRagdollComponent(self, request, workspace, editor, launcher_platform):
+ from . import C17411467_AddPhysxRagdollComponent as test_module
+ self._run_test(request, workspace, editor, test_module)
+
+ @revert_physics_config
+ def test_C12712453_ScriptCanvas_MultipleRaycastNode(self, request, workspace, editor, launcher_platform):
+ from . import C12712453_ScriptCanvas_MultipleRaycastNode as test_module
+ # Fixme: unexpected_lines = ["Assert"] + test_module.Lines.unexpected
+ self._run_test(request, workspace, editor, test_module)
+
+ @revert_physics_config
+ @fm.file_override('physxsystemconfiguration.setreg','C4982593_PhysXCollider_CollisionLayer.setreg', 'AutomatedTesting/Registry')
+ def test_C4982593_PhysXCollider_CollisionLayerTest(self, request, workspace, editor, launcher_platform):
+ from . import C4982593_PhysXCollider_CollisionLayerTest as test_module
+ self._run_test(request, workspace, editor, test_module)
+
+ @revert_physics_config
+ def test_C18243586_Joints_HingeLeadFollowerCollide(self, request, workspace, editor, launcher_platform):
+ from . import C18243586_Joints_HingeLeadFollowerCollide as test_module
+ self._run_test(request, workspace, editor, test_module)
+
+ @revert_physics_config
+ def test_C4982803_Enable_PxMesh_Option(self, request, workspace, editor, launcher_platform):
+ from . import C4982803_Enable_PxMesh_Option as test_module
+ self._run_test(request, workspace, editor, test_module)
+
+ @revert_physics_config
+ def test_C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain(self, request, workspace, editor, launcher_platform):
+ from . import C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain as test_module
self._run_test(request, workspace, editor, test_module)
\ No newline at end of file
diff --git a/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Periodic.py b/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Periodic.py
index 39ed85a65a..4f91f539ee 100755
--- a/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Periodic.py
+++ b/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Periodic.py
@@ -52,11 +52,6 @@ class TestAutomation(TestAutomationBase):
from . import C4976207_PhysXRigidBodies_KinematicBehavior as test_module
self._run_test(request, workspace, editor, test_module)
- @revert_physics_config
- def test_C5932041_PhysXForceRegion_LocalSpaceForceOnRigidBodies(self, request, workspace, editor, launcher_platform):
- from . import C5932041_PhysXForceRegion_LocalSpaceForceOnRigidBodies as test_module
- self._run_test(request, workspace, editor, test_module)
-
@revert_physics_config
def test_C5932042_PhysXForceRegion_LinearDamping(self, request, workspace, editor, launcher_platform):
from . import C5932042_PhysXForceRegion_LinearDamping as test_module
@@ -92,11 +87,6 @@ class TestAutomation(TestAutomationBase):
from . import C4976194_RigidBody_PhysXComponentIsValid as test_module
self._run_test(request, workspace, editor, test_module)
- @revert_physics_config
- def test_C4044459_Material_DynamicFriction(self, request, workspace, editor, launcher_platform):
- from . import C4044459_Material_DynamicFriction as test_module
- self._run_test(request, workspace, editor, test_module)
-
@revert_physics_config
def test_C5932045_ForceRegion_Spline(self, request, workspace, editor, launcher_platform):
from . import C5932045_ForceRegion_Spline as test_module
@@ -208,26 +198,11 @@ class TestAutomation(TestAutomationBase):
from . import C18981526_Material_RestitutionCombinePriority as test_module
self._run_test(request, workspace, editor, test_module)
- @revert_physics_config
- def test_C15425929_Undo_Redo(self, request, workspace, editor, launcher_platform):
- from . import C15425929_Undo_Redo as test_module
- self._run_test(request, workspace, editor, test_module)
-
- @revert_physics_config
- def test_C15308217_NoCrash_LevelSwitch(self, request, workspace, editor, launcher_platform):
- from . import C15308217_NoCrash_LevelSwitch as test_module
- self._run_test(request, workspace, editor, test_module)
-
@revert_physics_config
def test_C12868580_ForceRegion_SplineModifiedTransform(self, request, workspace, editor, launcher_platform):
from . import C12868580_ForceRegion_SplineModifiedTransform as test_module
self._run_test(request, workspace, editor, test_module)
- @revert_physics_config
- def test_C4976243_Collision_SameCollisionGroupDiffCollisionLayers(self, request, workspace, editor, launcher_platform):
- from . import C4976243_Collision_SameCollisionGroupDiffCollisionLayers as test_module
- self._run_test(request, workspace, editor, test_module)
-
@revert_physics_config
def test_C12712455_ScriptCanvas_ShapeCastVerification(self, request, workspace, editor, launcher_platform):
from . import C12712455_ScriptCanvas_ShapeCastVerification as test_module
@@ -248,17 +223,6 @@ class TestAutomation(TestAutomationBase):
from . import C6131473_StaticSlice_OnDynamicSliceSpawn as test_module
self._run_test(request, workspace, editor, test_module)
- @revert_physics_config
- def test_C4982798_Collider_ColliderRotationOffset(self, request, workspace, editor, launcher_platform):
- from . import C4982798_Collider_ColliderRotationOffset as test_module
- self._run_test(request, workspace, editor, test_module)
-
- @revert_physics_config
- def test_C12712453_ScriptCanvas_MultipleRaycastNode(self, request, workspace, editor, launcher_platform):
- from . import C12712453_ScriptCanvas_MultipleRaycastNode as test_module
- # Fixme: unexpected_lines = ["Assert"] + test_module.Lines.unexpected
- self._run_test(request, workspace, editor, test_module)
-
@revert_physics_config
def test_C5959808_ForceRegion_PositionOffset(self, request, workspace, editor, launcher_platform):
from . import C5959808_ForceRegion_PositionOffset as test_module
@@ -275,7 +239,7 @@ class TestAutomation(TestAutomationBase):
def test_C13895144_Ragdoll_ChangeLevel(self, request, workspace, editor, launcher_platform):
from . import C13895144_Ragdoll_ChangeLevel as test_module
self._run_test(request, workspace, editor, test_module)
-
+
@revert_physics_config
def test_C5968759_ForceRegion_ExertsSeveralForcesOnRigidBody(self, request, workspace, editor, launcher_platform):
from . import C5968759_ForceRegion_ExertsSeveralForcesOnRigidBody as test_module
@@ -305,11 +269,6 @@ class TestAutomation(TestAutomationBase):
from . import C5296614_PhysXMaterial_ColliderShape as test_module
self._run_test(request, workspace, editor, test_module)
- @revert_physics_config
- def test_C6090547_ForceRegion_ParentChildForceRegions(self, request, workspace, editor, launcher_platform):
- from . import C6090547_ForceRegion_ParentChildForceRegions as test_module
- self._run_test(request, workspace, editor, test_module)
-
@revert_physics_config
def test_C4982595_Collider_TriggerDisablesCollision(self, request, workspace, editor, launcher_platform):
from . import C4982595_Collider_TriggerDisablesCollision as test_module
@@ -320,11 +279,6 @@ class TestAutomation(TestAutomationBase):
from . import C14976307_Gravity_SetGravityWorks as test_module
self._run_test(request, workspace, editor, test_module)
- @revert_physics_config
- def test_C14654881_CharacterController_SwitchLevels(self, request, workspace, editor, launcher_platform):
- from . import C14654881_CharacterController_SwitchLevels as test_module
- self._run_test(request, workspace, editor, test_module)
-
@revert_physics_config
def test_C15556261_PhysXMaterials_CharacterControllerMaterialAssignment(self, request, workspace, editor, launcher_platform):
from . import C15556261_PhysXMaterials_CharacterControllerMaterialAssignment as test_module
@@ -374,18 +328,6 @@ class TestAutomation(TestAutomationBase):
from . import C4044461_Material_Restitution as test_module
self._run_test(request, workspace, editor, test_module)
- @revert_physics_config
- @fm.file_override('physxsystemconfiguration.setreg','C4982593_PhysXCollider_CollisionLayer.setreg', 'AutomatedTesting/Registry')
- def test_C4982593_PhysXCollider_CollisionLayerTest(self, request, workspace, editor, launcher_platform):
- from . import C4982593_PhysXCollider_CollisionLayerTest as test_module
- self._run_test(request, workspace, editor, test_module)
-
- @revert_physics_config
- @fm.file_override('physxsystemconfiguration.setreg','C3510644_Collider_CollisionGroups.setreg', 'AutomatedTesting/Registry')
- def test_C3510644_Collider_CollisionGroups(self, request, workspace, editor, launcher_platform):
- from . import C3510644_Collider_CollisionGroups as test_module
- self._run_test(request, workspace, editor, test_module)
-
@revert_physics_config
@fm.file_override('physxdefaultsceneconfiguration.setreg','C14902097_ScriptCanvas_PreUpdateEvent.setreg', 'AutomatedTesting/Registry')
def test_C14902097_ScriptCanvas_PreUpdateEvent(self, request, workspace, editor, launcher_platform):
@@ -415,11 +357,6 @@ class TestAutomation(TestAutomationBase):
from . import C18243589_Joints_BallSoftLimitsConstrained as test_module
self._run_test(request, workspace, editor, test_module)
- @revert_physics_config
- def test_C18243586_Joints_HingeLeadFollowerCollide(self, request, workspace, editor, launcher_platform):
- from . import C18243586_Joints_HingeLeadFollowerCollide as test_module
- self._run_test(request, workspace, editor, test_module)
-
@revert_physics_config
def test_C18243591_Joints_BallLeadFollowerCollide(self, request, workspace, editor, launcher_platform):
from . import C18243591_Joints_BallLeadFollowerCollide as test_module
@@ -441,21 +378,11 @@ class TestAutomation(TestAutomationBase):
from . import C14861500_DefaultSetting_ColliderShape as test_module
self._run_test(request, workspace, editor, test_module)
- @revert_physics_config
- def test_C19578021_ShapeCollider_CanBeAdded(self, request, workspace, editor, launcher_platform):
- from . import C19578021_ShapeCollider_CanBeAdded as test_module
- self._run_test(request, workspace, editor, test_module)
-
@revert_physics_config
def test_C19723164_ShapeCollider_WontCrashEditor(self, request, workspace, editor, launcher_platform):
from . import C19723164_ShapeColliders_WontCrashEditor as test_module
self._run_test(request, workspace, editor, test_module)
- @revert_physics_config
- def test_C4982803_Enable_PxMesh_Option(self, request, workspace, editor, launcher_platform):
- from . import C4982803_Enable_PxMesh_Option as test_module
- self._run_test(request, workspace, editor, test_module)
-
@revert_physics_config
def test_C4982800_PhysXColliderShape_CanBeSelected(self, request, workspace, editor, launcher_platform):
from . import C4982800_PhysXColliderShape_CanBeSelected as test_module
@@ -471,10 +398,6 @@ class TestAutomation(TestAutomationBase):
from . import C4982802_PhysXColliderShape_CanBeSelected as test_module
self._run_test(request, workspace, editor, test_module)
- def test_C17411467_AddPhysxRagdollComponent(self, request, workspace, editor, launcher_platform):
- from . import C17411467_AddPhysxRagdollComponent as test_module
- self._run_test(request, workspace, editor, test_module)
-
def test_C12905528_ForceRegion_WithNonTriggerCollider(self, request, workspace, editor, launcher_platform):
from . import C12905528_ForceRegion_WithNonTriggerCollider as test_module
# Fixme: expected_lines = ["[Warning] (PhysX Force Region) - Please ensure collider component marked as trigger exists in entity"]
@@ -522,4 +445,35 @@ class TestAutomation(TestAutomationBase):
def test_C100000_RigidBody_EnablingGravityWorksPoC(self, request, workspace, editor, launcher_platform):
from . import C100000_RigidBody_EnablingGravityWorksPoC as test_module
- self._run_test(request, workspace, editor, test_module)
\ No newline at end of file
+ self._run_test(request, workspace, editor, test_module)
+
+ @revert_physics_config
+ @fm.file_override('physxsystemconfiguration.setreg','C3510644_Collider_CollisionGroups.setreg', 'AutomatedTesting/Registry')
+ def test_C3510644_Collider_CollisionGroups(self, request, workspace, editor, launcher_platform):
+ from . import C3510644_Collider_CollisionGroups as test_module
+ self._run_test(request, workspace, editor, test_module)
+
+ @revert_physics_config
+ def test_C4982798_Collider_ColliderRotationOffset(self, request, workspace, editor, launcher_platform):
+ from . import C4982798_Collider_ColliderRotationOffset as test_module
+ self._run_test(request, workspace, editor, test_module)
+
+ @revert_physics_config
+ def test_C15308217_NoCrash_LevelSwitch(self, request, workspace, editor, launcher_platform):
+ from . import C15308217_NoCrash_LevelSwitch as test_module
+ self._run_test(request, workspace, editor, test_module)
+
+ @revert_physics_config
+ def test_C6090547_ForceRegion_ParentChildForceRegions(self, request, workspace, editor, launcher_platform):
+ from . import C6090547_ForceRegion_ParentChildForceRegions as test_module
+ self._run_test(request, workspace, editor, test_module)
+
+ @revert_physics_config
+ def test_C19578021_ShapeCollider_CanBeAdded(self, request, workspace, editor, launcher_platform):
+ from . import C19578021_ShapeCollider_CanBeAdded as test_module
+ self._run_test(request, workspace, editor, test_module)
+
+ @revert_physics_config
+ def test_C15425929_Undo_Redo(self, request, workspace, editor, launcher_platform):
+ from . import C15425929_Undo_Redo as test_module
+ self._run_test(request, workspace, editor, test_module)
diff --git a/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Sandbox.py b/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Sandbox.py
index 39bc4c8188..e829726ba9 100755
--- a/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Sandbox.py
+++ b/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Sandbox.py
@@ -1,49 +1,49 @@
-"""
-All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-its licensors.
-
-For complete copyright and license terms please see the LICENSE at the root of this
-distribution (the "License"). All use of this software is governed by the License,
-or, if provided, by the license below or the license accompanying this file. Do not
-remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-
-"""
-
-# This suite consists of all test cases that are passing and have been verified.
-
-import pytest
-import os
-import sys
-
-from .FileManagement import FileManagement as fm
-from ly_test_tools import LAUNCHERS
-
-sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../automatedtesting_shared')
-
-from base import TestAutomationBase
-
-
-revert_physics_config = fm.file_revert_list(['physxdebugconfiguration.setreg', 'physxdefaultsceneconfiguration.setreg', 'physxsystemconfiguration.setreg'], 'AutomatedTesting/Registry')
-
-
-@pytest.mark.SUITE_sandbox
-@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
-@pytest.mark.parametrize("project", ["AutomatedTesting"])
-class TestAutomation(TestAutomationBase):
-
- ## Seems to be flaky, need to investigate
- def test_C19536274_GetCollisionName_PrintsName(self, request, workspace, editor, launcher_platform):
- from . import C19536274_GetCollisionName_PrintsName as test_module
- # Fixme: expected_lines=["Layer Name: Right"]
- self._run_test(request, workspace, editor, test_module)
-
- ## Seems to be flaky, need to investigate
- def test_C19536277_GetCollisionName_PrintsNothing(self, request, workspace, editor, launcher_platform):
- from . import C19536277_GetCollisionName_PrintsNothing as test_module
- # All groups present in the PhysX Collider that could show up in test
- # Fixme: collision_groups = ["All", "None", "All_NoTouchBend", "All_3", "None_1", "All_NoTouchBend_1", "All_2", "None_1_1", "All_NoTouchBend_1_1", "All_1", "None_1_1_1", "All_NoTouchBend_1_1_1", "All_4", "None_1_1_1_1", "All_NoTouchBend_1_1_1_1", "GroupLeft", "GroupRight"]
- # Fixme: for group in collision_groups:
- # Fixme: unexpected_lines.append(f"GroupName: {group}")
- # Fixme: expected_lines=["GroupName: "]
- self._run_test(request, workspace, editor, test_module)
\ No newline at end of file
+"""
+All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
+its licensors.
+
+For complete copyright and license terms please see the LICENSE at the root of this
+distribution (the "License"). All use of this software is governed by the License,
+or, if provided, by the license below or the license accompanying this file. Do not
+remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+"""
+
+# This suite consists of all test cases that are passing and have been verified.
+
+import pytest
+import os
+import sys
+
+from .FileManagement import FileManagement as fm
+from ly_test_tools import LAUNCHERS
+
+sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../automatedtesting_shared')
+
+from base import TestAutomationBase
+
+
+revert_physics_config = fm.file_revert_list(['physxdebugconfiguration.setreg', 'physxdefaultsceneconfiguration.setreg', 'physxsystemconfiguration.setreg'], 'AutomatedTesting/Registry')
+
+
+@pytest.mark.SUITE_sandbox
+@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
+@pytest.mark.parametrize("project", ["AutomatedTesting"])
+class TestAutomation(TestAutomationBase):
+
+ ## Seems to be flaky, need to investigate
+ def test_C19536274_GetCollisionName_PrintsName(self, request, workspace, editor, launcher_platform):
+ from . import C19536274_GetCollisionName_PrintsName as test_module
+ # Fixme: expected_lines=["Layer Name: Right"]
+ self._run_test(request, workspace, editor, test_module)
+
+ ## Seems to be flaky, need to investigate
+ def test_C19536277_GetCollisionName_PrintsNothing(self, request, workspace, editor, launcher_platform):
+ from . import C19536277_GetCollisionName_PrintsNothing as test_module
+ # All groups present in the PhysX Collider that could show up in test
+ # Fixme: collision_groups = ["All", "None", "All_NoTouchBend", "All_3", "None_1", "All_NoTouchBend_1", "All_2", "None_1_1", "All_NoTouchBend_1_1", "All_1", "None_1_1_1", "All_NoTouchBend_1_1_1", "All_4", "None_1_1_1_1", "All_NoTouchBend_1_1_1_1", "GroupLeft", "GroupRight"]
+ # Fixme: for group in collision_groups:
+ # Fixme: unexpected_lines.append(f"GroupName: {group}")
+ # Fixme: expected_lines=["GroupName: "]
+ self._run_test(request, workspace, editor, test_module)
diff --git a/AutomatedTesting/Levels/Physics/C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain/C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain.ly b/AutomatedTesting/Levels/Physics/C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain/C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain.ly
index ba141251d5..d618bf1873 100644
--- a/AutomatedTesting/Levels/Physics/C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain/C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain.ly
+++ b/AutomatedTesting/Levels/Physics/C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain/C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain.ly
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:231d5ac32c95334eeb1cbf77ea0bceae1d8010de3290dfdbd991abb46d18bae6
-size 6844
+oid sha256:83af66a6db4ff2b4df7212099b661a96668cfb326d8984e41b16506ec0062141
+size 5844
diff --git a/AutomatedTesting/ShaderLib/raytracingscenesrg.srgi b/AutomatedTesting/ShaderLib/raytracingscenesrg.srgi
deleted file mode 100644
index ac1d663bb8..0000000000
--- a/AutomatedTesting/ShaderLib/raytracingscenesrg.srgi
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-* its licensors.
-*
-* For complete copyright and license terms please see the LICENSE at the root of this
-* distribution (the "License"). All use of this software is governed by the License,
-* or, if provided, by the license below or the license accompanying this file. Do not
-* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-*
-*/
-
-#pragma once
-
-// Please read README.md for an explanation on why scenesrg.srgi and viewsrg.srgi are
-// located in this folder (And how you can optionally customize your own scenesrg.srgi
-// and viewsrg.srgi in your game project).
-
-#include
-
-partial ShaderResourceGroup RayTracingSceneSrg : SRG_RayTracingScene
-{
-/* Intentionally Empty. Helps define the SrgSemantic for RayTracingSceneSrg once.*/
-};
-
-#define AZ_COLLECTING_PARTIAL_SRGS
-#include
-#undef AZ_COLLECTING_PARTIAL_SRGS
diff --git a/Code/CryEngine/CrySystem/System.cpp b/Code/CryEngine/CrySystem/System.cpp
index a48f63afdf..827a393103 100644
--- a/Code/CryEngine/CrySystem/System.cpp
+++ b/Code/CryEngine/CrySystem/System.cpp
@@ -31,7 +31,6 @@
#include
#include
#include
-#include
#include
@@ -1162,31 +1161,6 @@ void CSystem::SleepIfInactive()
{
return;
}
-
-#if defined(WIN32)
- if (!AZ::Interface::Get())
- {
- WIN_HWND hRendWnd = GetIRenderer()->GetHWND();
- if (!hRendWnd)
- {
- return;
- }
-
- AZ_TRACE_METHOD();
- // Loop here waiting for window to be activated.
- for (int nLoops = 0; nLoops < 5; nLoops++)
- {
- WIN_HWND hActiveWnd = ::GetActiveWindow();
- if (hActiveWnd == hRendWnd)
- {
- break;
- }
-
- AzFramework::ApplicationRequests::Bus::Broadcast(&AzFramework::ApplicationRequests::PumpSystemEventLoopUntilEmpty);
- Sleep(5);
- }
- }
-#endif
}
//////////////////////////////////////////////////////////////////////////
diff --git a/Code/CryEngine/CrySystem/SystemInit.cpp b/Code/CryEngine/CrySystem/SystemInit.cpp
index d293f9ca80..826810ef8a 100644
--- a/Code/CryEngine/CrySystem/SystemInit.cpp
+++ b/Code/CryEngine/CrySystem/SystemInit.cpp
@@ -68,7 +68,6 @@
#include
#include
#include
-#include
#include
#include
@@ -2462,21 +2461,6 @@ AZ_POP_DISABLE_WARNING
m_env.pRenderer->SetViewport(0, 0, screenWidth, screenHeight);
- // Skip splash screen rendering
- if (!AZ::Interface::Get())
- {
- // make sure it's rendered in full screen mode when triple buffering is enabled as well
- for (size_t n = 0; n < 3; n++)
- {
- m_env.pRenderer->BeginFrame();
- m_env.pRenderer->SetCullMode(R_CULL_NONE);
- m_env.pRenderer->SetState(GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA | GS_NODEPTHTEST);
- m_env.pRenderer->Draw2dImageStretchMode(true);
- m_env.pRenderer->Draw2dImage(x * vx, y * vy, w * vx, h * vy, pTex->GetTextureID(), 0.0f, 1.0f, 1.0f, 0.0f);
- m_env.pRenderer->Draw2dImageStretchMode(false);
- m_env.pRenderer->EndFrame();
- }
- }
#if defined(AZ_PLATFORM_IOS) || defined(AZ_PLATFORM_MAC)
// Pump system events in order to update the screen
AzFramework::ApplicationRequests::Bus::Broadcast(&AzFramework::ApplicationRequests::PumpSystemEventLoopUntilEmpty);
diff --git a/Code/Framework/AzCore/AzCore/Math/Matrix3x3.h b/Code/Framework/AzCore/AzCore/Math/Matrix3x3.h
index e1736e1444..973bb52df3 100644
--- a/Code/Framework/AzCore/AzCore/Math/Matrix3x3.h
+++ b/Code/Framework/AzCore/AzCore/Math/Matrix3x3.h
@@ -142,27 +142,44 @@ namespace AZ
void SetBasis(const Vector3& basisX, const Vector3& basisY, const Vector3& basisZ);
//! @}
- Matrix3x3 operator*(const Matrix3x3& rhs) const;
-
//! Calculates (this->GetTranspose() * rhs).
Matrix3x3 TransposedMultiply(const Matrix3x3& rhs) const;
//! Post-multiplies the matrix by a vector.
Vector3 operator*(const Vector3& rhs) const;
- Matrix3x3 operator+(const Matrix3x3& rhs) const;
- Matrix3x3 operator-(const Matrix3x3& rhs) const;
-
- Matrix3x3 operator*(float multiplier) const;
- Matrix3x3 operator/(float divisor) const;
-
- Matrix3x3 operator-() const;
-
- Matrix3x3& operator*=(const Matrix3x3& rhs);
+ //! Operator for matrix-matrix addition.
+ //! @{
+ [[nodiscard]] Matrix3x3 operator+(const Matrix3x3& rhs) const;
Matrix3x3& operator+=(const Matrix3x3& rhs);
+ //! @}
+
+ //! Operator for matrix-matrix substraction.
+ //! @{
+ [[nodiscard]] Matrix3x3 operator-(const Matrix3x3& rhs) const;
Matrix3x3& operator-=(const Matrix3x3& rhs);
+ //! @}
+
+ //! Operator for matrix-matrix multiplication.
+ //! @{
+ [[nodiscard]] Matrix3x3 operator*(const Matrix3x3& rhs) const;
+ Matrix3x3& operator*=(const Matrix3x3& rhs);
+ //! @}
+
+ //! Operator for multiplying all matrix's elements with a scalar
+ //! @{
+ [[nodiscard]] Matrix3x3 operator*(float multiplier) const;
Matrix3x3& operator*=(float multiplier);
+ //! @}
+
+ //! Operator for dividing all matrix's elements with a scalar
+ //! @{
+ [[nodiscard]] Matrix3x3 operator/(float divisor) const;
Matrix3x3& operator/=(float divisor);
+ //! @}
+
+ //! Operator for negating all matrix's elements
+ [[nodiscard]] Matrix3x3 operator-() const;
bool operator==(const Matrix3x3& rhs) const;
bool operator!=(const Matrix3x3& rhs) const;
@@ -187,7 +204,10 @@ namespace AZ
//! @}
//! Gets the scale part of the transformation, i.e. the length of the scale components.
- Vector3 RetrieveScale() const;
+ [[nodiscard]] Vector3 RetrieveScale() const;
+
+ //! Gets the squared scale part of the transformation (the squared length of the basis vectors).
+ [[nodiscard]] Vector3 RetrieveScaleSq() const;
//! Gets the scale part of the transformation as in RetrieveScale, and also removes this scaling from the matrix.
Vector3 ExtractScale();
@@ -195,6 +215,9 @@ namespace AZ
//! Quick multiplication by a scale matrix, equivalent to m*=Matrix3x3::CreateScale(scale).
void MultiplyByScale(const Vector3& scale);
+ //! Returns a matrix with the reciprocal scale, keeping the same rotation and translation.
+ [[nodiscard]] Matrix3x3 GetReciprocalScaled() const;
+
//! Polar decomposition, M=U*H, U is orthogonal (unitary) and H is symmetric (hermitian).
//! This function returns the orthogonal part only
Matrix3x3 GetPolarDecomposition() const;
@@ -241,7 +264,9 @@ namespace AZ
//! Note that this is not the usual multiplication order for transformations.
Vector3& operator*=(Vector3& lhs, const Matrix3x3& rhs);
+ //! Pre-multiplies the matrix by a scalar.
Matrix3x3 operator*(float lhs, const Matrix3x3& rhs);
-}
+
+} // namespace AZ
#include
diff --git a/Code/Framework/AzCore/AzCore/Math/Matrix3x3.inl b/Code/Framework/AzCore/AzCore/Math/Matrix3x3.inl
index ff92da1398..6b4dccf3c1 100644
--- a/Code/Framework/AzCore/AzCore/Math/Matrix3x3.inl
+++ b/Code/Framework/AzCore/AzCore/Math/Matrix3x3.inl
@@ -392,14 +392,6 @@ namespace AZ
}
- AZ_MATH_INLINE Matrix3x3 Matrix3x3::operator*(const Matrix3x3& rhs) const
- {
- Matrix3x3 result;
- Simd::Vec3::Mat3x3Multiply(GetSimdValues(), rhs.GetSimdValues(), result.GetSimdValues());
- return result;
- }
-
-
AZ_MATH_INLINE Matrix3x3 Matrix3x3::TransposedMultiply(const Matrix3x3& rhs) const
{
Matrix3x3 result;
@@ -416,51 +408,12 @@ namespace AZ
AZ_MATH_INLINE Matrix3x3 Matrix3x3::operator+(const Matrix3x3& rhs) const
{
- return Matrix3x3(Simd::Vec3::Add(m_rows[0].GetSimdValue(), rhs.m_rows[0].GetSimdValue())
- , Simd::Vec3::Add(m_rows[1].GetSimdValue(), rhs.m_rows[1].GetSimdValue())
- , Simd::Vec3::Add(m_rows[2].GetSimdValue(), rhs.m_rows[2].GetSimdValue()));
- }
-
-
- AZ_MATH_INLINE Matrix3x3 Matrix3x3::operator-(const Matrix3x3& rhs) const
- {
- return Matrix3x3(Simd::Vec3::Sub(m_rows[0].GetSimdValue(), rhs.m_rows[0].GetSimdValue())
- , Simd::Vec3::Sub(m_rows[1].GetSimdValue(), rhs.m_rows[1].GetSimdValue())
- , Simd::Vec3::Sub(m_rows[2].GetSimdValue(), rhs.m_rows[2].GetSimdValue()));
- }
-
-
- AZ_MATH_INLINE Matrix3x3 Matrix3x3::operator*(float multiplier) const
- {
- const Simd::Vec3::FloatType mulVec = Simd::Vec3::Splat(multiplier);
- return Matrix3x3(Simd::Vec3::Mul(m_rows[0].GetSimdValue(), mulVec)
- , Simd::Vec3::Mul(m_rows[1].GetSimdValue(), mulVec)
- , Simd::Vec3::Mul(m_rows[2].GetSimdValue(), mulVec));
- }
-
-
- AZ_MATH_INLINE Matrix3x3 Matrix3x3::operator/(float divisor) const
- {
- const Simd::Vec3::FloatType divVec = Simd::Vec3::Splat(divisor);
- return Matrix3x3(Simd::Vec3::Div(m_rows[0].GetSimdValue(), divVec)
- , Simd::Vec3::Div(m_rows[1].GetSimdValue(), divVec)
- , Simd::Vec3::Div(m_rows[2].GetSimdValue(), divVec));
- }
-
-
- AZ_MATH_INLINE Matrix3x3 Matrix3x3::operator-() const
- {
- const Simd::Vec3::FloatType zeroVec = Simd::Vec3::ZeroFloat();
- return Matrix3x3(Simd::Vec3::Sub(zeroVec, m_rows[0].GetSimdValue())
- , Simd::Vec3::Sub(zeroVec, m_rows[1].GetSimdValue())
- , Simd::Vec3::Sub(zeroVec, m_rows[2].GetSimdValue()));
- }
-
-
- AZ_MATH_INLINE Matrix3x3& Matrix3x3::operator*=(const Matrix3x3& rhs)
- {
- *this = *this * rhs;
- return *this;
+ return Matrix3x3
+ (
+ Simd::Vec3::Add(m_rows[0].GetSimdValue(), rhs.m_rows[0].GetSimdValue()),
+ Simd::Vec3::Add(m_rows[1].GetSimdValue(), rhs.m_rows[1].GetSimdValue()),
+ Simd::Vec3::Add(m_rows[2].GetSimdValue(), rhs.m_rows[2].GetSimdValue())
+ );
}
@@ -471,6 +424,17 @@ namespace AZ
}
+ AZ_MATH_INLINE Matrix3x3 Matrix3x3::operator-(const Matrix3x3& rhs) const
+ {
+ return Matrix3x3
+ (
+ Simd::Vec3::Sub(m_rows[0].GetSimdValue(), rhs.m_rows[0].GetSimdValue()),
+ Simd::Vec3::Sub(m_rows[1].GetSimdValue(), rhs.m_rows[1].GetSimdValue()),
+ Simd::Vec3::Sub(m_rows[2].GetSimdValue(), rhs.m_rows[2].GetSimdValue())
+ );
+ }
+
+
AZ_MATH_INLINE Matrix3x3& Matrix3x3::operator-=(const Matrix3x3& rhs)
{
*this = *this - rhs;
@@ -478,6 +442,33 @@ namespace AZ
}
+ AZ_MATH_INLINE Matrix3x3 Matrix3x3::operator*(const Matrix3x3& rhs) const
+ {
+ Matrix3x3 result;
+ Simd::Vec3::Mat3x3Multiply(GetSimdValues(), rhs.GetSimdValues(), result.GetSimdValues());
+ return result;
+ }
+
+
+ AZ_MATH_INLINE Matrix3x3& Matrix3x3::operator*=(const Matrix3x3& rhs)
+ {
+ *this = *this * rhs;
+ return *this;
+ }
+
+
+ AZ_MATH_INLINE Matrix3x3 Matrix3x3::operator*(float multiplier) const
+ {
+ const Simd::Vec3::FloatType mulVec = Simd::Vec3::Splat(multiplier);
+ return Matrix3x3
+ (
+ Simd::Vec3::Mul(m_rows[0].GetSimdValue(), mulVec),
+ Simd::Vec3::Mul(m_rows[1].GetSimdValue(), mulVec),
+ Simd::Vec3::Mul(m_rows[2].GetSimdValue(), mulVec)
+ );
+ }
+
+
AZ_MATH_INLINE Matrix3x3& Matrix3x3::operator*=(float multiplier)
{
*this = *this * multiplier;
@@ -485,6 +476,18 @@ namespace AZ
}
+ AZ_MATH_INLINE Matrix3x3 Matrix3x3::operator/(float divisor) const
+ {
+ const Simd::Vec3::FloatType divVec = Simd::Vec3::Splat(divisor);
+ return Matrix3x3
+ (
+ Simd::Vec3::Div(m_rows[0].GetSimdValue(), divVec),
+ Simd::Vec3::Div(m_rows[1].GetSimdValue(), divVec),
+ Simd::Vec3::Div(m_rows[2].GetSimdValue(), divVec)
+ );
+ }
+
+
AZ_MATH_INLINE Matrix3x3& Matrix3x3::operator/=(float divisor)
{
*this = *this / divisor;
@@ -492,6 +495,18 @@ namespace AZ
}
+ AZ_MATH_INLINE Matrix3x3 Matrix3x3::operator-() const
+ {
+ const Simd::Vec3::FloatType zeroVec = Simd::Vec3::ZeroFloat();
+ return Matrix3x3
+ (
+ Simd::Vec3::Sub(zeroVec, m_rows[0].GetSimdValue()),
+ Simd::Vec3::Sub(zeroVec, m_rows[1].GetSimdValue()),
+ Simd::Vec3::Sub(zeroVec, m_rows[2].GetSimdValue())
+ );
+ }
+
+
AZ_MATH_INLINE bool Matrix3x3::operator==(const Matrix3x3& rhs) const
{
return (Simd::Vec3::CmpAllEq(m_rows[0].GetSimdValue(), rhs.m_rows[0].GetSimdValue())
@@ -552,6 +567,12 @@ namespace AZ
}
+ AZ_MATH_INLINE Vector3 Matrix3x3::RetrieveScaleSq() const
+ {
+ return Vector3(GetBasisX().GetLengthSq(), GetBasisY().GetLengthSq(), GetBasisZ().GetLengthSq());
+ }
+
+
AZ_MATH_INLINE Vector3 Matrix3x3::ExtractScale()
{
const Vector3 x = GetBasisX();
@@ -584,6 +605,14 @@ namespace AZ
}
+ AZ_MATH_INLINE Matrix3x3 Matrix3x3::GetReciprocalScaled() const
+ {
+ Matrix3x3 result = *this;
+ result.MultiplyByScale(RetrieveScaleSq().GetReciprocal());
+ return result;
+ }
+
+
AZ_MATH_INLINE void Matrix3x3::GetPolarDecomposition(Matrix3x3* orthogonalOut, Matrix3x3* symmetricOut) const
{
*orthogonalOut = GetPolarDecomposition();
@@ -679,8 +708,6 @@ namespace AZ
AZ_MATH_INLINE Matrix3x3 operator*(float lhs, const Matrix3x3& rhs)
{
- const Simd::Vec3::FloatType lhsVec = Simd::Vec3::Splat(lhs);
- const Simd::Vec3::FloatType* rows = rhs.GetSimdValues();
- return Matrix3x3(Simd::Vec3::Mul(lhsVec, rows[0]), Simd::Vec3::Mul(lhsVec, rows[1]), Simd::Vec3::Mul(lhsVec, rows[2]));
+ return rhs * lhs;
}
-}
+} // namespace AZ
diff --git a/Code/Framework/AzCore/AzCore/Math/Matrix3x4.h b/Code/Framework/AzCore/AzCore/Math/Matrix3x4.h
index 09f443c1cf..a18f1e7565 100644
--- a/Code/Framework/AzCore/AzCore/Math/Matrix3x4.h
+++ b/Code/Framework/AzCore/AzCore/Math/Matrix3x4.h
@@ -225,23 +225,38 @@ namespace AZ
//! Sets the three basis vectors and the translation.
void SetBasisAndTranslation(const Vector3& basisX, const Vector3& basisY, const Vector3& basisZ, const Vector3& translation);
- //! Operator for matrix-matrix multiplication.
- [[nodiscard]] Matrix3x4 operator*(const Matrix3x4& rhs) const;
-
- //! Compound assignment operator for matrix-matrix multiplication.
- Matrix3x4& operator*=(const Matrix3x4& rhs);
-
//! Operator for matrix-matrix addition.
+ //! @{
[[nodiscard]] Matrix3x4 operator+(const Matrix3x4& rhs) const;
-
- //! Compound assignment operator for matrix-matrix addition.
Matrix3x4& operator+=(const Matrix3x4& rhs);
+ //! @}
+
+ //! Operator for matrix-matrix substraction.
+ //! @{
+ [[nodiscard]] Matrix3x4 operator-(const Matrix3x4& rhs) const;
+ Matrix3x4& operator-=(const Matrix3x4& rhs);
+ //! @}
+
+ //! Operator for matrix-matrix multiplication.
+ //! @{
+ [[nodiscard]] Matrix3x4 operator*(const Matrix3x4& rhs) const;
+ Matrix3x4& operator*=(const Matrix3x4& rhs);
+ //! @}
//! Operator for multiplying all matrix's elements with a scalar
- [[nodiscard]] Matrix3x4 operator*(float scalar) const;
+ //! @{
+ [[nodiscard]] Matrix3x4 operator*(float multiplier) const;
+ Matrix3x4& operator*=(float multiplier);
+ //! @}
- //! Compound assignment operator for multiplying all matrix's elements with a scalar
- Matrix3x4& operator*=(float scalar);
+ //! Operator for dividing all matrix's elements with a scalar
+ //! @{
+ [[nodiscard]] Matrix3x4 operator/(float divisor) const;
+ Matrix3x4& operator/=(float divisor);
+ //! @}
+
+ //! Operator for negating all matrix's elements
+ [[nodiscard]] Matrix3x4 operator-() const;
//! Operator for transforming a Vector3.
[[nodiscard]] Vector3 operator*(const Vector3& rhs) const;
@@ -353,6 +368,10 @@ namespace AZ
Vector4 m_rows[RowCount];
};
+
+ //! Pre-multiplies the matrix by a scalar.
+ Matrix3x4 operator*(float lhs, const Matrix3x4& rhs);
+
} // namespace AZ
#include
diff --git a/Code/Framework/AzCore/AzCore/Math/Matrix3x4.inl b/Code/Framework/AzCore/AzCore/Math/Matrix3x4.inl
index 232e8a5b30..781dcf9b66 100644
--- a/Code/Framework/AzCore/AzCore/Math/Matrix3x4.inl
+++ b/Code/Framework/AzCore/AzCore/Math/Matrix3x4.inl
@@ -472,21 +472,6 @@ namespace AZ
}
- AZ_MATH_INLINE Matrix3x4 Matrix3x4::operator*(const Matrix3x4& rhs) const
- {
- Matrix3x4 result;
- Simd::Vec4::Mat3x4Multiply(GetSimdValues(), rhs.GetSimdValues(), result.GetSimdValues());
- return result;
- }
-
-
- AZ_MATH_INLINE Matrix3x4& Matrix3x4::operator*=(const Matrix3x4& rhs)
- {
- *this = *this * rhs;
- return *this;
- }
-
-
AZ_MATH_INLINE Matrix3x4 Matrix3x4::operator+(const Matrix3x4& rhs) const
{
return Matrix3x4
@@ -505,25 +490,89 @@ namespace AZ
}
- AZ_MATH_INLINE Matrix3x4 Matrix3x4::operator*(float scalar) const
+ AZ_MATH_INLINE Matrix3x4 Matrix3x4::operator-(const Matrix3x4& rhs) const
{
- const Vector4 vector4Scalar(scalar);
return Matrix3x4
(
- Simd::Vec4::Mul(m_rows[0].GetSimdValue(), vector4Scalar.GetSimdValue()),
- Simd::Vec4::Mul(m_rows[1].GetSimdValue(), vector4Scalar.GetSimdValue()),
- Simd::Vec4::Mul(m_rows[2].GetSimdValue(), vector4Scalar.GetSimdValue())
+ Simd::Vec4::Sub(m_rows[0].GetSimdValue(), rhs.m_rows[0].GetSimdValue()),
+ Simd::Vec4::Sub(m_rows[1].GetSimdValue(), rhs.m_rows[1].GetSimdValue()),
+ Simd::Vec4::Sub(m_rows[2].GetSimdValue(), rhs.m_rows[2].GetSimdValue())
);
}
- AZ_MATH_INLINE Matrix3x4& Matrix3x4::operator*=(float scalar)
+ AZ_MATH_INLINE Matrix3x4& Matrix3x4::operator-=(const Matrix3x4& rhs)
{
- *this = *this * scalar;
+ *this = *this - rhs;
return *this;
}
+ AZ_MATH_INLINE Matrix3x4 Matrix3x4::operator*(const Matrix3x4& rhs) const
+ {
+ Matrix3x4 result;
+ Simd::Vec4::Mat3x4Multiply(GetSimdValues(), rhs.GetSimdValues(), result.GetSimdValues());
+ return result;
+ }
+
+
+ AZ_MATH_INLINE Matrix3x4& Matrix3x4::operator*=(const Matrix3x4& rhs)
+ {
+ *this = *this * rhs;
+ return *this;
+ }
+
+
+ AZ_MATH_INLINE Matrix3x4 Matrix3x4::operator*(float multiplier) const
+ {
+ const Simd::Vec4::FloatType mulVec = Simd::Vec4::Splat(multiplier);
+ return Matrix3x4
+ (
+ Simd::Vec4::Mul(m_rows[0].GetSimdValue(), mulVec),
+ Simd::Vec4::Mul(m_rows[1].GetSimdValue(), mulVec),
+ Simd::Vec4::Mul(m_rows[2].GetSimdValue(), mulVec)
+ );
+ }
+
+
+ AZ_MATH_INLINE Matrix3x4& Matrix3x4::operator*=(float multiplier)
+ {
+ *this = *this * multiplier;
+ return *this;
+ }
+
+
+ AZ_MATH_INLINE Matrix3x4 Matrix3x4::operator/(float divisor) const
+ {
+ const Simd::Vec4::FloatType divVec = Simd::Vec4::Splat(divisor);
+ return Matrix3x4
+ (
+ Simd::Vec4::Div(m_rows[0].GetSimdValue(), divVec),
+ Simd::Vec4::Div(m_rows[1].GetSimdValue(), divVec),
+ Simd::Vec4::Div(m_rows[2].GetSimdValue(), divVec)
+ );
+ }
+
+
+ AZ_MATH_INLINE Matrix3x4& Matrix3x4::operator/=(float divisor)
+ {
+ *this = *this / divisor;
+ return *this;
+ }
+
+
+ AZ_MATH_INLINE Matrix3x4 Matrix3x4::operator-() const
+ {
+ const Simd::Vec4::FloatType zeroVec = Simd::Vec4::ZeroFloat();
+ return Matrix3x4
+ (
+ Simd::Vec4::Sub(zeroVec, m_rows[0].GetSimdValue()),
+ Simd::Vec4::Sub(zeroVec, m_rows[1].GetSimdValue()),
+ Simd::Vec4::Sub(zeroVec, m_rows[2].GetSimdValue())
+ );
+ }
+
+
AZ_MATH_INLINE Vector3 Matrix3x4::operator*(const Vector3& rhs) const
{
return Vector3
@@ -711,4 +760,10 @@ namespace AZ
{
return reinterpret_cast(m_rows);
}
+
+
+ AZ_MATH_INLINE Matrix3x4 operator*(float lhs, const Matrix3x4& rhs)
+ {
+ return rhs * lhs;
+ }
} // namespace AZ
diff --git a/Code/Framework/AzCore/AzCore/Math/Matrix4x4.h b/Code/Framework/AzCore/AzCore/Math/Matrix4x4.h
index 1612f8c962..a94b3c7ae2 100644
--- a/Code/Framework/AzCore/AzCore/Math/Matrix4x4.h
+++ b/Code/Framework/AzCore/AzCore/Math/Matrix4x4.h
@@ -171,14 +171,38 @@ namespace AZ
void SetTranslation(const Vector3& v);
//! @}
- Matrix4x4 operator+(const Matrix4x4& rhs) const;
+ //! Operator for matrix-matrix addition.
+ //! @{
+ [[nodiscard]] Matrix4x4 operator+(const Matrix4x4& rhs) const;
Matrix4x4& operator+=(const Matrix4x4& rhs);
+ //! @}
- Matrix4x4 operator-(const Matrix4x4& rhs) const;
+ //! Operator for matrix-matrix substraction.
+ //! @{
+ [[nodiscard]] Matrix4x4 operator-(const Matrix4x4& rhs) const;
Matrix4x4& operator-=(const Matrix4x4& rhs);
+ //! @}
- Matrix4x4 operator*(const Matrix4x4& rhs) const;
+ //! Operator for matrix-matrix multiplication.
+ //! @{
+ [[nodiscard]] Matrix4x4 operator*(const Matrix4x4& rhs) const;
Matrix4x4& operator*=(const Matrix4x4& rhs);
+ //! @}
+
+ //! Operator for multiplying all matrix's elements with a scalar
+ //! @{
+ [[nodiscard]] Matrix4x4 operator*(float multiplier) const;
+ Matrix4x4& operator*=(float multiplier);
+ //! @}
+
+ //! Operator for dividing all matrix's elements with a scalar
+ //! @{
+ [[nodiscard]] Matrix4x4 operator/(float divisor) const;
+ Matrix4x4& operator/=(float divisor);
+ //! @}
+
+ //! Operator for negating all matrix's elements
+ [[nodiscard]] Matrix4x4 operator-() const;
//! Post-multiplies the matrix by a vector.
//! Assumes that the w-component of the Vector3 is 1.0.
@@ -222,7 +246,10 @@ namespace AZ
//! @}
//! Gets the scale part of the transformation, i.e. the length of the scale components.
- Vector3 RetrieveScale() const;
+ [[nodiscard]] Vector3 RetrieveScale() const;
+
+ //! Gets the squared scale part of the transformation (the squared length of the basis vectors).
+ [[nodiscard]] Vector3 RetrieveScaleSq() const;
//! Gets the scale part of the transformation as in RetrieveScale, and also removes this scaling from the matrix.
Vector3 ExtractScale();
@@ -230,6 +257,9 @@ namespace AZ
//! Quick multiplication by a scale matrix, equivalent to m*=Matrix4x4::CreateScale(scale).
void MultiplyByScale(const Vector3& scale);
+ //! Returns a matrix with the reciprocal scale, keeping the same rotation and translation.
+ [[nodiscard]] Matrix4x4 GetReciprocalScaled() const;
+
bool IsClose(const Matrix4x4& rhs, float tolerance = Constants::Tolerance) const;
bool operator==(const Matrix4x4& rhs) const;
@@ -270,6 +300,10 @@ namespace AZ
//! Pre-multiplies the matrix by a vector in-place.
//! Note that this is not the usual multiplication order for transformations.
Vector4& operator*=(Vector4& lhs, const Matrix4x4& rhs);
-}
+
+ //! Pre-multiplies the matrix by a scalar.
+ Matrix4x4 operator*(float lhs, const Matrix4x4& rhs);
+
+} // namespace AZ
#include
diff --git a/Code/Framework/AzCore/AzCore/Math/Matrix4x4.inl b/Code/Framework/AzCore/AzCore/Math/Matrix4x4.inl
index 3c4572accd..e32ebe31af 100644
--- a/Code/Framework/AzCore/AzCore/Math/Matrix4x4.inl
+++ b/Code/Framework/AzCore/AzCore/Math/Matrix4x4.inl
@@ -480,20 +480,12 @@ namespace AZ
AZ_MATH_INLINE Matrix4x4 Matrix4x4::operator+(const Matrix4x4& rhs) const
{
return Matrix4x4
- ( Simd::Vec4::Add(m_rows[0].GetSimdValue(), rhs.m_rows[0].GetSimdValue())
- , Simd::Vec4::Add(m_rows[1].GetSimdValue(), rhs.m_rows[1].GetSimdValue())
- , Simd::Vec4::Add(m_rows[2].GetSimdValue(), rhs.m_rows[2].GetSimdValue())
- , Simd::Vec4::Add(m_rows[3].GetSimdValue(), rhs.m_rows[3].GetSimdValue()));
- }
-
-
- AZ_MATH_INLINE Matrix4x4 Matrix4x4::operator-(const Matrix4x4& rhs) const
- {
- return Matrix4x4
- ( Simd::Vec4::Sub(m_rows[0].GetSimdValue(), rhs.m_rows[0].GetSimdValue())
- , Simd::Vec4::Sub(m_rows[1].GetSimdValue(), rhs.m_rows[1].GetSimdValue())
- , Simd::Vec4::Sub(m_rows[2].GetSimdValue(), rhs.m_rows[2].GetSimdValue())
- , Simd::Vec4::Sub(m_rows[3].GetSimdValue(), rhs.m_rows[3].GetSimdValue()));
+ (
+ Simd::Vec4::Add(m_rows[0].GetSimdValue(), rhs.m_rows[0].GetSimdValue()),
+ Simd::Vec4::Add(m_rows[1].GetSimdValue(), rhs.m_rows[1].GetSimdValue()),
+ Simd::Vec4::Add(m_rows[2].GetSimdValue(), rhs.m_rows[2].GetSimdValue()),
+ Simd::Vec4::Add(m_rows[3].GetSimdValue(), rhs.m_rows[3].GetSimdValue())
+ );
}
AZ_MATH_INLINE Matrix4x4& Matrix4x4::operator+=(const Matrix4x4& rhs)
@@ -502,6 +494,18 @@ namespace AZ
return *this;
}
+
+ AZ_MATH_INLINE Matrix4x4 Matrix4x4::operator-(const Matrix4x4& rhs) const
+ {
+ return Matrix4x4
+ (
+ Simd::Vec4::Sub(m_rows[0].GetSimdValue(), rhs.m_rows[0].GetSimdValue()),
+ Simd::Vec4::Sub(m_rows[1].GetSimdValue(), rhs.m_rows[1].GetSimdValue()),
+ Simd::Vec4::Sub(m_rows[2].GetSimdValue(), rhs.m_rows[2].GetSimdValue()),
+ Simd::Vec4::Sub(m_rows[3].GetSimdValue(), rhs.m_rows[3].GetSimdValue())
+ );
+ }
+
AZ_MATH_INLINE Matrix4x4& Matrix4x4::operator-=(const Matrix4x4& rhs)
{
*this = *this - rhs;
@@ -523,6 +527,59 @@ namespace AZ
}
+ AZ_MATH_INLINE Matrix4x4 Matrix4x4::operator*(float multiplier) const
+ {
+ const Simd::Vec4::FloatType mulVec = Simd::Vec4::Splat(multiplier);
+ return Matrix4x4
+ (
+ Simd::Vec4::Mul(m_rows[0].GetSimdValue(), mulVec),
+ Simd::Vec4::Mul(m_rows[1].GetSimdValue(), mulVec),
+ Simd::Vec4::Mul(m_rows[2].GetSimdValue(), mulVec),
+ Simd::Vec4::Mul(m_rows[3].GetSimdValue(), mulVec)
+ );
+ }
+
+
+ AZ_MATH_INLINE Matrix4x4& Matrix4x4::operator*=(float multiplier)
+ {
+ *this = *this * multiplier;
+ return *this;
+ }
+
+
+ AZ_MATH_INLINE Matrix4x4 Matrix4x4::operator/(float divisor) const
+ {
+ const Simd::Vec4::FloatType divVec = Simd::Vec4::Splat(divisor);
+ return Matrix4x4
+ (
+ Simd::Vec4::Div(m_rows[0].GetSimdValue(), divVec),
+ Simd::Vec4::Div(m_rows[1].GetSimdValue(), divVec),
+ Simd::Vec4::Div(m_rows[2].GetSimdValue(), divVec),
+ Simd::Vec4::Div(m_rows[3].GetSimdValue(), divVec)
+ );
+ }
+
+
+ AZ_MATH_INLINE Matrix4x4& Matrix4x4::operator/=(float divisor)
+ {
+ *this = *this / divisor;
+ return *this;
+ }
+
+
+ AZ_MATH_INLINE Matrix4x4 Matrix4x4::operator-() const
+ {
+ const Simd::Vec4::FloatType zeroVec = Simd::Vec4::ZeroFloat();
+ return Matrix4x4
+ (
+ Simd::Vec4::Sub(zeroVec, m_rows[0].GetSimdValue()),
+ Simd::Vec4::Sub(zeroVec, m_rows[1].GetSimdValue()),
+ Simd::Vec4::Sub(zeroVec, m_rows[2].GetSimdValue()),
+ Simd::Vec4::Sub(zeroVec, m_rows[3].GetSimdValue())
+ );
+ }
+
+
AZ_MATH_INLINE Vector3 Matrix4x4::operator*(const Vector3& rhs) const
{
return Vector3(Simd::Vec4::Mat4x4TransformPoint3(GetSimdValues(), rhs.GetSimdValue()));
@@ -595,6 +652,12 @@ namespace AZ
}
+ AZ_MATH_INLINE Vector3 Matrix4x4::RetrieveScaleSq() const
+ {
+ return Vector3(GetBasisX().GetLengthSq(), GetBasisY().GetLengthSq(), GetBasisZ().GetLengthSq());
+ }
+
+
AZ_MATH_INLINE Vector3 Matrix4x4::ExtractScale()
{
Vector4 x = GetBasisX();
@@ -619,6 +682,14 @@ namespace AZ
}
+ AZ_MATH_INLINE Matrix4x4 Matrix4x4::GetReciprocalScaled() const
+ {
+ Matrix4x4 result = *this;
+ result.MultiplyByScale(RetrieveScaleSq().GetReciprocal());
+ return result;
+ }
+
+
AZ_MATH_INLINE bool Matrix4x4::IsClose(const Matrix4x4& rhs, float tolerance) const
{
const Simd::Vec4::FloatType vecTolerance = Simd::Vec4::Splat(tolerance);
@@ -702,4 +773,10 @@ namespace AZ
lhs = lhs * rhs;
return lhs;
}
-}
+
+
+ AZ_MATH_INLINE Matrix4x4 operator*(float lhs, const Matrix4x4& rhs)
+ {
+ return rhs * lhs;
+ }
+} // namespace AZ
diff --git a/Code/Framework/AzCore/AzCore/Serialization/Json/JsonDeserializer.cpp b/Code/Framework/AzCore/AzCore/Serialization/Json/JsonDeserializer.cpp
index f2e9bb866f..8d0da9e54a 100644
--- a/Code/Framework/AzCore/AzCore/Serialization/Json/JsonDeserializer.cpp
+++ b/Code/Framework/AzCore/AzCore/Serialization/Json/JsonDeserializer.cpp
@@ -97,7 +97,8 @@ namespace AZ
return context.Report(Tasks::RetrieveInfo, Outcomes::Unknown,
AZStd::string::format("Failed to retrieve rtti information for %s.", classData->m_name));
}
- AZ_Assert(classData->m_azRtti->GetTypeId() == typeId, "Type id mismatch during deserialization of a json file. (%s vs %s)");
+ AZ_Assert(classData->m_azRtti->GetTypeId() == typeId, "Type id mismatch during deserialization of a json file. (%s vs %s)",
+ classData->m_azRtti->GetTypeId().ToString().c_str(), typeId.ToString().c_str());
void** objectPtr = reinterpret_cast(object);
bool isNull = *objectPtr == nullptr;
@@ -512,27 +513,24 @@ namespace AZ
if (*object)
{
const AZ::Uuid& actualClassId = rtti.GetActualUuid(*object);
- if (actualClassId != objectType)
+ const SerializeContext::ClassData* actualClassData = context.GetSerializeContext()->FindClassData(actualClassId);
+ if (!actualClassData)
{
- const SerializeContext::ClassData* actualClassData = context.GetSerializeContext()->FindClassData(actualClassId);
- if (!actualClassData)
- {
- status = context.Report(Tasks::RetrieveInfo, Outcomes::Unknown,
- AZStd::string::format("Unable to find serialization information for type %s.", actualClassId.ToString().c_str()));
- return ResolvePointerResult::FullyProcessed;
- }
+ status = context.Report(Tasks::RetrieveInfo, Outcomes::Unknown,
+ AZStd::string::format("Unable to find serialization information for type %s.", actualClassId.ToString().c_str()));
+ return ResolvePointerResult::FullyProcessed;
+ }
- if (actualClassData->m_factory)
- {
- actualClassData->m_factory->Destroy(*object);
- *object = nullptr;
- }
- else
- {
- status = context.Report(Tasks::RetrieveInfo, Outcomes::Catastrophic,
- "Unable to find the factory needed to clear out the default value.");
- return ResolvePointerResult::FullyProcessed;
- }
+ if (actualClassData->m_factory)
+ {
+ actualClassData->m_factory->Destroy(*object);
+ *object = nullptr;
+ }
+ else
+ {
+ status = context.Report(Tasks::RetrieveInfo, Outcomes::Catastrophic,
+ "Unable to find the factory needed to clear out the default value.");
+ return ResolvePointerResult::FullyProcessed;
}
}
status = ResultCode(Tasks::ReadField, Outcomes::Success);
diff --git a/Code/Framework/AzCore/AzCore/Serialization/Json/JsonSerialization.h b/Code/Framework/AzCore/AzCore/Serialization/Json/JsonSerialization.h
index 5746005832..cf73d8dc56 100644
--- a/Code/Framework/AzCore/AzCore/Serialization/Json/JsonSerialization.h
+++ b/Code/Framework/AzCore/AzCore/Serialization/Json/JsonSerialization.h
@@ -38,6 +38,20 @@ namespace AZ
};
//! Core class to handle serialization to and from json documents.
+ //! The Json Serialization works by taking a default constructed object and then apply the information found in the JSON document
+ //! on top of that object. This allows the Json Serialization to avoid storing default values and helps guarantee that the final
+ //! object is in a valid state even if non-fatal issues are encountered.
+ //! Note on containers: Containers such as vector or map are always considered to be empty even if there's entries in the provided
+ //! default object. During deserialization entries will be appended to any existing values. A flag is provided to automatically
+ //! clear containers during deserialization.
+ //! Note on maps: If the key for map containers such as unordered_map can be interpret as a string the Json Serialization will use
+ //! a JSON Object to store the data in instead of an array with key/value objects.
+ //! Note on pointers: The Json Serialization assumes that are always constructed, so a default JSON value of "{}" is interpret as
+ //! creating a new default instance even if the default value is a null pointer. A JSON Null needs to be explicitly stored in
+ //! the JSON Document in order to default or explicitly set a pointer to null.
+ //! Note on pointer memory: Objects created/destroyed by the Json Serialization for pointers require that the AZ_CLASS_ALLOCATOR is
+ //! declared and the object is created using aznew or memory is allocated using azmalloc. Without these the application may
+ //! crash if the Json Serialization tries to create or destroy an object pointed to by a pointer.
class JsonSerialization final
{
public:
diff --git a/Code/Framework/AzCore/AzCore/Serialization/Json/SmartPointerSerializer.cpp b/Code/Framework/AzCore/AzCore/Serialization/Json/SmartPointerSerializer.cpp
index 0180e99592..9e707f8644 100644
--- a/Code/Framework/AzCore/AzCore/Serialization/Json/SmartPointerSerializer.cpp
+++ b/Code/Framework/AzCore/AzCore/Serialization/Json/SmartPointerSerializer.cpp
@@ -23,13 +23,6 @@ namespace AZ
{
namespace JSR = JsonSerializationResult;
- if (IsExplicitDefault(inputValue))
- {
- // Do nothing if the input is an explicit default.
- return context.Report(JSR::Tasks::ReadField, JSR::Outcomes::DefaultsUsed,
- "Default value for smart pointer requested so no change was made.");
- }
-
const SerializeContext::ClassData* containerClass = context.GetSerializeContext()->FindClassData(outputValueTypeId);
if (!containerClass)
{
@@ -153,8 +146,7 @@ namespace AZ
if (defaultValue)
{
- bool typesMatch = false;
- auto defaultInputCallback = [&defaultValue, &inputPtrType, &typesMatch]
+ auto defaultInputCallback = [&defaultValue]
(void* elementPtr, const Uuid&, const SerializeContext::ClassData*, const SerializeContext::ClassElement*)
{
defaultValue = elementPtr;
@@ -164,11 +156,6 @@ namespace AZ
}
JSR::ResultCode result = ContinueStoring(outputValue, inputValue, defaultValue, inputPtrType, context, Flags::ResolvePointer);
- if (result.GetOutcome() == JSR::Outcomes::DefaultsUsed)
- {
- outputValue = GetExplicitDefault();
- return context.Report(result, "Smart pointer used all defaults.");
- }
return context.Report(result, result.GetProcessing() != JSR::Processing::Halted ?
"Successfully processed smart pointer." : "A problem occurred while processing a smart pointer.");
}
diff --git a/Code/Framework/AzCore/Tests/Math/Matrix3x3Tests.cpp b/Code/Framework/AzCore/Tests/Math/Matrix3x3Tests.cpp
index a849cfdaab..efa0ee531c 100644
--- a/Code/Framework/AzCore/Tests/Math/Matrix3x3Tests.cpp
+++ b/Code/Framework/AzCore/Tests/Math/Matrix3x3Tests.cpp
@@ -14,6 +14,7 @@
#include
#include
#include
+#include
using namespace AZ;
@@ -251,19 +252,19 @@ namespace UnitTest
m2.SetRow(2, 13.0f, 14.0f, 15.0f);
Matrix3x3 m3 = m1 * m2;
- AZ_TEST_ASSERT(m3.GetRow(0).IsClose(Vector3(66.0f, 72.0f, 78.0f)));
- AZ_TEST_ASSERT(m3.GetRow(1).IsClose(Vector3(156.0f, 171.0f, 186.0f)));
- AZ_TEST_ASSERT(m3.GetRow(2).IsClose(Vector3(246.0f, 270.0f, 294.0f)));
+ EXPECT_THAT(m3.GetRow(0), IsClose(Vector3(66.0f, 72.0f, 78.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(Vector3(156.0f, 171.0f, 186.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(Vector3(246.0f, 270.0f, 294.0f)));
Matrix3x3 m4 = m1;
m4 *= m2;
- AZ_TEST_ASSERT(m4.GetRow(0).IsClose(Vector3(66.0f, 72.0f, 78.0f)));
- AZ_TEST_ASSERT(m4.GetRow(1).IsClose(Vector3(156.0f, 171.0f, 186.0f)));
- AZ_TEST_ASSERT(m4.GetRow(2).IsClose(Vector3(246.0f, 270.0f, 294.0f)));
+ EXPECT_THAT(m4.GetRow(0), IsClose(Vector3(66.0f, 72.0f, 78.0f)));
+ EXPECT_THAT(m4.GetRow(1), IsClose(Vector3(156.0f, 171.0f, 186.0f)));
+ EXPECT_THAT(m4.GetRow(2), IsClose(Vector3(246.0f, 270.0f, 294.0f)));
m3 = m1.TransposedMultiply(m2);
- AZ_TEST_ASSERT(m3.GetRow(0).IsClose(Vector3(138.0f, 150.0f, 162.0f)));
- AZ_TEST_ASSERT(m3.GetRow(1).IsClose(Vector3(168.0f, 183.0f, 198.0f)));
- AZ_TEST_ASSERT(m3.GetRow(2).IsClose(Vector3(198.0f, 216.0f, 234.0f)));
+ EXPECT_THAT(m3.GetRow(0), IsClose(Vector3(138.0f, 150.0f, 162.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(Vector3(168.0f, 183.0f, 198.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(Vector3(198.0f, 216.0f, 234.0f)));
}
TEST(MATH_Matrix3x3, TestVectorMultiplication)
@@ -277,11 +278,11 @@ namespace UnitTest
m2.SetRow(1, 10.0f, 11.0f, 12.0f);
m2.SetRow(2, 13.0f, 14.0f, 15.0f);
- AZ_TEST_ASSERT((m1 * Vector3(1.0f, 2.0f, 3.0f)).IsClose(Vector3(14.0f, 32.0f, 50.0f)));
+ EXPECT_THAT((m1 * Vector3(1.0f, 2.0f, 3.0f)), IsClose(Vector3(14.0f, 32.0f, 50.0f)));
Vector3 v1(1.0f, 2.0f, 3.0f);
- AZ_TEST_ASSERT((v1 * m1).IsClose(Vector3(30.0f, 36.0f, 42.0f)));
+ EXPECT_THAT((v1 * m1), IsClose(Vector3(30.0f, 36.0f, 42.0f)));
v1 *= m1;
- AZ_TEST_ASSERT(v1.IsClose(Vector3(30.0f, 36.0f, 42.0f)));
+ EXPECT_THAT(v1, IsClose(Vector3(30.0f, 36.0f, 42.0f)));
}
TEST(MATH_Matrix3x3, TestSum)
@@ -296,15 +297,15 @@ namespace UnitTest
m2.SetRow(2, 13.0f, 14.0f, 15.0f);
Matrix3x3 m3 = m1 + m2;
- AZ_TEST_ASSERT(m3.GetRow(0).IsClose(Vector3(8.0f, 10.0f, 12.0f)));
- AZ_TEST_ASSERT(m3.GetRow(1).IsClose(Vector3(14.0f, 16.0f, 18.0f)));
- AZ_TEST_ASSERT(m3.GetRow(2).IsClose(Vector3(20.0f, 22.0f, 24.0f)));
+ EXPECT_THAT(m3.GetRow(0), IsClose(Vector3(8.0f, 10.0f, 12.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(Vector3(14.0f, 16.0f, 18.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(Vector3(20.0f, 22.0f, 24.0f)));
m3 = m1;
m3 += m2;
- AZ_TEST_ASSERT(m3.GetRow(0).IsClose(Vector3(8.0f, 10.0f, 12.0f)));
- AZ_TEST_ASSERT(m3.GetRow(1).IsClose(Vector3(14.0f, 16.0f, 18.0f)));
- AZ_TEST_ASSERT(m3.GetRow(2).IsClose(Vector3(20.0f, 22.0f, 24.0f)));
+ EXPECT_THAT(m3.GetRow(0), IsClose(Vector3(8.0f, 10.0f, 12.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(Vector3(14.0f, 16.0f, 18.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(Vector3(20.0f, 22.0f, 24.0f)));
}
TEST(MATH_Matrix3x3, TestDifference)
@@ -319,14 +320,14 @@ namespace UnitTest
m2.SetRow(2, 13.0f, 14.0f, 15.0f);
Matrix3x3 m3 = m1 - m2;
- AZ_TEST_ASSERT(m3.GetRow(0).IsClose(Vector3(-6.0f, -6.0f, -6.0f)));
- AZ_TEST_ASSERT(m3.GetRow(1).IsClose(Vector3(-6.0f, -6.0f, -6.0f)));
- AZ_TEST_ASSERT(m3.GetRow(2).IsClose(Vector3(-6.0f, -6.0f, -6.0f)));
+ EXPECT_THAT(m3.GetRow(0), IsClose(Vector3(-6.0f, -6.0f, -6.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(Vector3(-6.0f, -6.0f, -6.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(Vector3(-6.0f, -6.0f, -6.0f)));
m3 = m1;
m3 -= m2;
- AZ_TEST_ASSERT(m3.GetRow(0).IsClose(Vector3(-6.0f, -6.0f, -6.0f)));
- AZ_TEST_ASSERT(m3.GetRow(1).IsClose(Vector3(-6.0f, -6.0f, -6.0f)));
- AZ_TEST_ASSERT(m3.GetRow(2).IsClose(Vector3(-6.0f, -6.0f, -6.0f)));
+ EXPECT_THAT(m3.GetRow(0), IsClose(Vector3(-6.0f, -6.0f, -6.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(Vector3(-6.0f, -6.0f, -6.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(Vector3(-6.0f, -6.0f, -6.0f)));
}
TEST(MATH_Matrix3x3, TestScalarMultiplication)
@@ -341,18 +342,18 @@ namespace UnitTest
m2.SetRow(2, 13.0f, 14.0f, 15.0f);
Matrix3x3 m3 = m1 * 2.0f;
- AZ_TEST_ASSERT(m3.GetRow(0).IsClose(Vector3(2.0f, 4.0f, 6.0f)));
- AZ_TEST_ASSERT(m3.GetRow(1).IsClose(Vector3(8.0f, 10.0f, 12.0f)));
- AZ_TEST_ASSERT(m3.GetRow(2).IsClose(Vector3(14.0f, 16.0f, 18.0f)));
+ EXPECT_THAT(m3.GetRow(0), IsClose(Vector3(2.0f, 4.0f, 6.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(Vector3(8.0f, 10.0f, 12.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(Vector3(14.0f, 16.0f, 18.0f)));
m3 = m1;
m3 *= 2.0f;
- AZ_TEST_ASSERT(m3.GetRow(0).IsClose(Vector3(2.0f, 4.0f, 6.0f)));
- AZ_TEST_ASSERT(m3.GetRow(1).IsClose(Vector3(8.0f, 10.0f, 12.0f)));
- AZ_TEST_ASSERT(m3.GetRow(2).IsClose(Vector3(14.0f, 16.0f, 18.0f)));
+ EXPECT_THAT(m3.GetRow(0), IsClose(Vector3(2.0f, 4.0f, 6.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(Vector3(8.0f, 10.0f, 12.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(Vector3(14.0f, 16.0f, 18.0f)));
m3 = 2.0f * m1;
- AZ_TEST_ASSERT(m3.GetRow(0).IsClose(Vector3(2.0f, 4.0f, 6.0f)));
- AZ_TEST_ASSERT(m3.GetRow(1).IsClose(Vector3(8.0f, 10.0f, 12.0f)));
- AZ_TEST_ASSERT(m3.GetRow(2).IsClose(Vector3(14.0f, 16.0f, 18.0f)));
+ EXPECT_THAT(m3.GetRow(0), IsClose(Vector3(2.0f, 4.0f, 6.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(Vector3(8.0f, 10.0f, 12.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(Vector3(14.0f, 16.0f, 18.0f)));
}
TEST(MATH_Matrix3x3, TestScalarDivision)
@@ -367,18 +368,32 @@ namespace UnitTest
m2.SetRow(2, 13.0f, 14.0f, 15.0f);
Matrix3x3 m3 = m1 / 0.5f;
- AZ_TEST_ASSERT(m3.GetRow(0).IsClose(Vector3(2.0f, 4.0f, 6.0f)));
- AZ_TEST_ASSERT(m3.GetRow(1).IsClose(Vector3(8.0f, 10.0f, 12.0f)));
- AZ_TEST_ASSERT(m3.GetRow(2).IsClose(Vector3(14.0f, 16.0f, 18.0f)));
+ EXPECT_THAT(m3.GetRow(0), IsClose(Vector3(2.0f, 4.0f, 6.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(Vector3(8.0f, 10.0f, 12.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(Vector3(14.0f, 16.0f, 18.0f)));
m3 = m1;
m3 /= 0.5f;
- AZ_TEST_ASSERT(m3.GetRow(0).IsClose(Vector3(2.0f, 4.0f, 6.0f)));
- AZ_TEST_ASSERT(m3.GetRow(1).IsClose(Vector3(8.0f, 10.0f, 12.0f)));
- AZ_TEST_ASSERT(m3.GetRow(2).IsClose(Vector3(14.0f, 16.0f, 18.0f)));
- m3 = -m1;
- AZ_TEST_ASSERT(m3.GetRow(0).IsClose(Vector3(-1.0f, -2.0f, -3.0f)));
- AZ_TEST_ASSERT(m3.GetRow(1).IsClose(Vector3(-4.0f, -5.0f, -6.0f)));
- AZ_TEST_ASSERT(m3.GetRow(2).IsClose(Vector3(-7.0f, -8.0f, -9.0f)));
+ EXPECT_THAT(m3.GetRow(0), IsClose(Vector3(2.0f, 4.0f, 6.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(Vector3(8.0f, 10.0f, 12.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(Vector3(14.0f, 16.0f, 18.0f)));
+ }
+
+ TEST(MATH_Matrix3x3, TestNegation)
+ {
+ Matrix3x3 m1;
+ m1.SetRow(0, 1.0f, 2.0f, 3.0f);
+ m1.SetRow(1, 4.0f, 5.0f, 6.0f);
+ m1.SetRow(2, 7.0f, 8.0f, 9.0f);
+ EXPECT_THAT(-(-m1), IsClose(m1));
+ EXPECT_THAT(-Matrix3x3::CreateZero(), IsClose(Matrix3x3::CreateZero()));
+
+ Matrix3x3 m2 = -m1;
+ EXPECT_THAT(m2.GetRow(0), IsClose(Vector3(-1.0f, -2.0f, -3.0f)));
+ EXPECT_THAT(m2.GetRow(1), IsClose(Vector3(-4.0f, -5.0f, -6.0f)));
+ EXPECT_THAT(m2.GetRow(2), IsClose(Vector3(-7.0f, -8.0f, -9.0f)));
+
+ Matrix3x3 m3 = m1 + (-m1);
+ EXPECT_THAT(m3, IsClose(Matrix3x3::CreateZero()));
}
TEST(MATH_Matrix3x3, TestTranspose)
@@ -425,11 +440,33 @@ namespace UnitTest
TEST(MATH_Matrix3x3, TestScaleAccess)
{
Matrix3x3 m1 = Matrix3x3::CreateRotationX(DegToRad(40.0f)) * Matrix3x3::CreateScale(Vector3(2.0f, 3.0f, 4.0f));
- AZ_TEST_ASSERT(m1.RetrieveScale().IsClose(Vector3(2.0f, 3.0f, 4.0f)));
- AZ_TEST_ASSERT(m1.ExtractScale().IsClose(Vector3(2.0f, 3.0f, 4.0f)));
- AZ_TEST_ASSERT(m1.RetrieveScale().IsClose(Vector3::CreateOne()));
+ EXPECT_THAT(m1.RetrieveScale(), IsClose(Vector3(2.0f, 3.0f, 4.0f)));
+ EXPECT_THAT(m1.ExtractScale(), IsClose(Vector3(2.0f, 3.0f, 4.0f)));
+ EXPECT_THAT(m1.RetrieveScale(), IsClose(Vector3::CreateOne()));
m1.MultiplyByScale(Vector3(3.0f, 4.0f, 5.0f));
- AZ_TEST_ASSERT(m1.RetrieveScale().IsClose(Vector3(3.0f, 4.0f, 5.0f)));
+ EXPECT_THAT(m1.RetrieveScale(), IsClose(Vector3(3.0f, 4.0f, 5.0f)));
+ }
+
+ TEST(MATH_Matrix3x3, TestScaleSqAccess)
+ {
+ Matrix3x3 m1 = Matrix3x3::CreateRotationX(DegToRad(40.0f)) * Matrix3x3::CreateScale(Vector3(2.0f, 3.0f, 4.0f));
+ EXPECT_THAT(m1.RetrieveScaleSq(), IsClose(Vector3(4.0f, 9.0f, 16.0f)));
+ m1.ExtractScale();
+ EXPECT_THAT(m1.RetrieveScaleSq(), IsClose(Vector3::CreateOne()));
+ m1.MultiplyByScale(Vector3(3.0f, 4.0f, 5.0f));
+ EXPECT_THAT(m1.RetrieveScaleSq(), IsClose(Vector3(9.0f, 16.0f, 25.0f)));
+ }
+
+ TEST(MATH_Matrix3x3, TestReciprocalScaled)
+ {
+ Matrix3x3 orthogonalMatrix = Matrix3x3::CreateRotationX(DegToRad(40.0f));
+ EXPECT_THAT(orthogonalMatrix.GetReciprocalScaled(), IsClose(orthogonalMatrix));
+ const AZ::Vector3 scale(2.8f, 0.7f, 1.3f);
+ AZ::Matrix3x3 scaledMatrix = orthogonalMatrix;
+ scaledMatrix.MultiplyByScale(scale);
+ AZ::Matrix3x3 reciprocalScaledMatrix = orthogonalMatrix;
+ reciprocalScaledMatrix.MultiplyByScale(scale.GetReciprocal());
+ EXPECT_THAT(scaledMatrix.GetReciprocalScaled(), IsClose(reciprocalScaledMatrix));
}
TEST(MATH_Matrix3x3, TestPolarDecomposition)
diff --git a/Code/Framework/AzCore/Tests/Math/Matrix3x4Tests.cpp b/Code/Framework/AzCore/Tests/Math/Matrix3x4Tests.cpp
index 353b46874b..0bb64411e6 100644
--- a/Code/Framework/AzCore/Tests/Math/Matrix3x4Tests.cpp
+++ b/Code/Framework/AzCore/Tests/Math/Matrix3x4Tests.cpp
@@ -467,53 +467,136 @@ namespace UnitTest
EXPECT_THAT(matrix.Multiply3x3(axisDirection), IsClose(forwardDirection));
}
- TEST(MATH_Matrix3x4, MultiplyByMatrix3x4)
+ TEST(MATH_Matrix3x4, TestMatrixMultiplication)
{
- const AZ::Matrix3x4 matrix1 = AZ::Matrix3x4::CreateFromValue(1.2f);
- const AZ::Matrix3x4 matrix2 = AZ::Matrix3x4::CreateDiagonal(AZ::Vector3(1.3f, 1.5f, 0.4f));
- const AZ::Matrix3x4 matrix3 = AZ::Matrix3x4::CreateFromQuaternionAndTranslation(
- AZ::Quaternion(0.42f, 0.46f, -0.66f, 0.42f), AZ::Vector3(2.8f, -3.7f, 1.6f));
- const AZ::Matrix3x4 matrix4 = AZ::Matrix3x4::CreateRotationX(-0.7f) * AZ::Matrix3x4::CreateScale(AZ::Vector3(0.6f, 1.3f, 0.7f));
- AZ::Matrix3x4 matrix5 = matrix1;
- matrix5 *= matrix4;
- const AZ::Vector3 vector(1.9f, 2.3f, 0.2f);
- EXPECT_TRUE((matrix1 * (matrix2 * matrix3)).IsClose((matrix1 * matrix2) * matrix3));
- EXPECT_THAT((matrix3 * matrix4) * vector, IsClose(matrix3 * (matrix4 * vector)));
- EXPECT_TRUE((matrix2 * AZ::Matrix3x4::Identity()).IsClose(matrix2));
- EXPECT_TRUE((matrix3 * AZ::Matrix3x4::Identity()).IsClose(AZ::Matrix3x4::Identity() * matrix3));
- EXPECT_TRUE(matrix5.IsClose(matrix1 * matrix4));
+ AZ::Matrix3x4 m1;
+ m1.SetRow(0, 1.0f, 2.0f, 3.0f, 4.0f);
+ m1.SetRow(1, 5.0f, 6.0f, 7.0f, 8.0f);
+ m1.SetRow(2, 9.0f, 10.0f, 11.0f, 12.0f);
+ AZ::Matrix3x4 m2;
+ m2.SetRow(0, 7.0f, 8.0f, 9.0f, 10.0f);
+ m2.SetRow(1, 11.0f, 12.0f, 13.0f, 14.0f);
+ m2.SetRow(2, 15.0f, 16.0f, 17.0f, 18.0f);
+ AZ::Matrix3x4 m3 = m1 * m2;
+ EXPECT_THAT(m3.GetRow(0), IsClose(AZ::Vector4(74.0f, 80.0f, 86.0f, 96.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(AZ::Vector4(206.0f, 224.0f, 242.0f, 268.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(AZ::Vector4(338.0f, 368.0f, 398.0f, 440.0f)));
+ AZ::Matrix3x4 m4 = m1;
+ m4 *= m2;
+ EXPECT_THAT(m4.GetRow(0), IsClose(AZ::Vector4(74.0f, 80.0f, 86.0f, 96.0f)));
+ EXPECT_THAT(m4.GetRow(1), IsClose(AZ::Vector4(206.0f, 224.0f, 242.0f, 268.0f)));
+ EXPECT_THAT(m4.GetRow(2), IsClose(AZ::Vector4(338.0f, 368.0f, 398.0f, 440.0f)));
}
- TEST(MATH_Matrix3x4, AddMatrix3x4)
+ TEST(MATH_Matrix3x4, TestSum)
{
- const AZ::Matrix3x4 matrix1 = AZ::Matrix3x4::CreateFromValue(1.2f);
- const AZ::Matrix3x4 matrix2 = AZ::Matrix3x4::CreateDiagonal(AZ::Vector3(1.3f, 1.5f, 0.4f));
- const AZ::Matrix3x4 matrix3 = AZ::Matrix3x4::CreateFromQuaternionAndTranslation(
- AZ::Quaternion(0.42f, 0.46f, -0.66f, 0.42f), AZ::Vector3(2.8f, -3.7f, 1.6f));
- const AZ::Matrix3x4 matrix4 = AZ::Matrix3x4::CreateRotationX(-0.7f) * AZ::Matrix3x4::CreateScale(AZ::Vector3(0.6f, 1.3f, 0.7f));
- AZ::Matrix3x4 matrix5 = matrix1;
- matrix5 += matrix4;
- EXPECT_THAT(matrix1 + (matrix2 + matrix3), IsClose((matrix1 + matrix2) + matrix3));
- EXPECT_THAT(matrix2 + AZ::Matrix3x4::CreateZero(), IsClose(matrix2));
- EXPECT_THAT(matrix3 + AZ::Matrix3x4::CreateZero(), IsClose(AZ::Matrix3x4::CreateZero() + matrix3));
- EXPECT_THAT(matrix3 + matrix3, IsClose(matrix3 * 2.0f));
- EXPECT_THAT(matrix5, IsClose(matrix1 + matrix4));
+ AZ::Matrix3x4 m1;
+ m1.SetRow(0, 1.0f, 2.0f, 3.0f, 4.0f);
+ m1.SetRow(1, 5.0f, 6.0f, 7.0f, 8.0f);
+ m1.SetRow(2, 9.0f, 10.0f, 11.0f, 12.0f);
+ AZ::Matrix3x4 m2;
+ m2.SetRow(0, 7.0f, 8.0f, 9.0f, 10.0f);
+ m2.SetRow(1, 11.0f, 12.0f, 13.0f, 14.0f);
+ m2.SetRow(2, 15.0f, 16.0f, 17.0f, 18.0f);
+
+ AZ::Matrix3x4 m3 = m1 + m2;
+ EXPECT_THAT(m3.GetRow(0), IsClose(AZ::Vector4(8.0f, 10.0f, 12.0f, 14.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(AZ::Vector4(16.0f, 18.0f, 20.0f, 22.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(AZ::Vector4(24.0f, 26.0f, 28.0f, 30.0f)));
+
+ m3 = m1;
+ m3 += m2;
+ EXPECT_THAT(m3.GetRow(0), IsClose(AZ::Vector4(8.0f, 10.0f, 12.0f, 14.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(AZ::Vector4(16.0f, 18.0f, 20.0f, 22.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(AZ::Vector4(24.0f, 26.0f, 28.0f, 30.0f)));
}
- TEST(MATH_Matrix3x4, MultiplyByScalar)
+ TEST(MATH_Matrix3x4, TestDifference)
{
- const AZ::Vector4 row0(1.488f, 2.56f, 0.096f, 2.3f);
- const AZ::Vector4 row1(0.384f, -1.92f, 0.428f, -1.6f);
- const AZ::Vector4 row2(1.28f, -2.4f, -0.24f, 3.7f);
- const float scalar = 3.2f;
- const AZ::Vector4 row0Result = row0 * scalar;
- const AZ::Vector4 row1Result = row1 * scalar;
- const AZ::Vector4 row2Result = row2 * scalar;
- AZ::Matrix3x4 matrix = AZ::Matrix3x4::CreateFromRows(row0, row1, row2);
- EXPECT_THAT(matrix * 0.0f, IsClose(AZ::Matrix3x4::CreateZero()));
- EXPECT_THAT(matrix * 1.0f, IsClose(matrix));
- EXPECT_THAT(matrix * scalar, IsClose(AZ::Matrix3x4::CreateFromRows(row0Result, row1Result, row2Result)));
- EXPECT_THAT(matrix * 2.0f, IsClose(matrix + matrix));
+ AZ::Matrix3x4 m1;
+ m1.SetRow(0, 1.0f, 2.0f, 3.0f, 4.0f);
+ m1.SetRow(1, 5.0f, 6.0f, 7.0f, 8.0f);
+ m1.SetRow(2, 9.0f, 10.0f, 11.0f, 12.0f);
+ AZ::Matrix3x4 m2;
+ m2.SetRow(0, 7.0f, 8.0f, 9.0f, 10.0f);
+ m2.SetRow(1, 11.0f, 12.0f, 13.0f, 14.0f);
+ m2.SetRow(2, 15.0f, 16.0f, 17.0f, 18.0f);
+
+ AZ::Matrix3x4 m3 = m1 - m2;
+ EXPECT_THAT(m3.GetRow(0), IsClose(AZ::Vector4(-6.0f, -6.0f, -6.0f, -6.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(AZ::Vector4(-6.0f, -6.0f, -6.0f, -6.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(AZ::Vector4(-6.0f, -6.0f, -6.0f, -6.0f)));
+ m3 = m1;
+ m3 -= m2;
+ EXPECT_THAT(m3.GetRow(0), IsClose(AZ::Vector4(-6.0f, -6.0f, -6.0f, -6.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(AZ::Vector4(-6.0f, -6.0f, -6.0f, -6.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(AZ::Vector4(-6.0f, -6.0f, -6.0f, -6.0f)));
+ }
+
+ TEST(MATH_Matrix3x4, TestScalarMultiplication)
+ {
+ AZ::Matrix3x4 m1;
+ m1.SetRow(0, 1.0f, 2.0f, 3.0f, 4.0f);
+ m1.SetRow(1, 5.0f, 6.0f, 7.0f, 8.0f);
+ m1.SetRow(2, 9.0f, 10.0f, 11.0f, 12.0f);
+ AZ::Matrix3x4 m2;
+ m2.SetRow(0, 7.0f, 8.0f, 9.0f, 10.0f);
+ m2.SetRow(1, 11.0f, 12.0f, 13.0f, 14.0f);
+ m2.SetRow(2, 15.0f, 16.0f, 17.0f, 18.0f);
+
+ AZ::Matrix3x4 m3 = m1 * 2.0f;
+ EXPECT_THAT(m3.GetRow(0), IsClose(AZ::Vector4(2.0f, 4.0f, 6.0f, 8.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(AZ::Vector4(10.0f, 12.0f, 14.0f, 16.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(AZ::Vector4(18.0f, 20.0f, 22.0f, 24.0f)));
+ m3 = m1;
+ m3 *= 2.0f;
+ EXPECT_THAT(m3.GetRow(0), IsClose(AZ::Vector4(2.0f, 4.0f, 6.0f, 8.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(AZ::Vector4(10.0f, 12.0f, 14.0f, 16.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(AZ::Vector4(18.0f, 20.0f, 22.0f, 24.0f)));
+ m3 = 2.0f * m1;
+ EXPECT_THAT(m3.GetRow(0), IsClose(AZ::Vector4(2.0f, 4.0f, 6.0f, 8.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(AZ::Vector4(10.0f, 12.0f, 14.0f, 16.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(AZ::Vector4(18.0f, 20.0f, 22.0f, 24.0f)));
+ }
+
+ TEST(MATH_Matrix3x4, TestScalarDivision)
+ {
+ AZ::Matrix3x4 m1;
+ m1.SetRow(0, 1.0f, 2.0f, 3.0f, 4.0f);
+ m1.SetRow(1, 5.0f, 6.0f, 7.0f, 8.0f);
+ m1.SetRow(2, 9.0f, 10.0f, 11.0f, 12.0f);
+ AZ::Matrix3x4 m2;
+ m2.SetRow(0, 7.0f, 8.0f, 9.0f, 10.0f);
+ m2.SetRow(1, 11.0f, 12.0f, 13.0f, 14.0f);
+ m2.SetRow(2, 15.0f, 16.0f, 17.0f, 18.0f);
+
+ AZ::Matrix3x4 m3 = m1 / 0.5f;
+ EXPECT_THAT(m3.GetRow(0), IsClose(AZ::Vector4(2.0f, 4.0f, 6.0f, 8.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(AZ::Vector4(10.0f, 12.0f, 14.0f, 16.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(AZ::Vector4(18.0f, 20.0f, 22.0f, 24.0f)));
+ m3 = m1;
+ m3 /= 0.5f;
+ EXPECT_THAT(m3.GetRow(0), IsClose(AZ::Vector4(2.0f, 4.0f, 6.0f, 8.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(AZ::Vector4(10.0f, 12.0f, 14.0f, 16.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(AZ::Vector4(18.0f, 20.0f, 22.0f, 24.0f)));
+ }
+
+ TEST(MATH_Matrix3x4, TestNegation)
+ {
+ AZ::Matrix3x4 m1;
+ m1.SetRow(0, 1.0f, 2.0f, 3.0f, 4.0f);
+ m1.SetRow(1, 5.0f, 6.0f, 7.0f, 8.0f);
+ m1.SetRow(2, 9.0f, 10.0f, 11.0f, 12.0f);
+ EXPECT_THAT(-(-m1), IsClose(m1));
+ EXPECT_THAT(-AZ::Matrix3x4::CreateZero(), IsClose(AZ::Matrix3x4::CreateZero()));
+
+ AZ::Matrix3x4 m2 = -m1;
+ EXPECT_THAT(m2.GetRow(0), IsClose(AZ::Vector4(-1.0f, -2.0f, -3.0f, -4.0f)));
+ EXPECT_THAT(m2.GetRow(1), IsClose(AZ::Vector4(-5.0f, -6.0f, -7.0f, -8.0f)));
+ EXPECT_THAT(m2.GetRow(2), IsClose(AZ::Vector4(-9.0f, -10.0f, -11.0f, -12.0f)));
+
+ AZ::Matrix3x4 m3 = m1 + (-m1);
+ EXPECT_THAT(m3, IsClose(AZ::Matrix3x4::CreateZero()));
}
TEST(MATH_Matrix3x4, MultiplyByVector3)
diff --git a/Code/Framework/AzCore/Tests/Math/Matrix4x4Tests.cpp b/Code/Framework/AzCore/Tests/Math/Matrix4x4Tests.cpp
index 851de490d0..a9baa3ddea 100644
--- a/Code/Framework/AzCore/Tests/Math/Matrix4x4Tests.cpp
+++ b/Code/Framework/AzCore/Tests/Math/Matrix4x4Tests.cpp
@@ -246,16 +246,16 @@ namespace UnitTest
m2.SetRow(2, 15.0f, 16.0f, 17.0f, 18.0f);
m2.SetRow(3, 19.0f, 20.0f, 21.0f, 22.0f);
Matrix4x4 m3 = m1 * m2;
- AZ_TEST_ASSERT(m3.GetRow(0).IsClose(Vector4(150.0f, 160.0f, 170.0f, 180.0f)));
- AZ_TEST_ASSERT(m3.GetRow(1).IsClose(Vector4(358.0f, 384.0f, 410.0f, 436.0f)));
- AZ_TEST_ASSERT(m3.GetRow(2).IsClose(Vector4(566.0f, 608.0f, 650.0f, 692.0f)));
- AZ_TEST_ASSERT(m3.GetRow(3).IsClose(Vector4(774.0f, 832.0f, 890.0f, 948.0f)));
+ EXPECT_THAT(m3.GetRow(0), IsClose(Vector4(150.0f, 160.0f, 170.0f, 180.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(Vector4(358.0f, 384.0f, 410.0f, 436.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(Vector4(566.0f, 608.0f, 650.0f, 692.0f)));
+ EXPECT_THAT(m3.GetRow(3), IsClose(Vector4(774.0f, 832.0f, 890.0f, 948.0f)));
Matrix4x4 m4 = m1;
m4 *= m2;
- AZ_TEST_ASSERT(m4.GetRow(0).IsClose(Vector4(150.0f, 160.0f, 170.0f, 180.0f)));
- AZ_TEST_ASSERT(m4.GetRow(1).IsClose(Vector4(358.0f, 384.0f, 410.0f, 436.0f)));
- AZ_TEST_ASSERT(m4.GetRow(2).IsClose(Vector4(566.0f, 608.0f, 650.0f, 692.0f)));
- AZ_TEST_ASSERT(m4.GetRow(3).IsClose(Vector4(774.0f, 832.0f, 890.0f, 948.0f)));
+ EXPECT_THAT(m4.GetRow(0), IsClose(Vector4(150.0f, 160.0f, 170.0f, 180.0f)));
+ EXPECT_THAT(m4.GetRow(1), IsClose(Vector4(358.0f, 384.0f, 410.0f, 436.0f)));
+ EXPECT_THAT(m4.GetRow(2), IsClose(Vector4(566.0f, 608.0f, 650.0f, 692.0f)));
+ EXPECT_THAT(m4.GetRow(3), IsClose(Vector4(774.0f, 832.0f, 890.0f, 948.0f)));
}
TEST(MATH_Matrix4x4, TestVectorMultiplication)
@@ -265,18 +265,148 @@ namespace UnitTest
m1.SetRow(1, 5.0f, 6.0f, 7.0f, 8.0f);
m1.SetRow(2, 9.0f, 10.0f, 11.0f, 12.0f);
m1.SetRow(3, 13.0f, 14.0f, 15.0f, 16.0f);
- AZ_TEST_ASSERT((m1 * Vector3(1.0f, 2.0f, 3.0f)).IsClose(Vector3(18.0f, 46.0f, 74.0f)));
- AZ_TEST_ASSERT((m1 * Vector4(1.0f, 2.0f, 3.0f, 4.0f)).IsClose(Vector4(30.0f, 70.0f, 110.0f, 150.0f)));
- AZ_TEST_ASSERT(m1.TransposedMultiply3x3(Vector3(1.0f, 2.0f, 3.0f)).IsClose(Vector3(38.0f, 44.0f, 50.0f)));
- AZ_TEST_ASSERT(m1.Multiply3x3(Vector3(1.0f, 2.0f, 3.0f)).IsClose(Vector3(14.0f, 38.0f, 62.0f)));
+ EXPECT_THAT((m1 * Vector3(1.0f, 2.0f, 3.0f)), IsClose(Vector3(18.0f, 46.0f, 74.0f)));
+ EXPECT_THAT((m1 * Vector4(1.0f, 2.0f, 3.0f, 4.0f)), IsClose(Vector4(30.0f, 70.0f, 110.0f, 150.0f)));
+ EXPECT_THAT(m1.TransposedMultiply3x3(Vector3(1.0f, 2.0f, 3.0f)), IsClose(Vector3(38.0f, 44.0f, 50.0f)));
+ EXPECT_THAT(m1.Multiply3x3(Vector3(1.0f, 2.0f, 3.0f)), IsClose(Vector3(14.0f, 38.0f, 62.0f)));
Vector3 v1(1.0f, 2.0f, 3.0f);
- AZ_TEST_ASSERT((v1 * m1).IsClose(Vector3(51.0f, 58.0f, 65.0f)));
+ EXPECT_THAT((v1 * m1), IsClose(Vector3(51.0f, 58.0f, 65.0f)));
v1 *= m1;
- AZ_TEST_ASSERT(v1.IsClose(Vector3(51.0f, 58.0f, 65.0f)));
+ EXPECT_THAT(v1, IsClose(Vector3(51.0f, 58.0f, 65.0f)));
Vector4 v2(1.0f, 2.0f, 3.0f, 4.0f);
- AZ_TEST_ASSERT((v2 * m1).IsClose(Vector4(90.0f, 100.0f, 110.0f, 120.0f)));
+ EXPECT_THAT((v2 * m1), IsClose(Vector4(90.0f, 100.0f, 110.0f, 120.0f)));
v2 *= m1;
- AZ_TEST_ASSERT(v2.IsClose(Vector4(90.0f, 100.0f, 110.0f, 120.0f)));
+ EXPECT_THAT(v2, IsClose(Vector4(90.0f, 100.0f, 110.0f, 120.0f)));
+ }
+
+ TEST(MATH_Matrix4x4, TestSum)
+ {
+ Matrix4x4 m1;
+ m1.SetRow(0, 1.0f, 2.0f, 3.0f, 4.0f);
+ m1.SetRow(1, 5.0f, 6.0f, 7.0f, 8.0f);
+ m1.SetRow(2, 9.0f, 10.0f, 11.0f, 12.0f);
+ m1.SetRow(3, 13.0f, 14.0f, 15.0f, 16.0f);
+ Matrix4x4 m2;
+ m2.SetRow(0, 7.0f, 8.0f, 9.0f, 10.0f);
+ m2.SetRow(1, 11.0f, 12.0f, 13.0f, 14.0f);
+ m2.SetRow(2, 15.0f, 16.0f, 17.0f, 18.0f);
+ m2.SetRow(3, 19.0f, 20.0f, 21.0f, 22.0f);
+
+ Matrix4x4 m3 = m1 + m2;
+ EXPECT_THAT(m3.GetRow(0), IsClose(Vector4(8.0f, 10.0f, 12.0f, 14.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(Vector4(16.0f, 18.0f, 20.0f, 22.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(Vector4(24.0f, 26.0f, 28.0f, 30.0f)));
+ EXPECT_THAT(m3.GetRow(3), IsClose(Vector4(32.0f, 34.0f, 36.0f, 38.0f)));
+
+ m3 = m1;
+ m3 += m2;
+ EXPECT_THAT(m3.GetRow(0), IsClose(Vector4(8.0f, 10.0f, 12.0f, 14.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(Vector4(16.0f, 18.0f, 20.0f, 22.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(Vector4(24.0f, 26.0f, 28.0f, 30.0f)));
+ EXPECT_THAT(m3.GetRow(3), IsClose(Vector4(32.0f, 34.0f, 36.0f, 38.0f)));
+ }
+
+ TEST(MATH_Matrix4x4, TestDifference)
+ {
+ Matrix4x4 m1;
+ m1.SetRow(0, 1.0f, 2.0f, 3.0f, 4.0f);
+ m1.SetRow(1, 5.0f, 6.0f, 7.0f, 8.0f);
+ m1.SetRow(2, 9.0f, 10.0f, 11.0f, 12.0f);
+ m1.SetRow(3, 13.0f, 14.0f, 15.0f, 16.0f);
+ Matrix4x4 m2;
+ m2.SetRow(0, 7.0f, 8.0f, 9.0f, 10.0f);
+ m2.SetRow(1, 11.0f, 12.0f, 13.0f, 14.0f);
+ m2.SetRow(2, 15.0f, 16.0f, 17.0f, 18.0f);
+ m2.SetRow(3, 19.0f, 20.0f, 21.0f, 22.0f);
+
+ Matrix4x4 m3 = m1 - m2;
+ EXPECT_THAT(m3.GetRow(0), IsClose(Vector4(-6.0f, -6.0f, -6.0f, -6.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(Vector4(-6.0f, -6.0f, -6.0f, -6.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(Vector4(-6.0f, -6.0f, -6.0f, -6.0f)));
+ EXPECT_THAT(m3.GetRow(3), IsClose(Vector4(-6.0f, -6.0f, -6.0f, -6.0f)));
+ m3 = m1;
+ m3 -= m2;
+ EXPECT_THAT(m3.GetRow(0), IsClose(Vector4(-6.0f, -6.0f, -6.0f, -6.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(Vector4(-6.0f, -6.0f, -6.0f, -6.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(Vector4(-6.0f, -6.0f, -6.0f, -6.0f)));
+ EXPECT_THAT(m3.GetRow(3), IsClose(Vector4(-6.0f, -6.0f, -6.0f, -6.0f)));
+ }
+
+ TEST(MATH_Matrix4x4, TestScalarMultiplication)
+ {
+ Matrix4x4 m1;
+ m1.SetRow(0, 1.0f, 2.0f, 3.0f, 4.0f);
+ m1.SetRow(1, 5.0f, 6.0f, 7.0f, 8.0f);
+ m1.SetRow(2, 9.0f, 10.0f, 11.0f, 12.0f);
+ m1.SetRow(3, 13.0f, 14.0f, 15.0f, 16.0f);
+ Matrix4x4 m2;
+ m2.SetRow(0, 7.0f, 8.0f, 9.0f, 10.0f);
+ m2.SetRow(1, 11.0f, 12.0f, 13.0f, 14.0f);
+ m2.SetRow(2, 15.0f, 16.0f, 17.0f, 18.0f);
+ m2.SetRow(3, 19.0f, 20.0f, 21.0f, 22.0f);
+
+ Matrix4x4 m3 = m1 * 2.0f;
+ EXPECT_THAT(m3.GetRow(0), IsClose(Vector4(2.0f, 4.0f, 6.0f, 8.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(Vector4(10.0f, 12.0f, 14.0f, 16.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(Vector4(18.0f, 20.0f, 22.0f, 24.0f)));
+ EXPECT_THAT(m3.GetRow(3), IsClose(Vector4(26.0f, 28.0f, 30.0f, 32.0f)));
+ m3 = m1;
+ m3 *= 2.0f;
+ EXPECT_THAT(m3.GetRow(0), IsClose(Vector4(2.0f, 4.0f, 6.0f, 8.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(Vector4(10.0f, 12.0f, 14.0f, 16.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(Vector4(18.0f, 20.0f, 22.0f, 24.0f)));
+ EXPECT_THAT(m3.GetRow(3), IsClose(Vector4(26.0f, 28.0f, 30.0f, 32.0f)));
+ m3 = 2.0f * m1;
+ EXPECT_THAT(m3.GetRow(0), IsClose(Vector4(2.0f, 4.0f, 6.0f, 8.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(Vector4(10.0f, 12.0f, 14.0f, 16.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(Vector4(18.0f, 20.0f, 22.0f, 24.0f)));
+ EXPECT_THAT(m3.GetRow(3), IsClose(Vector4(26.0f, 28.0f, 30.0f, 32.0f)));
+ }
+
+ TEST(MATH_Matrix4x4, TestScalarDivision)
+ {
+ Matrix4x4 m1;
+ m1.SetRow(0, 1.0f, 2.0f, 3.0f, 4.0f);
+ m1.SetRow(1, 5.0f, 6.0f, 7.0f, 8.0f);
+ m1.SetRow(2, 9.0f, 10.0f, 11.0f, 12.0f);
+ m1.SetRow(3, 13.0f, 14.0f, 15.0f, 16.0f);
+ Matrix4x4 m2;
+ m2.SetRow(0, 7.0f, 8.0f, 9.0f, 10.0f);
+ m2.SetRow(1, 11.0f, 12.0f, 13.0f, 14.0f);
+ m2.SetRow(2, 15.0f, 16.0f, 17.0f, 18.0f);
+ m2.SetRow(3, 19.0f, 20.0f, 21.0f, 22.0f);
+
+ Matrix4x4 m3 = m1 / 0.5f;
+ EXPECT_THAT(m3.GetRow(0), IsClose(Vector4(2.0f, 4.0f, 6.0f, 8.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(Vector4(10.0f, 12.0f, 14.0f, 16.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(Vector4(18.0f, 20.0f, 22.0f, 24.0f)));
+ EXPECT_THAT(m3.GetRow(3), IsClose(Vector4(26.0f, 28.0f, 30.0f, 32.0f)));
+ m3 = m1;
+ m3 /= 0.5f;
+ EXPECT_THAT(m3.GetRow(0), IsClose(Vector4(2.0f, 4.0f, 6.0f, 8.0f)));
+ EXPECT_THAT(m3.GetRow(1), IsClose(Vector4(10.0f, 12.0f, 14.0f, 16.0f)));
+ EXPECT_THAT(m3.GetRow(2), IsClose(Vector4(18.0f, 20.0f, 22.0f, 24.0f)));
+ EXPECT_THAT(m3.GetRow(3), IsClose(Vector4(26.0f, 28.0f, 30.0f, 32.0f)));
+ }
+
+ TEST(MATH_Matrix4x4, TestNegation)
+ {
+ Matrix4x4 m1;
+ m1.SetRow(0, 1.0f, 2.0f, 3.0f, 4.0f);
+ m1.SetRow(1, 5.0f, 6.0f, 7.0f, 8.0f);
+ m1.SetRow(2, 9.0f, 10.0f, 11.0f, 12.0f);
+ m1.SetRow(3, 13.0f, 14.0f, 15.0f, 16.0f);
+ EXPECT_THAT(-(-m1), IsClose(m1));
+ EXPECT_THAT(-Matrix4x4::CreateZero(), IsClose(Matrix4x4::CreateZero()));
+
+ Matrix4x4 m2 = -m1;
+ EXPECT_THAT(m2.GetRow(0), IsClose(Vector4(-1.0f, -2.0f, -3.0f, -4.0f)));
+ EXPECT_THAT(m2.GetRow(1), IsClose(Vector4(-5.0f, -6.0f, -7.0f, -8.0f)));
+ EXPECT_THAT(m2.GetRow(2), IsClose(Vector4(-9.0f, -10.0f, -11.0f, -12.0f)));
+ EXPECT_THAT(m2.GetRow(3), IsClose(Vector4(-13.0f, -14.0f, -15.0f, -16.0f)));
+
+ Matrix4x4 m3 = m1 + (-m1);
+ EXPECT_THAT(m3, IsClose(Matrix4x4::CreateZero()));
}
TEST(MATH_Matrix4x4, TestTranspose)
@@ -368,4 +498,36 @@ namespace UnitTest
m1.SetRow(3, 13.0f, 14.0f, 15.0f, 16.0f);
AZ_TEST_ASSERT(m1.GetDiagonal() == Vector4(1.0f, 6.0f, 11.0f, 16.0f));
}
+
+ TEST(MATH_Matrix4x4, TestScaleAccess)
+ {
+ Matrix4x4 m1 = Matrix4x4::CreateRotationX(DegToRad(40.0f)) * Matrix4x4::CreateScale(Vector3(2.0f, 3.0f, 4.0f));
+ EXPECT_THAT(m1.RetrieveScale(), IsClose(Vector3(2.0f, 3.0f, 4.0f)));
+ EXPECT_THAT(m1.ExtractScale(), IsClose(Vector3(2.0f, 3.0f, 4.0f)));
+ EXPECT_THAT(m1.RetrieveScale(), IsClose(Vector3::CreateOne()));
+ m1.MultiplyByScale(Vector3(3.0f, 4.0f, 5.0f));
+ EXPECT_THAT(m1.RetrieveScale(), IsClose(Vector3(3.0f, 4.0f, 5.0f)));
+ }
+
+ TEST(MATH_Matrix4x4, TestScaleSqAccess)
+ {
+ Matrix4x4 m1 = Matrix4x4::CreateRotationX(DegToRad(40.0f)) * Matrix4x4::CreateScale(Vector3(2.0f, 3.0f, 4.0f));
+ EXPECT_THAT(m1.RetrieveScaleSq(), IsClose(Vector3(4.0f, 9.0f, 16.0f)));
+ m1.ExtractScale();
+ EXPECT_THAT(m1.RetrieveScaleSq(), IsClose(Vector3::CreateOne()));
+ m1.MultiplyByScale(Vector3(3.0f, 4.0f, 5.0f));
+ EXPECT_THAT(m1.RetrieveScaleSq(), IsClose(Vector3(9.0f, 16.0f, 25.0f)));
+ }
+
+ TEST(MATH_Matrix4x4, TestReciprocalScaled)
+ {
+ Matrix4x4 orthogonalMatrix = Matrix4x4::CreateRotationX(DegToRad(40.0f));
+ EXPECT_THAT(orthogonalMatrix.GetReciprocalScaled(), IsClose(orthogonalMatrix));
+ const AZ::Vector3 scale(2.8f, 0.7f, 1.3f);
+ AZ::Matrix4x4 scaledMatrix = orthogonalMatrix;
+ scaledMatrix.MultiplyByScale(scale);
+ AZ::Matrix4x4 reciprocalScaledMatrix = orthogonalMatrix;
+ reciprocalScaledMatrix.MultiplyByScale(scale.GetReciprocal());
+ EXPECT_THAT(scaledMatrix.GetReciprocalScaled(), IsClose(reciprocalScaledMatrix));
+ }
}
diff --git a/Code/Framework/AzCore/Tests/Serialization/Json/BaseJsonSerializerTests.cpp b/Code/Framework/AzCore/Tests/Serialization/Json/BaseJsonSerializerTests.cpp
index 417cb10c8c..08de21b54f 100644
--- a/Code/Framework/AzCore/Tests/Serialization/Json/BaseJsonSerializerTests.cpp
+++ b/Code/Framework/AzCore/Tests/Serialization/Json/BaseJsonSerializerTests.cpp
@@ -110,7 +110,7 @@ namespace JsonSerializationTests
EXPECT_EQ(42, value);
}
- TEST_F(BaseJsonSerializerTests, ContinueLoading_PointerInstance_ValueLoadedCorrectly)
+ TEST_F(BaseJsonSerializerTests, ContinueLoading_ToPointerInstance_ValueLoadedCorrectly)
{
using namespace AZ::JsonSerializationResult;
@@ -126,6 +126,51 @@ namespace JsonSerializationTests
EXPECT_EQ(42, value);
}
+ TEST_F(BaseJsonSerializerTests, ContinueLoading_ToNullPointer_ValueLoadedCorrectly)
+ {
+ using namespace AZ::JsonSerializationResult;
+
+ rapidjson::Value json;
+ json.Set(42);
+ int* ptrValue = nullptr;
+
+ ResultCode result = ContinueLoading(&ptrValue, azrtti_typeid(), json, *m_jsonDeserializationContext, Flags::ResolvePointer);
+
+ EXPECT_EQ(Processing::Completed, result.GetProcessing());
+ ASSERT_NE(nullptr, ptrValue);
+ EXPECT_EQ(42, *ptrValue);
+
+ azfree(ptrValue, AZ::SystemAllocator, sizeof(int), alignof(int));
+ }
+
+ TEST_F(BaseJsonSerializerTests, ContinueLoading_DefaultToNullPointer_ValueLoadedCorrectly)
+ {
+ using namespace AZ::JsonSerializationResult;
+
+ rapidjson::Value json(rapidjson::kObjectType);
+ int* ptrValue = nullptr;
+
+ ResultCode result = ContinueLoading(&ptrValue, azrtti_typeid(), json, *m_jsonDeserializationContext, Flags::ResolvePointer);
+
+ EXPECT_EQ(Processing::Completed, result.GetProcessing());
+ ASSERT_NE(nullptr, ptrValue);
+
+ azfree(ptrValue, AZ::SystemAllocator, sizeof(int), alignof(int));
+ }
+
+ TEST_F(BaseJsonSerializerTests, ContinueLoading_NullDeletesObject_ValueLoadedCorrectly)
+ {
+ using namespace AZ::JsonSerializationResult;
+
+ rapidjson::Value json(rapidjson::kNullType);
+ int* ptrValue = reinterpret_cast(azmalloc(sizeof(int), alignof(int), AZ::SystemAllocator));
+
+ ResultCode result = ContinueLoading(&ptrValue, azrtti_typeid(), json, *m_jsonDeserializationContext, Flags::ResolvePointer);
+
+ EXPECT_EQ(Processing::Completed, result.GetProcessing());
+ ASSERT_EQ(nullptr, ptrValue);
+ }
+
//
// ContinueStoring
//
@@ -156,6 +201,64 @@ namespace JsonSerializationTests
Expect_DocStrEq("42");
}
+ TEST_F(BaseJsonSerializerTests, ContinueStoring_StorePointerToFullDefaultedInstance_ValueStoredCorrectly)
+ {
+ using namespace AZ::JsonSerializationResult;
+
+ int value = 42;
+ int* ptrValue = &value;
+ int value2 = 42;
+ int* defaultPtrValue = &value2;
+
+ ResultCode result =
+ ContinueStoring(*m_jsonDocument, &ptrValue, &defaultPtrValue, azrtti_typeid(), *m_jsonSerializationContext, Flags::ResolvePointer);
+
+ EXPECT_EQ(Processing::Completed, result.GetProcessing());
+ Expect_DocStrEq("{}");
+ }
+
+ TEST_F(BaseJsonSerializerTests, ContinueStoring_StorePointerToNullptr_ValueStoredCorrectly)
+ {
+ using namespace AZ::JsonSerializationResult;
+
+ int* ptrValue = nullptr;
+
+ ResultCode result = ContinueStoring(
+ *m_jsonDocument, &ptrValue, nullptr, azrtti_typeid(), *m_jsonSerializationContext, Flags::ResolvePointer);
+
+ EXPECT_EQ(Processing::Completed, result.GetProcessing());
+ Expect_DocStrEq("null");
+ }
+
+ TEST_F(BaseJsonSerializerTests, ContinueStoring_StorePointerToNullptrWithValueDefault_ValueStoredCorrectly)
+ {
+ using namespace AZ::JsonSerializationResult;
+
+ int* ptrValue = nullptr;
+ int value2 = 42;
+ int* defaultPtrValue = &value2;
+
+ ResultCode result =
+ ContinueStoring(*m_jsonDocument, &ptrValue, &defaultPtrValue, azrtti_typeid(), *m_jsonSerializationContext, Flags::ResolvePointer);
+
+ EXPECT_EQ(Processing::Completed, result.GetProcessing());
+ Expect_DocStrEq("null");
+ }
+
+ TEST_F(BaseJsonSerializerTests, ContinueStoring_StorePointerToNullptrWithNullPtrDefault_NullPtrIsStored)
+ {
+ using namespace AZ::JsonSerializationResult;
+
+ int* ptrValue = nullptr;
+ int* defaultPtrValue = nullptr;
+
+ ResultCode result =
+ ContinueStoring(*m_jsonDocument, &ptrValue, &defaultPtrValue, azrtti_typeid(), *m_jsonSerializationContext, Flags::ResolvePointer);
+
+ EXPECT_EQ(Processing::Completed, result.GetProcessing());
+ Expect_DocStrEq("null");
+ }
+
TEST_F(BaseJsonSerializerTests, ContinueStoring_ReplaceDefault_ValueStoredCorrectly)
{
using namespace AZ::JsonSerializationResult;
diff --git a/Code/Framework/AzCore/Tests/Serialization/Json/SmartPointerSerializerTests.cpp b/Code/Framework/AzCore/Tests/Serialization/Json/SmartPointerSerializerTests.cpp
index df340a2e61..2fc131aae2 100644
--- a/Code/Framework/AzCore/Tests/Serialization/Json/SmartPointerSerializerTests.cpp
+++ b/Code/Framework/AzCore/Tests/Serialization/Json/SmartPointerSerializerTests.cpp
@@ -32,11 +32,6 @@ namespace JsonSerializationTests
return AZStd::make_shared();
}
- AZStd::shared_ptr CreateDefaultInstance() override
- {
- return AZStd::make_shared();
- }
-
void Reflect(AZStd::unique_ptr& context) override
{
context->RegisterGenericType();
@@ -51,6 +46,13 @@ namespace JsonSerializationTests
using SmartPointer = T;
using Base = SmartPointerBaseTestDescription;
+ AZStd::shared_ptr CreateDefaultInstance() override
+ {
+ auto result = AZStd::make_shared();
+ *result = SmartPointer(aznew SimpleClass());
+ return result;
+ }
+
AZStd::shared_ptr CreateFullySetInstance() override
{
auto result = AZStd::make_shared();
@@ -106,21 +108,6 @@ namespace JsonSerializationTests
}
};
- template class T>
- class SmartPointerSimpleClassWithInstanceTestDescription :
- public SmartPointerSimpleClassTestDescription
- {
- public:
- using SmartPointer = typename SmartPointerSimpleClassTestDescription::SmartPointer;
-
- AZStd::shared_ptr CreateDefaultInstance() override
- {
- auto result = AZStd::make_shared();
- *result = SmartPointer(aznew SimpleClass());
- return result;
- }
- };
-
template class T>
class SmartPointerSimpleDerivedClassTestDescription :
public SmartPointerBaseTestDescription>
@@ -129,6 +116,13 @@ namespace JsonSerializationTests
using SmartPointer = T;
using Base = SmartPointerBaseTestDescription;
+ AZStd::shared_ptr CreateDefaultInstance() override
+ {
+ auto result = AZStd::make_shared();
+ *result = SmartPointer(aznew BaseClass());
+ return result;
+ }
+
AZStd::shared_ptr CreateFullySetInstance() override
{
auto* instance = aznew SimpleInheritence();
@@ -272,6 +266,13 @@ namespace JsonSerializationTests
using SmartPointer = T;
using Base = SmartPointerBaseTestDescription;
+ AZStd::shared_ptr CreateDefaultInstance() override
+ {
+ auto result = AZStd::make_shared();
+ *result = SmartPointer(aznew BaseClass2());
+ return result;
+ }
+
AZStd::shared_ptr CreateFullySetInstance() override
{
auto* instance = aznew MultipleInheritence();
@@ -424,9 +425,6 @@ namespace JsonSerializationTests
SmartPointerSimpleClassTestDescription,
SmartPointerSimpleClassTestDescription,
SmartPointerSimpleClassTestDescription,
- SmartPointerSimpleClassWithInstanceTestDescription,
- SmartPointerSimpleClassWithInstanceTestDescription,
- SmartPointerSimpleClassWithInstanceTestDescription,
// Simple derived class, include single inheritance.
SmartPointerSimpleDerivedClassTestDescription,
SmartPointerSimpleDerivedClassTestDescription,
@@ -551,6 +549,37 @@ namespace JsonSerializationTests
EXPECT_EQ(nullptr, *instance);
}
+ TEST_F(JsonSmartPointerSerializerTests, Load_DefaultInstanceToNullptr_ReturnsSuccess)
+ {
+ namespace JSR = AZ::JsonSerializationResult;
+
+ SmartPointer instance;
+ AZStd::shared_ptr compare = m_description.CreateDefaultInstance();
+ m_jsonDocument->SetObject();
+
+ JSR::ResultCode result =
+ m_serializer.Load(&instance, azrtti_typeid(), *m_jsonDocument, *m_jsonDeserializationContext);
+
+ EXPECT_EQ(JSR::Processing::Completed, result.GetProcessing());
+ EXPECT_NE(nullptr, instance);
+ EXPECT_TRUE(m_description.AreEqual(instance, *compare));
+ }
+
+ TEST_F(JsonSmartPointerSerializerTests, Load_DefaultObjectDoesNotUpdateInstance_ReturnsSuccess)
+ {
+ namespace JSR = AZ::JsonSerializationResult;
+
+ AZStd::shared_ptr instance = m_description.CreateFullySetInstance();
+ AZStd::shared_ptr compare = m_description.CreateFullySetInstance();
+ m_jsonDocument->SetObject();
+
+ JSR::ResultCode result =
+ m_serializer.Load(instance.get(), azrtti_typeid(), *m_jsonDocument, *m_jsonDeserializationContext);
+
+ EXPECT_EQ(JSR::Processing::Completed, result.GetProcessing());
+ EXPECT_TRUE(m_description.AreEqual(*instance, *compare));
+ }
+
TEST_F(JsonSmartPointerSerializerTests, Load_InstanceBeingReplacedWithDifferentType_ReturnsSuccess)
{
namespace JSR = AZ::JsonSerializationResult;
@@ -720,13 +749,66 @@ namespace JsonSerializationTests
namespace JSR = AZ::JsonSerializationResult;
AZStd::shared_ptr instance = m_description.CreateFullySetInstance();
- SmartPointer nullPtr;
- JSR::ResultCode result = m_serializer.Store(*m_jsonDocument, instance.get(), &nullPtr,
+ SmartPointer defaultInstance;
+ JSR::ResultCode result = m_serializer.Store(
+ *m_jsonDocument, instance.get(), &defaultInstance,
azrtti_typeid(), *m_jsonSerializationContext);
EXPECT_EQ(JSR::Outcomes::Success, result.GetOutcome());
}
+ TEST_F(JsonSmartPointerSerializerTests, Store_ValuePointerIsNullPtr_ReturnsSuccessAndStoresNull)
+ {
+ namespace JSR = AZ::JsonSerializationResult;
+
+ SmartPointer instance;
+ AZStd::shared_ptr defaultInstance = m_description.CreateFullySetInstance();
+ JSR::ResultCode result = m_serializer.Store(
+ *m_jsonDocument, &instance, defaultInstance.get(), azrtti_typeid(), *m_jsonSerializationContext);
+
+ EXPECT_EQ(JSR::Outcomes::Success, result.GetOutcome());
+ EXPECT_TRUE(m_jsonDocument->IsNull());
+ }
+
+ TEST_F(JsonSmartPointerSerializerTests, Store_ValueAndDefaultPointersAreNullPtr_ReturnsSuccessAndStoresNull)
+ {
+ namespace JSR = AZ::JsonSerializationResult;
+
+ SmartPointer instance;
+ SmartPointer defaultInstance;
+ JSR::ResultCode result =
+ m_serializer.Store(*m_jsonDocument, &instance, &defaultInstance, azrtti_typeid(), *m_jsonSerializationContext);
+
+ EXPECT_EQ(JSR::Outcomes::DefaultsUsed, result.GetOutcome());
+ EXPECT_TRUE(m_jsonDocument->IsNull());
+ }
+
+ TEST_F(JsonSmartPointerSerializerTests, Store_ValueAndDefaultPointersAreBothDefault_ReturnsSuccess)
+ {
+ namespace JSR = AZ::JsonSerializationResult;
+
+ AZStd::shared_ptr instance = m_description.CreateDefaultInstance();
+ AZStd::shared_ptr defaultInstance = m_description.CreateDefaultInstance();
+ JSR::ResultCode result =
+ m_serializer.Store(*m_jsonDocument, instance.get(), defaultInstance.get(), azrtti_typeid(), *m_jsonSerializationContext);
+
+ EXPECT_EQ(JSR::Outcomes::DefaultsUsed, result.GetOutcome());
+ Expect_ExplicitDefault(*m_jsonDocument);
+ }
+
+ TEST_F(JsonSmartPointerSerializerTests, Store_ValueHasDefaultValuesAndDefaultHasNullPointer_ReturnsSuccess)
+ {
+ namespace JSR = AZ::JsonSerializationResult;
+
+ AZStd::shared_ptr instance = m_description.CreateDefaultInstance();
+ SmartPointer defaultInstance;
+ JSR::ResultCode result = m_serializer.Store(
+ *m_jsonDocument, instance.get(), &defaultInstance, azrtti_typeid(), *m_jsonSerializationContext);
+
+ EXPECT_EQ(JSR::Outcomes::DefaultsUsed, result.GetOutcome());
+ Expect_ExplicitDefault(*m_jsonDocument);
+ }
+
TEST_F(JsonSmartPointerSerializerTests, Store_DefaultPointerIsOtherClass_CompletesButDoesNotReturnDefaults)
{
namespace JSR = AZ::JsonSerializationResult;
@@ -749,7 +831,7 @@ namespace JsonSerializationTests
EXPECT_EQ(JSR::Processing::Completed, result.GetProcessing());
}
- TEST_F(JsonSmartPointerSerializerTests, Store_SaveAnClassThatIsNotReflected_ReturnsUnknown)
+ TEST_F(JsonSmartPointerSerializerTests, Store_ClassThatIsNotReflected_ReturnsUnknown)
{
namespace JSR = AZ::JsonSerializationResult;
diff --git a/Code/Framework/AzFramework/AzFramework/API/AtomActiveInterface.h b/Code/Framework/AzFramework/AzFramework/API/AtomActiveInterface.h
deleted file mode 100644
index 80d4f6c867..0000000000
--- a/Code/Framework/AzFramework/AzFramework/API/AtomActiveInterface.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
- * its licensors.
- *
- * For complete copyright and license terms please see the LICENSE at the root of this
- * distribution (the "License"). All use of this software is governed by the License,
- * or, if provided, by the license below or the license accompanying this file. Do not
- * remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- */
-#pragma once
-
-#include
-
-namespace AzFramework
-{
- class AtomActiveInterface
- {
- public:
- AZ_RTTI(AtomActiveInterface, "{4BB59C86-0848-485D-AB28-700540470B2B}");
-
- AtomActiveInterface() = default;
- virtual ~AtomActiveInterface() = default;
- };
-} // namespace AzFramework
diff --git a/Code/Framework/AzFramework/AzFramework/azframework_files.cmake b/Code/Framework/AzFramework/AzFramework/azframework_files.cmake
index b126a192ac..88f68d8bab 100644
--- a/Code/Framework/AzFramework/AzFramework/azframework_files.cmake
+++ b/Code/Framework/AzFramework/AzFramework/azframework_files.cmake
@@ -14,7 +14,6 @@ set(FILES
AzFrameworkModule.h
AzFrameworkModule.cpp
API/ApplicationAPI.h
- API/AtomActiveInterface.h
Application/Application.cpp
Application/Application.h
Archive/Archive.cpp
diff --git a/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/ViewportInteraction.h b/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/ViewportInteraction.h
index 56ff2010cd..884562d7e8 100644
--- a/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/ViewportInteraction.h
+++ b/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/ViewportInteraction.h
@@ -38,8 +38,9 @@ namespace AzManipulatorTestFramework
void SetGridSize(float size) override;
void SetAngularStep(float step) override;
int GetViewportId() const override;
- AZStd::optional ViewportScreenToWorld(const QPoint& screenPosition, float depth) override;
- AZStd::optional ViewportScreenToWorldRay(const QPoint& screenPosition) override;
+ AZStd::optional ViewportScreenToWorld(const AzFramework::ScreenPoint& screenPosition, float depth) override;
+ AZStd::optional ViewportScreenToWorldRay(
+ const AzFramework::ScreenPoint& screenPosition) override;
private:
// ViewportInteractionRequestBus ...
bool GridSnappingEnabled();
@@ -47,7 +48,7 @@ namespace AzManipulatorTestFramework
bool ShowGrid();
bool AngleSnappingEnabled();
float AngleStep();
- QPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition);
+ AzFramework::ScreenPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition);
private:
AZStd::unique_ptr m_nullDebugDisplayRequests;
const int m_viewportId = 1234; // Arbitrary viewport id for manipulator tests
diff --git a/Code/Framework/AzManipulatorTestFramework/Source/ViewportInteraction.cpp b/Code/Framework/AzManipulatorTestFramework/Source/ViewportInteraction.cpp
index 11f2a32441..ebef9dea30 100644
--- a/Code/Framework/AzManipulatorTestFramework/Source/ViewportInteraction.cpp
+++ b/Code/Framework/AzManipulatorTestFramework/Source/ViewportInteraction.cpp
@@ -66,10 +66,9 @@ namespace AzManipulatorTestFramework
return m_angularStep;
}
- QPoint ViewportInteraction::ViewportWorldToScreen(const AZ::Vector3& worldPosition)
+ AzFramework::ScreenPoint ViewportInteraction::ViewportWorldToScreen(const AZ::Vector3& worldPosition)
{
- auto pos = AzFramework::WorldToScreen(worldPosition, m_cameraState);
- return QPoint(pos.m_x, pos.m_y);
+ return AzFramework::WorldToScreen(worldPosition, m_cameraState);
}
void ViewportInteraction::SetCameraState(const AzFramework::CameraState& cameraState)
@@ -117,12 +116,14 @@ namespace AzManipulatorTestFramework
return m_viewportId;
}
- AZStd::optional ViewportInteraction::ViewportScreenToWorld([[maybe_unused]]const QPoint& screenPosition, [[maybe_unused]]float depth)
+ AZStd::optional ViewportInteraction::ViewportScreenToWorld(
+ [[maybe_unused]] const AzFramework::ScreenPoint& screenPosition, [[maybe_unused]] float depth)
{
return {};
}
- AZStd::optional ViewportInteraction::ViewportScreenToWorldRay([[maybe_unused]]const QPoint& screenPosition)
+ AZStd::optional ViewportInteraction::ViewportScreenToWorldRay(
+ [[maybe_unused]] const AzFramework::ScreenPoint& screenPosition)
{
return {};
}
diff --git a/Code/Framework/AzQtComponents/Platform/Windows/AzQtComponents/Utilities/HandleDpiAwareness_Windows.cpp b/Code/Framework/AzQtComponents/Platform/Windows/AzQtComponents/Utilities/HandleDpiAwareness_Windows.cpp
index 9ffe06f7e3..b834995bd9 100644
--- a/Code/Framework/AzQtComponents/Platform/Windows/AzQtComponents/Utilities/HandleDpiAwareness_Windows.cpp
+++ b/Code/Framework/AzQtComponents/Platform/Windows/AzQtComponents/Utilities/HandleDpiAwareness_Windows.cpp
@@ -16,7 +16,6 @@
#include
#include
-#include
#include
namespace AzQtComponents
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/API/EditorPythonConsoleBus.h b/Code/Framework/AzToolsFramework/AzToolsFramework/API/EditorPythonConsoleBus.h
index 4f5a349518..de4ff396b2 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/API/EditorPythonConsoleBus.h
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/API/EditorPythonConsoleBus.h
@@ -13,6 +13,12 @@
#include
#include
+#include
+
+namespace AZ
+{
+ struct BehaviorParameter;
+}
namespace AzToolsFramework
{
@@ -40,6 +46,8 @@ namespace AzToolsFramework
};
using GlobalFunctionCollection = AZStd::vector;
virtual void GetGlobalFunctionList(GlobalFunctionCollection& globalFunctionCollection) const = 0;
+
+ virtual AZStd::string FetchPythonTypeName(const AZ::BehaviorParameter& param) = 0;
};
//! Interface to signal the phases for the Python virtual machine
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/EditorVertexSelection.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/EditorVertexSelection.cpp
index 089037bbf3..4d10a4c171 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/EditorVertexSelection.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/EditorVertexSelection.cpp
@@ -127,8 +127,7 @@ namespace AzToolsFramework
ViewportInteraction::MainEditorViewportInteractionRequestBus::EventResult(
worldSurfacePosition, viewportId,
&ViewportInteraction::MainEditorViewportInteractionRequestBus::Events::PickTerrain,
- ViewportInteraction::QPointFromScreenPoint(
- mouseInteraction.m_mouseInteraction.m_mousePick.m_screenCoordinates));
+ mouseInteraction.m_mouseInteraction.m_mousePick.m_screenCoordinates);
AZ::Transform worldFromLocal;
AZ::TransformBus::EventResult(worldFromLocal, GetEntityId(), &AZ::TransformBus::Events::GetWorldTM);
@@ -402,10 +401,10 @@ namespace AzToolsFramework
vertexIndex, localVertex);
const AZ::Vector3 worldVertex = worldFromLocal.TransformPoint(AZ::AdaptVertexOut(localVertex));
- const QPoint screenPosition = GetScreenPosition(viewportId, worldVertex);
+ const AzFramework::ScreenPoint screenPosition = GetScreenPosition(viewportId, worldVertex);
// check if a vertex is inside the box select region
- if (editorBoxSelect.BoxRegion()->contains(screenPosition))
+ if (editorBoxSelect.BoxRegion()->contains(ViewportInteraction::QPointFromScreenPoint(screenPosition)))
{
// see if vertexIndex is in active selection
auto vertexIt = AZStd::find(
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/SurfaceManipulator.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/SurfaceManipulator.cpp
index e4d0cd59dd..f570c20a7e 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/SurfaceManipulator.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/SurfaceManipulator.cpp
@@ -103,8 +103,7 @@ namespace AzToolsFramework
ViewportInteraction::MainEditorViewportInteractionRequestBus::EventResult(
worldSurfacePosition, interaction.m_interactionId.m_viewportId,
&ViewportInteraction::MainEditorViewportInteractionRequestBus::Events::PickTerrain,
- ViewportInteraction::QPointFromScreenPoint(
- interaction.m_mousePick.m_screenCoordinates));
+ interaction.m_mousePick.m_screenCoordinates);
m_startInternal = CalculateManipulationDataStart(
worldFromLocalUniformScale, worldSurfacePosition, GetLocalPosition(),
@@ -129,8 +128,7 @@ namespace AzToolsFramework
ViewportInteraction::MainEditorViewportInteractionRequestBus::EventResult(
worldSurfacePosition, interaction.m_interactionId.m_viewportId,
&ViewportInteraction::MainEditorViewportInteractionRequestBus::Events::PickTerrain,
- ViewportInteraction::QPointFromScreenPoint(
- interaction.m_mousePick.m_screenCoordinates));
+ interaction.m_mousePick.m_screenCoordinates);
const GridSnapParameters gridSnapParams = GridSnapSettings(interaction.m_interactionId.m_viewportId);
@@ -150,8 +148,7 @@ namespace AzToolsFramework
ViewportInteraction::MainEditorViewportInteractionRequestBus::EventResult(
worldSurfacePosition, interaction.m_interactionId.m_viewportId,
&ViewportInteraction::MainEditorViewportInteractionRequestBus::Events::PickTerrain,
- ViewportInteraction::QPointFromScreenPoint(
- interaction.m_mousePick.m_screenCoordinates));
+ interaction.m_mousePick.m_screenCoordinates);
const GridSnapParameters gridSnapParams = GridSnapSettings(interaction.m_interactionId.m_viewportId);
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp
index 1e9cc35230..475510c52f 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp
@@ -96,9 +96,7 @@ namespace AzToolsFramework
// target templates of the other instances.
for (auto& nestedInstance : instances)
{
- PrefabUndoHelpers::RemoveLink(
- nestedInstance->GetTemplateId(), commonRootEntityOwningInstance->get().GetTemplateId(),
- nestedInstance->GetInstanceAlias(), nestedInstance->GetLinkId(), undoBatch.GetUndoBatch());
+ RemoveLink(nestedInstance, commonRootEntityOwningInstance->get().GetTemplateId(), undoBatch.GetUndoBatch());
}
PrefabUndoHelpers::UpdatePrefabInstance(
@@ -238,14 +236,9 @@ namespace AzToolsFramework
// Retrieve the owning instance of the common root entity, which will be our new instance's parent instance.
commonRootEntityOwningInstance = GetOwnerInstanceByEntityId(commonRootEntityId);
- if (!commonRootEntityOwningInstance)
- {
- AZ_Assert(
- false,
- "Failed to create prefab : Couldn't get a valid owning instance for the common root entity of the enities provided");
- return AZ::Failure(AZStd::string(
- "Failed to create prefab : Couldn't get a valid owning instance for the common root entity of the enities provided"));
- }
+ AZ_Assert(
+ commonRootEntityOwningInstance.has_value(),
+ "Failed to create prefab : Couldn't get a valid owning instance for the common root entity of the enities provided");
return AZ::Success();
}
@@ -287,6 +280,34 @@ namespace AzToolsFramework
m_prefabUndoCache.Store(containerEntityId, AZStd::move(containerEntityDomAfter));
}
+ void PrefabPublicHandler::RemoveLink(
+ AZStd::unique_ptr& sourceInstance, TemplateId targetTemplateId, UndoSystem::URSequencePoint* undoBatch)
+ {
+ LinkReference nestedInstanceLink = m_prefabSystemComponentInterface->FindLink(sourceInstance->GetLinkId());
+ AZ_Assert(
+ nestedInstanceLink.has_value(),
+ "A valid link was not found for one of the instances provided as input for the CreatePrefab operation.");
+
+ PrefabDomReference nestedInstanceLinkDom = nestedInstanceLink->get().GetLinkDom();
+ AZ_Assert(
+ nestedInstanceLinkDom.has_value(),
+ "A valid DOM was not found for the link corresponding to one of the instances provided as input for the "
+ "CreatePrefab operation.");
+
+ PrefabDomValueReference nestedInstanceLinkPatches =
+ PrefabDomUtils::FindPrefabDomValue(nestedInstanceLinkDom->get(), PrefabDomUtils::PatchesName);
+ AZ_Assert(
+ nestedInstanceLinkPatches.has_value(),
+ "A valid DOM for patches was not found for the link corresponding to one of the instances provided as input for the "
+ "CreatePrefab operation.");
+
+ PrefabDom patchesCopyForUndoSupport;
+ patchesCopyForUndoSupport.CopyFrom(nestedInstanceLinkPatches->get(), patchesCopyForUndoSupport.GetAllocator());
+ PrefabUndoHelpers::RemoveLink(
+ sourceInstance->GetTemplateId(), targetTemplateId, sourceInstance->GetInstanceAlias(), sourceInstance->GetLinkId(),
+ patchesCopyForUndoSupport, undoBatch);
+ }
+
PrefabOperationResult PrefabPublicHandler::SavePrefab(AZ::IO::Path filePath)
{
auto templateId = m_prefabSystemComponentInterface->GetTemplateIdFromFilePath(filePath.c_str());
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.h
index e83513dbff..5ade666a40 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.h
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.h
@@ -82,6 +82,16 @@ namespace AzToolsFramework
const EntityList& topLevelEntities, Instance& sourceInstance, TemplateId targetTemplateId,
UndoSystem::URSequencePoint* undoBatch, AZ::EntityId commonRootEntityId);
+ /**
+ * Removes the link between template of the sourceInstance and the template corresponding to targetTemplateId.
+ *
+ * \param sourceInstance The instance corresponding to the source template of the link to be removed.
+ * \param targetTemplateId The id of the target template of the link to be removed.
+ * \param undoBatch The undo batch to set as parent for this remove link action.
+ */
+ void RemoveLink(
+ AZStd::unique_ptr& sourceInstance, TemplateId targetTemplateId, UndoSystem::URSequencePoint* undoBatch);
+
/**
* Given a list of entityIds, finds the prefab instance that owns the common root entity of the entityIds.
*
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.cpp
index 2570367049..4413586e77 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.cpp
@@ -663,8 +663,9 @@ namespace AzToolsFramework
newLink.SetSourceTemplateId(linkSourceId);
newLink.SetInstanceName(instanceAlias.c_str());
newLink.GetLinkDom().SetObject();
- newLink.GetLinkDom().AddMember(rapidjson::StringRef(PrefabDomUtils::SourceName),
- rapidjson::StringRef(sourceTemplate.GetFilePath().c_str()), newLink.GetLinkDom().GetAllocator());
+ newLink.GetLinkDom().AddMember(
+ rapidjson::StringRef(PrefabDomUtils::SourceName), rapidjson::StringRef(sourceTemplate.GetFilePath().c_str()),
+ newLink.GetLinkDom().GetAllocator());
if (linkPatch && linkPatch->get().IsArray() && !(linkPatch->get().Empty()))
{
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndo.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndo.cpp
index ea3fa5d84d..ad0cdc166a 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndo.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndo.cpp
@@ -113,7 +113,7 @@ namespace AzToolsFramework
, m_sourceId(InvalidTemplateId)
, m_instanceAlias("")
, m_linkId(InvalidLinkId)
- , m_linkDom(PrefabDom())
+ , m_linkPatches(PrefabDom())
, m_linkStatus(LinkStatus::LINKSTATUS)
{
m_prefabSystemComponentInterface = AZ::Interface::Get();
@@ -124,7 +124,7 @@ namespace AzToolsFramework
const TemplateId& targetId,
const TemplateId& sourceId,
const InstanceAlias& instanceAlias,
- PrefabDomReference linkDom,
+ PrefabDomReference linkPatches,
const LinkId linkId)
{
m_targetId = targetId;
@@ -132,9 +132,9 @@ namespace AzToolsFramework
m_instanceAlias = instanceAlias;
m_linkId = linkId;
- if (linkDom.has_value())
+ if (linkPatches.has_value())
{
- m_linkDom = AZStd::move(linkDom->get());
+ m_linkPatches = AZStd::move(linkPatches->get());
}
//if linkId is invalid, set as ADD
@@ -193,7 +193,7 @@ namespace AzToolsFramework
void PrefabUndoInstanceLink::AddLink()
{
- m_linkId = m_prefabSystemComponentInterface->CreateLink(m_targetId, m_sourceId, m_instanceAlias, m_linkDom, m_linkId);
+ m_linkId = m_prefabSystemComponentInterface->CreateLink(m_targetId, m_sourceId, m_instanceAlias, m_linkPatches, m_linkId);
}
void PrefabUndoInstanceLink::RemoveLink()
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndo.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndo.h
index 0d15d707d2..49bae4eda0 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndo.h
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndo.h
@@ -101,7 +101,7 @@ namespace AzToolsFramework
const TemplateId& targetId,
const TemplateId& sourceId,
const InstanceAlias& instanceAlias,
- PrefabDomReference linkDom = PrefabDomReference(),
+ PrefabDomReference linkPatches = PrefabDomReference(),
const LinkId linkId = InvalidLinkId);
void Undo() override;
@@ -120,7 +120,7 @@ namespace AzToolsFramework
InstanceAlias m_instanceAlias;
LinkId m_linkId;
- PrefabDom m_linkDom; //data for delete/update
+ PrefabDom m_linkPatches; //data for delete/update
LinkStatus m_linkStatus;
PrefabSystemComponentInterface* m_prefabSystemComponentInterface = nullptr;
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndoHelpers.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndoHelpers.cpp
index 2062e8b12c..24eb71e055 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndoHelpers.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndoHelpers.cpp
@@ -46,13 +46,11 @@ namespace AzToolsFramework
}
void RemoveLink(
- TemplateId sourceTemplateId, TemplateId targetTemplateId, const InstanceAlias& instanceAlias,
- LinkId linkId, UndoSystem::URSequencePoint* undoBatch)
+ TemplateId sourceTemplateId, TemplateId targetTemplateId, const InstanceAlias& instanceAlias, LinkId linkId,
+ PrefabDomReference linkPatches, UndoSystem::URSequencePoint* undoBatch)
{
auto linkRemoveUndo = aznew PrefabUndoInstanceLink("Remove Link");
- PrefabDom emptyLinkDom;
- linkRemoveUndo->Capture(
- targetTemplateId, sourceTemplateId, instanceAlias, emptyLinkDom, linkId);
+ linkRemoveUndo->Capture(targetTemplateId, sourceTemplateId, instanceAlias, linkPatches, linkId);
linkRemoveUndo->SetParent(undoBatch);
linkRemoveUndo->Redo();
}
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndoHelpers.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndoHelpers.h
index 74532b87a2..6429df3b04 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndoHelpers.h
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndoHelpers.h
@@ -25,8 +25,8 @@ namespace AzToolsFramework
TemplateId sourceTemplateId, TemplateId targetTemplateId, PrefabDomReference patch,
const InstanceAlias& instanceAlias, UndoSystem::URSequencePoint* undoBatch);
void RemoveLink(
- TemplateId sourceTemplateId, TemplateId targetTemplateId, const InstanceAlias& instanceAlias,
- LinkId linkId, UndoSystem::URSequencePoint* undoBatch);
+ TemplateId sourceTemplateId, TemplateId targetTemplateId, const InstanceAlias& instanceAlias, LinkId linkId,
+ PrefabDomReference linkPatches, UndoSystem::URSequencePoint* undoBatch);
}
} // namespace Prefab
} // namespace AzToolsFramework
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.h
index a9949d382e..6ceb175fe4 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.h
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.h
@@ -21,8 +21,6 @@
#include
#include
-class QPoint; // LYN-2315 in-progress, remove this
-
namespace AzFramework
{
struct ScreenPoint;
@@ -167,14 +165,14 @@ namespace AzToolsFramework
/// Return the angle snapping/step size.
virtual float AngleStep() = 0;
/// Transform a point in world space to screen space coordinates.
- virtual QPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition) = 0;
+ virtual AzFramework::ScreenPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition) = 0;
/// Transform a point in screen space coordinates to a vector in world space based on clip space depth.
/// Depth specifies a relative camera depth to project in the range of [0.f, 1.f].
/// Returns the world space position if successful.
- virtual AZStd::optional ViewportScreenToWorld(const QPoint& screenPosition, float depth) = 0;
+ virtual AZStd::optional ViewportScreenToWorld(const AzFramework::ScreenPoint& screenPosition, float depth) = 0;
/// Casts a point in screen space to a ray in world space originating from the viewport camera frustum's near plane.
/// Returns a ray containing the ray's origin and a direction normal, if successful.
- virtual AZStd::optional ViewportScreenToWorldRay(const QPoint& screenPosition) = 0;
+ virtual AZStd::optional ViewportScreenToWorldRay(const AzFramework::ScreenPoint& screenPosition) = 0;
protected:
~ViewportInteractionRequests() = default;
@@ -207,9 +205,9 @@ namespace AzToolsFramework
public:
/// Given a point in screen space, return the picked entity (if any).
/// Picked EntityId will be returned, InvalidEntityId will be returned on failure.
- virtual AZ::EntityId PickEntity(const QPoint& point) = 0;
+ virtual AZ::EntityId PickEntity(const AzFramework::ScreenPoint& point) = 0;
/// Given a point in screen space, return the terrain position in world space.
- virtual AZ::Vector3 PickTerrain(const QPoint& point) = 0;
+ virtual AZ::Vector3 PickTerrain(const AzFramework::ScreenPoint& point) = 0;
/// Return the terrain height given a world position in 2d (xy plane).
virtual float TerrainHeight(const AZ::Vector2& position) = 0;
/// Given the current view frustum (viewport) return all visible entities.
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp
index f3abc70fba..68a5b43d73 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp
@@ -141,16 +141,16 @@ namespace AzToolsFramework
const AZ::Vector3& entityPosition = m_entityDataCache->GetVisibleEntityPosition(entityCacheIndex);
// selecting based on 2d icon - should only do it when visible and not selected
- const QPoint screenPosition = GetScreenPosition(viewportId, entityPosition);
+ const AzFramework::ScreenPoint screenPosition = GetScreenPosition(viewportId, entityPosition);
const float distSqFromCamera = cameraState.m_position.GetDistanceSq(entityPosition);
const auto iconRange = static_cast(GetIconScale(distSqFromCamera) * s_iconSize * 0.5f);
const auto screenCoords = mouseInteraction.m_mouseInteraction.m_mousePick.m_screenCoordinates;
- if ( screenCoords.m_x >= screenPosition.x() - iconRange
- && screenCoords.m_x <= screenPosition.x() + iconRange
- && screenCoords.m_y >= screenPosition.y() - iconRange
- && screenCoords.m_y <= screenPosition.y() + iconRange)
+ if ( screenCoords.m_x >= screenPosition.m_x - iconRange
+ && screenCoords.m_x <= screenPosition.m_x + iconRange
+ && screenCoords.m_y >= screenPosition.m_y - iconRange
+ && screenCoords.m_y <= screenPosition.m_y + iconRange)
{
entityIdUnderCursor = entityId;
break;
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorSelectionUtil.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorSelectionUtil.cpp
index 95095bd3c8..3be4bc9db2 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorSelectionUtil.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorSelectionUtil.cpp
@@ -53,11 +53,11 @@ namespace AzToolsFramework
return AZ::GetMax(projectedCameraDistance, cameraState.m_nearClip) / apparentDistance;
}
- QPoint GetScreenPosition(const int viewportId, const AZ::Vector3& worldTranslation)
+ AzFramework::ScreenPoint GetScreenPosition(const int viewportId, const AZ::Vector3& worldTranslation)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
- QPoint screenPosition = QPoint();
+ auto screenPosition = AzFramework::ScreenPoint(0, 0);
ViewportInteraction::ViewportInteractionRequestBus::EventResult(
screenPosition, viewportId,
&ViewportInteraction::ViewportInteractionRequestBus::Events::ViewportWorldToScreen,
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorSelectionUtil.h b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorSelectionUtil.h
index 65e0a99bfe..9936fb9afd 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorSelectionUtil.h
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorSelectionUtil.h
@@ -45,7 +45,7 @@ namespace AzToolsFramework
const AZ::Vector3& worldPosition, const AzFramework::CameraState& cameraState);
/// Map from world space to screen space.
- QPoint GetScreenPosition(int viewportId, const AZ::Vector3& worldTranslation);
+ AzFramework::ScreenPoint GetScreenPosition(int viewportId, const AZ::Vector3& worldTranslation);
/// Given a mouse interaction, determine if the pick ray from its position
/// in screen space intersected an aabb in world space.
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp
index ec22a2f7c8..9388f3f5f0 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp
@@ -316,14 +316,14 @@ namespace AzToolsFramework
template
static void BoxSelectAddRemoveToEntitySelection(
- const AZStd::optional& boxSelect, const QPoint& screenPosition, const AZ::EntityId visibleEntityId,
+ const AZStd::optional& boxSelect, const AzFramework::ScreenPoint& screenPosition, const AZ::EntityId visibleEntityId,
const EntityIdContainer& incomingEntityIds, EntityIdContainer& outgoingEntityIds,
EditorTransformComponentSelection& entityTransformComponentSelection,
EntitySelectFuncType selectFunc1, EntitySelectFuncType selectFunc2, Compare outgoingCheck)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
- if (boxSelect->contains(screenPosition))
+ if (boxSelect->contains(ViewportInteraction::QPointFromScreenPoint(screenPosition)))
{
const auto entityIt = incomingEntityIds.find(visibleEntityId);
@@ -389,7 +389,7 @@ namespace AzToolsFramework
const AZ::EntityId entityId = entityDataCache.GetVisibleEntityId(entityCacheIndex);
const AZ::Vector3& entityPosition = entityDataCache.GetVisibleEntityPosition(entityCacheIndex);
- const QPoint screenPosition = GetScreenPosition(viewportId, entityPosition);
+ const AzFramework::ScreenPoint screenPosition = GetScreenPosition(viewportId, entityPosition);
if (currentKeyboardModifiers.Ctrl())
{
@@ -927,7 +927,7 @@ namespace AzToolsFramework
ViewportInteraction::MainEditorViewportInteractionRequestBus::EventResult(
worldSurfacePosition, viewportId,
&ViewportInteraction::MainEditorViewportInteractionRequestBus::Events::PickTerrain,
- ViewportInteraction::QPointFromScreenPoint(mouseInteraction.m_mousePick.m_screenCoordinates));
+ mouseInteraction.m_mousePick.m_screenCoordinates);
// convert to local space - snap if enabled
const GridSnapParameters gridSnapParams = GridSnapSettings(viewportId);
diff --git a/Code/Sandbox/Editor/Core/LevelEditorMenuHandler.cpp b/Code/Sandbox/Editor/Core/LevelEditorMenuHandler.cpp
index 3f396894ff..869fa2fe25 100644
--- a/Code/Sandbox/Editor/Core/LevelEditorMenuHandler.cpp
+++ b/Code/Sandbox/Editor/Core/LevelEditorMenuHandler.cpp
@@ -23,7 +23,6 @@
#include "Objects/SelectionGroup.h"
#include "ViewManager.h"
-#include
#include
// Qt
diff --git a/Code/Sandbox/Editor/CryEditDoc.cpp b/Code/Sandbox/Editor/CryEditDoc.cpp
index ea40e3c1d6..2138c5c79e 100644
--- a/Code/Sandbox/Editor/CryEditDoc.cpp
+++ b/Code/Sandbox/Editor/CryEditDoc.cpp
@@ -27,12 +27,6 @@
// AzFramework
#include
#include
-#include
-#include
-
-// Atom
-#include
-#include
// AzToolsFramework
#include
@@ -68,6 +62,9 @@
#include "StatObjBus.h"
// LmbrCentral
+#include
+#include
+#include
#include // for LmbrCentral::EditorLightComponentRequestBus
@@ -2410,44 +2407,9 @@ void CCryEditDoc::InitEmptyLevel(int /*resolution*/, int /*unitSize*/, bool /*bU
GetIEditor()->SetStatusText("Ready");
}
-void CCryEditDoc::CreateDefaultLevelAssets(int resolution, int unitSize)
+void CCryEditDoc::CreateDefaultLevelAssets([[maybe_unused]] int resolution, [[maybe_unused]] int unitSize)
{
- if (AZ::Interface::Get())
- {
- AzToolsFramework::EditorLevelNotificationBus::Broadcast(&AzToolsFramework::EditorLevelNotificationBus::Events::OnNewLevelCreated);
- }
- else
- {
- bool isPrefabSystemEnabled = false;
- AzFramework::ApplicationRequests::Bus::BroadcastResult(
- isPrefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
-
- if (!isPrefabSystemEnabled)
- {
- AZ::Data::AssetCatalogRequestBus::BroadcastResult(
- m_envProbeSliceAssetId, &AZ::Data::AssetCatalogRequests::GetAssetIdByPath, m_envProbeSliceRelativePath,
- azrtti_typeid(), false);
-
- if (m_envProbeSliceAssetId.IsValid())
- {
- AZ::Data::Asset asset = AZ::Data::AssetManager::Instance().FindOrCreateAsset(
- m_envProbeSliceAssetId, AZ::Data::AssetLoadBehavior::Default);
- if (asset)
- {
- m_terrainSize = resolution * unitSize;
- const float halfTerrainSize = m_terrainSize / 2.0f;
-
- AZ::Transform worldTransform = AZ::Transform::CreateIdentity();
- worldTransform = AZ::Transform::CreateTranslation(AZ::Vector3(halfTerrainSize, halfTerrainSize, m_envProbeHeight / 2));
-
- AzToolsFramework::SliceEditorEntityOwnershipServiceNotificationBus::Handler::BusConnect();
- GetIEditor()->SuspendUndo();
- AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Broadcast(
- &AzToolsFramework::SliceEditorEntityOwnershipServiceRequests::InstantiateEditorSlice, asset, worldTransform);
- }
- }
- }
- }
+ AzToolsFramework::EditorLevelNotificationBus::Broadcast(&AzToolsFramework::EditorLevelNotificationBus::Events::OnNewLevelCreated);
}
void CCryEditDoc::OnEnvironmentPropertyChanged(IVariable* pVar)
diff --git a/Code/Sandbox/Editor/EditorViewportWidget.cpp b/Code/Sandbox/Editor/EditorViewportWidget.cpp
index 3c42b2db32..05986d6561 100644
--- a/Code/Sandbox/Editor/EditorViewportWidget.cpp
+++ b/Code/Sandbox/Editor/EditorViewportWidget.cpp
@@ -40,7 +40,6 @@
# include
#endif // defined(AZ_PLATFORM_WINDOWS)
#include // for AzFramework::InputDeviceMouse
-#include
#include
// AzQtComponents
@@ -321,8 +320,8 @@ AzToolsFramework::ViewportInteraction::MousePick EditorViewportWidget::BuildMous
using namespace AzToolsFramework::ViewportInteraction;
MousePick mousePick;
- mousePick.m_screenCoordinates = AzFramework::ScreenPoint(point.x(), point.y());
- const auto& ray = m_renderViewport->ViewportScreenToWorldRay(point);
+ mousePick.m_screenCoordinates = ScreenPointFromQPoint(point);
+ const auto& ray = m_renderViewport->ViewportScreenToWorldRay(mousePick.m_screenCoordinates);
if (ray.has_value())
{
mousePick.m_rayOrigin = ray.value().origin;
@@ -1132,14 +1131,14 @@ float EditorViewportWidget::AngleStep()
return GetViewManager()->GetGrid()->GetAngleSnap();
}
-AZ::Vector3 EditorViewportWidget::PickTerrain(const QPoint& point)
+AZ::Vector3 EditorViewportWidget::PickTerrain(const AzFramework::ScreenPoint& point)
{
FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR);
- return LYVec3ToAZVec3(ViewToWorld(point, nullptr, true));
+ return LYVec3ToAZVec3(ViewToWorld(AzToolsFramework::ViewportInteraction::QPointFromScreenPoint(point), nullptr, true));
}
-AZ::EntityId EditorViewportWidget::PickEntity(const QPoint& point)
+AZ::EntityId EditorViewportWidget::PickEntity(const AzFramework::ScreenPoint& point)
{
FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR);
@@ -1148,7 +1147,7 @@ AZ::EntityId EditorViewportWidget::PickEntity(const QPoint& point)
AZ::EntityId entityId;
HitContext hitInfo;
hitInfo.view = this;
- if (HitTest(point, hitInfo))
+ if (HitTest(AzToolsFramework::ViewportInteraction::QPointFromScreenPoint(point), hitInfo))
{
if (hitInfo.object && (hitInfo.object->GetType() == OBJTYPE_AZENTITY))
{
@@ -1174,7 +1173,7 @@ void EditorViewportWidget::FindVisibleEntities(AZStd::vector& visi
visibleEntitiesOut.assign(m_entityVisibilityQuery.Begin(), m_entityVisibilityQuery.End());
}
-QPoint EditorViewportWidget::ViewportWorldToScreen(const AZ::Vector3& worldPosition)
+AzFramework::ScreenPoint EditorViewportWidget::ViewportWorldToScreen(const AZ::Vector3& worldPosition)
{
return m_renderViewport->ViewportWorldToScreen(worldPosition);
}
@@ -2002,7 +2001,7 @@ Vec3 EditorViewportWidget::WorldToView3D(const Vec3& wp, [[maybe_unused]] int nF
//////////////////////////////////////////////////////////////////////////
QPoint EditorViewportWidget::WorldToView(const Vec3& wp) const
{
- return m_renderViewport->ViewportWorldToScreen(LYVec3ToAZVec3(wp));
+ return AzToolsFramework::ViewportInteraction::QPointFromScreenPoint(m_renderViewport->ViewportWorldToScreen(LYVec3ToAZVec3(wp)));
}
//////////////////////////////////////////////////////////////////////////
QPoint EditorViewportWidget::WorldToViewParticleEditor(const Vec3& wp, int width, int height) const
@@ -2024,7 +2023,8 @@ QPoint EditorViewportWidget::WorldToViewParticleEditor(const Vec3& wp, int width
}
//////////////////////////////////////////////////////////////////////////
-Vec3 EditorViewportWidget::ViewToWorld(const QPoint& vp, bool* collideWithTerrain, bool onlyTerrain, bool bSkipVegetation, bool bTestRenderMesh, bool* collideWithObject) const
+Vec3 EditorViewportWidget::ViewToWorld(
+ const QPoint& vp, bool* collideWithTerrain, bool onlyTerrain, bool bSkipVegetation, bool bTestRenderMesh, bool* collideWithObject) const
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Editor);
@@ -2035,7 +2035,7 @@ Vec3 EditorViewportWidget::ViewToWorld(const QPoint& vp, bool* collideWithTerrai
AZ_UNUSED(bSkipVegetation)
AZ_UNUSED(collideWithObject)
- auto ray = m_renderViewport->ViewportScreenToWorldRay(vp);
+ auto ray = m_renderViewport->ViewportScreenToWorldRay(AzToolsFramework::ViewportInteraction::ScreenPointFromQPoint(vp));
if (!ray.has_value())
{
return Vec3(0, 0, 0);
@@ -2152,7 +2152,7 @@ bool EditorViewportWidget::RayRenderMeshIntersection(IRenderMesh* pRenderMesh, c
void EditorViewportWidget::UnProjectFromScreen(float sx, float sy, float sz, float* px, float* py, float* pz) const
{
AZ::Vector3 wp;
- wp = m_renderViewport->ViewportScreenToWorld({(int)sx, m_rcClient.bottom() - ((int)sy)}, sz).value_or(wp);
+ wp = m_renderViewport->ViewportScreenToWorld(AzFramework::ScreenPoint{(int)sx, m_rcClient.bottom() - ((int)sy)}, sz).value_or(wp);
*px = wp.GetX();
*py = wp.GetY();
*pz = wp.GetZ();
@@ -2160,9 +2160,9 @@ void EditorViewportWidget::UnProjectFromScreen(float sx, float sy, float sz, flo
void EditorViewportWidget::ProjectToScreen(float ptx, float pty, float ptz, float* sx, float* sy, float* sz) const
{
- QPoint screenPosition = m_renderViewport->ViewportWorldToScreen(AZ::Vector3{ptx, pty, ptz});
- *sx = screenPosition.x();
- *sy = screenPosition.y();
+ AzFramework::ScreenPoint screenPosition = m_renderViewport->ViewportWorldToScreen(AZ::Vector3{ptx, pty, ptz});
+ *sx = screenPosition.m_x;
+ *sy = screenPosition.m_y;
*sz = 0.f;
}
diff --git a/Code/Sandbox/Editor/EditorViewportWidget.h b/Code/Sandbox/Editor/EditorViewportWidget.h
index 472f7e3c62..8673d258cc 100644
--- a/Code/Sandbox/Editor/EditorViewportWidget.h
+++ b/Code/Sandbox/Editor/EditorViewportWidget.h
@@ -196,15 +196,15 @@ public:
bool ShowGrid();
bool AngleSnappingEnabled();
float AngleStep();
- QPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition);
+ AzFramework::ScreenPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition);
// AzToolsFramework::ViewportFreezeRequestBus
bool IsViewportInputFrozen() override;
void FreezeViewportInput(bool freeze) override;
// AzToolsFramework::MainEditorViewportInteractionRequestBus
- AZ::EntityId PickEntity(const QPoint& point) override;
- AZ::Vector3 PickTerrain(const QPoint& point) override;
+ AZ::EntityId PickEntity(const AzFramework::ScreenPoint& point) override;
+ AZ::Vector3 PickTerrain(const AzFramework::ScreenPoint& point) override;
float TerrainHeight(const AZ::Vector2& position) override;
void FindVisibleEntities(AZStd::vector& visibleEntitiesOut) override;
bool ShowingWorldSpace() override;
@@ -557,8 +557,7 @@ private:
void PushDisableRendering();
void PopDisableRendering();
bool IsRenderingDisabled() const;
- AzToolsFramework::ViewportInteraction::MousePick BuildMousePickInternal(
- const QPoint& point) const;
+ AzToolsFramework::ViewportInteraction::MousePick BuildMousePickInternal(const QPoint& point) const;
void RestoreViewportAfterGameMode();
void UpdateCameraFromViewportContext();
diff --git a/Code/Sandbox/Editor/IconManager.cpp b/Code/Sandbox/Editor/IconManager.cpp
index 09c2d41035..828a7cdfcc 100644
--- a/Code/Sandbox/Editor/IconManager.cpp
+++ b/Code/Sandbox/Editor/IconManager.cpp
@@ -15,7 +15,6 @@
#include "IconManager.h"
-#include
#include
// AzToolsFramework
@@ -115,71 +114,6 @@ int CIconManager::GetIconTexture(const char* iconName)
return 0;
}
- if (AZ::Interface::Get())
- {
- ITexture* texture = GetIEditor()->GetRenderer() ? GetIEditor()->GetRenderer()->EF_LoadTexture(iconName) : nullptr;
- if (texture)
- {
- id = texture->GetTextureID();
- m_textures[iconName] = id;
- }
- }
- else
- {
- QString ext = Path::GetExt(iconName);
- QString actualName = iconName;
-
- char iconPath[AZ_MAX_PATH_LEN] = { 0 };
- gEnv->pFileIO->ResolvePath(actualName.toUtf8().data(), iconPath, AZ_MAX_PATH_LEN);
-
- // if we can't find it at the resolved path, try the devroot if necessary:
- if (!gEnv->pFileIO->Exists(iconPath))
- {
- if (iconName[0] != '@') // it has no specified alias
- {
- if (QString::compare(ext, "dds", Qt::CaseInsensitive) != 0) // if its a DDS, it comes out of processed files in @assets@, and assets is assumed by default (legacy renderer)
- {
- // check for a source file
- AZStd::string iconFullPath;
- bool pathFound = false;
- using AssetSysReqBus = AzToolsFramework::AssetSystemRequestBus;
- AssetSysReqBus::BroadcastResult(pathFound, &AssetSysReqBus::Events::GetFullSourcePathFromRelativeProductPath, iconName, iconFullPath);
-
- if (pathFound)
- {
- azstrncpy(iconPath, AZ_MAX_PATH_LEN, iconFullPath.c_str(), iconFullPath.length() + 1);
- }
- }
- }
- }
-
- CImageEx image;
- // Load icon.
- if (CImageUtil::LoadImage(iconPath, image))
- {
- IRenderer* pRenderer(GetIEditor()->GetRenderer());
- if (pRenderer->GetRenderType() != eRT_DX11)
- {
- image.SwapRedAndBlue();
- }
-
- if (QString::compare(ext, "bmp", Qt::CaseInsensitive) == 0 || QString::compare(ext, "jpg", Qt::CaseInsensitive) == 0)
- {
- int sz = image.GetWidth() * image.GetHeight();
- uint8* buf = (uint8*)image.GetData();
- for (int i = 0; i < sz; i++)
- {
- uint32 alpha = max(max(buf[i * 4], buf[i * 4 + 1]), buf[i * 4 + 2]);
- alpha *= 2;
- buf[i * 4 + 3] = (alpha > 255) ? 255 : alpha;
- }
- }
-
- id = pRenderer->DownLoadToVideoMemory((unsigned char*)image.GetData(), image.GetWidth(), image.GetHeight(), eTF_R8G8B8A8, eTF_R8G8B8A8, 0, 0, 0);
- m_textures[iconName] = id;
- }
- }
-
return id;
}
diff --git a/Code/Sandbox/Editor/LayoutWnd.cpp b/Code/Sandbox/Editor/LayoutWnd.cpp
index 34a96bca53..54389f30c1 100644
--- a/Code/Sandbox/Editor/LayoutWnd.cpp
+++ b/Code/Sandbox/Editor/LayoutWnd.cpp
@@ -24,7 +24,6 @@
#include
#include
-#include
#include // for AzQtComponents::Style
// Editor
diff --git a/Code/Sandbox/Editor/MainWindow.cpp b/Code/Sandbox/Editor/MainWindow.cpp
index 44d65af8cd..c266d37282 100644
--- a/Code/Sandbox/Editor/MainWindow.cpp
+++ b/Code/Sandbox/Editor/MainWindow.cpp
@@ -42,7 +42,6 @@ AZ_POP_DISABLE_WARNING
#include
#include
#include
-#include
// AzToolsFramework
#include
@@ -1093,7 +1092,7 @@ void MainWindow::InitActions()
QAction* saveLevelStatsAction =
am->AddAction(ID_TOOLS_LOGMEMORYUSAGE, tr("Save Level Statistics"))
.SetStatusTip(tr("Logs Editor memory usage."));
- if( saveLevelStatsAction && AZ::Interface::Get())
+ if( saveLevelStatsAction )
{
saveLevelStatsAction->setEnabled(false);
}
@@ -1189,13 +1188,6 @@ void MainWindow::InitActions()
.SetIcon(Style::icon("Audio"))
.SetApplyHoverEffect();
- if (!AZ::Interface::Get())
- {
- am->AddAction(ID_TERRAIN_TIMEOFDAYBUTTON, tr("Time of Day Editor"))
- .SetToolTip(tr("Open Time of Day"))
- .SetApplyHoverEffect();
- }
-
am->AddAction(ID_OPEN_UICANVASEDITOR, tr(LyViewPane::UiEditor))
.SetToolTip(tr("Open UI Editor"))
.SetApplyHoverEffect();
@@ -1652,10 +1644,6 @@ void MainWindow::RegisterStdViewClasses()
AzAssetBrowserWindow::RegisterViewClass();
AssetEditorWindow::RegisterViewClass();
- if (!AZ::Interface::Get())
- {
- CTimeOfDayDialog::RegisterViewClass();
- }
#ifdef ThumbnailDemo
ThumbnailsSampleWidget::RegisterViewClass();
#endif
diff --git a/Code/Sandbox/Editor/RenderViewport.cpp b/Code/Sandbox/Editor/RenderViewport.cpp
index cac1840b75..8eab8e92fa 100644
--- a/Code/Sandbox/Editor/RenderViewport.cpp
+++ b/Code/Sandbox/Editor/RenderViewport.cpp
@@ -42,7 +42,6 @@
# include
#endif // defined(AZ_PLATFORM_WINDOWS)
#include // for AzFramework::InputDeviceMouse
-#include
// AzQtComponents
#include
@@ -275,13 +274,10 @@ void CRenderViewport::resizeEvent(QResizeEvent* event)
gEnv->pSystem->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_RESIZE, width(), height());
- if (AZ::Interface::Get())
- {
- // We queue the window resize event because the render overlay may be hidden.
- // If the render overlay is not visible, the native window that is backing it will
- // also be hidden, and it will not resize until it becomes visible.
- m_windowResizedEvent = true;
- }
+ // We queue the window resize event because the render overlay may be hidden.
+ // If the render overlay is not visible, the native window that is backing it will
+ // also be hidden, and it will not resize until it becomes visible.
+ m_windowResizedEvent = true;
}
//////////////////////////////////////////////////////////////////////////
@@ -1553,14 +1549,6 @@ void CRenderViewport::OnRender()
if (levelIsDisplayable)
{
m_renderer->SetViewport(0, 0, m_renderer->GetWidth(), m_renderer->GetHeight(), m_nCurViewportID);
-
- if (!AZ::Interface::Get())
- {
- m_engine->Tick();
- m_engine->Update();
-
- m_engine->RenderWorld(SHDF_ALLOW_AO | SHDF_ALLOWPOSTPROCESS | SHDF_ALLOW_WATER | SHDF_ALLOWHDR | SHDF_ZPASS, SRenderingPassInfo::CreateGeneralPassRenderingInfo(m_Camera), __FUNCTION__);
- }
}
else
{
@@ -2043,14 +2031,14 @@ float CRenderViewport::AngleStep()
return GetViewManager()->GetGrid()->GetAngleSnap();
}
-AZ::Vector3 CRenderViewport::PickTerrain(const QPoint& point)
+AZ::Vector3 CRenderViewport::PickTerrain(const AzFramework::ScreenPoint& point)
{
FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR);
- return LYVec3ToAZVec3(ViewToWorld(point, nullptr, true));
+ return LYVec3ToAZVec3(ViewToWorld(AzToolsFramework::ViewportInteraction::QPointFromScreenPoint(point), nullptr, true));
}
-AZ::EntityId CRenderViewport::PickEntity(const QPoint& point)
+AZ::EntityId CRenderViewport::PickEntity(const AzFramework::ScreenPoint& point)
{
FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR);
@@ -2059,7 +2047,7 @@ AZ::EntityId CRenderViewport::PickEntity(const QPoint& point)
AZ::EntityId entityId;
HitContext hitInfo;
hitInfo.view = this;
- if (HitTest(point, hitInfo))
+ if (HitTest(AzToolsFramework::ViewportInteraction::QPointFromScreenPoint(point), hitInfo))
{
if (hitInfo.object && (hitInfo.object->GetType() == OBJTYPE_AZENTITY))
{
@@ -2100,12 +2088,13 @@ void CRenderViewport::FindVisibleEntities(AZStd::vector& visibleEn
}
}
-QPoint CRenderViewport::ViewportWorldToScreen(const AZ::Vector3& worldPosition)
+AzFramework::ScreenPoint CRenderViewport::ViewportWorldToScreen(const AZ::Vector3& worldPosition)
{
FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR);
PreWidgetRendering();
- const QPoint screenPosition = WorldToView(AZVec3ToLYVec3(worldPosition));
+ const AzFramework::ScreenPoint screenPosition =
+ AzToolsFramework::ViewportInteraction::ScreenPointFromQPoint(WorldToView(AZVec3ToLYVec3(worldPosition)));
PostWidgetRendering();
return screenPosition;
@@ -3659,11 +3648,8 @@ bool CRenderViewport::CreateRenderContext()
{
m_bRenderContextCreated = true;
- if (AZ::Interface::Get())
- {
- AzFramework::WindowRequestBus::Handler::BusConnect(renderOverlayHWND());
- AzFramework::WindowSystemNotificationBus::Broadcast(&AzFramework::WindowSystemNotificationBus::Handler::OnWindowCreated, renderOverlayHWND());
- }
+ AzFramework::WindowRequestBus::Handler::BusConnect(renderOverlayHWND());
+ AzFramework::WindowSystemNotificationBus::Broadcast(&AzFramework::WindowSystemNotificationBus::Handler::OnWindowCreated, renderOverlayHWND());
WIN_HWND oldContext = m_renderer->GetCurrentContextHWND();
m_renderer->CreateContext(renderOverlayHWND());
diff --git a/Code/Sandbox/Editor/RenderViewport.h b/Code/Sandbox/Editor/RenderViewport.h
index 2edbd86770..9985408d25 100644
--- a/Code/Sandbox/Editor/RenderViewport.h
+++ b/Code/Sandbox/Editor/RenderViewport.h
@@ -190,17 +190,24 @@ public:
bool ShowGrid() override;
bool AngleSnappingEnabled() override;
float AngleStep() override;
- QPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition) override;
- AZStd::optional ViewportScreenToWorld(const QPoint&, float) override { return {}; }
- AZStd::optional ViewportScreenToWorldRay(const QPoint&) override { return {}; }
+ AzFramework::ScreenPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition) override;
+ AZStd::optional ViewportScreenToWorld(const AzFramework::ScreenPoint&, float) override
+ {
+ return {};
+ }
+ AZStd::optional ViewportScreenToWorldRay(
+ const AzFramework::ScreenPoint&) override
+ {
+ return {};
+ }
// AzToolsFramework::ViewportFreezeRequestBus
bool IsViewportInputFrozen() override;
void FreezeViewportInput(bool freeze) override;
// AzToolsFramework::MainEditorViewportInteractionRequestBus
- AZ::EntityId PickEntity(const QPoint& point) override;
- AZ::Vector3 PickTerrain(const QPoint& point) override;
+ AZ::EntityId PickEntity(const AzFramework::ScreenPoint& point) override;
+ AZ::Vector3 PickTerrain(const AzFramework::ScreenPoint& point) override;
float TerrainHeight(const AZ::Vector2& position) override;
void FindVisibleEntities(AZStd::vector& visibleEntitiesOut) override;
bool ShowingWorldSpace() override;
diff --git a/Code/Sandbox/Editor/ToolbarManager.cpp b/Code/Sandbox/Editor/ToolbarManager.cpp
index 01bd7be82b..bbb3ef6790 100644
--- a/Code/Sandbox/Editor/ToolbarManager.cpp
+++ b/Code/Sandbox/Editor/ToolbarManager.cpp
@@ -16,7 +16,6 @@
// AzCore
#include
-#include
#include
// Qt
diff --git a/Code/Sandbox/Editor/ViewManager.cpp b/Code/Sandbox/Editor/ViewManager.cpp
index 7dd0f3e033..334e78a826 100644
--- a/Code/Sandbox/Editor/ViewManager.cpp
+++ b/Code/Sandbox/Editor/ViewManager.cpp
@@ -34,7 +34,6 @@
#include "EditorViewportWidget.h"
#include "CryEditDoc.h"
-#include
#include
AZ_CVAR(bool, ed_useAtomNativeViewport, true, nullptr, AZ::ConsoleFunctorFlags::Null, "Use the new Atom-native Editor viewport (experimental, not yet stable");
@@ -42,7 +41,7 @@ AZ_CVAR(bool, ed_useAtomNativeViewport, true, nullptr, AZ::ConsoleFunctorFlags::
bool CViewManager::IsMultiViewportEnabled()
{
// Enable multi-viewport for legacy renderer, or if we're using the new fully Atom-native viewport
- return !AZ::Interface::Get() || ed_useAtomNativeViewport;
+ return ed_useAtomNativeViewport;
}
//////////////////////////////////////////////////////////////////////
@@ -81,7 +80,7 @@ CViewManager::CViewManager()
RegisterQtViewPane(GetIEditor(), "Left", LyViewPane::CategoryViewport, viewportOptions);
viewportOptions.viewportType = ET_ViewportCamera;
- if (ed_useAtomNativeViewport && AZ::Interface::Get())
+ if (ed_useAtomNativeViewport)
{
RegisterQtViewPaneWithName(GetIEditor(), "Perspective", LyViewPane::CategoryViewport, viewportOptions);
}
diff --git a/Code/Sandbox/Editor/ViewPane.cpp b/Code/Sandbox/Editor/ViewPane.cpp
index 43e4330113..480e39bedf 100644
--- a/Code/Sandbox/Editor/ViewPane.cpp
+++ b/Code/Sandbox/Editor/ViewPane.cpp
@@ -33,7 +33,6 @@
// AzFramework
#include
-#include
#include
// Editor
diff --git a/Code/Sandbox/Editor/ViewportManipulatorController.cpp b/Code/Sandbox/Editor/ViewportManipulatorController.cpp
index fc376b27d0..43d2fb1f2c 100644
--- a/Code/Sandbox/Editor/ViewportManipulatorController.cpp
+++ b/Code/Sandbox/Editor/ViewportManipulatorController.cpp
@@ -112,8 +112,7 @@ bool ViewportManipulatorControllerInstance::HandleInputChannelEvent(const AzFram
m_state.m_mousePick.m_screenCoordinates = screenPosition;
AZStd::optional ray;
ViewportInteractionRequestBus::EventResult(
- ray, GetViewportId(), &ViewportInteractionRequestBus::Events::ViewportScreenToWorldRay,
- QPoint(screenPosition.m_x, screenPosition.m_y));
+ ray, GetViewportId(), &ViewportInteractionRequestBus::Events::ViewportScreenToWorldRay, screenPosition);
if (ray.has_value())
{
diff --git a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp
index 724664b1dc..c7c501c70a 100644
--- a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp
+++ b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp
@@ -30,7 +30,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -162,13 +161,6 @@ void SandboxIntegrationManager::Setup()
AzToolsFramework::EditorEvents::Bus::Handler::BusConnect();
AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusConnect();
AzToolsFramework::SliceEditorEntityOwnershipServiceNotificationBus::Handler::BusConnect();
- // turn on the this debug display request bus implementation if no other implementation is active
- if( !(AZ::Interface::Get() && AzFramework::DebugDisplayRequestBus::HasHandlers()))
- {
- m_debugDisplayBusImplementationActive = true;
- AzFramework::DebugDisplayRequestBus::Handler::BusConnect(
- AzToolsFramework::ViewportInteraction::g_mainViewportEntityDebugDisplayId);
- }
AzFramework::DisplayContextRequestBus::Handler::BusConnect();
SetupFileExtensionMap();
diff --git a/Code/Sandbox/Plugins/EditorCommon/QViewport.cpp b/Code/Sandbox/Plugins/EditorCommon/QViewport.cpp
index 5ca6cf5ac6..362452a67e 100644
--- a/Code/Sandbox/Plugins/EditorCommon/QViewport.cpp
+++ b/Code/Sandbox/Plugins/EditorCommon/QViewport.cpp
@@ -37,8 +37,6 @@
#include
#include
-#include
-
#include
// Class to implement the WindowRequestBus::Handler instead of the QViewport class.
@@ -365,7 +363,7 @@ bool QViewport::CreateRenderContext()
HWND windowHandle = reinterpret_cast(QWidget::winId());
- if( AZ::Interface::Get() && m_renderContextCreated && windowHandle == m_lastHwnd)
+ if( m_renderContextCreated && windowHandle == m_lastHwnd)
{
// the hwnd has not changed, no need to destroy and recreate context (and swap chain etc)
return false;
@@ -377,13 +375,10 @@ bool QViewport::CreateRenderContext()
{
m_renderContextCreated = true;
- if (AZ::Interface::Get())
- {
- m_viewportRequests.get()->BusConnect(windowHandle);
- AzFramework::WindowSystemNotificationBus::Broadcast(&AzFramework::WindowSystemNotificationBus::Handler::OnWindowCreated, windowHandle);
+ m_viewportRequests.get()->BusConnect(windowHandle);
+ AzFramework::WindowSystemNotificationBus::Broadcast(&AzFramework::WindowSystemNotificationBus::Handler::OnWindowCreated, windowHandle);
- m_lastHwnd = windowHandle;
- }
+ m_lastHwnd = windowHandle;
StorePreviousContext();
GetIEditor()->GetEnv()->pRenderer->CreateContext(windowHandle);
diff --git a/Code/Tools/SceneAPI/SceneCore/Containers/GraphObjectProxy.cpp b/Code/Tools/SceneAPI/SceneCore/Containers/GraphObjectProxy.cpp
index f2fda63ec4..989eccd526 100644
--- a/Code/Tools/SceneAPI/SceneCore/Containers/GraphObjectProxy.cpp
+++ b/Code/Tools/SceneAPI/SceneCore/Containers/GraphObjectProxy.cpp
@@ -13,9 +13,135 @@
#include
#include
#include
+#include
+#include
+#include
namespace AZ
{
+ namespace Python
+ {
+ static const char* const None = "None";
+
+ class PythonBehaviorInfo final
+ {
+ public:
+ AZ_RTTI(PythonBehaviorInfo, "{8055BD03-5B3B-490D-AEC5-1B1E2616D529}");
+ AZ_CLASS_ALLOCATOR(PythonBehaviorInfo, AZ::SystemAllocator, 0);
+
+ static void Reflect(AZ::ReflectContext* context);
+
+ PythonBehaviorInfo(const AZ::BehaviorClass* behaviorClass);
+ PythonBehaviorInfo() = delete;
+
+ protected:
+ bool IsMemberLike(const AZ::BehaviorMethod& method, const AZ::TypeId& typeId) const;
+ AZStd::string FetchPythonType(const AZ::BehaviorParameter& param) const;
+ void WriteMethod(AZStd::string_view methodName, const AZ::BehaviorMethod& behaviorMethod);
+
+ private:
+ const AZ::BehaviorClass* m_behaviorClass = nullptr;
+ AZStd::vector m_methodList;
+ };
+
+ PythonBehaviorInfo::PythonBehaviorInfo(const AZ::BehaviorClass* behaviorClass)
+ : m_behaviorClass(behaviorClass)
+ {
+ AZ_Assert(m_behaviorClass, "PythonBehaviorInfo requires a valid behaviorClass pointer");
+ for (const auto& entry : behaviorClass->m_methods)
+ {
+ WriteMethod(entry.first, *entry.second);
+ }
+ }
+
+ void PythonBehaviorInfo::Reflect(AZ::ReflectContext* context)
+ {
+ AZ::BehaviorContext* behaviorContext = azrtti_cast(context);
+ if (behaviorContext)
+ {
+ behaviorContext->Class()
+ ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
+ ->Attribute(AZ::Script::Attributes::Module, "scene.graph")
+ ->Property("className", [](const PythonBehaviorInfo& self)
+ { return self.m_behaviorClass->m_name; }, nullptr)
+ ->Property("classUuid", [](const PythonBehaviorInfo& self)
+ { return self.m_behaviorClass->m_typeId.ToString(); }, nullptr)
+ ->Property("methodList", BehaviorValueGetter(&PythonBehaviorInfo::m_methodList), nullptr);
+ }
+ }
+
+ bool PythonBehaviorInfo::IsMemberLike(const AZ::BehaviorMethod& method, const AZ::TypeId& typeId) const
+ {
+ return method.IsMember() || (method.GetNumArguments() > 0 && method.GetArgument(0)->m_typeId == typeId);
+ }
+
+ AZStd::string PythonBehaviorInfo::FetchPythonType(const AZ::BehaviorParameter& param) const
+ {
+ using namespace AzToolsFramework;
+ EditorPythonConsoleInterface* editorPythonConsoleInterface = AZ::Interface::Get();
+ if (editorPythonConsoleInterface)
+ {
+ return editorPythonConsoleInterface->FetchPythonTypeName(param);
+ }
+ return None;
+ }
+
+ void PythonBehaviorInfo::WriteMethod(AZStd::string_view methodName, const AZ::BehaviorMethod& behaviorMethod)
+ {
+ // if the method is a static method then it is not a part of the abstract class
+ const bool isMemberLike = IsMemberLike(behaviorMethod, m_behaviorClass->m_typeId);
+ if (isMemberLike == false)
+ {
+ return;
+ }
+
+ AZStd::string buffer;
+ AZStd::vector pythonArgs;
+
+ AzFramework::StringFunc::Append(buffer, "def ");
+ AzFramework::StringFunc::Append(buffer, methodName.data());
+ AzFramework::StringFunc::Append(buffer, "(");
+
+ pythonArgs.emplace_back("self");
+
+ AZStd::string bufferArg;
+ for (size_t argIndex = 1; argIndex < behaviorMethod.GetNumArguments(); ++argIndex)
+ {
+ const AZStd::string* name = behaviorMethod.GetArgumentName(argIndex);
+ if (!name || name->empty())
+ {
+ bufferArg = AZStd::string::format(" arg%zu", argIndex);
+ }
+ else
+ {
+ bufferArg = *name;
+ }
+
+ AZStd::string_view type = FetchPythonType(*behaviorMethod.GetArgument(argIndex));
+ if (!type.empty())
+ {
+ AzFramework::StringFunc::Append(bufferArg, ": ");
+ AzFramework::StringFunc::Append(bufferArg, type.data());
+ }
+
+ pythonArgs.push_back(bufferArg);
+ bufferArg.clear();
+ }
+
+ AZStd::string resultValue{ None };
+ if (behaviorMethod.HasResult() && behaviorMethod.GetResult())
+ {
+ resultValue = FetchPythonType(*behaviorMethod.GetResult());
+ }
+
+ AZStd::string argsList;
+ AzFramework::StringFunc::Join(buffer, pythonArgs.begin(), pythonArgs.end(), ",");
+ AzFramework::StringFunc::Append(buffer, ") -> ");
+ AzFramework::StringFunc::Append(buffer, resultValue.c_str());
+ m_methodList.emplace_back(buffer);
+ }
+ }
+
namespace SceneAPI
{
namespace Containers
@@ -25,6 +151,8 @@ namespace AZ
AZ::BehaviorContext* behaviorContext = azrtti_cast(context);
if (behaviorContext)
{
+ Python::PythonBehaviorInfo::Reflect(context);
+
behaviorContext->Class();
behaviorContext->Class()
@@ -33,6 +161,19 @@ namespace AZ
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
->Method("CastWithTypeName", &GraphObjectProxy::CastWithTypeName)
->Method("Invoke", &GraphObjectProxy::Invoke)
+ ->Method("GetClassInfo", [](GraphObjectProxy& self) -> Python::PythonBehaviorInfo*
+ {
+ if (self.m_pythonBehaviorInfo)
+ {
+ return self.m_pythonBehaviorInfo.get();
+ }
+ if (self.m_behaviorClass)
+ {
+ self.m_pythonBehaviorInfo = AZStd::make_shared(self.m_behaviorClass);
+ return self.m_pythonBehaviorInfo.get();
+ }
+ return nullptr;
+ })
;
}
}
diff --git a/Code/Tools/SceneAPI/SceneCore/Containers/GraphObjectProxy.h b/Code/Tools/SceneAPI/SceneCore/Containers/GraphObjectProxy.h
index 094b896364..d83a147e5f 100644
--- a/Code/Tools/SceneAPI/SceneCore/Containers/GraphObjectProxy.h
+++ b/Code/Tools/SceneAPI/SceneCore/Containers/GraphObjectProxy.h
@@ -16,6 +16,11 @@
namespace AZ
{
+ namespace Python
+ {
+ class PythonBehaviorInfo;
+ }
+
namespace SceneAPI
{
namespace Containers
@@ -44,6 +49,7 @@ namespace AZ
private:
AZStd::shared_ptr m_graphObject;
const AZ::BehaviorClass* m_behaviorClass = nullptr;
+ AZStd::shared_ptr m_pythonBehaviorInfo;
};
} // Containers
diff --git a/Code/Tools/SceneAPI/SceneCore/Tests/Containers/SceneBehaviorTests.cpp b/Code/Tools/SceneAPI/SceneCore/Tests/Containers/SceneBehaviorTests.cpp
index cb23e73b0e..8d7fb63baf 100644
--- a/Code/Tools/SceneAPI/SceneCore/Tests/Containers/SceneBehaviorTests.cpp
+++ b/Code/Tools/SceneAPI/SceneCore/Tests/Containers/SceneBehaviorTests.cpp
@@ -20,6 +20,7 @@
#include
#include
#include
+#include
#include
#include
@@ -378,6 +379,25 @@ namespace AZ
MOCK_CONST_METHOD1(QueryApplicationType, void(AZ::ApplicationTypeQuery&));
};
+ class MockEditorPythonConsoleInterface final
+ : public AzToolsFramework::EditorPythonConsoleInterface
+ {
+ public:
+ MockEditorPythonConsoleInterface()
+ {
+ AZ::Interface::Register(this);
+ }
+
+ ~MockEditorPythonConsoleInterface()
+ {
+ AZ::Interface::Unregister(this);
+ }
+
+ MOCK_CONST_METHOD1(GetModuleList, void(AZStd::vector&));
+ MOCK_CONST_METHOD1(GetGlobalFunctionList, void(GlobalFunctionCollection&));
+ MOCK_METHOD1(FetchPythonTypeName, AZStd::string(const AZ::BehaviorParameter&));
+ };
+
//
// SceneGraphBehaviorScriptTest
//
@@ -386,6 +406,7 @@ namespace AZ
{
public:
AZStd::unique_ptr m_componentApplication;
+ AZStd::unique_ptr m_editorPythonConsoleInterface;
AZStd::unique_ptr m_scriptContext;
AZStd::unique_ptr m_behaviorContext;
AZStd::unique_ptr m_serializeContext;
@@ -454,6 +475,15 @@ namespace AZ
{
return this->m_serializeContext.get();
}));
+
+ m_editorPythonConsoleInterface = AZStd::make_unique();
+ }
+
+ void SetupEditorPythonConsoleInterface()
+ {
+ EXPECT_CALL(*m_editorPythonConsoleInterface, FetchPythonTypeName(::testing::_))
+ .Times(4)
+ .WillRepeatedly(::testing::Invoke([](const AZ::BehaviorParameter&) {return "int"; }));
}
void TearDown() override
@@ -562,6 +592,38 @@ namespace AZ
ExpectExecute("TestExpectEquals(value, 17)");
}
+ TEST_F(SceneGraphBehaviorScriptTest, GraphObjectProxy_GetClassInfo_Loads)
+ {
+ SetupEditorPythonConsoleInterface();
+
+ ExpectExecute("builder = MockBuilder()");
+ ExpectExecute("builder:BuildSceneGraph()");
+ ExpectExecute("scene = builder:GetScene()");
+ ExpectExecute("nodeG = scene.graph:FindWithPath('A.C.E.G')");
+ ExpectExecute("proxy = scene.graph:GetNodeContent(nodeG)");
+ ExpectExecute("TestExpectTrue(proxy:CastWithTypeName('MockIGraphObject'))");
+ ExpectExecute("info = proxy:GetClassInfo()");
+ ExpectExecute("TestExpectTrue(info ~= nil)");
+ }
+
+ TEST_F(SceneGraphBehaviorScriptTest, GraphObjectProxy_GetClassInfo_CorrectFormats)
+ {
+ SetupEditorPythonConsoleInterface();
+
+ ExpectExecute("builder = MockBuilder()");
+ ExpectExecute("builder:BuildSceneGraph()");
+ ExpectExecute("scene = builder:GetScene()");
+ ExpectExecute("nodeG = scene.graph:FindWithPath('A.C.E.G')");
+ ExpectExecute("proxy = scene.graph:GetNodeContent(nodeG)");
+ ExpectExecute("TestExpectTrue(proxy:CastWithTypeName('MockIGraphObject'))");
+ ExpectExecute("info = proxy:GetClassInfo()");
+ ExpectExecute("TestExpectTrue(info.className == 'MockIGraphObject')");
+ ExpectExecute("TestExpectTrue(info.classUuid == '{66A082CC-851D-4E1F-ABBD-45B58A216CFA}')");
+ ExpectExecute("TestExpectTrue(info.methodList[1] == 'def GetId(self) -> int')");
+ ExpectExecute("TestExpectTrue(info.methodList[2] == 'def SetId(self, arg1: int) -> None')");
+ ExpectExecute("TestExpectTrue(info.methodList[3] == 'def AddAndSet(self, arg1: int, arg2: int) -> None')");
+ }
+
//
// SceneManifestBehaviorScriptTest is meant to test the script abilities of the SceneManifest
//
diff --git a/Code/Tools/SceneAPI/SceneData/GraphData/BlendShapeData.h b/Code/Tools/SceneAPI/SceneData/GraphData/BlendShapeData.h
index 9ae287da46..403ab867f2 100644
--- a/Code/Tools/SceneAPI/SceneData/GraphData/BlendShapeData.h
+++ b/Code/Tools/SceneAPI/SceneData/GraphData/BlendShapeData.h
@@ -31,7 +31,7 @@ namespace AZ
public:
AZ_RTTI(BlendShapeData, "{FF875C22-2E4F-4CE3-BA49-09BF78C70A09}", SceneAPI::DataTypes::IBlendShapeData)
- SCENE_DATA_API static void Reflect(ReflectContext* context);
+ static void Reflect(ReflectContext* context);
// Maximum number of color sets matches limitation set in assImp (AI_MAX_NUMBER_OF_COLOR_SETS)
static constexpr AZ::u8 MaxNumColorSets = 8;
diff --git a/Gems/Atom/Feature/Common/Assets/ShaderResourceGroups/RayTracingSceneSrg.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/RayTracing/RayTracingSceneSrg.azsli
similarity index 96%
rename from Gems/Atom/Feature/Common/Assets/ShaderResourceGroups/RayTracingSceneSrg.azsli
rename to Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/RayTracing/RayTracingSceneSrg.azsli
index 0aeb43bcf2..a7bb6cd3b1 100644
--- a/Gems/Atom/Feature/Common/Assets/ShaderResourceGroups/RayTracingSceneSrg.azsli
+++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/RayTracing/RayTracingSceneSrg.azsli
@@ -10,11 +10,9 @@
*
*/
-#ifndef AZ_COLLECTING_PARTIAL_SRGS
-#error Do not include this file directly. Include the main .srgi file instead.
-#endif
+#include
-partial ShaderResourceGroup RayTracingSceneSrg
+ShaderResourceGroup RayTracingSceneSrg : SRG_RayTracingScene
{
RaytracingAccelerationStructure m_scene;
@@ -150,6 +148,4 @@ partial ShaderResourceGroup RayTracingSceneSrg
#define MESH_NORMAL_BUFFER_OFFSET 2
ByteAddressBuffer m_meshBuffers[];
-}
-
-
+}
\ No newline at end of file
diff --git a/Gems/Atom/Feature/Common/Assets/ShaderResourceGroups/RayTracingSceneSrgAll.azsli b/Gems/Atom/Feature/Common/Assets/ShaderResourceGroups/RayTracingSceneSrgAll.azsli
deleted file mode 100644
index b1b2bea750..0000000000
--- a/Gems/Atom/Feature/Common/Assets/ShaderResourceGroups/RayTracingSceneSrgAll.azsli
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
-* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-* its licensors.
-*
-* For complete copyright and license terms please see the LICENSE at the root of this
-* distribution (the "License"). All use of this software is governed by the License,
-* or, if provided, by the license below or the license accompanying this file. Do not
-* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-*
-*/
-
-#pragma once
-
-// Please review README.md to understand how this file is used in RayTracingSceneSrg.azsrg generation
-
-#ifdef AZ_COLLECTING_PARTIAL_SRGS
-#include
-#endif
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing.azshader b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing.azshader
index a781a598ba..804b534277 100644
Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing.azshader and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing.azshader differ
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_dx12_0.azshadervariant b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_dx12_0.azshadervariant
index e9f841047e..b3bee56bfd 100644
Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_dx12_0.azshadervariant and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_dx12_0.azshadervariant differ
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_null_0.azshadervariant b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_null_0.azshadervariant
index e399dbcef0..d9b2f17848 100644
Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_null_0.azshadervariant and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_null_0.azshadervariant differ
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_vulkan_0.azshadervariant b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_vulkan_0.azshadervariant
index 1580aa2477..cf39160d3f 100644
Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_vulkan_0.azshadervariant and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_vulkan_0.azshadervariant differ
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit.azshader b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit.azshader
index bfed840feb..c4a83a26dc 100644
Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit.azshader and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit.azshader differ
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_dx12_0.azshadervariant b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_dx12_0.azshadervariant
index ee2031bf1a..fb5b740f04 100644
Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_dx12_0.azshadervariant and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_dx12_0.azshadervariant differ
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_null_0.azshadervariant b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_null_0.azshadervariant
index 3b37084adf..b7bdabeb4e 100644
Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_null_0.azshadervariant and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_null_0.azshadervariant differ
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_vulkan_0.azshadervariant b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_vulkan_0.azshadervariant
index e2f5a8cb50..1eeeffa8be 100644
Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_vulkan_0.azshadervariant and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_vulkan_0.azshadervariant differ
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingcommon_raytracingglobalsrg.azsrg b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingcommon_raytracingglobalsrg.azsrg
index 930d34171e..c9fa0f4e1c 100644
--- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingcommon_raytracingglobalsrg.azsrg
+++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingcommon_raytracingglobalsrg.azsrg
@@ -9904,4 +9904,4 @@
]
}
]
-}
+}
\ No newline at end of file
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss.azshader b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss.azshader
index 84e773d9db..4f0cea1bfe 100644
Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss.azshader and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss.azshader differ
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_dx12_0.azshadervariant b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_dx12_0.azshadervariant
index b288bb7647..839efa7278 100644
Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_dx12_0.azshadervariant and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_dx12_0.azshadervariant differ
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_null_0.azshadervariant b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_null_0.azshadervariant
index 0f2473b606..5f08825487 100644
Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_null_0.azshadervariant and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_null_0.azshadervariant differ
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_vulkan_0.azshadervariant b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_vulkan_0.azshadervariant
index bfd979e588..a5b0e842ef 100644
Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_vulkan_0.azshadervariant and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_vulkan_0.azshadervariant differ
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/PostProcessing/SsaoCompute.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/PostProcessing/SsaoCompute.azsl
index c1fa41991e..8294911b44 100644
--- a/Gems/Atom/Feature/Common/Assets/Shaders/PostProcessing/SsaoCompute.azsl
+++ b/Gems/Atom/Feature/Common/Assets/Shaders/PostProcessing/SsaoCompute.azsl
@@ -277,6 +277,8 @@ void MainCS(uint3 thread_id : SV_GroupThreadID, uint3 group_id : SV_GroupID, uin
// Gather depth values
float2 depthGatherUV = mad(float2(ldsPosition), GetPixelSize(), ldsOffsetUV);
+ // Gather on some GPUs will fall onto same pixels in adjacent coordinates due to rounding errors
+ depthGatherUV += GetHalfPixelSize();
float4 depthGather = PassSrg::m_linearDepth.Gather(PassSrg::PointSampler, depthGatherUV);
WriteDepthGatherToLDS(ldsPosition, depthGather);
diff --git a/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake b/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake
index f14fb4f4a0..84ef494216 100644
--- a/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake
+++ b/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake
@@ -280,8 +280,6 @@ set(FILES
ShaderLib/Atom/Features/Shadow/Shadow.azsli
ShaderLib/Atom/Features/Shadow/ShadowmapAtlasLib.azsli
ShaderLib/Atom/Features/Vertex/VertexHelper.azsli
- ShaderResourceGroups/RayTracingSceneSrg.azsli
- ShaderResourceGroups/RayTracingSceneSrgAll.azsli
ShaderResourceGroups/SceneSrg.azsli
ShaderResourceGroups/SceneSrgAll.azsli
ShaderResourceGroups/SceneTimeSrg.azsli
diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessor.h
index a89875aaa6..ff84f77a3e 100644
--- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessor.h
+++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessor.h
@@ -36,10 +36,11 @@ namespace AZ
void RemoveProbe(ReflectionProbeHandle& probe) override;
void SetProbeOuterExtents(const ReflectionProbeHandle& probe, const AZ::Vector3& outerExtents) override;
void SetProbeInnerExtents(const ReflectionProbeHandle& probe, const AZ::Vector3& innerExtents) override;
- void SetProbeCubeMap(const ReflectionProbeHandle& probe, Data::Instance& cubeMapImage) override;
+ void SetProbeCubeMap(const ReflectionProbeHandle& probe, Data::Instance& cubeMapImage, const AZStd::string& relativePath) override;
void SetProbeTransform(const ReflectionProbeHandle& probe, const AZ::Transform& transform) override;
- void BakeProbe(const ReflectionProbeHandle& probe, BuildCubeMapCallback callback) override;
- void NotifyCubeMapAssetReady(const AZStd::string relativePath, NotifyCubeMapAssetReadyCallback callback) override;
+ void BakeProbe(const ReflectionProbeHandle& probe, BuildCubeMapCallback callback, const AZStd::string& relativePath) override;
+ bool CheckCubeMapAssetNotification(const AZStd::string& relativePath, Data::Asset& outCubeMapAsset, CubeMapAssetNotificationType& outNotificationType) override;
+ bool IsCubeMapReferenced(const AZStd::string& relativePath) override;
bool IsValidProbeHandle(const ReflectionProbeHandle& probe) const override { return (probe.get() != nullptr); }
void ShowProbeVisualization(const ReflectionProbeHandle& probe, bool showVisualization) override;
@@ -72,10 +73,9 @@ namespace AZ
// AssetBus::MultiHandler overrides...
void OnAssetReady(Data::Asset asset) override;
void OnAssetError(Data::Asset asset) override;
- void OnAssetReloaded(Data::Asset asset) override;
// notifies and removes the notification entry
- void HandleAssetNotification(Data::Asset asset, CubeMapAssetNotificationType notificationTyp);
+ void HandleAssetNotification(Data::Asset asset, CubeMapAssetNotificationType notificationType);
// list of reflection probes
const size_t InitialProbeAllocationSize = 64;
@@ -86,9 +86,8 @@ namespace AZ
{
AZStd::string m_relativePath;
AZ::Data::AssetId m_assetId;
- bool m_existingAsset = false;
- NotifyCubeMapAssetReadyCallback m_callback;
Data::Asset m_asset;
+ CubeMapAssetNotificationType m_notificationType = CubeMapAssetNotificationType::None;
};
typedef AZStd::vector NotifyCubeMapAssetVector;
NotifyCubeMapAssetVector m_notifyCubeMapAssets;
diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessorInterface.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessorInterface.h
index 8b277e97c8..03c44d0442 100644
--- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessorInterface.h
+++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessorInterface.h
@@ -30,11 +30,11 @@ namespace AZ
enum CubeMapAssetNotificationType
{
+ None,
Ready,
Error,
Reloaded
};
- using NotifyCubeMapAssetReadyCallback = AZStd::function& cubeMapAsset, CubeMapAssetNotificationType notificationType)>;
// ReflectionProbeFeatureProcessorInterface provides an interface to the feature processor for code outside of Atom
class ReflectionProbeFeatureProcessorInterface
@@ -47,10 +47,11 @@ namespace AZ
virtual void RemoveProbe(ReflectionProbeHandle& handle) = 0;
virtual void SetProbeOuterExtents(const ReflectionProbeHandle& handle, const AZ::Vector3& outerExtents) = 0;
virtual void SetProbeInnerExtents(const ReflectionProbeHandle& handle, const AZ::Vector3& innerExtents) = 0;
- virtual void SetProbeCubeMap(const ReflectionProbeHandle& handle, Data::Instance& cubeMapImage) = 0;
+ virtual void SetProbeCubeMap(const ReflectionProbeHandle& handle, Data::Instance& cubeMapImage, const AZStd::string& relativePath) = 0;
virtual void SetProbeTransform(const ReflectionProbeHandle& handle, const AZ::Transform& transform) = 0;
- virtual void BakeProbe(const ReflectionProbeHandle& handle, BuildCubeMapCallback callback) = 0;
- virtual void NotifyCubeMapAssetReady(const AZStd::string relativePath, NotifyCubeMapAssetReadyCallback callback) = 0;
+ virtual void BakeProbe(const ReflectionProbeHandle& handle, BuildCubeMapCallback callback, const AZStd::string& relativePath) = 0;
+ virtual bool CheckCubeMapAssetNotification(const AZStd::string& relativePath, Data::Asset& outCubeMapAsset, CubeMapAssetNotificationType& outNotificationType) = 0;
+ virtual bool IsCubeMapReferenced(const AZStd::string& relativePath) = 0;
virtual bool IsValidProbeHandle(const ReflectionProbeHandle& probe) const = 0;
virtual void ShowProbeVisualization(const ReflectionProbeHandle& probe, bool showVisualization) = 0;
};
diff --git a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp
index 0c24c2953d..c4e9306dc9 100644
--- a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp
+++ b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp
@@ -67,7 +67,7 @@ namespace AZ
// load the RayTracingSceneSrg asset
Data::Asset rayTracingSceneSrgAsset =
- RPI::AssetUtils::LoadAssetByProductPath("shaderlib/raytracingscenesrg_raytracingscenesrg.azsrg", RPI::AssetUtils::TraceLevel::Error);
+ RPI::AssetUtils::LoadAssetByProductPath("shaderlib/atom/features/raytracing/raytracingscenesrg_raytracingscenesrg.azsrg", RPI::AssetUtils::TraceLevel::Error);
AZ_Assert(rayTracingSceneSrgAsset.IsReady(), "Failed to load RayTracingSceneSrg asset");
m_rayTracingSceneSrg = RPI::ShaderResourceGroup::Create(rayTracingSceneSrgAsset);
diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp
index cfce718146..e0b79e23aa 100644
--- a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp
+++ b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp
@@ -234,9 +234,10 @@ namespace AZ
m_updateSrg = true;
}
- void ReflectionProbe::SetCubeMapImage(const Data::Instance& cubeMapImage)
+ void ReflectionProbe::SetCubeMapImage(const Data::Instance& cubeMapImage, const AZStd::string& relativePath)
{
m_cubeMapImage = cubeMapImage;
+ m_cubeMapRelativePath = relativePath;
m_updateSrg = true;
}
diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.h b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.h
index 42b3ff5c5a..ab0e7a81d3 100644
--- a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.h
+++ b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.h
@@ -88,7 +88,9 @@ namespace AZ
const Aabb& GetInnerAabbWs() const { return m_innerAabbWs; }
const Data::Instance& GetCubeMapImage() const { return m_cubeMapImage; }
- void SetCubeMapImage(const Data::Instance& cubeMapImage);
+ void SetCubeMapImage(const Data::Instance