From aef1f01de2b598758af06c52458d219a0f61db53 Mon Sep 17 00:00:00 2001 From: Tommy Walton <82672795+amzn-tommy@users.noreply.github.com> Date: Tue, 5 Oct 2021 09:58:54 -0700 Subject: [PATCH] Expose OnModelReady to behavior context for hydra automation (#4331) * Expose OnModelReady to behavior context for hydra automation Signed-off-by: amzn-tommy * Adding assets used by the hydra test to Atom/TestData Signed-off-by: amzn-tommy * Attempt to fix line ending Signed-off-by: amzn-tommy * Moving behavior context for mesh notification bus to the component controller Signed-off-by: amzn-tommy * Changed the AssetManager DispatchEvents function to continously pump the AssetBus of queued functions until empty. This replicates the old behavior of the EBusQueuePolicy::Execute function that would continue to execute functions if new ones were added during the execution of the current queue. Split the TestFixture class from the AssetHandler and EBus handler for the DynamicSliceInstanceSpawnerTests and PrefabInstanceSpawnerTest. This avoids the AssetMananager destructor from deleting the test fixture if the call to UnregisterHandler is ever removed. This also allows the memory allocators to get online earlier. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Removing an incorrect [[maybe_unused]] Signed-off-by: amzn-tommy * Moving incorrectly placed [[maybe_unused]] Signed-off-by: amzn-tommy Co-authored-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> --- .../DisplayVertexColor.material | 18 +++++++++++++ .../Objects/ModelHotReload/novertexcolor.fbx | 3 +++ .../Objects/ModelHotReload/sphere_5lods.fbx | 3 +++ .../Objects/ModelHotReload/vertexcolor.fbx | 3 +++ .../Source/Mesh/MeshComponentController.cpp | 25 ++++++++++++++++++- 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 Gems/Atom/TestData/TestData/Objects/ModelHotReload/DisplayVertexColor.material create mode 100644 Gems/Atom/TestData/TestData/Objects/ModelHotReload/novertexcolor.fbx create mode 100644 Gems/Atom/TestData/TestData/Objects/ModelHotReload/sphere_5lods.fbx create mode 100644 Gems/Atom/TestData/TestData/Objects/ModelHotReload/vertexcolor.fbx diff --git a/Gems/Atom/TestData/TestData/Objects/ModelHotReload/DisplayVertexColor.material b/Gems/Atom/TestData/TestData/Objects/ModelHotReload/DisplayVertexColor.material new file mode 100644 index 0000000000..104d675387 --- /dev/null +++ b/Gems/Atom/TestData/TestData/Objects/ModelHotReload/DisplayVertexColor.material @@ -0,0 +1,18 @@ +{ + "description": "", + "materialType": "Materials/Types/StandardMultilayerPBR.materialtype", + "parentMaterial": "", + "propertyLayoutVersion": 3, + "properties": { + "blend": { + "blendSource": "BlendMaskVertexColors", + "debugDrawMode": "FinalBlendWeights", + "enableLayer2": true, + "enableLayer3": true, + "textureMap": "" + }, + "parallax": { + "enable": false + } + } +} diff --git a/Gems/Atom/TestData/TestData/Objects/ModelHotReload/novertexcolor.fbx b/Gems/Atom/TestData/TestData/Objects/ModelHotReload/novertexcolor.fbx new file mode 100644 index 0000000000..abc518cf09 --- /dev/null +++ b/Gems/Atom/TestData/TestData/Objects/ModelHotReload/novertexcolor.fbx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b6d860c6fc3703914716a97910899eca2e66927688690646f697c6246ac310fb +size 317340 diff --git a/Gems/Atom/TestData/TestData/Objects/ModelHotReload/sphere_5lods.fbx b/Gems/Atom/TestData/TestData/Objects/ModelHotReload/sphere_5lods.fbx new file mode 100644 index 0000000000..de03622834 --- /dev/null +++ b/Gems/Atom/TestData/TestData/Objects/ModelHotReload/sphere_5lods.fbx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:91b8153f93e4773d872478fef40ff00c1b8d5f1ef13101cf62f81956e1c30107 +size 68800 diff --git a/Gems/Atom/TestData/TestData/Objects/ModelHotReload/vertexcolor.fbx b/Gems/Atom/TestData/TestData/Objects/ModelHotReload/vertexcolor.fbx new file mode 100644 index 0000000000..3bbbc29a33 --- /dev/null +++ b/Gems/Atom/TestData/TestData/Objects/ModelHotReload/vertexcolor.fbx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2cf646a0a977c2edc5ee2ab6351ef633f194ce60c59ea3cb8359f71648db668e +size 374492 diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index 6cdb44a9e1..12b14d8162 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -32,6 +32,23 @@ namespace AZ { namespace Render { + namespace Internal + { + struct MeshComponentNotificationBusHandler final + : public MeshComponentNotificationBus::Handler + , public AZ::BehaviorEBusHandler + { + AZ_EBUS_BEHAVIOR_BINDER( + MeshComponentNotificationBusHandler, "{8B8F4977-817F-4C7C-9141-0E5FF899E1BC}", AZ::SystemAllocator, OnModelReady); + + void OnModelReady( + [[maybe_unused]] const Data::Asset& modelAsset, + [[maybe_unused]] const Data::Instance& model) override + { + Call(FN_OnModelReady); + } + }; + } // namespace Internal namespace MeshComponentControllerVersionUtility { @@ -173,6 +190,12 @@ namespace AZ ->VirtualProperty("MinimumScreenCoverage", "GetMinimumScreenCoverage", "SetMinimumScreenCoverage") ->VirtualProperty("QualityDecayRate", "GetQualityDecayRate", "SetQualityDecayRate") ; + + behaviorContext->EBus("MeshComponentNotificationBus") + ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) + ->Attribute(AZ::Script::Attributes::Category, "render") + ->Attribute(AZ::Script::Attributes::Module, "render") + ->Handler(); } } @@ -306,7 +329,7 @@ namespace AZ return model ? model->GetUvNames() : AZStd::unordered_set(); } - void MeshComponentController::OnMaterialsUpdated([[maybe_unused]] const MaterialAssignmentMap& materials) + void MeshComponentController::OnMaterialsUpdated(const MaterialAssignmentMap& materials) { if (m_meshFeatureProcessor) {