From 3e59c10e6452399e89afd558f3f634d3d47a826e Mon Sep 17 00:00:00 2001 From: Benjamin Jillich Date: Fri, 4 Feb 2022 12:37:43 +0100 Subject: [PATCH 01/11] Motion Matching: Enable test builds in CMakeLists.txt Signed-off-by: Benjamin Jillich --- Gems/MotionMatching/Code/CMakeLists.txt | 96 ++++++++++++------------- 1 file changed, 44 insertions(+), 52 deletions(-) diff --git a/Gems/MotionMatching/Code/CMakeLists.txt b/Gems/MotionMatching/Code/CMakeLists.txt index 275f8f2530..ae613f5d7f 100644 --- a/Gems/MotionMatching/Code/CMakeLists.txt +++ b/Gems/MotionMatching/Code/CMakeLists.txt @@ -99,57 +99,49 @@ endif() ################################################################################ # See if globally, tests are supported if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) - # We globally support tests, see if we support tests on this platform for MotionMatching.Static - if(PAL_TRAIT_MOTIONMATCHING_TEST_SUPPORTED) - # We support MotionMatching.Tests on this platform, add MotionMatching.Tests target which depends on MotionMatching.Static - ly_add_target( - NAME MotionMatching.Tests ${PAL_TRAIT_TEST_TARGET_TYPE} - NAMESPACE Gem - FILES_CMAKE - motionmatching_files.cmake - motionmatching_tests_files.cmake - INCLUDE_DIRECTORIES - PRIVATE - Tests - Source - BUILD_DEPENDENCIES - PRIVATE - AZ::AzTest - AZ::AzFramework - Gem::EMotionFX.Tests.Static - Gem::MotionMatching.Static - ) + ly_add_target( + NAME MotionMatching.Tests ${PAL_TRAIT_TEST_TARGET_TYPE} + NAMESPACE Gem + FILES_CMAKE + motionmatching_files.cmake + motionmatching_tests_files.cmake + INCLUDE_DIRECTORIES + PRIVATE + Tests + Source + BUILD_DEPENDENCIES + PRIVATE + AZ::AzTest + AZ::AzFramework + Gem::EMotionFX.Tests.Static + Gem::MotionMatching.Static + ) - # Add MotionMatching.Tests to googletest - ly_add_googletest( - NAME Gem::MotionMatching.Tests - ) - endif() - - # If we are a host platform we want to add tools test like editor tests here - if(PAL_TRAIT_BUILD_HOST_TOOLS) - # We are a host platform, see if Editor tests are supported on this platform - if(PAL_TRAIT_MOTIONMATCHING_EDITOR_TEST_SUPPORTED) - # We support MotionMatching.Editor.Tests on this platform, add MotionMatching.Editor.Tests target which depends on MotionMatching.Editor - ly_add_target( - NAME MotionMatching.Editor.Tests ${PAL_TRAIT_TEST_TARGET_TYPE} - NAMESPACE Gem - FILES_CMAKE - motionmatching_editor_tests_files.cmake - INCLUDE_DIRECTORIES - PRIVATE - Tests - Source - BUILD_DEPENDENCIES - PRIVATE - AZ::AzTest - Gem::MotionMatching.Editor - ) - - # Add MotionMatching.Editor.Tests to googletest - ly_add_googletest( - NAME Gem::MotionMatching.Editor.Tests - ) - endif() - endif() + # Add MotionMatching.Tests to googletest + ly_add_googletest( + NAME Gem::MotionMatching.Tests + ) +endif() + +# If we are a host platform we want to add tools test like editor tests here +if(PAL_TRAIT_BUILD_HOST_TOOLS) + ly_add_target( + NAME MotionMatching.Editor.Tests ${PAL_TRAIT_TEST_TARGET_TYPE} + NAMESPACE Gem + FILES_CMAKE + motionmatching_editor_tests_files.cmake + INCLUDE_DIRECTORIES + PRIVATE + Tests + Source + BUILD_DEPENDENCIES + PRIVATE + AZ::AzTest + Gem::MotionMatching.Editor + ) + + # Add MotionMatching.Editor.Tests to googletest + ly_add_googletest( + NAME Gem::MotionMatching.Editor.Tests + ) endif() From 80ac11889310696ac4beebd778ac23b87608a792 Mon Sep 17 00:00:00 2001 From: Benjamin Jillich Date: Fri, 4 Feb 2022 13:46:57 +0100 Subject: [PATCH 02/11] Motion Matching: Updated camera controller graph for automatic demo Simplified the script canvas graph of the camera controller for the automatic demo. Signed-off-by: Benjamin Jillich --- ...ameraController_AutomaticDemo.scriptcanvas | 1538 +++++------------ .../Assets/MotionMatching.animgraph | 3 - 2 files changed, 397 insertions(+), 1144 deletions(-) delete mode 100644 Gems/MotionMatching/Assets/MotionMatching.animgraph diff --git a/Gems/MotionMatching/Assets/Levels/MotionMatching_AutomaticDemo/CameraController_AutomaticDemo.scriptcanvas b/Gems/MotionMatching/Assets/Levels/MotionMatching_AutomaticDemo/CameraController_AutomaticDemo.scriptcanvas index 8569d7686b..391ad295a5 100644 --- a/Gems/MotionMatching/Assets/Levels/MotionMatching_AutomaticDemo/CameraController_AutomaticDemo.scriptcanvas +++ b/Gems/MotionMatching/Assets/Levels/MotionMatching_AutomaticDemo/CameraController_AutomaticDemo.scriptcanvas @@ -5,7 +5,7 @@ "ClassData": { "m_scriptCanvas": { "Id": { - "id": 1874297699023155003 + "id": 8461866310375259320 }, "Name": "CameraController", "Components": { @@ -577,214 +577,6 @@ } } }, - { - "Id": { - "id": 58633135722148 - }, - "Name": "SC-Node(OperatorMul)", - "Components": { - "Component_[13427352953117170385]": { - "$type": "OperatorMul", - "Id": 13427352953117170385, - "Slots": [ - { - "id": { - "m_id": "{B6D38C30-7BB4-4549-AFFA-C5A52AE9796E}" - }, - "contracts": [ - { - "$type": "SlotTypeContract" - } - ], - "slotName": "In", - "Descriptor": { - "ConnectionType": 1, - "SlotType": 1 - } - }, - { - "id": { - "m_id": "{86D20026-0D06-4DFB-B3CD-9BE5038B8121}" - }, - "contracts": [ - { - "$type": "SlotTypeContract" - } - ], - "slotName": "Out", - "Descriptor": { - "ConnectionType": 2, - "SlotType": 1 - } - }, - { - "id": { - "m_id": "{F9E6233F-EAFB-43F5-A10D-96A3A41763A7}" - }, - "DynamicTypeOverride": 3, - "contracts": [ - { - "$type": "SlotTypeContract" - }, - { - "$type": "MathOperatorContract", - "OperatorType": "Multiply", - "NativeTypes": [ - { - "m_type": 3 - }, - { - "m_type": 6 - }, - { - "m_type": 7 - }, - { - "m_type": 14 - }, - { - "m_type": 15 - } - ] - } - ], - "slotName": "Number", - "toolTip": "An operand to use in performing the specified Operation", - "DisplayDataType": { - "m_type": 3 - }, - "DisplayGroup": { - "Value": 1114760223 - }, - "Descriptor": { - "ConnectionType": 1, - "SlotType": 2 - }, - "DynamicGroup": { - "Value": 1114760223 - }, - "DataType": 1 - }, - { - "id": { - "m_id": "{9D3D613C-ABE4-4028-A1CC-22E6E036376C}" - }, - "DynamicTypeOverride": 3, - "contracts": [ - { - "$type": "SlotTypeContract" - }, - { - "$type": "MathOperatorContract", - "OperatorType": "Multiply", - "NativeTypes": [ - { - "m_type": 3 - }, - { - "m_type": 6 - }, - { - "m_type": 7 - }, - { - "m_type": 14 - }, - { - "m_type": 15 - } - ] - } - ], - "slotName": "Number", - "toolTip": "An operand to use in performing the specified Operation", - "DisplayDataType": { - "m_type": 3 - }, - "DisplayGroup": { - "Value": 1114760223 - }, - "Descriptor": { - "ConnectionType": 1, - "SlotType": 2 - }, - "DynamicGroup": { - "Value": 1114760223 - }, - "DataType": 1 - }, - { - "id": { - "m_id": "{C0EA31C9-71C6-4CCF-A31B-33E7385C78D0}" - }, - "DynamicTypeOverride": 3, - "contracts": [ - { - "$type": "SlotTypeContract" - }, - { - "$type": "MathOperatorContract", - "OperatorType": "Multiply", - "NativeTypes": [ - { - "m_type": 3 - }, - { - "m_type": 6 - }, - { - "m_type": 7 - }, - { - "m_type": 14 - }, - { - "m_type": 15 - } - ] - } - ], - "slotName": "Result", - "toolTip": "The result of the specified operation", - "DisplayDataType": { - "m_type": 3 - }, - "DisplayGroup": { - "Value": 1114760223 - }, - "Descriptor": { - "ConnectionType": 2, - "SlotType": 2 - }, - "DynamicGroup": { - "Value": 1114760223 - }, - "DataType": 1 - } - ], - "Datums": [ - { - "scriptCanvasType": { - "m_type": 3 - }, - "isNullPointer": false, - "$type": "double", - "value": 1.0, - "label": "Number" - }, - { - "scriptCanvasType": { - "m_type": 3 - }, - "isNullPointer": false, - "$type": "double", - "value": -90.0, - "label": "Number" - } - ] - } - } - }, { "Id": { "id": 214400860662419 @@ -856,214 +648,6 @@ } } }, - { - "Id": { - "id": 58577301147300 - }, - "Name": "SC-Node(OperatorMul)", - "Components": { - "Component_[14055904483179664364]": { - "$type": "OperatorMul", - "Id": 14055904483179664364, - "Slots": [ - { - "id": { - "m_id": "{F5BE2CBC-3CA3-44BD-B7D4-71D9CAC023B3}" - }, - "contracts": [ - { - "$type": "SlotTypeContract" - } - ], - "slotName": "In", - "Descriptor": { - "ConnectionType": 1, - "SlotType": 1 - } - }, - { - "id": { - "m_id": "{4CD5D25E-73DA-4936-89E9-8F0A7946DED1}" - }, - "contracts": [ - { - "$type": "SlotTypeContract" - } - ], - "slotName": "Out", - "Descriptor": { - "ConnectionType": 2, - "SlotType": 1 - } - }, - { - "id": { - "m_id": "{2F0B4FC7-0B48-42A9-8073-8493E9F1D2E5}" - }, - "DynamicTypeOverride": 3, - "contracts": [ - { - "$type": "SlotTypeContract" - }, - { - "$type": "MathOperatorContract", - "OperatorType": "Multiply", - "NativeTypes": [ - { - "m_type": 3 - }, - { - "m_type": 6 - }, - { - "m_type": 7 - }, - { - "m_type": 14 - }, - { - "m_type": 15 - } - ] - } - ], - "slotName": "Number", - "toolTip": "An operand to use in performing the specified Operation", - "DisplayDataType": { - "m_type": 3 - }, - "DisplayGroup": { - "Value": 1114760223 - }, - "Descriptor": { - "ConnectionType": 1, - "SlotType": 2 - }, - "DynamicGroup": { - "Value": 1114760223 - }, - "DataType": 1 - }, - { - "id": { - "m_id": "{67B729E8-73F9-4B97-A67C-C986E874BD01}" - }, - "DynamicTypeOverride": 3, - "contracts": [ - { - "$type": "SlotTypeContract" - }, - { - "$type": "MathOperatorContract", - "OperatorType": "Multiply", - "NativeTypes": [ - { - "m_type": 3 - }, - { - "m_type": 6 - }, - { - "m_type": 7 - }, - { - "m_type": 14 - }, - { - "m_type": 15 - } - ] - } - ], - "slotName": "Number", - "toolTip": "An operand to use in performing the specified Operation", - "DisplayDataType": { - "m_type": 3 - }, - "DisplayGroup": { - "Value": 1114760223 - }, - "Descriptor": { - "ConnectionType": 1, - "SlotType": 2 - }, - "DynamicGroup": { - "Value": 1114760223 - }, - "DataType": 1 - }, - { - "id": { - "m_id": "{785A9BC8-8F65-4DFE-8809-7C8E937A8D8B}" - }, - "DynamicTypeOverride": 3, - "contracts": [ - { - "$type": "SlotTypeContract" - }, - { - "$type": "MathOperatorContract", - "OperatorType": "Multiply", - "NativeTypes": [ - { - "m_type": 3 - }, - { - "m_type": 6 - }, - { - "m_type": 7 - }, - { - "m_type": 14 - }, - { - "m_type": 15 - } - ] - } - ], - "slotName": "Result", - "toolTip": "The result of the specified operation", - "DisplayDataType": { - "m_type": 3 - }, - "DisplayGroup": { - "Value": 1114760223 - }, - "Descriptor": { - "ConnectionType": 2, - "SlotType": 2 - }, - "DynamicGroup": { - "Value": 1114760223 - }, - "DataType": 1 - } - ], - "Datums": [ - { - "scriptCanvasType": { - "m_type": 3 - }, - "isNullPointer": false, - "$type": "double", - "value": 1.0, - "label": "Number" - }, - { - "scriptCanvasType": { - "m_type": 3 - }, - "isNullPointer": false, - "$type": "double", - "value": 1.0, - "label": "Number" - } - ] - } - } - }, { "Id": { "id": 58581596114596 @@ -1514,6 +1098,65 @@ "Value": 1114760223 }, "DataType": 1 + }, + { + "id": { + "m_id": "{095D00D3-962F-47DD-8400-F025C008E579}" + }, + "DynamicTypeOverride": 3, + "contracts": [ + { + "$type": "SlotTypeContract" + }, + { + "$type": "MathOperatorContract", + "NativeTypes": [ + { + "m_type": 3 + }, + { + "m_type": 6 + }, + { + "m_type": 8 + }, + { + "m_type": 9 + }, + { + "m_type": 10 + }, + { + "m_type": 11 + }, + { + "m_type": 12 + }, + { + "m_type": 14 + }, + { + "m_type": 15 + } + ] + } + ], + "slotName": "Number", + "toolTip": "An operand to use in performing the specified Operation", + "DisplayDataType": { + "m_type": 3 + }, + "DisplayGroup": { + "Value": 1114760223 + }, + "Descriptor": { + "ConnectionType": 1, + "SlotType": 2 + }, + "DynamicGroup": { + "Value": 1114760223 + }, + "DataType": 1 } ], "Datums": [ @@ -1534,6 +1177,16 @@ "$type": "double", "value": 0.0, "label": "Number" + }, + { + "isOverloadedStorage": false, + "scriptCanvasType": { + "m_type": 3 + }, + "isNullPointer": false, + "$type": "double", + "value": 0.0, + "label": "Number" } ] } @@ -1665,216 +1318,6 @@ } } }, - { - "Id": { - "id": 239870016727699 - }, - "Name": "SC-Node(OperatorMul)", - "Components": { - "Component_[3092852928531574536]": { - "$type": "OperatorMul", - "Id": 3092852928531574536, - "Slots": [ - { - "id": { - "m_id": "{FEFF67A1-C89B-447E-80D4-CD94CB0C8AD7}" - }, - "contracts": [ - { - "$type": "SlotTypeContract" - } - ], - "slotName": "In", - "Descriptor": { - "ConnectionType": 1, - "SlotType": 1 - } - }, - { - "id": { - "m_id": "{7E5D8673-F03A-4134-87DE-88AD13A74C29}" - }, - "contracts": [ - { - "$type": "SlotTypeContract" - } - ], - "slotName": "Out", - "Descriptor": { - "ConnectionType": 2, - "SlotType": 1 - } - }, - { - "id": { - "m_id": "{8A243C9C-0D69-4753-B28B-A8D2FAC5D508}" - }, - "DynamicTypeOverride": 3, - "contracts": [ - { - "$type": "SlotTypeContract" - }, - { - "$type": "MathOperatorContract", - "OperatorType": "Multiply", - "NativeTypes": [ - { - "m_type": 3 - }, - { - "m_type": 6 - }, - { - "m_type": 7 - }, - { - "m_type": 14 - }, - { - "m_type": 15 - } - ] - } - ], - "slotName": "Number", - "toolTip": "An operand to use in performing the specified Operation", - "DisplayDataType": { - "m_type": 3 - }, - "DisplayGroup": { - "Value": 1114760223 - }, - "Descriptor": { - "ConnectionType": 1, - "SlotType": 2 - }, - "DynamicGroup": { - "Value": 1114760223 - }, - "DataType": 1 - }, - { - "id": { - "m_id": "{3F3F3DD6-124E-48A8-8373-6666900D8177}" - }, - "DynamicTypeOverride": 3, - "contracts": [ - { - "$type": "SlotTypeContract" - }, - { - "$type": "MathOperatorContract", - "OperatorType": "Multiply", - "NativeTypes": [ - { - "m_type": 3 - }, - { - "m_type": 6 - }, - { - "m_type": 7 - }, - { - "m_type": 14 - }, - { - "m_type": 15 - } - ] - } - ], - "slotName": "Number", - "toolTip": "An operand to use in performing the specified Operation", - "DisplayDataType": { - "m_type": 3 - }, - "DisplayGroup": { - "Value": 1114760223 - }, - "Descriptor": { - "ConnectionType": 1, - "SlotType": 2 - }, - "DynamicGroup": { - "Value": 1114760223 - }, - "DataType": 1 - }, - { - "id": { - "m_id": "{DFD1DE7E-B470-43F6-A6CF-E9E572D0C075}" - }, - "DynamicTypeOverride": 3, - "contracts": [ - { - "$type": "SlotTypeContract" - }, - { - "$type": "MathOperatorContract", - "OperatorType": "Multiply", - "NativeTypes": [ - { - "m_type": 3 - }, - { - "m_type": 6 - }, - { - "m_type": 7 - }, - { - "m_type": 14 - }, - { - "m_type": 15 - } - ] - } - ], - "slotName": "Result", - "toolTip": "The result of the specified operation", - "DisplayDataType": { - "m_type": 3 - }, - "DisplayGroup": { - "Value": 1114760223 - }, - "Descriptor": { - "ConnectionType": 2, - "SlotType": 2 - }, - "DynamicGroup": { - "Value": 1114760223 - }, - "DataType": 1 - } - ], - "Datums": [ - { - "isOverloadedStorage": false, - "scriptCanvasType": { - "m_type": 3 - }, - "isNullPointer": false, - "$type": "double", - "value": 1.0, - "label": "Number" - }, - { - "isOverloadedStorage": false, - "scriptCanvasType": { - "m_type": 3 - }, - "isNullPointer": false, - "$type": "double", - "value": 10.0, - "label": "Number" - } - ] - } - } - }, { "Id": { "id": 58654610558628 @@ -2257,6 +1700,216 @@ } } }, + { + "Id": { + "id": 34623617265138 + }, + "Name": "SC-Node(OperatorMul)", + "Components": { + "Component_[6682944070117268251]": { + "$type": "OperatorMul", + "Id": 6682944070117268251, + "Slots": [ + { + "id": { + "m_id": "{E55CADF9-9769-43D3-B6BD-8EFA828C5B7B}" + }, + "contracts": [ + { + "$type": "SlotTypeContract" + } + ], + "slotName": "In", + "Descriptor": { + "ConnectionType": 1, + "SlotType": 1 + } + }, + { + "id": { + "m_id": "{00F5960A-A85F-4B88-A562-BB6E7BFCE05E}" + }, + "contracts": [ + { + "$type": "SlotTypeContract" + } + ], + "slotName": "Out", + "Descriptor": { + "ConnectionType": 2, + "SlotType": 1 + } + }, + { + "id": { + "m_id": "{FB35B335-EA81-45FF-A0BA-CED33329EB93}" + }, + "DynamicTypeOverride": 3, + "contracts": [ + { + "$type": "SlotTypeContract" + }, + { + "$type": "MathOperatorContract", + "OperatorType": "Multiply", + "NativeTypes": [ + { + "m_type": 3 + }, + { + "m_type": 6 + }, + { + "m_type": 7 + }, + { + "m_type": 14 + }, + { + "m_type": 15 + } + ] + } + ], + "slotName": "Number", + "toolTip": "An operand to use in performing the specified Operation", + "DisplayDataType": { + "m_type": 3 + }, + "DisplayGroup": { + "Value": 1114760223 + }, + "Descriptor": { + "ConnectionType": 1, + "SlotType": 2 + }, + "DynamicGroup": { + "Value": 1114760223 + }, + "DataType": 1 + }, + { + "id": { + "m_id": "{85824692-0B8B-4400-87BC-9D8CA6127A88}" + }, + "DynamicTypeOverride": 3, + "contracts": [ + { + "$type": "SlotTypeContract" + }, + { + "$type": "MathOperatorContract", + "OperatorType": "Multiply", + "NativeTypes": [ + { + "m_type": 3 + }, + { + "m_type": 6 + }, + { + "m_type": 7 + }, + { + "m_type": 14 + }, + { + "m_type": 15 + } + ] + } + ], + "slotName": "Number", + "toolTip": "An operand to use in performing the specified Operation", + "DisplayDataType": { + "m_type": 3 + }, + "DisplayGroup": { + "Value": 1114760223 + }, + "Descriptor": { + "ConnectionType": 1, + "SlotType": 2 + }, + "DynamicGroup": { + "Value": 1114760223 + }, + "DataType": 1 + }, + { + "id": { + "m_id": "{84852FBC-F135-48B2-B5C8-AFF3B1F35E42}" + }, + "DynamicTypeOverride": 3, + "contracts": [ + { + "$type": "SlotTypeContract" + }, + { + "$type": "MathOperatorContract", + "OperatorType": "Multiply", + "NativeTypes": [ + { + "m_type": 3 + }, + { + "m_type": 6 + }, + { + "m_type": 7 + }, + { + "m_type": 14 + }, + { + "m_type": 15 + } + ] + } + ], + "slotName": "Result", + "toolTip": "The result of the specified operation", + "DisplayDataType": { + "m_type": 3 + }, + "DisplayGroup": { + "Value": 1114760223 + }, + "Descriptor": { + "ConnectionType": 2, + "SlotType": 2 + }, + "DynamicGroup": { + "Value": 1114760223 + }, + "DataType": 1 + } + ], + "Datums": [ + { + "isOverloadedStorage": false, + "scriptCanvasType": { + "m_type": 3 + }, + "isNullPointer": false, + "$type": "double", + "value": 1.0, + "label": "Number" + }, + { + "isOverloadedStorage": false, + "scriptCanvasType": { + "m_type": 3 + }, + "isNullPointer": false, + "$type": "double", + "value": 12.5, + "label": "Number" + } + ] + } + } + }, { "Id": { "id": 58663200493220 @@ -2361,77 +2014,6 @@ } } }, - { - "Id": { - "id": 58594481016484 - }, - "Name": "SC Node(GetVariable)", - "Components": { - "Component_[8136131668650391163]": { - "$type": "GetVariableNode", - "Id": 8136131668650391163, - "Slots": [ - { - "id": { - "m_id": "{09256706-E7A2-47C3-ACE0-3BE7D80E34FD}" - }, - "contracts": [ - { - "$type": "SlotTypeContract" - } - ], - "slotName": "In", - "toolTip": "When signaled sends the property referenced by this node to a Data Output slot", - "Descriptor": { - "ConnectionType": 1, - "SlotType": 1 - } - }, - { - "id": { - "m_id": "{1ACC7F53-E81A-4721-9AC8-5C1A33C8BE96}" - }, - "contracts": [ - { - "$type": "SlotTypeContract" - } - ], - "slotName": "Out", - "toolTip": "Signaled after the referenced property has been pushed to the Data Output slot", - "Descriptor": { - "ConnectionType": 2, - "SlotType": 1 - } - }, - { - "id": { - "m_id": "{4972DD3B-D554-47B7-816B-CBCF67697ABA}" - }, - "contracts": [ - { - "$type": "SlotTypeContract" - } - ], - "slotName": "Number", - "DisplayDataType": { - "m_type": 3 - }, - "Descriptor": { - "ConnectionType": 2, - "SlotType": 2 - }, - "DataType": 1 - } - ], - "m_variableId": { - "m_id": "{0620A309-A152-4CF3-BF76-284115B30780}" - }, - "m_variableDataOutSlotId": { - "m_id": "{4972DD3B-D554-47B7-816B-CBCF67697ABA}" - } - } - } - }, { "Id": { "id": 58658905525924 @@ -2668,62 +2250,6 @@ } ], "m_connections": [ - { - "Id": { - "id": 58706150166180 - }, - "Name": "srcEndpoint=(Get Variable: Out), destEndpoint=(RotationZDegrees: In)", - "Components": { - "Component_[553961487450147653]": { - "$type": "{64CA5016-E803-4AC4-9A36-BDA2C890C6EB} Connection", - "Id": 553961487450147653, - "sourceEndpoint": { - "nodeId": { - "id": 58594481016484 - }, - "slotId": { - "m_id": "{1ACC7F53-E81A-4721-9AC8-5C1A33C8BE96}" - } - }, - "targetEndpoint": { - "nodeId": { - "id": 58590186049188 - }, - "slotId": { - "m_id": "{4B28D8A2-7F6C-4EB1-A7D5-EA68FB783B52}" - } - } - } - } - }, - { - "Id": { - "id": 58710445133476 - }, - "Name": "srcEndpoint=(Get Variable: Number), destEndpoint=(RotationZDegrees: Number: Degrees)", - "Components": { - "Component_[8946072267986857913]": { - "$type": "{64CA5016-E803-4AC4-9A36-BDA2C890C6EB} Connection", - "Id": 8946072267986857913, - "sourceEndpoint": { - "nodeId": { - "id": 58594481016484 - }, - "slotId": { - "m_id": "{4972DD3B-D554-47B7-816B-CBCF67697ABA}" - } - }, - "targetEndpoint": { - "nodeId": { - "id": 58590186049188 - }, - "slotId": { - "m_id": "{694A218A-8047-4981-BF62-726AF9BCB3C6}" - } - } - } - } - }, { "Id": { "id": 58714740100772 @@ -2920,118 +2446,6 @@ } } }, - { - "Id": { - "id": 58753394806436 - }, - "Name": "srcEndpoint=(TickBus Handler: Number), destEndpoint=(Multiply (*): Value)", - "Components": { - "Component_[1087668963814879388]": { - "$type": "{64CA5016-E803-4AC4-9A36-BDA2C890C6EB} Connection", - "Id": 1087668963814879388, - "sourceEndpoint": { - "nodeId": { - "id": 58667495460516 - }, - "slotId": { - "m_id": "{02148868-388F-44F0-9E3A-C31601701F3B}" - } - }, - "targetEndpoint": { - "nodeId": { - "id": 58577301147300 - }, - "slotId": { - "m_id": "{67B729E8-73F9-4B97-A67C-C986E874BD01}" - } - } - } - } - }, - { - "Id": { - "id": 58783459577508 - }, - "Name": "srcEndpoint=(Set Variable: Out), destEndpoint=(Get Variable: In)", - "Components": { - "Component_[5808096905671825435]": { - "$type": "{64CA5016-E803-4AC4-9A36-BDA2C890C6EB} Connection", - "Id": 5808096905671825435, - "sourceEndpoint": { - "nodeId": { - "id": 58654610558628 - }, - "slotId": { - "m_id": "{47175A2C-5EE4-4C48-8CC1-8F2C84D36FE5}" - } - }, - "targetEndpoint": { - "nodeId": { - "id": 58594481016484 - }, - "slotId": { - "m_id": "{09256706-E7A2-47C3-ACE0-3BE7D80E34FD}" - } - } - } - } - }, - { - "Id": { - "id": 58787754544804 - }, - "Name": "srcEndpoint=(Multiply (*): Result), destEndpoint=(Multiply (*): Value)", - "Components": { - "Component_[11775794502882233004]": { - "$type": "{64CA5016-E803-4AC4-9A36-BDA2C890C6EB} Connection", - "Id": 11775794502882233004, - "sourceEndpoint": { - "nodeId": { - "id": 58577301147300 - }, - "slotId": { - "m_id": "{785A9BC8-8F65-4DFE-8809-7C8E937A8D8B}" - } - }, - "targetEndpoint": { - "nodeId": { - "id": 58633135722148 - }, - "slotId": { - "m_id": "{F9E6233F-EAFB-43F5-A10D-96A3A41763A7}" - } - } - } - } - }, - { - "Id": { - "id": 58792049512100 - }, - "Name": "srcEndpoint=(Multiply (*): Out), destEndpoint=(Multiply (*): In)", - "Components": { - "Component_[80299809090156725]": { - "$type": "{64CA5016-E803-4AC4-9A36-BDA2C890C6EB} Connection", - "Id": 80299809090156725, - "sourceEndpoint": { - "nodeId": { - "id": 58577301147300 - }, - "slotId": { - "m_id": "{4CD5D25E-73DA-4936-89E9-8F0A7946DED1}" - } - }, - "targetEndpoint": { - "nodeId": { - "id": 58633135722148 - }, - "slotId": { - "m_id": "{B6D38C30-7BB4-4549-AFFA-C5A52AE9796E}" - } - } - } - } - }, { "Id": { "id": 58800639446692 @@ -3284,34 +2698,6 @@ } } }, - { - "Id": { - "id": 164626484669075 - }, - "Name": "srcEndpoint=(: ), destEndpoint=(: )", - "Components": { - "Component_[14524450253664706586]": { - "$type": "{64CA5016-E803-4AC4-9A36-BDA2C890C6EB} Connection", - "Id": 14524450253664706586, - "sourceEndpoint": { - "nodeId": { - "id": 58667495460516 - }, - "slotId": { - "m_id": "{8965578E-A29D-4468-B12B-9D4E4F814641}" - } - }, - "targetEndpoint": { - "nodeId": { - "id": 58577301147300 - }, - "slotId": { - "m_id": "{F5BE2CBC-3CA3-44BD-B7D4-71D9CAC023B3}" - } - } - } - } - }, { "Id": { "id": 214778817784467 @@ -3426,13 +2812,69 @@ }, { "Id": { - "id": 240698945415827 + "id": 71140482223643 + }, + "Name": "srcEndpoint=(Set Variable: Out), destEndpoint=(RotationZDegrees: In)", + "Components": { + "Component_[11167812872648006272]": { + "$type": "{64CA5016-E803-4AC4-9A36-BDA2C890C6EB} Connection", + "Id": 11167812872648006272, + "sourceEndpoint": { + "nodeId": { + "id": 58654610558628 + }, + "slotId": { + "m_id": "{47175A2C-5EE4-4C48-8CC1-8F2C84D36FE5}" + } + }, + "targetEndpoint": { + "nodeId": { + "id": 58590186049188 + }, + "slotId": { + "m_id": "{4B28D8A2-7F6C-4EB1-A7D5-EA68FB783B52}" + } + } + } + } + }, + { + "Id": { + "id": 71557094051355 + }, + "Name": "srcEndpoint=(Set Variable: Number), destEndpoint=(RotationZDegrees: Number: Degrees)", + "Components": { + "Component_[13278183946958091954]": { + "$type": "{64CA5016-E803-4AC4-9A36-BDA2C890C6EB} Connection", + "Id": 13278183946958091954, + "sourceEndpoint": { + "nodeId": { + "id": 58654610558628 + }, + "slotId": { + "m_id": "{1B58C71B-3AB9-4D90-A8D5-164A20B083DA}" + } + }, + "targetEndpoint": { + "nodeId": { + "id": 58590186049188 + }, + "slotId": { + "m_id": "{694A218A-8047-4981-BF62-726AF9BCB3C6}" + } + } + } + } + }, + { + "Id": { + "id": 35443956018674 }, "Name": "srcEndpoint=(Get Variable: Out), destEndpoint=(Multiply (*): In)", "Components": { - "Component_[12012899230680400379]": { + "Component_[1036318540886899366]": { "$type": "{64CA5016-E803-4AC4-9A36-BDA2C890C6EB} Connection", - "Id": 12012899230680400379, + "Id": 1036318540886899366, "sourceEndpoint": { "nodeId": { "id": 214400860662419 @@ -3443,10 +2885,10 @@ }, "targetEndpoint": { "nodeId": { - "id": 239870016727699 + "id": 34623617265138 }, "slotId": { - "m_id": "{FEFF67A1-C89B-447E-80D4-CD94CB0C8AD7}" + "m_id": "{E55CADF9-9769-43D3-B6BD-8EFA828C5B7B}" } } } @@ -3454,47 +2896,19 @@ }, { "Id": { - "id": 241158506916499 - }, - "Name": "srcEndpoint=(TickBus Handler: Number), destEndpoint=(Multiply (*): Value)", - "Components": { - "Component_[6729356013537587652]": { - "$type": "{64CA5016-E803-4AC4-9A36-BDA2C890C6EB} Connection", - "Id": 6729356013537587652, - "sourceEndpoint": { - "nodeId": { - "id": 58667495460516 - }, - "slotId": { - "m_id": "{02148868-388F-44F0-9E3A-C31601701F3B}" - } - }, - "targetEndpoint": { - "nodeId": { - "id": 239870016727699 - }, - "slotId": { - "m_id": "{8A243C9C-0D69-4753-B28B-A8D2FAC5D508}" - } - } - } - } - }, - { - "Id": { - "id": 241845701683859 + "id": 36113970916850 }, "Name": "srcEndpoint=(Multiply (*): Out), destEndpoint=(Add (+): In)", "Components": { - "Component_[1977054835666987502]": { + "Component_[14283307370513044941]": { "$type": "{64CA5016-E803-4AC4-9A36-BDA2C890C6EB} Connection", - "Id": 1977054835666987502, + "Id": 14283307370513044941, "sourceEndpoint": { "nodeId": { - "id": 239870016727699 + "id": 34623617265138 }, "slotId": { - "m_id": "{7E5D8673-F03A-4134-87DE-88AD13A74C29}" + "m_id": "{00F5960A-A85F-4B88-A562-BB6E7BFCE05E}" } }, "targetEndpoint": { @@ -3510,19 +2924,19 @@ }, { "Id": { - "id": 242150644361875 + "id": 36401733725682 }, "Name": "srcEndpoint=(Multiply (*): Result), destEndpoint=(Add (+): Number)", "Components": { - "Component_[4687422202712804034]": { + "Component_[5424678033357045019]": { "$type": "{64CA5016-E803-4AC4-9A36-BDA2C890C6EB} Connection", - "Id": 4687422202712804034, + "Id": 5424678033357045019, "sourceEndpoint": { "nodeId": { - "id": 239870016727699 + "id": 34623617265138 }, "slotId": { - "m_id": "{DFD1DE7E-B470-43F6-A6CF-E9E572D0C075}" + "m_id": "{84852FBC-F135-48B2-B5C8-AFF3B1F35E42}" } }, "targetEndpoint": { @@ -3535,6 +2949,34 @@ } } } + }, + { + "Id": { + "id": 37033093918194 + }, + "Name": "srcEndpoint=(TickBus Handler: Number), destEndpoint=(Multiply (*): Number)", + "Components": { + "Component_[7944449722082928320]": { + "$type": "{64CA5016-E803-4AC4-9A36-BDA2C890C6EB} Connection", + "Id": 7944449722082928320, + "sourceEndpoint": { + "nodeId": { + "id": 58667495460516 + }, + "slotId": { + "m_id": "{02148868-388F-44F0-9E3A-C31601701F3B}" + } + }, + "targetEndpoint": { + "nodeId": { + "id": 34623617265138 + }, + "slotId": { + "m_id": "{FB35B335-EA81-45FF-A0BA-CED33329EB93}" + } + } + } + } } ] }, @@ -3548,7 +2990,7 @@ "GraphCanvasData": [ { "Key": { - "id": 58577301147300 + "id": 34623617265138 }, "Value": { "ComponentData": { @@ -3562,8 +3004,8 @@ "{7CC444B1-F9B3-41B5-841B-0C4F2179F111}": { "$type": "GeometrySaveData", "Position": [ - -40.0, - 180.0 + 440.0, + 300.0 ] }, "{B0B99C8A-03AF-4CF6-A926-F65C874C3D97}": { @@ -3571,7 +3013,7 @@ }, "{B1F49A35-8408-40DA-B79E-F1E3B64322CE}": { "$type": "PersistentIdComponentSaveData", - "PersistentId": "{EB1D5C50-BE43-4D5B-95CA-72BB2444355C}" + "PersistentId": "{D071B475-12EA-47E9-9D36-3FF719DFDF55}" } } } @@ -3636,37 +3078,6 @@ } } }, - { - "Key": { - "id": 58594481016484 - }, - "Value": { - "ComponentData": { - "{24CB38BB-1705-4EC5-8F63-B574571B4DCD}": { - "$type": "NodeSaveData" - }, - "{328FF15C-C302-458F-A43D-E1794DE0904E}": { - "$type": "GeneralNodeTitleComponentSaveData", - "PaletteOverride": "GetVariableNodeTitlePalette" - }, - "{7CC444B1-F9B3-41B5-841B-0C4F2179F111}": { - "$type": "GeometrySaveData", - "Position": [ - 1820.0, - 160.0 - ] - }, - "{B0B99C8A-03AF-4CF6-A926-F65C874C3D97}": { - "$type": "StylingComponentSaveData", - "SubStyle": ".getVariable" - }, - "{B1F49A35-8408-40DA-B79E-F1E3B64322CE}": { - "$type": "PersistentIdComponentSaveData", - "PersistentId": "{4F7B87C1-4C5D-4B00-87F1-E742C7F9B0BB}" - } - } - } - }, { "Key": { "id": 58607365918372 @@ -3758,36 +3169,6 @@ } } }, - { - "Key": { - "id": 58633135722148 - }, - "Value": { - "ComponentData": { - "{24CB38BB-1705-4EC5-8F63-B574571B4DCD}": { - "$type": "NodeSaveData" - }, - "{328FF15C-C302-458F-A43D-E1794DE0904E}": { - "$type": "GeneralNodeTitleComponentSaveData", - "PaletteOverride": "MathNodeTitlePalette" - }, - "{7CC444B1-F9B3-41B5-841B-0C4F2179F111}": { - "$type": "GeometrySaveData", - "Position": [ - 300.0, - 180.0 - ] - }, - "{B0B99C8A-03AF-4CF6-A926-F65C874C3D97}": { - "$type": "StylingComponentSaveData" - }, - "{B1F49A35-8408-40DA-B79E-F1E3B64322CE}": { - "$type": "PersistentIdComponentSaveData", - "PersistentId": "{3B2FC30A-C96E-4D45-8FB8-D93213E40656}" - } - } - } - }, { "Key": { "id": 58654610558628 @@ -3804,8 +3185,8 @@ "{7CC444B1-F9B3-41B5-841B-0C4F2179F111}": { "$type": "GeometrySaveData", "Position": [ - 1300.0, - 480.0 + 1120.0, + 160.0 ] }, "{B0B99C8A-03AF-4CF6-A926-F65C874C3D97}": { @@ -3892,8 +3273,8 @@ "{7CC444B1-F9B3-41B5-841B-0C4F2179F111}": { "$type": "GeometrySaveData", "Position": [ - -480.0, - 500.0 + -420.0, + 180.0 ] }, "{9E81C95F-89C0-4476-8E82-63CCC4E52E04}": { @@ -3990,8 +3371,8 @@ "{7CC444B1-F9B3-41B5-841B-0C4F2179F111}": { "$type": "GeometrySaveData", "Position": [ - 940.0, - 520.0 + 800.0, + 160.0 ] }, "{B0B99C8A-03AF-4CF6-A926-F65C874C3D97}": { @@ -4020,8 +3401,8 @@ "{7CC444B1-F9B3-41B5-841B-0C4F2179F111}": { "$type": "GeometrySaveData", "Position": [ - 100.0, - 540.0 + 60.0, + 160.0 ] }, "{B0B99C8A-03AF-4CF6-A926-F65C874C3D97}": { @@ -4037,46 +3418,15 @@ }, { "Key": { - "id": 239870016727699 - }, - "Value": { - "ComponentData": { - "{24CB38BB-1705-4EC5-8F63-B574571B4DCD}": { - "$type": "NodeSaveData" - }, - "{328FF15C-C302-458F-A43D-E1794DE0904E}": { - "$type": "GeneralNodeTitleComponentSaveData", - "PaletteOverride": "MathNodeTitlePalette" - }, - "{7CC444B1-F9B3-41B5-841B-0C4F2179F111}": { - "$type": "GeometrySaveData", - "Position": [ - 480.0, - 700.0 - ] - }, - "{B0B99C8A-03AF-4CF6-A926-F65C874C3D97}": { - "$type": "StylingComponentSaveData" - }, - "{B1F49A35-8408-40DA-B79E-F1E3B64322CE}": { - "$type": "PersistentIdComponentSaveData", - "PersistentId": "{591ECD3E-51E5-4452-B8F0-91EEC22334EC}" - } - } - } - }, - { - "Key": { - "id": 1874297699023155003 + "id": 8461866310375259320 }, "Value": { "ComponentData": { "{5F84B500-8C45-40D1-8EFC-A5306B241444}": { "$type": "SceneComponentSaveData", "ViewParams": { - "Scale": 0.6141249999999999, - "AnchorX": -615.5098876953125, - "AnchorY": -29.309993743896484 + "AnchorX": -166.0, + "AnchorY": 51.0 } } } @@ -4095,11 +3445,11 @@ }, { "Key": 11545666372999204726, - "Value": 2 + "Value": 1 }, { "Key": 12702286953450386850, - "Value": 6 + "Value": 4 }, { "Key": 12777283451032324504, @@ -4151,103 +3501,9 @@ }, "VariableName": "RotateCamZ" } - }, - { - "Key": { - "m_id": "{6A2D4F20-5402-4283-8799-EB8DEABD6369}" - }, - "Value": { - "Datum": { - "scriptCanvasType": { - "m_type": 3 - }, - "isNullPointer": false, - "$type": "double", - "value": 0.1 - }, - "VariableId": { - "m_id": "{6A2D4F20-5402-4283-8799-EB8DEABD6369}" - }, - "VariableName": "JoystickDeadzone" - } - }, - { - "Key": { - "m_id": "{7062B1EE-2A8A-4E1D-8275-9DA1C5927FF0}" - }, - "Value": { - "Datum": { - "scriptCanvasType": { - "m_type": 3 - }, - "isNullPointer": false, - "$type": "double", - "value": 0.0 - }, - "VariableId": { - "m_id": "{7062B1EE-2A8A-4E1D-8275-9DA1C5927FF0}" - }, - "VariableName": "JoystickRight_X" - } - }, - { - "Key": { - "m_id": "{8E040B94-3374-4228-8020-577BB7C70EE7}" - }, - "Value": { - "Datum": { - "scriptCanvasType": { - "m_type": 3 - }, - "isNullPointer": false, - "$type": "double", - "value": 0.0 - }, - "VariableId": { - "m_id": "{8E040B94-3374-4228-8020-577BB7C70EE7}" - }, - "VariableName": "MoveX" - } - }, - { - "Key": { - "m_id": "{BF2919BD-19B4-4738-AC3A-81857D5204E4}" - }, - "Value": { - "Datum": { - "scriptCanvasType": { - "m_type": 3 - }, - "isNullPointer": false, - "$type": "double", - "value": 0.0 - }, - "VariableId": { - "m_id": "{BF2919BD-19B4-4738-AC3A-81857D5204E4}" - }, - "VariableName": "MoveY" - } } ] - }, - "CopiedVariableRemapping": [ - { - "Key": { - "m_id": "{5EB17E58-0B4E-451D-A1CE-0E7C272CBDEC}" - }, - "Value": { - "m_id": "{BF2919BD-19B4-4738-AC3A-81857D5204E4}" - } - }, - { - "Key": { - "m_id": "{B48E5726-A7FF-42A8-84D2-CF43ABBD1EDC}" - }, - "Value": { - "m_id": "{8E040B94-3374-4228-8020-577BB7C70EE7}" - } - } - ] + } } } } diff --git a/Gems/MotionMatching/Assets/MotionMatching.animgraph b/Gems/MotionMatching/Assets/MotionMatching.animgraph deleted file mode 100644 index e5656a3d05..0000000000 --- a/Gems/MotionMatching/Assets/MotionMatching.animgraph +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f974fa29f3542311ee6a4b6fbb92047186c3124b3bd6f88b728646bf9d686c45 -size 39099 From 1a23dc7b93345c545d398b40b4c4e3a6e8273bd3 Mon Sep 17 00:00:00 2001 From: Benjamin Jillich Date: Fri, 4 Feb 2022 16:29:27 +0100 Subject: [PATCH 03/11] Motion Matching: Debug visualization improvements * Moved reposibility from the instance to the system component to render debug visualizations. Why? To make sure all motion extraction deltas got applied to the character already and avoid any mismatches between last and current frame (resulting in visual jittering). * Added frame database stats to the ImGui monitor. * Switched ImGuiMonitor from internal histogram group to the now shared version in LYImGuiUtils. * Added a new debug draw bus that the motion matching instance hooks to, so that the system component can control when to render debug visualizations. * Added class description for the motion matching instance. Signed-off-by: Benjamin Jillich --- .../MotionMatching/MotionMatchingBus.h | 12 ++ .../Code/Source/BlendTreeMotionMatchNode.cpp | 2 - .../Code/Source/ImGuiMonitor.cpp | 106 ++++++------------ .../MotionMatching/Code/Source/ImGuiMonitor.h | 42 ++----- .../Code/Source/ImGuiMonitorBus.h | 29 ++++- .../Code/Source/MotionMatchingInstance.cpp | 82 ++++---------- .../Code/Source/MotionMatchingInstance.h | 25 +++-- .../Source/MotionMatchingSystemComponent.cpp | 34 +++++- .../Source/MotionMatchingSystemComponent.h | 7 +- 9 files changed, 153 insertions(+), 186 deletions(-) diff --git a/Gems/MotionMatching/Code/Include/MotionMatching/MotionMatchingBus.h b/Gems/MotionMatching/Code/Include/MotionMatching/MotionMatchingBus.h index 5b2bc1847a..dbf38e802b 100644 --- a/Gems/MotionMatching/Code/Include/MotionMatching/MotionMatchingBus.h +++ b/Gems/MotionMatching/Code/Include/MotionMatching/MotionMatchingBus.h @@ -11,8 +11,20 @@ #include #include +#include + namespace EMotionFX::MotionMatching { + class DebugDrawRequests + : public AZ::EBusTraits + { + public: + AZ_RTTI(DebugDrawRequests, "{7BBA4249-EC00-445C-8A0C-4472841049C3}"); + + virtual void DebugDraw(AzFramework::DebugDisplayRequests& debugDisplay) = 0; + }; + using DebugDrawRequestBus = AZ::EBus; + class MotionMatchingRequests { public: diff --git a/Gems/MotionMatching/Code/Source/BlendTreeMotionMatchNode.cpp b/Gems/MotionMatching/Code/Source/BlendTreeMotionMatchNode.cpp index 6661233b66..1546be4669 100644 --- a/Gems/MotionMatching/Code/Source/BlendTreeMotionMatchNode.cpp +++ b/Gems/MotionMatching/Code/Source/BlendTreeMotionMatchNode.cpp @@ -297,8 +297,6 @@ namespace EMotionFX::MotionMatching ImGuiMonitorRequestBus::Broadcast(&ImGuiMonitorRequests::PushPerformanceHistogramValue, "Output", m_outputTimeInMs); #endif } - - instance->DebugDraw(); } AZ::Crc32 BlendTreeMotionMatchNode::GetTrajectoryPathSettingsVisibility() const diff --git a/Gems/MotionMatching/Code/Source/ImGuiMonitor.cpp b/Gems/MotionMatching/Code/Source/ImGuiMonitor.cpp index 97b666c693..158a4b0d23 100644 --- a/Gems/MotionMatching/Code/Source/ImGuiMonitor.cpp +++ b/Gems/MotionMatching/Code/Source/ImGuiMonitor.cpp @@ -16,10 +16,11 @@ namespace EMotionFX::MotionMatching ImGuiMonitor::ImGuiMonitor() { - m_performanceStats.m_name = "Performance Statistics"; + m_performanceStats.SetName("Performance Statistics"); + m_performanceStats.SetHistogramBinCount(500); - m_featureCosts.m_name = "Feature Costs"; - m_featureCosts.m_histogramContainerCount = 100; + m_featureCosts.SetName("Feature Costs"); + m_featureCosts.SetHistogramBinCount(100); ImGui::ImGuiUpdateListenerBus::Handler::BusConnect(); ImGuiMonitorRequestBus::Handler::BusConnect(); @@ -40,18 +41,40 @@ namespace EMotionFX::MotionMatching if (ImGui::Begin("Motion Matching")) { + if (ImGui::CollapsingHeader("Motion Database", ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_Framed)) + { + if (ImGui::BeginTable("MDB", 2)) + { + ImGui::TableNextColumn(); ImGui::Text("Memory Usage: %.2f MB", m_frameDatabaseInfo.m_memoryUsedInBytes / 1024.0f / 1024.0f); + ImGui::TableNextColumn(); ImGui::Text("Motion Data: %.0f minutes", m_frameDatabaseInfo.m_motionDataInSeconds / 60.0f); + ImGui::TableNextColumn(); ImGui::Text("Num Frames: %zu", m_frameDatabaseInfo.m_numFrames); + ImGui::TableNextColumn(); ImGui::Text("Num Motions: %zu", m_frameDatabaseInfo.m_numMotions); + ImGui::EndTable(); + } + } + if (ImGui::CollapsingHeader("Feature Matrix", ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_Framed)) { - ImGui::Text("Memory Usage: %.2f MB", m_featureMatrixMemoryUsageInBytes / 1024.0f / 1024.0f); - ImGui::Text("Num Frames: %zu", m_featureMatrixNumFrames); - ImGui::Text("Num Feature Components: %zu", m_featureMatrixNumComponents); + if (ImGui::BeginTable("FM", 2)) + { + ImGui::TableNextColumn(); ImGui::Text("Memory Usage: %.2f MB", m_featurMatrixInfo.m_memoryUsedInBytes / 1024.0f / 1024.0f); + ImGui::TableNextColumn(); + ImGui::TableNextColumn(); ImGui::Text("Num Frames: %zu", m_featurMatrixInfo.m_numFrames); + ImGui::TableNextColumn(); ImGui::Text("Num Feature Components: %zu", m_featurMatrixInfo.m_numDimensions); + ImGui::EndTable(); + } } if (ImGui::CollapsingHeader("Kd-Tree", ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_Framed)) { - ImGui::Text("Memory Usage: %.2f MB", m_kdTreeMemoryUsageInBytes / 1024.0f / 1024.0f); - ImGui::Text("Num Nodes: %zu", m_kdTreeNumNodes); - ImGui::Text("Num Dimensions: %zu", m_kdTreeNumDimensions); + if (ImGui::BeginTable("KDT", 2)) + { + ImGui::TableNextColumn(); ImGui::Text("Memory Usage: %.2f MB", m_kdTreeInfo.m_memoryUsedInBytes / 1024.0f / 1024.0f); + ImGui::TableNextColumn(); + ImGui::TableNextColumn(); ImGui::Text("Num Nodes: %zu", m_kdTreeInfo.m_numNodes); + ImGui::TableNextColumn(); ImGui::Text("Num Dimensions: %zu", m_kdTreeInfo.m_numDimensions); + ImGui::EndTable(); + } } m_performanceStats.OnImGuiUpdate(); @@ -63,8 +86,8 @@ namespace EMotionFX::MotionMatching { if (ImGui::BeginMenu("Motion Matching")) { - ImGui::MenuItem(m_performanceStats.m_name.c_str(), "", &m_performanceStats.m_show); - ImGui::MenuItem(m_featureCosts.m_name.c_str(), "", &m_featureCosts.m_show); + ImGui::MenuItem(m_performanceStats.GetName(), "", &m_performanceStats.m_show); + ImGui::MenuItem(m_featureCosts.GetName(), "", &m_featureCosts.m_show); ImGui::EndMenu(); } } @@ -78,67 +101,6 @@ namespace EMotionFX::MotionMatching { m_featureCosts.PushHistogramValue(costName, value, color); } - - void ImGuiMonitor::HistogramGroup::PushHistogramValue(const char* valueName, float value, const AZ::Color& color) - { - auto iterator = m_histogramIndexByName.find(valueName); - if (iterator != m_histogramIndexByName.end()) - { - ImGui::LYImGuiUtils::HistogramContainer& histogramContiner = m_histograms[iterator->second]; - histogramContiner.PushValue(value); - histogramContiner.SetBarLineColor(ImColor(color.GetR(), color.GetG(), color.GetB(), color.GetA())); - } - else - { - ImGui::LYImGuiUtils::HistogramContainer newHistogram; - newHistogram.Init(/*histogramName=*/valueName, - /*containerCount=*/m_histogramContainerCount, - /*viewType=*/ImGui::LYImGuiUtils::HistogramContainer::ViewType::Histogram, - /*displayOverlays=*/true, - /*min=*/0.0f, - /*max=*/0.0f); - - newHistogram.SetMoveDirection(ImGui::LYImGuiUtils::HistogramContainer::PushRightMoveLeft); - newHistogram.PushValue(value); - - m_histogramIndexByName[valueName] = m_histograms.size(); - m_histograms.push_back(newHistogram); - } - } - - void ImGuiMonitor::HistogramGroup::OnImGuiUpdate() - { - if (!m_show) - { - return; - } - - if (ImGui::CollapsingHeader(m_name.c_str(), ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_Framed)) - { - for (auto& histogram : m_histograms) - { - ImGui::BeginGroup(); - { - histogram.Draw(ImGui::GetColumnWidth() - 70, s_histogramHeight); - - ImGui::SameLine(); - - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0,0,0,255)); - { - const ImColor color = histogram.GetBarLineColor(); - ImGui::PushStyleColor(ImGuiCol_Button, color.Value); - { - const AZStd::string valueString = AZStd::string::format("%.2f", histogram.GetLastValue()); - ImGui::Button(valueString.c_str()); - } - ImGui::PopStyleColor(); - } - ImGui::PopStyleColor(); - } - ImGui::EndGroup(); - } - } - } } // namespace EMotionFX::MotionMatching #endif // IMGUI_ENABLED diff --git a/Gems/MotionMatching/Code/Source/ImGuiMonitor.h b/Gems/MotionMatching/Code/Source/ImGuiMonitor.h index 0583d0ba41..a2af477987 100644 --- a/Gems/MotionMatching/Code/Source/ImGuiMonitor.h +++ b/Gems/MotionMatching/Code/Source/ImGuiMonitor.h @@ -20,7 +20,7 @@ #include #include #include -#include +#include namespace EMotionFX::MotionMatching { @@ -43,41 +43,17 @@ namespace EMotionFX::MotionMatching void PushPerformanceHistogramValue(const char* performanceMetricName, float value) override; void PushCostHistogramValue(const char* costName, float value, const AZ::Color& color) override; - void SetFeatureMatrixMemoryUsage(size_t sizeInBytes) override { m_featureMatrixMemoryUsageInBytes = sizeInBytes; } - void SetFeatureMatrixNumFrames(size_t numFrames) override { m_featureMatrixNumFrames = numFrames; } - void SetFeatureMatrixNumComponents(size_t numFeatureComponents) override { m_featureMatrixNumComponents = numFeatureComponents; } - - void SetKdTreeMemoryUsage(size_t sizeInBytes) override { m_kdTreeMemoryUsageInBytes = sizeInBytes; } - void SetKdTreeNumNodes(size_t numNodes) override { m_kdTreeNumNodes = numNodes; } - void SetKdTreeNumDimensions(size_t numDimensions) override { m_kdTreeNumDimensions = numDimensions; } + void SetFrameDatabaseInfo(const ImGuiMonitorRequests::FrameDatabaseInfo& info) override { m_frameDatabaseInfo = info; } + void SetFeatureMatrixInfo(const ImGuiMonitorRequests::FeatureMatrixInfo& info) override { m_featurMatrixInfo = info; } + void SetKdTreeInfo(const ImGuiMonitorRequests::KdTreeInfo& info) override { m_kdTreeInfo = info; } private: - //! Named and sub-divided group containing several histograms. - struct HistogramGroup - { - void OnImGuiUpdate(); - void PushHistogramValue(const char* valueName, float value, const AZ::Color& color); + ImGui::LYImGuiUtils::HistogramGroup m_performanceStats; + ImGui::LYImGuiUtils::HistogramGroup m_featureCosts; - bool m_show = true; - AZStd::string m_name; - using HistogramIndexByNames = AZStd::unordered_map; - HistogramIndexByNames m_histogramIndexByName; - AZStd::vector m_histograms; - int m_histogramContainerCount = 500; - - static constexpr float s_histogramHeight = 95.0f; - }; - - HistogramGroup m_performanceStats; - HistogramGroup m_featureCosts; - - size_t m_featureMatrixMemoryUsageInBytes = 0; - size_t m_featureMatrixNumFrames = 0; - size_t m_featureMatrixNumComponents = 0; - - size_t m_kdTreeMemoryUsageInBytes = 0; - size_t m_kdTreeNumNodes = 0; - size_t m_kdTreeNumDimensions = 0; + ImGuiMonitorRequests::FrameDatabaseInfo m_frameDatabaseInfo; + ImGuiMonitorRequests::FeatureMatrixInfo m_featurMatrixInfo; + ImGuiMonitorRequests::KdTreeInfo m_kdTreeInfo; }; } // namespace EMotionFX::MotionMatching diff --git a/Gems/MotionMatching/Code/Source/ImGuiMonitorBus.h b/Gems/MotionMatching/Code/Source/ImGuiMonitorBus.h index 7c50b317c5..faadd79681 100644 --- a/Gems/MotionMatching/Code/Source/ImGuiMonitorBus.h +++ b/Gems/MotionMatching/Code/Source/ImGuiMonitorBus.h @@ -25,13 +25,30 @@ namespace EMotionFX::MotionMatching virtual void PushPerformanceHistogramValue(const char* performanceMetricName, float value) = 0; virtual void PushCostHistogramValue(const char* costName, float value, const AZ::Color& color) = 0; - virtual void SetFeatureMatrixMemoryUsage(size_t sizeInBytes) = 0; - virtual void SetFeatureMatrixNumFrames(size_t numFrames) = 0; - virtual void SetFeatureMatrixNumComponents(size_t numFeatureComponents) = 0; + struct FrameDatabaseInfo + { + size_t m_memoryUsedInBytes = 0; + size_t m_numFrames; + size_t m_numMotions; + float m_motionDataInSeconds; + }; + virtual void SetFrameDatabaseInfo(const FrameDatabaseInfo& info) = 0; - virtual void SetKdTreeMemoryUsage(size_t sizeInBytes) = 0; - virtual void SetKdTreeNumNodes(size_t numNodes) = 0; - virtual void SetKdTreeNumDimensions(size_t numDimensions) = 0; + struct FeatureMatrixInfo + { + size_t m_memoryUsedInBytes = 0; + size_t m_numFrames = 0; + size_t m_numDimensions = 0; + }; + virtual void SetFeatureMatrixInfo(const FeatureMatrixInfo& info) = 0; + + struct KdTreeInfo + { + size_t m_memoryUsedInBytes = 0; + size_t m_numNodes = 0; + size_t m_numDimensions = 0; + }; + virtual void SetKdTreeInfo(const KdTreeInfo& info) = 0; }; using ImGuiMonitorRequestBus = AZ::EBus; } // namespace EMotionFX::MotionMatching diff --git a/Gems/MotionMatching/Code/Source/MotionMatchingInstance.cpp b/Gems/MotionMatching/Code/Source/MotionMatchingInstance.cpp index 54fc2918e6..36a51f2677 100644 --- a/Gems/MotionMatching/Code/Source/MotionMatchingInstance.cpp +++ b/Gems/MotionMatching/Code/Source/MotionMatchingInstance.cpp @@ -28,14 +28,14 @@ #include #include -#include - namespace EMotionFX::MotionMatching { AZ_CLASS_ALLOCATOR_IMPL(MotionMatchingInstance, MotionMatchAllocator, 0) MotionMatchingInstance::~MotionMatchingInstance() { + DebugDrawRequestBus::Handler::BusDisconnect(); + if (m_motionInstance) { GetMotionInstancePool().Free(m_motionInstance); @@ -58,6 +58,8 @@ namespace EMotionFX::MotionMatching AZ_Assert(settings.m_actorInstance, "The actor instance cannot be a nullptr."); AZ_Assert(settings.m_data, "The motion match data cannot be nullptr."); + DebugDrawRequestBus::Handler::BusConnect(); + // Update the cached pointer to the trajectory feature. const FeatureSchema& featureSchema = settings.m_data->GetFeatureSchema(); for (Feature* feature : featureSchema.GetFeatures()) @@ -69,29 +71,6 @@ namespace EMotionFX::MotionMatching } } - // Debug display initialization. - const auto AddDebugDisplay = [=](AZ::s32 debugDisplayId) - { - if (debugDisplayId == -1) - { - return; - } - - AzFramework::DebugDisplayRequestBus::BusPtr debugDisplayBus; - AzFramework::DebugDisplayRequestBus::Bind(debugDisplayBus, debugDisplayId); - - AzFramework::DebugDisplayRequests* debugDisplay = AzFramework::DebugDisplayRequestBus::FindFirstHandler(debugDisplayBus); - if (debugDisplay) - { - m_debugDisplays.emplace_back(debugDisplay); - } - }; - // Draw the debug visualizations to the Animation Editor as well as the LY Editor viewport. - AZ::s32 animationEditorViewportId = -1; - EMStudio::ViewportPluginRequestBus::BroadcastResult(animationEditorViewportId, &EMStudio::ViewportPluginRequestBus::Events::GetViewportId); - AddDebugDisplay(animationEditorViewportId); - AddDebugDisplay(AzFramework::g_defaultSceneEntityDebugDisplayId); - m_actorInstance = settings.m_actorInstance; m_data = settings.m_data; if (settings.m_data->GetFrameDatabase().GetNumFrames() == 0) @@ -123,30 +102,17 @@ namespace EMotionFX::MotionMatching m_queryFeatureValues.resize(numValuesInKdTree); // Initialize the trajectory history. - size_t rootJointIndex = m_actorInstance->GetActor()->GetMotionExtractionNodeIndex(); - if (rootJointIndex == InvalidIndex32) + if (m_cachedTrajectoryFeature) { - rootJointIndex = 0; - } - m_trajectoryHistory.Init(*m_actorInstance->GetTransformData()->GetCurrentPose(), - rootJointIndex, - m_cachedTrajectoryFeature->GetFacingAxisDir(), - m_trajectorySecsToTrack); - } - - void MotionMatchingInstance::DebugDraw() - { - if (m_data && !m_debugDisplays.empty()) - { - for (AzFramework::DebugDisplayRequests* debugDisplay : m_debugDisplays) + size_t rootJointIndex = m_actorInstance->GetActor()->GetMotionExtractionNodeIndex(); + if (rootJointIndex == InvalidIndex32) { - if (debugDisplay) - { - const AZ::u32 prevState = debugDisplay->GetState(); - DebugDraw(*debugDisplay); - debugDisplay->SetState(prevState); - } + rootJointIndex = 0; } + m_trajectoryHistory.Init(*m_actorInstance->GetTransformData()->GetCurrentPose(), + rootJointIndex, + m_cachedTrajectoryFeature->GetFacingAxisDir(), + m_trajectorySecsToTrack); } } @@ -306,7 +272,7 @@ namespace EMotionFX::MotionMatching { AZ_PROFILE_SCOPE(Animation, "MotionMatchingInstance::Update"); - if (!m_data) + if (!m_data || !m_motionInstance) { return; } @@ -322,7 +288,7 @@ namespace EMotionFX::MotionMatching // Update the time. After this there is no sample for the updated time in the history as we're about to prepare this with the current update. m_trajectoryHistory.Update(timePassedInSeconds); - // Register the current actor instance position to the history data of the spline. + // Update the trajectory query control points. m_trajectoryQuery.Update(m_actorInstance, m_cachedTrajectoryFeature, m_trajectoryHistory, @@ -371,8 +337,7 @@ namespace EMotionFX::MotionMatching SamplePose(m_motionInstance->GetMotion(), m_queryPose, newMotionTime); // Copy over the motion extraction joint transform from the current pose to the newly sampled pose. - // When sampling a motion, the motion extraction joint is in animation space, while we need the query pose to be in - // world space. + // When sampling a motion, the motion extraction joint is in animation space, while we need the query pose to be in world space. // Note: This does not yet take the extraction delta from the current tick into account. if (m_actorInstance->GetActor()->GetMotionExtractionNode()) { @@ -433,16 +398,17 @@ namespace EMotionFX::MotionMatching // ImGui monitor { #ifdef IMGUI_ENABLED - const KdTree& kdTree = m_data->GetKdTree(); - ImGuiMonitorRequestBus::Broadcast(&ImGuiMonitorRequests::SetKdTreeMemoryUsage, kdTree.CalcMemoryUsageInBytes()); - ImGuiMonitorRequestBus::Broadcast(&ImGuiMonitorRequests::SetKdTreeNumNodes, kdTree.GetNumNodes()); - ImGuiMonitorRequestBus::Broadcast(&ImGuiMonitorRequests::SetKdTreeNumDimensions, kdTree.GetNumDimensions()); - // TODO: add memory usage for frame database + const FrameDatabase& frameDatabase = m_data->GetFrameDatabase(); + ImGuiMonitorRequests::FrameDatabaseInfo frameDatabaseInfo{frameDatabase.CalcMemoryUsageInBytes(), frameDatabase.GetNumFrames(), frameDatabase.GetNumUsedMotions(), frameDatabase.GetNumFrames() / (float)frameDatabase.GetSampleRate()}; + ImGuiMonitorRequestBus::Broadcast(&ImGuiMonitorRequests::SetFrameDatabaseInfo, frameDatabaseInfo); + const KdTree& kdTree = m_data->GetKdTree(); + ImGuiMonitorRequests::KdTreeInfo kdTreeInfo{kdTree.CalcMemoryUsageInBytes(), kdTree.GetNumNodes(), kdTree.GetNumDimensions()}; + ImGuiMonitorRequestBus::Broadcast(&ImGuiMonitorRequests::SetKdTreeInfo, kdTreeInfo); + const FeatureMatrix& featureMatrix = m_data->GetFeatureMatrix(); - ImGuiMonitorRequestBus::Broadcast(&ImGuiMonitorRequests::SetFeatureMatrixMemoryUsage, featureMatrix.CalcMemoryUsageInBytes()); - ImGuiMonitorRequestBus::Broadcast(&ImGuiMonitorRequests::SetFeatureMatrixNumFrames, featureMatrix.rows()); - ImGuiMonitorRequestBus::Broadcast(&ImGuiMonitorRequests::SetFeatureMatrixNumComponents, featureMatrix.cols()); + ImGuiMonitorRequests::FeatureMatrixInfo featureMatrixInfo{featureMatrix.CalcMemoryUsageInBytes(), static_cast(featureMatrix.rows()), static_cast(featureMatrix.cols())}; + ImGuiMonitorRequestBus::Broadcast(&ImGuiMonitorRequests::SetFeatureMatrixInfo, featureMatrixInfo); #endif } } diff --git a/Gems/MotionMatching/Code/Source/MotionMatchingInstance.h b/Gems/MotionMatching/Code/Source/MotionMatchingInstance.h index 49c781162d..0969763809 100644 --- a/Gems/MotionMatching/Code/Source/MotionMatchingInstance.h +++ b/Gems/MotionMatching/Code/Source/MotionMatchingInstance.h @@ -19,6 +19,8 @@ #include #include +#include + namespace AZ { class ReflectContext; @@ -34,12 +36,17 @@ namespace EMotionFX::MotionMatching { class MotionMatchingData; + //! The instance is where everything comes together. It stores the trajectory history, the trajectory query along with the query vector, knows about the + //! last lowest cost frame frame index and stores the time of the animation that the instance is currently playing. It is responsible for motion extraction, + //! blending towards a new frame in the motion capture database in case the algorithm found a better matching frame and executes the actual search. class EMFX_API MotionMatchingInstance + : public DebugDrawRequestBus::Handler { public: AZ_RTTI(MotionMatchingInstance, "{1ED03AD8-0FB2-431B-AF01-02F7E930EB73}") AZ_CLASS_ALLOCATOR_DECL + MotionMatchingInstance() = default; virtual ~MotionMatchingInstance(); struct EMFX_API InitSettings @@ -49,8 +56,8 @@ namespace EMotionFX::MotionMatching }; void Init(const InitSettings& settings); - void DebugDraw(); - void DebugDraw(AzFramework::DebugDisplayRequests& debugDisplay); + // DebugDrawRequestBus::Handler overrides + void DebugDraw(AzFramework::DebugDisplayRequests& debugDisplay) override; void Update(float timePassedInSeconds, const AZ::Vector3& targetPos, const AZ::Vector3& targetFacingDir, TrajectoryQuery::EMode mode, float pathRadius, float pathSpeed); void PostUpdate(float timeDelta); @@ -64,10 +71,8 @@ namespace EMotionFX::MotionMatching void SetLowestCostSearchFrequency(float frequency) { m_lowestCostSearchFrequency = frequency; } float GetNewMotionTime() const { return m_newMotionTime; } - /** - * Get the cached trajectory feature. - * The trajectory feature is searched in the feature schema used in the current instance at init time. - */ + //! Get the cached trajectory feature. + //! The trajectory feature is searched in the feature schema used in the current instance at init time. FeatureTrajectory* GetTrajectoryFeature() const { return m_cachedTrajectoryFeature; } const TrajectoryQuery& GetTrajectoryQuery() const { return m_trajectoryQuery; } const TrajectoryHistory& GetTrajectoryHistory() const { return m_trajectoryHistory; } @@ -90,10 +95,10 @@ namespace EMotionFX::MotionMatching Transform m_motionExtractionDelta = Transform::CreateIdentity(); /// Buffers used for the broad-phase KD-tree search. - AZStd::vector m_queryFeatureValues; /** The input query features to be compared to every entry/row in the feature matrix with the motion matching search. */ - AZStd::vector m_nearestFrames; /** Stores the nearest matching frames / search result from the KD-tree. */ + AZStd::vector m_queryFeatureValues; //< The input query features to be compared to every entry/row in the feature matrix with the motion matching search. + AZStd::vector m_nearestFrames; //< Stores the nearest matching frames / search result from the KD-tree. - FeatureTrajectory* m_cachedTrajectoryFeature = nullptr; /** Cached pointer to the trajectory feature in the feature schema. */ + FeatureTrajectory* m_cachedTrajectoryFeature = nullptr; //< Cached pointer to the trajectory feature in the feature schema. TrajectoryQuery m_trajectoryQuery; TrajectoryHistory m_trajectoryHistory; static constexpr float m_trajectorySecsToTrack = 5.0f; @@ -105,7 +110,7 @@ namespace EMotionFX::MotionMatching bool m_blending = false; float m_blendWeight = 1.0f; - float m_blendProgressTime = 0.0f; // How long are we already blending? In seconds. + float m_blendProgressTime = 0.0f; //< How long are we already blending? In seconds. /// Buffers used for FindLowestCostFrameIndex(). AZStd::vector m_tempCosts; diff --git a/Gems/MotionMatching/Code/Source/MotionMatchingSystemComponent.cpp b/Gems/MotionMatching/Code/Source/MotionMatchingSystemComponent.cpp index 073362d741..9091c60c0a 100644 --- a/Gems/MotionMatching/Code/Source/MotionMatchingSystemComponent.cpp +++ b/Gems/MotionMatching/Code/Source/MotionMatchingSystemComponent.cpp @@ -16,6 +16,8 @@ #include +#include + #include #include #include @@ -39,7 +41,7 @@ namespace EMotionFX::MotionMatching { ec->Class("MotionMatching", "[Description of functionality provided by this System Component]") ->ClassElement(AZ::Edit::ClassElements::EditorData, "") - ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System")) + ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("System")) ->Attribute(AZ::Edit::Attributes::AutoExpand, true) ; } @@ -69,9 +71,9 @@ namespace EMotionFX::MotionMatching incompatible.push_back(AZ_CRC_CE("MotionMatchingService")); } - void MotionMatchingSystemComponent::GetRequiredServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& required) + void MotionMatchingSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required) { - required.push_back(AZ_CRC("EMotionFXAnimationService", 0x3f8a6369)); + required.push_back(AZ_CRC_CE("EMotionFXAnimationService")); } void MotionMatchingSystemComponent::GetDependentServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& dependent) @@ -122,7 +124,33 @@ namespace EMotionFX::MotionMatching MotionMatchingRequestBus::Handler::BusDisconnect(); } + void MotionMatchingSystemComponent::DebugDraw(AZ::s32 debugDisplayId) + { + AZ_PROFILE_SCOPE(Animation, "MotionMatchingSystemComponent::DebugDraw"); + + if (debugDisplayId == -1) + { + return; + } + + AzFramework::DebugDisplayRequestBus::BusPtr debugDisplayBus; + AzFramework::DebugDisplayRequestBus::Bind(debugDisplayBus, debugDisplayId); + + AzFramework::DebugDisplayRequests* debugDisplay = AzFramework::DebugDisplayRequestBus::FindFirstHandler(debugDisplayBus); + if (debugDisplay) + { + const AZ::u32 prevState = debugDisplay->GetState(); + EMotionFX::MotionMatching::DebugDrawRequestBus::Broadcast(&EMotionFX::MotionMatching::DebugDrawRequests::DebugDraw, *debugDisplay); + debugDisplay->SetState(prevState); + } + } + void MotionMatchingSystemComponent::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time) { + // Draw the debug visualizations to the Animation Editor as well as the LY Editor viewport. + AZ::s32 animationEditorViewportId = -1; + EMStudio::ViewportPluginRequestBus::BroadcastResult(animationEditorViewportId, &EMStudio::ViewportPluginRequestBus::Events::GetViewportId); + DebugDraw(animationEditorViewportId); + DebugDraw(AzFramework::g_defaultSceneEntityDebugDisplayId); } } // namespace EMotionFX::MotionMatching diff --git a/Gems/MotionMatching/Code/Source/MotionMatchingSystemComponent.h b/Gems/MotionMatching/Code/Source/MotionMatchingSystemComponent.h index 6a5b5a7b73..09d47b9dc3 100644 --- a/Gems/MotionMatching/Code/Source/MotionMatchingSystemComponent.h +++ b/Gems/MotionMatching/Code/Source/MotionMatchingSystemComponent.h @@ -33,8 +33,7 @@ namespace EMotionFX::MotionMatching ~MotionMatchingSystemComponent(); protected: - //////////////////////////////////////////////////////////////////////// - // MotionMatchingRequestBus interface implementation + void DebugDraw(AZ::s32 debugDisplayId); //////////////////////////////////////////////////////////////////////// // AZ::Component interface implementation @@ -45,6 +44,10 @@ namespace EMotionFX::MotionMatching //////////////////////////////////////////////////////////////////////// // AZTickBus interface implementation + int GetTickOrder() override + { + return AZ::TICK_PRE_RENDER; + } void OnTick(float deltaTime, AZ::ScriptTimePoint time) override; //////////////////////////////////////////////////////////////////////// }; From 5baf7d5147330fd6913764bd9ab5ca2bcd5cf23b Mon Sep 17 00:00:00 2001 From: antonmic <56370189+antonmic@users.noreply.github.com> Date: Fri, 4 Feb 2022 12:46:42 -0800 Subject: [PATCH 04/11] removing compute queue flag from SSAO since it's causing crashes for some people Signed-off-by: antonmic <56370189+antonmic@users.noreply.github.com> --- Gems/Atom/Feature/Common/Assets/Passes/SsaoCompute.pass | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/Passes/SsaoCompute.pass b/Gems/Atom/Feature/Common/Assets/Passes/SsaoCompute.pass index 2c48506f8f..3c4a8c76f1 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/SsaoCompute.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/SsaoCompute.pass @@ -50,8 +50,7 @@ "FilePath": "Shaders/PostProcessing/SsaoCompute.shader" }, "Make Fullscreen Pass": true, - "PipelineViewTag": "MainCamera", - "Use Async Compute": true + "PipelineViewTag": "MainCamera" }, "FallbackConnections": [ { From 69e0090a0b0f6e952832d17bd7cbae3c1db48309 Mon Sep 17 00:00:00 2001 From: Steve Pham <82231385+spham-amzn@users.noreply.github.com> Date: Fri, 4 Feb 2022 14:20:09 -0800 Subject: [PATCH 05/11] Remove -Wno-return-local-addr warning suppression for GCC - Remove '-Wno-return-local-addr' warning suppression flag for GCC - Fixed discovered error resulting from -Wreturn-local-addr Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com> * Remove extra ws Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com> --- .../AzCore/RTTI/AzStdOnDemandReflectionSpecializations.cpp | 2 +- cmake/Platform/Common/GCC/Configurations_gcc.cmake | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflectionSpecializations.cpp b/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflectionSpecializations.cpp index c42e32cd42..582d106964 100644 --- a/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflectionSpecializations.cpp +++ b/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflectionSpecializations.cpp @@ -136,7 +136,7 @@ namespace AZ::CommonOnDemandReflections ->template Constructor() ->Attribute(AZ::Script::Attributes::ConstructorOverride, &OnDemandLuaFunctions::ConstructStringView) ->Attribute(AZ::Script::Attributes::ReaderWriterOverride, ScriptContext::CustomReaderWriter(&OnDemandLuaFunctions::StringTypeToLua, &OnDemandLuaFunctions::StringTypeFromLua)) - ->Method("ToString", [](const ContainerType& stringView) { return static_cast(stringView).c_str(); }, { { { "Reference", "String view object being converted to string" } } }) + ->Method("ToString", [](const ContainerType& stringView) { return stringView.data(); }, { { { "Reference", "String view object being converted to string" } } }) ->Attribute(AZ::Script::Attributes::ToolTip, "Converts string_view to string") ->Attribute(AZ::Script::Attributes::Operator, AZ::Script::Attributes::OperatorType::ToString) ->template WrappingMember(&ContainerType::data) diff --git a/cmake/Platform/Common/GCC/Configurations_gcc.cmake b/cmake/Platform/Common/GCC/Configurations_gcc.cmake index 12dd4d7bdd..ad5f3bec28 100644 --- a/cmake/Platform/Common/GCC/Configurations_gcc.cmake +++ b/cmake/Platform/Common/GCC/Configurations_gcc.cmake @@ -55,7 +55,6 @@ ly_append_configurations_options( -Wno-parentheses -Wno-reorder -Wno-restrict - -Wno-return-local-addr -Wno-sequence-point -Wno-sign-compare -Wno-strict-aliasing From dc6d8ab2bace71dffa5597c2ed56a4a6bc92a665 Mon Sep 17 00:00:00 2001 From: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> Date: Fri, 4 Feb 2022 17:21:48 -0800 Subject: [PATCH 06/11] Fix conversion issues blocking nightly builds. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> --- .../AzToolsFramework/Prefab/PrefabFocusHandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp index c7e37258f2..62c6518d4c 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp @@ -222,7 +222,7 @@ namespace AzToolsFramework::Prefab SetInstanceContainersOpenState(m_rootAliasFocusPath, false); const RootAliasPath previousContainerRootAliasPath = m_rootAliasFocusPath; - const InstanceOptionalConstReference previousFocusedInstance = GetInstanceReference(previousContainerRootAliasPath); + const InstanceOptionalReference previousFocusedInstance = GetInstanceReference(previousContainerRootAliasPath); m_rootAliasFocusPath = focusedInstance->get().GetAbsoluteInstanceAliasPath(); m_focusedTemplateId = focusedInstance->get().GetTemplateId(); @@ -277,7 +277,7 @@ namespace AzToolsFramework::Prefab AZ::EntityId PrefabFocusHandler::GetFocusedPrefabContainerEntityId([[maybe_unused]] AzFramework::EntityContextId entityContextId) const { - if (const InstanceOptionalConstReference instance = GetInstanceReference(m_rootAliasFocusPath); instance.has_value()) + if (const InstanceOptionalReference instance = GetInstanceReference(m_rootAliasFocusPath); instance.has_value()) { return instance->get().GetContainerEntityId(); } From a6ddf4164f36c9687119dd2034d6fa8dc00b8e66 Mon Sep 17 00:00:00 2001 From: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com> Date: Mon, 7 Feb 2022 10:57:39 -0600 Subject: [PATCH 07/11] SurfaceTagWeights optimization (#7436) * Add comparison operators to SurfaceTagWeight. Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com> * Changed AddSurfaceTagWeight to always combine weights. This simplifies the API a bit and defines the behavior if someone ever tries to add a duplicate tag. Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com> * Added benchmarks for measuring the performance-critical APIs. Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com> * Changed SurfaceTagWeights to a fixed_vector. Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com> --- .../AzFramework/SurfaceData/SurfaceData.h | 13 +++ .../GradientSurfaceDataComponent.cpp | 2 +- .../Include/SurfaceData/SurfaceDataTypes.h | 91 +++++++++++++------ .../SurfaceDataColliderComponent.cpp | 2 +- .../Components/SurfaceDataShapeComponent.cpp | 2 +- .../Code/Source/SurfaceDataTypes.cpp | 62 +++++++------ .../Code/Tests/SurfaceDataBenchmarks.cpp | 83 +++++++++++++++++ .../Code/Tests/SurfaceDataTest.cpp | 2 +- .../Code/Source/AreaSystemComponent.cpp | 2 +- 9 files changed, 198 insertions(+), 61 deletions(-) diff --git a/Code/Framework/AzFramework/AzFramework/SurfaceData/SurfaceData.h b/Code/Framework/AzFramework/AzFramework/SurfaceData/SurfaceData.h index 77d9ae4239..9faa03f921 100644 --- a/Code/Framework/AzFramework/AzFramework/SurfaceData/SurfaceData.h +++ b/Code/Framework/AzFramework/AzFramework/SurfaceData/SurfaceData.h @@ -29,6 +29,19 @@ namespace AzFramework::SurfaceData { } + //! Equality comparison operator for SurfaceTagWeight. + bool operator==(const SurfaceTagWeight& rhs) const + { + return (m_surfaceType == rhs.m_surfaceType) && (m_weight == rhs.m_weight); + } + + //! Inequality comparison operator for SurfaceTagWeight. + bool operator!=(const SurfaceTagWeight& rhs) const + { + return !(*this == rhs); + } + + AZ::Crc32 m_surfaceType = AZ::Crc32(Constants::s_unassignedTagName); float m_weight = 0.0f; //! A Value in the range [0.0f .. 1.0f] diff --git a/Gems/GradientSignal/Code/Source/Components/GradientSurfaceDataComponent.cpp b/Gems/GradientSignal/Code/Source/Components/GradientSurfaceDataComponent.cpp index cd87e3044c..86bcbf2a2d 100644 --- a/Gems/GradientSignal/Code/Source/Components/GradientSurfaceDataComponent.cpp +++ b/Gems/GradientSignal/Code/Source/Components/GradientSurfaceDataComponent.cpp @@ -251,7 +251,7 @@ namespace GradientSignal const float value = m_gradientSampler.GetValue(sampleParams); if (value >= m_configuration.m_thresholdMin && value <= m_configuration.m_thresholdMax) { - weights.AddSurfaceWeightsIfGreater(m_configuration.m_modifierTags, value); + weights.AddSurfaceTagWeights(m_configuration.m_modifierTags, value); } } }); diff --git a/Gems/SurfaceData/Code/Include/SurfaceData/SurfaceDataTypes.h b/Gems/SurfaceData/Code/Include/SurfaceData/SurfaceDataTypes.h index c892bc8c09..943c45bb6a 100644 --- a/Gems/SurfaceData/Code/Include/SurfaceData/SurfaceDataTypes.h +++ b/Gems/SurfaceData/Code/Include/SurfaceData/SurfaceDataTypes.h @@ -24,9 +24,17 @@ namespace SurfaceData using SurfaceTagVector = AZStd::vector; //! SurfaceTagWeights stores a collection of surface tags and weights. + //! A surface tag can only appear once in the collection. Attempting to add it multiple times will always preserve the + //! highest weight value. class SurfaceTagWeights { public: + //! The maximum number of surface weights that we can store. + //! For performance reasons, we want to limit this so that we can preallocate the max size in advance. + //! The current number is chosen to be higher than expected needs, but small enough to avoid being excessively wasteful. + //! (Dynamic structures would end up taking more memory than what we're preallocating) + static inline constexpr size_t MaxSurfaceWeights = 16; + SurfaceTagWeights() = default; //! Construct a collection of SurfaceTagWeights from the given SurfaceTagWeightList. @@ -45,42 +53,68 @@ namespace SurfaceData //! @param weight - The weight to assign to each tag. void AssignSurfaceTagWeights(const SurfaceTagVector& tags, float weight); - //! Add a surface tag weight to this collection. - //! @param tag - The surface tag. - //! @param weight - The surface tag weight. - void AddSurfaceTagWeight(const AZ::Crc32 tag, const float weight); - - //! Replace the surface tag weight with the new one if it's higher, or add it if the tag isn't found. + //! Add a surface tag weight to this collection. If the tag already exists, the higher weight will be preserved. //! (This method is intentionally inlined for its performance impact) //! @param tag - The surface tag. //! @param weight - The surface tag weight. - void AddSurfaceWeightIfGreater(const AZ::Crc32 tag, const float weight) + void AddSurfaceTagWeight(const AZ::Crc32 tag, const float weight) { - const auto maskItr = m_weights.find(tag); - const float previousValue = maskItr != m_weights.end() ? maskItr->second : 0.0f; - m_weights[tag] = AZ::GetMax(weight, previousValue); - } - - //! Replace the surface tag weight with the new one if it's higher, or add it if the tag isn't found. - //! (This method is intentionally inlined for its performance impact) - //! @param tags - The surface tags to replace/add. - //! @param weight - The surface tag weight to use for each tag. - void AddSurfaceWeightsIfGreater(const SurfaceTagVector& tags, const float weight) - { - for (const auto& tag : tags) + for (auto weightItr = m_weights.begin(); weightItr != m_weights.end(); ++weightItr) { - AddSurfaceWeightIfGreater(tag, weight); + // Since we need to scan for duplicate surface types, store the entries sorted by surface type so that we can + // early-out once we pass the location for the entry instead of always searching every entry. + if (weightItr->m_surfaceType > tag) + { + if (m_weights.size() != MaxSurfaceWeights) + { + // We didn't find the surface type, so add the new entry in sorted order. + m_weights.insert(weightItr, { tag, weight }); + } + else + { + AZ_Assert(false, "SurfaceTagWeights has reached max capacity, it cannot add a new tag / weight."); + } + return; + } + else if (weightItr->m_surfaceType == tag) + { + // We found the surface type, so just keep the higher of the two weights. + weightItr->m_weight = AZ::GetMax(weight, weightItr->m_weight); + return; + } + } + + // We didn't find the surface weight, and the sort order for it is at the end, so add it to the back of the list. + if (m_weights.size() != MaxSurfaceWeights) + { + m_weights.emplace_back(tag, weight); + } + else + { + AZ_Assert(false, "SurfaceTagWeights has reached max capacity, it cannot add a new tag / weight."); } } - //! Replace the surface tag weight with the new one if it's higher, or add it if the tag isn't found. + //! Add surface tags and weights to this collection. If a tag already exists, the higher weight will be preserved. + //! (This method is intentionally inlined for its performance impact) + //! @param tags - The surface tags to replace/add. + //! @param weight - The surface tag weight to use for each tag. + void AddSurfaceTagWeights(const SurfaceTagVector& tags, const float weight) + { + for (const auto& tag : tags) + { + AddSurfaceTagWeight(tag, weight); + } + } + + //! Add surface tags and weights to this collection. If a tag already exists, the higher weight will be preserved. //! (This method is intentionally inlined for its performance impact) //! @param weights - The surface tags and weights to replace/add. - void AddSurfaceWeightsIfGreater(const SurfaceTagWeights& weights) + void AddSurfaceTagWeights(const SurfaceTagWeights& weights) { for (const auto& [tag, weight] : weights.m_weights) { - AddSurfaceWeightIfGreater(tag, weight); + AddSurfaceTagWeight(tag, weight); } } @@ -125,7 +159,7 @@ namespace SurfaceData //! Check to see if the collection contains the given tag. //! @param sampleTag - The tag to look for. //! @return True if the tag is found, false if it isn't. - bool HasMatchingTag(const AZ::Crc32& sampleTag) const; + bool HasMatchingTag(AZ::Crc32 sampleTag) const; //! Check to see if the collection contains the given tag with the given weight range. //! The range check is inclusive on both sides of the range: [weightMin, weightMax] @@ -133,7 +167,7 @@ namespace SurfaceData //! @param weightMin - The minimum weight for this tag. //! @param weightMax - The maximum weight for this tag. //! @return True if the tag is found, false if it isn't. - bool HasMatchingTag(const AZ::Crc32& sampleTag, float weightMin, float weightMax) const; + bool HasMatchingTag(AZ::Crc32 sampleTag, float weightMin, float weightMax) const; //! Check to see if the collection contains any of the given tags. //! @param sampleTags - The tags to look for. @@ -149,7 +183,12 @@ namespace SurfaceData bool HasAnyMatchingTags(const SurfaceTagVector& sampleTags, float weightMin, float weightMax) const; private: - AZStd::unordered_map m_weights; + //! Search for the given tag entry. + //! @param tag - The tag to search for. + //! @return The pointer to the tag that's found, or end() if it wasn't found. + const AzFramework::SurfaceData::SurfaceTagWeight* FindTag(AZ::Crc32 tag) const; + + AZStd::fixed_vector m_weights; }; //! SurfacePointList stores a collection of surface point data, which consists of positions, normals, and surface tag weights. diff --git a/Gems/SurfaceData/Code/Source/Components/SurfaceDataColliderComponent.cpp b/Gems/SurfaceData/Code/Source/Components/SurfaceDataColliderComponent.cpp index e51fbc09b2..86a165b7d8 100644 --- a/Gems/SurfaceData/Code/Source/Components/SurfaceDataColliderComponent.cpp +++ b/Gems/SurfaceData/Code/Source/Components/SurfaceDataColliderComponent.cpp @@ -259,7 +259,7 @@ namespace SurfaceData if (DoRayTrace(position, queryPointOnly, hitPosition, hitNormal)) { // If the query point collides with the volume, add all our modifier tags with a weight of 1.0f. - weights.AddSurfaceWeightsIfGreater(m_configuration.m_modifierTags, 1.0f); + weights.AddSurfaceTagWeights(m_configuration.m_modifierTags, 1.0f); } } }); diff --git a/Gems/SurfaceData/Code/Source/Components/SurfaceDataShapeComponent.cpp b/Gems/SurfaceData/Code/Source/Components/SurfaceDataShapeComponent.cpp index b84607782e..481372b7dc 100644 --- a/Gems/SurfaceData/Code/Source/Components/SurfaceDataShapeComponent.cpp +++ b/Gems/SurfaceData/Code/Source/Components/SurfaceDataShapeComponent.cpp @@ -179,7 +179,7 @@ namespace SurfaceData if (m_shapeBounds.Contains(position) && shape->IsPointInside(position)) { // If the point is inside our shape, add all our modifier tags with a weight of 1.0f. - weights.AddSurfaceWeightsIfGreater(m_configuration.m_modifierTags, 1.0f); + weights.AddSurfaceTagWeights(m_configuration.m_modifierTags, 1.0f); } }); }); diff --git a/Gems/SurfaceData/Code/Source/SurfaceDataTypes.cpp b/Gems/SurfaceData/Code/Source/SurfaceDataTypes.cpp index 3071fd02ee..04c1ada677 100644 --- a/Gems/SurfaceData/Code/Source/SurfaceDataTypes.cpp +++ b/Gems/SurfaceData/Code/Source/SurfaceDataTypes.cpp @@ -14,28 +14,21 @@ namespace SurfaceData void SurfaceTagWeights::AssignSurfaceTagWeights(const AzFramework::SurfaceData::SurfaceTagWeightList& weights) { m_weights.clear(); - m_weights.reserve(weights.size()); for (auto& weight : weights) { - m_weights.emplace(weight.m_surfaceType, weight.m_weight); + AddSurfaceTagWeight(weight.m_surfaceType, weight.m_weight); } } void SurfaceTagWeights::AssignSurfaceTagWeights(const SurfaceTagVector& tags, float weight) { m_weights.clear(); - m_weights.reserve(tags.size()); for (auto& tag : tags) { - m_weights[tag] = weight; + AddSurfaceTagWeight(tag.operator AZ::Crc32(), weight); } } - void SurfaceTagWeights::AddSurfaceTagWeight(const AZ::Crc32 tag, const float value) - { - m_weights[tag] = value; - } - void SurfaceTagWeights::Clear() { m_weights.clear(); @@ -52,7 +45,7 @@ namespace SurfaceData weights.reserve(m_weights.size()); for (auto& weight : m_weights) { - weights.emplace_back(weight.first, weight.second); + weights.emplace_back(weight); } return weights; } @@ -65,17 +58,8 @@ namespace SurfaceData return false; } - for (auto& weight : m_weights) - { - auto rhsWeight = rhs.m_weights.find(weight.first); - if ((rhsWeight == rhs.m_weights.end()) || (rhsWeight->second != weight.second)) - { - return false; - } - } - - // All the entries matched, and the lists are the same size, so they're equal. - return true; + // The lists are stored in sorted order, so we can compare every entry in order for equivalence. + return (m_weights == rhs.m_weights); } bool SurfaceTagWeights::SurfaceWeightsAreEqual(const AzFramework::SurfaceData::SurfaceTagWeightList& compareWeights) const @@ -92,7 +76,7 @@ namespace SurfaceData compareWeights.begin(), compareWeights.end(), [weight](const AzFramework::SurfaceData::SurfaceTagWeight& compareWeight) -> bool { - return (weight.first == compareWeight.m_surfaceType) && (weight.second == compareWeight.m_weight); + return (weight == compareWeight); }); // If we didn't find a match, they're not equal. @@ -119,9 +103,9 @@ namespace SurfaceData bool SurfaceTagWeights::HasValidTags() const { - for (const auto& sourceTag : m_weights) + for (const auto& weight : m_weights) { - if (sourceTag.first != Constants::s_unassignedTagCrc) + if (weight.m_surfaceType != Constants::s_unassignedTagCrc) { return true; } @@ -129,9 +113,9 @@ namespace SurfaceData return false; } - bool SurfaceTagWeights::HasMatchingTag(const AZ::Crc32& sampleTag) const + bool SurfaceTagWeights::HasMatchingTag(AZ::Crc32 sampleTag) const { - return m_weights.find(sampleTag) != m_weights.end(); + return FindTag(sampleTag) != m_weights.end(); } bool SurfaceTagWeights::HasAnyMatchingTags(const SurfaceTagVector& sampleTags) const @@ -147,10 +131,10 @@ namespace SurfaceData return false; } - bool SurfaceTagWeights::HasMatchingTag(const AZ::Crc32& sampleTag, float weightMin, float weightMax) const + bool SurfaceTagWeights::HasMatchingTag(AZ::Crc32 sampleTag, float weightMin, float weightMax) const { - auto maskItr = m_weights.find(sampleTag); - return maskItr != m_weights.end() && weightMin <= maskItr->second && weightMax >= maskItr->second; + auto weightEntry = FindTag(sampleTag); + return weightEntry != m_weights.end() && weightMin <= weightEntry->m_weight && weightMax >= weightEntry->m_weight; } bool SurfaceTagWeights::HasAnyMatchingTags(const SurfaceTagVector& sampleTags, float weightMin, float weightMax) const @@ -166,7 +150,25 @@ namespace SurfaceData return false; } + const AzFramework::SurfaceData::SurfaceTagWeight* SurfaceTagWeights::FindTag(AZ::Crc32 tag) const + { + for (auto weightItr = m_weights.begin(); weightItr != m_weights.end(); ++weightItr) + { + if (weightItr->m_surfaceType == tag) + { + // Found the tag, return a pointer to the entry. + return weightItr; + } + else if (weightItr->m_surfaceType > tag) + { + // Our list is stored in sorted order by surfaceType, so early-out if our values get too high. + break; + } + } + // The tag wasn't found, so return end(). + return m_weights.end(); + } SurfacePointList::SurfacePointList(AZStd::initializer_list surfacePoints) @@ -192,7 +194,7 @@ namespace SurfaceData if (m_surfacePositionList[index].IsClose(position) && m_surfaceNormalList[index].IsClose(normal)) { // consolidate points with similar attributes by adding masks/weights to the similar point instead of adding a new one. - m_surfaceWeightsList[index].AddSurfaceWeightsIfGreater(masks); + m_surfaceWeightsList[index].AddSurfaceTagWeights(masks); return; } else if (m_surfacePositionList[index].GetZ() < position.GetZ()) diff --git a/Gems/SurfaceData/Code/Tests/SurfaceDataBenchmarks.cpp b/Gems/SurfaceData/Code/Tests/SurfaceDataBenchmarks.cpp index 226a711cff..f8b4c675a5 100644 --- a/Gems/SurfaceData/Code/Tests/SurfaceDataBenchmarks.cpp +++ b/Gems/SurfaceData/Code/Tests/SurfaceDataBenchmarks.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -270,6 +271,88 @@ namespace UnitTest ->Arg( 2048 ) ->Unit(::benchmark::kMillisecond); + BENCHMARK_DEFINE_F(SurfaceDataBenchmark, BM_AddSurfaceTagWeight)(benchmark::State& state) + { + AZ_PROFILE_FUNCTION(Entity); + + AZ::Crc32 tags[SurfaceData::SurfaceTagWeights::MaxSurfaceWeights]; + AZ::SimpleLcgRandom randomGenerator(1234567); + + // Declare this outside the loop so that we aren't benchmarking creation and destruction. + SurfaceData::SurfaceTagWeights weights; + + bool clearEachTime = state.range(0) > 0; + + // Create a list of randomly-generated tag values. + for (auto& tag : tags) + { + tag = randomGenerator.GetRandom(); + } + + for (auto _ : state) + { + // We'll benchmark this two ways: + // 1. We clear each time, which means each AddSurfaceWeightIfGreater call will search the whole list then add. + // 2. We don't clear, which means that after the first run, AddSurfaceWeightIfGreater will always try to replace values. + if (clearEachTime) + { + weights.Clear(); + } + + // For each tag, try to add it with a random weight. + for (auto& tag : tags) + { + weights.AddSurfaceTagWeight(tag, randomGenerator.GetRandomFloat()); + } + } + } + + BENCHMARK_REGISTER_F(SurfaceDataBenchmark, BM_AddSurfaceTagWeight) + ->Arg(false) + ->Arg(true) + ->ArgName("ClearEachTime"); + + BENCHMARK_DEFINE_F(SurfaceDataBenchmark, BM_HasAnyMatchingTags_NoMatches)(benchmark::State& state) + { + AZ_PROFILE_FUNCTION(Entity); + + AZ::Crc32 tags[SurfaceData::SurfaceTagWeights::MaxSurfaceWeights]; + AZ::SimpleLcgRandom randomGenerator(1234567); + + // Declare this outside the loop so that we aren't benchmarking creation and destruction. + SurfaceData::SurfaceTagWeights weights; + + // Create a list of randomly-generated tag values. + for (auto& tag : tags) + { + // Specifically always set the last bit so that we can create comparison tags that won't match. + tag = randomGenerator.GetRandom() | 0x01; + + // Add the tag to our weights list with a random weight. + weights.AddSurfaceTagWeight(tag, randomGenerator.GetRandomFloat()); + } + + // Create a set of similar comparison tags that won't match. We still want a random distribution of values though, + // because the SurfaceTagWeights might behave differently with ordered lists. + SurfaceData::SurfaceTagVector comparisonTags; + for (auto& tag : tags) + { + comparisonTags.emplace_back(tag ^ 0x01); + } + + for (auto _ : state) + { + // Test to see if any of our tags match. + // All of comparison tags should get compared against all of the added tags. + bool result = weights.HasAnyMatchingTags(comparisonTags); + benchmark::DoNotOptimize(result); + } + } + + BENCHMARK_REGISTER_F(SurfaceDataBenchmark, BM_HasAnyMatchingTags_NoMatches); + + + #endif } diff --git a/Gems/SurfaceData/Code/Tests/SurfaceDataTest.cpp b/Gems/SurfaceData/Code/Tests/SurfaceDataTest.cpp index 39659313f5..f4ff0cb04c 100644 --- a/Gems/SurfaceData/Code/Tests/SurfaceDataTest.cpp +++ b/Gems/SurfaceData/Code/Tests/SurfaceDataTest.cpp @@ -169,7 +169,7 @@ class MockSurfaceProvider if (surfacePoints != m_GetSurfacePoints.end()) { - weights.AddSurfaceWeightsIfGreater(m_tags, 1.0f); + weights.AddSurfaceTagWeights(m_tags, 1.0f); } }); } diff --git a/Gems/Vegetation/Code/Source/AreaSystemComponent.cpp b/Gems/Vegetation/Code/Source/AreaSystemComponent.cpp index e575480ff4..f4ef3bd6f1 100644 --- a/Gems/Vegetation/Code/Source/AreaSystemComponent.cpp +++ b/Gems/Vegetation/Code/Source/AreaSystemComponent.cpp @@ -1137,7 +1137,7 @@ namespace Vegetation claimPoint.m_position = position; claimPoint.m_normal = normal; claimPoint.m_masks = masks; - sectorInfo.m_baseContext.m_masks.AddSurfaceWeightsIfGreater(masks); + sectorInfo.m_baseContext.m_masks.AddSurfaceTagWeights(masks); return true; }); } From 4d4f10beb877117274c013cee2921a5b77cd93d1 Mon Sep 17 00:00:00 2001 From: Steve Pham <82231385+spham-amzn@users.noreply.github.com> Date: Mon, 7 Feb 2022 09:01:07 -0800 Subject: [PATCH 08/11] Clang/GCC compiler settings update [SECURITY] (#7358) - Add the following compilation flags for clang -fpie -fstack-protector-all -fstack-check (non-release) - Add the following compilation flags for gcc -fpie -fstack-protector-all - Fix -Wunused-result errors from above compilation flag updates - Add _FORTIFY_SOURCE=2 to GCC DEFINES Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com> --- Code/Editor/Util/ImageUtil.cpp | 3 +- .../Android/Tests/UtilsTests_Android.cpp | 8 ++-- .../AzFramework/Archive/ZipDirCache.cpp | 4 +- .../Process/ProcessWatcher_Linux.cpp | 14 ++++--- .../Utilities/NetworkCommon_UnixLike.cpp | 2 +- .../Platform/Common/platform_host_posix.cpp | 4 +- .../Code/src/TressFX/TressFXAsset.cpp | 41 +++++++++---------- .../Common/Clang/Configurations_clang.cmake | 23 +++++++---- .../Common/GCC/Configurations_gcc.cmake | 21 +++++++++- .../Platform/Linux/Configurations_linux.cmake | 11 +++++ 10 files changed, 88 insertions(+), 43 deletions(-) diff --git a/Code/Editor/Util/ImageUtil.cpp b/Code/Editor/Util/ImageUtil.cpp index 45d39f1f02..627ea9f750 100644 --- a/Code/Editor/Util/ImageUtil.cpp +++ b/Code/Editor/Util/ImageUtil.cpp @@ -143,7 +143,8 @@ bool CImageUtil::LoadPGM(const QString& fileName, CImageEx& image) fseek(file, 0, SEEK_SET); char* str = new char[fileSize]; - fread(str, fileSize, 1, file); + + [[maybe_unused]] auto bytesRead = fread(str, fileSize, 1, file); [[maybe_unused]] char* nextToken = nullptr; token = azstrtok(str, 0, seps, &nextToken); diff --git a/Code/Framework/AzCore/Tests/Platform/Android/Tests/UtilsTests_Android.cpp b/Code/Framework/AzCore/Tests/Platform/Android/Tests/UtilsTests_Android.cpp index 7ec589d103..45063bfa27 100644 --- a/Code/Framework/AzCore/Tests/Platform/Android/Tests/UtilsTests_Android.cpp +++ b/Code/Framework/AzCore/Tests/Platform/Android/Tests/UtilsTests_Android.cpp @@ -69,9 +69,11 @@ namespace UnitTest // Note that ConvertToAbsolutePath will perform a realpath on the result. The result of AZ::Utils::GetExecutableDirectory // uses AZ::Android::AndroidEnv::Get()->GetAppPrivateStoragePath() which will retrieve the storage path, but that path could // be symlinked, so we need to perform a real path on it before comparison - char realExecutableDirectory[AZ::IO::MaxPathLength]; - ASSERT_TRUE(realpath(executableDirectory, realExecutableDirectory)); - + char* realExecutableDirectory = realpath(executableDirectory, nullptr); + ASSERT_NE(realExecutableDirectory, nullptr); + EXPECT_STRCASEEQ(realExecutableDirectory, absolutePath->c_str()); + + free(realExecutableDirectory); } } diff --git a/Code/Framework/AzFramework/AzFramework/Archive/ZipDirCache.cpp b/Code/Framework/AzFramework/AzFramework/Archive/ZipDirCache.cpp index 05c773f056..de6cc0042b 100644 --- a/Code/Framework/AzFramework/AzFramework/Archive/ZipDirCache.cpp +++ b/Code/Framework/AzFramework/AzFramework/Archive/ZipDirCache.cpp @@ -383,7 +383,7 @@ namespace AZ::IO::ZipDir if (!AZ::IO::FileIOBase::GetDirectInstance()->Write(m_fileHandle, ptr, sizeToWrite)) { char error[1024]; - azstrerror_s(error, AZ_ARRAY_SIZE(error), errno); + [[maybe_unused]] auto azStrErrorResult = azstrerror_s(error, AZ_ARRAY_SIZE(error), errno); AZ_Warning("Archive", false, "Cannot write to zip file!! error = (%d): %s", errno, error); return ZD_ERROR_IO_FAILED; } @@ -531,7 +531,7 @@ namespace AZ::IO::ZipDir if (!WriteCompressedData((uint8_t*)pUncompressed, nSegmentSize, encrypt)) { char error[1024]; - azstrerror_s(error, AZ_ARRAY_SIZE(error), errno); + [[maybe_unused]] auto azStrErrorResult = azstrerror_s(error, AZ_ARRAY_SIZE(error), errno); AZ_Warning("Archive", false, "Cannot write to zip file!! error = (%d): %s", errno, error); return ZD_ERROR_IO_FAILED; } diff --git a/Code/Framework/AzFramework/Platform/Linux/AzFramework/Process/ProcessWatcher_Linux.cpp b/Code/Framework/AzFramework/Platform/Linux/AzFramework/Process/ProcessWatcher_Linux.cpp index 7c86e00fec..999f2e9650 100644 --- a/Code/Framework/AzFramework/Platform/Linux/AzFramework/Process/ProcessWatcher_Linux.cpp +++ b/Code/Framework/AzFramework/Platform/Linux/AzFramework/Process/ProcessWatcher_Linux.cpp @@ -120,7 +120,7 @@ namespace AzFramework int res = chdir(processLaunchInfo.m_workingDirectory.c_str()); if (res != 0) { - write(errorPipe[1], &errno, sizeof(int)); + [[maybe_unused]] auto writeResult = write(errorPipe[1], &errno, sizeof(int)); // We *have* to _exit as we are the child process and simply // returning at this point would mean we would start running // the code from our parent process and that will just wreck @@ -132,15 +132,19 @@ namespace AzFramework switch (processLaunchInfo.m_processPriority) { case PROCESSPRIORITY_BELOWNORMAL: - nice(1); + { + [[maybe_unused]] auto niceResult = nice(1); // also reduce disk impact: // setiopolicy_np(IOPOL_TYPE_DISK, IOPOL_SCOPE_PROCESS, IOPOL_UTILITY); break; + } case PROCESSPRIORITY_IDLE: - nice(20); + { + [[maybe_unused]] auto niceResult = nice(20); // also reduce disk impact: // setiopolicy_np(IOPOL_TYPE_DISK, IOPOL_SCOPE_PROCESS, IOPOL_THROTTLE); break; + } } startupInfo.SetupHandlesForChildProcess(); @@ -153,7 +157,7 @@ namespace AzFramework // to stop it from continuing to run as a clone of the parent. // Communicate the error code back to the parent via a pipe for the // parent to read. - write(errorPipe[1], &errval, sizeof(errval)); + [[maybe_unused]] auto writeResult = write(errorPipe[1], &errval, sizeof(errval)); _exit(0); } @@ -317,7 +321,7 @@ namespace AzFramework // Set up a pipe to communicate the error code from the subprocess's execvpe call AZStd::array childErrorPipeFds{}; - pipe(childErrorPipeFds.data()); + [[maybe_unused]] auto pipeResult = pipe(childErrorPipeFds.data()); // This configures the write end of the pipe to close on calls to `exec` fcntl(childErrorPipeFds[1], F_SETFD, fcntl(childErrorPipeFds[1], F_GETFD) | FD_CLOEXEC); diff --git a/Code/Framework/AzNetworking/Platform/Common/UnixLike/AzNetworking/Utilities/NetworkCommon_UnixLike.cpp b/Code/Framework/AzNetworking/Platform/Common/UnixLike/AzNetworking/Utilities/NetworkCommon_UnixLike.cpp index e2825f4afb..20dfe8b155 100644 --- a/Code/Framework/AzNetworking/Platform/Common/UnixLike/AzNetworking/Utilities/NetworkCommon_UnixLike.cpp +++ b/Code/Framework/AzNetworking/Platform/Common/UnixLike/AzNetworking/Utilities/NetworkCommon_UnixLike.cpp @@ -71,7 +71,7 @@ namespace AzNetworking const char* GetNetworkErrorDesc(int32_t errorCode) { static AZ_THREAD_LOCAL char buffer[1024]; - strerror_r(errorCode, buffer, sizeof(buffer)); + [[maybe_unused]] auto strErrorResult = strerror_r(errorCode, buffer, sizeof(buffer)); return buffer; } } diff --git a/Code/Tools/AzTestRunner/Platform/Common/platform_host_posix.cpp b/Code/Tools/AzTestRunner/Platform/Common/platform_host_posix.cpp index e2e0e801df..7eee861fba 100644 --- a/Code/Tools/AzTestRunner/Platform/Common/platform_host_posix.cpp +++ b/Code/Tools/AzTestRunner/Platform/Common/platform_host_posix.cpp @@ -13,7 +13,7 @@ namespace AzTestRunner { void set_quiet_mode() { - freopen("/dev/null", "a", stdout); + [[maybe_unused]] auto freopenResult = freopen("/dev/null", "a", stdout); } const char* get_current_working_directory() @@ -24,7 +24,7 @@ namespace AzTestRunner void pause_on_completion() { - system("pause"); + [[maybe_unused]] auto systemResult = system("pause"); } } diff --git a/Gems/AtomTressFX/External/Code/src/TressFX/TressFXAsset.cpp b/Gems/AtomTressFX/External/Code/src/TressFX/TressFXAsset.cpp index 58c66c3b8c..c2ce6a5ffe 100644 --- a/Gems/AtomTressFX/External/Code/src/TressFX/TressFXAsset.cpp +++ b/Gems/AtomTressFX/External/Code/src/TressFX/TressFXAsset.cpp @@ -282,8 +282,8 @@ namespace AMD TressFXTFXFileHeader header = {}; // read the header - EI_Seek(ioObject, 0); // make sure the stream pos is at the beginning. - EI_Read((void*)&header, sizeof(TressFXTFXFileHeader), ioObject); + [[maybe_unused]] auto eiSeekResult = EI_Seek(ioObject, 0); // make sure the stream pos is at the beginning. + [[maybe_unused]] auto eiReadResult = EI_Read((void*)&header, sizeof(TressFXTFXFileHeader), ioObject); // If the tfx version is lower than the current major version, exit. if (header.version < AMD_TRESSFX_VERSION_MAJOR) @@ -317,8 +317,8 @@ namespace AMD m_positions.resize(m_numTotalVertices); // size of m_positions = number of total vertices * sizeo of each position vector. // Read position data from the io stream. - EI_Seek(ioObject, header.offsetVertexPosition); - EI_Read((void*)m_positions.data(), numStrandsInFile * m_numVerticesPerStrand * sizeof(AMD::float4), ioObject); // note that the position data in io stream contains only guide hairs. If we call GenerateFollowHairs + eiSeekResult = EI_Seek(ioObject, header.offsetVertexPosition); + eiReadResult = EI_Read((void*)m_positions.data(), numStrandsInFile * m_numVerticesPerStrand * sizeof(AMD::float4), ioObject); // note that the position data in io stream contains only guide hairs. If we call GenerateFollowHairs // to generate follow hairs, m_positions will be re-allocated. // We need to make up some strands to fill up the buffer because the number of strands from stream is not necessarily multile of thread size. @@ -335,11 +335,11 @@ namespace AMD } // Read strand UVs - EI_Seek(ioObject, header.offsetStrandUV); + eiSeekResult = EI_Seek(ioObject, header.offsetStrandUV); m_strandUV.resize(m_numTotalStrands); // If we call GenerateFollowHairs to generate follow hairs, // m_strandUV will be re-allocated. - EI_Read((void*)m_strandUV.data(), numStrandsInFile * sizeof(AMD::float2), ioObject); + eiReadResult = EI_Read((void*)m_strandUV.data(), numStrandsInFile * sizeof(AMD::float2), ioObject); // Fill up the last empty space AMD::int32 indexLastStrand = (numStrandsInFile - 1); @@ -683,21 +683,21 @@ namespace AMD void TressFXAsset::GetBonesNames(FILE* ioObject, std::vector& boneNames) { AMD::int32 numOfBones = 0; - EI_Seek(ioObject, 0); - EI_Read((void*)&numOfBones, sizeof(AMD::int32), ioObject); + [[maybe_unused]] auto eiSeekResult = EI_Seek(ioObject, 0); + [[maybe_unused]] auto eiReadResult = EI_Read((void*)&numOfBones, sizeof(AMD::int32), ioObject); // boneNames.reserve(numOfBones); boneNames.resize(numOfBones); for (int i = 0; i < numOfBones; i++) { int boneIndex; - EI_Read((char*)&boneIndex, sizeof(AMD::int32), ioObject); + eiReadResult = EI_Read((char*)&boneIndex, sizeof(AMD::int32), ioObject); AMD::int32 charLen = 0; - EI_Read((char*)&charLen, sizeof(AMD::int32), ioObject); // character length includes null termination already. + eiReadResult = EI_Read((char*)&charLen, sizeof(AMD::int32), ioObject); // character length includes null termination already. char boneName[128]; - EI_Read(boneName, sizeof(char) * charLen, ioObject); + eiReadResult = EI_Read(boneName, sizeof(char) * charLen, ioObject); boneName[charLen] = '\0'; // adding 0 termination to be on the safe side. boneNames[i] = std::string(boneName); } @@ -730,8 +730,8 @@ namespace AMD m_boneSkinningData.resize(0); AMD::int32 numOfBones = 0; - EI_Seek(ioObject, 0); - EI_Read((void*)&numOfBones, sizeof(AMD::int32), ioObject); + [[maybe_unused]] auto eiSeekResult = EI_Seek(ioObject, 0); + [[maybe_unused]] auto eiReadResult = EI_Read((void*)&numOfBones, sizeof(AMD::int32), ioObject); if (skeletonBoneIndices.size() != numOfBones) { @@ -742,18 +742,18 @@ namespace AMD for (int i = 0; i < numOfBones; i++) { int boneIndex; - EI_Read((char*)&boneIndex, sizeof(AMD::int32), ioObject); + eiReadResult = EI_Read((char*)&boneIndex, sizeof(AMD::int32), ioObject); AMD::int32 charLen = 0; - EI_Read((char*)&charLen, sizeof(AMD::int32), ioObject); // character length includes null termination already. + eiReadResult = EI_Read((char*)&charLen, sizeof(AMD::int32), ioObject); // character length includes null termination already. char boneName[128]; - EI_Read(boneName, sizeof(char) * charLen, ioObject); + eiReadResult = EI_Read(boneName, sizeof(char) * charLen, ioObject); } // Reading the number of strands AMD::int32 numOfStrandsInStream = 0; - EI_Read((char*)&numOfStrandsInStream, sizeof(AMD::int32), ioObject); + eiReadResult = EI_Read((char*)&numOfStrandsInStream, sizeof(AMD::int32), ioObject); //If the number of strands from the input stream (tfxbone) is bigger than what we already know from tfx, something is wrong. if (m_numGuideStrands < numOfStrandsInStream) @@ -765,15 +765,15 @@ namespace AMD for (int i = 0; i < numOfStrandsInStream; ++i) { AMD::int32 index = 0; // Well, we don't really use this here. - EI_Read((char*)&index, sizeof(AMD::int32), ioObject); + eiReadResult = EI_Read((char*)&index, sizeof(AMD::int32), ioObject); for (AMD::int32 j = 0; j < TRESSFX_MAX_INFLUENTIAL_BONE_COUNT; ++j) { AMD::int32 boneIndex; - EI_Read((char*)&boneIndex, sizeof(AMD::int32), ioObject); + eiReadResult = EI_Read((char*)&boneIndex, sizeof(AMD::int32), ioObject); assert(boneIndex >= 0); skinData.boneIndex[j] = (float)skeletonBoneIndices[boneIndex]; // Change the joint index to be what the engine wants - EI_Read((char*)&skinData.weight[j], sizeof(AMD::real32), ioObject); + eiReadResult = EI_Read((char*)&skinData.weight[j], sizeof(AMD::real32), ioObject); } #if defined(AZ_ENABLE_TRACING) @@ -987,4 +987,3 @@ namespace AMD return true; } } // namespace AMD - diff --git a/cmake/Platform/Common/Clang/Configurations_clang.cmake b/cmake/Platform/Common/Clang/Configurations_clang.cmake index 2a311d6079..a46ac6647d 100644 --- a/cmake/Platform/Common/Clang/Configurations_clang.cmake +++ b/cmake/Platform/Common/Clang/Configurations_clang.cmake @@ -9,6 +9,8 @@ include(cmake/Platform/Common/Configurations_common.cmake) ly_append_configurations_options( + DEFINES + _FORTIFY_SOURCE=2 COMPILATION -fno-exceptions -fvisibility=hidden @@ -16,6 +18,8 @@ ly_append_configurations_options( -Wall -Werror + -fpie # Position-Independent Executables + ################### # Disabled warnings (please do not disable any others without first consulting sig-build) ################### @@ -35,17 +39,22 @@ ly_append_configurations_options( ################### COMPILATION_DEBUG - -O0 # No optimization - -g # debug symbols - -fno-inline # don't inline functions - -fstack-protector # Add additional checks to catch stack corruption issues + -O0 # No optimization + -g # debug symbols + -fno-inline # don't inline functions + + -fstack-protector-all # Enable stack protectors for all functions + -fstack-check + COMPILATION_PROFILE -O2 - -g # debug symbols + -g # debug symbols + + -fstack-protector-all # Enable stack protectors for all functions + -fstack-check + COMPILATION_RELEASE -O2 - LINK_NON_STATIC - -Wl,-undefined,error ) include(cmake/Platform/Common/TargetIncludeSystemDirectories_supported.cmake) diff --git a/cmake/Platform/Common/GCC/Configurations_gcc.cmake b/cmake/Platform/Common/GCC/Configurations_gcc.cmake index ad5f3bec28..9ce6d2b405 100644 --- a/cmake/Platform/Common/GCC/Configurations_gcc.cmake +++ b/cmake/Platform/Common/GCC/Configurations_gcc.cmake @@ -20,6 +20,8 @@ endif() ly_append_configurations_options( + DEFINES + _FORTIFY_SOURCE=2 COMPILATION_C -fno-exceptions @@ -27,6 +29,9 @@ ly_append_configurations_options( -Wall -Werror + -fpie # Position-Independent Executables + -fstack-protector-all # Enable stack protectors for all functions + ${LY_GCC_GCOV_FLAGS} ${LY_GCC_GPROF_FLAGS} @@ -37,6 +42,9 @@ ly_append_configurations_options( -Wall -Werror + -fpie # Position-Independent Executables + -fstack-protector-all # Enable stack protectors for all functions + ${LY_GCC_GCOV_FLAGS} ${LY_GCC_GPROF_FLAGS} @@ -71,12 +79,23 @@ ly_append_configurations_options( -O0 # No optimization -g # debug symbols -fno-inline # don't inline functions - -fstack-protector # Add additional checks to catch stack corruption issues COMPILATION_PROFILE -O2 -g # debug symbols COMPILATION_RELEASE -O2 + + LINK_NON_STATIC + -Wl,-undefined,error + -fpie + -Wl,-z,relro,-z,now + -Wl,-z,noexecstack + LINK_EXE + -pie + -fpie + -Wl,-z,relro,-z,now + -Wl,-z,noexecstack + ) include(cmake/Platform/Common/TargetIncludeSystemDirectories_supported.cmake) diff --git a/cmake/Platform/Linux/Configurations_linux.cmake b/cmake/Platform/Linux/Configurations_linux.cmake index 98b946426d..300b7bee10 100644 --- a/cmake/Platform/Linux/Configurations_linux.cmake +++ b/cmake/Platform/Linux/Configurations_linux.cmake @@ -18,7 +18,18 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") COMPILATION -fPIC -msse4.1 + LINK_NON_STATIC + -Wl,-undefined,error + -fpie + -Wl,-z,relro,-z,now + -Wl,-z,noexecstack + LINK_EXE + -pie + -fpie + -Wl,-z,relro,-z,now + -Wl,-z,noexecstack ) + ly_set(CMAKE_CXX_EXTENSIONS OFF) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") From 07bdba11ca9527717f960e36eb531e7468b454a5 Mon Sep 17 00:00:00 2001 From: AMZN-stankowi <4838196+AMZN-stankowi@users.noreply.github.com> Date: Mon, 7 Feb 2022 09:09:00 -0800 Subject: [PATCH 09/11] Updating to assimp 5.1.6 (#7435) * Updated UV channel name retrieval to match changes to the assimp sdk Signed-off-by: AMZN-stankowi <4838196+AMZN-stankowi@users.noreply.github.com> * Updated FBX automated tests to work with latest changes Signed-off-by: AMZN-stankowi <4838196+AMZN-stankowi@users.noreply.github.com> * Updating to the latest build of assimp: 5.1.6 with our two fixes applied on top Signed-off-by: AMZN-stankowi <4838196+AMZN-stankowi@users.noreply.github.com> * Adding updated linux package info Signed-off-by: AMZN-stankowi <4838196+AMZN-stankowi@users.noreply.github.com> * Added mac package info for 5.1.6 assimp Signed-off-by: AMZN-stankowi <4838196+AMZN-stankowi@users.noreply.github.com> * Updating Linux assimp package hash with latest changes Signed-off-by: AMZN-stankowi <4838196+AMZN-stankowi@users.noreply.github.com> * Updated mac hash to match latest assimp mac package Signed-off-by: AMZN-stankowi <4838196+AMZN-stankowi@users.noreply.github.com> * Updated windows to the latest assimp 5.1.6 package Signed-off-by: AMZN-stankowi <4838196+AMZN-stankowi@users.noreply.github.com> --- .../Motion/SceneDebug/Jack_Idle_Aim_ZUp.dbgsg | 10 +-- .../SceneDebug/jack_idle_aim_zup.dbgsg.xml | 82 +++++++++---------- .../SoftNamingLOD/SceneDebug/lodtest.dbgsg | 12 +-- .../SceneDebug/lodtest.dbgsg.xml | 12 +-- .../SceneDebug/physicstest.dbgsg | 12 +-- .../SceneDebug/physicstest.dbgsg.xml | 12 +-- .../multiple_mesh_linked_materials.dbgsg | 12 +-- .../multiple_mesh_linked_materials.dbgsg.xml | 12 +-- .../multiple_mesh_one_material.dbgsg | 12 +-- .../multiple_mesh_one_material.dbgsg.xml | 12 +-- .../multiple_mesh_multiple_material.dbgsg | 12 +-- .../multiple_mesh_multiple_material.dbgsg.xml | 12 +-- ...iple_mesh_multiple_material_override.dbgsg | 6 +- ..._mesh_multiple_material_override.dbgsg.xml | 6 +- .../Importers/AssImpUvMapImporter.cpp | 8 +- .../Linux/BuiltInPackages_linux.cmake | 2 +- .../Platform/Mac/BuiltInPackages_mac.cmake | 2 +- .../Windows/BuiltInPackages_windows.cmake | 2 +- 18 files changed, 119 insertions(+), 119 deletions(-) diff --git a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/Motion/SceneDebug/Jack_Idle_Aim_ZUp.dbgsg b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/Motion/SceneDebug/Jack_Idle_Aim_ZUp.dbgsg index c8c5c8697b..d27055e826 100644 --- a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/Motion/SceneDebug/Jack_Idle_Aim_ZUp.dbgsg +++ b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/Motion/SceneDebug/Jack_Idle_Aim_ZUp.dbgsg @@ -242,7 +242,7 @@ Node Type: BoneData BasisX: < 1.000000, -0.000000, 0.000000> BasisY: < 0.000000, 1.000000, 0.000000> BasisZ: <-0.000000, -0.000000, 1.000000> - Transl: < 0.152547, 0.043345, 0.090954> + Transl: < 0.152547, 0.043345, 0.090955> Node Name: animation Node Path: RootNode.jack_root.Bip01__pelvis.spine1.spine2.animation @@ -544,7 +544,7 @@ Node Type: BoneData Node Name: animation Node Path: RootNode.jack_root.Bip01__pelvis.spine1.spine2.spine3.l_shldr.l_upArm.l_upArmRoll.animation Node Type: AnimationData - KeyFrames: Count 195. Hash: 8781707605519483934 + KeyFrames: Count 195. Hash: 15529789169672670472 TimeStepBetweenFrames: 0.033333 Node Name: transform @@ -710,7 +710,7 @@ Node Type: BoneData BasisX: < 0.514369, 0.855813, 0.054857> BasisY: < 0.088153, 0.010863, -0.996047> BasisZ: <-0.853026, 0.517172, -0.069855> - Transl: <-0.247306, -0.062325, 0.878372> + Transl: <-0.247306, -0.062325, 0.878373> Node Name: animation Node Path: RootNode.jack_root.Bip01__pelvis.spine1.spine2.spine3.r_shldr.r_upArm.r_loArm.r_loArmRoll.animation @@ -857,7 +857,7 @@ Node Type: BoneData BasisX: < 0.329257, 0.944038, -0.019538> BasisY: < 0.465563, -0.180309, -0.866452> BasisZ: <-0.821487, 0.276189, -0.498877> - Transl: <-0.255124, -0.049696, 0.794466> + Transl: <-0.255124, -0.049696, 0.794467> Node Name: animation Node Path: RootNode.jack_root.Bip01__pelvis.spine1.spine2.spine3.l_shldr.l_upArm.l_loArm.l_hand.l_metacarpal.animation @@ -953,7 +953,7 @@ Node Type: BoneData BasisX: <-0.102387, -0.418082, -0.902621> BasisY: < 0.928150, 0.286271, -0.237880> BasisZ: < 0.357847, -0.862123, 0.358732> - Transl: < 0.187367, 0.698323, 1.467209> + Transl: < 0.187367, 0.698324, 1.467209> Node Name: animation Node Path: RootNode.jack_root.Bip01__pelvis.spine1.spine2.spine3.r_shldr.r_upArm.r_loArm.r_hand.r_mid1.animation diff --git a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/Motion/SceneDebug/jack_idle_aim_zup.dbgsg.xml b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/Motion/SceneDebug/jack_idle_aim_zup.dbgsg.xml index caaf3810fe..ba0da98440 100644 --- a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/Motion/SceneDebug/jack_idle_aim_zup.dbgsg.xml +++ b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/Motion/SceneDebug/jack_idle_aim_zup.dbgsg.xml @@ -114,7 +114,7 @@ - + @@ -191,7 +191,7 @@ - + @@ -204,7 +204,7 @@ - + @@ -268,7 +268,7 @@ - + @@ -319,7 +319,7 @@ - + @@ -408,7 +408,7 @@ - + @@ -497,7 +497,7 @@ - + @@ -548,7 +548,7 @@ - + @@ -650,7 +650,7 @@ - + @@ -701,7 +701,7 @@ - + @@ -727,7 +727,7 @@ - + @@ -854,7 +854,7 @@ - + @@ -905,7 +905,7 @@ - + @@ -1109,7 +1109,7 @@ - + @@ -1141,7 +1141,7 @@ - + @@ -1415,7 +1415,7 @@ - + @@ -1441,7 +1441,7 @@ - + @@ -1454,7 +1454,7 @@ - + @@ -1467,7 +1467,7 @@ - + @@ -1569,7 +1569,7 @@ - + @@ -1582,7 +1582,7 @@ - + @@ -1608,7 +1608,7 @@ - + @@ -1659,7 +1659,7 @@ - + @@ -1710,7 +1710,7 @@ - + @@ -1761,7 +1761,7 @@ - + @@ -1812,7 +1812,7 @@ - + @@ -1825,7 +1825,7 @@ - + @@ -1914,7 +1914,7 @@ - + @@ -1965,7 +1965,7 @@ - + @@ -2067,7 +2067,7 @@ - + @@ -2169,7 +2169,7 @@ - + @@ -2220,7 +2220,7 @@ - + @@ -2271,7 +2271,7 @@ - + @@ -2322,7 +2322,7 @@ - + @@ -2373,7 +2373,7 @@ - + @@ -2475,7 +2475,7 @@ - + @@ -2526,7 +2526,7 @@ - + @@ -2628,7 +2628,7 @@ - + @@ -2793,7 +2793,7 @@ - + @@ -2844,7 +2844,7 @@ - + @@ -3009,7 +3009,7 @@ - + diff --git a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/SoftNamingLOD/SceneDebug/lodtest.dbgsg b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/SoftNamingLOD/SceneDebug/lodtest.dbgsg index 90bcb94795..6d0b8fe246 100644 --- a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/SoftNamingLOD/SceneDebug/lodtest.dbgsg +++ b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/SoftNamingLOD/SceneDebug/lodtest.dbgsg @@ -90,7 +90,7 @@ Node Path: RootNode.lodtest_lod1.lodtest_lod1_1 Node Type: MeshData Positions: Count 192. Hash: 1283526254311745349 Normals: Count 192. Hash: 1873340970602844856 - FaceList: Count 124. Hash: 3728991722746136013 + FaceList: Count 124. Hash: 8546457964849634958 FaceMaterialIds: Count 124. Hash: 2372486708814455910 Node Name: lodtest_lod1_2 @@ -107,7 +107,7 @@ Node Path: RootNode.lodtest_lod1.lodtest_lod1_1_optimized Node Type: MeshData Positions: Count 192. Hash: 7921557352486854444 Normals: Count 192. Hash: 1873340970602844856 - FaceList: Count 124. Hash: 18311637590974204568 + FaceList: Count 124. Hash: 7602933716150163115 FaceMaterialIds: Count 124. Hash: 2372486708814455910 Node Name: transform @@ -641,14 +641,14 @@ Node Type: MaterialData Node Name: TangentSet_0 Node Path: RootNode.lodtest_lod1.lodtest_lod1_1.TangentSet_0 Node Type: MeshVertexTangentData - Tangents: Count 192. Hash: 11165448242141781141 + Tangents: Count 192. Hash: 13347865366302598201 GenerationMethod: 1 SetIndex: 0 Node Name: BitangentSet_0 Node Path: RootNode.lodtest_lod1.lodtest_lod1_1.BitangentSet_0 Node Type: MeshVertexBitangentData - Bitangents: Count 192. Hash: 7987814487334449536 + Bitangents: Count 192. Hash: 11177881960262055002 GenerationMethod: 1 Node Name: transform @@ -705,14 +705,14 @@ Node Type: MeshVertexUVData Node Name: TangentSet_0 Node Path: RootNode.lodtest_lod1.lodtest_lod1_1_optimized.TangentSet_0 Node Type: MeshVertexTangentData - Tangents: Count 192. Hash: 7293001660047850407 + Tangents: Count 192. Hash: 13256424469303674766 GenerationMethod: 1 SetIndex: 0 Node Name: BitangentSet_0 Node Path: RootNode.lodtest_lod1.lodtest_lod1_1_optimized.BitangentSet_0 Node Type: MeshVertexBitangentData - Bitangents: Count 192. Hash: 2874689498270494796 + Bitangents: Count 192. Hash: 12542581737782433115 GenerationMethod: 1 Node Name: transform diff --git a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/SoftNamingLOD/SceneDebug/lodtest.dbgsg.xml b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/SoftNamingLOD/SceneDebug/lodtest.dbgsg.xml index d1af4198b5..73cb0e2776 100644 --- a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/SoftNamingLOD/SceneDebug/lodtest.dbgsg.xml +++ b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/SoftNamingLOD/SceneDebug/lodtest.dbgsg.xml @@ -424,7 +424,7 @@ - + @@ -492,7 +492,7 @@ - + @@ -1729,7 +1729,7 @@ - + @@ -1760,7 +1760,7 @@ - + @@ -1891,7 +1891,7 @@ - + @@ -1922,7 +1922,7 @@ - + diff --git a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/SoftNamingPhysics/SceneDebug/physicstest.dbgsg b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/SoftNamingPhysics/SceneDebug/physicstest.dbgsg index 9b7ec58b7a..8cafe03a8f 100644 --- a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/SoftNamingPhysics/SceneDebug/physicstest.dbgsg +++ b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/SoftNamingPhysics/SceneDebug/physicstest.dbgsg @@ -15,7 +15,7 @@ Node Path: RootNode.Cone.Cone_1 Node Type: MeshData Positions: Count 128. Hash: 7714223793259938211 Normals: Count 128. Hash: 2352668179264002707 - FaceList: Count 62. Hash: 14563017593520122982 + FaceList: Count 62. Hash: 9996709738915796379 FaceMaterialIds: Count 62. Hash: 12234218120113875284 Node Name: Cone_2 @@ -32,7 +32,7 @@ Node Path: RootNode.Cone.Cone_1_optimized Node Type: MeshData Positions: Count 128. Hash: 10174710861731544050 Normals: Count 128. Hash: 2352668179264002707 - FaceList: Count 62. Hash: 11332459830831720586 + FaceList: Count 62. Hash: 16809217014760075539 FaceMaterialIds: Count 62. Hash: 12234218120113875284 Node Name: Cube_phys_1 @@ -100,14 +100,14 @@ Node Type: MaterialData Node Name: TangentSet_0 Node Path: RootNode.Cone.Cone_1.TangentSet_0 Node Type: MeshVertexTangentData - Tangents: Count 128. Hash: 14351734474754285313 + Tangents: Count 128. Hash: 913385441694195840 GenerationMethod: 1 SetIndex: 0 Node Name: BitangentSet_0 Node Path: RootNode.Cone.Cone_1.BitangentSet_0 Node Type: MeshVertexBitangentData - Bitangents: Count 128. Hash: 15997251922861304891 + Bitangents: Count 128. Hash: 16763868708150748964 GenerationMethod: 1 Node Name: transform @@ -164,14 +164,14 @@ Node Type: MeshVertexUVData Node Name: TangentSet_0 Node Path: RootNode.Cone.Cone_1_optimized.TangentSet_0 Node Type: MeshVertexTangentData - Tangents: Count 128. Hash: 12937806066914201637 + Tangents: Count 128. Hash: 11496565252852403390 GenerationMethod: 1 SetIndex: 0 Node Name: BitangentSet_0 Node Path: RootNode.Cone.Cone_1_optimized.BitangentSet_0 Node Type: MeshVertexBitangentData - Bitangents: Count 128. Hash: 873786942732834087 + Bitangents: Count 128. Hash: 6810649909977646014 GenerationMethod: 1 Node Name: transform diff --git a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/SoftNamingPhysics/SceneDebug/physicstest.dbgsg.xml b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/SoftNamingPhysics/SceneDebug/physicstest.dbgsg.xml index b22eb14fc6..24452dabeb 100644 --- a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/SoftNamingPhysics/SceneDebug/physicstest.dbgsg.xml +++ b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/SoftNamingPhysics/SceneDebug/physicstest.dbgsg.xml @@ -55,7 +55,7 @@ - + @@ -123,7 +123,7 @@ - + @@ -309,7 +309,7 @@ - + @@ -340,7 +340,7 @@ - + @@ -471,7 +471,7 @@ - + @@ -502,7 +502,7 @@ - + diff --git a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshLinkedMaterials/SceneDebug/multiple_mesh_linked_materials.dbgsg b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshLinkedMaterials/SceneDebug/multiple_mesh_linked_materials.dbgsg index c0544ea3a9..a9f329af3b 100644 --- a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshLinkedMaterials/SceneDebug/multiple_mesh_linked_materials.dbgsg +++ b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshLinkedMaterials/SceneDebug/multiple_mesh_linked_materials.dbgsg @@ -40,7 +40,7 @@ Node Path: RootNode.Cone.Cone_1 Node Type: MeshData Positions: Count 128. Hash: 12506421592104186200 Normals: Count 128. Hash: 367461522682321485 - FaceList: Count 62. Hash: 13208951979626973193 + FaceList: Count 62. Hash: 5910399941817424750 FaceMaterialIds: Count 62. Hash: 15454348664434923102 Node Name: Cone_2 @@ -57,7 +57,7 @@ Node Path: RootNode.Cone.Cone_1_optimized Node Type: MeshData Positions: Count 128. Hash: 14946490408303214595 Normals: Count 128. Hash: 367461522682321485 - FaceList: Count 62. Hash: 11102693598481718079 + FaceList: Count 62. Hash: 17210030509394354449 FaceMaterialIds: Count 62. Hash: 15454348664434923102 Node Name: transform @@ -389,14 +389,14 @@ Node Type: MaterialData Node Name: TangentSet_0 Node Path: RootNode.Cone.Cone_1.TangentSet_0 Node Type: MeshVertexTangentData - Tangents: Count 128. Hash: 12695232913942738512 + Tangents: Count 128. Hash: 11574815809363656385 GenerationMethod: 1 SetIndex: 0 Node Name: BitangentSet_0 Node Path: RootNode.Cone.Cone_1.BitangentSet_0 Node Type: MeshVertexBitangentData - Bitangents: Count 128. Hash: 9034210764777745751 + Bitangents: Count 128. Hash: 1026129762512670051 GenerationMethod: 1 Node Name: transform @@ -483,14 +483,14 @@ Node Type: MeshVertexUVData Node Name: TangentSet_0 Node Path: RootNode.Cone.Cone_1_optimized.TangentSet_0 Node Type: MeshVertexTangentData - Tangents: Count 128. Hash: 10740776669168782230 + Tangents: Count 128. Hash: 5198081677141836233 GenerationMethod: 1 SetIndex: 0 Node Name: BitangentSet_0 Node Path: RootNode.Cone.Cone_1_optimized.BitangentSet_0 Node Type: MeshVertexBitangentData - Bitangents: Count 128. Hash: 6990068477421150065 + Bitangents: Count 128. Hash: 6948605204859680167 GenerationMethod: 1 Node Name: transform diff --git a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshLinkedMaterials/SceneDebug/multiple_mesh_linked_materials.dbgsg.xml b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshLinkedMaterials/SceneDebug/multiple_mesh_linked_materials.dbgsg.xml index 3eaf018fb6..fe2ffe18f5 100644 --- a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshLinkedMaterials/SceneDebug/multiple_mesh_linked_materials.dbgsg.xml +++ b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshLinkedMaterials/SceneDebug/multiple_mesh_linked_materials.dbgsg.xml @@ -178,7 +178,7 @@ - + @@ -246,7 +246,7 @@ - + @@ -957,7 +957,7 @@ - + @@ -988,7 +988,7 @@ - + @@ -1174,7 +1174,7 @@ - + @@ -1205,7 +1205,7 @@ - + diff --git a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshOneMaterial/SceneDebug/multiple_mesh_one_material.dbgsg b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshOneMaterial/SceneDebug/multiple_mesh_one_material.dbgsg index 48135760f2..f1b230c37f 100644 --- a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshOneMaterial/SceneDebug/multiple_mesh_one_material.dbgsg +++ b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshOneMaterial/SceneDebug/multiple_mesh_one_material.dbgsg @@ -40,7 +40,7 @@ Node Path: RootNode.Cylinder.Cylinder_1 Node Type: MeshData Positions: Count 192. Hash: 1283526254311745349 Normals: Count 192. Hash: 1873340970602844856 - FaceList: Count 124. Hash: 3728991722746136013 + FaceList: Count 124. Hash: 8546457964849634958 FaceMaterialIds: Count 124. Hash: 2372486708814455910 Node Name: Cylinder_2 @@ -57,7 +57,7 @@ Node Path: RootNode.Cylinder.Cylinder_1_optimized Node Type: MeshData Positions: Count 192. Hash: 7921557352486854444 Normals: Count 192. Hash: 1873340970602844856 - FaceList: Count 124. Hash: 18311637590974204568 + FaceList: Count 124. Hash: 7602933716150163115 FaceMaterialIds: Count 124. Hash: 2372486708814455910 Node Name: transform @@ -269,14 +269,14 @@ Node Type: MaterialData Node Name: TangentSet_0 Node Path: RootNode.Cylinder.Cylinder_1.TangentSet_0 Node Type: MeshVertexTangentData - Tangents: Count 192. Hash: 11165448242141781141 + Tangents: Count 192. Hash: 13347865366302598201 GenerationMethod: 1 SetIndex: 0 Node Name: BitangentSet_0 Node Path: RootNode.Cylinder.Cylinder_1.BitangentSet_0 Node Type: MeshVertexBitangentData - Bitangents: Count 192. Hash: 7987814487334449536 + Bitangents: Count 192. Hash: 11177881960262055002 GenerationMethod: 1 Node Name: transform @@ -333,14 +333,14 @@ Node Type: MeshVertexUVData Node Name: TangentSet_0 Node Path: RootNode.Cylinder.Cylinder_1_optimized.TangentSet_0 Node Type: MeshVertexTangentData - Tangents: Count 192. Hash: 7293001660047850407 + Tangents: Count 192. Hash: 13256424469303674766 GenerationMethod: 1 SetIndex: 0 Node Name: BitangentSet_0 Node Path: RootNode.Cylinder.Cylinder_1_optimized.BitangentSet_0 Node Type: MeshVertexBitangentData - Bitangents: Count 192. Hash: 2874689498270494796 + Bitangents: Count 192. Hash: 12542581737782433115 GenerationMethod: 1 Node Name: transform diff --git a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshOneMaterial/SceneDebug/multiple_mesh_one_material.dbgsg.xml b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshOneMaterial/SceneDebug/multiple_mesh_one_material.dbgsg.xml index 39ac33f654..2ff1a1bc9e 100644 --- a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshOneMaterial/SceneDebug/multiple_mesh_one_material.dbgsg.xml +++ b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshOneMaterial/SceneDebug/multiple_mesh_one_material.dbgsg.xml @@ -178,7 +178,7 @@ - + @@ -246,7 +246,7 @@ - + @@ -737,7 +737,7 @@ - + @@ -768,7 +768,7 @@ - + @@ -899,7 +899,7 @@ - + @@ -930,7 +930,7 @@ - + diff --git a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshTwoMaterial/SceneDebug/multiple_mesh_multiple_material.dbgsg b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshTwoMaterial/SceneDebug/multiple_mesh_multiple_material.dbgsg index c5587a2778..8a350f1ff9 100644 --- a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshTwoMaterial/SceneDebug/multiple_mesh_multiple_material.dbgsg +++ b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshTwoMaterial/SceneDebug/multiple_mesh_multiple_material.dbgsg @@ -40,7 +40,7 @@ Node Path: RootNode.Cylinder.Cylinder_1 Node Type: MeshData Positions: Count 192. Hash: 1283526254311745349 Normals: Count 192. Hash: 1873340970602844856 - FaceList: Count 124. Hash: 3728991722746136013 + FaceList: Count 124. Hash: 8546457964849634958 FaceMaterialIds: Count 124. Hash: 2372486708814455910 Node Name: Cylinder_2 @@ -57,7 +57,7 @@ Node Path: RootNode.Cylinder.Cylinder_1_optimized Node Type: MeshData Positions: Count 192. Hash: 7921557352486854444 Normals: Count 192. Hash: 1873340970602844856 - FaceList: Count 124. Hash: 18311637590974204568 + FaceList: Count 124. Hash: 7602933716150163115 FaceMaterialIds: Count 124. Hash: 2372486708814455910 Node Name: transform @@ -269,14 +269,14 @@ Node Type: MaterialData Node Name: TangentSet_0 Node Path: RootNode.Cylinder.Cylinder_1.TangentSet_0 Node Type: MeshVertexTangentData - Tangents: Count 192. Hash: 11165448242141781141 + Tangents: Count 192. Hash: 13347865366302598201 GenerationMethod: 1 SetIndex: 0 Node Name: BitangentSet_0 Node Path: RootNode.Cylinder.Cylinder_1.BitangentSet_0 Node Type: MeshVertexBitangentData - Bitangents: Count 192. Hash: 7987814487334449536 + Bitangents: Count 192. Hash: 11177881960262055002 GenerationMethod: 1 Node Name: transform @@ -333,14 +333,14 @@ Node Type: MeshVertexUVData Node Name: TangentSet_0 Node Path: RootNode.Cylinder.Cylinder_1_optimized.TangentSet_0 Node Type: MeshVertexTangentData - Tangents: Count 192. Hash: 7293001660047850407 + Tangents: Count 192. Hash: 13256424469303674766 GenerationMethod: 1 SetIndex: 0 Node Name: BitangentSet_0 Node Path: RootNode.Cylinder.Cylinder_1_optimized.BitangentSet_0 Node Type: MeshVertexBitangentData - Bitangents: Count 192. Hash: 2874689498270494796 + Bitangents: Count 192. Hash: 12542581737782433115 GenerationMethod: 1 Node Name: transform diff --git a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshTwoMaterial/SceneDebug/multiple_mesh_multiple_material.dbgsg.xml b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshTwoMaterial/SceneDebug/multiple_mesh_multiple_material.dbgsg.xml index c41c1414a4..5d86d401cf 100644 --- a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshTwoMaterial/SceneDebug/multiple_mesh_multiple_material.dbgsg.xml +++ b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshTwoMaterial/SceneDebug/multiple_mesh_multiple_material.dbgsg.xml @@ -178,7 +178,7 @@ - + @@ -246,7 +246,7 @@ - + @@ -737,7 +737,7 @@ - + @@ -768,7 +768,7 @@ - + @@ -899,7 +899,7 @@ - + @@ -930,7 +930,7 @@ - + diff --git a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshTwoMaterial/SceneDebug/multiple_mesh_multiple_material_override.dbgsg b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshTwoMaterial/SceneDebug/multiple_mesh_multiple_material_override.dbgsg index 8426a68d3b..32fbc37a50 100644 --- a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshTwoMaterial/SceneDebug/multiple_mesh_multiple_material_override.dbgsg +++ b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshTwoMaterial/SceneDebug/multiple_mesh_multiple_material_override.dbgsg @@ -40,7 +40,7 @@ Node Path: RootNode.Cylinder.Cylinder_1 Node Type: MeshData Positions: Count 192. Hash: 1283526254311745349 Normals: Count 192. Hash: 1873340970602844856 - FaceList: Count 124. Hash: 3728991722746136013 + FaceList: Count 124. Hash: 8546457964849634958 FaceMaterialIds: Count 124. Hash: 2372486708814455910 Node Name: Cylinder_2 @@ -261,14 +261,14 @@ Node Type: MaterialData Node Name: TangentSet_0 Node Path: RootNode.Cylinder.Cylinder_1.TangentSet_0 Node Type: MeshVertexTangentData - Tangents: Count 192. Hash: 11165448242141781141 + Tangents: Count 192. Hash: 13347865366302598201 GenerationMethod: 1 SetIndex: 0 Node Name: BitangentSet_0 Node Path: RootNode.Cylinder.Cylinder_1.BitangentSet_0 Node Type: MeshVertexBitangentData - Bitangents: Count 192. Hash: 7987814487334449536 + Bitangents: Count 192. Hash: 11177881960262055002 GenerationMethod: 1 Node Name: transform diff --git a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshTwoMaterial/SceneDebug/multiple_mesh_multiple_material_override.dbgsg.xml b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshTwoMaterial/SceneDebug/multiple_mesh_multiple_material_override.dbgsg.xml index 01167ec0ee..dec8ec1bb8 100644 --- a/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshTwoMaterial/SceneDebug/multiple_mesh_multiple_material_override.dbgsg.xml +++ b/AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/TwoMeshTwoMaterial/SceneDebug/multiple_mesh_multiple_material_override.dbgsg.xml @@ -178,7 +178,7 @@ - + @@ -682,7 +682,7 @@ - + @@ -713,7 +713,7 @@ - + diff --git a/Code/Tools/SceneAPI/SceneBuilder/Importers/AssImpUvMapImporter.cpp b/Code/Tools/SceneAPI/SceneBuilder/Importers/AssImpUvMapImporter.cpp index 9e0d788896..31c155c7eb 100644 --- a/Code/Tools/SceneAPI/SceneBuilder/Importers/AssImpUvMapImporter.cpp +++ b/Code/Tools/SceneAPI/SceneBuilder/Importers/AssImpUvMapImporter.cpp @@ -115,22 +115,22 @@ namespace AZ const aiMesh* mesh = scene->mMeshes[currentNode->mMeshes[sdkMeshIndex]]; if(mesh->mTextureCoords[texCoordIndex]) { - if (mesh->mTextureCoordsNames[texCoordIndex].length > 0) + if (mesh->HasTextureCoordsName(texCoordIndex)) { if (!customNameFound) { - name = mesh->mTextureCoordsNames[texCoordIndex].C_Str(); + name = mesh->GetTextureCoordsName(texCoordIndex)->C_Str(); customNameFound = true; } else { AZ_Warning(Utilities::WarningWindow, - strcmp(name.c_str(), mesh->mTextureCoordsNames[texCoordIndex].C_Str()) == 0, + strcmp(name.c_str(), mesh->GetTextureCoordsName(texCoordIndex)->C_Str()) == 0, "Node %s has conflicting mesh coordinate names at index %d, %s and %s. Using %s.", currentNode->mName.C_Str(), texCoordIndex, name.c_str(), - mesh->mTextureCoordsNames[texCoordIndex].C_Str(), + mesh->GetTextureCoordsName(texCoordIndex)->C_Str(), name.c_str()); } } diff --git a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake index f20b67307b..5d30abfb4d 100644 --- a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake +++ b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake @@ -19,7 +19,7 @@ ly_associate_package(PACKAGE_NAME glad-2.0.0-beta-rev2-multiplatform ly_associate_package(PACKAGE_NAME xxhash-0.7.4-rev1-multiplatform TARGETS xxhash PACKAGE_HASH e81f3e6c4065975833996dd1fcffe46c3cf0f9e3a4207ec5f4a1b564ba75861e) # platform-specific: -ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev12-linux TARGETS assimplib PACKAGE_HASH 49d32e11c594e58a9079972ad63570dd895ac61e6148e428b9c39a62feb676ee) +ly_associate_package(PACKAGE_NAME assimp-5.1.6-rev1-linux TARGETS assimplib PACKAGE_HASH 40d64242d5d32a69af3a25690b76f051f3c1a573c1bafba0782cb771a53dfab7) ly_associate_package(PACKAGE_NAME AWSGameLiftServerSDK-3.4.1-rev1-linux TARGETS AWSGameLiftServerSDK PACKAGE_HASH a8149a95bd100384af6ade97e2b21a56173740d921e6c3da8188cd51554d39af) ly_associate_package(PACKAGE_NAME tiff-4.2.0.15-rev3-linux TARGETS TIFF PACKAGE_HASH 2377f48b2ebc2d1628d9f65186c881544c92891312abe478a20d10b85877409a) ly_associate_package(PACKAGE_NAME freetype-2.10.4.16-linux TARGETS freetype PACKAGE_HASH 3f10c703d9001ecd2bb51a3bd003d3237c02d8f947ad0161c0252fdc54cbcf97) diff --git a/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake b/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake index fba8f73ba1..082cefee5d 100644 --- a/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake +++ b/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake @@ -19,7 +19,7 @@ ly_associate_package(PACKAGE_NAME glad-2.0.0-beta-rev2-multiplatform ly_associate_package(PACKAGE_NAME xxhash-0.7.4-rev1-multiplatform TARGETS xxhash PACKAGE_HASH e81f3e6c4065975833996dd1fcffe46c3cf0f9e3a4207ec5f4a1b564ba75861e) # platform-specific: -ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev12-mac TARGETS assimplib PACKAGE_HASH 12db03817553f607bee0d65b690bcaae748014f3ed9266b70384f463bc98c9d1) +ly_associate_package(PACKAGE_NAME assimp-5.1.6-rev1-mac TARGETS assimplib PACKAGE_HASH ad35c2e0efd0852021c84b9a454fdcba2fc8af8b7117e9a0dd7ea0a1915932e0) ly_associate_package(PACKAGE_NAME DirectXShaderCompilerDxc-1.6.2104-o3de-rev3-mac TARGETS DirectXShaderCompilerDxc PACKAGE_HASH 3f77367dbb0342136ec4ebbd44bc1fedf7198089a0f83c5631248530769b2be6) ly_associate_package(PACKAGE_NAME SPIRVCross-2021.04.29-rev1-mac TARGETS SPIRVCross PACKAGE_HASH 78c6376ed2fd195b9b1f5fb2b56e5267a32c3aa21fb399e905308de470eb4515) ly_associate_package(PACKAGE_NAME tiff-4.2.0.15-rev3-mac TARGETS TIFF PACKAGE_HASH c2615ccdadcc0e1d6c5ed61e5965c4d3a82193d206591b79b805c3b3ff35a4bf) diff --git a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake index e24582a453..dd4d158d1c 100644 --- a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake +++ b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake @@ -19,7 +19,7 @@ ly_associate_package(PACKAGE_NAME glad-2.0.0-beta-rev2-multiplatform ly_associate_package(PACKAGE_NAME xxhash-0.7.4-rev1-multiplatform TARGETS xxhash PACKAGE_HASH e81f3e6c4065975833996dd1fcffe46c3cf0f9e3a4207ec5f4a1b564ba75861e) # platform-specific: -ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev12-windows TARGETS assimplib PACKAGE_HASH 5273b7661a7a247bb18e8bc928d25c9cd1bd8ce9dfcc56c50742bac8fa02f0f2) +ly_associate_package(PACKAGE_NAME assimp-5.1.6-rev1-windows TARGETS assimplib PACKAGE_HASH 299d8a3c70657d74af8841650538e9d083fda9356f6782416edbec0ef5a0493e) ly_associate_package(PACKAGE_NAME AWSGameLiftServerSDK-3.4.1-rev1-windows TARGETS AWSGameLiftServerSDK PACKAGE_HASH a0586b006e4def65cc25f388de17dc475e417dc1e6f9d96749777c88aa8271b0) ly_associate_package(PACKAGE_NAME DirectXShaderCompilerDxc-1.6.2104-o3de-rev3-windows TARGETS DirectXShaderCompilerDxc PACKAGE_HASH 803e10b94006b834cbbdd30f562a8ddf04174c2cb6956c8399ec164ef8418d1f) ly_associate_package(PACKAGE_NAME SPIRVCross-2021.04.29-rev1-windows TARGETS SPIRVCross PACKAGE_HASH 7d601ea9d625b1d509d38bd132a1f433d7e895b16adab76bac6103567a7a6817) From 2d8b4d8285241125715dc19c519aa515a4d0a89c Mon Sep 17 00:00:00 2001 From: Qing Tao <55564570+VickyAtAZ@users.noreply.github.com> Date: Mon, 7 Feb 2022 09:20:55 -0800 Subject: [PATCH 10/11] Fix for github issue https://github.com/o3de/o3de/issues/6380 (#7386) The texture was treated as in linear space which leads to the color change when renders. Change to sRGB fixes the issue. Signed-off-by: Qing Tao <55564570+VickyAtAZ@users.noreply.github.com> --- .../Config/UserInterface_Compressed.preset | 20 +++++++++++++------ .../Config/UserInterface_Lossless.preset | 20 +++++++++++++------ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/UserInterface_Compressed.preset b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/UserInterface_Compressed.preset index cd1b00b2fb..c89fae1136 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/UserInterface_Compressed.preset +++ b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/UserInterface_Compressed.preset @@ -8,33 +8,41 @@ "Name": "UserInterface_Compressed", "SuppressEngineReduce": true, "PixelFormat": "R8G8B8A8", - "SourceColor": "Linear", - "DestColor": "Linear" + "SourceColor": "sRGB", + "DestColor": "sRGB" }, "PlatformsPresets": { "android": { "UUID": "{2828FBFE-BDF9-45A7-9370-F93822719CCF}", "Name": "UserInterface_Compressed", "SuppressEngineReduce": true, - "PixelFormat": "ASTC_4x4" + "PixelFormat": "ASTC_4x4", + "SourceColor": "sRGB", + "DestColor": "sRGB" }, "ios": { "UUID": "{2828FBFE-BDF9-45A7-9370-F93822719CCF}", "Name": "UserInterface_Compressed", "SuppressEngineReduce": true, - "PixelFormat": "ASTC_6x6" + "PixelFormat": "ASTC_6x6", + "SourceColor": "sRGB", + "DestColor": "sRGB" }, "mac": { "UUID": "{2828FBFE-BDF9-45A7-9370-F93822719CCF}", "Name": "UserInterface_Compressed", "SuppressEngineReduce": true, - "PixelFormat": "BC1" + "PixelFormat": "BC1", + "SourceColor": "sRGB", + "DestColor": "sRGB" }, "provo": { "UUID": "{2828FBFE-BDF9-45A7-9370-F93822719CCF}", "Name": "UserInterface_Compressed", "SuppressEngineReduce": true, - "PixelFormat": "BC1" + "PixelFormat": "BC1", + "SourceColor": "sRGB", + "DestColor": "sRGB" } } } diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/UserInterface_Lossless.preset b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/UserInterface_Lossless.preset index bec6a604ef..e68ea9edc3 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/UserInterface_Lossless.preset +++ b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/UserInterface_Lossless.preset @@ -8,33 +8,41 @@ "Name": "UserInterface_Lossless", "SuppressEngineReduce": true, "PixelFormat": "R8G8B8A8", - "SourceColor": "Linear", - "DestColor": "Linear" + "SourceColor": "sRGB", + "DestColor": "sRGB" }, "PlatformsPresets": { "android": { "UUID": "{83003128-F63E-422B-AEC2-68F0A947225F}", "Name": "UserInterface_Lossless", "SuppressEngineReduce": true, - "PixelFormat": "R8G8B8A8" + "PixelFormat": "R8G8B8A8", + "SourceColor": "sRGB", + "DestColor": "sRGB" }, "ios": { "UUID": "{83003128-F63E-422B-AEC2-68F0A947225F}", "Name": "UserInterface_Lossless", "SuppressEngineReduce": true, - "PixelFormat": "R8G8B8A8" + "PixelFormat": "R8G8B8A8", + "SourceColor": "sRGB", + "DestColor": "sRGB" }, "mac": { "UUID": "{83003128-F63E-422B-AEC2-68F0A947225F}", "Name": "UserInterface_Lossless", "SuppressEngineReduce": true, - "PixelFormat": "R8G8B8A8" + "PixelFormat": "R8G8B8A8", + "SourceColor": "sRGB", + "DestColor": "sRGB" }, "provo": { "UUID": "{83003128-F63E-422B-AEC2-68F0A947225F}", "Name": "UserInterface_Lossless", "SuppressEngineReduce": true, - "PixelFormat": "R8G8B8A8" + "PixelFormat": "R8G8B8A8", + "SourceColor": "sRGB", + "DestColor": "sRGB" } } } From be242f9c7138455129371c2bda825bde3fab6f2c Mon Sep 17 00:00:00 2001 From: Roman <69218254+amzn-rhhong@users.noreply.github.com> Date: Mon, 7 Feb 2022 09:50:31 -0800 Subject: [PATCH 11/11] Fix a problem about rotation and scale manipulator (#7451) * Load workspace should activate the graph by default. Signed-off-by: rhhong * Fixed the bug with rotation and scale manipulator Signed-off-by: rhhong --- .../Code/Tools/EMStudio/AtomRenderPlugin.cpp | 51 ++++++++----------- .../Code/Tools/EMStudio/AtomRenderPlugin.h | 3 +- 2 files changed, 23 insertions(+), 31 deletions(-) diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.cpp index 131cbd7053..5b3f305cd0 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.cpp @@ -177,10 +177,19 @@ namespace EMStudio m_rotateManipulators.ConfigureView( AzToolsFramework::RotationManipulatorRadius(), AzFramework::ViewportColors::XAxisColor, AzFramework::ViewportColors::YAxisColor, AzFramework::ViewportColors::ZAxisColor); + m_rotateManipulators.InstallLeftMouseDownCallback( + [this]([[maybe_unused]]const AzToolsFramework::AngularManipulator::Action& action) + { + const AZ::EntityId entityId = m_animViewportWidget->GetAnimViewportRenderer()->GetEntityId(); + AZ::TransformBus::EventResult(m_mouseDownStartTransform, entityId, &AZ::TransformBus::Events::GetLocalTM); + }); + m_rotateManipulators.InstallMouseMoveCallback( [this](const AzToolsFramework::AngularManipulator::Action& action) { - OnManipulatorRotated(action.LocalOrientation()); + const AZ::EntityId entityId = m_animViewportWidget->GetAnimViewportRenderer()->GetEntityId(); + AZ::TransformBus::Event(entityId, &AZ::TransformBus::Events::SetLocalRotationQuaternion, + m_mouseDownStartTransform.GetRotation() * action.m_current.m_delta); }); // Setup the scale manipulator @@ -189,10 +198,21 @@ namespace EMStudio m_scaleManipulators.ConfigureView( AzToolsFramework::LinearManipulatorAxisLength(), AzFramework::ViewportColors::XAxisColor, AzFramework::ViewportColors::YAxisColor, AzFramework::ViewportColors::ZAxisColor); + m_scaleManipulators.InstallAxisLeftMouseDownCallback( + [this]([[maybe_unused]] const AzToolsFramework::LinearManipulator::Action& action) + { + const AZ::EntityId entityId = m_animViewportWidget->GetAnimViewportRenderer()->GetEntityId(); + AZ::TransformBus::EventResult(m_mouseDownStartTransform, entityId, &AZ::TransformBus::Events::GetLocalTM); + }); m_scaleManipulators.InstallAxisMouseMoveCallback( [this](const AzToolsFramework::LinearManipulator::Action& action) { - OnManipulatorScaled(action.LocalScale(), action.LocalScaleOffset()); + // Since we are compulting a uniform scale, the delta scale should be the none-zero value from one of the three axis. + const float deltaScale = action.m_current.m_localPositionOffset.GetMaxElement() + + action.m_current.m_localPositionOffset.GetMinElement(); + const AZ::EntityId entityId = m_animViewportWidget->GetAnimViewportRenderer()->GetEntityId(); + AZ::TransformBus::Event(entityId, &AZ::TransformBus::Events::SetLocalUniformScale, + m_mouseDownStartTransform.GetUniformScale() + deltaScale); }); } @@ -259,33 +279,6 @@ namespace EMStudio AZ::TransformBus::Event(entityId, &AZ::TransformBus::Events::SetLocalTranslation, position); } - void AtomRenderPlugin::OnManipulatorRotated(const AZ::Quaternion& rotation) - { - const AZ::EntityId entityId = m_animViewportWidget->GetAnimViewportRenderer()->GetEntityId(); - AZ::TransformBus::Event(entityId, &AZ::TransformBus::Events::SetLocalRotationQuaternion, rotation); - } - - void AtomRenderPlugin::OnManipulatorScaled( - const AZ::Vector3& scale, const AZ::Vector3& scaleOffset) - { - // Use the scaleOffset to determine which axis to use on the uniform scale. - float localScale = 1.0f; - if (scaleOffset.GetX() != 0.0f) - { - localScale = scale.GetX(); - } - else if (scaleOffset.GetY() != 0.0f) - { - localScale = scale.GetY(); - } - else if (scaleOffset.GetZ() != 0.0f) - { - localScale = scale.GetZ(); - } - const AZ::EntityId entityId = m_animViewportWidget->GetAnimViewportRenderer()->GetEntityId(); - AZ::TransformBus::Event(entityId, &AZ::TransformBus::Events::SetLocalUniformScale, localScale); - } - void AtomRenderPlugin::LoadRenderOptions() { AZStd::string renderOptionsFilename(GetManager()->GetAppDataFolder()); diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.h b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.h index 23980ddc0d..2207690628 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.h +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.h @@ -70,8 +70,6 @@ namespace EMStudio void SetupManipulators(); void OnManipulatorMoved(const AZ::Vector3& position); - void OnManipulatorRotated(const AZ::Quaternion& rotation); - void OnManipulatorScaled(const AZ::Vector3& scale, const AZ::Vector3& scaleOffset); QWidget* m_innerWidget = nullptr; AnimViewportWidget* m_animViewportWidget = nullptr; @@ -82,6 +80,7 @@ namespace EMStudio AzToolsFramework::RotationManipulators m_rotateManipulators; AzToolsFramework::ScaleManipulators m_scaleManipulators; AZStd::shared_ptr m_manipulatorManager; + AZ::Transform m_mouseDownStartTransform; MCORE_DEFINECOMMANDCALLBACK(ImportActorCallback); MCORE_DEFINECOMMANDCALLBACK(RemoveActorCallback);