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/EditorPythonBindings/CryMaterialsCommands_test.py b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/CryMaterialsCommands_test.py
deleted file mode 100755
index 41ae0608a4..0000000000
--- a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/CryMaterialsCommands_test.py
+++ /dev/null
@@ -1,75 +0,0 @@
-"""
-All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-its licensors.
-
-For complete copyright and license terms please see the LICENSE at the root of this
-distribution (the "License"). All use of this software is governed by the License,
-or, if provided, by the license below or the license accompanying this file. Do not
-remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-"""
-
-#
-# This is a pytest module to test the in-Editor Python API from ViewPane.h
-#
-import pytest
-pytest.importorskip('ly_test_tools')
-
-import sys
-import os
-sys.path.append(os.path.dirname(__file__))
-from hydra_utils import launch_test_case
-
-
-@pytest.mark.SUITE_sandbox
-@pytest.mark.parametrize('launcher_platform', ['windows_editor'])
-@pytest.mark.parametrize('project', ['AutomatedTesting'])
-@pytest.mark.parametrize('level', ['auto_test'])
-class TestLegacyCryMaterialsCommandsAutomation(object):
-
- def test_Legacy_CryMaterials(self, request, editor, level, launcher_platform):
-
- unexpected_lines=[]
- expected_lines = [
- # "Material Settings/Shader updated correctly", # Disabled, SPEC-3590
- # "Material Settings/Surface Type updated correctly", # Disabled, SPEC-3590
- "Texture Maps/Diffuse/Tiling/IsTileU updated correctly",
- "Texture Maps/Diffuse/Tiling/TileU updated correctly",
- "Texture Maps/Diffuse/Rotator/Type updated correctly",
- "Texture Maps/Diffuse/Rotator/Amplitude updated correctly",
- "Texture Maps/Diffuse/Oscillator/AmplitudeU updated correctly",
- "Opacity Settings/Opacity updated correctly",
- "Opacity Settings/AlphaTest updated correctly",
- "Opacity Settings/Additive updated correctly",
- "Lighting Settings/Diffuse Color updated correctly",
- "Lighting Settings/Specular Color updated correctly",
- "Lighting Settings/Emissive Intensity updated correctly",
- "Lighting Settings/Emissive Color updated correctly",
- "Advanced/Allow layer activation updated correctly",
- "Advanced/2 Sided updated correctly",
- "Advanced/No Shadow updated correctly",
- "Advanced/Use Scattering updated correctly",
- "Advanced/Hide After Breaking updated correctly",
- "Advanced/Fog Volume Shading Quality High updated correctly",
- "Advanced/Blend Terrain Color updated correctly",
- "Advanced/Voxel Coverage updated correctly",
- "Advanced/Propagate Opacity Settings updated correctly",
- "Advanced/Propagate Lighting Settings updated correctly",
- "Advanced/Propagate Advanced Settings updated correctly",
- "Advanced/Propagate Texture Maps updated correctly",
- "Advanced/Propagate Shader Params updated correctly",
- "Advanced/Propagate Shader Generation updated correctly",
- "Advanced/Propagate Vertex Deformation updated correctly",
- # "Shader Params/Blend Factor updated correctly", # Disabled, SPEC-3590
- # "Shader Params/Indirect bounce color updated correctly", # Disabled, SPEC-3590
- "Vertex Deformation/Type updated correctly",
- "Vertex Deformation/Wave Length X updated correctly",
- "Vertex Deformation/Wave X/Level updated correctly",
- "Vertex Deformation/Wave X/Amplitude updated correctly",
- "Vertex Deformation/Wave X/Phase updated correctly",
- "Vertex Deformation/Wave X/Frequency updated correctly"
- ]
-
- test_case_file = os.path.join(os.path.dirname(__file__), 'CryMaterialsCommands_test_case.py')
- launch_test_case(editor, test_case_file, expected_lines, unexpected_lines)
-
diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/CryMaterialsCommands_test_case.py b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/CryMaterialsCommands_test_case.py
deleted file mode 100755
index 913b1ace24..0000000000
--- a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/CryMaterialsCommands_test_case.py
+++ /dev/null
@@ -1,116 +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.
-"""
-
-# Tests the legacy Python API for CryMaterials while the Editor is running
-
-import azlmbr.bus as bus
-import azlmbr.editor as editor
-import azlmbr.legacy.material as material
-import azlmbr.math as math
-
-materialName = 'materials/ter_layer_green'
-print(f'Starting CryMaterial test case using material {materialName}')
-
-
-def MaterialPropertyTest(property, value, doReset=True):
- try:
- # get old value and attempt to set new value
- oldValue = material.get_property(materialName, property)
- if oldValue == value:
- print(f'>>> `{property}` already set to {oldValue}')
- return
- material.set_property(materialName, property, value)
-
- # test that the set new value worked
- newValue = material.get_property(materialName, property)
- if oldValue != newValue:
- print(f"{property} updated correctly")
-
- # reset back to old value
- if doReset:
- material.set_property(materialName, property, oldValue)
- except:
- print(f'!!! hit an exception when setting `{property}` to {value}')
-
-
-color = math.Color()
-color.r = 255.0
-color.g = 128.0
-color.b = 64.0
-color.a = 0.0
-
-# Material Settings
-# MaterialPropertyTest("Material Settings/Shader", "Geometrybeam") # Disabled, SPEC-3590
-# MaterialPropertyTest("Material Settings/Surface Type", "grass") # Disabled, SPEC-3590
-
-# Texture Maps
-MaterialPropertyTest("Texture Maps/Diffuse/Tiling/IsTileU", False)
-MaterialPropertyTest("Texture Maps/Diffuse/Tiling/IsTileV", False)
-MaterialPropertyTest("Texture Maps/Diffuse/Tiling/TileU", 0.42)
-MaterialPropertyTest("Texture Maps/Diffuse/Rotator/Type", 'Oscillated Rotation')
-MaterialPropertyTest("Texture Maps/Diffuse/Rotator/Amplitude", 42.0)
-MaterialPropertyTest("Texture Maps/Diffuse/Oscillator/TypeU", 'Fixed Moving')
-MaterialPropertyTest("Texture Maps/Diffuse/Oscillator/AmplitudeU", 42.0)
-
-# Vertex Deformation
-MaterialPropertyTest("Vertex Deformation/Type", 'Sin Wave')
-MaterialPropertyTest("Vertex Deformation/Wave Length X", 42.0)
-MaterialPropertyTest("Vertex Deformation/Type", 'Perlin 3D')
-MaterialPropertyTest("Vertex Deformation/Noise Scale", math.Vector3(1.1, 2.2, 3.3))
-
-# Opacity Settings
-MaterialPropertyTest("Opacity Settings/Opacity", 42)
-MaterialPropertyTest("Opacity Settings/AlphaTest", 2)
-MaterialPropertyTest("Opacity Settings/Additive", True)
-
-# Lighting Settings
-MaterialPropertyTest("Lighting Settings/Diffuse Color", color)
-MaterialPropertyTest("Lighting Settings/Specular Color", color)
-MaterialPropertyTest("Lighting Settings/Emissive Intensity", 42.0)
-MaterialPropertyTest("Lighting Settings/Emissive Color", color)
-MaterialPropertyTest("Lighting Settings/Specular Level", 2.0)
-
-# Advanced
-MaterialPropertyTest("Advanced/Allow layer activation", False)
-MaterialPropertyTest("Advanced/2 Sided", True)
-MaterialPropertyTest("Advanced/No Shadow", True)
-MaterialPropertyTest("Advanced/Use Scattering", True)
-MaterialPropertyTest("Advanced/Hide After Breaking", True)
-MaterialPropertyTest("Advanced/Fog Volume Shading Quality High", True)
-MaterialPropertyTest("Advanced/Blend Terrain Color", True)
-MaterialPropertyTest("Advanced/Voxel Coverage", 0.42)
-# --- MaterialPropertyTest("Advanced/Link to Material", "materials/ter_layer_blue") # Works, but clears on UI refresh
-MaterialPropertyTest("Advanced/Propagate Opacity Settings", True)
-MaterialPropertyTest("Advanced/Propagate Lighting Settings", True)
-MaterialPropertyTest("Advanced/Propagate Advanced Settings", True)
-MaterialPropertyTest("Advanced/Propagate Texture Maps", True)
-MaterialPropertyTest("Advanced/Propagate Shader Params", True)
-MaterialPropertyTest("Advanced/Propagate Shader Generation", True)
-MaterialPropertyTest("Advanced/Propagate Vertex Deformation", True)
-
-# Shader parameters vary with each Shader, just testing a couple of them...
-# MaterialPropertyTest("Shader Params/Blend Factor", 7.0, False) # Disabled, SPEC-3590
-# MaterialPropertyTest("Shader Params/Indirect bounce color", color, False) # Disabled, SPEC-3590
-
-### These values are reset to False when set. Left them here commented for reference.
-# MaterialPropertyTest("Shader Generation Params/Dust & Turbulence", True)
-# MaterialPropertyTest("Shader Generation Params/Receive Shadows", True)
-# MaterialPropertyTest("Shader Generation Params/UV Vignetting", True)
-
-# Vertex Deformation
-MaterialPropertyTest("Vertex Deformation/Type", "Sin Wave")
-MaterialPropertyTest("Vertex Deformation/Wave Length X", 42.0)
-MaterialPropertyTest("Vertex Deformation/Wave X/Level", 42.0)
-MaterialPropertyTest("Vertex Deformation/Wave X/Amplitude", 42.0)
-MaterialPropertyTest("Vertex Deformation/Wave X/Phase", 42.0)
-MaterialPropertyTest("Vertex Deformation/Wave X/Frequency", 42.0)
-
-editor.EditorToolsApplicationRequestBus(bus.Broadcast, 'ExitNoPrompt')
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/CMakeLists.txt b/CMakeLists.txt
index cefbcf2ef4..ae8a7a05f8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -75,7 +75,9 @@ foreach(restricted_platform ${PAL_RESTRICTED_PLATFORMS})
endif()
endforeach()
-add_subdirectory(scripts)
+if(NOT INSTALLED_ENGINE)
+ add_subdirectory(scripts)
+endif()
# SPEC-1417 will investigate and fix this
if(NOT PAL_PLATFORM_NAME STREQUAL "Mac")
@@ -125,5 +127,5 @@ if(NOT INSTALLED_ENGINE)
ly_setup_o3de_install()
# IMPORTANT: must be included last
- include(cmake/CPack.cmake)
+ include(cmake/Packaging.cmake)
endif()
diff --git a/Code/CryEngine/CryCommon/CREVolumeObject.h b/Code/CryEngine/CryCommon/CREVolumeObject.h
index d84c7b3e50..2137053a8e 100644
--- a/Code/CryEngine/CryCommon/CREVolumeObject.h
+++ b/Code/CryEngine/CryCommon/CREVolumeObject.h
@@ -55,7 +55,7 @@ public:
Matrix34 m_matInv;
Vec3 m_eyePosInWS;
Vec3 m_eyePosInOS;
- Plane m_volumeTraceStartPlane;
+ Plane_tpl m_volumeTraceStartPlane;
AABB m_renderBoundsOS;
bool m_viewerInsideVolume;
bool m_nearPlaneIntersectsVolume;
diff --git a/Code/CryEngine/CryCommon/CREWaterOcean.h b/Code/CryEngine/CryCommon/CREWaterOcean.h
index 784588309f..e8ca310d41 100644
--- a/Code/CryEngine/CryCommon/CREWaterOcean.h
+++ b/Code/CryEngine/CryCommon/CREWaterOcean.h
@@ -25,7 +25,7 @@ public:
virtual void mfPrepare(bool bCheckOverflow);
virtual bool mfDraw(CShader* ef, SShaderPass* sfm);
- virtual void mfGetPlane(Plane& pl);
+ virtual void mfGetPlane(Plane_tpl& pl);
virtual void Create(uint32 nVerticesCount, SVF_P3F_C4B_T2F* pVertices, uint32 nIndicesCount, const void* pIndices, uint32 nIndexSizeof);
void ReleaseOcean();
diff --git a/Code/CryEngine/CryCommon/CREWaterVolume.h b/Code/CryEngine/CryCommon/CREWaterVolume.h
index 3e7a0636e6..89102e3097 100644
--- a/Code/CryEngine/CryCommon/CREWaterVolume.h
+++ b/Code/CryEngine/CryCommon/CREWaterVolume.h
@@ -27,7 +27,7 @@ public:
virtual ~CREWaterVolume();
virtual void mfPrepare(bool bCheckOverflow);
virtual bool mfDraw(CShader* ef, SShaderPass* sfm);
- virtual void mfGetPlane(Plane& pl);
+ virtual void mfGetPlane(Plane_tpl& pl);
virtual void mfCenter(Vec3& vCenter, CRenderObject* pObj);
virtual void GetMemoryUsage(ICrySizer* pSizer) const
@@ -69,7 +69,7 @@ public:
Vec3 m_center;
AABB m_WSBBox;
- Plane m_fogPlane;
+ Plane_tpl m_fogPlane;
float m_fogDensity;
Vec3 m_fogColor;
bool m_fogColorAffectedBySun;
diff --git a/Code/CryEngine/CryCommon/Cry_Camera.h b/Code/CryEngine/CryCommon/Cry_Camera.h
index a744d7335f..56a764d897 100644
--- a/Code/CryEngine/CryCommon/Cry_Camera.h
+++ b/Code/CryEngine/CryCommon/Cry_Camera.h
@@ -594,7 +594,7 @@ public:
ILINE const Vec3& GetFPVertex(int nId) const; //get far-plane vertices
ILINE const Vec3& GetPPVertex(int nId) const; //get projection-plane vertices
- ILINE const Plane* GetFrustumPlane(int numplane) const { return &m_fp[numplane]; }
+ ILINE const Plane_tpl* GetFrustumPlane(int numplane) const { return &m_fp[numplane]; }
//////////////////////////////////////////////////////////////////////////
// Z-Buffer ranges.
@@ -720,7 +720,7 @@ private:
Vec3 m_cltn, m_crtn, m_clbn, m_crbn; //this are the 4 vertices of the near-plane in cam-space
Vec3 m_cltf, m_crtf, m_clbf, m_crbf; //this are the 4 vertices of the farclip-plane in cam-space
- Plane m_fp [FRUSTUM_PLANES]; //
+ Plane_tpl m_fp [FRUSTUM_PLANES]; //
uint32 m_idx1[FRUSTUM_PLANES], m_idy1[FRUSTUM_PLANES], m_idz1[FRUSTUM_PLANES]; //
uint32 m_idx2[FRUSTUM_PLANES], m_idy2[FRUSTUM_PLANES], m_idz2[FRUSTUM_PLANES]; //
@@ -742,7 +742,7 @@ public:
m_crtp = arrvVerts[2];
m_crbp = arrvVerts[3];
}
- inline void SetFrustumPlane(int i, const Plane& plane)
+ inline void SetFrustumPlane(int i, const Plane_tpl& plane)
{
m_fp[i] = plane;
//do not break strict aliasing rules, use union instead of reinterpret_casts
@@ -1180,12 +1180,12 @@ inline void CCamera::UpdateFrustum()
//-------------------------------------------------------------------------------
//--- calculate the six frustum-planes using the frustum edges in world-space ---
//-------------------------------------------------------------------------------
- m_fp[FR_PLANE_NEAR ] = Plane::CreatePlane(m_crtn + GetPosition(), m_cltn + GetPosition(), m_crbn + GetPosition());
- m_fp[FR_PLANE_RIGHT ] = Plane::CreatePlane(m_crbf + GetPosition(), m_crtf + GetPosition(), GetPosition());
- m_fp[FR_PLANE_LEFT ] = Plane::CreatePlane(m_cltf + GetPosition(), m_clbf + GetPosition(), GetPosition());
- m_fp[FR_PLANE_TOP ] = Plane::CreatePlane(m_crtf + GetPosition(), m_cltf + GetPosition(), GetPosition());
- m_fp[FR_PLANE_BOTTOM] = Plane::CreatePlane(m_clbf + GetPosition(), m_crbf + GetPosition(), GetPosition());
- m_fp[FR_PLANE_FAR ] = Plane::CreatePlane(m_crtf + GetPosition(), m_crbf + GetPosition(), m_cltf + GetPosition()); //clip-plane
+ m_fp[FR_PLANE_NEAR ] = Plane_tpl::CreatePlane(m_crtn + GetPosition(), m_cltn + GetPosition(), m_crbn + GetPosition());
+ m_fp[FR_PLANE_RIGHT ] = Plane_tpl::CreatePlane(m_crbf + GetPosition(), m_crtf + GetPosition(), GetPosition());
+ m_fp[FR_PLANE_LEFT ] = Plane_tpl::CreatePlane(m_cltf + GetPosition(), m_clbf + GetPosition(), GetPosition());
+ m_fp[FR_PLANE_TOP ] = Plane_tpl::CreatePlane(m_crtf + GetPosition(), m_cltf + GetPosition(), GetPosition());
+ m_fp[FR_PLANE_BOTTOM] = Plane_tpl::CreatePlane(m_clbf + GetPosition(), m_crbf + GetPosition(), GetPosition());
+ m_fp[FR_PLANE_FAR ] = Plane_tpl::CreatePlane(m_crtf + GetPosition(), m_crbf + GetPosition(), m_cltf + GetPosition()); //clip-plane
uint32 rh = m_Matrix.IsOrthonormalRH();
if (rh == 0)
diff --git a/Code/CryEngine/CryCommon/Cry_GeoDistance.h b/Code/CryEngine/CryCommon/Cry_GeoDistance.h
index 92c1f65d87..47794c7671 100644
--- a/Code/CryEngine/CryCommon/Cry_GeoDistance.h
+++ b/Code/CryEngine/CryCommon/Cry_GeoDistance.h
@@ -1168,17 +1168,6 @@ namespace Distance {
return fDist2;
}
- // Compute both the min and max distances of a box to a plane, in the sense of the plane normal.
- inline void AABB_Plane(float* pfDistMin, float* pfDistMax, const AABB& box, const Plane& pl)
- {
- float fDist0 = pl.DistFromPlane(box.min),
- fDistX = (box.max.x - box.min.x) * pl.n.x,
- fDistY = (box.max.y - box.min.y) * pl.n.y,
- fDistZ = (box.max.z - box.min.z) * pl.n.z;
- *pfDistMin = fDist0 + min(fDistX, 0.f) + min(fDistY, 0.f) + min(fDistZ, 0.f);
- *pfDistMax = fDist0 + max(fDistX, 0.f) + max(fDistY, 0.f) + max(fDistZ, 0.f);
- }
-
//----------------------------------------------------------------------------------
// Distance: Sphere_Triangle
//----------------------------------------------------------------------------------
diff --git a/Code/CryEngine/CryCommon/Cry_GeoIntersect.h b/Code/CryEngine/CryCommon/Cry_GeoIntersect.h
index c2f556c4b7..89f6d8ebaf 100644
--- a/Code/CryEngine/CryCommon/Cry_GeoIntersect.h
+++ b/Code/CryEngine/CryCommon/Cry_GeoIntersect.h
@@ -22,7 +22,7 @@
#include
namespace Intersect {
- inline bool Ray_Plane(const Ray& ray, const Plane& plane, Vec3& output, bool bSingleSidePlane = true)
+ inline bool Ray_Plane(const Ray& ray, const Plane_tpl& plane, Vec3& output, bool bSingleSidePlane = true)
{
float cosine = plane.n | ray.direction;
@@ -49,7 +49,7 @@ namespace Intersect {
return true; //intersection occurred
}
- inline bool Line_Plane(const Line& line, const Plane& plane, Vec3& output, bool bSingleSidePlane = true)
+ inline bool Line_Plane(const Line& line, const Plane_tpl& plane, Vec3& output, bool bSingleSidePlane = true)
{
float cosine = plane.n | line.direction;
diff --git a/Code/CryEngine/CryCommon/Cry_GeoOverlap.h b/Code/CryEngine/CryCommon/Cry_GeoOverlap.h
index 3f2c7081d7..ab560b7518 100644
--- a/Code/CryEngine/CryCommon/Cry_GeoOverlap.h
+++ b/Code/CryEngine/CryCommon/Cry_GeoOverlap.h
@@ -945,29 +945,6 @@ namespace Overlap {
}
}
-
- /*!
- *
- * we use the SEPARATING-AXIS-TEST for OBB/Plane overlap.
- *
- * Example:
- * bool result=Overlap::OBB_Plane( pos,obb, plane );
- *
- */
- inline bool OBB_Plane(const Vec3& pos, const OBB& obb, const Plane& plane)
- {
- //the new center-position in world-space
- Vec3 p = obb.m33 * obb.c + pos;
- //extract the orientation-vectors from the columns of the 3x3 matrix
- //and scale them by the half-lengths
- Vec3 ax = Vec3(obb.m33.m00, obb.m33.m10, obb.m33.m20) * obb.h.x;
- Vec3 ay = Vec3(obb.m33.m01, obb.m33.m11, obb.m33.m21) * obb.h.y;
- Vec3 az = Vec3(obb.m33.m02, obb.m33.m12, obb.m33.m22) * obb.h.z;
- //check OBB against Plane, using the plane-normal as separating axis
- return fabsf(plane | p) < (fabsf(plane.n | ax) + fabsf(plane.n | ay) + fabsf(plane.n | az));
- }
-
-
/*!
*
* we use the SEPARATING AXIS TEST to check if a triangle and AABB overlap.
@@ -1214,7 +1191,7 @@ namespace Overlap {
//test if the box intersects the plane of the triangle
//compute plane equation of triangle: normal*x+d=0
- Plane plane = Plane::CreatePlane((e0 % e1), v0);
+ Plane_tpl plane = Plane_tpl::CreatePlane((e0 % e1), v0);
Vec3 vmin, vmax;
if (plane.n.x > 0.0f)
@@ -1505,7 +1482,7 @@ namespace Overlap {
//test if the box overlaps the plane of the triangle
//compute plane equation of triangle: normal*x+d=0
- Plane plane = Plane::CreatePlane((e0 % e1), v0);
+ Plane_tpl plane = Plane_tpl::CreatePlane((e0 % e1), v0);
Vec3 vmin, vmax;
if (plane.n.x > 0.0f)
diff --git a/Code/CryEngine/CryCommon/I3DEngine.h b/Code/CryEngine/CryCommon/I3DEngine.h
index 8d3801ecb4..883b0a6d3b 100644
--- a/Code/CryEngine/CryCommon/I3DEngine.h
+++ b/Code/CryEngine/CryCommon/I3DEngine.h
@@ -458,7 +458,7 @@ struct SClipVolumeBlendInfo
{
static const int BlendPlaneCount = 2;
- Plane blendPlanes[BlendPlaneCount];
+ Plane_tpl blendPlanes[BlendPlaneCount];
struct IClipVolume* blendVolumes[BlendPlaneCount];
};
diff --git a/Code/CryEngine/CryCommon/IEntityRenderState.h b/Code/CryEngine/CryCommon/IEntityRenderState.h
index 912f4632ab..92ff354eff 100644
--- a/Code/CryEngine/CryCommon/IEntityRenderState.h
+++ b/Code/CryEngine/CryCommon/IEntityRenderState.h
@@ -731,8 +731,8 @@ struct IWaterVolumeRenderNode
virtual void SetAuxPhysParams(pe_params_area*) = 0;
virtual void CreateOcean(uint64 volumeID, /* TBD */ bool keepSerializationParams = false) = 0;
- virtual void CreateArea(uint64 volumeID, const Vec3* pVertices, unsigned int numVertices, const Vec2& surfUVScale, const Plane& fogPlane, bool keepSerializationParams = false, int nSID = -1) = 0;
- virtual void CreateRiver(uint64 volumeID, const Vec3* pVertices, unsigned int numVertices, float uTexCoordBegin, float uTexCoordEnd, const Vec2& surfUVScale, const Plane& fogPlane, bool keepSerializationParams = false, int nSID = -1) = 0;
+ virtual void CreateArea(uint64 volumeID, const Vec3* pVertices, unsigned int numVertices, const Vec2& surfUVScale, const Plane_tpl& fogPlane, bool keepSerializationParams = false, int nSID = -1) = 0;
+ virtual void CreateRiver(uint64 volumeID, const Vec3* pVertices, unsigned int numVertices, float uTexCoordBegin, float uTexCoordEnd, const Vec2& surfUVScale, const Plane_tpl& fogPlane, bool keepSerializationParams = false, int nSID = -1) = 0;
virtual void CreateRiver(uint64 volumeID, const AZStd::vector& verticies, const AZ::Transform& transform, float uTexCoordBegin, float uTexCoordEnd, const AZ::Vector2& surfUVScale, const AZ::Plane& fogPlane, bool keepSerializationParams = false, int nSID = -1) = 0;
virtual void SetAreaPhysicsArea(const Vec3* pVertices, unsigned int numVertices, bool keepSerializationParams = false) = 0;
diff --git a/Code/CryEngine/CryCommon/IShader.h b/Code/CryEngine/CryCommon/IShader.h
index 1e8553ac57..7fcbdefebb 100644
--- a/Code/CryEngine/CryCommon/IShader.h
+++ b/Code/CryEngine/CryCommon/IShader.h
@@ -52,7 +52,6 @@ struct SShaderItem;
class ITexture;
struct IMaterial;
struct SParam;
-class CMaterial;
struct SShaderSerializeContext;
struct IAnimNode;
struct SSkinningData;
diff --git a/Code/CryEngine/CryCommon/RendElement.h b/Code/CryEngine/CryCommon/RendElement.h
index c3dc1c080d..41bcf2bf67 100644
--- a/Code/CryEngine/CryCommon/RendElement.h
+++ b/Code/CryEngine/CryCommon/RendElement.h
@@ -119,7 +119,7 @@ struct IRenderElement
virtual void mfCenter(Vec3& centr, CRenderObject* pObj) = 0;
virtual void mfGetBBox(Vec3& vMins, Vec3& vMaxs) = 0;
virtual void mfReset() = 0;
- virtual void mfGetPlane(Plane& pl) = 0;
+ virtual void mfGetPlane(Plane_tpl& pl) = 0;
virtual void mfExport(struct SShaderSerializeContext& SC) = 0;
virtual void mfImport(struct SShaderSerializeContext& SC, uint32& offset) = 0;
virtual void mfPrecache(const SShaderItem& SH) = 0;
@@ -265,7 +265,7 @@ public:
void mfPrecache([[maybe_unused]] const SShaderItem& SH) override {}
void mfExport([[maybe_unused]] struct SShaderSerializeContext& SC) override { CryFatalError("mfExport has not been implemented for this render element type"); }
void mfImport([[maybe_unused]] struct SShaderSerializeContext& SC, [[maybe_unused]] uint32& offset) override { CryFatalError("mfImport has not been implemented for this render element type"); }
- void mfGetPlane(Plane& pl) override;
+ void mfGetPlane(Plane_tpl& pl) override;
void* mfGetPointer([[maybe_unused]] ESrcPointer ePT, [[maybe_unused]] int* Stride, [[maybe_unused]] EParamType Type, [[maybe_unused]] ESrcPointer Dst, [[maybe_unused]] int Flags) override { return nullptr; }
uint16 mfGetFlags() override { return m_Flags; }
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/Asset/AssetContainer.cpp b/Code/Framework/AzCore/AzCore/Asset/AssetContainer.cpp
index 4e7a19c197..2ff6143912 100644
--- a/Code/Framework/AzCore/AzCore/Asset/AssetContainer.cpp
+++ b/Code/Framework/AzCore/AzCore/Asset/AssetContainer.cpp
@@ -239,8 +239,13 @@ namespace AZ
return;
}
- CheckReady();
m_initComplete = true;
+
+ // *After* setting initComplete to true, check to see if the assets are already ready.
+ // This check needs to wait until after setting initComplete because if they *are* ready, we want the final call to
+ // RemoveWaitingAsset to trigger the OnAssetContainerReady/Canceled event. If we call CheckReady() *before* setting
+ // initComplete, if all the assets are ready, the event will never get triggered.
+ CheckReady();
}
bool AssetContainer::IsReady() const
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;
+ //! Operator for matrix-matrix addition.
+ //! @{
+ [[nodiscard]] Matrix3x3 operator+(const Matrix3x3& rhs) const;
+ Matrix3x3& operator+=(const Matrix3x3& rhs);
+ //! @}
- Matrix3x3 operator-() const;
+ //! 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);
- Matrix3x3& operator+=(const Matrix3x3& rhs);
- 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,44 +408,45 @@ 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()));
+ 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
+ AZ_MATH_INLINE Matrix3x3& Matrix3x3::operator+=(const Matrix3x3& rhs)
{
- 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()));
+ *this = *this + rhs;
+ return *this;
}
- AZ_MATH_INLINE Matrix3x3 Matrix3x3::operator*(float multiplier) const
+ AZ_MATH_INLINE Matrix3x3 Matrix3x3::operator-(const Matrix3x3& rhs) 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));
+ 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 divisor) const
+ AZ_MATH_INLINE Matrix3x3& Matrix3x3::operator-=(const Matrix3x3& rhs)
{
- 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));
+ *this = *this - rhs;
+ return *this;
}
- AZ_MATH_INLINE Matrix3x3 Matrix3x3::operator-() const
+ AZ_MATH_INLINE Matrix3x3 Matrix3x3::operator*(const Matrix3x3& rhs) 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()));
+ Matrix3x3 result;
+ Simd::Vec3::Mat3x3Multiply(GetSimdValues(), rhs.GetSimdValues(), result.GetSimdValues());
+ return result;
}
@@ -464,24 +457,34 @@ namespace AZ
}
- AZ_MATH_INLINE Matrix3x3& Matrix3x3::operator+=(const Matrix3x3& rhs)
+ AZ_MATH_INLINE Matrix3x3 Matrix3x3::operator*(float multiplier) const
{
- *this = *this + rhs;
- return *this;
+ 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-=(const Matrix3x3& rhs)
+ AZ_MATH_INLINE Matrix3x3& Matrix3x3::operator*=(float multiplier)
{
- *this = *this - rhs;
+ *this = *this * multiplier;
return *this;
}
- AZ_MATH_INLINE Matrix3x3& Matrix3x3::operator*=(float multiplier)
+ AZ_MATH_INLINE Matrix3x3 Matrix3x3::operator/(float divisor) const
{
- *this = *this * multiplier;
- return *this;
+ 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)
+ );
}
@@ -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 8773d4ea6a..a18f1e7565 100644
--- a/Code/Framework/AzCore/AzCore/Math/Matrix3x4.h
+++ b/Code/Framework/AzCore/AzCore/Math/Matrix3x4.h
@@ -225,11 +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 addition.
+ //! @{
+ [[nodiscard]] Matrix3x4 operator+(const Matrix3x4& rhs) const;
+ 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;
-
- //! Compound assignment operator for matrix-matrix multiplication.
Matrix3x4& operator*=(const Matrix3x4& rhs);
+ //! @}
+
+ //! Operator for multiplying all matrix's elements with a scalar
+ //! @{
+ [[nodiscard]] Matrix3x4 operator*(float multiplier) const;
+ Matrix3x4& operator*=(float multiplier);
+ //! @}
+
+ //! 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;
@@ -274,12 +301,18 @@ namespace AZ
//! Gets the scale part of the transformation (the length of the basis vectors).
[[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();
//! Multiplies the basis vectors of the matrix by the elements of the scale specified.
void MultiplyByScale(const Vector3& scale);
+ //! Returns a matrix with the reciprocal scale, keeping the same rotation and translation.
+ [[nodiscard]] Matrix3x4 GetReciprocalScaled() const;
+
//! Tests if the 3x3 part of the matrix is orthogonal.
bool IsOrthogonal(float tolerance = Constants::Tolerance) const;
@@ -335,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 bd310d293e..781dcf9b66 100644
--- a/Code/Framework/AzCore/AzCore/Math/Matrix3x4.inl
+++ b/Code/Framework/AzCore/AzCore/Math/Matrix3x4.inl
@@ -472,6 +472,42 @@ namespace AZ
}
+ AZ_MATH_INLINE Matrix3x4 Matrix3x4::operator+(const Matrix3x4& rhs) const
+ {
+ return Matrix3x4
+ (
+ 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())
+ );
+ }
+
+
+ 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
+ (
+ 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-=(const Matrix3x4& rhs)
+ {
+ *this = *this - rhs;
+ return *this;
+ }
+
+
AZ_MATH_INLINE Matrix3x4 Matrix3x4::operator*(const Matrix3x4& rhs) const
{
Matrix3x4 result;
@@ -487,6 +523,56 @@ namespace AZ
}
+ 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
@@ -583,6 +669,12 @@ namespace AZ
}
+ AZ_MATH_INLINE Vector3 Matrix3x4::RetrieveScaleSq() const
+ {
+ return Vector3(GetColumn(0).GetLengthSq(), GetColumn(1).GetLengthSq(), GetColumn(2).GetLengthSq());
+ }
+
+
AZ_MATH_INLINE Vector3 Matrix3x4::ExtractScale()
{
const Vector3 scale = RetrieveScale();
@@ -600,6 +692,14 @@ namespace AZ
}
+ AZ_MATH_INLINE Matrix3x4 Matrix3x4::GetReciprocalScaled() const
+ {
+ Matrix3x4 result = *this;
+ result.MultiplyByScale(RetrieveScaleSq().GetReciprocal());
+ return result;
+ }
+
+
AZ_MATH_INLINE void Matrix3x4::Orthogonalize()
{
*this = GetOrthogonalized();
@@ -660,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/RTTI/AzStdOnDemandReflection.inl b/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflection.inl
index ab92604266..079c70c878 100644
--- a/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflection.inl
+++ b/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflection.inl
@@ -816,7 +816,7 @@ namespace AZ
template
static void ReflectUnpackMethodFold(BehaviorContext::ClassBuilder& builder)
{
- AZStd::string methodName = AZStd::string::format("Get%ld", Index);
+ const AZStd::string methodName = AZStd::string::format("Get%zu", Index);
builder->Method(methodName.data(), [](ContainerType& value) { return AZStd::get(value); })
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
->Attribute(AZ::ScriptCanvasAttributes::TupleGetFunctionIndex, Index)
diff --git a/Code/Framework/AzCore/Tests/Asset/AssetManagerStreamingTests.cpp b/Code/Framework/AzCore/Tests/Asset/AssetManagerStreamingTests.cpp
index 807288ff82..c55a95cf2a 100644
--- a/Code/Framework/AzCore/Tests/Asset/AssetManagerStreamingTests.cpp
+++ b/Code/Framework/AzCore/Tests/Asset/AssetManagerStreamingTests.cpp
@@ -330,4 +330,163 @@ namespace UnitTest
}
}
-}
+ // The AssetManagerStreamerImmediateCompletionTests class adjusts the asset loading to force it to complete immediately,
+ // while still within the callstack for GetAsset(). This can be used to test various conditions in which the load thread
+ // completes more rapidly than expected, and can expose subtle race conditions.
+ // There are a few key things that this class does to make this work:
+ // - The file I/O streamer is mocked
+ // - The asset stream data is mocked to a 0-byte length for the asset so that the stream load will bypass the I/O streamer and
+ // just immediately return completion.
+ // - The number of JobManager threads is set to 0, forcing jobs to execute synchronously inline when they are started.
+ // With these changes, GetAssetInternal() will queue the stream, which will immediately call the callback that creates LoadAssetJob,
+ // which immediately executes in-place to process the asset due to the synchronous JobManager.
+ // Note that if we just created the asset in a Ready state, most of the asset loading code is completely bypassed, and so we
+ // wouldn't be able to test for race conditions in the AssetContainer.
+ //
+ // This class also unregisters the catalog and asset handler before shutting down the asset manager. This is done to catch
+ // any outstanding asset references that exist due to loads not completing and cleaning up successfully.
+ struct AssetManagerStreamerImmediateCompletionTests : public BaseAssetManagerTest,
+ public AZ::Data::AssetCatalogRequestBus::Handler,
+ public AZ::Data::AssetHandler,
+ public AZ::Data::AssetCatalog
+ {
+ static inline const AZ::Uuid TestAssetId{"{E970B177-5F45-44EB-A2C4-9F29D9A0B2A2}"};
+ static inline constexpr AZStd::string_view TestAssetPath = "test";
+
+ void SetUp() override
+ {
+ BaseAssetManagerTest::SetUp();
+ AssetManager::Descriptor desc;
+ AssetManager::Create(desc);
+
+ // Register the handler and catalog after creation, because we intend to destroy them before AssetManager destruction.
+ // The specific asset we load is irrelevant, so register EmptyAsset.
+ AZ::Data::AssetManager::Instance().RegisterHandler(this, AZ::AzTypeInfo::Uuid());
+ AZ::Data::AssetManager::Instance().RegisterCatalog(this, AZ::AzTypeInfo::Uuid());
+
+ // Intercept messages for finding assets by name so that we can mock out the asset we're loading.
+ AZ::Data::AssetCatalogRequestBus::Handler::BusConnect();
+ }
+
+ void TearDown() override
+ {
+ // Unregister before destroying AssetManager.
+ // This will catch any assets that got stuck in a loading state without getting cleaned up.
+ AZ::Data::AssetManager::Instance().UnregisterCatalog(this);
+ AZ::Data::AssetManager::Instance().UnregisterHandler(this);
+
+ AZ::Data::AssetCatalogRequestBus::Handler::BusDisconnect();
+
+ AssetManager::Destroy();
+ BaseAssetManagerTest::TearDown();
+ }
+
+ size_t GetNumJobManagerThreads() const override
+ {
+ // Return 0 threads so that the Job Manager executes jobs synchronously inline. This lets us finish a load while still
+ // in the callstack that initiates the load.
+ return 0;
+ }
+
+ // Create a mock streamer instead of a real one, since we don't really want to load an asset.
+ IO::IStreamer* CreateStreamer() override
+ {
+ m_mockStreamer = AZStd::make_unique();
+ return &(m_mockStreamer->m_mockStreamer);
+ }
+
+ void DestroyStreamer([[maybe_unused]] IO::IStreamer* streamer) override
+ {
+ m_mockStreamer = nullptr;
+ }
+
+ // AssetHandler implementation
+
+ // Minimalist mock to create a new EmptyAsset with the desired asset ID.
+ AZ::Data::AssetPtr CreateAsset(const AZ::Data::AssetId& id, [[maybe_unused]] const AZ::Data::AssetType& type) override
+ {
+ return new EmptyAsset(id);
+ }
+
+ void DestroyAsset(AZ::Data::AssetPtr ptr) override
+ {
+ delete ptr;
+ }
+
+ // The mocked-out Asset Catalog handles EmptyAsset types.
+ void GetHandledAssetTypes(AZStd::vector& assetTypes) override
+ {
+ assetTypes.push_back(AZ::AzTypeInfo::Uuid());
+ }
+
+ // This is a mocked-out load, so just immediately return completion without doing anything.
+ AZ::Data::AssetHandler::LoadResult LoadAssetData(
+ [[maybe_unused]] const AZ::Data::Asset& asset,
+ [[maybe_unused]] AZStd::shared_ptr stream,
+ [[maybe_unused]] const AZ::Data::AssetFilterCB& assetLoadFilterCB)
+ {
+ return AZ::Data::AssetHandler::LoadResult::LoadComplete;
+ }
+
+ // AssetCatalogRequestBus implementation
+
+ // Minimalist mocks to provide our desired asset path or asset id
+ AZStd::string GetAssetPathById([[maybe_unused]] const AZ::Data::AssetId& id) override
+ {
+ return TestAssetPath;
+ }
+ AZ::Data::AssetId GetAssetIdByPath(
+ [[maybe_unused]] const char* path, [[maybe_unused]] const AZ::Data::AssetType& typeToRegister,
+ [[maybe_unused]] bool autoRegisterIfNotFound) override
+ {
+ return TestAssetId;
+ }
+
+ // Return the mocked-out information for our test asset
+ AZ::Data::AssetInfo GetAssetInfoById([[maybe_unused]] const AZ::Data::AssetId& id) override
+ {
+ AZ::Data::AssetInfo assetInfo;
+ assetInfo.m_assetId = TestAssetId;
+ assetInfo.m_assetType = AZ::AzTypeInfo::Uuid();
+ assetInfo.m_relativePath = TestAssetPath;
+ return assetInfo;
+ }
+
+ // AssetCatalog implementation
+
+ // Set the mocked-out asset load to have a 0-byte length so that the load skips I/O and immediately returns success
+ AZ::Data::AssetStreamInfo GetStreamInfoForLoad(
+ [[maybe_unused]] const AZ::Data::AssetId& id, const AZ::Data::AssetType& type) override
+ {
+ EXPECT_TRUE(type == AZ::AzTypeInfo::Uuid());
+ AZ::Data::AssetStreamInfo info;
+ info.m_dataOffset = 0;
+ info.m_streamName = TestAssetPath;
+ info.m_dataLen = 0;
+ info.m_streamFlags = AZ::IO::OpenMode::ModeRead;
+
+ return info;
+ }
+
+ AZStd::unique_ptr m_mockStreamer;
+ };
+
+ // This test will verify that even if the asset loading stream/job returns immediately, all of the loading
+ // code works successfully. The test here is fairly simple - it just loads the asset and verifies that it
+ // loaded successfully. The bulk of the test is really in the setup class above, where the load is forced
+ // to complete immediately. Also, the true failure condition is caught in the setup class too, which is
+ // the presence of any assets at the point that the asset handler is unregistered. If they're present, then
+ // the immediate load wasn't truly successful, as it left around extra references to the asset that haven't
+ // been cleaned up.
+ TEST_F(AssetManagerStreamerImmediateCompletionTests, LoadAssetWithImmediateJobCompletion_WorksSuccessfully)
+ {
+ AZ::Data::AssetLoadParameters loadParams;
+
+ auto testAsset =
+ AssetManager::Instance().GetAsset(TestAssetId, AZ::Data::AssetLoadBehavior::Default, loadParams);
+
+ AZ::Data::AssetManager::Instance().DispatchEvents();
+ EXPECT_TRUE(testAsset.IsReady());
+ }
+
+} // namespace UnitTest
diff --git a/Code/Framework/AzCore/Tests/Asset/TestAssetTypes.h b/Code/Framework/AzCore/Tests/Asset/TestAssetTypes.h
index 83f3909676..d4267972ec 100644
--- a/Code/Framework/AzCore/Tests/Asset/TestAssetTypes.h
+++ b/Code/Framework/AzCore/Tests/Asset/TestAssetTypes.h
@@ -24,6 +24,13 @@ namespace UnitTest
public:
AZ_CLASS_ALLOCATOR(EmptyAsset, AZ::SystemAllocator, 0);
AZ_RTTI(EmptyAsset, "{098E3F7F-13AC-414B-9B4E-49B5AD1BD7FE}", AZ::Data::AssetData);
+
+ EmptyAsset(
+ const AZ::Data::AssetId& assetId = AZ::Data::AssetId(),
+ AZ::Data::AssetData::AssetStatus status = AZ::Data::AssetData::AssetStatus::NotLoaded)
+ : AZ::Data::AssetData(assetId, status)
+ {
+ }
};
// EmptyAssetWithNoHandler: no data contained within, and no AssetHandler registered for this type
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 f61b633fc2..0bb64411e6 100644
--- a/Code/Framework/AzCore/Tests/Math/Matrix3x4Tests.cpp
+++ b/Code/Framework/AzCore/Tests/Math/Matrix3x4Tests.cpp
@@ -467,21 +467,136 @@ namespace UnitTest
EXPECT_THAT(matrix.Multiply3x3(axisDirection), IsClose(forwardDirection));
}
- TEST(MATH_Matrix3x4, MultiplyByMatrix3x4)
- {
- 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));
+ TEST(MATH_Matrix3x4, TestMatrixMultiplication)
+ {
+ 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, TestSum)
+ {
+ 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, TestDifference)
+ {
+ 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)
@@ -652,6 +767,34 @@ namespace UnitTest
EXPECT_THAT(scaledMatrix.RetrieveScale(), IsClose(AZ::Vector3::CreateOne()));
}
+ TEST_P(Matrix3x4ScaleFixture, ScaleSq)
+ {
+ const AZ::Matrix3x4 orthogonalMatrix = GetParam();
+ EXPECT_THAT(orthogonalMatrix.RetrieveScaleSq(), IsClose(AZ::Vector3::CreateOne()));
+ AZ::Matrix3x4 unscaledMatrix = orthogonalMatrix;
+ unscaledMatrix.ExtractScale();
+ EXPECT_THAT(unscaledMatrix.RetrieveScaleSq(), IsClose(AZ::Vector3::CreateOne()));
+ const AZ::Vector3 scale(2.8f, 0.7f, 1.3f);
+ AZ::Matrix3x4 scaledMatrix = orthogonalMatrix;
+ scaledMatrix.MultiplyByScale(scale);
+ EXPECT_THAT(scaledMatrix.RetrieveScaleSq(), IsClose(scale * scale));
+ EXPECT_THAT(scaledMatrix.RetrieveScaleSq(), IsClose(scaledMatrix.RetrieveScale() * scaledMatrix.RetrieveScale()));
+ scaledMatrix.ExtractScale();
+ EXPECT_THAT(scaledMatrix.RetrieveScaleSq(), IsClose(AZ::Vector3::CreateOne()));
+ }
+
+ TEST_P(Matrix3x4ScaleFixture, GetReciprocalScaled)
+ {
+ const AZ::Matrix3x4 orthogonalMatrix = GetParam();
+ EXPECT_THAT(orthogonalMatrix.GetReciprocalScaled(), IsClose(orthogonalMatrix));
+ const AZ::Vector3 scale(2.8f, 0.7f, 1.3f);
+ AZ::Matrix3x4 scaledMatrix = orthogonalMatrix;
+ scaledMatrix.MultiplyByScale(scale);
+ AZ::Matrix3x4 reciprocalScaledMatrix = orthogonalMatrix;
+ reciprocalScaledMatrix.MultiplyByScale(scale.GetReciprocal());
+ EXPECT_THAT(scaledMatrix.GetReciprocalScaled(), IsClose(reciprocalScaledMatrix));
+ }
+
INSTANTIATE_TEST_CASE_P(MATH_Matrix3x4, Matrix3x4ScaleFixture, ::testing::ValuesIn(MathTestData::OrthogonalMatrix3x4s));
TEST(MATH_Matrix3x4, IsOrthogonal)
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/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/ProjectManager/ProjectManager.cpp b/Code/Framework/AzFramework/AzFramework/ProjectManager/ProjectManager.cpp
index ea8fd75cfd..985bc4665d 100644
--- a/Code/Framework/AzFramework/AzFramework/ProjectManager/ProjectManager.cpp
+++ b/Code/Framework/AzFramework/AzFramework/ProjectManager/ProjectManager.cpp
@@ -137,7 +137,7 @@ namespace AzFramework::ProjectManager
}
AZ::IO::FixedMaxPath pythonPath = engineRootPath / "python";
pythonPath /= AZ_TRAIT_AZFRAMEWORK_PYTHON_SHELL;
- auto cmdPath = AZ::IO::FixedMaxPathString::format("%s %s%s --executable_path=%s --parent_pid=%" PRId64, pythonPath.Native().c_str(),
+ auto cmdPath = AZ::IO::FixedMaxPathString::format("%s %s%s --executable_path=%s --parent_pid=%" PRIu32, pythonPath.Native().c_str(),
debugOption.c_str(), (projectManagerPath / projectsScript).c_str(), executablePath.c_str(), AZ::Platform::GetCurrentProcessId());
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
diff --git a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp
index ee49a95b23..e9dace3433 100644
--- a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp
+++ b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp
@@ -12,14 +12,150 @@
#include "CameraInput.h"
+#include
#include
#include
+#include
#include
#include
namespace AzFramework
{
- void CameraSystem::HandleEvents(const InputEvent& event)
+ AZ_CVAR(
+ float, ed_cameraSystemDefaultPlaneHeight, 34.0f, nullptr, AZ::ConsoleFunctorFlags::Null,
+ "The default height of the ground plane to do intersection tests against when orbiting");
+ AZ_CVAR(float, ed_cameraSystemBoostMultiplier, 3.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(float, ed_cameraSystemTranslateSpeed, 10.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(float, ed_cameraSystemOrbitDollyScrollSpeed, 0.02f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(float, ed_cameraSystemOrbitDollyCursorSpeed, 0.01f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(float, ed_cameraSystemScrollTranslateSpeed, 0.02f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(float, ed_cameraSystemDefaultOrbitDistance, 60.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(float, ed_cameraSystemMaxOrbitDistance, 100.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(float, ed_cameraSystemLookSmoothness, 5.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(float, ed_cameraSystemTranslateSmoothness, 5.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(float, ed_cameraSystemRotateSpeed, 0.005f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(float, ed_cameraSystemPanSpeed, 0.01f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(bool, ed_cameraSystemPanInvertX, true, nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(bool, ed_cameraSystemPanInvertY, true, nullptr, AZ::ConsoleFunctorFlags::Null, "");
+
+ AZ_CVAR(
+ AZ::CVarFixedString, ed_cameraSystemTranslateForwardKey, "keyboard_key_alphanumeric_W", nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(
+ AZ::CVarFixedString, ed_cameraSystemTranslateBackwardKey, "keyboard_key_alphanumeric_S", nullptr, AZ::ConsoleFunctorFlags::Null,
+ "");
+ AZ_CVAR(
+ AZ::CVarFixedString, ed_cameraSystemTranslateLeftKey, "keyboard_key_alphanumeric_A", nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(
+ AZ::CVarFixedString, ed_cameraSystemTranslateRightKey, "keyboard_key_alphanumeric_D", nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(AZ::CVarFixedString, ed_cameraSystemTranslateUpKey, "keyboard_key_alphanumeric_E", nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(
+ AZ::CVarFixedString, ed_cameraSystemTranslateDownKey, "keyboard_key_alphanumeric_Q", nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(
+ AZ::CVarFixedString, ed_cameraSystemTranslateBoostKey, "keyboard_key_modifier_shift_l", nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(AZ::CVarFixedString, ed_cameraSystemOrbitKey, "keyboard_key_modifier_alt_l", nullptr, AZ::ConsoleFunctorFlags::Null, "");
+
+ AZ_CVAR(AZ::CVarFixedString, ed_cameraSystemFreeLookButton, "mouse_button_right", nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(AZ::CVarFixedString, ed_cameraSystemFreePanButton, "mouse_button_middle", nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(AZ::CVarFixedString, ed_cameraSystemOrbitLookButton, "mouse_button_left", nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(AZ::CVarFixedString, ed_cameraSystemOrbitDollyButton, "mouse_button_right", nullptr, AZ::ConsoleFunctorFlags::Null, "");
+ AZ_CVAR(AZ::CVarFixedString, ed_cameraSystemOrbitPanButton, "mouse_button_middle", nullptr, AZ::ConsoleFunctorFlags::Null, "");
+
+ static InputChannelId CameraTranslateForwardId;
+ static InputChannelId CameraTranslateBackwardId;
+ static InputChannelId CameraTranslateLeftId;
+ static InputChannelId CameraTranslateRightId;
+ static InputChannelId CameraTranslateDownId;
+ static InputChannelId CameraTranslateUpId;
+ static InputChannelId CameraTranslateBoostId;
+ static InputChannelId CameraOrbitId;
+
+ // externed elsewhere
+ InputChannelId CameraFreeLookButton;
+ InputChannelId CameraFreePanButton;
+ InputChannelId CameraOrbitLookButton;
+ InputChannelId CameraOrbitDollyButton;
+ InputChannelId CameraOrbitPanButton;
+
+ void ReloadCameraKeyBindings()
+ {
+ const AZ::CVarFixedString& forward = ed_cameraSystemTranslateForwardKey;
+ CameraTranslateForwardId = InputChannelId(forward.c_str());
+ const AZ::CVarFixedString& backward = ed_cameraSystemTranslateBackwardKey;
+ CameraTranslateBackwardId = InputChannelId(backward.c_str());
+ const AZ::CVarFixedString& left = ed_cameraSystemTranslateLeftKey;
+ CameraTranslateLeftId = InputChannelId(left.c_str());
+ const AZ::CVarFixedString& right = ed_cameraSystemTranslateRightKey;
+ CameraTranslateRightId = InputChannelId(right.c_str());
+ const AZ::CVarFixedString& down = ed_cameraSystemTranslateDownKey;
+ CameraTranslateDownId = InputChannelId(down.c_str());
+ const AZ::CVarFixedString& up = ed_cameraSystemTranslateUpKey;
+ CameraTranslateUpId = InputChannelId(up.c_str());
+ const AZ::CVarFixedString& boost = ed_cameraSystemTranslateBoostKey;
+ CameraTranslateBoostId = InputChannelId(boost.c_str());
+ const AZ::CVarFixedString& orbit = ed_cameraSystemOrbitKey;
+ CameraOrbitId = InputChannelId(orbit.c_str());
+ const AZ::CVarFixedString& freeLook = ed_cameraSystemFreeLookButton;
+ CameraFreeLookButton = InputChannelId(freeLook.c_str());
+ const AZ::CVarFixedString& freePan = ed_cameraSystemFreePanButton;
+ CameraFreePanButton = InputChannelId(freePan.c_str());
+ const AZ::CVarFixedString& orbitLook = ed_cameraSystemOrbitLookButton;
+ CameraOrbitLookButton = InputChannelId(orbitLook.c_str());
+ const AZ::CVarFixedString& orbitDolly = ed_cameraSystemOrbitDollyButton;
+ CameraOrbitDollyButton = InputChannelId(orbitDolly.c_str());
+ const AZ::CVarFixedString& orbitPan = ed_cameraSystemOrbitPanButton;
+ CameraOrbitPanButton = InputChannelId(orbitPan.c_str());
+ }
+
+ static void ReloadCameraKeyBindingsConsole(const AZ::ConsoleCommandContainer&)
+ {
+ ReloadCameraKeyBindings();
+ }
+
+ AZ_CONSOLEFREEFUNC(ReloadCameraKeyBindingsConsole, AZ::ConsoleFunctorFlags::Null, "Reload keybindings for the modern camera system");
+
+ // Based on paper by David Eberly - https://www.geometrictools.com/Documentation/EulerAngles.pdf
+ AZ::Vector3 EulerAngles(const AZ::Matrix3x3& orientation)
+ {
+ float x;
+ float y;
+ float z;
+
+ // 2.4 Factor as RzRyRx
+ if (orientation.GetElement(2, 0) < 1.0f)
+ {
+ if (orientation.GetElement(2, 0) > -1.0f)
+ {
+ x = std::atan2(orientation.GetElement(2, 1), orientation.GetElement(2, 2));
+ y = std::asin(-orientation.GetElement(2, 0));
+ z = std::atan2(orientation.GetElement(1, 0), orientation.GetElement(0, 0));
+ }
+ else
+ {
+ x = 0.0f;
+ y = AZ::Constants::Pi * 0.5f;
+ z = -std::atan2(-orientation.GetElement(2, 1), orientation.GetElement(1, 1));
+ }
+ }
+ else
+ {
+ x = 0.0f;
+ y = -AZ::Constants::Pi * 0.5f;
+ z = std::atan2(-orientation.GetElement(1, 2), orientation.GetElement(1, 1));
+ }
+
+ return {x, y, z};
+ }
+
+ void UpdateCameraFromTransform(Camera& camera, const AZ::Transform& transform)
+ {
+ const auto eulerAngles = AzFramework::EulerAngles(AZ::Matrix3x3::CreateFromTransform(transform));
+
+ camera.m_lookAt = transform.GetTranslation();
+ camera.m_pitch = eulerAngles.GetX();
+ camera.m_yaw = eulerAngles.GetZ();
+ }
+
+ bool CameraSystem::HandleEvents(const InputEvent& event)
{
if (const auto& cursor_motion = AZStd::get_if(&event))
{
@@ -30,10 +166,10 @@ namespace AzFramework
m_scrollDelta = scroll->m_delta;
}
- m_cameras.HandleEvents(event);
+ return m_cameras.HandleEvents(event);
}
- Camera CameraSystem::StepCamera(const Camera& targetCamera, float deltaTime)
+ Camera CameraSystem::StepCamera(const Camera& targetCamera, const float deltaTime)
{
const auto cursorDelta = m_currentCursorPosition.has_value() && m_lastCursorPosition.has_value()
? m_currentCursorPosition.value() - m_lastCursorPosition.value()
@@ -51,36 +187,41 @@ namespace AzFramework
return nextCamera;
}
- void Cameras::AddCamera(AZStd::shared_ptr camera_input)
+ void Cameras::AddCamera(AZStd::shared_ptr cameraInput)
{
- m_idleCameraInputs.push_back(AZStd::move(camera_input));
+ m_idleCameraInputs.push_back(AZStd::move(cameraInput));
}
- void Cameras::HandleEvents(const InputEvent& event)
+ bool Cameras::HandleEvents(const InputEvent& event)
{
- for (auto& camera_input : m_activeCameraInputs)
+ bool handling = false;
+ for (auto& cameraInput : m_activeCameraInputs)
{
- camera_input->HandleEvents(event);
+ cameraInput->HandleEvents(event);
+ handling = !cameraInput->Idle() || handling;
}
- for (auto& camera_input : m_idleCameraInputs)
+ for (auto& cameraInput : m_idleCameraInputs)
{
- camera_input->HandleEvents(event);
+ cameraInput->HandleEvents(event);
}
+
+ return handling;
}
- Camera Cameras::StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, const float deltaTime)
+ Camera Cameras::StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, const float scrollDelta, const float deltaTime)
{
for (int i = 0; i < m_idleCameraInputs.size();)
{
- auto& camera_input = m_idleCameraInputs[i];
- const bool can_begin = camera_input->Beginning() &&
+ auto& cameraInput = m_idleCameraInputs[i];
+ const bool canBegin = cameraInput->Beginning() &&
std::all_of(m_activeCameraInputs.cbegin(), m_activeCameraInputs.cend(),
[](const auto& input) { return !input->Exclusive(); }) &&
- (!camera_input->Exclusive() || (camera_input->Exclusive() && m_activeCameraInputs.empty()));
- if (can_begin)
+ (!cameraInput->Exclusive() || (cameraInput->Exclusive() && m_activeCameraInputs.empty()));
+
+ if (canBegin)
{
- m_activeCameraInputs.push_back(camera_input);
+ m_activeCameraInputs.push_back(cameraInput);
using AZStd::swap;
swap(m_idleCameraInputs[i], m_idleCameraInputs[m_idleCameraInputs.size() - 1]);
m_idleCameraInputs.pop_back();
@@ -93,25 +234,25 @@ namespace AzFramework
// accumulate
Camera nextCamera = targetCamera;
- for (auto& camera_input : m_activeCameraInputs)
+ for (auto& cameraInput : m_activeCameraInputs)
{
- nextCamera = camera_input->StepCamera(nextCamera, cursorDelta, scrollDelta, deltaTime);
+ nextCamera = cameraInput->StepCamera(nextCamera, cursorDelta, scrollDelta, deltaTime);
}
for (int i = 0; i < m_activeCameraInputs.size();)
{
- auto& camera_input = m_activeCameraInputs[i];
- if (camera_input->Ending())
+ auto& cameraInput = m_activeCameraInputs[i];
+ if (cameraInput->Ending())
{
- camera_input->ClearActivation();
- m_idleCameraInputs.push_back(camera_input);
+ cameraInput->ClearActivation();
+ m_idleCameraInputs.push_back(cameraInput);
using AZStd::swap;
swap(m_activeCameraInputs[i], m_activeCameraInputs[m_activeCameraInputs.size() - 1]);
m_activeCameraInputs.pop_back();
}
else
{
- camera_input->ContinueActivation();
+ cameraInput->ContinueActivation();
i++;
}
}
@@ -134,7 +275,7 @@ namespace AzFramework
{
if (const auto& input = AZStd::get_if(&event))
{
- if (input->m_channelId == m_channelId)
+ if (input->m_channelId == m_rotateChannelId)
{
if (input->m_state == InputChannel::State::Began)
{
@@ -154,14 +295,14 @@ namespace AzFramework
{
Camera nextCamera = targetCamera;
- nextCamera.m_pitch += float(cursorDelta.m_y) * m_props.m_rotateSpeed;
- nextCamera.m_yaw += float(cursorDelta.m_x) * m_props.m_rotateSpeed;
+ nextCamera.m_pitch -= float(cursorDelta.m_y) * ed_cameraSystemRotateSpeed;
+ nextCamera.m_yaw -= float(cursorDelta.m_x) * ed_cameraSystemRotateSpeed;
- auto clamp_rotation = [](const float angle) { return std::fmod(angle + AZ::Constants::TwoOverPi, AZ::Constants::TwoOverPi); };
+ const auto clampRotation = [](const float angle) { return std::fmod(angle + AZ::Constants::TwoPi, AZ::Constants::TwoPi); };
- nextCamera.m_yaw = clamp_rotation(nextCamera.m_yaw);
+ nextCamera.m_yaw = clampRotation(nextCamera.m_yaw);
// clamp pitch to be +-90 degrees
- nextCamera.m_pitch = AZ::GetClamp(nextCamera.m_pitch, -AZ::Constants::Pi * 0.5f, AZ::Constants::Pi * 0.5f);
+ nextCamera.m_pitch = AZ::GetClamp(nextCamera.m_pitch, -AZ::Constants::HalfPi, AZ::Constants::HalfPi);
return nextCamera;
}
@@ -170,7 +311,7 @@ namespace AzFramework
{
if (const auto& input = AZStd::get_if(&event))
{
- if (input->m_channelId == InputDeviceMouse::Button::Middle)
+ if (input->m_channelId == m_panChannelId)
{
if (input->m_state == InputChannel::State::Began)
{
@@ -190,51 +331,50 @@ namespace AzFramework
{
Camera nextCamera = targetCamera;
- const auto pan_axes = m_panAxesFn(nextCamera);
+ const auto panAxes = m_panAxesFn(nextCamera);
- const auto delta_pan_x = float(cursorDelta.m_x) * pan_axes.m_horizontalAxis * m_props.m_panSpeed;
- const auto delta_pan_y = float(cursorDelta.m_y) * pan_axes.m_verticalAxis * m_props.m_panSpeed;
+ const auto deltaPanX = float(cursorDelta.m_x) * panAxes.m_horizontalAxis * ed_cameraSystemPanSpeed;
+ const auto deltaPanY = float(cursorDelta.m_y) * panAxes.m_verticalAxis * ed_cameraSystemPanSpeed;
const auto inv = [](const bool invert) {
constexpr float Dir[] = {1.0f, -1.0f};
return Dir[static_cast(invert)];
};
- nextCamera.m_lookAt += delta_pan_x * inv(m_props.m_panInvertX);
- nextCamera.m_lookAt += delta_pan_y * -inv(m_props.m_panInvertY);
+ nextCamera.m_lookAt += deltaPanX * inv(ed_cameraSystemPanInvertX);
+ nextCamera.m_lookAt += deltaPanY * -inv(ed_cameraSystemPanInvertY);
return nextCamera;
}
TranslateCameraInput::TranslationType TranslateCameraInput::translationFromKey(InputChannelId channelId)
{
- // note: remove hard-coded InputDevice keys
- if (channelId == InputDeviceKeyboard::Key::AlphanumericW)
+ if (channelId == CameraTranslateForwardId)
{
return TranslationType::Forward;
}
- if (channelId == InputDeviceKeyboard::Key::AlphanumericS)
+ if (channelId == CameraTranslateBackwardId)
{
return TranslationType::Backward;
}
- if (channelId == InputDeviceKeyboard::Key::AlphanumericA)
+ if (channelId == CameraTranslateLeftId)
{
return TranslationType::Left;
}
- if (channelId == InputDeviceKeyboard::Key::AlphanumericD)
+ if (channelId == CameraTranslateRightId)
{
return TranslationType::Right;
}
- if (channelId == InputDeviceKeyboard::Key::AlphanumericQ)
+ if (channelId == CameraTranslateDownId)
{
return TranslationType::Down;
}
- if (channelId == InputDeviceKeyboard::Key::AlphanumericE)
+ if (channelId == CameraTranslateUpId)
{
return TranslationType::Up;
}
@@ -259,19 +399,19 @@ namespace AzFramework
BeginActivation();
}
- if (input->m_channelId == InputDeviceKeyboard::Key::ModifierShiftL)
+ if (input->m_channelId == CameraTranslateBoostId)
{
m_boost = true;
}
}
else if (input->m_state == InputChannel::State::Ended)
{
- m_translation ^= translationFromKey(input->m_channelId);
+ m_translation &= ~(translationFromKey(input->m_channelId));
if (m_translation == TranslationType::Nil)
{
EndActivation();
}
- if (input->m_channelId == InputDeviceKeyboard::Key::ModifierShiftL)
+ if (input->m_channelId == CameraTranslateBoostId)
{
m_boost = false;
}
@@ -285,13 +425,13 @@ namespace AzFramework
{
Camera nextCamera = targetCamera;
- const auto translation_basis = m_translationAxesFn(nextCamera);
- const auto axisX = translation_basis.GetBasisX();
- const auto axisY = translation_basis.GetBasisY();
- const auto axisZ = translation_basis.GetBasisZ();
+ const auto translationBasis = m_translationAxesFn(nextCamera);
+ const auto axisX = translationBasis.GetBasisX();
+ const auto axisY = translationBasis.GetBasisY();
+ const auto axisZ = translationBasis.GetBasisZ();
- const float speed = [boost = m_boost, props = m_props]() {
- return props.m_translateSpeed * (boost ? props.m_boostMultiplier : 1.0f);
+ const float speed = [boost = m_boost]() {
+ return ed_cameraSystemTranslateSpeed * (boost ? ed_cameraSystemBoostMultiplier : 1.0f);
}();
if ((m_translation & TranslationType::Forward) == TranslationType::Forward)
@@ -342,12 +482,8 @@ namespace AzFramework
{
if (const auto* input = AZStd::get_if(&event))
{
- if (input->m_channelId == InputDeviceKeyboard::Key::ModifierAltL)
+ if (input->m_channelId == CameraOrbitId)
{
- if (input->m_state == InputChannel::State::Updated)
- {
- goto end;
- }
if (input->m_state == InputChannel::State::Began)
{
BeginActivation();
@@ -358,7 +494,7 @@ namespace AzFramework
}
}
}
- end:
+
if (Active())
{
m_orbitCameras.HandleEvents(event);
@@ -366,29 +502,29 @@ namespace AzFramework
}
Camera OrbitCameraInput::StepCamera(
- const Camera& targetCamera, const ScreenVector& cursorDelta, const float scrollDelta, float deltaTime)
+ const Camera& targetCamera, const ScreenVector& cursorDelta, const float scrollDelta, const float deltaTime)
{
Camera nextCamera = targetCamera;
if (Beginning())
{
float hit_distance = 0.0f;
- if (AZ::Plane::CreateFromNormalAndPoint(AZ::Vector3::CreateAxisZ(), AZ::Vector3::CreateZero())
- .CastRay(targetCamera.Translation(), targetCamera.Rotation().GetBasisY() * m_props.m_maxOrbitDistance, hit_distance))
+ if (AZ::Plane::CreateFromNormalAndPoint(AZ::Vector3::CreateAxisZ(), AZ::Vector3::CreateAxisZ(ed_cameraSystemDefaultPlaneHeight))
+ .CastRay(targetCamera.Translation(), targetCamera.Rotation().GetBasisY(), hit_distance))
{
+ hit_distance = AZStd::min(hit_distance, ed_cameraSystemMaxOrbitDistance);
nextCamera.m_lookDist = -hit_distance;
nextCamera.m_lookAt = targetCamera.Translation() + targetCamera.Rotation().GetBasisY() * hit_distance;
}
else
{
- nextCamera.m_lookDist = -m_props.m_defaultOrbitDistance;
- nextCamera.m_lookAt = targetCamera.Translation() + targetCamera.Rotation().GetBasisY() * m_props.m_defaultOrbitDistance;
+ nextCamera.m_lookDist = -ed_cameraSystemMaxOrbitDistance;
+ nextCamera.m_lookAt = targetCamera.Translation() + targetCamera.Rotation().GetBasisY() * ed_cameraSystemMaxOrbitDistance;
}
}
if (Active())
{
- // todo: need to return nested cameras to idle state when ending
nextCamera = m_orbitCameras.StepCamera(nextCamera, cursorDelta, scrollDelta, deltaTime);
}
@@ -413,10 +549,10 @@ namespace AzFramework
Camera OrbitDollyScrollCameraInput::StepCamera(
const Camera& targetCamera, [[maybe_unused]] const ScreenVector& cursorDelta, const float scrollDelta,
- [[maybe_unused]] float deltaTime)
+ [[maybe_unused]] const float deltaTime)
{
Camera nextCamera = targetCamera;
- nextCamera.m_lookDist = AZ::GetMin(nextCamera.m_lookDist + scrollDelta * m_props.m_dollySpeed, 0.0f);
+ nextCamera.m_lookDist = AZ::GetMin(nextCamera.m_lookDist + scrollDelta * ed_cameraSystemOrbitDollyScrollSpeed, 0.0f);
EndActivation();
return nextCamera;
}
@@ -425,7 +561,7 @@ namespace AzFramework
{
if (const auto& input = AZStd::get_if(&event))
{
- if (input->m_channelId == InputDeviceMouse::Button::Right)
+ if (input->m_channelId == m_dollyChannelId)
{
if (input->m_state == InputChannel::State::Began)
{
@@ -444,7 +580,7 @@ namespace AzFramework
[[maybe_unused]] const float deltaTime)
{
Camera nextCamera = targetCamera;
- nextCamera.m_lookDist = AZ::GetMin(nextCamera.m_lookDist + float(cursorDelta.m_y) * m_props.m_dollySpeed, 0.0f);
+ nextCamera.m_lookDist = AZ::GetMin(nextCamera.m_lookDist + float(cursorDelta.m_y) * ed_cameraSystemOrbitDollyCursorSpeed, 0.0f);
return nextCamera;
}
@@ -457,7 +593,7 @@ namespace AzFramework
}
Camera ScrollTranslationCameraInput::StepCamera(
- const Camera& targetCamera, [[maybe_unused]] const ScreenVector& cursorDelta, float scrollDelta,
+ const Camera& targetCamera, [[maybe_unused]] const ScreenVector& cursorDelta, const float scrollDelta,
[[maybe_unused]] const float deltaTime)
{
Camera nextCamera = targetCamera;
@@ -465,38 +601,39 @@ namespace AzFramework
const auto translation_basis = LookTranslation(nextCamera);
const auto axisY = translation_basis.GetBasisY();
- nextCamera.m_lookAt += axisY * scrollDelta * m_props.m_translateSpeed;
+ nextCamera.m_lookAt += axisY * scrollDelta * ed_cameraSystemScrollTranslateSpeed;
EndActivation();
return nextCamera;
}
- Camera SmoothCamera(const Camera& currentCamera, const Camera& targetCamera, const SmoothProps& props, const float deltaTime)
+ Camera SmoothCamera(const Camera& currentCamera, const Camera& targetCamera, const float deltaTime)
{
const auto clamp_rotation = [](const float angle) { return std::fmod(angle + AZ::Constants::TwoPi, AZ::Constants::TwoPi); };
// keep yaw in 0 - 360 range
- float target_yaw = clamp_rotation(targetCamera.m_yaw);
- const float current_yaw = clamp_rotation(currentCamera.m_yaw);
+ float targetYaw = clamp_rotation(targetCamera.m_yaw);
+ const float currentYaw = clamp_rotation(currentCamera.m_yaw);
- auto sign = [](const float value) { return static_cast((0.0f < value) - (value < 0.0f)); };
+ // return the sign of the float input (-1, 0, 1)
+ const auto sign = [](const float value) { return aznumeric_cast((0.0f < value) - (value < 0.0f)); };
// ensure smooth transition when moving across 0 - 360 boundary
- const float yaw_delta = target_yaw - current_yaw;
- if (std::abs(yaw_delta) >= AZ::Constants::Pi)
+ const float yawDelta = targetYaw - currentYaw;
+ if (std::abs(yawDelta) >= AZ::Constants::Pi)
{
- target_yaw -= AZ::Constants::TwoPi * sign(yaw_delta);
+ targetYaw -= AZ::Constants::TwoPi * sign(yawDelta);
}
Camera camera;
- // note: the math for the lerp smoothing implementation for camera rotation and translation was inspired by this excellent
+ // note: the math for the lerp smoothing implementation for camera rotation and translation was inspired by this excellent
// article by Scott Lembcke: https://www.gamasutra.com/blogs/ScottLembcke/20180404/316046/Improved_Lerp_Smoothing.php
- const float lookRate = std::exp2(props.m_lookSmoothness);
+ const float lookRate = std::exp2(ed_cameraSystemLookSmoothness);
const float lookT = std::exp2(-lookRate * deltaTime);
camera.m_pitch = AZ::Lerp(targetCamera.m_pitch, currentCamera.m_pitch, lookT);
- camera.m_yaw = AZ::Lerp(target_yaw, current_yaw, lookT);
- const float moveRate = std::exp2(props.m_moveSmoothness);
+ camera.m_yaw = AZ::Lerp(targetYaw, currentYaw, lookT);
+ const float moveRate = std::exp2(ed_cameraSystemTranslateSmoothness);
const float moveT = std::exp2(-moveRate * deltaTime);
camera.m_lookDist = AZ::Lerp(targetCamera.m_lookDist, currentCamera.m_lookDist, moveT);
camera.m_lookAt = targetCamera.m_lookAt.Lerp(currentCamera.m_lookAt, moveT);
@@ -508,20 +645,24 @@ namespace AzFramework
const auto& inputChannelId = inputChannel.GetInputChannelId();
const auto& inputDeviceId = inputChannel.GetInputDevice().GetInputDeviceId();
- if (inputChannelId == InputDeviceMouse::SystemCursorPosition)
+ const bool wasMouseButton =
+ AZStd::any_of(InputDeviceMouse::Button::All.begin(), InputDeviceMouse::Button::All.end(), [inputChannelId](const auto& button) {
+ return button == inputChannelId;
+ });
+
+ if (inputChannelId == InputDeviceMouse::Movement::X || inputChannelId == InputDeviceMouse::Movement::Y)
{
- AZ::Vector2 systemCursorPositionNormalized = AZ::Vector2::CreateZero();
- InputSystemCursorRequestBus::EventResult(
- systemCursorPositionNormalized, inputDeviceId, &InputSystemCursorRequestBus::Events::GetSystemCursorPositionNormalized);
+ const auto* position = inputChannel.GetCustomData();
+ AZ_Assert(position, "Expected PositionData2D but found nullptr");
return CursorMotionEvent{ScreenPoint(
- systemCursorPositionNormalized.GetX() * windowSize.m_width, systemCursorPositionNormalized.GetY() * windowSize.m_height)};
+ position->m_normalizedPosition.GetX() * windowSize.m_width, position->m_normalizedPosition.GetY() * windowSize.m_height)};
}
else if (inputChannelId == InputDeviceMouse::Movement::Z)
{
return ScrollEvent{inputChannel.GetValue()};
}
- else if (InputDeviceMouse::IsMouseDevice(inputDeviceId) || InputDeviceKeyboard::IsKeyboardDevice(inputDeviceId))
+ else if (wasMouseButton || InputDeviceKeyboard::IsKeyboardDevice(inputDeviceId))
{
return DiscreteInputEvent{inputChannelId, inputChannel.GetState()};
}
diff --git a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h
index 736e2404d9..6ccd7c43eb 100644
--- a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h
+++ b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h
@@ -17,13 +17,16 @@
#include
#include
#include
-#include
-#include
#include
+#include
namespace AzFramework
{
- struct WindowSize;
+ //! Update camera key bindings that can be overridden with AZ console vars (invoke from console to update)
+ void ReloadCameraKeyBindings();
+
+ //! Return Euler angles (pitch, roll, yaw) for the incoming orientation.
+ AZ::Vector3 EulerAngles(const AZ::Matrix3x3& orientation);
struct Camera
{
@@ -51,8 +54,8 @@ namespace AzFramework
inline AZ::Transform Camera::Transform() const
{
- return AZ::Transform::CreateTranslation(m_lookAt) * AZ::Transform::CreateRotationX(m_pitch) *
- AZ::Transform::CreateRotationZ(m_yaw) * AZ::Transform::CreateTranslation(AZ::Vector3::CreateAxisZ(m_lookDist));
+ return AZ::Transform::CreateTranslation(m_lookAt) * AZ::Transform::CreateRotationZ(m_yaw) *
+ AZ::Transform::CreateRotationX(m_pitch) * AZ::Transform::CreateTranslation(AZ::Vector3::CreateAxisY(m_lookDist));
}
inline AZ::Matrix3x3 Camera::Rotation() const
@@ -65,6 +68,8 @@ namespace AzFramework
return Transform().GetTranslation();
}
+ void UpdateCameraFromTransform(Camera& camera, const AZ::Transform& transform);
+
struct CursorMotionEvent
{
ScreenPoint m_position;
@@ -159,19 +164,13 @@ namespace AzFramework
Activation m_activation = Activation::Idle;
};
- struct SmoothProps
- {
- float m_lookSmoothness = 5.0f;
- float m_moveSmoothness = 5.0f;
- };
-
- Camera SmoothCamera(const Camera& currentCamera, const Camera& targetCamera, const SmoothProps& props, float deltaTime);
+ Camera SmoothCamera(const Camera& currentCamera, const Camera& targetCamera, float deltaTime);
class Cameras
{
public:
void AddCamera(AZStd::shared_ptr cameraInput);
- void HandleEvents(const InputEvent& event);
+ bool HandleEvents(const InputEvent& event);
Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime);
void Reset();
@@ -183,7 +182,7 @@ namespace AzFramework
class CameraSystem
{
public:
- void HandleEvents(const InputEvent& event);
+ bool HandleEvents(const InputEvent& event);
Camera StepCamera(const Camera& targetCamera, float deltaTime);
Cameras m_cameras;
@@ -197,19 +196,16 @@ namespace AzFramework
class RotateCameraInput : public CameraInput
{
public:
- explicit RotateCameraInput(const InputChannelId channelId)
- : m_channelId(channelId)
+ explicit RotateCameraInput(const InputChannelId rotateChannelId)
+ : m_rotateChannelId(rotateChannelId)
{
}
+
void HandleEvents(const InputEvent& event) override;
Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override;
- InputChannelId m_channelId;
-
- struct Props
- {
- float m_rotateSpeed = 0.005f;
- } m_props;
+ private:
+ InputChannelId m_rotateChannelId;
};
struct PanAxes
@@ -242,22 +238,17 @@ namespace AzFramework
class PanCameraInput : public CameraInput
{
public:
- explicit PanCameraInput(PanAxesFn panAxesFn)
+ PanCameraInput(const InputChannelId panChannelId, PanAxesFn panAxesFn)
: m_panAxesFn(AZStd::move(panAxesFn))
+ , m_panChannelId(panChannelId)
{
}
void HandleEvents(const InputEvent& event) override;
Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override;
- struct Props
- {
- float m_panSpeed = 0.01f;
- bool m_panInvertX = true;
- bool m_panInvertY = true;
- } m_props;
-
private:
PanAxesFn m_panAxesFn;
+ InputChannelId m_panChannelId;
};
using TranslationAxesFn = AZStd::function;
@@ -298,17 +289,11 @@ namespace AzFramework
Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override;
void ResetImpl() override;
- struct Props
- {
- float m_translateSpeed = 10.0f;
- float m_boostMultiplier = 3.0f;
- } m_props;
-
private:
enum class TranslationType
{
// clang-format off
- Nil = 0,
+ Nil = 0,
Forward = 1 << 0,
Backward = 1 << 1,
Left = 1 << 2,
@@ -354,6 +339,11 @@ namespace AzFramework
return lhs;
}
+ friend TranslationType operator~(const TranslationType lhs)
+ {
+ return static_cast(~static_cast>(lhs));
+ }
+
static TranslationType translationFromKey(InputChannelId channelId);
TranslationType m_translation = TranslationType::Nil;
@@ -366,23 +356,19 @@ namespace AzFramework
public:
void HandleEvents(const InputEvent& event) override;
Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override;
-
- struct Props
- {
- float m_dollySpeed = 0.2f;
- } m_props;
};
class OrbitDollyCursorMoveCameraInput : public CameraInput
{
public:
+ explicit OrbitDollyCursorMoveCameraInput(const InputChannelId dollyChannelId)
+ : m_dollyChannelId(dollyChannelId) {}
+
void HandleEvents(const InputEvent& event) override;
Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override;
- struct Props
- {
- float m_dollySpeed = 0.1f;
- } m_props;
+ private:
+ InputChannelId m_dollyChannelId;
};
class ScrollTranslationCameraInput : public CameraInput
@@ -390,11 +376,6 @@ namespace AzFramework
public:
void HandleEvents(const InputEvent& event) override;
Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override;
-
- struct Props
- {
- float m_translateSpeed = 0.2f;
- } m_props;
};
class OrbitCameraInput : public CameraInput
@@ -408,13 +389,10 @@ namespace AzFramework
}
Cameras m_orbitCameras;
-
- struct Props
- {
- float m_defaultOrbitDistance = 15.0f;
- float m_maxOrbitDistance = 100.0f;
- } m_props;
};
+ struct WindowSize;
+
+ //! Map from a generic InputChannel event to a camera specific InputEvent.
InputEvent BuildInputEvent(const InputChannel& inputChannel, const WindowSize& windowSize);
} // 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/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/AssetBundle/AssetBundleComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBundle/AssetBundleComponent.cpp
index 61e144d338..95319d2e6b 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBundle/AssetBundleComponent.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBundle/AssetBundleComponent.cpp
@@ -17,7 +17,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -250,7 +250,7 @@ namespace AzToolsFramework
AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance();
AZ_Assert(fileIO != nullptr, "AZ::IO::FileIOBase must be ready for use.\n");
- AZStd::string bundleFilePath = assetBundleSettings.m_bundleFilePath;
+ AZ::IO::Path bundleFilePath = AZ::IO::Path(AZStd::string_view{ AZ::Utils::GetEnginePath() }) / assetBundleSettings.m_bundleFilePath;
AzFramework::PlatformId platformId = static_cast(AzFramework::PlatformHelper::GetPlatformIndexFromName(assetBundleSettings.m_platform.c_str()));
@@ -259,22 +259,13 @@ namespace AzToolsFramework
return false;
}
- const char* appRoot = nullptr;
- AzFramework::ApplicationRequests::Bus::BroadcastResult(appRoot, &AzFramework::ApplicationRequests::GetAppRoot);
-
- if (AzFramework::StringFunc::Path::IsRelative(bundleFilePath.c_str()))
- {
- AzFramework::StringFunc::Path::ConstructFull(appRoot, bundleFilePath.c_str(), bundleFilePath, true);
- }
-
AZ::u64 maxSizeInBytes = static_cast(assetBundleSettings.m_maxBundleSizeInMB * NumOfBytesInMB);
AZ::u64 assetCatalogFileSizeBuffer = static_cast(AssetCatalogFileSizeBufferPercentage * assetBundleSettings.m_maxBundleSizeInMB * NumOfBytesInMB) / 100;
AZ::u64 bundleSize = 0;
AZ::u64 totalFileSize = 0;
int bundleIndex = 0;
- AZStd::string bundleFullPath = bundleFilePath;
- AZStd::string tempBundleFilePath = bundleFullPath + "_temp";
+ AZStd::string tempBundleFilePath = bundleFilePath.Native() + "_temp";
AZStd::vector dependentBundleNames;
AZStd::vector levelDirs;
@@ -301,7 +292,7 @@ namespace AzToolsFramework
if (fileIO->Exists(bundleFilePath.c_str()))
{
// This will delete both the parent bundle as well as all the dependent bundles mentioned in the manifest file of the parent bundle.
- if (!DeleteBundleFiles(bundleFilePath))
+ if (!DeleteBundleFiles(bundleFilePath.Native()))
{
return false;
}
@@ -390,7 +381,7 @@ namespace AzToolsFramework
// we need to find a bundle which does not exist on disk;
bundleIndex++;
numOfTries--;
- dependentBundleFileName = CreateAssetBundleFileName(bundleFilePath, bundleIndex);
+ dependentBundleFileName = CreateAssetBundleFileName(bundleFilePath.Native(), bundleIndex);
AzFramework::StringFunc::Path::ReplaceFullName(tempBundleFilePath, (dependentBundleFileName + tempBundleFileSuffix).c_str());
} while (numOfTries && fileIO->Exists(tempBundleFilePath.c_str()));
@@ -463,15 +454,7 @@ namespace AzToolsFramework
AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance();
- AZStd::string assetFileInfoListPath = assetBundleSettings.m_assetFileInfoListPath;
-
- const char* appRoot = nullptr;
- AzFramework::ApplicationRequests::Bus::BroadcastResult(appRoot, &AzFramework::ApplicationRequests::GetAppRoot);
-
- if (AzFramework::StringFunc::Path::IsRelative(assetFileInfoListPath.c_str()))
- {
- AzFramework::StringFunc::Path::ConstructFull(appRoot, assetFileInfoListPath.c_str(), assetFileInfoListPath, true);
- }
+ AZ::IO::Path assetFileInfoListPath = AZ::IO::Path{ AZStd::string_view{AZ::Utils::GetEnginePath()} } / assetBundleSettings.m_assetFileInfoListPath;
if (!fileIO->Exists(assetFileInfoListPath.c_str()))
{
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AzToolsFrameworkModule.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AzToolsFrameworkModule.cpp
index e7037c8936..373787e7dd 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/AzToolsFrameworkModule.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AzToolsFrameworkModule.cpp
@@ -53,7 +53,6 @@
#include
#include
#include
-#include
#include
namespace AzToolsFramework
@@ -93,7 +92,6 @@ namespace AzToolsFramework
AzToolsFramework::SliceDependencyBrowserComponent::CreateDescriptor(),
AzToolsFramework::Thumbnailer::ThumbnailerComponent::CreateDescriptor(),
AzToolsFramework::AssetBrowser::AssetBrowserComponent::CreateDescriptor(),
- AzToolsFramework::MaterialBrowser::MaterialBrowserComponent::CreateDescriptor(),
AzToolsFramework::EditorInteractionSystemComponent::CreateDescriptor(),
AzToolsFramework::Components::EditorComponentAPIComponent::CreateDescriptor(),
AzToolsFramework::Components::EditorLevelComponentAPIComponent::CreateDescriptor(),
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/MaterialBrowser/MaterialBrowserBus.h b/Code/Framework/AzToolsFramework/AzToolsFramework/MaterialBrowser/MaterialBrowserBus.h
deleted file mode 100644
index b0d625b6e4..0000000000
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/MaterialBrowser/MaterialBrowserBus.h
+++ /dev/null
@@ -1,43 +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 AZ
-{
- namespace Data
- {
- struct AssetId;
- }
-}
-
-namespace AzToolsFramework
-{
- namespace MaterialBrowser
- {
- class MaterialBrowserRequests
- : public AZ::EBusTraits
- {
- public:
-
- // Only a single handler is allowed
- static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
-
- virtual bool HasRecord(const AZ::Data::AssetId& assetId) = 0;
- virtual bool IsMultiMaterial(const AZ::Data::AssetId& assetId) = 0;
- };
-
- using MaterialBrowserRequestBus = AZ::EBus;
- } // namespace MaterialBrowser
-} // namespace AzToolsFramework
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/MaterialBrowser/MaterialBrowserComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/MaterialBrowser/MaterialBrowserComponent.cpp
deleted file mode 100644
index f64d4af23d..0000000000
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/MaterialBrowser/MaterialBrowserComponent.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-* its licensors.
-*
-* For complete copyright and license terms please see the LICENSE at the root of this
-* distribution (the "License"). All use of this software is governed by the License,
-* or, if provided, by the license below or the license accompanying this file. Do not
-* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-*
-*/
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 4251: 'QBrush::d': class 'QScopedPointer' needs to have dll-interface to be used by clients of class 'QBrush'
-#include
-AZ_POP_DISABLE_WARNING
-
-namespace AzToolsFramework
-{
- namespace MaterialBrowser
- {
- MaterialBrowserComponent::MaterialBrowserComponent()
- {
- }
-
- void MaterialBrowserComponent::Activate()
- {
- using namespace Thumbnailer;
- using namespace AssetBrowser;
- const char* contextName = "MaterialBrowser";
- ThumbnailerRequestsBus::Broadcast(&ThumbnailerRequests::RegisterContext, contextName);
- ThumbnailerRequestsBus::Broadcast(&ThumbnailerRequests::RegisterThumbnailProvider, MAKE_TCACHE(FolderThumbnailCache), contextName);
- ThumbnailerRequestsBus::Broadcast(&ThumbnailerRequests::RegisterThumbnailProvider, MAKE_TCACHE(SourceThumbnailCache), contextName);
- ThumbnailerRequestsBus::Broadcast(&ThumbnailerRequests::RegisterThumbnailProvider, MAKE_TCACHE(MaterialThumbnailCache), contextName);
- ThumbnailerRequestsBus::Broadcast(&ThumbnailerRequests::RegisterThumbnailProvider, MAKE_TCACHE(SourceControlThumbnailCache), contextName);
- }
-
- void MaterialBrowserComponent::Deactivate()
- {
- }
-
- void MaterialBrowserComponent::Reflect(AZ::ReflectContext* context)
- {
- AZ::SerializeContext* serialize = azrtti_cast(context);
- if (serialize)
- {
- serialize->Class();
- }
- }
-
- void MaterialBrowserComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
- {
- required.push_back(AZ_CRC("ThumbnailerService", 0x65422b97));
- }
- } // namespace MaterialBrowser
-} // namespace AzToolsFramework
-
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/MaterialBrowser/MaterialBrowserComponent.h b/Code/Framework/AzToolsFramework/AzToolsFramework/MaterialBrowser/MaterialBrowserComponent.h
deleted file mode 100644
index 93a48cf22c..0000000000
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/MaterialBrowser/MaterialBrowserComponent.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-* its licensors.
-*
-* For complete copyright and license terms please see the LICENSE at the root of this
-* distribution (the "License"). All use of this software is governed by the License,
-* or, if provided, by the license below or the license accompanying this file. Do not
-* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-*
-*/
-#pragma once
-
-#include
-#include
-
-namespace AzToolsFramework
-{
- namespace MaterialBrowser
- {
- //! MaterialBrowserComponent allows initialization of MaterialBrowser systems, such as thumbnails
- class MaterialBrowserComponent
- : public AZ::Component
- {
- public:
- AZ_COMPONENT(MaterialBrowserComponent, "{121F3F3B-2412-490D-9E3E-C205C677F476}")
-
- MaterialBrowserComponent();
- virtual ~MaterialBrowserComponent() = default;
-
- //////////////////////////////////////////////////////////////////////////
- // AZ::Component
- //////////////////////////////////////////////////////////////////////////
- void Activate() override;
- void Deactivate() override;
- static void Reflect(AZ::ReflectContext* context);
-
- static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
- };
- } // namespace MaterialBrowser
-} // namespace AzToolsFramework
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/MaterialBrowser/MaterialThumbnail.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/MaterialBrowser/MaterialThumbnail.cpp
deleted file mode 100644
index e04df8937c..0000000000
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/MaterialBrowser/MaterialThumbnail.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
-* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-* its licensors.
-*
-* For complete copyright and license terms please see the LICENSE at the root of this
-* distribution (the "License"). All use of this software is governed by the License,
-* or, if provided, by the license below or the license accompanying this file. Do not
-* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-*
-*/
-
-#include
-
-#include
-
-namespace AzToolsFramework
-{
- namespace MaterialBrowser
- {
- static constexpr const char* SimpleMaterialIconPath = ":/MaterialBrowser/images/material_04.png";
- static constexpr const char* MultiMaterialIconPath = ":/MaterialBrowser/images/material_06.png";
-
- //////////////////////////////////////////////////////////////////////////
- // MaterialThumbnail
- //////////////////////////////////////////////////////////////////////////
- MaterialThumbnail::MaterialThumbnail(Thumbnailer::SharedThumbnailKey key)
- : Thumbnail(key)
- {
- auto productKey = azrtti_cast(m_key.data());
- AZ_Assert(productKey, "Incorrect key type, excpected ProductThumbnailKey");
-
- bool multiMat = false;
- MaterialBrowserRequestBus::BroadcastResult(multiMat, &MaterialBrowserRequests::IsMultiMaterial, productKey->GetAssetId());
-
- QString iconPath = multiMat ? MultiMaterialIconPath : SimpleMaterialIconPath;
- m_pixmap.load(iconPath);
- m_state = m_pixmap.isNull() ? State::Failed : State::Ready;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // MaterialThumbnailCache
- //////////////////////////////////////////////////////////////////////////
- MaterialThumbnailCache::MaterialThumbnailCache()
- : ThumbnailCache() {}
-
- MaterialThumbnailCache::~MaterialThumbnailCache() = default;
-
- int MaterialThumbnailCache::GetPriority() const
- {
- return 1;
- }
-
- const char* MaterialThumbnailCache::GetProviderName() const
- {
- return ProviderName;
- }
-
- bool MaterialThumbnailCache::IsSupportedThumbnail(Thumbnailer::SharedThumbnailKey key) const
- {
- return azrtti_istypeof(key.data());
- }
-
- } // namespace MaterialBrowser
-} // namespace AzToolsFramework
-
-#include "MaterialBrowser/moc_MaterialThumbnail.cpp"
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/MaterialBrowser/MaterialThumbnail.h b/Code/Framework/AzToolsFramework/AzToolsFramework/MaterialBrowser/MaterialThumbnail.h
deleted file mode 100644
index 60a2bb11e5..0000000000
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/MaterialBrowser/MaterialThumbnail.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
-* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-* its licensors.
-*
-* For complete copyright and license terms please see the LICENSE at the root of this
-* distribution (the "License"). All use of this software is governed by the License,
-* or, if provided, by the license below or the license accompanying this file. Do not
-* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-*
-*/
-
-#pragma once
-
-#if !defined(Q_MOC_RUN)
-#include
-#include
-#include
-#endif
-
-namespace AzToolsFramework
-{
- namespace MaterialBrowser
- {
- //! Material Browser uses only 2 thumbnails: simple and multimaterial
- class MaterialThumbnail
- : public Thumbnailer::Thumbnail
- {
- Q_OBJECT
- public:
- MaterialThumbnail(Thumbnailer::SharedThumbnailKey key);
- };
-
- namespace
- {
- class MaterialKeyHash
- {
- public:
- size_t operator()(const Thumbnailer::SharedThumbnailKey& /*val*/) const
- {
- return 0; // there is only 2 thumbnails in this cache
- }
- };
-
- class MaterialKeyEqual
- {
- public:
- bool operator()(const Thumbnailer::SharedThumbnailKey& val1, const Thumbnailer::SharedThumbnailKey& val2) const
- {
- auto productThumbnailKey1 = azrtti_cast(val1.data());
- auto productThumbnailKey2 = azrtti_cast(val2.data());
- if (!productThumbnailKey1 || !productThumbnailKey2)
- {
- return false;
- }
-
- // check whether keys point to single or multimaterial asset type
- bool multiMat1 = false;
- bool multiMat2 = false;
- MaterialBrowserRequestBus::BroadcastResult(multiMat1, &MaterialBrowserRequests::IsMultiMaterial, productThumbnailKey1->GetAssetId());
- MaterialBrowserRequestBus::BroadcastResult(multiMat2, &MaterialBrowserRequests::IsMultiMaterial, productThumbnailKey2->GetAssetId());
- return multiMat1 == multiMat2;
- }
- };
- }
-
- //! MaterialBrowserEntry thumbnails
- class MaterialThumbnailCache
- : public Thumbnailer::ThumbnailCache
- {
- public:
- MaterialThumbnailCache();
- ~MaterialThumbnailCache() override;
-
- int GetPriority() const override;
- const char* GetProviderName() const override;
-
- static constexpr const char* ProviderName = "CryMaterial Thumbnails";
-
- protected:
- bool IsSupportedThumbnail(Thumbnailer::SharedThumbnailKey key) const override;
- };
- } // namespace MaterialBrowser
-} // namespace AzToolsFramework
-
-
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/aztoolsframework_files.cmake b/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake
index 4cf121c517..a7fcf2e711 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake
@@ -70,11 +70,6 @@ set(FILES
AssetCatalog/PlatformAddressedAssetCatalog.cpp
AssetCatalog/PlatformAddressedAssetCatalogManager.h
AssetCatalog/PlatformAddressedAssetCatalogManager.cpp
- MaterialBrowser/MaterialBrowserBus.h
- MaterialBrowser/MaterialBrowserComponent.cpp
- MaterialBrowser/MaterialBrowserComponent.h
- MaterialBrowser/MaterialThumbnail.cpp
- MaterialBrowser/MaterialThumbnail.h
Thumbnails/ThumbnailerComponent.cpp
Thumbnails/ThumbnailerComponent.h
Thumbnails/LoadingThumbnail.cpp
diff --git a/Code/Sandbox/Editor/Controls/PreviewModelCtrl.cpp b/Code/Sandbox/Editor/Controls/PreviewModelCtrl.cpp
index 5746e9db2f..9b07f59e6a 100644
--- a/Code/Sandbox/Editor/Controls/PreviewModelCtrl.cpp
+++ b/Code/Sandbox/Editor/Controls/PreviewModelCtrl.cpp
@@ -365,10 +365,6 @@ bool CPreviewModelCtrl::Render()
}
_smart_ptr pMaterial;
- if (m_pCurrentMaterial)
- {
- pMaterial = m_pCurrentMaterial->GetMatInfo();
- }
if (m_bPrecacheMaterial)
{
@@ -430,11 +426,6 @@ bool CPreviewModelCtrl::Render()
m_pRenderer->EF_ADDDlight(&m_lights[i], passInfo);
}
- if (m_pCurrentMaterial)
- {
- m_pCurrentMaterial->DisableHighlightForFrame();
- }
-
if (m_bShowObject)
{
RenderObject(pMaterial, passInfo);
@@ -778,32 +769,6 @@ void CPreviewModelCtrl::SetRotation(bool bEnable)
m_bRotate = bEnable;
}
-void CPreviewModelCtrl::SetMaterial(CMaterial* pMaterial)
-{
- if (pMaterial)
- {
- if ((pMaterial->GetFlags() & MTL_FLAG_NOPREVIEW))
- {
- m_pCurrentMaterial = 0;
- if (isVisible())
- {
- update();
- }
- return;
- }
- }
- m_pCurrentMaterial = pMaterial;
- if (isVisible())
- {
- update();
- }
-}
-
-CMaterial* CPreviewModelCtrl::GetMaterial()
-{
- return m_pCurrentMaterial;
-}
-
void CPreviewModelCtrl::OnEditorNotifyEvent(EEditorNotifyEvent event)
{
switch (event)
diff --git a/Code/Sandbox/Editor/Controls/PreviewModelCtrl.h b/Code/Sandbox/Editor/Controls/PreviewModelCtrl.h
index 73839612af..6388be9fd5 100644
--- a/Code/Sandbox/Editor/Controls/PreviewModelCtrl.h
+++ b/Code/Sandbox/Editor/Controls/PreviewModelCtrl.h
@@ -22,8 +22,6 @@
#include
-#include
-
#endif
struct IRenderNode;
@@ -71,9 +69,6 @@ public:
int heightForWidth(int w) const override;
bool hasHeightForWidth() const override;
- void SetMaterial(CMaterial* pMaterial);
- CMaterial* GetMaterial();
-
void GetImageOffscreen(CImageEx& image, const QSize& customSize = QSize(0, 0));
void GetCameraTM(Matrix34& cameraTM);
@@ -192,7 +187,6 @@ protected:
float m_tileY;
float m_tileSizeX;
float m_tileSizeY;
- _smart_ptr m_pCurrentMaterial;
CameraChangeCallback m_cameraChangeCallback;
void* m_pCameraChangeUserData;
diff --git a/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/PropertyCtrl.cpp b/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/PropertyCtrl.cpp
index c21aff046e..f0367ffdc1 100644
--- a/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/PropertyCtrl.cpp
+++ b/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/PropertyCtrl.cpp
@@ -29,7 +29,6 @@ void RegisterReflectedVarHandlers()
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew AnimationPropertyWidgetHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew FileResourceSelectorWidgetHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew ShaderPropertyHandler());
- EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew MaterialPropertyHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew ReverbPresetPropertyHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew SequencePropertyHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew SequenceIdPropertyHandler());
diff --git a/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/PropertyGenericCtrl.cpp b/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/PropertyGenericCtrl.cpp
index 3d17e77bb0..75344b2172 100644
--- a/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/PropertyGenericCtrl.cpp
+++ b/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/PropertyGenericCtrl.cpp
@@ -27,7 +27,6 @@
// Editor
#include "ShadersDialog.h"
-#include "Material/MaterialManager.h"
#include "SelectLightAnimationDialog.h"
#include "SelectSequenceDialog.h"
#include "SelectEAXPresetDlg.h"
@@ -88,25 +87,6 @@ void ShaderPropertyEditor::onEditClicked()
}
}
-void MaterialPropertyEditor::onEditClicked()
-{
-}
-
-void MaterialPropertyEditor::onButton2Clicked()
-{
- // Open material browser dialog.
- IDataBaseItem *pItem = GetIEditor()->GetMaterialManager()->GetSelectedItem();
- if (pItem)
- {
- QString value = pItem->GetName();
- value.replace('\\', '/');
- if (value.length() >= MAX_PATH)
- value = value.left(MAX_PATH);
- SetValue(value);
- }
- else
- SetValue(QString());
-}
void ReverbPresetPropertyEditor::onEditClicked()
{
diff --git a/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/PropertyGenericCtrl.h b/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/PropertyGenericCtrl.h
index d5ec0045c4..cdbb18ae12 100644
--- a/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/PropertyGenericCtrl.h
+++ b/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/PropertyGenericCtrl.h
@@ -109,16 +109,6 @@ public:
void onEditClicked() override;
};
-class MaterialPropertyEditor
- : public GenericPopupPropertyEditor
-{
-public:
- MaterialPropertyEditor(QWidget* pParent = nullptr)
- : GenericPopupPropertyEditor(pParent, true){}
- void onEditClicked() override;
- void onButton2Clicked() override;
-};
-
class ReverbPresetPropertyEditor
: public GenericPopupPropertyEditor
{
@@ -179,7 +169,6 @@ public:
#define CONST_AZ_CRC(name, value) AZ::u32(value)
using ShaderPropertyHandler = GenericPopupWidgetHandler;
-using MaterialPropertyHandler = GenericPopupWidgetHandler;
using ReverbPresetPropertyHandler = GenericPopupWidgetHandler;
using MissionObjPropertyHandler = GenericPopupWidgetHandler;
using SequencePropertyHandler = GenericPopupWidgetHandler;
diff --git a/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/PropertyResourceCtrl.cpp b/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/PropertyResourceCtrl.cpp
index a66a73eaa4..e698b86341 100644
--- a/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/PropertyResourceCtrl.cpp
+++ b/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/PropertyResourceCtrl.cpp
@@ -111,14 +111,12 @@ private:
{
case ePropertyTexture:
case ePropertyModel:
- case ePropertyMaterial:
newPath.replace("\\\\", "/");
}
switch (m_propertyType)
{
case ePropertyTexture:
case ePropertyModel:
- case ePropertyMaterial:
case ePropertyFile:
if (newPath.size() > MAX_PATH)
{
diff --git a/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.cpp b/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.cpp
index 92610021b9..a188ee117b 100644
--- a/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.cpp
+++ b/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.cpp
@@ -361,16 +361,6 @@ void ReflectedPropertyControl::CreateItems(XmlNodeRef node, CVarBlockPtr& outBlo
textureVar->Set(textureName);
}
}
- else if (!azstricmp(type, "material"))
- {
- CSmartVariable materialVar;
- AddVariable(group, materialVar, child->getTag(), humanReadableName.toUtf8().data(), strDescription.toUtf8().data(), func, pUserData, IVariable::DT_MATERIAL);
- const char* materialName;
- if (child->getAttr("value", &materialName))
- {
- materialVar->Set(materialName);
- }
- }
else if (!azstricmp(type, "color"))
{
CSmartVariable colorVar;
diff --git a/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/ReflectedPropertyItem.cpp b/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/ReflectedPropertyItem.cpp
index 055fc26a15..13584d9b82 100644
--- a/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/ReflectedPropertyItem.cpp
+++ b/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/ReflectedPropertyItem.cpp
@@ -269,7 +269,6 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
m_reflectedVarAdapter = new ReflectedVarUserAdapter;
break;
case ePropertyShader:
- case ePropertyMaterial:
case ePropertyEquip:
case ePropertyReverbPreset:
case ePropertyGameToken:
@@ -576,7 +575,6 @@ void ReflectedPropertyItem::SetValue(const QString& sValue, bool bRecordUndo, bo
case ePropertyTexture:
case ePropertyModel:
- case ePropertyMaterial:
value.replace('\\', '/');
break;
}
@@ -586,7 +584,6 @@ void ReflectedPropertyItem::SetValue(const QString& sValue, bool bRecordUndo, bo
{
case ePropertyTexture:
case ePropertyModel:
- case ePropertyMaterial:
case ePropertyFile:
if (value.length() >= MAX_PATH)
{
diff --git a/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/ReflectedVar.cpp b/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/ReflectedVar.cpp
index a805c07a2f..12165d2be8 100644
--- a/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/ReflectedVar.cpp
+++ b/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/ReflectedVar.cpp
@@ -286,8 +286,6 @@ AZ::u32 CReflectedVarGenericProperty::handler()
{
case ePropertyShader:
return AZ_CRC("ePropertyShader", 0xc40932f1);
- case ePropertyMaterial:
- return AZ_CRC("ePropertyMaterial", 0xf324dffa);
case ePropertyEquip:
return AZ_CRC("ePropertyEquip", 0x66ffd290);
case ePropertyReverbPreset:
diff --git a/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/ReflectedVarWrapper.cpp b/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/ReflectedVarWrapper.cpp
index 84a7f8c26f..b2fc07073f 100644
--- a/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/ReflectedVarWrapper.cpp
+++ b/Code/Sandbox/Editor/Controls/ReflectedPropertyControl/ReflectedVarWrapper.cpp
@@ -455,8 +455,6 @@ void ReflectedVarGenericPropertyAdapter::SyncReflectedVarToIVar(IVariable *pVari
{
QString value;
pVariable->Get(value);
- if (m_reflectedVar->m_propertyType == ePropertyMaterial)
- value.replace('\\', '/');
m_reflectedVar->m_value = value.toUtf8().data();
}
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/CryEdit.cpp b/Code/Sandbox/Editor/CryEdit.cpp
index e118104687..abffd1f995 100644
--- a/Code/Sandbox/Editor/CryEdit.cpp
+++ b/Code/Sandbox/Editor/CryEdit.cpp
@@ -102,7 +102,6 @@ AZ_POP_DISABLE_WARNING
#include "ModelViewport.h"
#include "FileTypeUtils.h"
#include "PluginManager.h"
-#include "Material/MaterialManager.h"
#include "IEditorImpl.h"
#include "StartupLogoDialog.h"
@@ -157,9 +156,6 @@ AZ_POP_DISABLE_WARNING
#include "Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.h"
-// LmbrCentral
-#include
-
// AWSNativeSDK
#include
#include
@@ -459,9 +455,6 @@ void CCryEditApp::RegisterActionHandlers()
ON_COMMAND(ID_CHANGEMOVESPEED_INCREASE, OnChangemovespeedIncrease)
ON_COMMAND(ID_CHANGEMOVESPEED_DECREASE, OnChangemovespeedDecrease)
ON_COMMAND(ID_CHANGEMOVESPEED_CHANGESTEP, OnChangemovespeedChangestep)
- ON_COMMAND(ID_MATERIAL_ASSIGNCURRENT, OnMaterialAssigncurrent)
- ON_COMMAND(ID_MATERIAL_RESETTODEFAULT, OnMaterialResettodefault)
- ON_COMMAND(ID_MATERIAL_GETMATERIAL, OnMaterialGetmaterial)
ON_COMMAND(ID_FILE_SAVELEVELRESOURCES, OnFileSavelevelresources)
ON_COMMAND(ID_CLEAR_REGISTRY, OnClearRegistryData)
ON_COMMAND(ID_VALIDATELEVEL, OnValidatelevel)
@@ -4180,25 +4173,6 @@ void CCryEditApp::OnSwitchcameraNext()
}
}
-//////////////////////////////////////////////////////////////////////////
-void CCryEditApp::OnMaterialAssigncurrent()
-{
- CUndo undo("Assign Material To Selection");
- GetIEditor()->GetMaterialManager()->Command_AssignToSelection();
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CCryEditApp::OnMaterialResettodefault()
-{
- GetIEditor()->GetMaterialManager()->Command_ResetSelection();
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CCryEditApp::OnMaterialGetmaterial()
-{
- GetIEditor()->GetMaterialManager()->Command_SelectFromObject();
-}
-
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnOpenAssetBrowserView()
{
diff --git a/Code/Sandbox/Editor/CryEdit.h b/Code/Sandbox/Editor/CryEdit.h
index 8c0c4bd59b..bce7f0c90d 100644
--- a/Code/Sandbox/Editor/CryEdit.h
+++ b/Code/Sandbox/Editor/CryEdit.h
@@ -417,9 +417,6 @@ private:
void OnChangemovespeedIncrease();
void OnChangemovespeedDecrease();
void OnChangemovespeedChangestep();
- void OnMaterialAssigncurrent();
- void OnMaterialResettodefault();
- void OnMaterialGetmaterial();
void OnFileSavelevelresources();
void OnClearRegistryData();
void OnValidatelevel();
diff --git a/Code/Sandbox/Editor/CryEditDoc.cpp b/Code/Sandbox/Editor/CryEditDoc.cpp
index 41c49ab026..2138c5c79e 100644
--- a/Code/Sandbox/Editor/CryEditDoc.cpp
+++ b/Code/Sandbox/Editor/CryEditDoc.cpp
@@ -27,7 +27,6 @@
// AzFramework
#include
#include
-#include
// AzToolsFramework
#include
@@ -51,7 +50,6 @@
#include "CryEdit.h"
#include "ActionManager.h"
#include "Include/IObjectManager.h"
-#include "Material/MaterialManager.h"
#include "ErrorReportDialog.h"
#include "SurfaceTypeValidator.h"
#include "ShaderCache.h"
@@ -64,6 +62,9 @@
#include "StatObjBus.h"
// LmbrCentral
+#include
+#include
+#include
#include // for LmbrCentral::EditorLightComponentRequestBus
@@ -357,8 +358,6 @@ void CCryEditDoc::Save(TDocMultiArchive& arrXmlAr)
SerializeFogSettings((*arrXmlAr[DMAS_GENERAL]));
// Serialize Missions //////////////////////////////////////////////////
SerializeMissions(arrXmlAr, currentMissionName, false);
- //! Serialize material manager.
- GetIEditor()->GetMaterialManager()->Serialize((*arrXmlAr[DMAS_GENERAL]).root, (*arrXmlAr[DMAS_GENERAL]).bLoading);
SerializeShaderCache((*arrXmlAr[DMAS_GENERAL_NAMED_DATA]));
SerializeNameSelection((*arrXmlAr[DMAS_GENERAL]));
@@ -513,14 +512,6 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
//////////////////////////////////////////////////////////////////////////
(*arrXmlAr[DMAS_GENERAL]).root->getAttr("WaterColor", m_waterColor);
- //////////////////////////////////////////////////////////////////////////
- // Load materials.
- //////////////////////////////////////////////////////////////////////////
- {
- CAutoLogTime logtime("Load MaterialManager");
- GetIEditor()->GetMaterialManager()->Serialize((*arrXmlAr[DMAS_GENERAL]).root, (*arrXmlAr[DMAS_GENERAL]).bLoading);
- }
-
//////////////////////////////////////////////////////////////////////////
// Load View Settings
//////////////////////////////////////////////////////////////////////////
@@ -658,6 +649,7 @@ void CCryEditDoc::SerializeViewSettings(CXmlArchive& xmlAr)
CViewport* pVP = GetIEditor()->GetViewManager()->GetView(i);
+
if (pVP)
{
Matrix34 tm = Matrix34::CreateRotationXYZ(va);
@@ -2415,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/DisplaySettings.cpp b/Code/Sandbox/Editor/DisplaySettings.cpp
index bd4372ae70..75e5c54ae9 100644
--- a/Code/Sandbox/Editor/DisplaySettings.cpp
+++ b/Code/Sandbox/Editor/DisplaySettings.cpp
@@ -22,7 +22,6 @@
// Editor
#include "Settings.h"
-#include "Material/MaterialManager.h"
@@ -112,30 +111,6 @@ void CDisplaySettings::SetDebugFlags(int flags)
//SetCVarInt( "sys_enable_budgetmonitoring",(m_debugFlags&DBG_BUDGET_MONITORING) ? 4:0 );
//SetCVarInt( "Profile",(m_debugFlags&DBG_FRAMEPROFILE) ? 1:0 );
-
- if (CMaterialManager* pMaterialManager = GetIEditor()->GetMaterialManager())
- {
- int mask = pMaterialManager->GetHighlightMask();
- if (m_debugFlags & DBG_HIGHLIGHT_BREAKABLE)
- {
- mask |= eHighlight_Breakable;
- }
- else
- {
- mask &= ~eHighlight_Breakable;
- }
-
- if (m_debugFlags & DBG_HIGHLIGHT_MISSING_SURFACE_TYPE)
- {
- mask |= eHighlight_NoSurfaceType;
- }
- else
- {
- mask &= ~eHighlight_NoSurfaceType;
- }
-
- pMaterialManager->SetHighlightMask(mask);
- }
}
//////////////////////////////////////////////////////////////////////////
diff --git a/Code/Sandbox/Editor/EditorToolsApplication.cpp b/Code/Sandbox/Editor/EditorToolsApplication.cpp
index 97caaf612a..2e3d70795a 100644
--- a/Code/Sandbox/Editor/EditorToolsApplication.cpp
+++ b/Code/Sandbox/Editor/EditorToolsApplication.cpp
@@ -21,14 +21,12 @@
#include
#include
#include
-#include
// Editor
#include "MainWindow.h"
#include "CryEdit.h"
#include "DisplaySettingsPythonFuncs.h"
#include "GameEngine.h"
-#include "Material/MaterialPythonFuncs.h"
#include "PythonEditorFuncs.h"
#include "TrackView/TrackViewPythonFuncs.h"
#include "Include/IObjectManager.h"
@@ -65,7 +63,6 @@ namespace EditorInternal
RegisterComponentDescriptor(AzToolsFramework::DisplaySettingsPythonFuncsHandler::CreateDescriptor());
RegisterComponentDescriptor(AzToolsFramework::MainWindowEditorFuncsHandler::CreateDescriptor());
RegisterComponentDescriptor(AzToolsFramework::ObjectManagerFuncsHandler::CreateDescriptor());
- RegisterComponentDescriptor(AzToolsFramework::MaterialPythonFuncsHandler::CreateDescriptor());
RegisterComponentDescriptor(AzToolsFramework::PythonEditorComponent::CreateDescriptor());
RegisterComponentDescriptor(AzToolsFramework::PythonEditorFuncsHandler::CreateDescriptor());
RegisterComponentDescriptor(AzToolsFramework::DisplaySettingsComponent::CreateDescriptor());
@@ -81,7 +78,6 @@ namespace EditorInternal
components.emplace_back(azrtti_typeid());
components.emplace_back(azrtti_typeid());
- components.emplace_back(azrtti_typeid());
// Add new Bus-based Python Bindings
components.emplace_back(azrtti_typeid());
diff --git a/Code/Sandbox/Editor/EditorViewportWidget.cpp b/Code/Sandbox/Editor/EditorViewportWidget.cpp
index 9165809c7f..a127203071 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
@@ -1234,6 +1233,7 @@ void EditorViewportWidget::SetViewportId(int id)
if (ed_useNewCameraSystem)
{
+ AzFramework::ReloadCameraKeyBindings();
m_renderViewport->GetControllerList()->Add(AZStd::make_shared());
}
else
@@ -1626,8 +1626,8 @@ void EditorViewportWidget::keyPressEvent(QKeyEvent* event)
QCoreApplication::sendEvent(GetIEditor()->GetEditorMainWindow(), event);
}
- // NOTE: we keep track of keypresses and releases explicitly because the OS/Qt will insert a slight delay between sending
- // keyevents when the key is held down. This is standard, but makes responding to key events for game style input silly
+ // NOTE: we keep track of key presses and releases explicitly because the OS/Qt will insert a slight delay between sending
+ // key events when the key is held down. This is standard, but makes responding to key events for game style input silly
// because we want the movement to be butter smooth.
if (!event->isAutoRepeat())
{
diff --git a/Code/Sandbox/Editor/ErrorReport.h b/Code/Sandbox/Editor/ErrorReport.h
index f78410be62..b13f8ae120 100644
--- a/Code/Sandbox/Editor/ErrorReport.h
+++ b/Code/Sandbox/Editor/ErrorReport.h
@@ -19,7 +19,6 @@
#pragma once
// forward declarations.
-class CMaterial;
class CParticleItem;
#include "BaseLibraryItem.h"
diff --git a/Code/Sandbox/Editor/Export/ExportManager.cpp b/Code/Sandbox/Editor/Export/ExportManager.cpp
index b41872595a..638977b191 100644
--- a/Code/Sandbox/Editor/Export/ExportManager.cpp
+++ b/Code/Sandbox/Editor/Export/ExportManager.cpp
@@ -23,7 +23,6 @@
// Editor
#include "Geometry/EdGeometry.h"
-#include "Material/Material.h"
#include "ViewManager.h"
#include "OBJExporter.h"
#include "OCMExporter.h"
@@ -79,47 +78,6 @@ Export::CMesh::CMesh()
}
-void Export::CMesh::SetMaterial(CMaterial* pMtl, CBaseObject* pBaseObj)
-{
- if (!pMtl)
- {
- cry_strcpy(material.name, pBaseObj->GetName().toUtf8().data());
- return;
- }
-
- cry_strcpy(material.name, pMtl->GetFullName().toUtf8().data());
-
- _smart_ptr matInfo = pMtl->GetMatInfo();
- IRenderShaderResources* pRes = matInfo->GetShaderItem().m_pShaderResources;
- if (!pRes)
- {
- return;
- }
-
- ColorF difColor = pRes->GetColorValue(EFTT_DIFFUSE);
- material.diffuse.r = difColor.r;
- material.diffuse.g = difColor.g;
- material.diffuse.b = difColor.b;
- material.diffuse.a = difColor.a;
-
- ColorF specColor = pRes->GetColorValue(EFTT_SPECULAR);
- material.specular.r = specColor.r;
- material.specular.g = specColor.g;
- material.specular.b = specColor.b;
- material.specular.a = specColor.a;
-
- material.opacity = pRes->GetStrengthValue(EFTT_OPACITY);
- material.smoothness = pRes->GetStrengthValue(EFTT_SMOOTHNESS);
-
- SetTexture(material.mapDiffuse, pRes, EFTT_DIFFUSE);
- SetTexture(material.mapSpecular, pRes, EFTT_SPECULAR);
- SetTexture(material.mapOpacity, pRes, EFTT_OPACITY);
- SetTexture(material.mapNormals, pRes, EFTT_NORMALS);
- SetTexture(material.mapDecal, pRes, EFTT_DECAL_OVERLAY);
- SetTexture(material.mapDisplacement, pRes, EFTT_HEIGHT);
-}
-
-
//////////////////////////////////////////////////////////
// CObject
Export::CObject::CObject(const char* pName)
@@ -416,18 +374,6 @@ void CExportManager::AddMesh(Export::CObject* pObj, const IIndexedMesh* pIndMesh
pObj->m_texCoords.push_back(tc);
}
- CMaterial* pMtl = 0;
-
- if (m_pBaseObj)
- {
- pMtl = m_pBaseObj->GetRenderMaterial();
- }
-
- if (pMtl)
- {
- pObj->SetMaterialName(pMtl->GetFullName().toUtf8().data());
- }
-
if (pIndMesh->GetSubSetCount() && !(pIndMesh->GetSubSetCount() == 1 && pIndMesh->GetSubSet(0).nNumIndices == 0))
{
for (int i = 0; i < pIndMesh->GetSubSetCount(); ++i)
@@ -447,23 +393,6 @@ void CExportManager::AddMesh(Export::CObject* pObj, const IIndexedMesh* pIndMesh
pMesh->m_faces.push_back(face);
}
- if (pMtl)
- {
- if (pMtl->IsMultiSubMaterial())
- {
- CMaterial* pSubMtl = 0;
- if (sms.nMatID < pMtl->GetSubMaterialCount())
- {
- pSubMtl = pMtl->GetSubMaterial(sms.nMatID);
- }
- pMesh->SetMaterial(pSubMtl, m_pBaseObj);
- }
- else
- {
- pMesh->SetMaterial(pMtl, m_pBaseObj);
- }
- }
-
pObj->m_meshes.push_back(pMesh);
}
}
@@ -497,10 +426,6 @@ void CExportManager::AddMesh(Export::CObject* pObj, const IIndexedMesh* pIndMesh
}
}
- if (m_pBaseObj && pMtl)
- {
- pMesh->SetMaterial(pMtl, m_pBaseObj);
- }
pObj->m_meshes.push_back(pMesh);
}
}
diff --git a/Code/Sandbox/Editor/Export/ExportManager.h b/Code/Sandbox/Editor/Export/ExportManager.h
index 8904ef08ed..a27e54b085 100644
--- a/Code/Sandbox/Editor/Export/ExportManager.h
+++ b/Code/Sandbox/Editor/Export/ExportManager.h
@@ -43,8 +43,6 @@ namespace Export
virtual int GetFaceCount() const { return m_faces.size(); }
virtual const Face* GetFaceBuffer() const { return m_faces.size() ? &m_faces[0] : 0; }
- void SetMaterial(CMaterial* pMtl, CBaseObject* pBaseObj);
-
private:
std::vector m_faces;
diff --git a/Code/Sandbox/Editor/GameExporter.cpp b/Code/Sandbox/Editor/GameExporter.cpp
index 8f0b6f6d0f..64e1fc6514 100644
--- a/Code/Sandbox/Editor/GameExporter.cpp
+++ b/Code/Sandbox/Editor/GameExporter.cpp
@@ -27,8 +27,6 @@
#include "Mission.h"
#include "ShaderCache.h"
#include "UsedResources.h"
-#include "Material/MaterialManager.h"
-#include "Material/MaterialLibrary.h"
#include "WaitProgress.h"
#include "Util/CryMemFile.h"
#include "Objects/ObjectManager.h"
@@ -336,11 +334,6 @@ void CGameExporter::ExportLevelData(const QString& path, bool bExportMission)
ExportMapInfo(root);
- //////////////////////////////////////////////////////////////////////////
- // Export materials.
- ExportMaterials(root, path);
- //////////////////////////////////////////////////////////////////////////
-
CCryEditDoc* pDocument = pEditor->GetDocument();
CMission* pCurrentMission = 0;
@@ -508,48 +501,6 @@ void CGameExporter::ExportMapInfo(XmlNodeRef& node)
xmlAr.root = node;
}
-//////////////////////////////////////////////////////////////////////////
-void CGameExporter::ExportMaterials(XmlNodeRef& levelDataNode, const QString& path)
-{
- //////////////////////////////////////////////////////////////////////////
- // Export materials manager.
- CMaterialManager* pManager = GetIEditor()->GetMaterialManager();
- pManager->Export(levelDataNode);
-
- QString filename = Path::Make(path, MATERIAL_LEVEL_LIBRARY_FILE);
-
- bool bHaveItems = true;
-
- int numMtls = 0;
-
- XmlNodeRef nodeMaterials = XmlHelpers::CreateXmlNode("MaterialsLibrary");
- // Export Materials local level library.
- for (int i = 0; i < pManager->GetLibraryCount(); i++)
- {
- XmlNodeRef nodeLib = nodeMaterials->newChild("Library");
- CMaterialLibrary* pLib = (CMaterialLibrary*)pManager->GetLibrary(i);
- if (pLib->GetItemCount() > 0)
- {
- bHaveItems = false;
- // Export this library.
- numMtls += pManager->ExportLib(pLib, nodeLib);
- }
- }
- if (!bHaveItems)
- {
- XmlString xmlData = nodeMaterials->getXML();
-
- CCryMemFile file;
- file.Write(xmlData.c_str(), xmlData.length());
- m_levelPak.m_pakFile.UpdateFile(filename.toUtf8().data(), file);
- }
- else
- {
- m_levelPak.m_pakFile.RemoveFile(filename.toUtf8().data());
- }
- m_numExportedMaterials = numMtls;
-}
-
//////////////////////////////////////////////////////////////////////////
void CGameExporter::ExportLevelResourceList(const QString& path)
{
diff --git a/Code/Sandbox/Editor/GameExporter.h b/Code/Sandbox/Editor/GameExporter.h
index 52731a7000..a428046f0a 100644
--- a/Code/Sandbox/Editor/GameExporter.h
+++ b/Code/Sandbox/Editor/GameExporter.h
@@ -98,7 +98,6 @@ private:
void ExportLevelResourceList(const QString& path);
void ExportLevelUsedResourceList(const QString& path);
void ExportLevelShaderCache(const QString& path);
- void ExportMaterials(XmlNodeRef& levelDataNode, const QString& path);
void ExportGameData(const QString& path);
void ExportFileList(const QString& path, const QString& levelName);
diff --git a/Code/Sandbox/Editor/GameResourcesExporter.cpp b/Code/Sandbox/Editor/GameResourcesExporter.cpp
index 564396d090..8a6c547dca 100644
--- a/Code/Sandbox/Editor/GameResourcesExporter.cpp
+++ b/Code/Sandbox/Editor/GameResourcesExporter.cpp
@@ -21,7 +21,6 @@
// Editor
#include "UsedResources.h"
#include "GameEngine.h"
-#include "Material/MaterialManager.h"
#include "Include/IObjectManager.h"
#include "WaitProgress.h"
@@ -51,7 +50,7 @@ void CGameResourcesExporter::ChooseDirectory()
void CGameResourcesExporter::GatherAllLoadedResources()
{
m_files.clear();
- m_files.reserve(100000); // count from GetResourceList, GetFilesFromObjects, GetFilesFromMaterials ... is unknown
+ m_files.reserve(100000); // count from GetResourceList, GetFilesFromObjects ... is unknown
auto pResList = gEnv->pCryPak->GetResourceList(AZ::IO::IArchive::RFOM_Level);
{
@@ -62,7 +61,6 @@ void CGameResourcesExporter::GatherAllLoadedResources()
}
GetFilesFromObjects();
- GetFilesFromMaterials();
}
//////////////////////////////////////////////////////////////////////////
@@ -158,12 +156,3 @@ void CGameResourcesExporter::GetFilesFromObjects()
Append(m_files, rs.files);
}
-
-//////////////////////////////////////////////////////////////////////////
-void CGameResourcesExporter::GetFilesFromMaterials()
-{
- CUsedResources rs;
- GetIEditor()->GetMaterialManager()->GatherUsedResources(rs);
- Append(m_files, rs.files);
-}
-
diff --git a/Code/Sandbox/Editor/GameResourcesExporter.h b/Code/Sandbox/Editor/GameResourcesExporter.h
index b408cbb42f..8236458cb3 100644
--- a/Code/Sandbox/Editor/GameResourcesExporter.h
+++ b/Code/Sandbox/Editor/GameResourcesExporter.h
@@ -44,7 +44,6 @@ private:
void GetFilesFromObjects();
void GetFilesFromVarBlock(CVarBlock* pVB);
void GetFilesFromVariable(IVariable* pVar);
- void GetFilesFromMaterials();
};
#endif // CRYINCLUDE_EDITOR_GAMERESOURCESEXPORTER_H
diff --git a/Code/Sandbox/Editor/IEditor.h b/Code/Sandbox/Editor/IEditor.h
index 838f48573d..c03b99e128 100644
--- a/Code/Sandbox/Editor/IEditor.h
+++ b/Code/Sandbox/Editor/IEditor.h
@@ -46,9 +46,7 @@ class CGameEngine;
struct IIconManager;
class CToolBoxManager;
class CClassFactory;
-class CMaterialManager;
class CMusicManager;
-class CMaterail;
struct IEditorParticleManager;
class CEAXPresetManager;
class CErrorReport;
@@ -544,8 +542,6 @@ struct IEditor
virtual CSettingsManager* GetSettingsManager() = 0;
//! Get DB manager that own items of specified type.
virtual IDataBaseManager* GetDBItemManager(EDataBaseItemType itemType) = 0;
- //! Get Manager of Materials.
- virtual CMaterialManager* GetMaterialManager() = 0;
virtual IBaseLibraryManager* GetMaterialManagerLibrary() = 0; // Vladimir@conffx
virtual IEditorMaterialManager* GetIEditorMaterialManager() = 0; // Vladimir@Conffx
//! Returns IconManager.
diff --git a/Code/Sandbox/Editor/IEditorImpl.cpp b/Code/Sandbox/Editor/IEditorImpl.cpp
index 060bf41189..61d24db90c 100644
--- a/Code/Sandbox/Editor/IEditorImpl.cpp
+++ b/Code/Sandbox/Editor/IEditorImpl.cpp
@@ -53,7 +53,6 @@ AZ_POP_DISABLE_WARNING
#include "KeyboardCustomizationSettings.h"
#include "Export/ExportManager.h"
#include "LevelIndependentFileMan.h"
-#include "Material/MaterialManager.h"
#include "TrackView/TrackViewSequenceManager.h"
#include "AnimationContext.h"
#include "GameEngine.h"
@@ -167,7 +166,6 @@ CEditorImpl::CEditorImpl()
, m_pAnimationContext(nullptr)
, m_pSequenceManager(nullptr)
, m_pToolBoxManager(nullptr)
- , m_pMaterialManager(nullptr)
, m_pMusicManager(nullptr)
, m_pErrorReport(nullptr)
, m_pLasLoadedLevelErrorReport(nullptr)
@@ -222,7 +220,6 @@ CEditorImpl::CEditorImpl()
m_pIconManager = new CIconManager;
m_pUndoManager = new CUndoManager;
m_pToolBoxManager = new CToolBoxManager;
- m_pMaterialManager = new CMaterialManager(regCtx);
m_pAlembicCompiler = new CAlembicCompiler();
m_pSequenceManager = new CTrackViewSequenceManager;
m_pAnimationContext = new CAnimationContext;
@@ -342,7 +339,6 @@ CEditorImpl::~CEditorImpl()
m_bExiting = true; // Can't save level after this point (while Crash)
SAFE_RELEASE(m_pSourceControl);
- SAFE_DELETE(m_pMaterialManager)
SAFE_DELETE(m_pAlembicCompiler)
SAFE_DELETE(m_pIconManager)
SAFE_DELETE(m_pViewManager)
@@ -412,7 +408,6 @@ void CEditorImpl::SetGameEngine(CGameEngine* ge)
m_pObjectManager->LoadClassTemplates("Editor");
m_pObjectManager->RegisterCVars();
- m_pMaterialManager->Set3DEngine();
m_pAnimationContext->Init();
}
@@ -1000,13 +995,8 @@ void CEditorImpl::CloseView(const GUID& classId)
}
}
-IDataBaseManager* CEditorImpl::GetDBItemManager(EDataBaseItemType itemType)
+IDataBaseManager* CEditorImpl::GetDBItemManager([[maybe_unused]] EDataBaseItemType itemType)
{
- switch (itemType)
- {
- case EDB_TYPE_MATERIAL:
- return m_pMaterialManager;
- }
return 0;
}
@@ -1772,13 +1762,13 @@ SEditorSettings* CEditorImpl::GetEditorSettings()
// Vladimir@Conffx
IBaseLibraryManager* CEditorImpl::GetMaterialManagerLibrary()
{
- return m_pMaterialManager;
+ return nullptr;
}
// Vladimir@Conffx
IEditorMaterialManager* CEditorImpl::GetIEditorMaterialManager()
{
- return m_pMaterialManager;
+ return nullptr;
}
IImageUtil* CEditorImpl::GetImageUtil()
diff --git a/Code/Sandbox/Editor/IEditorImpl.h b/Code/Sandbox/Editor/IEditorImpl.h
index 3c440dd5fc..d17a94807f 100644
--- a/Code/Sandbox/Editor/IEditorImpl.h
+++ b/Code/Sandbox/Editor/IEditorImpl.h
@@ -180,7 +180,6 @@ public:
bool IsSelectionLocked();
IDataBaseManager* GetDBItemManager(EDataBaseItemType itemType);
- CMaterialManager* GetMaterialManager() { return m_pMaterialManager; }
CMusicManager* GetMusicManager() { return m_pMusicManager; };
IBackgroundTaskManager* GetBackgroundTaskManager() override;
@@ -379,7 +378,6 @@ protected:
CAnimationContext* m_pAnimationContext;
CTrackViewSequenceManager* m_pSequenceManager;
CToolBoxManager* m_pToolBoxManager;
- CMaterialManager* m_pMaterialManager;
CAlembicCompiler* m_pAlembicCompiler;
CMusicManager* m_pMusicManager;
CErrorReport* m_pErrorReport;
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/Include/IErrorReport.h b/Code/Sandbox/Editor/Include/IErrorReport.h
index 8afe269324..f25a1163a3 100644
--- a/Code/Sandbox/Editor/Include/IErrorReport.h
+++ b/Code/Sandbox/Editor/Include/IErrorReport.h
@@ -21,7 +21,6 @@
#include
// forward declarations.
-class CMaterial;
class CParticleItem;
class CBaseObject;
class CBaseLibraryItem;
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/LevelInfo.cpp b/Code/Sandbox/Editor/LevelInfo.cpp
index 4b8a6d5cac..81441a3797 100644
--- a/Code/Sandbox/Editor/LevelInfo.cpp
+++ b/Code/Sandbox/Editor/LevelInfo.cpp
@@ -20,7 +20,6 @@
// Editor
#include "Util/fastlib.h"
-#include "Material/MaterialManager.h" // for CMaterialManager
#include
@@ -67,7 +66,6 @@ void CLevelInfo::Validate()
// Validate level.
ValidateObjects();
- ValidateMaterials();
if (m_pReport->GetErrorCount() == 0)
{
@@ -186,11 +184,3 @@ void CLevelInfo::ValidateObjects()
}
}
}
-
-//////////////////////////////////////////////////////////////////////////
-void CLevelInfo::ValidateMaterials()
-{
- // Validate all objects
- CBaseObjectsArray objects;
- GetIEditor()->GetMaterialManager()->Validate();
-}
diff --git a/Code/Sandbox/Editor/LevelInfo.h b/Code/Sandbox/Editor/LevelInfo.h
index 0611ad652e..515a21886e 100644
--- a/Code/Sandbox/Editor/LevelInfo.h
+++ b/Code/Sandbox/Editor/LevelInfo.h
@@ -27,7 +27,6 @@ public:
private:
void ValidateObjects();
- void ValidateMaterials();
IErrorReport* m_pReport;
};
diff --git a/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h b/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h
index 45810da2cf..6659e41122 100644
--- a/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h
+++ b/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h
@@ -91,7 +91,6 @@ public:
MOCK_METHOD0(GetObjectManager, struct IObjectManager* ());
MOCK_METHOD0(GetSettingsManager, CSettingsManager* ());
MOCK_METHOD1(GetDBItemManager, IDataBaseManager* (EDataBaseItemType));
- MOCK_METHOD0(GetMaterialManager, CMaterialManager* ());
MOCK_METHOD0(GetMaterialManagerLibrary, IBaseLibraryManager* ());
MOCK_METHOD0(GetIEditorMaterialManager, IEditorMaterialManager* ());
MOCK_METHOD0(GetIconManager, IIconManager* ());
diff --git a/Code/Sandbox/Editor/Lib/Tests/test_MaterialPythonFuncs.cpp b/Code/Sandbox/Editor/Lib/Tests/test_MaterialPythonFuncs.cpp
deleted file mode 100644
index c27608b695..0000000000
--- a/Code/Sandbox/Editor/Lib/Tests/test_MaterialPythonFuncs.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
-* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-* its licensors.
-*
-* For complete copyright and license terms please see the LICENSE at the root of this
-* distribution (the "License"). All use of this software is governed by the License,
-* or, if provided, by the license below or the license accompanying this file. Do not
-* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-*
-*/
-#include "EditorDefs.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-namespace MaterialPythonFuncsUnitTests
-{
-
- class MaterialPythonBindingsFixture
- : public testing::Test
- {
- public:
- AzToolsFramework::ToolsApplication m_app;
-
- void SetUp() override
- {
- AzFramework::Application::Descriptor appDesc;
- appDesc.m_enableDrilling = false;
-
- m_app.Start(appDesc);
- // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
- // shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
- // in the unit tests.
- AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
- m_app.RegisterComponentDescriptor(AzToolsFramework::MaterialPythonFuncsHandler::CreateDescriptor());
- }
-
- void TearDown() override
- {
- m_app.Stop();
- }
- };
-
- TEST_F(MaterialPythonBindingsFixture, MaterialEditorCommands_ApiExists)
- {
- AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
- ASSERT_TRUE(behaviorContext);
-
- EXPECT_TRUE(behaviorContext->m_methods.find("create") != behaviorContext->m_methods.end());
- EXPECT_TRUE(behaviorContext->m_methods.find("create_multi") != behaviorContext->m_methods.end());
- EXPECT_TRUE(behaviorContext->m_methods.find("convert_to_multi") != behaviorContext->m_methods.end());
- EXPECT_TRUE(behaviorContext->m_methods.find("duplicate_current") != behaviorContext->m_methods.end());
- EXPECT_TRUE(behaviorContext->m_methods.find("merge_selection") != behaviorContext->m_methods.end());
- EXPECT_TRUE(behaviorContext->m_methods.find("delete_current") != behaviorContext->m_methods.end());
- EXPECT_TRUE(behaviorContext->m_methods.find("get_submaterial") != behaviorContext->m_methods.end());
- EXPECT_TRUE(behaviorContext->m_methods.find("get_property") != behaviorContext->m_methods.end());
- EXPECT_TRUE(behaviorContext->m_methods.find("set_property") != behaviorContext->m_methods.end());
- }
-}
diff --git a/Code/Sandbox/Editor/MainWindow.cpp b/Code/Sandbox/Editor/MainWindow.cpp
index 96f4da7312..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
@@ -94,13 +93,11 @@ AZ_POP_DISABLE_WARNING
#include "TimeOfDayDialog.h"
#include "Dialogs/PythonScriptsDialog.h"
-#include "Material/MaterialManager.h"
#include "EngineSettingsManager.h"
#include "AzAssetBrowser/AzAssetBrowserWindow.h"
#include "AssetEditor/AssetEditorWindow.h"
#include "GridSettingsDialog.h"
-#include "MaterialSender.h"
#include "ActionManager.h"
// uncomment this to show thumbnail demo widget
@@ -1095,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);
}
@@ -1191,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();
@@ -1654,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/MatEditPreviewDlg.cpp b/Code/Sandbox/Editor/MatEditPreviewDlg.cpp
deleted file mode 100644
index 4bac9b5e76..0000000000
--- a/Code/Sandbox/Editor/MatEditPreviewDlg.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
-* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-* its licensors.
-*
-* For complete copyright and license terms please see the LICENSE at the root of this
-* distribution (the "License"). All use of this software is governed by the License,
-* or, if provided, by the license below or the license accompanying this file. Do not
-* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-*
-*/
-// Original file Copyright Crytek GMBH or its affiliates, used under license.
-
-#include "EditorDefs.h"
-
-#include "MatEditPreviewDlg.h"
-
-// Qt
-#include
-#include
-#include
-
-// Editor
-#include "Material/MaterialManager.h"
-#include "Material/MaterialPreviewModelView.h"
-
-
-/////////////////////////////////////////////////////////////////////////////
-// CMatEditPreviewDlg dialog
-
-
-CMatEditPreviewDlg::CMatEditPreviewDlg(QWidget* parent)
- : QDialog(parent)
-{
- setAttribute(Qt::WA_DeleteOnClose);
- setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
-
- setWindowTitle(tr("Material Preview"));
-
- /* create sub controls */
- m_previewCtrl.reset(new MaterialPreviewModelView(this));
- m_menubar.reset(new QMenuBar);
-
- /* configure layout */
- QVBoxLayout* layout = new QVBoxLayout();
- layout->setContentsMargins(0, 0, 0, 0);
- layout->addWidget(m_menubar.data());
- layout->addWidget(m_previewCtrl.data());
- layout->setStretchFactor(m_previewCtrl.data(), 1);
- setLayout(layout);
-
- GetIEditor()->GetMaterialManager()->AddListener(this);
-
- SetupMenuBar();
-
- OnPreviewPlane();
- m_previewCtrl->SetMaterial(GetIEditor()->GetMaterialManager()->GetCurrentMaterial() ? GetIEditor()->GetMaterialManager()->GetCurrentMaterial()->GetMatInfo() : nullptr);
- m_previewCtrl->Update();
-}
-
-CMatEditPreviewDlg::~CMatEditPreviewDlg()
-{
- GetIEditor()->GetMaterialManager()->RemoveListener(this);
-}
-
-QSize CMatEditPreviewDlg::sizeHint() const
-{
- return QSize(450, 400);
-}
-
-void CMatEditPreviewDlg::showEvent(QShowEvent* e)
-{
- QDialog::showEvent(e);
- resize(sizeHint()); // Because WindowDecorationWrapper resizes it to the minimum for some reason.
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMatEditPreviewDlg::SetupMenuBar()
-{
- QMenu* menu;
- QAction* action;
-
- menu = m_menubar->addMenu(tr("Preview"));
- action = menu->addAction(tr("&Plane"));
- connect(action, &QAction::triggered, this, &CMatEditPreviewDlg::OnPreviewPlane);
- action = menu->addAction(tr("&Sphere"));
- connect(action, &QAction::triggered, this, &CMatEditPreviewDlg::OnPreviewSphere);
- action = menu->addAction(tr("&Box"));
- connect(action, &QAction::triggered, this, &CMatEditPreviewDlg::OnPreviewBox);
- action = menu->addAction(tr("&Teapot"));
- connect(action, &QAction::triggered, this, &CMatEditPreviewDlg::OnPreviewTeapot);
- action = menu->addAction(tr("&Custom"));
- connect(action, &QAction::triggered, this, &CMatEditPreviewDlg::OnPreviewCustom);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMatEditPreviewDlg::OnPreviewSphere()
-{
- m_previewCtrl->LoadModelFile("Objects/MtlSphere.cgf");
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMatEditPreviewDlg::OnPreviewBox()
-{
- m_previewCtrl->LoadModelFile("Objects/MtlBox.cgf");
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMatEditPreviewDlg::OnPreviewTeapot()
-{
- m_previewCtrl->LoadModelFile("Objects/MtlTeapot.cgf");
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMatEditPreviewDlg::OnPreviewPlane()
-{
- m_previewCtrl->LoadModelFile("Objects/MtlPlane.cgf");
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMatEditPreviewDlg::OnPreviewCustom()
-{
- const QString fullFileName =
- QFileDialog::getOpenFileName(this, tr("Custom Model"), QString(), tr("Objects (*.cgf);;All files (*.*)"));
- if (!fullFileName.isNull())
- {
- m_previewCtrl->LoadModelFile(fullFileName);
- }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// CMatEditPreviewDlg message handlers
-
-void CMatEditPreviewDlg::OnDataBaseItemEvent([[maybe_unused]] IDataBaseItem* pItem, EDataBaseItemEvent event)
-{
- switch (event)
- {
- case EDB_ITEM_EVENT_SELECTED:
- case EDB_ITEM_EVENT_ADD:
- case EDB_ITEM_EVENT_CHANGED:
- m_previewCtrl->SetMaterial(GetIEditor()->GetMaterialManager()->GetCurrentMaterial() ? GetIEditor()->GetMaterialManager()->GetCurrentMaterial()->GetMatInfo() : nullptr);
- break;
- case EDB_ITEM_EVENT_DELETE:
- m_previewCtrl->SetMaterial(nullptr);
- break;
- }
-}
-
-#include
diff --git a/Code/Sandbox/Editor/MatEditPreviewDlg.h b/Code/Sandbox/Editor/MatEditPreviewDlg.h
deleted file mode 100644
index 870d1b901e..0000000000
--- a/Code/Sandbox/Editor/MatEditPreviewDlg.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-* its licensors.
-*
-* For complete copyright and license terms please see the LICENSE at the root of this
-* distribution (the "License"). All use of this software is governed by the License,
-* or, if provided, by the license below or the license accompanying this file. Do not
-* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-*
-*/
-// Original file Copyright Crytek GMBH or its affiliates, used under license.
-
-#ifndef CRYINCLUDE_EDITOR_MATEDITPREVIEWDLG_H
-#define CRYINCLUDE_EDITOR_MATEDITPREVIEWDLG_H
-
-#pragma once
-
-#if !defined(Q_MOC_RUN)
-#include
-#include
-
-#include "IDataBaseManager.h"
-#endif
-
-class MaterialPreviewModelView;
-class QMenuBar;
-
-// MatEditPreviewDlg.h : header file
-//
-
-/////////////////////////////////////////////////////////////////////////////
-// CMatEditPreviewDlg dialog
-class CMatEditPreviewDlg
- : public QDialog
- , public IDataBaseManagerListener
-{
- Q_OBJECT
- // Construction
-public:
- CMatEditPreviewDlg(QWidget* parent); // standard constructor
- ~CMatEditPreviewDlg();
-
- QSize sizeHint() const override;
- void showEvent(QShowEvent*) override;
-
- //Functions
-
- virtual void OnDataBaseItemEvent(IDataBaseItem* pItem, EDataBaseItemEvent event);
-
-protected:
- void SetupMenuBar();
-
-private slots:
- void OnPreviewSphere();
- void OnPreviewPlane();
- void OnPreviewBox();
- void OnPreviewTeapot();
- void OnPreviewCustom();
-
-private:
- QScopedPointer m_previewCtrl;
- QScopedPointer m_menubar;
-};
-
-#endif // CRYINCLUDE_EDITOR_MATEDITPREVIEWDLG_H
diff --git a/Code/Sandbox/Editor/Material/Material.cpp b/Code/Sandbox/Editor/Material/Material.cpp
deleted file mode 100644
index 3d642a53dd..0000000000
--- a/Code/Sandbox/Editor/Material/Material.cpp
+++ /dev/null
@@ -1,1982 +0,0 @@
-/*
-* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-* its licensors.
-*
-* For complete copyright and license terms please see the LICENSE at the root of this
-* distribution (the "License"). All use of this software is governed by the License,
-* or, if provided, by the license below or the license accompanying this file. Do not
-* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-*
-*/
-// Original file Copyright Crytek GMBH or its affiliates, used under license.
-
-#include "EditorDefs.h"
-
-#include "Material.h"
-
-// Editor
-#include "MaterialHelpers.h"
-#include "MaterialManager.h"
-#include "UsedResources.h"
-#include "ErrorReport.h"
-#include "Include/ISourceControl.h"
-#include "Undo/IUndoObject.h"
-
-
-static SInputShaderResources defaultShaderResource;
-
-//////////////////////////////////////////////////////////////////////////
-CMaterial::CMaterial(const QString& name, int nFlags)
- : m_highlightFlags(0)
- , m_dccMaterialHash(0)
-{
- m_scFileAttributes = SCC_FILE_ATTRIBUTE_NORMAL;
-
- m_pParent = 0;
-
- m_shaderResources = defaultShaderResource;
- m_shaderResources.m_LMaterial.m_Opacity = 1;
- m_shaderResources.m_LMaterial.m_Diffuse.Set(1.0f, 1.0f, 1.0f, 1.0f);
- m_shaderResources.m_LMaterial.m_Specular.Set(0.045f, 0.045f, 0.045f, 1.0f); // default 59 spec + div by Gamma exponent -> lin
- m_shaderResources.m_LMaterial.m_Smoothness = 10.0f;
-
- m_mtlFlags = nFlags;
- ZeroStruct(m_shaderItem);
-
- // Default shader.
- m_shaderName = "Illum";
- m_nShaderGenMask = 0;
-
- m_name = name;
- m_bRegetPublicParams = true;
- m_bKeepPublicParamsValues = false;
- m_bIgnoreNotifyChange = false;
- m_bDummyMaterial = false;
-
- m_pMatInfo = NULL;
- m_propagationFlags = 0;
-
- m_allowLayerActivation = true;
-}
-
-CMaterial::CMaterial(const CMaterial& rhs)
- : m_scFileAttributes{rhs.m_scFileAttributes}
- , m_pParent{nullptr}
- , m_shaderResources{rhs.m_shaderResources}
- , m_mtlFlags{rhs.m_mtlFlags}
- , m_shaderName{rhs.m_shaderName}
- , m_nShaderGenMask{rhs.m_nShaderGenMask}
- , m_bRegetPublicParams{rhs.m_bRegetPublicParams}
- , m_bKeepPublicParamsValues{rhs.m_bKeepPublicParamsValues}
- , m_bDummyMaterial{rhs.m_bDummyMaterial}
- , m_pMatInfo{nullptr}
- , m_propagationFlags{rhs.m_propagationFlags}
- , m_allowLayerActivation{rhs.m_allowLayerActivation}
- , m_dccMaterialHash(rhs.m_dccMaterialHash)
-{
- ZeroStruct(m_shaderItem);
- m_name = rhs.m_name;
-}
-
-//////////////////////////////////////////////////////////////////////////
-CMaterial::~CMaterial()
-{
- if (IsModified())
- {
- Save(false);
- }
-
- // Release used shader.
- SAFE_RELEASE(m_shaderItem.m_pShader);
- SAFE_RELEASE(m_shaderItem.m_pShaderResources);
-
- if (m_pMatInfo)
- {
- m_pMatInfo->SetUserData(0);
- m_pMatInfo = 0;
- }
-
- if (!m_subMaterials.empty())
- {
- for (int i = 0; i < m_subMaterials.size(); i++)
- {
- if (m_subMaterials[i])
- {
- m_subMaterials[i]->m_pParent = NULL;
- }
- }
-
- m_subMaterials.clear();
- }
-
- if (!IsPureChild() && !(GetFlags() & MTL_FLAG_UIMATERIAL))
- {
- // Unregister this material from manager.
- // Don't use here local variable m_pManager. Manager can be destroyed.
- if (GetIEditor()->GetMaterialManager())
- {
- GetIEditor()->GetMaterialManager()->DeleteItem(this);
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::SetName(const QString& name)
-{
- if (name != m_name)
- {
- QString oldName = GetFullName();
- m_name = name;
-
- if (!IsPureChild())
- {
- if (GetIEditor()->GetMaterialManager())
- {
- GetIEditor()->GetMaterialManager()->OnRenameItem(this, oldName);
- }
-
- if (m_pMatInfo)
- {
- GetIEditor()->Get3DEngine()->GetMaterialManager()->RenameMaterial(m_pMatInfo, GetName().toUtf8().data());
- }
- }
- else
- {
- if (m_pMatInfo)
- {
- m_pMatInfo->SetName(m_name.toUtf8().data());
- }
- }
-
- NotifyChanged();
- }
-
- if (m_shaderItem.m_pShaderResources)
- {
- // Only for correct warning message purposes.
- m_shaderItem.m_pShaderResources->SetMaterialName(m_name.toUtf8().data());
- }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-QString CMaterial::GetFilename() const
-{
- return GetIEditor()->GetMaterialManager()->MaterialToFilename(IsPureChild() && m_pParent ? m_pParent->m_name : m_name);
-}
-
-//////////////////////////////////////////////////////////////////////////
-int CMaterial::GetTextureFilenames(QStringList& outFilenames) const
-{
- for (auto& iter : m_shaderResources.m_TexturesResourcesMap )
- {
- const SEfResTexture* pTexture = (const SEfResTexture*) &(iter.second);
- QString name = QtUtil::ToQString(pTexture->m_Name);
- if (name.isEmpty())
- {
- AZ_Warning("Shaders System", false, "Error: CMaterial::GetTextureFilenames - texture slot name does not exist for slot %d", iter.first );
- continue;
- }
-
- // Collect image filenames
- if (IResourceCompilerHelper::IsSourceImageFormatSupported(name.toUtf8().data()))
- {
- stl::push_back_unique(outFilenames, Path::GamePathToFullPath(name));
- }
-
- // collect source files used in DCC tools
- QString dccFilename;
- if (CFileUtil::CalculateDccFilename(name, dccFilename))
- {
- stl::push_back_unique(outFilenames, Path::GamePathToFullPath(dccFilename));
- }
- }
-
- if (IsMultiSubMaterial())
- {
- for (int i = 0; i < GetSubMaterialCount(); ++i)
- {
- CMaterial* pSubMtl = GetSubMaterial(i);
- if (pSubMtl)
- {
- pSubMtl->GetTextureFilenames(outFilenames);
- }
- }
- }
-
- return outFilenames.size();
-}
-
-//////////////////////////////////////////////////////////////////////////
-int CMaterial::GetAnyTextureFilenames(QStringList& outFilenames) const
-{
- for ( auto& iter : m_shaderResources.m_TexturesResourcesMap )
- {
- QString name = QtUtil::ToQString( iter.second.m_Name);
- if (name.isEmpty())
- {
- continue;
- }
-
- // Collect any filenames
- stl::push_back_unique(outFilenames, Path::GamePathToFullPath(name));
- }
-
- if (IsMultiSubMaterial())
- {
- for (int i = 0; i < GetSubMaterialCount(); ++i)
- {
- CMaterial* pSubMtl = GetSubMaterial(i);
- if (pSubMtl)
- {
- pSubMtl->GetAnyTextureFilenames(outFilenames);
- }
- }
- }
-
- return outFilenames.size();
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::UpdateFileAttributes(bool useSourceControl)
-{
- QString filename = GetFilename();
- if (filename.isEmpty())
- {
- return;
- }
-
- m_scFileAttributes = CFileUtil::GetAttributes(filename.toUtf8().data(), useSourceControl);
-}
-
-//////////////////////////////////////////////////////////////////////////
-uint32 CMaterial::GetFileAttributes()
-{
- if (IsDummy())
- {
- return m_scFileAttributes;
- }
-
- if (IsPureChild() && m_pParent)
- {
- return m_pParent->GetFileAttributes();
- }
-
- UpdateFileAttributes();
- return m_scFileAttributes;
-};
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::SetShaderName(const QString& shaderName)
-{
- if (m_shaderName != shaderName)
- {
- m_bRegetPublicParams = true;
- m_bKeepPublicParamsValues = false;
-
- RecordUndo("Change Shader");
- }
-
- m_shaderName = shaderName;
- if (QString::compare(m_shaderName, "nodraw", Qt::CaseInsensitive) == 0)
- {
- m_mtlFlags |= MTL_FLAG_NODRAW;
- }
- else
- {
- m_mtlFlags &= ~MTL_FLAG_NODRAW;
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::CheckSpecialConditions()
-{
- if (QString::compare(m_shaderName, "nodraw", Qt::CaseInsensitive) == 0)
- {
- m_mtlFlags |= MTL_FLAG_NODRAW;
- }
- else
- {
- m_mtlFlags &= ~MTL_FLAG_NODRAW;
- }
-
- // If environment texture name have auto/nearest cubemap in it, force material to use auto cube-map for it.
- SEfResTexture* pTextureRes = m_shaderResources.GetTextureResource(EFTT_ENV);
- if (!pTextureRes)
- return;
-
- if (!pTextureRes->m_Name.empty())
- {
- const char* sAtPos;
- sAtPos = strstr(pTextureRes->m_Name.c_str(), "auto_2d");
- if (sAtPos)
- {
- pTextureRes->m_Sampler.m_eTexType = eTT_Auto2D; // Force Auto-2D
- }
- sAtPos = strstr(pTextureRes->m_Name.c_str(), "nearest_cubemap");
- if (sAtPos)
- {
- pTextureRes->m_Sampler.m_eTexType = eTT_NearestCube; // Force Nearest Cubemap
- }
- }
-
- // Force auto 2D map if user sets texture type
- if (pTextureRes->m_Sampler.m_eTexType == eTT_Auto2D)
- {
- pTextureRes->m_Name = "auto_2d";
- }
-
- // Force nearest cube map if user sets texture type
- if (pTextureRes->m_Sampler.m_eTexType == eTT_NearestCube)
- {
- pTextureRes->m_Name = "nearest_cubemap";
- m_mtlFlags |= MTL_FLAG_REQUIRE_NEAREST_CUBEMAP;
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool CMaterial::LoadShader()
-{
- if (m_bDummyMaterial)
- {
- return true;
- }
-
- CheckSpecialConditions();
-
- GetIEditor()->GetErrorReport()->SetCurrentValidatorItem(this);
-
- m_shaderResources.m_ResFlags = m_mtlFlags;
-
- QString sShader = m_shaderName;
- if (sShader.isEmpty())
- {
- sShader = "";
- }
-
- QByteArray n = m_name.toUtf8();
- m_shaderResources.m_szMaterialName = n.data();
- SShaderItem newShaderItem = GetIEditor()->GetRenderer()->EF_LoadShaderItem(sShader.toUtf8().data(), false, 0, &m_shaderResources, m_nShaderGenMask);
-
- // Shader not found
- if (newShaderItem.m_pShader && (newShaderItem.m_pShader->GetFlags() & EF_NOTFOUND) != 0)
- {
- CryWarning(VALIDATOR_MODULE_EDITOR, VALIDATOR_WARNING, "Failed to load shader \"%s\" in material \"%s\"", newShaderItem.m_pShader->GetName(), m_name.toUtf8().constData());
- }
-
- // Release previously used shader (Must be After new shader is loaded, for speed).
- SAFE_RELEASE(m_shaderItem.m_pShader);
- SAFE_RELEASE(m_shaderItem.m_pShaderResources);
-
- m_shaderItem = newShaderItem;
- if (!m_shaderItem.m_pShader)
- {
- CErrorRecord err;
-
- err.error = QObject::tr("Failed to Load Shader %1").arg(m_shaderName);
- err.pItem = this;
-
- GetIEditor()->GetErrorReport()->ReportError(err);
- GetIEditor()->GetErrorReport()->SetCurrentValidatorItem(NULL);
- return false;
- }
-
- IShader* pShader = m_shaderItem.m_pShader;
- m_nShaderGenMask = pShader->GetGenerationMask();
- if (pShader->GetFlags() & EF_NOPREVIEW)
- {
- m_mtlFlags |= MTL_FLAG_NOPREVIEW;
- }
- else
- {
- m_mtlFlags &= ~MTL_FLAG_NOPREVIEW;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // Reget shader parms.
- //////////////////////////////////////////////////////////////////////////
- if (m_bRegetPublicParams)
- {
- if (m_bKeepPublicParamsValues)
- {
- m_bKeepPublicParamsValues = false;
- m_publicVarsCache = XmlHelpers::CreateXmlNode("PublicParams");
-
- MaterialHelpers::SetXmlFromShaderParams(m_shaderResources, m_publicVarsCache);
- }
-
- m_shaderResources.m_ShaderParams = pShader->GetPublicParams();
- m_bRegetPublicParams = false;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // If we have XML node with public parameters loaded, apply it on shader parms.
- //////////////////////////////////////////////////////////////////////////
- if (m_publicVarsCache)
- {
- MaterialHelpers::SetShaderParamsFromXml(m_shaderResources, m_publicVarsCache);
- GetIEditor()->GetMaterialManager()->OnUpdateProperties(this, false);
- m_publicVarsCache = 0;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // Set shader parms.
- if (m_shaderItem.m_pShaderResources)
- {
- m_shaderItem.m_pShaderResources->SetShaderParams(&m_shaderResources, m_shaderItem.m_pShader);
- }
- //////////////////////////////////////////////////////////////////////////
-
- gEnv->pRenderer->UpdateShaderItem(&m_shaderItem, nullptr);
-
- //////////////////////////////////////////////////////////////////////////
- // Set Shader Params for material layers
- //////////////////////////////////////////////////////////////////////////
- if (m_pMatInfo)
- {
- UpdateMatInfo();
- }
-
- GetIEditor()->GetMaterialManager()->OnLoadShader(this);
- GetIEditor()->GetErrorReport()->SetCurrentValidatorItem(NULL);
-
- return true;
-}
-
-bool CMaterial::LoadMaterialLayers()
-{
- if (!m_pMatInfo)
- {
- return false;
- }
-
- if (m_shaderItem.m_pShader && m_shaderItem.m_pShaderResources)
- {
- // mask generation for base material shader
- uint32 nMaskGenBase = m_shaderItem.m_pShader->GetGenerationMask();
- SShaderGen* pShaderGenBase = m_shaderItem.m_pShader->GetGenerationParams();
-
- for (uint32 l(0); l < MTL_LAYER_MAX_SLOTS; ++l)
- {
- SMaterialLayerResources* pCurrLayer = &m_pMtlLayerResources[l];
- pCurrLayer->m_nFlags |= MTL_FLAG_NODRAW;
- if (!pCurrLayer->m_shaderName.isEmpty())
- {
- if (QString::compare(pCurrLayer->m_shaderName, "nodraw", Qt::CaseInsensitive) == 0)
- {
- // no shader = skip layer
- pCurrLayer->m_shaderName.clear();
- continue;
- }
-
- IShader* pNewShader = GetIEditor()->GetRenderer()->EF_LoadShader(pCurrLayer->m_shaderName.toUtf8().data(), 0);
-
- // Check if shader loaded
- if (!pNewShader || (pNewShader->GetFlags() & EF_NOTFOUND) != 0)
- {
- CryWarning(VALIDATOR_MODULE_EDITOR, VALIDATOR_WARNING, "Failed to load material layer shader \"%s\" in material \"%s\"", pCurrLayer->m_shaderName.toUtf8().constData(), m_pMatInfo->GetName());
- if (!pNewShader)
- {
- continue;
- }
- }
-
- if (!pCurrLayer->m_pMatLayer)
- {
- pCurrLayer->m_pMatLayer = m_pMatInfo->CreateLayer();
- }
-
- // mask generation for base material shader
- uint64 nMaskGenLayer = 0;
- SShaderGen* pShaderGenLayer = pNewShader->GetGenerationParams();
- if (pShaderGenBase && pShaderGenLayer)
- {
- for (int nLayerBit(0); nLayerBit < pShaderGenLayer->m_BitMask.size(); ++nLayerBit)
- {
- SShaderGenBit* pLayerBit = pShaderGenLayer->m_BitMask[nLayerBit];
-
- for (int nBaseBit(0); nBaseBit < pShaderGenBase->m_BitMask.size(); ++nBaseBit)
- {
- SShaderGenBit* pBaseBit = pShaderGenBase->m_BitMask[nBaseBit];
-
- // Need to check if flag name is common to both shaders (since flags values can be different), if so activate it on this layer
- if (nMaskGenBase & pBaseBit->m_Mask)
- {
- if (!pLayerBit->m_ParamName.empty() && !pBaseBit->m_ParamName.empty())
- {
- if (pLayerBit->m_ParamName == pBaseBit->m_ParamName)
- {
- nMaskGenLayer |= pLayerBit->m_Mask;
- break;
- }
- }
- }
- }
- }
- }
-
- // Reload with proper flags
- SShaderItem newShaderItem = GetIEditor()->GetRenderer()->EF_LoadShaderItem(pCurrLayer->m_shaderName.toUtf8().data(), false, 0, &pCurrLayer->m_shaderResources, nMaskGenLayer);
- if (!newShaderItem.m_pShader || (newShaderItem.m_pShader->GetFlags() & EF_NOTFOUND) != 0)
- {
- CryWarning(VALIDATOR_MODULE_EDITOR, VALIDATOR_WARNING, "Failed to load material layer shader \"%s\" in material \"%s\"", pCurrLayer->m_shaderName.toUtf8().data(), m_pMatInfo->GetName());
- if (!newShaderItem.m_pShader)
- {
- continue;
- }
- }
-
- SShaderItem& pCurrShaderItem = pCurrLayer->m_pMatLayer->GetShaderItem();
-
- if (newShaderItem.m_pShader)
- {
- newShaderItem.m_pShader->AddRef();
- }
-
- // Release previously used shader (Must be After new shader is loaded, for speed).
- SAFE_RELEASE(pCurrShaderItem.m_pShader);
- SAFE_RELEASE(pCurrShaderItem.m_pShaderResources);
- SAFE_RELEASE(newShaderItem.m_pShaderResources);
-
- pCurrShaderItem.m_pShader = newShaderItem.m_pShader;
- // Copy resources from base material
- pCurrShaderItem.m_pShaderResources = m_shaderItem.m_pShaderResources->Clone();
- pCurrShaderItem.m_nTechnique = newShaderItem.m_nTechnique;
- pCurrShaderItem.m_nPreprocessFlags = newShaderItem.m_nPreprocessFlags;
-
- // set default params
- if (pCurrLayer->m_bRegetPublicParams)
- {
- pCurrLayer->m_shaderResources.m_ShaderParams = pCurrShaderItem.m_pShader->GetPublicParams();
- }
-
- pCurrLayer->m_bRegetPublicParams = false;
-
- if (pCurrLayer->m_publicVarsCache)
- {
- MaterialHelpers::SetShaderParamsFromXml(pCurrLayer->m_shaderResources, pCurrLayer->m_publicVarsCache);
- pCurrLayer->m_publicVarsCache = 0;
- }
-
- if (pCurrShaderItem.m_pShaderResources)
- {
- pCurrShaderItem.m_pShaderResources->SetShaderParams(&pCurrLayer->m_shaderResources, pCurrShaderItem.m_pShader);
- }
-
- // Activate layer
- pCurrLayer->m_nFlags &= ~MTL_FLAG_NODRAW;
- }
- }
-
- return true;
- }
-
- return false;
-}
-
-//////////////////////////////////////////////////////////////////////////
-
-void CMaterial::UpdateMaterialLayers()
-{
- if (m_pMatInfo && m_shaderItem.m_pShaderResources)
- {
- m_pMatInfo->SetLayerCount(MTL_LAYER_MAX_SLOTS);
-
- uint8 nMaterialLayerFlags = 0;
-
- for (int l(0); l < MTL_LAYER_MAX_SLOTS; ++l)
- {
- SMaterialLayerResources* pCurrLayer = &m_pMtlLayerResources[l];
- if (pCurrLayer && !pCurrLayer->m_shaderName.isEmpty() && pCurrLayer->m_pMatLayer)
- {
- pCurrLayer->m_pMatLayer->SetFlags(pCurrLayer->m_nFlags);
- m_pMatInfo->SetLayer(l, pCurrLayer->m_pMatLayer);
-
- if ((pCurrLayer->m_nFlags & MTL_LAYER_USAGE_NODRAW))
- {
- if (!QString::compare(pCurrLayer->m_shaderName, "frozenlayerwip", Qt::CaseInsensitive))
- {
- nMaterialLayerFlags |= MTL_LAYER_FROZEN;
- }
- }
- }
- }
-
- if (m_shaderItem.m_pShaderResources)
- {
- m_shaderItem.m_pShaderResources->SetMtlLayerNoDrawFlags(nMaterialLayerFlags);
- }
- }
-}
-
-void CMaterial::UpdateMatInfo()
-{
- if (m_pMatInfo)
- {
- // Mark material invalid.
- m_pMatInfo->SetFlags(m_mtlFlags);
- m_pMatInfo->SetShaderItem(m_shaderItem);
- m_pMatInfo->SetShaderName(m_shaderName.toUtf8().constData());
- m_pMatInfo->SetSurfaceType(m_surfaceType.toUtf8().constData());
-
- LoadMaterialLayers();
- UpdateMaterialLayers();
-
- m_pMatInfo->SetMaterialLinkName(m_linkedMaterial.toUtf8().data());
-
- if (IsMultiSubMaterial())
- {
- m_pMatInfo->SetSubMtlCount(m_subMaterials.size());
- for (unsigned int i = 0; i < m_subMaterials.size(); i++)
- {
- if (m_subMaterials[i])
- {
- m_pMatInfo->SetSubMtl(i, m_subMaterials[i]->GetMatInfo());
- }
- else
- {
- m_pMatInfo->SetSubMtl(i, NULL);
- }
- }
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-CVarBlock* CMaterial::GetPublicVars(SInputShaderResources& pShaderResources)
-{
- return MaterialHelpers::GetPublicVars(pShaderResources);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::SetShaderParamPublicScript()
-{
- IShader* pShader = m_shaderItem.m_pShader;
-
- if (!pShader)
- {
- return;
- }
-
- if (m_shaderResources.m_ShaderParams.size() == 0 || pShader->GetPublicParams().size() == 0)
- {
- return;
- }
-
- // We want to inspect public shader param and paste the m_script into our shader resource param script
- for (int i = 0; i < m_shaderResources.m_ShaderParams.size(); ++i)
- {
- SShaderParam ¤tShaderParam = m_shaderResources.m_ShaderParams.at(i);
- for (int j = 0; j < pShader->GetPublicParams().size(); ++j)
- {
- const SShaderParam &publicShaderParam = pShader->GetPublicParams().at(j);
- if ((currentShaderParam.m_Name == publicShaderParam.m_Name) && (currentShaderParam.m_Type == publicShaderParam.m_Type))
- {
- currentShaderParam.m_Script = publicShaderParam.m_Script;
- }
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::SetPublicVars(CVarBlock* pPublicVars, CMaterial* pMtl)
-{
- if (!pMtl->GetShaderResources().m_ShaderParams.empty())
- {
- RecordUndo("Set Public Vars");
- }
-
- MaterialHelpers::SetPublicVars(pPublicVars, pMtl->GetShaderResources(), pMtl->GetShaderItem().m_pShaderResources, pMtl->GetShaderItem().m_pShader);
-
- GetIEditor()->GetMaterialManager()->OnUpdateProperties(this, false);
-}
-
-//////////////////////////////////////////////////////////////////////////
-CVarBlock* CMaterial::GetShaderGenParamsVars()
-{
- return MaterialHelpers::GetShaderGenParamsVars(GetShaderItem().m_pShader, m_nShaderGenMask);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::SetShaderGenParamsVars(CVarBlock* pBlock)
-{
- RecordUndo("Change Shader GenMask");
-
- uint64 nGenMask = MaterialHelpers::SetShaderGenParamsVars(GetShaderItem().m_pShader, pBlock);
- if (m_nShaderGenMask != nGenMask)
- {
- m_bRegetPublicParams = true;
- m_bKeepPublicParamsValues = true;
- m_nShaderGenMask = nGenMask;
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-unsigned int CMaterial::GetTexmapUsageMask() const
-{
- int mask = 0;
- if (m_shaderItem.m_pShader)
- {
- IShader* pTempl = m_shaderItem.m_pShader;
- if (pTempl)
- {
- mask = pTempl->GetUsedTextureTypes();
- }
- }
- return mask;
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::Update()
-{
- // Reload shader item with new resources and shader.
- LoadShader();
-
- // Mark library as modified.
- SetModified();
-
- GetIEditor()->SetModifiedFlag();
-
- // When modifying pure child, mark his parent as modified.
- if (IsPureChild() && m_pParent)
- {
- m_pParent->SetModified();
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::Serialize(SerializeContext& ctx)
-{
- //CBaseLibraryItem::Serialize( ctx );
-
- XmlNodeRef node = ctx.node;
- if (ctx.bLoading)
- {
- m_bIgnoreNotifyChange = true;
- m_bRegetPublicParams = true;
-
- SInputShaderResources& sr = m_shaderResources;
- m_shaderResources = defaultShaderResource;
-
- // Loading
- int flags = m_mtlFlags;
- if (node->getAttr("MtlFlags", flags))
- {
- m_mtlFlags &= ~(MTL_FLAGS_SAVE_MASK);
- m_mtlFlags |= (flags & (MTL_FLAGS_SAVE_MASK));
- }
-
- uint32 dccMaterialHash = 0;
- node->getAttr("DccMaterialHash", dccMaterialHash);
- SetDccMaterialHash(dccMaterialHash);
-
- if (!IsMultiSubMaterial())
- {
- node->getAttr("Shader", m_shaderName);
- node->getAttr("GenMask", m_nShaderGenMask);
-
- if (!(m_mtlFlags & MTL_64BIT_SHADERGENMASK))
- {
- uint32 nShaderGenMask = 0;
- node->getAttr("GenMask", nShaderGenMask);
- m_nShaderGenMask = nShaderGenMask;
- }
- else
- {
- node->getAttr("GenMask", m_nShaderGenMask);
- }
-
- // Remap flags if needed
- if (!(m_mtlFlags & MTL_64BIT_SHADERGENMASK))
- {
- m_nShaderGenMask = GetIEditor()->GetRenderer()->EF_GetRemapedShaderMaskGen(m_shaderName.toUtf8().data(), m_nShaderGenMask);
- m_mtlFlags |= MTL_64BIT_SHADERGENMASK;
- }
-
- if (node->getAttr("StringGenMask", m_pszShaderGenMask))
- {
- m_nShaderGenMask = GetIEditor()->GetRenderer()->EF_GetShaderGlobalMaskGenFromString(m_shaderName.toUtf8().data(), m_pszShaderGenMask.toUtf8().data(), m_nShaderGenMask); // get common mask gen
- }
- else
- {
- // version doens't has string gen mask yet ? Remap flags if needed
- m_nShaderGenMask = GetIEditor()->GetRenderer()->EF_GetRemapedShaderMaskGen(m_shaderName.toUtf8().data(), m_nShaderGenMask, ((m_mtlFlags & MTL_64BIT_SHADERGENMASK) != 0));
- }
- m_mtlFlags |= MTL_64BIT_SHADERGENMASK;
-
- node->getAttr("SurfaceType", m_surfaceType);
- node->getAttr("LayerAct", m_allowLayerActivation);
-
- MaterialHelpers::SetLightingFromXml(sr, node);
-
- MaterialHelpers::SetTexturesFromXml(sr, node);
- MaterialHelpers::MigrateXmlLegacyData(sr, node);
- }
-
- //////////////////////////////////////////////////////////////////////////
- // Check if we have a link name and if any propagation settings were
- // present
- //////////////////////////////////////////////////////////////////////////
- XmlNodeRef pLinkName = node->findChild("MaterialLinkName");
- if (pLinkName)
- {
- m_linkedMaterial = pLinkName->getAttr("name");
- }
- else
- {
- m_linkedMaterial = QString();
- }
-
- XmlNodeRef pPropagationFlags = node->findChild("MaterialPropagationFlags");
- if (pPropagationFlags)
- {
- pPropagationFlags->getAttr("flags", m_propagationFlags);
- }
- else
- {
- m_propagationFlags = 0;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // Check if we have vertex deform.
- //////////////////////////////////////////////////////////////////////////
- MaterialHelpers::SetVertexDeformFromXml(m_shaderResources, node);
-
- // Serialize sub materials.
-
- const auto ResizeSubMaterials = [this](size_t count)
- {
- for (size_t i = count; i < m_subMaterials.size(); ++i)
- {
- if (auto& pSubMtl = m_subMaterials[i])
- {
- pSubMtl->m_pParent = nullptr;
- }
- }
- m_subMaterials.resize(count);
- };
-
- XmlNodeRef childsNode = node->findChild("SubMaterials");
- if (childsNode && !ctx.bIgnoreChilds)
- {
- QString name;
- int nSubMtls = childsNode->getChildCount();
- ResizeSubMaterials(nSubMtls);
- for (int i = 0; i < nSubMtls; i++)
- {
- auto& pSubMtl = m_subMaterials[i];
- XmlNodeRef mtlNode = childsNode->getChild(i);
- if (mtlNode->isTag("Material"))
- {
- mtlNode->getAttr("Name", name);
- if (pSubMtl && pSubMtl->IsPureChild())
- {
- pSubMtl->SetName(name);
- }
- else
- {
- if (pSubMtl)
- {
- pSubMtl->m_pParent = nullptr;
- }
-
- pSubMtl = new CMaterial(name, MTL_FLAG_PURE_CHILD);
- pSubMtl->m_pParent = this;
- }
-
- SerializeContext childCtx(ctx);
- childCtx.node = mtlNode;
- pSubMtl->Serialize(childCtx);
-
- pSubMtl->m_shaderResources.m_SortPrio = nSubMtls - i - 1;
- }
- else
- {
- if (pSubMtl)
- {
- pSubMtl->m_pParent = nullptr;
- pSubMtl = nullptr;
- }
-
- if (mtlNode->getAttr("Name", name))
- {
- CMaterial* pMtl = GetIEditor()->GetMaterialManager()->LoadMaterial(name);
- if (pMtl && !pMtl->IsMultiSubMaterial())
- {
- pSubMtl = pMtl;
- }
- }
- }
- }
-
- m_subMaterials.erase(std::remove(m_subMaterials.begin(), m_subMaterials.end(), nullptr), m_subMaterials.end());
- }
- else
- {
- ResizeSubMaterials(0);
- }
-
- UpdateMatInfo();
-
- //////////////////////////////////////////////////////////////////////////
- // Load public parameters.
- //////////////////////////////////////////////////////////////////////////
- m_publicVarsCache = node->findChild("PublicParams");
-
- //////////////////////////////////////////////////////////////////////////
- // Load material layers data
- //////////////////////////////////////////////////////////////////////////
- XmlNodeRef mtlLayersNode = node->findChild("MaterialLayers");
- if (mtlLayersNode)
- {
- int nChildCount = min((int) MTL_LAYER_MAX_SLOTS, (int) mtlLayersNode->getChildCount());
- for (int l = 0; l < nChildCount; ++l)
- {
- XmlNodeRef layerNode = mtlLayersNode->getChild(l);
- if (layerNode)
- {
- if (layerNode->getAttr("Name", m_pMtlLayerResources[l].m_shaderName))
- {
- m_pMtlLayerResources[l].m_bRegetPublicParams = true;
-
- bool bNoDraw = false;
- layerNode->getAttr("NoDraw", bNoDraw);
-
- m_pMtlLayerResources[l].m_publicVarsCache = layerNode->findChild("PublicParams");
-
- if (bNoDraw)
- {
- m_pMtlLayerResources[l].m_nFlags |= MTL_LAYER_USAGE_NODRAW;
- }
- else
- {
- m_pMtlLayerResources[l].m_nFlags &= ~MTL_LAYER_USAGE_NODRAW;
- }
-
-
- bool bFadeOut = false;
- layerNode->getAttr("FadeOut", bFadeOut);
- if (bFadeOut)
- {
- m_pMtlLayerResources[l].m_nFlags |= MTL_LAYER_USAGE_FADEOUT;
- }
- else
- {
- m_pMtlLayerResources[l].m_nFlags &= ~MTL_LAYER_USAGE_FADEOUT;
- }
- }
- }
- }
- }
-
- if (ctx.bUndo)
- {
- LoadShader();
- UpdateMatInfo();
- }
-
- m_bIgnoreNotifyChange = false;
-
- // If copy pasting or undo send update event.
- if (ctx.bCopyPaste || ctx.bUndo)
- {
- NotifyChanged();
- }
-
- // NotifyChanged calls SetModified but since we just loaded it, its not actually changed.
- SetModified(false);
- }
- else // If !ctx.bLoading
- {
- int extFlags = MTL_64BIT_SHADERGENMASK;
- {
- const QString& name = GetName();
- const size_t len = name.length();
- if (len > 4 && strstri(name.toUtf8().data() + (len - 4), "_con"))
- {
- extFlags |= MTL_FLAG_CONSOLE_MAT;
- }
- }
-
- // Saving.
- node->setAttr("MtlFlags", m_mtlFlags | extFlags);
- node->setAttr("DccMaterialHash", GetDccMaterialHash());
-
- if (!IsMultiSubMaterial())
- {
- // store shader gen bit mask string
- m_pszShaderGenMask = GetIEditor()->GetRenderer()->EF_GetStringFromShaderGlobalMaskGen(m_shaderName.toUtf8().data(), m_nShaderGenMask).c_str();
-
- node->setAttr("Shader", m_shaderName.toUtf8().data());
- node->setAttr("GenMask", m_nShaderGenMask);
- node->setAttr("StringGenMask", m_pszShaderGenMask.toUtf8().data());
- node->setAttr("SurfaceType", m_surfaceType.toUtf8().data());
-
- //if (!m_shaderName.IsEmpty() && (stricmp(m_shaderName,"nodraw") != 0))
- {
- MaterialHelpers::SetXmlFromLighting(m_shaderResources, node);
- MaterialHelpers::SetXmlFromTextures(m_shaderResources, node);
- }
- }
-
- //////////////////////////////////////////////////////////////////////////
- // Save out the link name if present and the propagation flags
- //////////////////////////////////////////////////////////////////////////
- if (!m_linkedMaterial.isEmpty())
- {
- XmlNodeRef pLinkName = node->newChild("MaterialLinkName");
- pLinkName->setAttr("name", m_linkedMaterial.toUtf8().data());
- }
-
- if (m_propagationFlags)
- {
- XmlNodeRef pPropagationFlags = node->newChild("MaterialPropagationFlags");
- pPropagationFlags->setAttr("flags", m_propagationFlags);
- }
-
- //////////////////////////////////////////////////////////////////////////
- // Check if we have vertex deform.
- //////////////////////////////////////////////////////////////////////////
- MaterialHelpers::SetXmlFromVertexDeform(m_shaderResources, node);
-
- if (GetSubMaterialCount() > 0)
- {
- // Serialize sub materials.
-
- // Let's not serialize empty submaterials at the end of the list.
- // Note that IDs of the remaining submaterials stay intact.
- int count = GetSubMaterialCount();
- while (count > 0 && !GetSubMaterial(count - 1))
- {
- --count;
- }
-
- XmlNodeRef childsNode = node->newChild("SubMaterials");
-
- for (int i = 0; i < count; ++i)
- {
- CMaterial* const pSubMtl = GetSubMaterial(i);
- if (pSubMtl && pSubMtl->IsPureChild())
- {
- XmlNodeRef mtlNode = childsNode->newChild("Material");
- mtlNode->setAttr("Name", pSubMtl->GetName().toUtf8().data());
- SerializeContext childCtx(ctx);
- childCtx.node = mtlNode;
- pSubMtl->Serialize(childCtx);
- }
- else
- {
- XmlNodeRef mtlNode = childsNode->newChild("MaterialRef");
- if (pSubMtl)
- {
- mtlNode->setAttr("Name", pSubMtl->GetName().toUtf8().data());
- }
- }
- }
- }
-
- //////////////////////////////////////////////////////////////////////////
- // Save public parameters.
- //////////////////////////////////////////////////////////////////////////
- if (m_publicVarsCache)
- {
- node->addChild(m_publicVarsCache);
- }
- else if (!m_shaderResources.m_ShaderParams.empty())
- {
- XmlNodeRef publicsNode = node->newChild("PublicParams");
- MaterialHelpers::SetXmlFromShaderParams(m_shaderResources, publicsNode);
- }
-
- //////////////////////////////////////////////////////////////////////////
- // Save material layers data
- //////////////////////////////////////////////////////////////////////////
-
- bool bMaterialLayers = false;
- for (int l(0); l < MTL_LAYER_MAX_SLOTS; ++l)
- {
- if (!m_pMtlLayerResources[l].m_shaderName.isEmpty())
- {
- bMaterialLayers = true;
- break;
- }
- }
-
- if (bMaterialLayers)
- {
- XmlNodeRef mtlLayersNode = node->newChild("MaterialLayers");
- for (int l(0); l < MTL_LAYER_MAX_SLOTS; ++l)
- {
- XmlNodeRef layerNode = mtlLayersNode->newChild("Layer");
- if (!m_pMtlLayerResources[l].m_shaderName.isEmpty())
- {
- layerNode->setAttr("Name", m_pMtlLayerResources[l].m_shaderName.toUtf8().data());
- layerNode->setAttr("NoDraw", m_pMtlLayerResources[l].m_nFlags & MTL_LAYER_USAGE_NODRAW);
- layerNode->setAttr("FadeOut", m_pMtlLayerResources[l].m_nFlags & MTL_LAYER_USAGE_FADEOUT);
-
- if (m_pMtlLayerResources[l].m_publicVarsCache)
- {
- layerNode->addChild(m_pMtlLayerResources[l].m_publicVarsCache);
- }
- else if (!m_pMtlLayerResources[l].m_shaderResources.m_ShaderParams.empty())
- {
- XmlNodeRef publicsNode = layerNode->newChild("PublicParams");
- MaterialHelpers::SetXmlFromShaderParams(m_pMtlLayerResources[l].m_shaderResources, publicsNode);
- }
- }
- }
- }
-
- if (GetSubMaterialCount() == 0 || GetParent())
- {
- node->setAttr("LayerAct", m_allowLayerActivation);
- }
- }
-}
-
-/*
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::SerializePublics( XmlNodeRef &node,bool bLoading )
-{
-if (bLoading)
-{
-}
-else
-{
-if (m_shaderParams.empty())
-return;
-XmlNodeRef publicsNode = node->newChild( "PublicParams" );
-
-for (int i = 0; i < m_shaderParams.size(); i++)
-{
-XmlNodeRef paramNode = node->newChild( "Param" );
-SShaderParam *pParam = &m_shaderParams[i];
-paramNode->setAttr( "Name",pParam->m_Name );
-switch (pParam->m_Type)
-{
-case eType_BYTE:
-paramNode->setAttr( "Value",(int)pParam->m_Value.m_Byte );
-paramNode->setAttr( "Type",(int)pParam->m_Value.m_Byte );
-break;
-case eType_SHORT:
-paramNode->setAttr( "Value",(int)pParam->m_Value.m_Short );
-break;
-case eType_INT:
-paramNode->setAttr( "Value",(int)pParam->m_Value.m_Int );
-break;
-case eType_FLOAT:
-paramNode->setAttr( "Value",pParam->m_Value.m_Float );
-break;
-case eType_STRING:
-paramNode->setAttr( "Value",pParam->m_Value.m_String );
-break;
-case eType_FCOLOR:
-paramNode->setAttr( "Value",Vec3(pParam->m_Value.m_Color[0],pParam->m_Value.m_Color[1],pParam->m_Value.m_Color[2]) );
-break;
-case eType_VECTOR:
-paramNode->setAttr( "Value",Vec3(pParam->m_Value.m_Vector[0],pParam->m_Value.m_Vector[1],pParam->m_Value.m_Vector[2]) );
-break;
-}
-}
-}
-}
-*/
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::AssignToEntity(IRenderNode* pEntity)
-{
- assert(pEntity);
- pEntity->SetMaterial(GetMatInfo());
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool CMaterial::IsBreakable2D() const
-{
- if ((GetFlags() & MTL_FLAG_NODRAW) != 0)
- {
- return false;
- }
-
- const QString& surfaceTypeName = GetSurfaceTypeName();
- if (ISurfaceTypeManager* pSurfaceManager = GetIEditor()->Get3DEngine()->GetMaterialManager()->GetSurfaceTypeManager())
- {
- ISurfaceType* pSurfaceType = pSurfaceManager->GetSurfaceTypeByName(surfaceTypeName.toUtf8().data());
- if (pSurfaceType && pSurfaceType->GetBreakable2DParams() != 0)
- {
- return true;
- }
- }
-
- int count = GetSubMaterialCount();
- for (int i = 0; i < count; ++i)
- {
- const CMaterial* pSub = GetSubMaterial(i);
- if (!pSub)
- {
- continue;
- }
- if (pSub->IsBreakable2D())
- {
- return true;
- }
- }
- return false;
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::SetFromMatInfo(_smart_ptr pMatInfo)
-{
- assert(pMatInfo);
-
- m_shaderName = "";
-
- ClearMatInfo();
- SetModified(true);
-
- m_mtlFlags = pMatInfo->GetFlags();
- if (m_mtlFlags & MTL_FLAG_MULTI_SUBMTL)
- {
- // Create sub materials.
- SetSubMaterialCount(pMatInfo->GetSubMtlCount());
- for (int i = 0; i < GetSubMaterialCount(); i++)
- {
- _smart_ptr pChildMatInfo = pMatInfo->GetSubMtl(i);
- if (!pChildMatInfo)
- {
- continue;
- }
-
- if (pChildMatInfo->GetFlags() & MTL_FLAG_PURE_CHILD)
- {
- CMaterial* existingChild = GetSubMaterial(i);
- if (existingChild)
- {
- existingChild->SetFromMatInfo(pChildMatInfo);
- }
- else
- {
- CMaterial* pChild = new CMaterial(pChildMatInfo->GetName(), pChildMatInfo->GetFlags());
- pChild->SetFromMatInfo(pChildMatInfo);
- SetSubMaterial(i, pChild);
- }
- }
- else
- {
- CMaterial* pChild = GetIEditor()->GetMaterialManager()->LoadMaterial(pChildMatInfo->GetName());
- pChild->SetFromMatInfo(pChildMatInfo);
- SetSubMaterial(i, pChild);
- }
- }
- }
- else
- {
- SetShaderItem(pMatInfo->GetShaderItem());
-
- if (m_shaderItem.m_pShaderResources)
- {
- m_shaderResources = SInputShaderResources(m_shaderItem.m_pShaderResources);
- }
- if (m_shaderItem.m_pShader)
- {
- // Get name of template.
- IShader* pTemplShader = m_shaderItem.m_pShader;
- if (pTemplShader)
- {
- m_nShaderGenMask = pTemplShader->GetGenerationMask();
- }
- }
- m_shaderName = pMatInfo->GetShaderName();
- ISurfaceType* pSurfaceType = pMatInfo->GetSurfaceType();
- if (pSurfaceType)
- {
- m_surfaceType = pSurfaceType->GetName();
- }
- else
- {
- m_surfaceType = "";
- }
- }
-
- // Mark as not modified.
- SetModified(false);
-
- // Material link names
- if (const char* szLinkName = pMatInfo->GetMaterialLinkName())
- {
- m_linkedMaterial = szLinkName;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // Assign mat info.
- m_pMatInfo = pMatInfo;
- m_pMatInfo->SetUserData(this);
- AddRef(); // Let IMaterial keep a reference to us.
-}
-
-//////////////////////////////////////////////////////////////////////////
-int CMaterial::GetSubMaterialCount() const
-{
- return m_subMaterials.size();
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::SetSubMaterialCount(int nSubMtlsCount)
-{
- RecordUndo("Multi Material Change");
- m_subMaterials.resize(nSubMtlsCount);
- UpdateMatInfo();
- NotifyChanged();
-}
-
-//////////////////////////////////////////////////////////////////////////
-CMaterial* CMaterial::GetSubMaterial(int index) const
-{
- const int nSubMats = m_subMaterials.size();
- assert(index >= 0 && index < nSubMats);
-
- if (index < 0 || index >= nSubMats)
- {
- return NULL;
- }
-
- return m_subMaterials[index];
-}
-
-//////////////////////////////////////////////////////////////////////////
-int CMaterial::FindMaterialIndex(const QString& name)
-{
- for (int i = 0; i < m_subMaterials.size(); ++i)
- {
- if (m_subMaterials[i]->GetName().compare(name) == 0)
- {
- return i;
- }
- }
-
- return -1;
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::SetSubMaterial(int nSlot, CMaterial* mtl)
-{
- RecordUndo("Multi Material Change");
- assert(nSlot >= 0 && nSlot < m_subMaterials.size());
- if (mtl)
- {
- if (mtl->IsMultiSubMaterial())
- {
- return;
- }
- if (mtl->IsPureChild())
- {
- mtl->m_pParent = this;
- }
- }
-
- if (m_subMaterials[nSlot])
- {
- m_subMaterials[nSlot]->m_pParent = NULL;
- }
- m_subMaterials[nSlot] = mtl;
-
- if (!m_subMaterials[nSlot])
- {
- m_subMaterials.erase(m_subMaterials.begin() + nSlot);
- }
-
- UpdateMatInfo();
- NotifyChanged();
-}
-
-//////////////////////////////////////////////////////////////////////////
-// This method will populate for the material editor the name and tool tip of the
-// different textures of the current material
-//CVarBlock* CMaterial::UpdateTextureNames(AZStd::unordered_map& textureVarsMap)
-CVarBlock* CMaterial::UpdateTextureNames(CSmartVariableArray textureVars[EFTT_MAX])
-{
- CVarBlock* pTextureSlots = new CVarBlock;
- IShader* pTemplShader = m_shaderItem.m_pShader;
- int nTech = max(0, m_shaderItem.m_nTechnique);
- SShaderTexSlots* pShaderSlots = pTemplShader ? pTemplShader->GetUsedTextureSlots(nTech) : nullptr;
-
- for (EEfResTextures nTexSlot = EEfResTextures(0); nTexSlot < EFTT_MAX; nTexSlot = EEfResTextures(nTexSlot + 1))
- {
- if (!MaterialHelpers::IsAdjustableTexSlot((EEfResTextures)nTexSlot))
- { // do not take into account virtual slots (such as smoothness - normal's alpha)
- // in theory this case should not happen as it is filtered from the source list.
- continue;
- }
-
- IVariable* pVar = textureVars[nTexSlot].GetVar();
- SShaderTextureSlot* pSlot = pShaderSlots ? pShaderSlots->m_UsedTextureSlots[nTexSlot] : nullptr;
-
- // If slot is NULL, fall back to default name - name here is the context name (i.e. diffuse, normal..)
- // and not the actual texture file name
- pVar->SetName(pSlot && pSlot->m_Name.length() ? pSlot->m_Name.c_str() : MaterialHelpers::LookupTexName((EEfResTextures) nTexSlot));
- pVar->SetDescription(pSlot && pSlot->m_Description.length() ? pSlot->m_Description.c_str() : MaterialHelpers::LookupTexDesc((EEfResTextures)nTexSlot));
-
- int flags = pVar->GetFlags();
-
- // TODO: slot->m_TexType gives expected sampler type (2D vs Cube etc). Could check/extract this here.
-
- // Not sure why this needs COLLAPSED added again, but without this all the slots expand
- flags |= IVariable::UI_COLLAPSED;
-
- //clear the auto-expand flag if there is no texture assigned.
- SEfResTexture* pTextureRes = m_shaderResources.GetTextureResource(nTexSlot);
- bool noTextureName = (!pTextureRes ? true : pTextureRes->m_Name.empty());
-
- if (noTextureName)
- {
- flags &= ~IVariable::UI_AUTO_EXPAND;
- }
-
- // if slot is NULL, but we have reflection information, this slot isn't used - make the variable invisible
- // unless there's a texture in the slot
- if (pShaderSlots && !pSlot && noTextureName)
- {
- flags |= IVariable::UI_INVISIBLE;
- }
- else
- {
- flags &= ~IVariable::UI_INVISIBLE;
- }
-
- pVar->SetFlags(flags);
-
- pTextureSlots->AddVariable(pVar);
- }
-
- return pTextureSlots;
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::ClearAllSubMaterials()
-{
- RecordUndo("Multi Material Change");
- for (int i = 0; i < m_subMaterials.size(); i++)
- {
- if (m_subMaterials[i])
- {
- m_subMaterials[i]->m_pParent = NULL;
- m_subMaterials[i] = NULL;
- }
- }
- UpdateMatInfo();
- NotifyChanged();
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::Validate()
-{
- if (IsDummy())
- {
- CErrorRecord err;
- err.error = QObject::tr("Material %1 file not found").arg(GetName());
- err.pItem = this;
- GetIEditor()->GetErrorReport()->ReportError(err);
- }
- // Reload shader.
- LoadShader();
-
- // Validate sub materials.
- for (int i = 0; i < m_subMaterials.size(); i++)
- {
- if (m_subMaterials[i])
- {
- m_subMaterials[i]->Validate();
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::GatherUsedResources(CUsedResources& resources)
-{
- if (!IsUsed())
- {
- return;
- }
-
- SInputShaderResources& sr = GetShaderResources();
- for (auto iter = sr.m_TexturesResourcesMap.begin(); iter != sr.m_TexturesResourcesMap.end(); ++iter)
- {
- SEfResTexture* pTexture = &iter->second;
- if (!pTexture->m_Name.empty())
- {
- resources.Add(pTexture->m_Name.c_str());
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool CMaterial::CanModify(bool bSkipReadOnly)
-{
- if (m_bDummyMaterial)
- {
- return false;
- }
-
- if (IsPureChild() && GetParent())
- {
- return GetParent()->CanModify(bSkipReadOnly);
- }
-
- if (bSkipReadOnly)
- {
- // If read only or in pack, do not save.
- if (m_scFileAttributes & (SCC_FILE_ATTRIBUTE_READONLY | SCC_FILE_ATTRIBUTE_INPAK))
- {
- return false;
- }
-
- // Managed file must be checked out.
- if ((m_scFileAttributes & SCC_FILE_ATTRIBUTE_MANAGED) && !(m_scFileAttributes & SCC_FILE_ATTRIBUTE_CHECKEDOUT))
- {
- return false;
- }
- }
- else
- {
- // Only if in pack.
- if (m_scFileAttributes & (SCC_FILE_ATTRIBUTE_INPAK))
- {
- return false;
- }
- }
- return true;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool CMaterial::Save(bool bSkipReadOnly, const QString& fullPath)
-{
- // Save our parent
- if (IsPureChild())
- {
- if (m_pParent)
- {
- return m_pParent->Save(bSkipReadOnly);
- }
- return false;
- }
-
- if (m_mtlFlags & MTL_FLAG_UIMATERIAL)
- {
- return false;
- }
-
- GetFileAttributes();
-
- if (bSkipReadOnly && IsModified())
- {
- // If read only or in pack, do not save.
- if (m_scFileAttributes & (SCC_FILE_ATTRIBUTE_READONLY | SCC_FILE_ATTRIBUTE_INPAK))
- {
- gEnv->pLog->LogError("Can't save material %s (read-only)", GetName().toUtf8().constData());
- }
-
- // Managed file must be checked out.
- if ((m_scFileAttributes & SCC_FILE_ATTRIBUTE_MANAGED) && !(m_scFileAttributes & SCC_FILE_ATTRIBUTE_CHECKEDOUT))
- {
- gEnv->pLog->LogError("Can't save material %s (need to check out)", GetName().toUtf8().constData());
- }
- }
-
- if (!CanModify(bSkipReadOnly))
- {
- return false;
- }
-
-
- // If filename is empty do not not save.
- if (GetFilename().isEmpty())
- {
- return false;
- }
-
- // Save material XML to a file that corresponds to the material name with extension .mtl.
- XmlNodeRef mtlNode = XmlHelpers::CreateXmlNode("Material");
- CBaseLibraryItem::SerializeContext ctx(mtlNode, false);
- Serialize(ctx);
-
- bool saveSucceeded = false;
- if (fullPath.isEmpty())
- {
- // If no filepath was specified, get the filename using the relative path/unique identifier of this material
- saveSucceeded = XmlHelpers::SaveXmlNode(GetIEditor()->GetFileUtil(), mtlNode, GetFilename().toUtf8().data());
- }
- else
- {
- // If a filepath was specified, save to the specified location
- saveSucceeded = XmlHelpers::SaveXmlNode(GetIEditor()->GetFileUtil(), mtlNode, fullPath.toUtf8().data());
- }
-
- if (saveSucceeded)
- {
- // If material successfully saved, clear modified flag.
- SetModified(false);
- for (int i = 0; i < GetSubMaterialCount(); ++i)
- {
- CMaterial* pSubMaterial = GetSubMaterial(i);
- if (pSubMaterial)
- {
- pSubMaterial->SetModified(false);
- }
- }
- }
- else
- {
- AZ_Warning("Material Editor", false, "Material '%s' failed to save successfully. Check that the file is writable and has been successfully checked out in source control.", m_name.toUtf8().data());
- }
-
- return saveSucceeded;
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::ClearMatInfo()
-{
- m_pMatInfo = nullptr;
-}
-
-//////////////////////////////////////////////////////////////////////////
-_smart_ptr CMaterial::GetMatInfo(bool bUseExistingEngineMaterial)
-{
- if (!m_pMatInfo)
- {
- if (m_bDummyMaterial)
- {
- m_pMatInfo = GetIEditor()->Get3DEngine()->GetMaterialManager()->GetDefaultMaterial();
- AddRef(); // Always keep dummy materials.
- return m_pMatInfo;
- }
-
- if (!IsMultiSubMaterial() && !m_shaderItem.m_pShader)
- {
- LoadShader();
- }
-
- if (!IsPureChild())
- {
- if (bUseExistingEngineMaterial)
- {
- m_pMatInfo = GetIEditor()->Get3DEngine()->GetMaterialManager()->FindMaterial(GetName().toUtf8().data());
- }
-
- if (!m_pMatInfo)
- {
- m_pMatInfo = GetIEditor()->Get3DEngine()->GetMaterialManager()->CreateMaterial(GetName().toUtf8().data(), m_mtlFlags);
- }
- }
- else
- {
- // Pure child should not be registered with the name.
- m_pMatInfo = GetIEditor()->Get3DEngine()->GetMaterialManager()->CreateMaterial("", m_mtlFlags);
- m_pMatInfo->SetName(GetName().toUtf8().data());
- }
- m_mtlFlags = m_pMatInfo->GetFlags();
- UpdateMatInfo();
-
- if (m_pMatInfo->GetUserData() != this)
- {
- m_pMatInfo->SetUserData(this);
- AddRef(); // Let IMaterial keep a reference to us.
- }
- }
-
- return m_pMatInfo;
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::NotifyChanged()
-{
- if (m_bIgnoreNotifyChange)
- {
- return;
- }
-
- if (!CanModify() && !IsModified() && CUndo::IsRecording())
- {
- // Display Warning message.
- Warning("Modifying read only material %s\r\nChanges will not be saved!", GetName().toUtf8().data());
- }
-
- SetModified();
-
- GetIEditor()->GetMaterialManager()->OnItemChanged(this);
-}
-
-//////////////////////////////////////////////////////////////////////////
-class CUndoMaterial
- : public IUndoObject
-{
-public:
- CUndoMaterial(CMaterial* pMaterial, const char* undoDescription, bool bForceUpdate)
- {
- assert(pMaterial);
-
- // Stores the current state of this object.
- m_undoDescription = undoDescription;
-
- m_bIsSubMaterial = pMaterial->IsPureChild();
-
- if (m_bIsSubMaterial)
- {
- CMaterial* pParentMaterial = pMaterial->GetParent();
- assert(pParentMaterial && !pParentMaterial->IsPureChild());
- if (pParentMaterial && !pParentMaterial->IsPureChild())
- {
- bool bFound = false;
- const int subMaterialCount = pParentMaterial->GetSubMaterialCount();
- for (int i = 0; i < subMaterialCount; ++i)
- {
- CMaterial* pSubMaterial = pParentMaterial->GetSubMaterial(i);
- if (pSubMaterial == pMaterial)
- {
- bFound = true;
- m_subMaterialName = pSubMaterial->GetName();
- break;
- }
- }
- assert(bFound);
- m_mtlName = pParentMaterial->GetName();
- }
- }
- else
- {
- m_mtlName = pMaterial->GetName();
- }
-
- // Save material XML to a file that corresponds to the material name with extension .mtl.
- m_undo = XmlHelpers::CreateXmlNode("Material");
- CBaseLibraryItem::SerializeContext ctx(m_undo, false);
- pMaterial->Serialize(ctx);
- m_bForceUpdate = bForceUpdate;
- }
-
-protected:
- virtual void Release() { delete this; };
-
- virtual int GetSize()
- {
- return sizeof(*this) + m_undoDescription.length() + m_mtlName.length();
- }
-
- virtual QString GetDescription() { return m_undoDescription; };
-
- virtual void Undo(bool bUndo)
- {
- CMaterial* pMaterial = GetMaterial();
-
- assert(pMaterial);
- if (!pMaterial)
- {
- return;
- }
-
- if (bUndo)
- {
- // Save current object state.
- m_redo = XmlHelpers::CreateXmlNode("Material");
- CBaseLibraryItem::SerializeContext ctx(m_redo, false);
- pMaterial->Serialize(ctx);
- }
-
- CBaseLibraryItem::SerializeContext ctx(m_undo, true);
- ctx.bUndo = bUndo;
- pMaterial->Serialize(ctx);
-
- if (m_bForceUpdate && bUndo)
- {
- GetIEditor()->GetMaterialManager()->OnUpdateProperties(pMaterial, true);
- }
- }
-
- virtual void Redo()
- {
- CMaterial* pMaterial = GetMaterial();
-
- if (!pMaterial)
- {
- return;
- }
-
- CBaseLibraryItem::SerializeContext ctx(m_redo, true);
- ctx.bUndo = true;
- pMaterial->Serialize(ctx);
-
- if (m_bForceUpdate)
- {
- GetIEditor()->GetMaterialManager()->OnUpdateProperties(pMaterial, true);
- }
- }
-
-private:
- CMaterial* GetMaterial()
- {
- CMaterial* pMaterial = (CMaterial*)GetIEditor()->GetMaterialManager()->FindItemByName(m_mtlName);
- assert(pMaterial);
-
- if (pMaterial && m_bIsSubMaterial)
- {
- bool bFound = false;
- const int subMaterialCount = pMaterial->GetSubMaterialCount();
- for (int i = 0; i < subMaterialCount; ++i)
- {
- CMaterial* pSubMaterial = pMaterial->GetSubMaterial(i);
- if (pSubMaterial && (pSubMaterial->GetName() == m_subMaterialName))
- {
- bFound = true;
- pMaterial = pSubMaterial;
- break;
- }
- }
- assert(bFound && pMaterial);
- }
-
- return pMaterial;
- }
-
- QString m_undoDescription;
- QString m_mtlName;
- bool m_bIsSubMaterial;
- QString m_subMaterialName;
- XmlNodeRef m_undo;
- XmlNodeRef m_redo;
- bool m_bForceUpdate;
-};
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::RecordUndo(const char* sText, bool bForceUpdate)
-{
- if (CUndo::IsRecording())
- {
- CUndo::Record(new CUndoMaterial(this, sText, bForceUpdate));
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::OnMakeCurrent()
-{
- UpdateFileAttributes(false);
-
- // If Shader not yet loaded, load it now.
- if (!m_shaderItem.m_pShader)
- {
- LoadShader();
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::SetSurfaceTypeName(const QString& surfaceType)
-{
- m_surfaceType = surfaceType;
- UpdateMatInfo();
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::Reload()
-{
- if (IsPureChild())
- {
- if (m_pParent)
- {
- m_pParent->Reload();
- }
- return;
- }
- if (IsDummy())
- {
- return;
- }
-
- XmlNodeRef mtlNode = GetISystem()->LoadXmlFromFile(GetFilename().toUtf8().data());
- if (!mtlNode)
- {
- return;
- }
- CBaseLibraryItem::SerializeContext serCtx(mtlNode, true);
- serCtx.bUndo = true; // Simulate undo.
- Serialize(serCtx);
-
- // was called by Simulate undo.
- //UpdateMatInfo();
- //NotifyChanged();
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::LinkToMaterial(const QString& name)
-{
- m_linkedMaterial = name;
- UpdateMatInfo();
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::DisableHighlightForFrame()
-{
- SetHighlightFlags(0);
-}
-
-static ColorF Interpolate(const ColorF& a, const ColorF& b, float phase)
-{
- const float oneMinusPhase = 1.0f - phase;
- return ColorF(b.r * phase + a.r * oneMinusPhase,
- b.g * phase + a.g * oneMinusPhase,
- b.b * phase + a.b * oneMinusPhase,
- b.a * phase + a.a * oneMinusPhase);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::UpdateHighlighting()
-{
- if (!(GetFlags() & MTL_FLAG_NODRAW))
- {
- const CInputLightMaterial& original = m_shaderResources.m_LMaterial;
- CInputLightMaterial lm = original;
-
- ColorF highlightColor(0.0f, 0.0f, 0.0f, 1.0f);
- float highlightIntensity = 0.0f;
-
- MAKE_SURE(GetIEditor()->GetMaterialManager(), return );
- GetIEditor()->GetMaterialManager()->GetHighlightColor(&highlightColor, &highlightIntensity, m_highlightFlags);
-
- if (m_shaderItem.m_pShaderResources)
- {
- ColorF diffuseColor = Interpolate(original.m_Diffuse, highlightColor, highlightIntensity);
- ColorF emissiveColor = Interpolate(original.m_Emittance, highlightColor, highlightIntensity);
- ColorF specularColor = Interpolate(original.m_Specular, highlightColor, highlightIntensity);
-
- // [Shader System TO DO] remove this hard coded association!
- m_shaderItem.m_pShaderResources->SetColorValue(EFTT_DIFFUSE, diffuseColor);
- m_shaderItem.m_pShaderResources->SetColorValue(EFTT_SPECULAR, specularColor);
- m_shaderItem.m_pShaderResources->SetColorValue(EFTT_EMITTANCE, emissiveColor);
-
- m_shaderItem.m_pShaderResources->UpdateConstants(m_shaderItem.m_pShader);
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CMaterial::SetHighlightFlags(int highlightFlags)
-{
- m_highlightFlags = highlightFlags;
-
- UpdateHighlighting();
-}
-
-
-void CMaterial::SetShaderItem(const SShaderItem& shaderItem)
-{
- SAFE_RELEASE(m_shaderItem.m_pShader);
- SAFE_RELEASE(m_shaderItem.m_pShaderResources);
-
- m_shaderItem = shaderItem;
- if (m_shaderItem.m_pShader)
- {
- m_shaderItem.m_pShader->AddRef();
- }
- if (m_shaderItem.m_pShaderResources)
- {
- m_shaderItem.m_pShaderResources->AddRef();
- }
-}
diff --git a/Code/Sandbox/Editor/Material/Material.h b/Code/Sandbox/Editor/Material/Material.h
deleted file mode 100644
index b311744e14..0000000000
--- a/Code/Sandbox/Editor/Material/Material.h
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
-* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-* its licensors.
-*
-* For complete copyright and license terms please see the LICENSE at the root of this
-* distribution (the "License"). All use of this software is governed by the License,
-* or, if provided, by the license below or the license accompanying this file. Do not
-* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-*
-*/
-// Original file Copyright Crytek GMBH or its affiliates, used under license.
-
-#ifndef CRYINCLUDE_EDITOR_MATERIAL_MATERIAL_H
-#define CRYINCLUDE_EDITOR_MATERIAL_MATERIAL_H
-#pragma once
-
-#include
-#include
-#include "BaseLibraryItem.h"
-#include "Include/IEditorMaterial.h"
-#include "Util/Variable.h"
-#include
-
-// forward declarations,
-class CMaterialManager;
-class CVarBlock;
-
-enum eMTL_PROPAGATION
-{
- MTL_PROPAGATE_OPACITY = 1 << 0,
- MTL_PROPAGATE_LIGHTING = 1 << 1,
- MTL_PROPAGATE_ADVANCED = 1 << 2,
- MTL_PROPAGATE_TEXTURES = 1 << 3,
- MTL_PROPAGATE_SHADER_PARAMS = 1 << 4,
- MTL_PROPAGATE_SHADER_GEN = 1 << 5,
- MTL_PROPAGATE_VERTEX_DEF = 1 << 6,
- MTL_PROPAGATE_LAYER_PRESETS = 1 << 7,
- MTL_PROPAGATE_MATERIAL_SETTINGS = 1 << 8,
- MTL_PROPAGATE_ALL = (
- MTL_PROPAGATE_OPACITY |
- MTL_PROPAGATE_LIGHTING |
- MTL_PROPAGATE_ADVANCED |
- MTL_PROPAGATE_TEXTURES |
- MTL_PROPAGATE_SHADER_PARAMS |
- MTL_PROPAGATE_SHADER_GEN |
- MTL_PROPAGATE_VERTEX_DEF |
- MTL_PROPAGATE_LAYER_PRESETS |
- MTL_PROPAGATE_MATERIAL_SETTINGS),
- MTL_PROPAGATE_RESERVED = 1 << 9
-};
-
-/** CMaterial class
- Every Material is a member of material library.
- Materials can have child sub materials,
- Sub materials are applied to the same geometry of the parent material in the other material slots.
-*/
-
-struct SMaterialLayerResources
-{
- SMaterialLayerResources()
- : m_nFlags(MTL_LAYER_USAGE_REPLACEBASE)
- , m_bRegetPublicParams(true)
- , m_pMatLayer(0)
- {
- }
-
- uint8 m_nFlags;
- bool m_bRegetPublicParams;
- QString m_shaderName;
-
- _smart_ptr< IMaterialLayer > m_pMatLayer;
- SInputShaderResources m_shaderResources;
- XmlNodeRef m_publicVarsCache;
-};
-
-AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
-class CRYEDIT_API CMaterial
- : public IEditorMaterial
-{
-AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
-public:
- //////////////////////////////////////////////////////////////////////////
- CMaterial(const QString& name, int nFlags = 0);
- CMaterial(const CMaterial& rhs);
- ~CMaterial();
-
- virtual EDataBaseItemType GetType() const { return EDB_TYPE_MATERIAL; };
-
- void SetName(const QString& name);
-
- //////////////////////////////////////////////////////////////////////////
- QString GetFullName() const { return m_name; };
-
- //////////////////////////////////////////////////////////////////////////
- // File properties of the material.
- //////////////////////////////////////////////////////////////////////////
- QString GetFilename() const;
-
- //! Collect filenames of texture sources used in material
- //! Return number of filenames
- int GetTextureFilenames(QStringList& outFilenames) const;
- int GetAnyTextureFilenames(QStringList& outFilenames) const;
-
- void UpdateFileAttributes(bool useSourceControl = true);
- uint32 GetFileAttributes();
- //////////////////////////////////////////////////////////////////////////
-
- //! Sets one or more material flags from EMaterialFlags enum.
- void SetFlags(int flags) { m_mtlFlags = flags; };
- //! Query this material flags.
- virtual int GetFlags() const { return m_mtlFlags; }
- bool IsMultiSubMaterial() const { return (m_mtlFlags & MTL_FLAG_MULTI_SUBMTL) != 0; };
- bool IsPureChild() const { return (m_mtlFlags & MTL_FLAG_PURE_CHILD) != 0; }
-
- // Check if material is used.
- bool IsUsed() const { /*return m_nUseCount > 0 || (m_mtlFlags & MTL_FLAG_ALWAYS_USED);*/ return true; };
-
- virtual void GatherUsedResources(CUsedResources& resources);
-
- //! Set name of shader used by this material.
- void SetShaderName(const QString& shaderName);
- //! Get name of shader used by this material.
- QString GetShaderName() const { return m_shaderName; };
-
- virtual SInputShaderResources& GetShaderResources() { return m_shaderResources; };
-
- //! Get public parameters of material in variable block.
- CVarBlock* GetPublicVars(SInputShaderResources& pShaderResources);
-
- //! Set the shader public param m_script variable into our own m_script, script contains min/max for a given shader param value
- void SetShaderParamPublicScript();
-
- //! Sets variable block of public shader parameters.
- //! VarBlock must be in same format as returned by GetPublicVars().
- void SetPublicVars(CVarBlock* pPublicVars, CMaterial* pMtl);
-
- //! Update names/descriptions in this variable array, return a variable block for replacing
- CVarBlock* UpdateTextureNames(CSmartVariableArray textureVars[EFTT_MAX]);
-// [Shader System] - Do To: add back with map usage: CVarBlock* UpdateTextureNames(AZStd::unordered_map& textureVarsMap);
-
- //////////////////////////////////////////////////////////////////////////
- CVarBlock* GetShaderGenParamsVars();
- void SetShaderGenParamsVars(CVarBlock* pBlock);
- uint64 GetShaderGenMask() { return m_nShaderGenMask; }
- void SetShaderGenMask(uint64 mask) { m_nShaderGenMask = mask; }
-
- //! Return variable block of shader params.
- SShaderItem& GetShaderItem() { return m_shaderItem; };
-
- //! Return material layers resources
- SMaterialLayerResources* GetMtlLayerResources() { return m_pMtlLayerResources; };
-
- //! Get texture map usage mask for shader in this material.
- unsigned int GetTexmapUsageMask() const;
-
- //! Load new shader.
- bool LoadShader();
-
- //! Reload shader, update all shader parameters.
- virtual void Update();
-
- // Reload material settings from file.
- // NOTICE: The function will remove all the sub-materials and recreate them!
- void Reload();
-
- //! Serialize material settings to xml.
- virtual void Serialize(SerializeContext& ctx);
-
- //! Assign this material to static geometry.
- void AssignToEntity(IRenderNode* pEntity);
-
- //////////////////////////////////////////////////////////////////////////
- // Surface types.
- //////////////////////////////////////////////////////////////////////////
- virtual void SetSurfaceTypeName(const QString& surfaceType);
- virtual const QString& GetSurfaceTypeName() const { return m_surfaceType; };
- bool IsBreakable2D() const;
-
- //////////////////////////////////////////////////////////////////////////
- // Child Sub materials.
- //////////////////////////////////////////////////////////////////////////
- //! Get number of sub materials childs.
- int GetSubMaterialCount() const;
- //! Set number of sub materials childs.
- void SetSubMaterialCount(int nSubMtlsCount);
- //! Get sub material child by index.
- CMaterial* GetSubMaterial(int index) const;
- //! Find sub material index by name
- int FindMaterialIndex(const QString& name);
- // Set a material to the sub materials slot.
- // Use NULL material pointer to clear slot.
- void SetSubMaterial(int nSlot, CMaterial* mtl);
- //! Remove all sub materials, does not change number of sub material slots.
- void ClearAllSubMaterials();
-
- //! Return pointer to engine material.
- virtual _smart_ptr GetMatInfo(bool bUseExistingEngineMaterial = true);
- // Clear stored pointer to engine material.
- void ClearMatInfo();
-
- //! Validate materials for errors.
- void Validate();
-
- // Check if material file can be modified.
- // Will check file attributes if it is not read only.
- bool CanModify(bool bSkipReadOnly = true);
-
- // Save material to file.
- virtual bool Save(bool bSkipReadOnly = true, const QString& fullPath = "");
-
- // Dummy material is just a placeholder item for materials that have not been found on disk.
- void SetDummy(bool bDummy) { m_bDummyMaterial = bDummy; }
- bool IsDummy() const { return m_bDummyMaterial != 0; }
-
- // Called by material manager when material selected as a current material.
- void OnMakeCurrent();
-
- void SetFromMatInfo(_smart_ptr pMatInfo);
-
- // Link a submaterial by name (used for value propagation in CMaterialUI)
- void LinkToMaterial(const QString& name);
- const QString& GetLinkedMaterialName() { return m_linkedMaterial; }
-
- // Return parent material for submaterial
- CMaterial* GetParent() const {return m_pParent; }
-
- //! Loads material layers
- bool LoadMaterialLayers();
- //! Updates material layers
- void UpdateMaterialLayers();
-
- void SetHighlightFlags(int highlightFlags);
- void UpdateHighlighting();
- virtual void DisableHighlightForFrame();
- void RecordUndo(const char* sText, bool bForceUpdate = false);
-
- int GetPropagationFlags() const { return m_propagationFlags; }
- void SetPropagationFlags(const int flags) { m_propagationFlags = flags; }
-
- bool LayerActivationAllowed() const { return m_allowLayerActivation; }
- void SetLayerActivation(bool allowed) { m_allowLayerActivation = allowed; }
-
- uint32 GetDccMaterialHash() const { return m_dccMaterialHash; }
- void SetDccMaterialHash(AZ::u32 hash) { m_dccMaterialHash = hash; }
- void SetShaderItem(const SShaderItem& shaderItem);
-
-private:
- void UpdateMatInfo();
- void CheckSpecialConditions();
-
- void NotifyChanged();
-
-private:
- //////////////////////////////////////////////////////////////////////////
- // Variables.
- //////////////////////////////////////////////////////////////////////////
- QString m_shaderName;
- QString m_surfaceType;
- QString m_linkedMaterial;
-
- //! Material flags.
- int m_mtlFlags;
-
- // Hash for DCC material attributes, used to check if .dccmtl has changed
- // If so, the source .mtl file will need to be rebuilt
- uint32 m_dccMaterialHash;
-
- // Parent material, Only valid for Pure Childs.
- CMaterial* m_pParent;
-
- //////////////////////////////////////////////////////////////////////////
- // Shader resources.
- //////////////////////////////////////////////////////////////////////////
- AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
- SShaderItem m_shaderItem;
- SInputShaderResources m_shaderResources;
- AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
-
- //CVarBlockPtr m_shaderParamsVar;
- //! Common shader flags.
- uint64 m_nShaderGenMask;
- QString m_pszShaderGenMask;
-
- AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
- SMaterialLayerResources m_pMtlLayerResources[MTL_LAYER_MAX_SLOTS];
-
- _smart_ptr m_pMatInfo;
-
- XmlNodeRef m_publicVarsCache;
-
- //! Array of sub materials.
- std::vector<_smart_ptr > m_subMaterials;
- AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
-
- int m_nUseCount;
- uint32 m_scFileAttributes;
-
- unsigned char m_highlightFlags;
-
- // The propagation flags are a bit combination of the MTL_PROPAGATION enum above
- // and determine which properties get propagated to an optional linked material
- // during ui editing
- int m_propagationFlags;
-
- //! Material Used in level.
- unsigned int m_bDummyMaterial : 1; // Dummy material, name specified but material file not found.
- unsigned int m_bIgnoreNotifyChange : 1; // Do not send notifications about changes.
- unsigned int m_bRegetPublicParams : 1;
- unsigned int m_bKeepPublicParamsValues : 1;
-
- bool m_allowLayerActivation;
-};
-
-#endif // CRYINCLUDE_EDITOR_MATERIAL_MATERIAL_H
diff --git a/Code/Sandbox/Editor/Material/MaterialBrowser.cpp b/Code/Sandbox/Editor/Material/MaterialBrowser.cpp
deleted file mode 100644
index e39a29a47d..0000000000
--- a/Code/Sandbox/Editor/Material/MaterialBrowser.cpp
+++ /dev/null
@@ -1,1792 +0,0 @@
-/*
-* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-* its licensors.
-*
-* For complete copyright and license terms please see the LICENSE at the root of this
-* distribution (the "License"). All use of this software is governed by the License,
-* or, if provided, by the license below or the license accompanying this file. Do not
-* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-*
-*/
-// Original file Copyright Crytek GMBH or its affiliates, used under license.
-
-#include "EditorDefs.h"
-
-#include "MaterialBrowser.h"
-
-// Qt
-#include
-
-// AzQtComponents
-#include
-
-// AzToolsFramework
-#include
-
-// Editor
-#include "MaterialManager.h"
-#include "Clipboard.h"
-#include "MaterialImageListCtrl.h"
-#include "StringDlg.h"
-
-AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
-#include
-AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
-
-
-enum
-{
- MENU_UNDEFINED = CMaterialImageListCtrl::MaterialBrowserWidgetActionsStart,
- MENU_CUT,
- MENU_COPY,
- MENU_COPY_NAME,
- MENU_PASTE,
- MENU_EXPLORE,
- MENU_DUPLICATE,
- MENU_EXTRACT,
- MENU_RENAME,
- MENU_DELETE,
- MENU_RESET,
- MENU_ASSIGNTOSELECTION,
- MENU_SELECTASSIGNEDOBJECTS,
- MENU_NUM_SUBMTL,
- MENU_ADDNEW,
- MENU_ADDNEW_MULTI,
- MENU_CONVERT_TO_MULTI,
- MENU_SUBMTL_MAKE,
- MENU_SUBMTL_CLEAR,
- MENU_SAVE_TO_FILE,
- MENU_SAVE_TO_FILE_MULTI,
- MENU_MERGE,
-
- MENU_SCM_ADD,
- MENU_SCM_CHECK_OUT,
- MENU_SCM_UNDO_CHECK_OUT,
- MENU_SCM_GET_LATEST,
- MENU_SCM_GET_LATEST_TEXTURES,
-};
-
-static QAction* CreateTreeViewAction(const char* text, const QKeySequence& shortcut, QWidget* shortcutContext, MaterialBrowserWidget* widget, void (MaterialBrowserWidget::*slot)())
-{
- QAction* action = new QAction(text, shortcutContext);
- action->setShortcut(shortcut);
- QObject::connect(action, &QAction::triggered, widget, slot);
- widget->addAction(action);
- return action;
-}
-
-//////////////////////////////////////////////////////////////////////////
-MaterialBrowserWidget::MaterialBrowserWidget(QWidget* parent)
- : QWidget(parent)
- , m_ui(new Ui::MaterialBrowser)
- , m_filterModel(new MaterialBrowserFilterModel(this))
-{
- using namespace AzToolsFramework::AssetBrowser;
-
- m_ui->setupUi(this);
-
- // create some permanent (for the life of this widget) actions for shortcut handling
- m_cutAction = CreateTreeViewAction("Cut", QKeySequence::Cut, m_ui->treeView, this, &MaterialBrowserWidget::OnCut);
- m_copyAction = CreateTreeViewAction("Copy", QKeySequence::Copy, m_ui->treeView, this, &MaterialBrowserWidget::OnCopy);
- m_pasteAction = CreateTreeViewAction("Paste", QKeySequence::Paste, m_ui->treeView, this, &MaterialBrowserWidget::OnPaste);
- m_duplicateAction = CreateTreeViewAction("Duplicate", QKeySequence(Qt::CTRL + Qt::Key_D), m_ui->treeView, this, &MaterialBrowserWidget::OnDuplicate);
- m_deleteAction = CreateTreeViewAction("Delete", QKeySequence::Delete, m_ui->treeView, this, &MaterialBrowserWidget::DeleteItem);
- m_renameItemAction = CreateTreeViewAction("Rename", Qt::Key_F2, m_ui->treeView, this, &MaterialBrowserWidget::OnRenameItem);
- m_addNewMaterialAction = CreateTreeViewAction("Add New Material", Qt::Key_Insert, m_ui->treeView, this, &MaterialBrowserWidget::OnAddNewMaterial);
-
- MaterialBrowserWidgetBus::Handler::BusConnect();
-
- // Get the asset browser model
- AssetBrowserComponentRequestBus::BroadcastResult(m_assetBrowserModel, &AssetBrowserComponentRequests::GetAssetBrowserModel);
- AZ_Assert(m_assetBrowserModel, "Failed to get filebrowser model");
-
- // Set up the filter model
- m_filterModel->setSourceModel(m_assetBrowserModel);
- m_ui->treeView->setModel(m_filterModel.data());
- m_ui->treeView->SetThumbnailContext("MaterialBrowser");
- m_ui->treeView->SetShowSourceControlIcons(true);
-
- m_ui->m_searchWidget->Setup(true, false);
- m_filterModel->SetSearchFilter(m_ui->m_searchWidget);
- connect(m_ui->m_searchWidget->GetFilter().data(), &AssetBrowserEntryFilter::updatedSignal, m_filterModel.data(), &MaterialBrowserFilterModel::SearchFilterUpdated);
-
- // Call LoadState to initialize the AssetBrowserTreeView's QTreeViewStateSaver
- // This must be done BEFORE StartRecordUpdateJobs(). A race condition from the update jobs was causing a 5-10% crash/hang when opening the Material Editor.
- m_ui->treeView->SetName("MaterialBrowserTreeView");
-
- // Override the AssetBrowserTreeView's custom context menu
- disconnect(m_ui->treeView, &QWidget::customContextMenuRequested, 0, 0);
- connect(m_ui->treeView, &QWidget::customContextMenuRequested, this, [=](const QPoint& point)
- {
- CMaterialBrowserRecord record;
- TryGetSelectedRecord(record);
- ShowContextMenu(record, point);
- });
-
- connect(m_ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &MaterialBrowserWidget::OnSelectionChanged);
- //Wait for the signal emitted on record update jobs finished, then we can restore the selection for the previous selected item
- connect(this, SIGNAL(refreshSelection()), this, SLOT(OnRefreshSelection()));
-
- connect(this, SIGNAL(materialAdded()), this, SLOT(OnMaterialAdded()));
-
- m_bIgnoreSelectionChange = false;
- m_bItemsValid = true;
-
- m_pMatMan = GetIEditor()->GetMaterialManager();
- m_pMatMan->AddListener(this);
- m_pListener = NULL;
-
- m_viewType = VIEW_LEVEL;
- m_pMaterialImageListCtrl = NULL;
- m_pLastActiveMultiMaterial = 0;
-
- m_bNeedReload = false;
-
- m_bHighlightMaterial = false;
- m_timeOfHighlight = 0;
-
- m_bShowOnlyCheckedOut = false;
-
- GetIEditor()->RegisterNotifyListener(this);
-}
-
-//////////////////////////////////////////////////////////////////////////
-MaterialBrowserWidget::~MaterialBrowserWidget()
-{
- m_filterModel->CancelRecordUpdateJobs();
- m_filterModel->deleteLater();
- m_ui->treeView->SaveState();
- GetIEditor()->UnregisterNotifyListener(this);
-
- m_pMaterialImageListCtrl = NULL;
- m_pMatMan->RemoveListener(this);
- ClearItems();
-
- if (m_bHighlightMaterial)
- {
- m_pMatMan->SetHighlightedMaterial(0);
- }
-
- MaterialBrowserWidgetBus::Handler::BusDisconnect();
-}
-
-//////////////////////////////////////////////////////////////////////////
-void MaterialBrowserWidget::ClearItems()
-{
- m_bIgnoreSelectionChange = true;
-
- if (m_pMaterialImageListCtrl)
- {
- QMaterialImageListModel* materialModel =
- qobject_cast(m_pMaterialImageListCtrl->model());
- Q_ASSERT(materialModel);
- materialModel->DeleteAllItems();
- }
-
- m_pLastActiveMultiMaterial = nullptr;
- m_delayedSelection = nullptr;
-
- m_bIgnoreSelectionChange = false;
-}
-
-//////////////////////////////////////////////////////////////////////////
-void MaterialBrowserWidget::TryLoadRecordMaterial(CMaterialBrowserRecord& record)
-{
- // If material already loaded ignore.
- if (record.m_material)
- {
- return;
- }
-
- m_bIgnoreSelectionChange = true;
- // Try to load material for it.
- record.m_material = m_pMatMan->LoadMaterial(record.GetRelativeFilePath().c_str(), false);
-
- m_filterModel->SetRecord(record);
- m_bIgnoreSelectionChange = false;
-}
-
-//////////////////////////////////////////////////////////////////////////
-void MaterialBrowserWidget::TickRefreshMaterials()
-{
- if (m_bHighlightMaterial)
- {
- uint32 t = GetTickCount();
- if ((t - m_timeOfHighlight) > 300)
- {
- m_bHighlightMaterial = false;
- m_pMatMan->SetHighlightedMaterial(0);
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void MaterialBrowserWidget::OnEditorNotifyEvent(EEditorNotifyEvent event)
-{
- switch (event)
- {
- case eNotify_OnIdleUpdate:
- {
- TickRefreshMaterials();
- }
- break;
- case eNotify_OnBeginLoad:
- {
- //Need to make sure the selection is cleared before clearing the record map
- SetSelectedItem(nullptr, nullptr, true);
- m_filterModel->ClearRecordMap();
- }
- break;
- case eNotify_OnCloseScene:
- {
- m_filterModel->ShowOnlyLevelMaterials(false, true);
- ClearItems();
- m_ui->treeView->SaveState();
- //Need to make sure the selection is cleared before clearing the record map
- SetSelectedItem(nullptr, nullptr, true);
- m_filterModel->ClearRecordMap();
- }
- break;
- case eNotify_OnEndNewScene:
- case eNotify_OnEndSceneOpen:
- {
- m_filterModel->ShowOnlyLevelMaterials(false, true);
- m_filterModel->StartRecordUpdateJobs();
- if (m_ui->treeView->IsTreeViewSavingReady())
- {
- m_ui->treeView->ApplyTreeViewSnapshot();
- }
- }
- break;
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void MaterialBrowserWidget::SetSelectedItem(_smart_ptr material, const TMaterialBrowserRecords* pMarkedRecords, bool selectInTreeView)
-{
- if (m_bIgnoreSelectionChange)
- {
- return;
- }
-
- m_bIgnoreSelectionChange = true;
- if (pMarkedRecords)
- {
- m_markedRecords = *pMarkedRecords;
- }
- else
- {
- m_markedRecords.clear();
- }
-
- m_pMatMan->SetCurrentFolder("");
-
- _smart_ptr selectedMaterial = material;
- if (material && material->IsPureChild())
- {
- selectedMaterial = material->GetParent();
- }
-
- // Clear the delayed selection whenever a new material is selected
- m_delayedSelection = nullptr;
-
- // In some cases, such as when SetSelectedItem is called from the material picker or the rollup bar,
- // the material has not yet been selected in the tree-view, so that item must be selected here
- bool validSelection = false;
- if (selectInTreeView)
- {
- if (!selectedMaterial)
- {
- // Clear the current selection so that the upcoming call to RefreshSelected()
- // doesn't try to refresh the previously selected material which may be invalid
- m_ui->treeView->clearSelection();
- m_ui->treeView->setCurrentIndex(QModelIndex());
- }
- else if (m_markedRecords.size() > 0)
- {
- QItemSelection selection;
- for (CMaterialBrowserRecord record : m_markedRecords)
- {
- QModelIndex currentIndex = m_filterModel->GetIndexFromMaterial(record.m_material);
- if (currentIndex.isValid())
- {
- selection.push_back(QItemSelectionRange(currentIndex));
- validSelection = true;
- }
- }
- m_ui->treeView->selectionModel()->select(selection, QItemSelectionModel::ClearAndSelect);
- }
- else
- {
- QModelIndex currentIndex = m_filterModel->GetIndexFromMaterial(selectedMaterial);
- if (currentIndex.isValid())
- {
- m_ui->treeView->selectionModel()->setCurrentIndex(currentIndex, QItemSelectionModel::ClearAndSelect);
- validSelection = true;
-
- // Now that the parent material is selected in the browser,
- // select the appropriate sub-material in the material preview window
- if (selectedMaterial == material->GetParent())
- {
- for (int i = 0; i < selectedMaterial->GetSubMaterialCount(); ++i)
- {
- if (material == selectedMaterial->GetSubMaterial(i))
- {
- m_selectedSubMaterialIndex = i;
- break;
- }
- }
- }
- }
- else
- {
- // Hold on to a pointer to this material, listen for the MaterialFinishedProcessing event,
- // and attempt to re-select this material if it finishes processing in the background
- m_delayedSelection = selectedMaterial;
- }
- }
- }
-
- RefreshSelected();
-
- if (!selectedMaterial)
- {
- QModelIndex current = m_ui->treeView->currentIndex();
- QString path;
- while (current.isValid())
- {
- path = '/' + current.data().toString() + path;
- current = current.parent();
- }
- m_pMatMan->SetCurrentFolder((Path::GetEditingGameDataFolder() + path.toUtf8().data()).c_str());
- }
- else
- {
- if (selectedMaterial->IsMultiSubMaterial() && m_selectedSubMaterialIndex >= 0)
- {
- selectedMaterial = selectedMaterial->GetSubMaterial(m_selectedSubMaterialIndex);
- }
- }
-
- if (m_pListener)
- {
- // Don't call the listener event if we attempted to select an item in the tree view and failed
- // to prevent the material parameter editor from switching to a new material if it wasn't actually selected
- if (!selectInTreeView || validSelection)
- {
- m_pListener->OnBrowserSelectItem(selectedMaterial, false);
- }
- //Update the selected item if no material is selected in tree view
- else if (!selectedMaterial && selectInTreeView)
- {
- m_pListener->OnBrowserSelectItem(nullptr, false);
- }
- }
-
- m_timeOfHighlight = GetTickCount();
- m_pMatMan->SetHighlightedMaterial(selectedMaterial);
- if (selectedMaterial)
- {
- m_bHighlightMaterial = true;
- }
-
- std::vector<_smart_ptr > markedMaterials;
- if (pMarkedRecords)
- {
- for (size_t i = 0; i < pMarkedRecords->size(); ++i)
- {
- markedMaterials.push_back((*pMarkedRecords)[i].m_material);
- }
- }
- m_pMatMan->SetMarkedMaterials(markedMaterials);
-
- m_bIgnoreSelectionChange = false;
-}
-
-//////////////////////////////////////////////////////////////////////////
-void MaterialBrowserWidget::SelectItem(IDataBaseItem* pItem, [[maybe_unused]] IDataBaseItem* pParentItem)
-{
- if (m_bIgnoreSelectionChange)
- {
- return;
- }
-
- if (!pItem)
- {
- return;
- }
-
- _smart_ptr material = static_cast(pItem);
- SetSelectedItem(material, 0, true);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void MaterialBrowserWidget::OnDuplicate()
-{
- GetIEditor()->GetMaterialManager()->Command_Merge();
-}
-
-//////////////////////////////////////////////////////////////////////////
-void MaterialBrowserWidget::OnCut()
-{
- CMaterialBrowserRecord record;
- bool found = TryGetSelectedRecord(record);
- if (found)
- {
- OnCopy();
- DeleteItem(record);
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void MaterialBrowserWidget::OnCopyName()
-{
- _smart_ptr pMtl = GetCurrentMaterial();
- if (pMtl)
- {
- CClipboard clipboard(this);
- clipboard.PutString(pMtl->GetName(), "Material Name");
- }
-}
-
-void MaterialBrowserWidget::ShowOnlyLevelMaterials(bool levelOnly)
-{
- m_filterModel->ShowOnlyLevelMaterials(levelOnly);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void MaterialBrowserWidget::OnCopy()
-{
- _smart_ptr pMtl = GetCurrentMaterial();
- if (pMtl)
- {
- CClipboard clipboard(this);
- XmlNodeRef node = XmlHelpers::CreateXmlNode("Material");
- node->setAttr("Name", pMtl->GetName().toUtf8().data());
- CBaseLibraryItem::SerializeContext ctx(node, false);
- ctx.bCopyPaste = true;
- pMtl->Serialize(ctx);
- clipboard.Put(node);
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool MaterialBrowserWidget::CanPaste() const
-{
- CClipboard clipboard(nullptr);
- if (clipboard.IsEmpty())
- {
- return false;
- }
- XmlNodeRef node = clipboard.Get();
- if (!node)
- {
- return false;
- }
-
- if (strcmp(node->getTag(), "Material") == 0)
- {
- return true;
- }
- return false;
-}
-
-//////////////////////////////////////////////////////////////////////////
-void MaterialBrowserWidget::OnPaste()
-{
- CClipboard clipboard(this);
- if (clipboard.IsEmpty())
- {
- return;
- }
- XmlNodeRef node = clipboard.Get();
- if (!node)
- {
- return;
- }
-
- if (strcmp(node->getTag(), "Material") == 0)
- {
- if (!m_pMatMan->GetCurrentMaterial())
- {
- GetIEditor()->GetMaterialManager()->Command_Create();
- }
-
- _smart_ptr pMtl = m_pMatMan->GetCurrentMaterial();
- if (pMtl)
- {
- // This is material node.
- CBaseLibraryItem::SerializeContext serCtx(node, true);
- serCtx.bCopyPaste = true;
- serCtx.bUniqName = true;
- pMtl->Serialize(serCtx);
-
- SelectItem(pMtl, NULL);
- pMtl->Save();
- pMtl->Reload();
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void MaterialBrowserWidget::OnAddNewMaterial()
-{
- GetIEditor()->GetMaterialManager()->Command_Create();
-}
-
-//////////////////////////////////////////////////////////////////////////
-void MaterialBrowserWidget::OnAddNewMultiMaterial()
-{
- GetIEditor()->GetMaterialManager()->Command_CreateMulti();
-}
-
-//////////////////////////////////////////////////////////////////////////
-void MaterialBrowserWidget::OnMergeMaterials()
-{
- GetIEditor()->GetMaterialManager()->Command_Merge();
-}
-
-//////////////////////////////////////////////////////////////////////////
-void MaterialBrowserWidget::OnConvertToMulti()
-{
- GetIEditor()->GetMaterialManager()->Command_ConvertToMulti();
-}
-
-//////////////////////////////////////////////////////////////////////////
-void MaterialBrowserWidget::DeleteItem()
-{
- CMaterialBrowserRecord record;
- bool found = TryGetSelectedRecord(record);
- if (found)
- {
- DeleteItem(record);
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void MaterialBrowserWidget::OnResetItem()
-{
- if (QMessageBox::question(this, tr("Reset Material"), tr("Reset Material to default?")) == QMessageBox::Yes)
- {
- _smart_ptr pMtl = GetCurrentMaterial();
- int index;
-
- pMtl->GetSubMaterialCount() > 0 ? index = pMtl->GetSubMaterialCount() : index = 1;
-
- if (pMtl)
- {
- for (int i = 0; i < index; i++)
- {
- pMtl->GetSubMaterialCount() > 0 ? pMtl->GetSubMaterial(i)->Reload() : pMtl->Reload();
- TickRefreshMaterials();
- }
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void MaterialBrowserWidget::DeleteItem(const CMaterialBrowserRecord& record)
-{
- _smart_ptr pMtl = record.m_material;
- if (pMtl)
- {
- if (m_selectedSubMaterialIndex >= 0)
- {
- pMtl = pMtl->GetSubMaterial(m_selectedSubMaterialIndex);
- OnClearSubMtlSlot(pMtl);
- }
- else
- {
- GetIEditor()->GetMaterialManager()->Command_Delete();
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void MaterialBrowserWidget::OnRenameItem()
-{
- _smart_ptr pMtl = GetCurrentMaterial();
- if (!pMtl)
- {
- return;
- }
-
- if (pMtl->IsPureChild())
- {
- StringDlg dlg(tr("Enter New Sub-Material Name"), this);
- dlg.SetString(pMtl->GetName());
- dlg.SetCheckCallback([this](QString name) -> bool
- {
- static const int MAX_REASONABLE_MATERIAL_NAME = 128;
- if (name.length() >= MAX_REASONABLE_MATERIAL_NAME)
- {
- QMessageBox::warning(this, tr("Name too long"), tr("Please enter a name less than %1 characters").arg(MAX_REASONABLE_MATERIAL_NAME));
- return false;
- }
- return true;
- });
-
- if (dlg.exec() == QDialog::Accepted)
- {
- pMtl->SetName(dlg.GetString());
- pMtl->Save();
- pMtl->Reload();
- }
- }
- else
- {
- if ((pMtl->GetFileAttributes() & SCC_FILE_ATTRIBUTE_MANAGED) &&
- !(pMtl->GetFileAttributes() & SCC_FILE_ATTRIBUTE_CHECKEDOUT))
- {
- if (QMessageBox::Cancel == QMessageBox::information(this, tr("Confirm"), tr("Only checked-out files can be renamed. Check out and mark for delete before rename it?"), QMessageBox::Ok | QMessageBox::Cancel))
- {
- return;
- }
- }
-
- QFileInfo info(pMtl->GetFilename());
- QString filename = info.fileName();
- if (!CFileUtil::SelectSaveFile("Material Files (*.mtl)", "mtl", info.path(), filename))
- {
- return;
- }
-
- QString itemName = m_pMatMan->FilenameToMaterial(Path::GetRelativePath(filename));
- if (itemName.isEmpty())
- {
- return;
- }
-
- if (m_pMatMan->FindItemByName(itemName))
- {
- Warning("Material with name %s already exist", itemName.toUtf8().data());
- return;
- }
-
- if (pMtl->GetFileAttributes() & SCC_FILE_ATTRIBUTE_MANAGED)
- {
- if (pMtl->GetFileAttributes() & SCC_FILE_ATTRIBUTE_CHECKEDOUT)
- {
- if (QMessageBox::Cancel == QMessageBox::information(this, tr("Confirm"), tr("The original file will be marked for delete and the new named file will be marked for integration."), QMessageBox::Ok | QMessageBox::Cancel))
- {
- return;
- }
- }
- else
- {
- CFileUtil::CheckoutFile(pMtl->GetFilename().toUtf8().data(), this);
- }
-
- if (!CFileUtil::RenameFile(pMtl->GetFilename().toUtf8().data(), filename.toUtf8().data()))
- {
- QMessageBox::critical(this, tr("Error"), tr("Could not rename file in Source Control."));
- }
- }
-
-
- // Delete file on disk.
- if (!pMtl->GetFilename().isEmpty())
- {
- QFile::remove(pMtl->GetFilename());
- }
- pMtl->SetName(itemName);
- pMtl->Save();
- SetSelectedItem(pMtl, 0, true);
- }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-void MaterialBrowserWidget::OnSetSubMtlCount(const CMaterialBrowserRecord& record)
-{
- _smart_ptr