From 808fd1d3ba2843a2e0e19205726f4ca957e5fcd8 Mon Sep 17 00:00:00 2001 From: moraaar Date: Fri, 16 Apr 2021 18:24:29 +0100 Subject: [PATCH 01/32] Cloth works with Actors in Atom. Cloth system uses MeshAssetHelper to read model mesh information for actors too. --- .../Code/Source/AtomActorInstance.cpp | 48 +++++++------------ .../Code/Source/AtomActorInstance.h | 9 ---- .../ClothComponentMesh/ClothComponentMesh.cpp | 15 ++++-- .../NvCloth/Code/Source/Utils/AssetHelper.cpp | 26 ++-------- .../Code/Source/Utils/MeshAssetHelper.cpp | 6 +++ .../Code/Source/Utils/MeshAssetHelper.h | 4 +- 6 files changed, 41 insertions(+), 67 deletions(-) diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp index 0a17a6444d..cd5f3bb6c5 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp @@ -212,19 +212,26 @@ namespace AZ void AtomActorInstance::SetModelAsset([[maybe_unused]] Data::Asset modelAsset) { - // Atom Actor Instance is not based on an actual Model Asset yet, - // it's created at runtime from an Actor Asset. + // Changing model asset is not supported by Atom Actor Instance. + // The model asset is obtained from the Actor inside the ActorAsset, + // which is passed to the constructor. To set a different model asset + // this instance should use a different Actor. + AZ_Assert(false, "AtomActorInstance::SetModelAsset not supported"); } const Data::Asset& AtomActorInstance::GetModelAsset() const { - return m_skinnedMeshInstance->m_model->GetModelAsset(); + AZ_Assert(GetActor(), "Expecting a Atom Actor Instance having a valid Actor."); + return GetActor()->GetMeshAsset(); } void AtomActorInstance::SetModelAssetId([[maybe_unused]] Data::AssetId modelAssetId) { - // Atom Actor Instance is not based on an actual Model Asset yet, - // it's created at runtime from an Actor Asset. + // Changing model asset is not supported by Atom Actor Instance. + // The model asset is obtained from the Actor inside the ActorAsset, + // which is passed to the constructor. To set a different model asset + // this instance should use a different Actor. + AZ_Assert(false, "AtomActorInstance::SetModelAssetId not supported"); } Data::AssetId AtomActorInstance::GetModelAssetId() const @@ -234,8 +241,11 @@ namespace AZ void AtomActorInstance::SetModelAssetPath([[maybe_unused]] const AZStd::string& modelAssetPath) { - // Atom Actor Instance is not based on an actual Model Asset yet, - // it's created at runtime from an Actor Asset. + // Changing model asset is not supported by Atom Actor Instance. + // The model asset is obtained from the Actor inside the ActorAsset, + // which is passed to the constructor. To set a different model asset + // this instance should use a different Actor. + AZ_Assert(false, "AtomActorInstance::SetModelAssetPath not supported"); } AZStd::string AtomActorInstance::GetModelAssetPath() const @@ -278,28 +288,6 @@ namespace AZ return IsVisible(); } - void AtomActorInstance::SetMeshAsset(const AZ::Data::AssetId& id) - { - AZ::Data::Asset asset = - AZ::Data::AssetManager::Instance().GetAsset( - id, m_actorAsset.GetAutoLoadBehavior()); - if (asset) - { - m_actorAsset = asset; - Create(); - } - } - - AZ::Data::Asset AtomActorInstance::GetMeshAsset() - { - return m_actorAsset; - } - - bool AtomActorInstance::GetVisibility() - { - return static_cast(*this).GetVisibility(); - } - AZ::u32 AtomActorInstance::GetJointCount() { return m_actorInstance->GetActor()->GetSkeleton()->GetNumNodes(); @@ -469,7 +457,6 @@ namespace AZ TransformNotificationBus::Handler::BusConnect(m_entityId); MaterialComponentNotificationBus::Handler::BusConnect(m_entityId); MeshComponentRequestBus::Handler::BusConnect(m_entityId); - LmbrCentral::MeshComponentRequestBus::Handler::BusConnect(m_entityId); const Data::Instance model = m_meshFeatureProcessor->GetModel(*m_meshHandle); MeshComponentNotificationBus::Event(m_entityId, &MeshComponentNotificationBus::Events::OnModelReady, model->GetModelAsset(), model); @@ -479,7 +466,6 @@ namespace AZ { MeshComponentNotificationBus::Event(m_entityId, &MeshComponentNotificationBus::Events::OnModelPreDestroy); - LmbrCentral::MeshComponentRequestBus::Handler::BusDisconnect(); MeshComponentRequestBus::Handler::BusDisconnect(); MaterialComponentNotificationBus::Handler::BusDisconnect(); TransformNotificationBus::Handler::BusDisconnect(); diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.h b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.h index e14a0a7c4f..a2cf042efa 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.h +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.h @@ -62,7 +62,6 @@ namespace AZ , public AzFramework::BoundsRequestBus::Handler , public AZ::Render::MaterialComponentNotificationBus::Handler , public AZ::Render::MeshComponentRequestBus::Handler - , public LmbrCentral::MeshComponentRequestBus::Handler , private AZ::Render::SkinnedMeshFeatureProcessorNotificationBus::Handler , private AZ::Render::SkinnedMeshOutputStreamNotificationBus::Handler , private LmbrCentral::SkeletalHierarchyRequestBus::Handler @@ -143,14 +142,6 @@ namespace AZ bool GetVisibility() const override; // GetWorldBounds/GetLocalBounds already overridden by BoundsRequestBus::Handler - ////////////////////////////////////////////////////////////////////////// - // LmbrCentral::MeshComponentRequestBus::Handler - void SetMeshAsset(const AZ::Data::AssetId& id) override; - AZ::Data::Asset GetMeshAsset() override; - bool GetVisibility() override; - // SetVisibility already overridden by MeshComponentRequestBus::Handler - // GetWorldBounds/GetLocalBounds already overridden by BoundsRequestBus::Handler - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// // SkeletalHierarchyRequestBus::Handler overrides... AZ::u32 GetJointCount() override; diff --git a/Gems/NvCloth/Code/Source/Components/ClothComponentMesh/ClothComponentMesh.cpp b/Gems/NvCloth/Code/Source/Components/ClothComponentMesh/ClothComponentMesh.cpp index cf2593048f..92dbfdb89a 100644 --- a/Gems/NvCloth/Code/Source/Components/ClothComponentMesh/ClothComponentMesh.cpp +++ b/Gems/NvCloth/Code/Source/Components/ClothComponentMesh/ClothComponentMesh.cpp @@ -448,9 +448,18 @@ namespace NvCloth const auto& renderTangents = renderData.m_tangents; const auto& renderBitangents = renderData.m_bitangents; - AZ::Data::Asset modelAsset; - AZ::Render::MeshComponentRequestBus::EventResult( - modelAsset, m_entityId, &AZ::Render::MeshComponentRequestBus::Events::GetModelAsset); + // Since Atom has a 1:1 relation with between ModelAsset buffers and Model buffers, + // internally it created a new asset for the model instance. So it's important to + // get the asset from the model when we want to write to them, instead of getting the + // ModelAsset directly from the bus (which returns the original asset shared by all entities). + AZ::Data::Instance model; + AZ::Render::MeshComponentRequestBus::EventResult(model, m_entityId, &AZ::Render::MeshComponentRequestBus::Events::GetModel); + if (!model) + { + return; + } + + AZ::Data::Asset modelAsset = model->GetModelAsset(); if (!modelAsset.IsReady()) { return; diff --git a/Gems/NvCloth/Code/Source/Utils/AssetHelper.cpp b/Gems/NvCloth/Code/Source/Utils/AssetHelper.cpp index cb4d644065..c7558580b3 100644 --- a/Gems/NvCloth/Code/Source/Utils/AssetHelper.cpp +++ b/Gems/NvCloth/Code/Source/Utils/AssetHelper.cpp @@ -13,11 +13,7 @@ #include #include -#include -#include - -#include namespace NvCloth { @@ -30,25 +26,9 @@ namespace NvCloth AZStd::unique_ptr AssetHelper::CreateAssetHelper(AZ::EntityId entityId) { - // Does the entity have an Actor Asset? - EMotionFX::ActorInstance* actorInstance = nullptr; - EMotionFX::Integration::ActorComponentRequestBus::EventResult( - actorInstance, entityId, &EMotionFX::Integration::ActorComponentRequestBus::Events::GetActorInstance); - if (actorInstance) - { - return AZStd::make_unique(entityId); - } - - AZ::Data::Asset modelAsset; - AZ::Render::MeshComponentRequestBus::EventResult( - modelAsset, entityId, &AZ::Render::MeshComponentRequestBus::Events::GetModelAsset); - if (modelAsset.GetId().IsValid()) - { - return AZStd::make_unique(entityId); - } - - AZ_Warning("AssetHelper", false, "Unexpected asset type"); - return nullptr; + return entityId.IsValid() + ? AZStd::make_unique(entityId) + : nullptr; } float AssetHelper::ConvertBackstopOffset(float backstopOffset) diff --git a/Gems/NvCloth/Code/Source/Utils/MeshAssetHelper.cpp b/Gems/NvCloth/Code/Source/Utils/MeshAssetHelper.cpp index fa8d6e5455..6852d245d2 100644 --- a/Gems/NvCloth/Code/Source/Utils/MeshAssetHelper.cpp +++ b/Gems/NvCloth/Code/Source/Utils/MeshAssetHelper.cpp @@ -14,11 +14,17 @@ #include +#include + namespace NvCloth { MeshAssetHelper::MeshAssetHelper(AZ::EntityId entityId) : AssetHelper(entityId) { + EMotionFX::ActorInstance* actorInstance = nullptr; + EMotionFX::Integration::ActorComponentRequestBus::EventResult( + actorInstance, entityId, &EMotionFX::Integration::ActorComponentRequestBus::Events::GetActorInstance); + m_supportSkinnedAnimation = actorInstance != nullptr; } void MeshAssetHelper::GatherClothMeshNodes(MeshNodeList& meshNodes) diff --git a/Gems/NvCloth/Code/Source/Utils/MeshAssetHelper.h b/Gems/NvCloth/Code/Source/Utils/MeshAssetHelper.h index b558519bd4..a7849583e7 100644 --- a/Gems/NvCloth/Code/Source/Utils/MeshAssetHelper.h +++ b/Gems/NvCloth/Code/Source/Utils/MeshAssetHelper.h @@ -35,12 +35,14 @@ namespace NvCloth MeshClothInfo& meshClothInfo) override; bool DoesSupportSkinnedAnimation() const override { - return false; + return m_supportSkinnedAnimation; } private: bool CopyDataFromMeshes( const AZStd::vector& meshes, MeshClothInfo& meshClothInfo); + + bool m_supportSkinnedAnimation = false; }; } // namespace NvCloth From 9e6a5ecbaf3e8619bffd11f2d4944145a42560cf Mon Sep 17 00:00:00 2001 From: moraaar Date: Fri, 16 Apr 2021 18:25:24 +0100 Subject: [PATCH 02/32] Fix cloth chicken actor asset in NvCloth gem. --- .../cloth/Chicken/Actor/chicken.fbx.assetinfo | 534 ++++++------------ 1 file changed, 172 insertions(+), 362 deletions(-) diff --git a/Gems/NvCloth/Assets/Objects/cloth/Chicken/Actor/chicken.fbx.assetinfo b/Gems/NvCloth/Assets/Objects/cloth/Chicken/Actor/chicken.fbx.assetinfo index 808b024189..a6024e0c5f 100644 --- a/Gems/NvCloth/Assets/Objects/cloth/Chicken/Actor/chicken.fbx.assetinfo +++ b/Gems/NvCloth/Assets/Objects/cloth/Chicken/Actor/chicken.fbx.assetinfo @@ -1,362 +1,172 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +{ + "values": [ + { + "$type": "ActorGroup", + "name": "chicken", + "id": "{C086F309-EE7E-5AFD-A9C2-69DE5BA48461}", + "rules": { + "rules": [ + { + "$type": "MetaDataRule", + "metaData": "AdjustActor -actorID $(ACTORID) -name \"chicken\"\r\nActorSetCollisionMeshes -actorID $(ACTORID) -lod 0 -nodeList \"\"\r\nAdjustActor -actorID $(ACTORID) -nodesExcludedFromBounds \"\" -nodeAction \"select\"\r\nAdjustActor -actorID $(ACTORID) -nodeAction \"replace\" -attachmentNodes \"\"\r\n" + }, + { + "$type": "ActorPhysicsSetupRule", + "data": { + "config": { + "clothConfig": { + "nodes": [ + { + "name": "def_c_head_joint", + "shapes": [ + [ + { + "Visible": true, + "Position": [ + -0.08505599945783615, + 0.0, + 0.009370899759232998 + ], + "Rotation": [ + 0.7071437239646912, + 0.0, + 0.0, + 0.708984375 + ], + "propertyVisibilityFlags": 248 + }, + { + "$type": "CapsuleShapeConfiguration", + "Height": 0.191273495554924, + "Radius": 0.05063670128583908 + } + ] + ] + }, + { + "name": "def_c_neck_joint", + "shapes": [ + [ + { + "Visible": true, + "Position": [ + -0.03810190036892891, + 0.0, + -0.03132440149784088 + ], + "propertyVisibilityFlags": 248 + }, + { + "$type": "SphereShapeConfiguration", + "Radius": 0.16069939732551576 + } + ] + ] + }, + { + "name": "def_c_spine_end", + "shapes": [ + [ + { + "Visible": true, + "Position": [ + -2.0000000233721949e-7, + 0.012646200135350228, + -0.24104370176792146 + ], + "propertyVisibilityFlags": 248 + }, + { + "$type": "SphereShapeConfiguration", + "Radius": 0.24875959753990174 + } + ] + ] + } + ] + } + } + } + }, + { + "$type": "CoordinateSystemRule" + } + ] + } + }, + { + "$type": "{07B356B7-3635-40B5-878A-FAC4EFD5AD86} MeshGroup", + "name": "chicken", + "nodeSelectionList": { + "selectedNodes": [ + {}, + "RootNode", + "RootNode.chicken_skeleton", + "RootNode.chicken_feet_skin", + "RootNode.chicken_eyes_skin", + "RootNode.chicken_body_skin", + "RootNode.chicken_mohawk", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_l_uprLeg_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_r_uprLeg_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_l_uprLeg_joint.def_l_lwrLeg_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_r_uprLeg_joint.def_r_lwrLeg_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_l_wing1_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_r_wing1_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_l_uprLeg_joint.def_l_lwrLeg_joint.def_l_foot_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_r_uprLeg_joint.def_r_lwrLeg_joint.def_r_foot_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_tail1_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_l_wing1_joint.def_l_wing2_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_r_wing1_joint.def_r_wing2_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_l_uprLeg_joint.def_l_lwrLeg_joint.def_l_foot_joint.def_l_ball_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_r_uprLeg_joint.def_r_lwrLeg_joint.def_r_foot_joint.def_r_ball_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_tail1_joint.def_c_tail2_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_l_wing1_joint.def_l_wing2_joint.def_l_wing_end", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_r_wing1_joint.def_r_wing2_joint.def_r_wing_end", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_feather1_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_mouth_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_waddle1_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_feather1_joint.def_c_feather2_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_mouth_joint.def_c_mouth_end", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_waddle1_joint.def_c_waddle2_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_feather1_joint.def_c_feather2_joint.def_c_feather3_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_waddle1_joint.def_c_waddle2_joint.def_c_waddle3_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_feather1_joint.def_c_feather2_joint.def_c_feather3_joint.def_c_feather4_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_waddle1_joint.def_c_waddle2_joint.def_c_waddle3_joint.def_c_waddle_end", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_feather1_joint.def_c_feather2_joint.def_c_feather3_joint.def_c_feather4_joint.def_c_feather_end" + ] + }, + "rules": { + "rules": [ + { + "$type": "SkinRule" + }, + { + "$type": "StaticMeshAdvancedRule", + "vertexColorStreamName": "Disabled" + }, + { + "$type": "MaterialRule" + }, + { + "$type": "CoordinateSystemRule" + }, + { + "$type": "ClothRule", + "meshNodeName": "RootNode.chicken_mohawk", + "inverseMassesStreamName": "colorSet1", + "motionConstraintsStreamName": "Default: 1.0", + "backstopStreamName": "None" + } + ] + }, + "id": "{55E26F74-B35F-4BC1-87BB-83E3DE85C346}" + } + ] +} \ No newline at end of file From 4b3662ac0a47cb6e962653e3acd838183c701eed Mon Sep 17 00:00:00 2001 From: moraaar Date: Fri, 16 Apr 2021 18:26:17 +0100 Subject: [PATCH 03/32] Sort out cloth tests after Actors work with model mesh assets. --- .../ActorClothCollidersTest.cpp | 10 ++-- .../ClothComponentMeshTest.cpp | 28 ++++++++--- .../Components/EditorClothComponentTest.cpp | 20 ++++---- Gems/NvCloth/Code/Tests/System/ClothTest.cpp | 2 +- .../Code/Tests/System/FabricCookerTest.cpp | 44 ++++++++-------- .../Code/Tests/Utils/ActorAssetHelperTest.cpp | 50 +++++++++++++------ 6 files changed, 96 insertions(+), 58 deletions(-) diff --git a/Gems/NvCloth/Code/Tests/Components/ClothComponentMesh/ActorClothCollidersTest.cpp b/Gems/NvCloth/Code/Tests/Components/ClothComponentMesh/ActorClothCollidersTest.cpp index 946f9e0af2..e3a321cebd 100644 --- a/Gems/NvCloth/Code/Tests/Components/ClothComponentMesh/ActorClothCollidersTest.cpp +++ b/Gems/NvCloth/Code/Tests/Components/ClothComponentMesh/ActorClothCollidersTest.cpp @@ -145,8 +145,8 @@ namespace UnitTest const AZStd::vector& capsuleColliders = actorClothColliders->GetCapsuleColliders(); const AZStd::vector& nativeCapsuleIndices = actorClothColliders->GetCapsuleIndices(); - EXPECT_EQ(sphereColliders.size(), 1); - EXPECT_EQ(nativeSpheres.size(), 1); + ASSERT_EQ(sphereColliders.size(), 1); + ASSERT_EQ(nativeSpheres.size(), 1); EXPECT_TRUE(capsuleColliders.empty()); EXPECT_TRUE(nativeCapsuleIndices.empty()); @@ -189,9 +189,9 @@ namespace UnitTest const AZStd::vector& nativeCapsuleIndices = actorClothColliders->GetCapsuleIndices(); EXPECT_TRUE(sphereColliders.empty()); - EXPECT_EQ(nativeSpheres.size(), 2); // Each capsule produces 2 spheres - EXPECT_EQ(capsuleColliders.size(), 1); - EXPECT_EQ(nativeCapsuleIndices.size(), 2); // Each capsule is 2 indices + ASSERT_EQ(nativeSpheres.size(), 2); // Each capsule produces 2 spheres + ASSERT_EQ(capsuleColliders.size(), 1); + ASSERT_EQ(nativeCapsuleIndices.size(), 2); // Each capsule is 2 indices EXPECT_NEAR(capsuleColliders[0].m_height, height, Tolerance); EXPECT_NEAR(capsuleColliders[0].m_radius, radius, Tolerance); diff --git a/Gems/NvCloth/Code/Tests/Components/ClothComponentMesh/ClothComponentMeshTest.cpp b/Gems/NvCloth/Code/Tests/Components/ClothComponentMesh/ClothComponentMeshTest.cpp index c463c30226..3d5b7713b3 100644 --- a/Gems/NvCloth/Code/Tests/Components/ClothComponentMesh/ClothComponentMeshTest.cpp +++ b/Gems/NvCloth/Code/Tests/Components/ClothComponentMesh/ClothComponentMeshTest.cpp @@ -144,8 +144,12 @@ namespace UnitTest EXPECT_TRUE(renderData.m_bitangents.empty()); EXPECT_TRUE(renderData.m_normals.empty()); } - - TEST_F(NvClothComponentMesh, ClothComponentMesh_InitWithEntityActorWithNoClothData_TriggersError) + + // [TODO LYN-1891] + // Revisit when Cloth Component Mesh works with Actors adapted to Atom models. + // Editor Cloth component now uses the new AZ::Render::MeshComponentNotificationBus::OnModelReady + // notification and this test does not setup a model yet. + TEST_F(NvClothComponentMesh, DISABLED_ClothComponentMesh_InitWithEntityActorWithNoClothData_TriggersError) { { auto actor = AZStd::make_unique("actor_test"); @@ -165,8 +169,12 @@ namespace UnitTest AZ_TEST_STOP_TRACE_SUPPRESSION(1); // Expect 1 error } - - TEST_F(NvClothComponentMesh, ClothComponentMesh_InitWithEntityActor_ReturnsValidRenderData) + + // [TODO LYN-1891] + // Revisit when Cloth Component Mesh works with Actors adapted to Atom models. + // Editor Cloth component now uses the new AZ::Render::MeshComponentNotificationBus::OnModelReady + // notification and this test does not setup a model yet. + TEST_F(NvClothComponentMesh, DISABLED_ClothComponentMesh_InitWithEntityActor_ReturnsValidRenderData) { { auto actor = AZStd::make_unique("actor_test"); @@ -265,7 +273,11 @@ namespace UnitTest EXPECT_TRUE(renderData.m_normals.empty()); } - TEST_F(NvClothComponentMesh, ClothComponentMesh_UpdateConfigurationDifferentEntity_ReturnsRenderDataFromNewEntity) + // [TODO LYN-1891] + // Revisit when Cloth Component Mesh works with Actors adapted to Atom models. + // Editor Cloth component now uses the new AZ::Render::MeshComponentNotificationBus::OnModelReady + // notification and this test does not setup a model yet. + TEST_F(NvClothComponentMesh, DISABLED_ClothComponentMesh_UpdateConfigurationDifferentEntity_ReturnsRenderDataFromNewEntity) { { auto actor = AZStd::make_unique("actor_test"); @@ -341,7 +353,11 @@ namespace UnitTest EXPECT_TRUE(renderData.m_normals.empty()); } - TEST_F(NvClothComponentMesh, ClothComponentMesh_UpdateConfigurationNewMeshNode_ReturnsRenderDataFromNewMeshNode) + // [TODO LYN-1891] + // Revisit when Cloth Component Mesh works with Actors adapted to Atom models. + // Editor Cloth component now uses the new AZ::Render::MeshComponentNotificationBus::OnModelReady + // notification and this test does not setup a model yet. + TEST_F(NvClothComponentMesh, DISABLED_ClothComponentMesh_UpdateConfigurationNewMeshNode_ReturnsRenderDataFromNewMeshNode) { const AZStd::string meshNode2Name = "cloth_node_2"; diff --git a/Gems/NvCloth/Code/Tests/Components/EditorClothComponentTest.cpp b/Gems/NvCloth/Code/Tests/Components/EditorClothComponentTest.cpp index bb3218a4f5..7dc191bd9a 100644 --- a/Gems/NvCloth/Code/Tests/Components/EditorClothComponentTest.cpp +++ b/Gems/NvCloth/Code/Tests/Components/EditorClothComponentTest.cpp @@ -184,7 +184,7 @@ namespace UnitTest const NvCloth::MeshNodeList& meshNodeList = editorClothComponent->GetMeshNodeList(); - EXPECT_EQ(meshNodeList.size(), 1); + ASSERT_EQ(meshNodeList.size(), 1); EXPECT_TRUE(meshNodeList[0] == NvCloth::Internal::StatusMessageNoAsset); } @@ -208,7 +208,7 @@ namespace UnitTest const NvCloth::MeshNodeList& meshNodeList = editorClothComponent->GetMeshNodeList(); - EXPECT_EQ(meshNodeList.size(), 1); + ASSERT_EQ(meshNodeList.size(), 1); EXPECT_TRUE(meshNodeList[0] == NvCloth::Internal::StatusMessageNoClothNodes); } @@ -234,7 +234,7 @@ namespace UnitTest const NvCloth::MeshNodeList& meshNodeList = editorClothComponent->GetMeshNodeList(); - EXPECT_EQ(meshNodeList.size(), 1); + ASSERT_EQ(meshNodeList.size(), 1); EXPECT_TRUE(meshNodeList[0] == NvCloth::Internal::StatusMessageNoClothNodes); } @@ -261,7 +261,7 @@ namespace UnitTest const NvCloth::MeshNodeList& meshNodeList = editorClothComponent->GetMeshNodeList(); - EXPECT_EQ(meshNodeList.size(), 2); + ASSERT_EQ(meshNodeList.size(), 2); EXPECT_TRUE(meshNodeList[0] == NvCloth::Internal::StatusMessageSelectNode); EXPECT_TRUE(meshNodeList[1] == MeshNodeName); } @@ -322,9 +322,11 @@ namespace UnitTest EXPECT_TRUE(meshNodesWithBackstopData.find(MeshNodeName) != meshNodesWithBackstopData.end()); } - // [TODO LYN-2252] - // Enable test once OnModelDestroyed is available. - TEST_F(NvClothEditorClothComponent, DISABLED_EditorClothComponent_OnMeshDestroyed_ReturnsMeshNodeListWithNoAssetMessage) + // [TODO LYN-1891] + // Revisit when Cloth Component Mesh works with Actors adapted to Atom models. + // Editor Cloth component now uses the new AZ::Render::MeshComponentNotificationBus::OnModelReady + // notification and this test does not setup a model yet. + TEST_F(NvClothEditorClothComponent, DISABLED_EditorClothComponent_OnModelPreDestroy_ReturnsMeshNodeListWithNoAssetMessage) { auto editorEntity = CreateInactiveEditorEntity("ClothComponentEditorEntity"); auto* editorClothComponent = editorEntity->CreateComponent(); @@ -341,12 +343,12 @@ namespace UnitTest editorActorComponent->SetActorAsset(CreateAssetFromActor(AZStd::move(actor))); } - //editorClothComponent->OnModelDestroyed(); + editorClothComponent->OnModelPreDestroy(); const NvCloth::MeshNodeList& meshNodeList = editorClothComponent->GetMeshNodeList(); const auto& meshNodesWithBackstopData = editorClothComponent->GetMeshNodesWithBackstopData(); - EXPECT_EQ(meshNodeList.size(), 1); + ASSERT_EQ(meshNodeList.size(), 1); EXPECT_TRUE(meshNodeList[0] == NvCloth::Internal::StatusMessageNoAsset); EXPECT_TRUE(meshNodesWithBackstopData.empty()); } diff --git a/Gems/NvCloth/Code/Tests/System/ClothTest.cpp b/Gems/NvCloth/Code/Tests/System/ClothTest.cpp index 2c3ae610e4..08959a9196 100644 --- a/Gems/NvCloth/Code/Tests/System/ClothTest.cpp +++ b/Gems/NvCloth/Code/Tests/System/ClothTest.cpp @@ -506,7 +506,7 @@ namespace UnitTest EXPECT_EQ(initialParticles.size(), nvClothCurrentParticles.size()); EXPECT_EQ(initialParticles.size(), nvClothPreviousParticles.size()); - for (size_t i = 0; i < nvClothCurrentParticles.size(); ++i) + for (size_t i = 0; i < initialParticles.size(); ++i) { ExpectEq(initialParticles[i], nvClothCurrentParticles[i]); ExpectEq(initialParticles[i], nvClothPreviousParticles[i]); diff --git a/Gems/NvCloth/Code/Tests/System/FabricCookerTest.cpp b/Gems/NvCloth/Code/Tests/System/FabricCookerTest.cpp index 16a5d2efa3..d2d312c2ca 100644 --- a/Gems/NvCloth/Code/Tests/System/FabricCookerTest.cpp +++ b/Gems/NvCloth/Code/Tests/System/FabricCookerTest.cpp @@ -283,7 +283,7 @@ namespace UnitTest AZStd::vector remappedVertices; NvCloth::Internal::WeldVertices(vertices, indices, weldedVertices, weldedIndices, remappedVertices); - EXPECT_EQ(weldedVertices.size(), expectedSizeAfterWelding); + ASSERT_EQ(weldedVertices.size(), expectedSizeAfterWelding); EXPECT_THAT(weldedVertices[0].GetAsVector3(), IsCloseTolerance(vertexPosition, Tolerance)); EXPECT_NEAR(weldedVertices[0].GetW(), lowestInverseMass, Tolerance); } @@ -307,9 +307,9 @@ namespace UnitTest AZStd::vector remappedVertices; NvCloth::Internal::WeldVertices(vertices, indices, weldedVertices, weldedIndices, remappedVertices); - EXPECT_EQ(weldedVertices.size(), expectedSizeAfterWelding); - EXPECT_EQ(weldedIndices.size(), indices.size()); - EXPECT_EQ(remappedVertices.size(), vertices.size()); + ASSERT_EQ(weldedVertices.size(), expectedSizeAfterWelding); + ASSERT_EQ(weldedIndices.size(), indices.size()); + ASSERT_EQ(remappedVertices.size(), vertices.size()); for (size_t i = 0; i < remappedVertices.size(); ++i) { @@ -347,9 +347,9 @@ namespace UnitTest // The result after calling WeldVertices is expected to have the same size. // The vertices inside will be reordered though due to the welding process. - EXPECT_EQ(weldedVertices.size(), vertices.size()); - EXPECT_EQ(weldedIndices.size(), indices.size()); - EXPECT_EQ(remappedVertices.size(), vertices.size()); + ASSERT_EQ(weldedVertices.size(), vertices.size()); + ASSERT_EQ(weldedIndices.size(), indices.size()); + ASSERT_EQ(remappedVertices.size(), vertices.size()); for (size_t i = 0; i < remappedVertices.size(); ++i) { @@ -422,9 +422,9 @@ namespace UnitTest AZStd::vector remappedVertices; NvCloth::Internal::RemoveStaticTriangles(vertices, indices, simplifiedVertices, simplifiedIndices, remappedVertices); - EXPECT_EQ(simplifiedVertices.size(), expectedVerticesSizeAfterSimplification); - EXPECT_EQ(simplifiedIndices.size(), expectedIndicesSizeAfterSimplification); - EXPECT_EQ(remappedVertices.size(), vertices.size()); + ASSERT_EQ(simplifiedVertices.size(), expectedVerticesSizeAfterSimplification); + ASSERT_EQ(simplifiedIndices.size(), expectedIndicesSizeAfterSimplification); + ASSERT_EQ(remappedVertices.size(), vertices.size()); for (size_t i = 0; i < remappedVertices.size(); ++i) { @@ -477,9 +477,9 @@ namespace UnitTest AZStd::vector remappedVertices; NvCloth::Internal::RemoveStaticTriangles(vertices, indices, simplifiedVertices, simplifiedIndices, remappedVertices); - EXPECT_EQ(simplifiedVertices.size(), expectedVerticesSizeAfterSimplification); - EXPECT_EQ(simplifiedIndices.size(), expectedIndicesSizeAfterSimplification); - EXPECT_EQ(remappedVertices.size(), vertices.size()); + ASSERT_EQ(simplifiedVertices.size(), expectedVerticesSizeAfterSimplification); + ASSERT_EQ(simplifiedIndices.size(), expectedIndicesSizeAfterSimplification); + ASSERT_EQ(remappedVertices.size(), vertices.size()); for (size_t i = 0; i < remappedVertices.size(); ++i) { @@ -532,9 +532,9 @@ namespace UnitTest // The result after calling RemoveStaticTriangles is expected to have the same size. // The vertices will be reordered though due to the processing during simplification. - EXPECT_EQ(simplifiedVertices.size(), vertices.size()); - EXPECT_EQ(simplifiedIndices.size(), indices.size()); - EXPECT_EQ(remappedVertices.size(), vertices.size()); + ASSERT_EQ(simplifiedVertices.size(), vertices.size()); + ASSERT_EQ(simplifiedIndices.size(), indices.size()); + ASSERT_EQ(remappedVertices.size(), vertices.size()); for (size_t i = 0; i < remappedVertices.size(); ++i) { @@ -576,9 +576,9 @@ namespace UnitTest AZStd::vector remappedVertices; AZ::Interface::Get()->SimplifyMesh(vertices, indices, simplifiedVertices, simplifiedIndices, remappedVertices, removeStaticTriangles); - EXPECT_EQ(simplifiedVertices.size(), expectedVerticesSizeAfterSimplification); - EXPECT_EQ(simplifiedIndices.size(), expectedIndicesSizeAfterSimplification); - EXPECT_EQ(remappedVertices.size(), vertices.size()); + ASSERT_EQ(simplifiedVertices.size(), expectedVerticesSizeAfterSimplification); + ASSERT_EQ(simplifiedIndices.size(), expectedIndicesSizeAfterSimplification); + ASSERT_EQ(remappedVertices.size(), vertices.size()); for (size_t i = 0; i < remappedVertices.size(); ++i) { @@ -635,9 +635,9 @@ namespace UnitTest AZStd::vector remappedVertices; AZ::Interface::Get()->SimplifyMesh(vertices, indices, simplifiedVertices, simplifiedIndices, remappedVertices, removeStaticTriangles); - EXPECT_EQ(simplifiedVertices.size(), expectedVerticesSizeAfterSimplification); - EXPECT_EQ(simplifiedIndices.size(), expectedIndicesSizeAfterSimplification); - EXPECT_EQ(remappedVertices.size(), vertices.size()); + ASSERT_EQ(simplifiedVertices.size(), expectedVerticesSizeAfterSimplification); + ASSERT_EQ(simplifiedIndices.size(), expectedIndicesSizeAfterSimplification); + ASSERT_EQ(remappedVertices.size(), vertices.size()); for (size_t i = 0; i < remappedVertices.size(); ++i) { diff --git a/Gems/NvCloth/Code/Tests/Utils/ActorAssetHelperTest.cpp b/Gems/NvCloth/Code/Tests/Utils/ActorAssetHelperTest.cpp index 481bf70c67..de0ba9031e 100644 --- a/Gems/NvCloth/Code/Tests/Utils/ActorAssetHelperTest.cpp +++ b/Gems/NvCloth/Code/Tests/Utils/ActorAssetHelperTest.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include @@ -24,7 +24,7 @@ namespace UnitTest { //! Fixture to setup entity with actor component and the tests data. - class NvClothActorAssetHelper + class NvClothMeshAssetHelper : public ::testing::Test { public: @@ -75,7 +75,7 @@ namespace UnitTest AZStd::unique_ptr m_entity; }; - void NvClothActorAssetHelper::SetUp() + void NvClothMeshAssetHelper::SetUp() { m_entity = AZStd::make_unique(); m_entity->CreateComponent(); @@ -84,14 +84,14 @@ namespace UnitTest m_entity->Activate(); } - void NvClothActorAssetHelper::TearDown() + void NvClothMeshAssetHelper::TearDown() { m_entity->Deactivate(); m_actorComponent = nullptr; m_entity.reset(); } - TEST_F(NvClothActorAssetHelper, ActorAssetHelper_CreateAssetHelperWithInvalidEntityId_ReturnsNull) + TEST_F(NvClothMeshAssetHelper, MeshAssetHelper_CreateAssetHelperWithInvalidEntityId_ReturnsNull) { AZ::EntityId entityId; @@ -100,7 +100,18 @@ namespace UnitTest EXPECT_TRUE(assetHelper.get() == nullptr); } - TEST_F(NvClothActorAssetHelper, ActorAssetHelper_CreateAssetHelperWithActor_ReturnsValidActorAssetHelper) + TEST_F(NvClothMeshAssetHelper, MeshAssetHelper_CreateAssetHelperWithValidEntityId_ReturnsValidMeshAssetHelper) + { + AZStd::unique_ptr entity = AZStd::make_unique(); + + AZStd::unique_ptr assetHelper = NvCloth::AssetHelper::CreateAssetHelper(entity->GetId()); + + EXPECT_TRUE(assetHelper.get() != nullptr); + EXPECT_TRUE(azrtti_cast(assetHelper.get()) != nullptr); + EXPECT_FALSE(assetHelper->DoesSupportSkinnedAnimation()); + } + + TEST_F(NvClothMeshAssetHelper, MeshAssetHelper_CreateAssetHelperWithActor_ReturnsValidMeshAssetHelper) { { auto actor = AZStd::make_unique("actor_test"); @@ -112,10 +123,11 @@ namespace UnitTest AZStd::unique_ptr assetHelper = NvCloth::AssetHelper::CreateAssetHelper(m_actorComponent->GetEntityId()); EXPECT_TRUE(assetHelper.get() != nullptr); - EXPECT_TRUE(azrtti_cast(assetHelper.get()) != nullptr); + EXPECT_TRUE(azrtti_cast(assetHelper.get()) != nullptr); + EXPECT_TRUE(assetHelper->DoesSupportSkinnedAnimation()); } - TEST_F(NvClothActorAssetHelper, ActorAssetHelper_DoesSupportSkinnedAnimation_ReturnsTrue) + TEST_F(NvClothMeshAssetHelper, MeshAssetHelper_DoesSupportSkinnedAnimation_ReturnsTrue) { { auto actor = AZStd::make_unique("actor_test"); @@ -129,7 +141,7 @@ namespace UnitTest EXPECT_TRUE(assetHelper->DoesSupportSkinnedAnimation()); } - TEST_F(NvClothActorAssetHelper, ActorAssetHelper_GatherClothMeshNodesWithEmptyActor_ReturnsEmptyInfo) + TEST_F(NvClothMeshAssetHelper, MeshAssetHelper_GatherClothMeshNodesWithEmptyActor_ReturnsEmptyInfo) { { auto actor = AZStd::make_unique("actor_test"); @@ -146,7 +158,7 @@ namespace UnitTest EXPECT_TRUE(meshNodes.empty()); } - TEST_F(NvClothActorAssetHelper, ActorAssetHelper_ObtainClothMeshNodeInfoWithEmptyActor_ReturnsFalse) + TEST_F(NvClothMeshAssetHelper, MeshAssetHelper_ObtainClothMeshNodeInfoWithEmptyActor_ReturnsFalse) { { auto actor = AZStd::make_unique("actor_test"); @@ -164,7 +176,11 @@ namespace UnitTest EXPECT_FALSE(infoObtained); } - TEST_F(NvClothActorAssetHelper, ActorAssetHelper_GatherClothMeshNodesWithActor_ReturnsCorrectMeshNodeList) + // [TODO LYN-1891] + // Revisit when Cloth Component Mesh works with Actors adapted to Atom models. + // Editor Cloth component now uses the new AZ::Render::MeshComponentNotificationBus::OnModelReady + // notification and this test does not setup a model yet. + TEST_F(NvClothMeshAssetHelper, DISABLED_MeshAssetHelper_GatherClothMeshNodesWithActor_ReturnsCorrectMeshNodeList) { { auto actor = AZStd::make_unique("actor_test"); @@ -185,12 +201,16 @@ namespace UnitTest NvCloth::MeshNodeList meshNodes; assetHelper->GatherClothMeshNodes(meshNodes); - EXPECT_EQ(meshNodes.size(), 2); + ASSERT_EQ(meshNodes.size(), 2); EXPECT_TRUE(meshNodes[0] == MeshNode1Name); EXPECT_TRUE(meshNodes[1] == MeshNode2Name); } - - TEST_F(NvClothActorAssetHelper, ActorAssetHelper_ObtainClothMeshNodeInfoWithActor_ReturnsCorrectClothInfo) + + // [TODO LYN-1891] + // Revisit when Cloth Component Mesh works with Actors adapted to Atom models. + // Editor Cloth component now uses the new AZ::Render::MeshComponentNotificationBus::OnModelReady + // notification and this test does not setup a model yet. + TEST_F(NvClothMeshAssetHelper, DISABLED_MeshAssetHelper_ObtainClothMeshNodeInfoWithActor_ReturnsCorrectClothInfo) { { auto actor = AZStd::make_unique("actor_test"); @@ -215,7 +235,7 @@ namespace UnitTest EXPECT_TRUE(infoObtained); EXPECT_EQ(meshNodeInfo.m_lodLevel, LodLevel); - EXPECT_EQ(meshNodeInfo.m_subMeshes.size(), 1); + ASSERT_EQ(meshNodeInfo.m_subMeshes.size(), 1); EXPECT_EQ(meshNodeInfo.m_subMeshes[0].m_primitiveIndex, 2); EXPECT_EQ(meshNodeInfo.m_subMeshes[0].m_verticesFirstIndex, 0); EXPECT_EQ(meshNodeInfo.m_subMeshes[0].m_numVertices, MeshVertices.size()); From d614b357e5cc1fe20398eb4a0244c3120be1e10f Mon Sep 17 00:00:00 2001 From: guthadam Date: Fri, 16 Apr 2021 22:11:01 -0500 Subject: [PATCH 04/32] ATOM-5921 Material Editor: Select newly created materials in the asset browser The code was previously using asset browser notifications to listen for new files being added in order to select newly created materials. Attempting to change the selection within the notification failed because the new entry still had not been added. Now the material browser queues and processes the selection on tick. https://jira.agscollab.com/browse/ATOM-5921 --- .../Source/Window/MaterialBrowserWidget.cpp | 126 ++++++++---------- .../Source/Window/MaterialBrowserWidget.h | 26 ++-- 2 files changed, 69 insertions(+), 83 deletions(-) diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserWidget.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserWidget.cpp index bd7e1d94ab..408ee1a478 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserWidget.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserWidget.cpp @@ -10,36 +10,32 @@ * */ -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include - #include AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT -#include -#include -#include -#include #include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include AZ_POP_DISABLE_WARNING namespace MaterialEditor @@ -99,7 +95,6 @@ namespace MaterialEditor } }); - AssetBrowserModelNotificationBus::Handler::BusConnect(); MaterialDocumentNotificationBus::Handler::BusConnect(); } @@ -108,7 +103,7 @@ namespace MaterialEditor // Maintains the tree expansion state between runs m_ui->m_assetBrowserTreeViewWidget->SaveState(); MaterialDocumentNotificationBus::Handler::BusDisconnect(); - AssetBrowserModelNotificationBus::Handler::BusDisconnect(); + AZ::TickBus::Handler::BusDisconnect(); } AzToolsFramework::AssetBrowser::FilterConstType MaterialBrowserWidget::CreateFilter() const @@ -151,72 +146,65 @@ namespace MaterialEditor for (const AssetBrowserEntry* entry : entries) { - const SourceAssetBrowserEntry* sourceEntry = azrtti_cast(entry); - if (!sourceEntry) + if (entry) { - const ProductAssetBrowserEntry* productEntry = azrtti_cast(entry); - if (productEntry) + if (AzFramework::StringFunc::Path::IsExtension(entry->GetFullPath().c_str(), MaterialExtension)) { - sourceEntry = azrtti_cast(productEntry->GetParent()); + MaterialDocumentSystemRequestBus::Broadcast(&MaterialDocumentSystemRequestBus::Events::OpenDocument, entry->GetFullPath()); } - } - - if (sourceEntry) - { - if (AzFramework::StringFunc::Path::IsExtension(sourceEntry->GetFullPath().c_str(), MaterialExtension)) - { - MaterialDocumentSystemRequestBus::Broadcast(&MaterialDocumentSystemRequestBus::Events::OpenDocument, sourceEntry->GetFullPath()); - } - else if (AzFramework::StringFunc::Path::IsExtension(sourceEntry->GetFullPath().c_str(), MaterialTypeExtension)) + else if (AzFramework::StringFunc::Path::IsExtension(entry->GetFullPath().c_str(), MaterialTypeExtension)) { //ignore MaterialTypeExtension } else { - QDesktopServices::openUrl(QUrl::fromLocalFile(sourceEntry->GetFullPath().c_str())); + QDesktopServices::openUrl(QUrl::fromLocalFile(entry->GetFullPath().c_str())); } } } } - void MaterialBrowserWidget::EntryAdded(const AssetBrowserEntry* entry) - { - if (m_pathToSelect.empty()) - { - return; - } - - const SourceAssetBrowserEntry* sourceEntry = azrtti_cast(entry); - if (!sourceEntry) - { - const ProductAssetBrowserEntry* productEntry = azrtti_cast(entry); - if (productEntry) - { - sourceEntry = azrtti_cast(productEntry->GetParent()); - } - } - - if (sourceEntry) - { - AZStd::string sourcePath = sourceEntry->GetFullPath(); - AzFramework::StringFunc::Path::Normalize(sourcePath); - if (m_pathToSelect == sourcePath) - { - m_ui->m_assetBrowserTreeViewWidget->SelectFileAtPath(m_pathToSelect); - m_pathToSelect.clear(); - } - } - } - void MaterialBrowserWidget::OnDocumentOpened(const AZ::Uuid& documentId) { AZStd::string absolutePath; MaterialDocumentRequestBus::EventResult(absolutePath, documentId, &MaterialDocumentRequestBus::Events::GetAbsolutePath); if (!absolutePath.empty()) { + // Selecting a new asset in the browser is not guaranteed to happen immediately. + // The asset browser model notifications are sent before the model is updated. + // Instead of relying on the notifications, queue the selection and process it on tick until this change occurs. m_pathToSelect = absolutePath; AzFramework::StringFunc::Path::Normalize(m_pathToSelect); - m_ui->m_assetBrowserTreeViewWidget->SelectFileAtPath(m_pathToSelect); + AZ::TickBus::Handler::BusConnect(); + } + } + + void MaterialBrowserWidget::OnTick(float deltaTime, AZ::ScriptTimePoint time) + { + AZ_UNUSED(time); + AZ_UNUSED(deltaTime); + + if (!m_pathToSelect.empty()) + { + // Attempt to select the new path + AzToolsFramework::AssetBrowser::AssetBrowserViewRequestBus::Broadcast( + &AzToolsFramework::AssetBrowser::AssetBrowserViewRequestBus::Events::SelectFileAtPath, m_pathToSelect); + + // Iterate over the selected entries to verify if the selection was made + for (const AssetBrowserEntry* entry : m_ui->m_assetBrowserTreeViewWidget->GetSelectedAssets()) + { + if (entry) + { + AZStd::string sourcePath = entry->GetFullPath(); + AzFramework::StringFunc::Path::Normalize(sourcePath); + if (m_pathToSelect == sourcePath) + { + // Once the selection is confirmed, cancel the operation and disconnect + AZ::TickBus::Handler::BusDisconnect(); + m_pathToSelect.clear(); + } + } + } } } diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserWidget.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserWidget.h index d33f568ba3..38ff894214 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserWidget.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserWidget.h @@ -13,11 +13,11 @@ #pragma once #if !defined(Q_MOC_RUN) +#include +#include #include -#include #include #include -#include AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT #include @@ -26,8 +26,6 @@ AZ_POP_DISABLE_WARNING #endif - - namespace AzToolsFramework { namespace AssetBrowser @@ -50,8 +48,8 @@ namespace MaterialEditor //! Provides a tree view of all available materials and other assets exposed by the MaterialEditor. class MaterialBrowserWidget : public QWidget - , public AzToolsFramework::AssetBrowser::AssetBrowserModelNotificationBus::Handler - , public MaterialDocumentNotificationBus::Handler + , protected AZ::TickBus::Handler + , protected MaterialDocumentNotificationBus::Handler { Q_OBJECT public: @@ -62,20 +60,20 @@ namespace MaterialEditor AzToolsFramework::AssetBrowser::FilterConstType CreateFilter() const; void OpenSelectedEntries(); + // MaterialDocumentNotificationBus::Handler implementation + void OnDocumentOpened(const AZ::Uuid& documentId) override; + + // AZ::TickBus::Handler + void OnTick(float deltaTime, AZ::ScriptTimePoint time) override; + + void OpenOptionsMenu(); + QScopedPointer m_ui; AzToolsFramework::AssetBrowser::AssetBrowserFilterModel* m_filterModel = nullptr; //! if new asset is being created with this path it will automatically be selected AZStd::string m_pathToSelect; - // AssetBrowserModelNotificationBus::Handler implementation - void EntryAdded(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) override; - - // MaterialDocumentNotificationBus::Handler implementation - void OnDocumentOpened(const AZ::Uuid& documentId) override; - - void OpenOptionsMenu(); - QByteArray m_materialBrowserState; }; } // namespace MaterialEditor From 9a0b47137a53d10d01c1faba3efa0b238b0f14ad Mon Sep 17 00:00:00 2001 From: spham Date: Mon, 19 Apr 2021 10:14:59 -0700 Subject: [PATCH 05/32] Add linux setup scripts to: 1. Install Linux AWSCLI 2. Install Linux Git, GitLFS, and GCM 3. Install Linux build libraries and tools for O3DE --- .../Platform/Linux/install-awscli.sh | 47 ++++++++ .../Linux/install-ubuntu-build-libraries.sh | 103 ++++++++++++++++++ .../Linux/install-ubuntu-build-tools.sh | 72 ++++++++++++ .../Platform/Linux/install-ubuntu-git.sh | 96 ++++++++++++++++ 4 files changed, 318 insertions(+) create mode 100644 scripts/build/build_node/Platform/Linux/install-awscli.sh create mode 100644 scripts/build/build_node/Platform/Linux/install-ubuntu-build-libraries.sh create mode 100644 scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh create mode 100644 scripts/build/build_node/Platform/Linux/install-ubuntu-git.sh diff --git a/scripts/build/build_node/Platform/Linux/install-awscli.sh b/scripts/build/build_node/Platform/Linux/install-awscli.sh new file mode 100644 index 0000000000..c9addedc82 --- /dev/null +++ b/scripts/build/build_node/Platform/Linux/install-awscli.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +# its licensors. +# +# For complete copyright and license terms please see the LICENSE at the root of this +# distribution (the "License"). All use of this software is governed by the License, +# or, if provided, by the license below or the license accompanying this file. Do not +# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + +# This script must be run as root +if [ "`whoami`" != "root" ] +then + echo "This script must be run as root (sudo)" + exit 1 +fi + +# +# Install curl if its not installed +# +curl --version >/dev/null 2>&1 +if [ $? -ne 0 ] +then + echo "Installing curl" + apt-get install curl -y +fi + +# +# Setup AWS CLI if needed +# +aws --version >/dev/null 2>&1 +if [ $? -ne 0 ] +then + echo Setting up AWS CLI + curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" + unzip awscliv2.zip + ./aws/install + rm -rf ./aws +else + AWS_CLI_VERSION=`aws --version | awk '{print $1}' | awk -F/ '{print $2}'` + echo AWS CLI \(version $AWS_CLI_VERSION\) already installed +fi + + + + diff --git a/scripts/build/build_node/Platform/Linux/install-ubuntu-build-libraries.sh b/scripts/build/build_node/Platform/Linux/install-ubuntu-build-libraries.sh new file mode 100644 index 0000000000..7b78a53802 --- /dev/null +++ b/scripts/build/build_node/Platform/Linux/install-ubuntu-build-libraries.sh @@ -0,0 +1,103 @@ +#!/bin/bash + +# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +# its licensors. +# +# For complete copyright and license terms please see the LICENSE at the root of this +# distribution (the "License"). All use of this software is governed by the License, +# or, if provided, by the license below or the license accompanying this file. Do not +# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + +# This script must be run as root +if [ "`whoami`" != "root" ] +then + echo "This script must be run as root (sudo)" + exit 1 +fi + +# +# Make sure we are installing on a supported ubuntu distro +# +lsb_release -c >/dev/null 2>&1 +if [ $? -ne 0 ] +then + echo This script is only supported on Ubuntu Distros + exit 1 +fi + +UBUNTU_DISTRO="`lsb_release -c | awk '{print $2}'`" +if [ "$UBUNTU_DISTRO" == "bionic" ] +then + echo "Setup for Ubuntu 18.04 LTS ($UBUNTU_DISTRO)" +elif [ "$UBUNTU_DISTRO" == "focal" ] +then + echo "Setup for Ubuntu 20.04 LTS ($UBUNTU_DISTRO)" +else + echo "Unsupported version of Ubuntu $UBUNTU_DISTRO" + exit 1 +fi + +# +# Install curl if its not installed +# +curl --version >/dev/null 2>&1 +if [ $? -ne 0 ] +then + echo "Installing curl" + apt-get install curl -y +fi + + +# +# If the linux distro is 20.04 (focal), we need libffi.so.6, which is not part of the focal distro. We +# will install it from the bionic distro manually into focal. This is needed since Ubuntu 20.04 supports +# python 3.8 out of the box, but we are using 3.7 +# +LIBFFI6_COUNT=`apt list --installed 2>/dev/null | grep libffi6 | wc -l` +if [ "$UBUNTU_DISTRO" == "focal" ] && [ $LIBFFI6_COUNT -eq 0 ] +then + echo "Installing libffi for Ubuntu 20.04" + + pushd /tmp >/dev/null + + LIBFFI_PACKAGE_NAME=libffi6_3.2.1-8_amd64.deb + LIBFFI_PACKAGE_URL=http://mirrors.kernel.org/ubuntu/pool/main/libf/libffi/ + + curl --location $LIBFFI_PACKAGE_URL/$LIBFFI_PACKAGE_NAME -o $LIBFFI_PACKAGE_NAME + if [ $? -ne 0 ] + then + echo Unable to download $LIBFFI_PACKAGE_URL/$LIBFFI_PACKAGE_NAME + popd + exit 1 + fi + + apt install ./$LIBFFI_PACKAGE_NAME -y + if [ $? -ne 0 ] + then + echo Unable to install $LIBFFI_PACKAGE_NAME + rm -f ./$LIBFFI_PACKAGE_NAME + popd + exit 1 + fi + + rm -f ./$LIBFFI_PACKAGE_NAME + popd + echo "libffi.so.6 installed" +fi + +# Install the required build packages +apt-get install clang-6.0 -y # For the compiler and its dependencies +apt-get install libglu1-mesa-dev -y # For Qt (GL dependency) + +# The following packages resolves a runtime error with Qt Plugins +apt-get install libxcb-xinerama0 -y # For Qt plugins at runtime +apt-get install libxcb-xinput0 -y # For Qt plugins at runtime + +apt-get install libcurl4-openssl-dev -y # For HttpRequestor +apt-get install libsdl2-dev -y # For WWise + +apt-get install libz-dev -y +apt-get install mesa-common-dev -y + +echo Build Libraries Setup Complete diff --git a/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh b/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh new file mode 100644 index 0000000000..eb9229d90b --- /dev/null +++ b/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +# its licensors. +# +# For complete copyright and license terms please see the LICENSE at the root of this +# distribution (the "License"). All use of this software is governed by the License, +# or, if provided, by the license below or the license accompanying this file. Do not +# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + +# This script must be run as root +if [ "`whoami`" != "root" ] +then + echo "This script must be run as root (sudo)" + exit 1 +fi + +# +# Make sure we are installing on a supported ubuntu distro +# +lsb_release -c >/dev/null 2>&1 +if [ $? -ne 0 ] +then + echo This script is only supported on Ubuntu Distros + exit 1 +fi + +UBUNTU_DISTRO="`lsb_release -c | awk '{print $2}'`" +if [ "$UBUNTU_DISTRO" == "bionic" ] +then + echo "Setup for Ubuntu 18.04 LTS ($UBUNTU_DISTRO)" +elif [ "$UBUNTU_DISTRO" == "focal" ] +then + echo "Setup for Ubuntu 20.04 LTS ($UBUNTU_DISTRO)" +else + echo "Unsupported version of Ubuntu $UBUNTU_DISTRO" + exit 1 +fi + +# +# Always install the latest version of cmake (from kitware) +# +echo Installing the latest version of CMake + +# Remove any pre-existing version of cmake +apt purge --auto-remove cmake -y +wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null +CMAKE_DEB_REPO="'deb https://apt.kitware.com/ubuntu/ $UBUNTU_DISTRO main'" + +# Add the appropriate kitware repository to apt +if [ "$UBUNTU_DISTRO" == "bionic" ] +then + apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' +elif [ "$UBUNTU_DISTRO" == "focal" ] +then + apt-add-repository 'deb https://apt.kitware.com/ubuntu/ focal main' +fi +apt-get update + +# Install cmake +apt-get install cmake -y + + +# +# Make sure that Ninja is installed +# +echo Installing Ninja +apt-get install ninja-build -y + + +echo Build Tools Setup Complete diff --git a/scripts/build/build_node/Platform/Linux/install-ubuntu-git.sh b/scripts/build/build_node/Platform/Linux/install-ubuntu-git.sh new file mode 100644 index 0000000000..a1c2923c13 --- /dev/null +++ b/scripts/build/build_node/Platform/Linux/install-ubuntu-git.sh @@ -0,0 +1,96 @@ +#!/bin/bash + +# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +# its licensors. +# +# For complete copyright and license terms please see the LICENSE at the root of this +# distribution (the "License"). All use of this software is governed by the License, +# or, if provided, by the license below or the license accompanying this file. Do not +# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + +# This script must be run as root +if [ "`whoami`" != "root" ] +then + echo "This script must be run as root (sudo)" + exit 1 +fi + +# +# Make sure we are installing on a supported ubuntu distro +# +lsb_release -c >/dev/null 2>&1 +if [ $? -ne 0 ] +then + echo This script is only supported on Ubuntu Distros + exit 1 +fi + +UBUNTU_DISTRO="`lsb_release -c | awk '{print $2}'`" +if [ "$UBUNTU_DISTRO" == "bionic" ] +then + echo "Setup for Ubuntu 18.04 LTS ($UBUNTU_DISTRO)" +elif [ "$UBUNTU_DISTRO" == "focal" ] +then + echo "Setup for Ubuntu 20.04 LTS ($UBUNTU_DISTRO)" +else + echo "Unsupported version of Ubuntu $UBUNTU_DISTRO" + exit 1 +fi + +# +# Setup and get the latest from git if necessary +# +git --version > /dev/null 2>&1 +if [ $? -ne 0 ] +then + echo Setting up latest version of GIT + add-apt-repository ppa:git-core/ppa -y + apt-get update + apt-get install git -y +else + GIT_VERSION=`git --version | awk '{print $3}'` + echo Git $GIT_VERSION already Installed. Skipping Git installation +fi + +# +# Setup Git-LFS if needed +# +GIT_LFS_PACKAGE_COUNT=`apt list --installed 2>/dev/null | grep git-lfs/ | wc -l` +if [ $GIT_LFS_PACKAGE_COUNT -eq 0 ] +then + echo Setting up Git-LFS + pushd /tmp + wget https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh -o script.deb.sh + rm script.deb.sh + mv script.deb.sh.1 script.deb.sh + chmod +x script.deb.sh + ./script.deb.sh + sudo apt-get install git-lfs -y + popd +else + echo Git LFS already installed. Skipping Git-LFS installation +fi + +# Setup GCM if needed +git-credential-manager-core --version > /dev/null 2>&1 +if [ $? -ne 0 ] +then + # Download and setup Git Credential Manager + GCM_PACKAGE_NAME=gcmcore-linux_amd64.2.0.394.50751.deb + GCM_PACKAGE_URL=https://github.com/microsoft/Git-Credential-Manager-Core/releases/download/v2.0.394-beta + + echo Installing Git Credential Manager \($GCM_PACKAGE_NAME\) + + pushd /tmp > /dev/null + curl --location $GCM_PACKAGE_URL/$GCM_PACKAGE_NAME -o $GCM_PACKAGE_NAME + dpkg -i $GCM_PACKAGE_NAME + popd +else + GCM_VERSION=`git-credential-manager-core --version` + echo Git Credential Manager \(GCM\) version $GCM_VERSION already installed. Skipping GCM installation +fi + +# Setup pass (password manager) for git-credential-manager +apt-get install pass -y + From c9153b035350e68a1a15f6918f64d62c770e1d24 Mon Sep 17 00:00:00 2001 From: qingtao Date: Mon, 19 Apr 2021 11:47:57 -0700 Subject: [PATCH 06/32] ATOM-15272 Running game with Actor spams asserts in the log resulting in low framerate The condition was setup wrongly when introducing DynamicInputAssembly. --- Gems/Atom/RPI/Code/Source/RPI.Public/Buffer/Buffer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Buffer/Buffer.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Buffer/Buffer.cpp index 81fd9e751b..afcf4670f3 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Buffer/Buffer.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Buffer/Buffer.cpp @@ -74,7 +74,8 @@ namespace AZ const RHI::BufferView* Buffer::GetBufferView() const { - if(RHI::CheckBitsAny(m_rhiBuffer->GetDescriptor().m_bindFlags, RHI::BufferBindFlags::InputAssembly | RHI::BufferBindFlags::DynamicInputAssembly)) + if (m_rhiBuffer->GetDescriptor().m_bindFlags == RHI::BufferBindFlags::InputAssembly || + m_rhiBuffer->GetDescriptor().m_bindFlags == RHI::BufferBindFlags::DynamicInputAssembly) { AZ_Assert(false, "Input assembly buffer doesn't need a regular buffer view, it requires a stream or index buffer view."); From 4fb407e1309da2d661a9ed71cb72ada58ed23fc7 Mon Sep 17 00:00:00 2001 From: Chris Galvan Date: Mon, 19 Apr 2021 15:39:50 -0500 Subject: [PATCH 07/32] [LYN-3070] Removed legacy Material Editor. --- Code/Sandbox/Editor/CryEdit.cpp | 9 - Code/Sandbox/Editor/CryEdit.h | 2 - Code/Sandbox/Editor/MainWindow.cpp | 2 - Code/Sandbox/Editor/MatEditMainDlg.cpp | 110 - Code/Sandbox/Editor/MatEditMainDlg.h | 48 - .../Editor/Material/MaterialDialog.cpp | 2290 ----------------- Code/Sandbox/Editor/Material/MaterialDialog.h | 176 -- .../Editor/Material/MaterialDialog.qrc | 35 - .../Material/images/materialdialog_add.png | 3 - .../images/materialdialog_add_active.png | 3 - .../images/materialdialog_add_disabled.png | 3 - .../images/materialdialog_add_normal.png | 3 - .../images/materialdialog_assignselection.png | 3 - .../materialdialog_assignselection_active.png | 3 - ...aterialdialog_assignselection_disabled.png | 3 - .../materialdialog_assignselection_normal.png | 3 - .../Material/images/materialdialog_copy.png | 3 - .../images/materialdialog_copy_active.png | 3 - .../images/materialdialog_copy_disabled.png | 3 - .../images/materialdialog_copy_normal.png | 3 - .../materialdialog_getfromselection.png | 3 - ...materialdialog_getfromselection_active.png | 3 - ...terialdialog_getfromselection_disabled.png | 3 - ...materialdialog_getfromselection_normal.png | 3 - .../Material/images/materialdialog_paste.png | 3 - .../images/materialdialog_paste_active.png | 3 - .../images/materialdialog_paste_disabled.png | 3 - .../images/materialdialog_paste_normal.png | 3 - .../Material/images/materialdialog_pick.png | 3 - .../images/materialdialog_pick_active.png | 3 - .../images/materialdialog_pick_disabled.png | 3 - .../images/materialdialog_pick_normal.png | 3 - .../images/materialdialog_preview.png | 3 - .../images/materialdialog_preview_active.png | 3 - .../materialdialog_preview_disabled.png | 3 - .../images/materialdialog_preview_normal.png | 3 - .../Material/images/materialdialog_remove.png | 3 - .../images/materialdialog_remove_active.png | 3 - .../images/materialdialog_remove_disabled.png | 3 - .../images/materialdialog_remove_normal.png | 3 - .../Material/images/materialdialog_reset.png | 3 - .../images/materialdialog_reset_active.png | 3 - .../images/materialdialog_reset_disabled.png | 3 - .../images/materialdialog_reset_normal.png | 3 - .../materialdialog_reset_viewport_active.png | 3 - ...materialdialog_reset_viewport_disabled.png | 3 - .../materialdialog_reset_viewport_normal.png | 3 - .../Material/images/materialdialog_save.png | 3 - .../images/materialdialog_save_active.png | 3 - .../images/materialdialog_save_disabled.png | 3 - .../images/materialdialog_save_normal.png | 3 - Code/Sandbox/Editor/editor_lib_files.cmake | 4 - 52 files changed, 2805 deletions(-) delete mode 100644 Code/Sandbox/Editor/MatEditMainDlg.cpp delete mode 100644 Code/Sandbox/Editor/MatEditMainDlg.h delete mode 100644 Code/Sandbox/Editor/Material/MaterialDialog.cpp delete mode 100644 Code/Sandbox/Editor/Material/MaterialDialog.h delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_add.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_add_active.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_add_disabled.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_add_normal.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_assignselection.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_assignselection_active.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_assignselection_disabled.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_assignselection_normal.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_copy.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_copy_active.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_copy_disabled.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_copy_normal.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_getfromselection.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_getfromselection_active.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_getfromselection_disabled.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_getfromselection_normal.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_paste.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_paste_active.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_paste_disabled.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_paste_normal.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_pick.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_pick_active.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_pick_disabled.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_pick_normal.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_preview.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_preview_active.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_preview_disabled.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_preview_normal.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_remove.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_remove_active.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_remove_disabled.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_remove_normal.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_reset.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_reset_active.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_reset_disabled.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_reset_normal.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_reset_viewport_active.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_reset_viewport_disabled.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_reset_viewport_normal.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_save.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_save_active.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_save_disabled.png delete mode 100644 Code/Sandbox/Editor/Material/images/materialdialog_save_normal.png diff --git a/Code/Sandbox/Editor/CryEdit.cpp b/Code/Sandbox/Editor/CryEdit.cpp index dff5b2267c..e4f06a1bc3 100644 --- a/Code/Sandbox/Editor/CryEdit.cpp +++ b/Code/Sandbox/Editor/CryEdit.cpp @@ -126,7 +126,6 @@ AZ_POP_DISABLE_WARNING #include "EditorPreferencesDialog.h" #include "GraphicsSettingsDialog.h" #include "FeedbackDialog/FeedbackDialog.h" -#include "MatEditMainDlg.h" #include "AnimationContext.h" #include "GotoPositionDlg.h" @@ -1898,14 +1897,6 @@ BOOL CCryEditApp::InitInstance() CWipFeatureManager::Init(); #endif - if (GetIEditor()->IsInMatEditMode()) - { - m_pMatEditDlg = new CMatEditMainDlg(QStringLiteral("Material Editor")); - m_pEditor->InitFinished(); - m_pMatEditDlg->show(); - return true; - } - if (!m_bConsoleMode && !m_bPreviewMode) { GetIEditor()->UpdateViews(); diff --git a/Code/Sandbox/Editor/CryEdit.h b/Code/Sandbox/Editor/CryEdit.h index 7480b34e5a..6a17f9a8bf 100644 --- a/Code/Sandbox/Editor/CryEdit.h +++ b/Code/Sandbox/Editor/CryEdit.h @@ -28,7 +28,6 @@ class CCryDocManager; class CQuickAccessBar; -class CMatEditMainDlg; class CCryEditDoc; class CEditCommandLineInfo; class CMainFrame; @@ -367,7 +366,6 @@ private: //! Autotest mode: Special mode meant for automated testing, things like blocking dialogs or error report windows won't appear bool m_bAutotestMode = false; - CMatEditMainDlg* m_pMatEditDlg = nullptr; CConsoleDialog* m_pConsoleDialog = nullptr; AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING diff --git a/Code/Sandbox/Editor/MainWindow.cpp b/Code/Sandbox/Editor/MainWindow.cpp index ab5e0cf559..b926c00fc8 100644 --- a/Code/Sandbox/Editor/MainWindow.cpp +++ b/Code/Sandbox/Editor/MainWindow.cpp @@ -92,7 +92,6 @@ AZ_POP_DISABLE_WARNING #include "TrackView/TrackViewDialog.h" #include "ErrorReportDialog.h" -#include "Material/MaterialDialog.h" #include "LensFlareEditor/LensFlareEditor.h" #include "TimeOfDayDialog.h" @@ -1974,7 +1973,6 @@ void MainWindow::RegisterStdViewClasses() if (!AZ::Interface::Get()) { - CMaterialDialog::RegisterViewClass(); CLensFlareEditor::RegisterViewClass(); CTimeOfDayDialog::RegisterViewClass(); } diff --git a/Code/Sandbox/Editor/MatEditMainDlg.cpp b/Code/Sandbox/Editor/MatEditMainDlg.cpp deleted file mode 100644 index 9a96ad15d0..0000000000 --- a/Code/Sandbox/Editor/MatEditMainDlg.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : implementation file - -#include "EditorDefs.h" - -#include "MatEditMainDlg.h" - -// Qt -#include -#include - -// Editor -#include "Material/MaterialDialog.h" -#include "Material/MaterialManager.h" -#include "MaterialSender.h" - - -CMatEditMainDlg::CMatEditMainDlg(const QString& title, QWidget* pParent /*=NULL*/) - : QWidget(pParent) -{ - resize(1000, 600); - - setWindowTitle(title); - - QTimer* t = new QTimer(this); - connect(t, &QTimer::timeout, this, &CMatEditMainDlg::OnKickIdle); - t->start(250); - - m_materialDialog = new CMaterialDialog(); // must be created after the timer - auto layout = new QVBoxLayout(this); - layout->addWidget(m_materialDialog); - -#ifdef Q_OS_WIN - if (auto aed = QAbstractEventDispatcher::instance()) - { - aed->installNativeEventFilter(this); - } -#endif -} - -CMatEditMainDlg::~CMatEditMainDlg() -{ -#ifdef Q_OS_WIN - if (auto aed = QAbstractEventDispatcher::instance()) - { - aed->removeNativeEventFilter(this); - } -#endif -} - -///////////////////////////////////////////////////////////////////////////// -// CMatEditMainDlg message handlers - -void CMatEditMainDlg::showEvent(QShowEvent*) -{ - if (QWindow *win = window()->windowHandle()) - { - // Make sure our top-level window decorator wrapper set this exact title - // 3ds Max Exporter will use ::FindWindow with this name - win->setTitle("Material Editor"); - } -} - -bool CMatEditMainDlg::nativeEventFilter(const QByteArray&, void* message, long*) -{ -#ifdef Q_OS_WIN - // WM_MATEDITSEND is Windows only. Used by 3ds Max exporter. - MSG* msg = static_cast(message); - if (msg->message == WM_MATEDITSEND) - { - OnMatEditSend(msg->wParam); - return true; - } -#endif - - return false; -} - -void CMatEditMainDlg::closeEvent(QCloseEvent* event) -{ - QWidget::closeEvent(event); - qApp->quit(); -} - -void CMatEditMainDlg::OnKickIdle() -{ - GetIEditor()->Notify(eNotify_OnIdleUpdate); -} - -void CMatEditMainDlg::OnMatEditSend(int param) -{ - if (param != eMSM_Init) - { - GetIEditor()->GetMaterialManager()->SyncMaterialEditor(); - } -} - -#include diff --git a/Code/Sandbox/Editor/MatEditMainDlg.h b/Code/Sandbox/Editor/MatEditMainDlg.h deleted file mode 100644 index b329933c1f..0000000000 --- a/Code/Sandbox/Editor/MatEditMainDlg.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#ifndef CRYINCLUDE_EDITOR_MATEDITMAINDLG_H -#define CRYINCLUDE_EDITOR_MATEDITMAINDLG_H - -#pragma once - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#endif - -class CMaterialDialog; - -class CMatEditMainDlg - : public QWidget - , public QAbstractNativeEventFilter -{ - Q_OBJECT -public: - explicit CMatEditMainDlg(const QString& title = QString(), QWidget* parent = nullptr); - ~CMatEditMainDlg(); - - bool nativeEventFilter(const QByteArray& eventType, void* message, long* result) override; - -protected: - void closeEvent(QCloseEvent* event) override; - void showEvent(QShowEvent* event) override; - -private: - void OnKickIdle(); - void OnMatEditSend(int param); - CMaterialDialog* m_materialDialog = nullptr; -}; - -#endif // CRYINCLUDE_EDITOR_MATEDITMAINDLG_H diff --git a/Code/Sandbox/Editor/Material/MaterialDialog.cpp b/Code/Sandbox/Editor/Material/MaterialDialog.cpp deleted file mode 100644 index 5d5f14ecd2..0000000000 --- a/Code/Sandbox/Editor/Material/MaterialDialog.cpp +++ /dev/null @@ -1,2290 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "EditorDefs.h" - -#include "MaterialDialog.h" - -// Qt -#include -#include -#include -#include -#include -#include -#include -#include - -// AzToolsFramework -#include // for AzToolsFramework::ViewPaneOptions - -// Editor -#include "IEditor.h" -#include "EditTool.h" -#include "MaterialImageListCtrl.h" -#include "MaterialManager.h" -#include "MaterialHelpers.h" -#include "ShaderEnum.h" -#include "MatEditPreviewDlg.h" -#include "Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.h" -#include "Include/IObjectManager.h" -#include "Objects/BaseObject.h" -#include "Settings.h" -#include "Objects/SelectionGroup.h" -#include "LyViewPaneNames.h" - - -const QString EDITOR_OBJECTS_PATH("Objects\\Editor\\"); - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::RegisterViewClass() -{ - AzToolsFramework::ViewPaneOptions opts; - opts.shortcut = QKeySequence(Qt::Key_M); - opts.canHaveMultipleInstances = true; - - AzToolsFramework::RegisterViewPane(MATERIAL_EDITOR_NAME, LyViewPane::CategoryTools, opts); - - GetIEditor()->GetSettingsManager()->AddToolVersion(MATERIAL_EDITOR_NAME, MATERIAL_EDITOR_VER); -} - -const GUID& CMaterialDialog::GetClassID() -{ - static const GUID guid = - { - 0xc7891863, 0x1665, 0x45ac, { 0xae, 0x51, 0x48, 0x66, 0x71, 0xbc, 0x8b, 0x12 } - }; - return guid; -} - -inline float RoundDegree(float val) -{ - return (float)((int)(val * 100 + 0.5f)) * 0.01f; -} - -////////////////////////////////////////////////////////////////////////// -// Material structures. -////////////////////////////////////////////////////////////////////////// - -#ifndef _countof -#define _countof(array) (sizeof(array) / sizeof(array[0])) -#endif - -struct STextureVars -{ - CSmartVariable is_tile[2]; - - CSmartVariableEnum etcgentype; - CSmartVariableEnum etcmrotatetype; - CSmartVariableEnum etcmumovetype; - CSmartVariableEnum etcmvmovetype; - CSmartVariableEnum etextype; - CSmartVariableEnum filter; - - CSmartVariable is_tcgprojected; - CSmartVariable tiling[3]; - CSmartVariable rotate[3]; - CSmartVariable offset[3]; - CSmartVariable tcmuoscrate; - CSmartVariable tcmvoscrate; - CSmartVariable tcmuoscamplitude; - CSmartVariable tcmvoscamplitude; - CSmartVariable tcmuoscphase; - CSmartVariable tcmvoscphase; - CSmartVariable tcmrotoscrate; - CSmartVariable tcmrotoscamplitude; - CSmartVariable tcmrotoscphase; - CSmartVariable tcmrotosccenter[2]; - - CSmartVariableArray tableTiling; - CSmartVariableArray tableOscillator; - CSmartVariableArray tableRotator; - - void Reset() - { - SEfTexModificator defaultTextureCoordinateModifier; - SEfResTexture defaultTextureResource; - for (int i = 0; i < 2; i++) - { - *is_tile[i] = defaultTextureResource.GetTiling(i); - *tcmrotosccenter[i] = defaultTextureCoordinateModifier.m_RotOscCenter[i]; - } - - for (int i = 0; i < 3; i++) - { - *rotate[i] = RoundDegree(Word2Degr(defaultTextureCoordinateModifier.m_Rot[i])); - *tiling[i] = defaultTextureCoordinateModifier.m_Tiling[i]; - *offset[i] = defaultTextureCoordinateModifier.m_Offs[i]; - } - - etcgentype = defaultTextureCoordinateModifier.m_eTGType; - etcmrotatetype = defaultTextureCoordinateModifier.m_eRotType; - etcmumovetype = defaultTextureCoordinateModifier.m_eMoveType[0]; - etcmvmovetype = defaultTextureCoordinateModifier.m_eMoveType[1]; - etextype = defaultTextureResource.m_Sampler.m_eTexType; - filter = defaultTextureResource.m_Filter; - is_tcgprojected = defaultTextureCoordinateModifier.m_bTexGenProjected; - - tcmuoscrate = defaultTextureCoordinateModifier.m_OscRate[0]; - tcmvoscrate = defaultTextureCoordinateModifier.m_OscRate[1]; - - tcmuoscamplitude = defaultTextureCoordinateModifier.m_OscAmplitude[0]; - tcmvoscamplitude = defaultTextureCoordinateModifier.m_OscAmplitude[1]; - - tcmuoscphase = defaultTextureCoordinateModifier.m_OscPhase[0]; - tcmvoscphase = defaultTextureCoordinateModifier.m_OscPhase[1]; - - tcmrotoscrate = RoundDegree(Word2Degr(defaultTextureCoordinateModifier.m_RotOscRate[2])); - tcmrotoscamplitude = RoundDegree(Word2Degr(defaultTextureCoordinateModifier.m_RotOscAmplitude[2])); - tcmrotoscphase = RoundDegree(Word2Degr(defaultTextureCoordinateModifier.m_RotOscPhase[2])); - } -}; - -struct SMaterialLayerVars -{ - CSmartVariable bNoDraw; // disable layer rendering (useful in some cases) - CSmartVariable bFadeOut; // fade out layer rendering and parent rendering - CSmartVariableEnum shader; // shader layer name -}; - -struct SVertexWaveFormUI -{ - CSmartVariableArray table; - CSmartVariableEnum waveFormType; - CSmartVariable level; - CSmartVariable amplitude; - CSmartVariable phase; - CSmartVariable frequency; -}; - -////////////////////////////////////////////////////////////////////////// -struct SVertexModUI -{ - CSmartVariableEnum type; - CSmartVariable fDividerX; - CSmartVariable fDividerY; - CSmartVariable fDividerZ; - CSmartVariable fDividerW; - CSmartVariable vNoiseScale; - SVertexWaveFormUI wave; -}; - -/** User Interface definition of material. -*/ -class CMaterialUI -{ -public: - CSmartVariableEnum shader; - CSmartVariable bNoShadow; - CSmartVariable bAdditive; - CSmartVariable bWire; - CSmartVariable b2Sided; - CSmartVariable opacity; - CSmartVariable alphaTest; - CSmartVariable emissiveIntensity; - CSmartVariable voxelCoverage; - CSmartVariable heatAmount; - CSmartVariable bScatter; - CSmartVariable bHideAfterBreaking; - CSmartVariable bFogVolumeShadingQualityHigh; - CSmartVariable bBlendTerrainColor; - //CSmartVariable bTranslucenseLayer; - CSmartVariableEnum surfaceType; - - CSmartVariable allowLayerActivation; - - ////////////////////////////////////////////////////////////////////////// - // Material Value Propagation for dynamic material switches, as for instance - // used by breakable glass - ////////////////////////////////////////////////////////////////////////// - CSmartVariableEnum matPropagate; - CSmartVariable bPropagateMaterialSettings; - CSmartVariable bPropagateOpactity; - CSmartVariable bPropagateLighting; - CSmartVariable bPropagateAdvanced; - CSmartVariable bPropagateTexture; - CSmartVariable bPropagateVertexDef; - CSmartVariable bPropagateShaderParams; - CSmartVariable bPropagateLayerPresets; - CSmartVariable bPropagateShaderGenParams; - - ////////////////////////////////////////////////////////////////////////// - // Lighting - ////////////////////////////////////////////////////////////////////////// - CSmartVariable diffuse; // Diffuse color 0..1 - CSmartVariable specular; // Specular color 0..1 - CSmartVariable smoothness; // Specular shininess. - CSmartVariable emissiveCol; // Emissive color 0..1 - - ////////////////////////////////////////////////////////////////////////// - // Textures. - ////////////////////////////////////////////////////////////////////////// - CSmartVariableArray textureVars[EFTT_MAX]; - CSmartVariableArray advancedTextureGroup[EFTT_MAX]; - STextureVars textures[EFTT_MAX]; - - ////////////////////////////////////////////////////////////////////////// - // Material layers settings - ////////////////////////////////////////////////////////////////////////// - - // 8 max for now. change this later - SMaterialLayerVars materialLayers[MTL_LAYER_MAX_SLOTS]; - - ////////////////////////////////////////////////////////////////////////// - - SVertexModUI vertexMod; - - CSmartVariableArray tableShader; - CSmartVariableArray tableOpacity; - CSmartVariableArray tableLighting; - CSmartVariableArray tableTexture; - CSmartVariableArray tableAdvanced; - CSmartVariableArray tableVertexMod; - CSmartVariableArray tableEffects; - - CSmartVariableArray tableShaderParams; - CSmartVariableArray tableShaderGenParams; - - CVarEnumList* enumTexType; - CVarEnumList* enumTexGenType; - CVarEnumList* enumTexModRotateType; - CVarEnumList* enumTexModUMoveType; - CVarEnumList* enumTexModVMoveType; - CVarEnumList* enumTexFilterType; - - CVarEnumList* enumVertexMod; - CVarEnumList* enumWaveType; - - ////////////////////////////////////////////////////////////////////////// - int texUsageMask; - - CVarBlockPtr m_vars; - - typedef std::map TVarChangeNotifications; - TVarChangeNotifications m_varChangeNotifications; - - ////////////////////////////////////////////////////////////////////////// - void SetFromMaterial(CMaterial* mtl); - void SetToMaterial(CMaterial* mtl, int propagationFlags = MTL_PROPAGATE_ALL); - void SetTextureNames(CMaterial* mtl); - - void SetShaderResources(const SInputShaderResources& srTextures, bool bSetTextures = true); - void GetShaderResources(SInputShaderResources& sr, int propagationFlags); - - void SetVertexDeform(const SInputShaderResources& sr); - void GetVertexDeform(SInputShaderResources& sr, int propagationFlags); - - void PropagateFromLinkedMaterial(CMaterial* mtl); - void PropagateToLinkedMaterial(CMaterial* mtl, CVarBlockPtr pShaderParamsBlock); - void NotifyObjectsAboutMaterialChange(IVariable* var); - - - ////////////////////////////////////////////////////////////////////////// - CMaterialUI() - { - } - - ~CMaterialUI() - { - } - - ////////////////////////////////////////////////////////////////////////// - CVarBlock* CreateVars() - { - m_vars = new CVarBlock; - - ////////////////////////////////////////////////////////////////////////// - // Init enums. - ////////////////////////////////////////////////////////////////////////// - enumTexType = new CVarEnumList(); - enumTexType->AddItem("2D", eTT_2D); - enumTexType->AddItem("Cube-Map", eTT_Cube); - enumTexType->AddItem("Nearest Cube-Map probe for alpha blended", eTT_NearestCube); - enumTexType->AddItem("Dynamic 2D-Map", eTT_Dyn2D); - enumTexType->AddItem("From User Params", eTT_User); - - enumTexGenType = new CVarEnumList(); - enumTexGenType->AddItem("Stream", ETG_Stream); - enumTexGenType->AddItem("World", ETG_World); - enumTexGenType->AddItem("Camera", ETG_Camera); - - enumTexModRotateType = new CVarEnumList(); - enumTexModRotateType->AddItem("No Change", ETMR_NoChange); - enumTexModRotateType->AddItem("Fixed Rotation", ETMR_Fixed); - enumTexModRotateType->AddItem("Constant Rotation", ETMR_Constant); - enumTexModRotateType->AddItem("Oscillated Rotation", ETMR_Oscillated); - - enumTexModUMoveType = new CVarEnumList(); - enumTexModUMoveType->AddItem("No Change", ETMM_NoChange); - enumTexModUMoveType->AddItem("Fixed Moving", ETMM_Fixed); - enumTexModUMoveType->AddItem("Constant Moving", ETMM_Constant); - enumTexModUMoveType->AddItem("Jitter Moving", ETMM_Jitter); - enumTexModUMoveType->AddItem("Pan Moving", ETMM_Pan); - enumTexModUMoveType->AddItem("Stretch Moving", ETMM_Stretch); - enumTexModUMoveType->AddItem("Stretch-Repeat Moving", ETMM_StretchRepeat); - - enumTexModVMoveType = new CVarEnumList(); - enumTexModVMoveType->AddItem("No Change", ETMM_NoChange); - enumTexModVMoveType->AddItem("Fixed Moving", ETMM_Fixed); - enumTexModVMoveType->AddItem("Constant Moving", ETMM_Constant); - enumTexModVMoveType->AddItem("Jitter Moving", ETMM_Jitter); - enumTexModVMoveType->AddItem("Pan Moving", ETMM_Pan); - enumTexModVMoveType->AddItem("Stretch Moving", ETMM_Stretch); - enumTexModVMoveType->AddItem("Stretch-Repeat Moving", ETMM_StretchRepeat); - - enumTexFilterType = new CVarEnumList(); - enumTexFilterType->AddItem("Default", FILTER_NONE); - enumTexFilterType->AddItem("Point", FILTER_POINT); - enumTexFilterType->AddItem("Linear", FILTER_LINEAR); - enumTexFilterType->AddItem("Bilinear", FILTER_BILINEAR); - enumTexFilterType->AddItem("Trilinear", FILTER_TRILINEAR); - enumTexFilterType->AddItem("Anisotropic 2x", FILTER_ANISO2X); - enumTexFilterType->AddItem("Anisotropic 4x", FILTER_ANISO4X); - enumTexFilterType->AddItem("Anisotropic 8x", FILTER_ANISO8X); - enumTexFilterType->AddItem("Anisotropic 16x", FILTER_ANISO16X); - - ////////////////////////////////////////////////////////////////////////// - // Vertex Mods. - ////////////////////////////////////////////////////////////////////////// - enumVertexMod = new CVarEnumList(); - enumVertexMod->AddItem("None", eDT_Unknown); - enumVertexMod->AddItem("Sin Wave", eDT_SinWave); - enumVertexMod->AddItem("Sin Wave using vertex color", eDT_SinWaveUsingVtxColor); - enumVertexMod->AddItem("Bulge", eDT_Bulge); - enumVertexMod->AddItem("Squeeze", eDT_Squeeze); - enumVertexMod->AddItem("FixedOffset", eDT_FixedOffset); - - ////////////////////////////////////////////////////////////////////////// - - enumWaveType = new CVarEnumList(); - enumWaveType->AddItem("Sin", eWF_Sin); - - ////////////////////////////////////////////////////////////////////////// - // Fill shaders enum. - ////////////////////////////////////////////////////////////////////////// - CVarEnumList* enumShaders = new CVarEnumList(); - { - CShaderEnum* pShaderEnum = GetIEditor()->GetShaderEnum(); - pShaderEnum->EnumShaders(); - for (int i = 0; i < pShaderEnum->GetShaderCount(); i++) - { - QString shaderName = pShaderEnum->GetShader(i); - if (shaderName.contains("_Overlay", Qt::CaseInsensitive)) - { - continue; - } - enumShaders->AddItem(shaderName, shaderName); - } - } - - ////////////////////////////////////////////////////////////////////////// - // Fill surface types. - ////////////////////////////////////////////////////////////////////////// - CVarEnumList* enumSurfaceTypes = new CVarEnumList(); - { - QStringList types; - types.push_back(""); // Push empty surface type. - ISurfaceTypeEnumerator* pSurfaceTypeEnum = gEnv->p3DEngine->GetMaterialManager()->GetSurfaceTypeManager()->GetEnumerator(); - if (pSurfaceTypeEnum) - { - for (ISurfaceType* pSurfaceType = pSurfaceTypeEnum->GetFirst(); pSurfaceType; pSurfaceType = pSurfaceTypeEnum->GetNext()) - { - types.push_back(pSurfaceType->GetName()); - } - std::sort(types.begin(), types.end()); - for (int i = 0; i < types.size(); i++) - { - QString name = types[i]; - if (name.left(4) == "mat_") - { - name.remove(0, 4); - } - enumSurfaceTypes->AddItem(name, types[i]); - } - } - } - - ////////////////////////////////////////////////////////////////////////// - // Init tables. - ////////////////////////////////////////////////////////////////////////// - AddVariable(m_vars, tableShader, "Material Settings", ""); - AddVariable(m_vars, tableOpacity, "Opacity Settings", ""); - AddVariable(m_vars, tableLighting, "Lighting Settings", ""); - AddVariable(m_vars, tableAdvanced, "Advanced", ""); - AddVariable(m_vars, tableTexture, "Texture Maps", ""); - AddVariable(m_vars, tableShaderParams, "Shader Params", ""); - AddVariable(m_vars, tableShaderGenParams, "Shader Generation Params", ""); - AddVariable(m_vars, tableVertexMod, "Vertex Deformation", ""); - - tableTexture->SetFlags(tableTexture->GetFlags() | IVariable::UI_ROLLUP2); - tableVertexMod->SetFlags(tableVertexMod->GetFlags() | IVariable::UI_ROLLUP2 | IVariable::UI_COLLAPSED); - tableAdvanced->SetFlags(tableAdvanced->GetFlags() | IVariable::UI_COLLAPSED); - tableShaderGenParams->SetFlags(tableShaderGenParams->GetFlags() | IVariable::UI_ROLLUP2 | IVariable::UI_COLLAPSED); - tableShaderParams->SetFlags(tableShaderParams->GetFlags() | IVariable::UI_ROLLUP2); - - - ////////////////////////////////////////////////////////////////////////// - // Shader. - ////////////////////////////////////////////////////////////////////////// - AddVariable(tableShader, shader, "Shader", "Selects shader type for specific surface response and options"); - AddVariable(tableShader, surfaceType, "Surface Type", "Defines how entities interact with surfaces using the material effects system"); - m_varChangeNotifications["Surface Type"] = MATERIALCHANGE_SURFACETYPE; - - shader->SetEnumList(enumShaders); - - surfaceType->SetEnumList(enumSurfaceTypes); - - // Properties that use this scriptingDescription are based on what's available in MaterialHelpers::SetGetMaterialParamVec3 and MaterialHelpers::SetGetMaterialParamFloat. - // This should match what's done in MaterialHelpers.cpp AddRealNameToDescription(). - auto scriptingDescription = [](const AZStd::string& scriptAccessibleName, const AZStd::string& description) { return description + "\n(Script Param Name = " + scriptAccessibleName + ")"; }; - - ////////////////////////////////////////////////////////////////////////// - // Opacity. - ////////////////////////////////////////////////////////////////////////// - AddVariable(tableOpacity, opacity, "Opacity", - scriptingDescription("opacity", "Sets the transparency amount. Uses 0-99 to set Alpha Blend and 100 for Opaque and Alpha Test.").c_str(), IVariable::DT_PERCENT); - AddVariable(tableOpacity, alphaTest, "AlphaTest", - scriptingDescription("alpha", "Uses the alpha mask and refines the transparent edge. Uses 0-50 to bias toward white or 50-100 to bias toward black.").c_str(), IVariable::DT_PERCENT); - AddVariable(tableOpacity, bAdditive, "Additive", "Adds material color to the background color resulting in a brighter transparent surface"); - opacity->SetLimits(0, 100, 1, true, true); - alphaTest->SetLimits(0, 100, 1, true, true); - - ////////////////////////////////////////////////////////////////////////// - // Lighting. - ////////////////////////////////////////////////////////////////////////// - AddVariable(tableLighting, diffuse, "Diffuse Color (Tint)", scriptingDescription("diffuse", "Tints the material diffuse color. Physically based materials should be left at white").c_str(), IVariable::DT_COLOR); - AddVariable(tableLighting, specular, "Specular Color", scriptingDescription("specular", "Reflective and shininess intensity and color of reflective highlights").c_str(), IVariable::DT_COLOR); - AddVariable(tableLighting, smoothness, "Smoothness", scriptingDescription("shininess", "Smoothness or glossiness simulating how light bounces off the surface").c_str()); - AddVariable(tableLighting, emissiveIntensity, "Emissive Intensity (kcd/m2)", scriptingDescription("emissive_intensity", "Brightness simulating light emitting from the surface making an object glow").c_str()); - AddVariable(tableLighting, emissiveCol, "Emissive Color", scriptingDescription("emissive_color", "Tints the emissive color").c_str(), IVariable::DT_COLOR); - emissiveIntensity->SetLimits(0, EMISSIVE_INTENSITY_SOFT_MAX, 1, true, false); - smoothness->SetLimits(0, 255, 1, true, true); - - ////////////////////////////////////////////////////////////////////////// - // Init texture variables. - ////////////////////////////////////////////////////////////////////////// - for (EEfResTextures texId = EEfResTextures(0); texId < EFTT_MAX; texId = EEfResTextures(texId + 1)) - { - if (!MaterialHelpers::IsAdjustableTexSlot(texId)) - { - continue; - } - - InitTextureVars(texId, MaterialHelpers::LookupTexName(texId), MaterialHelpers::LookupTexDesc(texId)); - } - - //AddVariable( tableAdvanced,bWire,"Wireframe" ); - AddVariable(tableAdvanced, allowLayerActivation, "Allow layer activation", ""); - AddVariable(tableAdvanced, b2Sided, "2 Sided", "Enables both sides of mesh faces to render"); - AddVariable(tableAdvanced, bNoShadow, "No Shadow", "Disables casting shadows from mesh faces"); - AddVariable(tableAdvanced, bScatter, "Use Scattering", "Deprecated"); - AddVariable(tableAdvanced, bHideAfterBreaking, "Hide After Breaking", "Causes the object to disappear after procedurally breaking"); - AddVariable(tableAdvanced, bFogVolumeShadingQualityHigh, "Fog Volume Shading Quality High", "high fog volume shading quality behaves more accurately with fog volumes."); - AddVariable(tableAdvanced, bBlendTerrainColor, "Blend Terrain Color", ""); - AddVariable(tableAdvanced, voxelCoverage, "Voxel Coverage", "Fine tunes occlusion amount for svogi feature. Higher values occlude more closely to object shape."); - voxelCoverage->SetLimits(0, 1.0f); - - ////////////////////////////////////////////////////////////////////////// - // Material Value Propagation for dynamic material switches, as for instance - // used by breakable glass - ////////////////////////////////////////////////////////////////////////// - AddVariable(tableAdvanced, matPropagate, "Link to Material", ""); - AddVariable(tableAdvanced, bPropagateMaterialSettings, "Propagate Material Settings", ""); - AddVariable(tableAdvanced, bPropagateOpactity, "Propagate Opacity Settings", ""); - AddVariable(tableAdvanced, bPropagateLighting, "Propagate Lighting Settings", ""); - AddVariable(tableAdvanced, bPropagateAdvanced, "Propagate Advanced Settings", ""); - AddVariable(tableAdvanced, bPropagateTexture, "Propagate Texture Maps", ""); - AddVariable(tableAdvanced, bPropagateShaderParams, "Propagate Shader Params", ""); - AddVariable(tableAdvanced, bPropagateShaderGenParams, "Propagate Shader Generation", ""); - AddVariable(tableAdvanced, bPropagateVertexDef, "Propagate Vertex Deformation", ""); - - ////////////////////////////////////////////////////////////////////////// - // Init Vertex Deformation. - ////////////////////////////////////////////////////////////////////////// - vertexMod.type->SetEnumList(enumVertexMod); - AddVariable(tableVertexMod, vertexMod.type, "Type", "Choose method to define how the vertices will deform"); - AddVariable(tableVertexMod, vertexMod.fDividerX, "Wave Length", "Length of wave deformation"); - - AddVariable(tableVertexMod, vertexMod.wave.table, "Parameters", "Fine tunes how the vertices deform"); - - vertexMod.wave.waveFormType->SetEnumList(enumWaveType); - AddVariable(vertexMod.wave.table, vertexMod.wave.waveFormType, "Type", "Sin type will include vertex color in calculation"); - AddVariable(vertexMod.wave.table, vertexMod.wave.level, "Level", "Scales the object equally in xyz"); - AddVariable(vertexMod.wave.table, vertexMod.wave.amplitude, "Amplitude", "Strength of vertex deformation (vertex color: b, normal: z)"); - AddVariable(vertexMod.wave.table, vertexMod.wave.phase, "Phase", "Offset of vertex deformation (vertex color: r, normal: x)"); - AddVariable(vertexMod.wave.table, vertexMod.wave.frequency, "Frequency", "Speed of vertex animation (vertex color: g, normal: y)"); - - return m_vars; - } - -private: - ////////////////////////////////////////////////////////////////////////// - void InitTextureVars(int id, const QString& name, const QString& desc) - { - textureVars[id]->SetFlags(IVariable::UI_BOLD); - textureVars[id]->SetFlags(textureVars[id]->GetFlags() | IVariable::UI_AUTO_EXPAND); - advancedTextureGroup[id]->SetFlags(advancedTextureGroup[id]->GetFlags() | IVariable::UI_COLLAPSED); - AddVariable(tableTexture, *textureVars[id], name.toUtf8().data(), desc.toUtf8().data(), IVariable::DT_TEXTURE); - AddVariable(*textureVars[id], *advancedTextureGroup[id], "Advanced", "Controls UV tiling, offset, and rotation as well as texture filtering"); - - AddVariable(*advancedTextureGroup[id], textures[id].etextype, "TexType", ""); - AddVariable(*advancedTextureGroup[id], textures[id].filter, "Filter", "Sets texture smoothing method to determine texture pixel quality"); - - AddVariable(*advancedTextureGroup[id], textures[id].is_tcgprojected, "IsProjectedTexGen", ""); - AddVariable(*advancedTextureGroup[id], textures[id].etcgentype, "TexGenType", "Controls UV projection behavior"); - - if (IsTextureModifierSupportedForTextureMap(static_cast(id))) - { - ////////////////////////////////////////////////////////////////////////// - // Tiling table. - AddVariable(*advancedTextureGroup[id], textures[id].tableTiling, "Tiling", "Controls UV tiling, offset, and rotation"); - { - CVariableArray& table = textures[id].tableTiling; - table.SetFlags(IVariable::UI_BOLD); - AddVariable(table, *textures[id].is_tile[0], "IsTileU", "Enables UV tiling on U"); - AddVariable(table, *textures[id].is_tile[1], "IsTileV", "Enables UV tiling on V"); - AddVariable(table, *textures[id].tiling[0], "TileU", "Multiplies tiled projection on U"); - AddVariable(table, *textures[id].tiling[1], "TileV", "Multiplies tiled projection on V"); - AddVariable(table, *textures[id].offset[0], "OffsetU", "Offsets texture projection on U"); - AddVariable(table, *textures[id].offset[1], "OffsetV", "Offsets texture projection on V"); - AddVariable(table, *textures[id].rotate[0], "RotateU", "Rotates texture projection on U"); - AddVariable(table, *textures[id].rotate[1], "RotateV", "Rotates texture projection on V"); - AddVariable(table, *textures[id].rotate[2], "RotateW", "Rotates texture projection on W"); - } - - ////////////////////////////////////////////////////////////////////////// - // Rotator tables. - AddVariable(*advancedTextureGroup[id], textures[id].tableRotator, "Rotator", "Controls the animated UV rotation"); - { - CVariableArray& table = textures[id].tableRotator; - table.SetFlags(IVariable::UI_BOLD); - AddVariable(table, textures[id].etcmrotatetype, "Type", "Controls the behavior of UV rotation"); - AddVariable(table, textures[id].tcmrotoscrate, "Rate", "Sets the speed (number of complete cycles per unit of time) of rotation"); - AddVariable(table, textures[id].tcmrotoscphase, "Phase", "Sets the initial offset of rotation"); - AddVariable(table, textures[id].tcmrotoscamplitude, "Amplitude", "Sets the strength (maximum value) of rotation"); - AddVariable(table, *textures[id].tcmrotosccenter[0], "CenterU", "Sets the center of rotation along U"); - AddVariable(table, *textures[id].tcmrotosccenter[1], "CenterV", "Sets the center of rotation along V"); - } - - ////////////////////////////////////////////////////////////////////////// - // Oscillator table - AddVariable(*advancedTextureGroup[id], textures[id].tableOscillator, "Oscillator", "Controls the animated UV oscillation"); - { - CVariableArray& table = textures[id].tableOscillator; - table.SetFlags(IVariable::UI_BOLD); - AddVariable(table, textures[id].etcmumovetype, "TypeU", "Sets the behavior of oscillation in the U direction"); - AddVariable(table, textures[id].etcmvmovetype, "TypeV", "Sets the behavior of oscillation in the V direction"); - AddVariable(table, textures[id].tcmuoscrate, "RateU", "Sets the speed (number of complete cycles per unit of time) of oscillation in U"); - AddVariable(table, textures[id].tcmvoscrate, "RateV", "Sets the speed (number of complete cycles per unit of time) of oscillation in V"); - AddVariable(table, textures[id].tcmuoscphase, "PhaseU", "Sets the initial offset of oscillation in U"); - AddVariable(table, textures[id].tcmvoscphase, "PhaseV", "Sets the initial offset of oscillation in V"); - AddVariable(table, textures[id].tcmuoscamplitude, "AmplitudeU", "Sets the strength (maximum value) of oscillation in U"); - AddVariable(table, textures[id].tcmvoscamplitude, "AmplitudeV", "Sets the strength (maximum value) of oscillation in V"); - } - } - - ////////////////////////////////////////////////////////////////////////// - // Assign enums tables to variable. - ////////////////////////////////////////////////////////////////////////// - textures[id].etextype->SetEnumList(enumTexType); - textures[id].etcgentype->SetEnumList(enumTexGenType); - textures[id].etcmrotatetype->SetEnumList(enumTexModRotateType); - textures[id].etcmumovetype->SetEnumList(enumTexModUMoveType); - textures[id].etcmvmovetype->SetEnumList(enumTexModVMoveType); - textures[id].filter->SetEnumList(enumTexFilterType); - } - ////////////////////////////////////////////////////////////////////////// - - void AddVariable(CVariableBase& varArray, CVariableBase& var, const char* varName, const char* varTooltip, unsigned char dataType = IVariable::DT_SIMPLE) - { - if (varName) - { - var.SetName(varName); - } - if (varTooltip) - { - var.SetDescription(varTooltip); - } - var.SetDataType(dataType); - varArray.AddVariable(&var); - } - ////////////////////////////////////////////////////////////////////////// - void AddVariable(CVarBlock* vars, CVariableBase& var, const char* varName, const char* varTooltip, unsigned char dataType = IVariable::DT_SIMPLE) - { - if (varName) - { - var.SetName(varName); - } - if (varTooltip) - { - var.SetDescription(varTooltip); - } - var.SetDataType(dataType); - vars->AddVariable(&var); - } - - void SetTextureResources(const SEfResTexture *pTextureRes, uint16 tex, bool bSetTextures); - void GetTextureResources(SInputShaderResources& sr, int texid, int propagationFlags); - void ResetTextureResources(uint16 tex); - Vec4 ToVec4(const ColorF& col) { return Vec4(col.r, col.g, col.b, col.a); } - Vec3 ToVec3(const ColorF& col) { return Vec3(col.r, col.g, col.b); } - ColorF ToCFColor(const Vec3& col) { return ColorF(col); } - ColorF ToCFColor(const Vec4& col) { return ColorF(col); } -}; - -////////////////////////////////////////////////////////////////////////// -void CMaterialUI::NotifyObjectsAboutMaterialChange(IVariable* var) -{ - if (!var) - { - return; - } - - TVarChangeNotifications::iterator it = m_varChangeNotifications.find(var->GetName()); - if (it == m_varChangeNotifications.end()) - { - return; - } - - CMaterial* pMaterial = GetIEditor()->GetMaterialManager()->GetCurrentMaterial(); - if (!pMaterial) - { - return; - } - - // Get a parent, if we are editing submaterial - if (pMaterial->GetParent() != 0) - { - pMaterial = pMaterial->GetParent(); - } - - CBaseObjectsArray objects; - GetIEditor()->GetObjectManager()->GetObjects(objects); - int numObjects = objects.size(); - for (int i = 0; i < numObjects; ++i) - { - CBaseObject* pObject = objects[i]; - if (pObject->GetRenderMaterial() == pMaterial) - { - pObject->OnMaterialChanged(it->second); - } - } -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialUI::SetShaderResources(const SInputShaderResources& srTextures, bool bSetTextures) -{ - alphaTest = srTextures.m_AlphaRef; - voxelCoverage = (float) srTextures.m_VoxelCoverage / 255.0f; - - diffuse = ToVec3(srTextures.m_LMaterial.m_Diffuse); - specular = ToVec3(srTextures.m_LMaterial.m_Specular); - emissiveCol = ToVec3(srTextures.m_LMaterial.m_Emittance); - emissiveIntensity = srTextures.m_LMaterial.m_Emittance.a; - opacity = srTextures.m_LMaterial.m_Opacity; - smoothness = srTextures.m_LMaterial.m_Smoothness; - - SetVertexDeform(srTextures); - - - for (EEfResTextures texId = EEfResTextures(0); texId < EFTT_MAX; texId = EEfResTextures(texId + 1)) - { - if (!MaterialHelpers::IsAdjustableTexSlot(texId)) - { - continue; - } - - auto foundIter = srTextures.m_TexturesResourcesMap.find((ResourceSlotIndex)texId); - if (foundIter != srTextures.m_TexturesResourcesMap.end()) - { - const SEfResTexture* pTextureRes = const_cast(&foundIter->second); - SetTextureResources(pTextureRes, texId, bSetTextures); - } - else - { - ResetTextureResources(texId); - } - } -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialUI::GetShaderResources(SInputShaderResources& sr, int propagationFlags) -{ - if (propagationFlags & MTL_PROPAGATE_OPACITY) - { - sr.m_LMaterial.m_Opacity = opacity; - sr.m_AlphaRef = alphaTest; - } - - if (propagationFlags & MTL_PROPAGATE_ADVANCED) - { - sr.m_VoxelCoverage = int_round(voxelCoverage * 255.0f); - } - - if (propagationFlags & MTL_PROPAGATE_LIGHTING) - { - sr.m_LMaterial.m_Diffuse = ToCFColor(diffuse); - sr.m_LMaterial.m_Specular = ToCFColor(specular); - sr.m_LMaterial.m_Emittance = ColorF(emissiveCol, emissiveIntensity); - sr.m_LMaterial.m_Smoothness = smoothness; - } - - GetVertexDeform(sr, propagationFlags); - - for (EEfResTextures texId = EEfResTextures(0); texId < EFTT_MAX; texId = EEfResTextures(texId + 1)) - { - if (!MaterialHelpers::IsAdjustableTexSlot(texId)) - { - continue; - } - - GetTextureResources(sr, texId, propagationFlags); - } -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialUI::SetTextureResources( const SEfResTexture *pTextureRes, uint16 texSlot, bool bSetTextures) -{ - /* - // Enable/Disable texture map, depending on the mask. - int flags = textureVars[tex].GetFlags(); - if ((1 << tex) & texUsageMask) - flags &= ~IVariable::UI_DISABLED; - else - flags |= IVariable::UI_DISABLED; - textureVars[tex].SetFlags( flags ); - */ - - if (bSetTextures) - { - QString texFilename = pTextureRes->m_Name.c_str(); - texFilename = Path::ToUnixPath(texFilename); - textureVars[texSlot]->Set(texFilename); - } - - //textures[tex].amount = pTextureRes->m_Amount; - *textures[texSlot].is_tile[0] = pTextureRes->m_bUTile; - *textures[texSlot].is_tile[1] = pTextureRes->m_bVTile; - - *textures[texSlot].tiling[0] = pTextureRes->GetTiling(0); - *textures[texSlot].tiling[1] = pTextureRes->GetTiling(1); - *textures[texSlot].offset[0] = pTextureRes->GetOffset(0); - *textures[texSlot].offset[1] = pTextureRes->GetOffset(1); - textures[texSlot].filter = (int)pTextureRes->m_Filter; - textures[texSlot].etextype = pTextureRes->m_Sampler.m_eTexType; - - if (pTextureRes->m_Ext.m_pTexModifier) - { - textures[texSlot].etcgentype = pTextureRes->m_Ext.m_pTexModifier->m_eTGType; - textures[texSlot].etcmumovetype = pTextureRes->m_Ext.m_pTexModifier->m_eMoveType[0]; - textures[texSlot].etcmvmovetype = pTextureRes->m_Ext.m_pTexModifier->m_eMoveType[1]; - textures[texSlot].etcmrotatetype = pTextureRes->m_Ext.m_pTexModifier->m_eRotType; - textures[texSlot].is_tcgprojected = pTextureRes->m_Ext.m_pTexModifier->m_bTexGenProjected; - textures[texSlot].tcmuoscrate = pTextureRes->m_Ext.m_pTexModifier->m_OscRate[0]; - textures[texSlot].tcmuoscphase = pTextureRes->m_Ext.m_pTexModifier->m_OscPhase[0]; - textures[texSlot].tcmuoscamplitude = pTextureRes->m_Ext.m_pTexModifier->m_OscAmplitude[0]; - textures[texSlot].tcmvoscrate = pTextureRes->m_Ext.m_pTexModifier->m_OscRate[1]; - textures[texSlot].tcmvoscphase = pTextureRes->m_Ext.m_pTexModifier->m_OscPhase[1]; - textures[texSlot].tcmvoscamplitude = pTextureRes->m_Ext.m_pTexModifier->m_OscAmplitude[1]; - - for (int i = 0; i < 3; i++) - { - *textures[texSlot].rotate[i] = RoundDegree(Word2Degr(pTextureRes->m_Ext.m_pTexModifier->m_Rot[i])); - } - textures[texSlot].tcmrotoscrate = RoundDegree(Word2Degr(pTextureRes->m_Ext.m_pTexModifier->m_RotOscRate[2])); - textures[texSlot].tcmrotoscphase = RoundDegree(Word2Degr(pTextureRes->m_Ext.m_pTexModifier->m_RotOscPhase[2])); - textures[texSlot].tcmrotoscamplitude = RoundDegree(Word2Degr(pTextureRes->m_Ext.m_pTexModifier->m_RotOscAmplitude[2])); - *textures[texSlot].tcmrotosccenter[0] = pTextureRes->m_Ext.m_pTexModifier->m_RotOscCenter[0]; - *textures[texSlot].tcmrotosccenter[1] = pTextureRes->m_Ext.m_pTexModifier->m_RotOscCenter[1]; - } - else - { - textures[texSlot].etcgentype = 0; - textures[texSlot].etcmumovetype = 0; - textures[texSlot].etcmvmovetype = 0; - textures[texSlot].etcmrotatetype = 0; - textures[texSlot].is_tcgprojected = false; - textures[texSlot].tcmuoscrate = 0; - textures[texSlot].tcmuoscphase = 0; - textures[texSlot].tcmuoscamplitude = 0; - textures[texSlot].tcmvoscrate = 0; - textures[texSlot].tcmvoscphase = 0; - textures[texSlot].tcmvoscamplitude = 0; - - for (int i = 0; i < 3; i++) - { - *textures[texSlot].rotate[i] = 0; - } - - textures[texSlot].tcmrotoscrate = 0; - textures[texSlot].tcmrotoscphase = 0; - textures[texSlot].tcmrotoscamplitude = 0; - *textures[texSlot].tcmrotosccenter[0] = 0; - *textures[texSlot].tcmrotosccenter[1] = 0; - } -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialUI::ResetTextureResources(uint16 texSlot) -{ - QString texFilename = ""; - textureVars[texSlot]->Set(texFilename); - textures[texSlot].Reset(); -} - -void CMaterialUI::GetTextureResources(SInputShaderResources& sr, int tex, int propagationFlags) -{ - if ((propagationFlags & MTL_PROPAGATE_TEXTURES) == 0) - { - return; - } - - QString texFilename; - textureVars[tex]->Get(texFilename); - if (texFilename.isEmpty()) - { - // Remove the texture if the path was cleared in the UI - sr.m_TexturesResourcesMap.erase(tex); - - // If the normal map/second normal map has been cleared in the UI, - // we must also clear the smoothness/second smoothness since smoothness lives in the alpha of the normal - if (tex == EFTT_NORMALS) - { - sr.m_TexturesResourcesMap.erase(EFTT_SMOOTHNESS); - } - // EFTT_CUSTOM_SECONDARY is the 2nd normal - if (tex == EFTT_CUSTOM_SECONDARY) - { - sr.m_TexturesResourcesMap.erase(EFTT_SECOND_SMOOTHNESS); - } - return; - } - texFilename = Path::ToUnixPath(texFilename); - - // Clear any texture resource that has no associated file - if (texFilename.size() > AZ_MAX_PATH_LEN) - { - AZ_Error("Material Editor", false, "Texture path exceeds the maximium allowable length of %d.", AZ_MAX_PATH_LEN); - return; - } - - // The following line will insert the slot if did not exist. - SEfResTexture* pTextureRes = &(sr.m_TexturesResourcesMap[tex]); - pTextureRes->m_Name = texFilename.toUtf8().data(); - - //pTextureRes->m_Amount = textures[tex].amount; - pTextureRes->m_bUTile = *textures[tex].is_tile[0]; - pTextureRes->m_bVTile = *textures[tex].is_tile[1]; - SEfTexModificator& texm = *pTextureRes->AddModificator(); - texm.m_bTexGenProjected = textures[tex].is_tcgprojected; - - texm.m_Tiling[0] = *textures[tex].tiling[0]; - texm.m_Tiling[1] = *textures[tex].tiling[1]; - texm.m_Offs[0] = *textures[tex].offset[0]; - texm.m_Offs[1] = *textures[tex].offset[1]; - pTextureRes->m_Filter = (int)textures[tex].filter; - pTextureRes->m_Sampler.m_eTexType = textures[tex].etextype; - texm.m_eRotType = textures[tex].etcmrotatetype; - texm.m_eTGType = textures[tex].etcgentype; - texm.m_eMoveType[0] = textures[tex].etcmumovetype; - texm.m_eMoveType[1] = textures[tex].etcmvmovetype; - texm.m_OscRate[0] = textures[tex].tcmuoscrate; - texm.m_OscPhase[0] = textures[tex].tcmuoscphase; - texm.m_OscAmplitude[0] = textures[tex].tcmuoscamplitude; - texm.m_OscRate[1] = textures[tex].tcmvoscrate; - texm.m_OscPhase[1] = textures[tex].tcmvoscphase; - texm.m_OscAmplitude[1] = textures[tex].tcmvoscamplitude; - - for (int i = 0; i < 3; i++) - { - texm.m_Rot[i] = Degr2Word(*textures[tex].rotate[i]); - } - texm.m_RotOscRate[2] = Degr2Word(textures[tex].tcmrotoscrate); - texm.m_RotOscPhase[2] = Degr2Word(textures[tex].tcmrotoscphase); - texm.m_RotOscAmplitude[2] = Degr2Word(textures[tex].tcmrotoscamplitude); - texm.m_RotOscCenter[0] = *textures[tex].tcmrotosccenter[0]; - texm.m_RotOscCenter[1] = *textures[tex].tcmrotosccenter[1]; - texm.m_RotOscCenter[2] = 0.0f; -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialUI::SetVertexDeform(const SInputShaderResources& sr) -{ - vertexMod.type = (int)sr.m_DeformInfo.m_eType; - vertexMod.fDividerX = sr.m_DeformInfo.m_fDividerX; - vertexMod.vNoiseScale = sr.m_DeformInfo.m_vNoiseScale; - - vertexMod.wave.waveFormType = EWaveForm::eWF_Sin; - vertexMod.wave.amplitude = sr.m_DeformInfo.m_WaveX.m_Amp; - vertexMod.wave.level = sr.m_DeformInfo.m_WaveX.m_Level; - vertexMod.wave.phase = sr.m_DeformInfo.m_WaveX.m_Phase; - vertexMod.wave.frequency = sr.m_DeformInfo.m_WaveX.m_Freq; -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialUI::GetVertexDeform(SInputShaderResources& sr, int propagationFlags) -{ - if ((propagationFlags & MTL_PROPAGATE_VERTEX_DEF) == 0) - { - return; - } - - sr.m_DeformInfo.m_eType = (EDeformType)((int)vertexMod.type); - sr.m_DeformInfo.m_fDividerX = vertexMod.fDividerX; - sr.m_DeformInfo.m_vNoiseScale = vertexMod.vNoiseScale; - - sr.m_DeformInfo.m_WaveX.m_eWFType = (EWaveForm)((int)vertexMod.wave.waveFormType); - sr.m_DeformInfo.m_WaveX.m_Amp = vertexMod.wave.amplitude; - sr.m_DeformInfo.m_WaveX.m_Level = vertexMod.wave.level; - sr.m_DeformInfo.m_WaveX.m_Phase = vertexMod.wave.phase; - sr.m_DeformInfo.m_WaveX.m_Freq = vertexMod.wave.frequency; -} - -void CMaterialUI::PropagateToLinkedMaterial(CMaterial* mtl, CVarBlockPtr pShaderParams) -{ - if (!mtl) - { - return; - } - CMaterial* subMtl = NULL, * parentMtl = mtl->GetParent(); - const QString& linkedMaterialName = matPropagate; - int propFlags = 0; - - if (parentMtl) - { - for (int i = 0; i < parentMtl->GetSubMaterialCount(); ++i) - { - CMaterial* pMtl = parentMtl->GetSubMaterial(i); - if (pMtl && pMtl != mtl && pMtl->GetFullName() == linkedMaterialName) - { - subMtl = pMtl; - break; - } - } - } - if (!linkedMaterialName.isEmpty() && subMtl) - { - // Ensure that the linked material is cleared if it can't be found anymore - mtl->LinkToMaterial(linkedMaterialName); - } - // Note: It's only allowed to propagate the shader params and shadergen params - // if we also propagate the actual shader to the linked material as well, else - // bogus values will be set - bPropagateShaderParams = (int)bPropagateShaderParams & - (int)bPropagateMaterialSettings; - bPropagateShaderGenParams = (int)bPropagateShaderGenParams & - (int)bPropagateMaterialSettings; - - propFlags |= MTL_PROPAGATE_MATERIAL_SETTINGS & - (int)bPropagateMaterialSettings; - propFlags |= MTL_PROPAGATE_OPACITY & - (int)bPropagateOpactity; - propFlags |= MTL_PROPAGATE_LIGHTING & - (int)bPropagateLighting; - propFlags |= MTL_PROPAGATE_ADVANCED & - (int)bPropagateAdvanced; - propFlags |= MTL_PROPAGATE_TEXTURES & - (int)bPropagateTexture; - propFlags |= MTL_PROPAGATE_SHADER_PARAMS & - (int)bPropagateShaderParams; - propFlags |= MTL_PROPAGATE_SHADER_GEN & - (int)bPropagateShaderGenParams; - propFlags |= MTL_PROPAGATE_VERTEX_DEF & - (int)bPropagateVertexDef; - propFlags |= MTL_PROPAGATE_LAYER_PRESETS & - (int)bPropagateLayerPresets; - mtl->SetPropagationFlags(propFlags); - - if (subMtl) - { - SetToMaterial(subMtl, propFlags | MTL_PROPAGATE_RESERVED); - if (propFlags & MTL_PROPAGATE_SHADER_PARAMS) - { - if (CVarBlock* pPublicVars = subMtl->GetPublicVars(mtl->GetShaderResources())) - { - subMtl->SetPublicVars(pPublicVars, subMtl); - } - } - if (propFlags & MTL_PROPAGATE_SHADER_GEN) - { - subMtl->SetShaderGenParamsVars(mtl->GetShaderGenParamsVars()); - } - subMtl->Update(); - subMtl->UpdateMaterialLayers(); - } -} - -void CMaterialUI::PropagateFromLinkedMaterial(CMaterial* mtl) -{ - if (!mtl) - { - return; - } - CMaterial* subMtl = NULL, * parentMtl = mtl->GetParent(); - const QString& linkedMaterialName = mtl->GetLinkedMaterialName(); - //CVarEnumList *enumMtls = new CVarEnumList; - if (parentMtl) - { - for (int i = 0; i < parentMtl->GetSubMaterialCount(); ++i) - { - CMaterial* pMtl = parentMtl->GetSubMaterial(i); - if (!pMtl || pMtl == mtl) - { - continue; - } - const QString& subMtlName = pMtl->GetFullName(); - //enumMtls->AddItem(subMtlName, subMtlName); - if (subMtlName == linkedMaterialName) - { - subMtl = pMtl; - break; - } - } - } - matPropagate = QString(); - //matPropagate.SetEnumList(enumMtls); - if (!linkedMaterialName.isEmpty() && !subMtl) - { - // Ensure that the linked material is cleared if it can't be found anymore - mtl->LinkToMaterial(QString()); - } - else - { - matPropagate = linkedMaterialName; - } - bPropagateMaterialSettings = mtl->GetPropagationFlags() & MTL_PROPAGATE_MATERIAL_SETTINGS; - bPropagateOpactity = mtl->GetPropagationFlags() & MTL_PROPAGATE_OPACITY; - bPropagateLighting = mtl->GetPropagationFlags() & MTL_PROPAGATE_LIGHTING; - bPropagateTexture = mtl->GetPropagationFlags() & MTL_PROPAGATE_TEXTURES; - bPropagateAdvanced = mtl->GetPropagationFlags() & MTL_PROPAGATE_ADVANCED; - bPropagateVertexDef = mtl->GetPropagationFlags() & MTL_PROPAGATE_VERTEX_DEF; - bPropagateShaderParams = mtl->GetPropagationFlags() & MTL_PROPAGATE_SHADER_PARAMS; - bPropagateLayerPresets = mtl->GetPropagationFlags() & MTL_PROPAGATE_LAYER_PRESETS; - bPropagateShaderGenParams = mtl->GetPropagationFlags() & MTL_PROPAGATE_SHADER_GEN; -} - -void CMaterialUI::SetFromMaterial(CMaterial* mtlIn) -{ - QString shaderName = mtlIn->GetShaderName(); - if (!shaderName.isEmpty()) - { - // Capitalize first letter. - shaderName = shaderName[0].toUpper() + shaderName.mid(1); - } - - shader = shaderName; - - int mtlFlags = mtlIn->GetFlags(); - bNoShadow = (mtlFlags & MTL_FLAG_NOSHADOW); - bAdditive = (mtlFlags & MTL_FLAG_ADDITIVE); - bWire = (mtlFlags & MTL_FLAG_WIRE); - b2Sided = (mtlFlags & MTL_FLAG_2SIDED); - bScatter = (mtlFlags & MTL_FLAG_SCATTER); - bHideAfterBreaking = (mtlFlags & MTL_FLAG_HIDEONBREAK); - bFogVolumeShadingQualityHigh = (mtlFlags & MTL_FLAG_FOG_VOLUME_SHADING_QUALITY_HIGH); - bBlendTerrainColor = (mtlFlags & MTL_FLAG_BLEND_TERRAIN); - texUsageMask = mtlIn->GetTexmapUsageMask(); - - allowLayerActivation = mtlIn->LayerActivationAllowed(); - - // Detail, decal and custom textures are always active. - const uint32 nDefaultFlagsEFTT = (1 << EFTT_DETAIL_OVERLAY) | (1 << EFTT_DECAL_OVERLAY) | (1 << EFTT_CUSTOM) | (1 << EFTT_CUSTOM_SECONDARY); - texUsageMask |= nDefaultFlagsEFTT; - if ((texUsageMask & (1 << EFTT_NORMALS))) - { - texUsageMask |= 1 << EFTT_NORMALS; - } - - surfaceType = mtlIn->GetSurfaceTypeName(); - SetShaderResources(mtlIn->GetShaderResources(), true); - - // Propagate settings and properties to a sub material if edited - PropagateFromLinkedMaterial(mtlIn); - - // set each material layer - SMaterialLayerResources* pMtlLayerResources = mtlIn->GetMtlLayerResources(); - for (int l(0); l < MTL_LAYER_MAX_SLOTS; ++l) - { - materialLayers[l].shader = pMtlLayerResources[l].m_shaderName; - materialLayers[l].bNoDraw = pMtlLayerResources[l].m_nFlags & MTL_LAYER_USAGE_NODRAW; - materialLayers[l].bFadeOut = pMtlLayerResources[l].m_nFlags & MTL_LAYER_USAGE_FADEOUT; - } -} - -void CMaterialUI::SetToMaterial(CMaterial* mtl, int propagationFlags) -{ - int mtlFlags = mtl->GetFlags(); - - if (propagationFlags & MTL_PROPAGATE_ADVANCED) - { - if (bNoShadow) - { - mtlFlags |= MTL_FLAG_NOSHADOW; - } - else - { - mtlFlags &= ~MTL_FLAG_NOSHADOW; - } - } - - if (propagationFlags & MTL_PROPAGATE_OPACITY) - { - if (bAdditive) - { - mtlFlags |= MTL_FLAG_ADDITIVE; - } - else - { - mtlFlags &= ~MTL_FLAG_ADDITIVE; - } - } - - if (bWire) - { - mtlFlags |= MTL_FLAG_WIRE; - } - else - { - mtlFlags &= ~MTL_FLAG_WIRE; - } - - if (propagationFlags & MTL_PROPAGATE_ADVANCED) - { - if (b2Sided) - { - mtlFlags |= MTL_FLAG_2SIDED; - } - else - { - mtlFlags &= ~MTL_FLAG_2SIDED; - } - - if (bScatter) - { - mtlFlags |= MTL_FLAG_SCATTER; - } - else - { - mtlFlags &= ~MTL_FLAG_SCATTER; - } - - if (bHideAfterBreaking) - { - mtlFlags |= MTL_FLAG_HIDEONBREAK; - } - else - { - mtlFlags &= ~MTL_FLAG_HIDEONBREAK; - } - - if (bFogVolumeShadingQualityHigh) - { - mtlFlags |= MTL_FLAG_FOG_VOLUME_SHADING_QUALITY_HIGH; - } - else - { - mtlFlags &= ~MTL_FLAG_FOG_VOLUME_SHADING_QUALITY_HIGH; - } - - if (bBlendTerrainColor) - { - mtlFlags |= MTL_FLAG_BLEND_TERRAIN; - } - else - { - mtlFlags &= ~MTL_FLAG_BLEND_TERRAIN; - } - } - - mtl->SetFlags(mtlFlags); - - mtl->SetLayerActivation(allowLayerActivation); - - // set each material layer - if (propagationFlags & MTL_PROPAGATE_LAYER_PRESETS) - { - SMaterialLayerResources* pMtlLayerResources = mtl->GetMtlLayerResources(); - for (int l(0); l < MTL_LAYER_MAX_SLOTS; ++l) - { - if (pMtlLayerResources[l].m_shaderName != materialLayers[l].shader) - { - pMtlLayerResources[l].m_shaderName = materialLayers[l].shader; - pMtlLayerResources[l].m_bRegetPublicParams = true; - } - - if (materialLayers[l].bNoDraw) - { - pMtlLayerResources[l].m_nFlags |= MTL_LAYER_USAGE_NODRAW; - } - else - { - pMtlLayerResources[l].m_nFlags &= ~MTL_LAYER_USAGE_NODRAW; - } - - if (materialLayers[l].bFadeOut) - { - pMtlLayerResources[l].m_nFlags |= MTL_LAYER_USAGE_FADEOUT; - } - else - { - pMtlLayerResources[l].m_nFlags &= ~MTL_LAYER_USAGE_FADEOUT; - } - } - } - - if (propagationFlags & MTL_PROPAGATE_MATERIAL_SETTINGS) - { - mtl->SetSurfaceTypeName(surfaceType); - // If shader name is different reload shader. - mtl->SetShaderName(shader); - } - - GetShaderResources(mtl->GetShaderResources(), propagationFlags); -} - -void CMaterialUI::SetTextureNames(CMaterial* mtl) -{ - SInputShaderResources& sr = mtl->GetShaderResources(); - - for ( auto& iter : sr.m_TexturesResourcesMap ) - { - uint16 texId = iter.first; - if (!MaterialHelpers::IsAdjustableTexSlot((EEfResTextures)texId)) - { - continue; - } - - SEfResTexture* pTextureRes = &(iter.second); - textureVars[texId]->Set(pTextureRes->m_Name.c_str()); - } -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -class CMtlPickCallback - : public IPickObjectCallback -{ -public: - CMtlPickCallback() { m_bActive = true; }; - //! Called when object picked. - virtual void OnPick(CBaseObject* picked) - { - m_bActive = false; - CMaterial* pMtl = picked->GetMaterial(); - if (pMtl) - { - GetIEditor()->OpenMaterialLibrary(pMtl); - } - delete this; - } - //! Called when pick mode canceled. - virtual void OnCancelPick() - { - m_bActive = false; - delete this; - } - //! Return true if specified object is pickable. - virtual bool OnPickFilter(CBaseObject* filterObject) - { - // Check if object have material. - if (filterObject->GetMaterial()) - { - return true; - } - else - { - return false; - } - } - static bool IsActive() { return m_bActive; }; -private: - static bool m_bActive; -}; -bool CMtlPickCallback::m_bActive = false; -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -// CMaterialDialog implementation. -////////////////////////////////////////////////////////////////////////// -CMaterialDialog::CMaterialDialog(QWidget* parent /* = 0 */) - : QMainWindow(parent) - , m_wndMtlBrowser(0) -{ - m_propsCtrl = new TwoColumnPropertyControl; - m_propsCtrl->Setup(true, 150); - m_propsCtrl->SetSavedStateKey("MaterialDialog"); - m_propsCtrl->setMinimumWidth(460); - - m_placeHolderLabel = new QLabel(tr("Select a material in the Material Editor hierarchy to view properties")); - m_placeHolderLabel->setMinimumHeight(250); - m_placeHolderLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); - - SEventLog toolEvent(MATERIAL_EDITOR_NAME, "", MATERIAL_EDITOR_VER); - GetIEditor()->GetSettingsManager()->RegisterEvent(toolEvent); - - m_pMatManager = GetIEditor()->GetMaterialManager(); - - m_shaderGenParamsVars = 0; - - m_textureSlots = 0; - - m_pMaterialUI = new CMaterialUI; - - m_bForceReloadPropsCtrl = true; - - m_pMaterialImageListModel.reset(new QMaterialImageListModel); - - m_pMaterialImageListCtrl.reset(new CMaterialImageListCtrl); - m_pMaterialImageListCtrl->setModel(m_pMaterialImageListModel.data()); - - // Immediately create dialog. - OnInitDialog(); - - GetIEditor()->RegisterNotifyListener(this); - m_pMatManager->AddListener(this); - m_propsCtrl->SetUndoCallback(AZStd::bind(&CMaterialDialog::OnUndo, this, AZStd::placeholders::_1)); - m_propsCtrl->SetStoreUndoByItems(false); - - // KDAB_TODO: hack until we have proper signal coming from the IEDitor - connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::awake, this, &CMaterialDialog::UpdateActions); -} - -////////////////////////////////////////////////////////////////////////// -CMaterialDialog::~CMaterialDialog() -{ - m_pMatManager->RemoveListener(this); - GetIEditor()->UnregisterNotifyListener(this); - m_wndMtlBrowser->SetImageListCtrl(NULL); - - delete m_pMaterialUI; - m_vars = 0; - m_publicVars = 0; - m_shaderGenParamsVars = 0; - m_textureSlots = 0; - - m_propsCtrl->ClearUndoCallback(); - m_propsCtrl->RemoveAllItems(); - - SEventLog toolEvent(MATERIAL_EDITOR_NAME, "", MATERIAL_EDITOR_VER); - GetIEditor()->GetSettingsManager()->UnregisterEvent(toolEvent); -} - -BOOL CMaterialDialog::OnInitDialog() -{ - setWindowTitle(tr(LyViewPane::MaterialEditor)); - if (gEnv->p3DEngine) - { - ISurfaceTypeManager* pSurfaceTypeManager = gEnv->p3DEngine->GetMaterialManager()->GetSurfaceTypeManager(); - if (pSurfaceTypeManager) - { - pSurfaceTypeManager->LoadSurfaceTypes(); - } - } - - InitToolbar(IDR_DB_MATERIAL_BAR); - - setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); - - // hide menu bar - menuBar()->hide(); - - // Create status bar. - { - m_statusBar = this->statusBar(); - m_statusBar->setSizeGripEnabled(false); - } - - QSplitter* centralWidget = new QSplitter(Qt::Horizontal, this); - setCentralWidget(centralWidget); - - QSplitter* rightWidget = new QSplitter(Qt::Vertical, centralWidget); - centralWidget->addWidget(rightWidget); - - rightWidget->addWidget(m_propsCtrl); - - m_vars = m_pMaterialUI->CreateVars(); - m_propsCtrl->AddVarBlock(m_vars); - - m_propsCtrl->setEnabled(false); - m_propsCtrl->hide(); - - ////////////////////////////////////////////////////////////////////////// - // Preview Pane - ////////////////////////////////////////////////////////////////////////// - { - rightWidget->insertWidget(0, m_pMaterialImageListCtrl.data()); - - int h = m_pMaterialImageListCtrl->sizeHint().height(); - m_pMaterialImageListCtrl->hide(); - rightWidget->setSizes({h, height() - h }); - } - - rightWidget->addWidget(m_placeHolderLabel); - m_placeHolderLabel->setAlignment(Qt::AlignCenter); - - ////////////////////////////////////////////////////////////////////////// - // Browser Pane - ////////////////////////////////////////////////////////////////////////// - if (!m_wndMtlBrowser) - { - m_wndMtlBrowser = new MaterialBrowserWidget(this); - m_wndMtlBrowser->SetListener(this); - m_wndMtlBrowser->SetImageListCtrl(m_pMaterialImageListCtrl.data()); - //m_wndMtlBrowser->resize(width() / 3, height()); - - centralWidget->insertWidget(0, m_wndMtlBrowser); - - int w = m_wndMtlBrowser->sizeHint().height(); - centralWidget->setSizes({ w, width() - w }); - centralWidget->setStretchFactor(0, 0); - centralWidget->setStretchFactor(1, 1); - - // Start the background processing of material files after the widget has been initialized - m_wndMtlBrowser->StartRecordUpdateJobs(); - } - - // Set the image list control to give stretch priority to the other widgets. This is both to avoid resizing the - // image list control when the window is resized and to avoid an issue with the QSplitter resizing the image list - // control when enabling/disabling the other two widgets. - const int materialImageControlIndex = 0; - const int materialImagePropertiesControlIndex = 1; - const int materialPlaceholderLabelIndex = 2; - rightWidget->setStretchFactor(materialImageControlIndex, 0); - rightWidget->setStretchFactor(materialImagePropertiesControlIndex, 1); - rightWidget->setStretchFactor(materialPlaceholderLabelIndex, 1); - - resize(1200, 800); - - return true; // return true unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void CMaterialDialog::closeEvent(QCloseEvent *ev) -{ - // We call save before running any dtors, as it might trigger a modal dialog / nested event loop - // asking to overwrite files, and that causes a crash - m_wndMtlBrowser->SaveCurrentMaterial(); - ev->accept(); // All good, dialog will close now -} - -////////////////////////////////////////////////////////////////////////// -// Create the toolbar -void CMaterialDialog::InitToolbar([[maybe_unused]] UINT nToolbarResID) -{ - // detect if the new viewport interaction model is enabled and give - // feedback to the user that certain operations are not yet compatible - const bool newViewportInteractionModelEnabled = GetIEditor()->IsNewViewportInteractionModelEnabled(); - const char* const newViewportInteractionModelWarning = - "This option is currently not available with the new Viewport Interaction Model enabled"; - - m_toolbar = addToolBar(tr("Material ToolBar")); - m_toolbar->setFloatable(false); - - QIcon assignselectionIcon; - assignselectionIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_assignselection_normal.png" }, QIcon::Normal); - assignselectionIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_assignselection_active.png" }, QIcon::Active); - assignselectionIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_assignselection_disabled.png" }, QIcon::Disabled); - - m_assignToSelectionAction = - m_toolbar->addAction(assignselectionIcon, - newViewportInteractionModelEnabled - ? tr(newViewportInteractionModelWarning) - : tr("Assign Item to Selected Objects"), - this, SLOT(OnAssignMaterialToSelection())); - - QIcon resetIcon; - resetIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_reset_normal.png" }, QIcon::Normal); - resetIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_reset_active.png" }, QIcon::Active); - resetIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_reset_disabled.png" }, QIcon::Disabled); - - m_resetAction = - m_toolbar->addAction(resetIcon, - newViewportInteractionModelEnabled - ? tr(newViewportInteractionModelWarning) - : tr("Reset Material on Selection to Default"), - this, SLOT(OnResetMaterialOnSelection())); - - QIcon getfromselectionIcon; - getfromselectionIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_getfromselection_normal.png" }, QIcon::Normal); - getfromselectionIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_getfromselection_active.png" }, QIcon::Active); - getfromselectionIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_getfromselection_disabled.png" }, QIcon::Disabled); - - m_getFromSelectionAction = - m_toolbar->addAction( - getfromselectionIcon, - newViewportInteractionModelEnabled - ? tr(newViewportInteractionModelWarning) - : tr("Get Properties From Selection"), - this, SLOT(OnGetMaterialFromSelection())); - - QIcon pickIcon; - pickIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_pick_normal.png" }, QIcon::Normal); - pickIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_pick_active.png" }, QIcon::Active); - pickIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_pick_disabled.png" }, QIcon::Disabled); - - m_pickAction = m_toolbar->addAction( - pickIcon, - newViewportInteractionModelEnabled - ? tr(newViewportInteractionModelWarning) - : tr("Pick Material from Object"), - this, SLOT(OnPickMtl())); - - m_pickAction->setCheckable(true); - - if (newViewportInteractionModelEnabled) - { - m_pickAction->setEnabled(false); - } - - QAction* sepAction = m_toolbar->addSeparator(); - m_filterTypeSelection = new QComboBox(this); - m_filterTypeSelection->addItem(tr("All Materials")); - m_filterTypeSelection->addItem(tr("Used In Level")); - m_filterTypeSelection->setMinimumWidth(150); - QAction* cbAction = m_toolbar->addWidget(m_filterTypeSelection); - m_filterTypeSelection->setCurrentIndex(0); - connect(m_filterTypeSelection, SIGNAL(currentIndexChanged(int)), this, SLOT(OnChangedBrowserListType(int))); - m_toolbar->addSeparator(); - QIcon addIcon; - addIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_add_normal.png" }, QIcon::Normal); - addIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_add_active.png" }, QIcon::Active); - addIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_add_disabled.png" }, QIcon::Disabled); - m_addAction = m_toolbar->addAction(addIcon, tr("Add New Item"), this, SLOT(OnAddItem())); - QIcon saveIcon; - saveIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_save_normal.png" }, QIcon::Normal); - saveIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_save_active.png" }, QIcon::Active); - saveIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_save_disabled.png" }, QIcon::Disabled); - m_saveAction = m_toolbar->addAction(saveIcon, tr("Save Item"), this, SLOT(OnSaveItem())); - QIcon removeIcon; - removeIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_remove_normal.png" }, QIcon::Normal); - removeIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_remove_active.png" }, QIcon::Active); - removeIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_remove_disabled.png" }, QIcon::Disabled); - m_removeAction = m_toolbar->addAction(removeIcon, tr("Remove Item"), this, SLOT(OnDeleteItem())); - m_toolbar->addSeparator(); - QIcon copyIcon; - copyIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_copy_normal.png" }, QIcon::Normal); - copyIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_copy_active.png" }, QIcon::Active); - copyIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_copy_disabled.png" }, QIcon::Disabled); - m_copyAction = m_toolbar->addAction(copyIcon, tr("Copy Material"), this, SLOT(OnCopy())); - QIcon pasteIcon; - pasteIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_paste_normal.png" }, QIcon::Normal); - pasteIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_paste_active.png" }, QIcon::Active); - pasteIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_paste_disabled.png" }, QIcon::Disabled); - m_pasteAction = m_toolbar->addAction(pasteIcon, tr("Paste Material"), this, SLOT(OnPaste())); - m_toolbar->addSeparator(); - QIcon previewIcon; - previewIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_preview_normal.png" }, QIcon::Normal); - previewIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_preview_active.png" }, QIcon::Active); - previewIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_preview_disabled.png" }, QIcon::Disabled); - m_previewAction = m_toolbar->addAction(previewIcon, tr("Open Large Material Preview Window"), this, SLOT(OnMaterialPreview())); - m_toolbar->addSeparator(); - QIcon resetViewportIcon; - resetViewportIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_reset_viewport_normal.png" }, QIcon::Normal); - resetViewportIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_reset_viewport_active.png" }, QIcon::Active); - resetViewportIcon.addPixmap(QPixmap{ ":/MaterialDialog/ToolBar/images/materialdialog_reset_viewport_disabled.png" }, QIcon::Disabled); - m_resetViewporAction = m_toolbar->addAction(resetViewportIcon, tr("Reset Material Viewport"), this, SLOT(OnResetMaterialViewport())); - - UpdateActions(); - setContextMenuPolicy(Qt::ContextMenuPolicy::NoContextMenu); - - connect(m_toolbar, &QToolBar::orientationChanged, m_toolbar, [=](Qt::Orientation orientation) - { - if (orientation == Qt::Vertical) - { - m_toolbar->removeAction(cbAction); - } - else - { - m_toolbar->insertAction(sepAction, cbAction); - } - }); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::ReloadItems() -{ - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnAddItem() -{ - m_wndMtlBrowser->OnAddNewMaterial(); - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnSaveItem() -{ - CMaterial* pMtl = GetSelectedMaterial(); - if (pMtl) - { - CMaterial* parent = pMtl->GetParent(); - - if (!pMtl->Save(false)) - { - if (!parent) - { - QMessageBox::warning(this, QString(), tr("The material file cannot be saved. The file is located in a PAK archive or access is denied")); - } - } - - if (parent) - { - //The reload function will clear all the sub-material references, and re-create them. - //Thus pMtl will point to old sub-material that should be deleted instead. - //So we need to set m_pMatManager's current material to the new one. - int index = -1; - - //Find the corresponding sub-material and record its index - for (int i = 0; i < parent->GetSubMaterialCount(); i++) - { - if (parent->GetSubMaterial(i) == pMtl) - { - index = i; - break; - } - } - pMtl->Reload(); - - if (index >= 0 && index < parent->GetSubMaterialCount()) - { - m_pMatManager->SetCurrentMaterial(parent->GetSubMaterial(index)); - } - else //If we can't find the sub-material, use parent instead - { - m_pMatManager->SetCurrentMaterial(parent); - } - } - else - { - pMtl->Reload(); - } - - } - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnDeleteItem() -{ - m_wndMtlBrowser->DeleteItem(); - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::SetMaterialVars([[maybe_unused]] CMaterial* mtl) -{ -} - - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::UpdateShaderParamsUI(CMaterial* pMtl) -{ - ////////////////////////////////////////////////////////////////////////// - // Shader Gen Mask. - ////////////////////////////////////////////////////////////////////////// - IVariable* shaderGenParamsContainerVar = m_pMaterialUI->tableShaderGenParams.GetVar(); - if (m_propsCtrl->FindVariable(shaderGenParamsContainerVar)) - { - m_shaderGenParamsVars = pMtl->GetShaderGenParamsVars(); - m_propsCtrl->ReplaceVarBlock(shaderGenParamsContainerVar, m_shaderGenParamsVars); - } - - ////////////////////////////////////////////////////////////////////////// - // Shader Public Params. - ////////////////////////////////////////////////////////////////////////// - IVariable* publicVars = m_pMaterialUI->tableShaderParams.GetVar(); - if (m_propsCtrl->FindVariable(publicVars)) - { - bool bNeedUpdateMaterialFromUI = false; - CVarBlockPtr pPublicVars = pMtl->GetPublicVars(pMtl->GetShaderResources()); - if (m_publicVars && pPublicVars) - { - // list of shader parameters depends on list of shader generation parameters - // we need to keep values of vars which not presented in every combinations, - // but probably adjusted by user, to keep his work. - // m_excludedPublicVars is used for these values - if (m_excludedPublicVars.pMaterial) - { - if (m_excludedPublicVars.pMaterial != pMtl) - { - m_excludedPublicVars.vars.DeleteAllVariables(); - } - else - { - // find new presented vars in pPublicVars, which not existed in old m_publicVars - for (int j = pPublicVars->GetNumVariables() - 1; j >= 0; --j) - { - IVariable* pVar = pPublicVars->GetVariable(j); - bool isVarExist = false; - for (int i = m_publicVars->GetNumVariables() - 1; i >= 0; --i) - { - IVariable* pOldVar = m_publicVars->GetVariable(i); - if (!QString::compare(pOldVar->GetName(), pVar->GetName())) - { - isVarExist = true; - break; - } - } - if (!isVarExist) // var exist in new pPublicVars block, but not in previous (m_publicVars) - { - // try to find value for this var inside "excluded vars" collection - for (int i = m_excludedPublicVars.vars.GetNumVariables() - 1; i >= 0; --i) - { - IVariable* pStoredVar = m_excludedPublicVars.vars.GetVariable(i); - if (!QString::compare(pStoredVar->GetName(), pVar->GetName()) && pVar->GetDataType() == pStoredVar->GetDataType()) - { - pVar->CopyValue(pStoredVar); - m_excludedPublicVars.vars.DeleteVariable(pStoredVar); - bNeedUpdateMaterialFromUI = true; - break; - } - } - } - } - } - } - // We only want to collect vars if the old and new block are part of the same - // material, otherwise we are storing state from one material to an other. - if (m_excludedPublicVars.pMaterial == pMtl) - { - // collect excluded vars from old block (m_publicVars) - // which exist in m_publicVars but not in a new generated pPublicVars block - for (int i = m_publicVars->GetNumVariables() - 1; i >= 0; --i) - { - IVariable* pOldVar = m_publicVars->GetVariable(i); - bool isVarExist = false; - for (int j = pPublicVars->GetNumVariables() - 1; j >= 0; --j) - { - IVariable* pVar = pPublicVars->GetVariable(j); - if (!QString::compare(pOldVar->GetName(), pVar->GetName())) - { - isVarExist = true; - break; - } - } - if (!isVarExist) - { - m_excludedPublicVars.vars.AddVariable(pOldVar->Clone(false)); - } - } - } - m_excludedPublicVars.pMaterial = pMtl; - } - - m_publicVars = pPublicVars; - if (m_publicVars) - { - m_publicVars->Sort(); - } - - m_propsCtrl->ReplaceVarBlock(publicVars, m_publicVars); - - if (m_publicVars && bNeedUpdateMaterialFromUI) - { - pMtl->SetPublicVars(m_publicVars, pMtl); - } - } - IVariable* textureSlotsVar = m_pMaterialUI->tableTexture.GetVar(); - if (m_propsCtrl->FindVariable(textureSlotsVar)) - { - m_textureSlots = pMtl->UpdateTextureNames(m_pMaterialUI->textureVars); - m_propsCtrl->ReplaceVarBlock(textureSlotsVar, m_textureSlots); - } - - ////////////////////////////////////////////////////////////////////////// -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::SelectItem(CBaseLibraryItem* item, bool bForceReload) -{ - static bool bNoRecursiveSelect = false; - if (bNoRecursiveSelect) - { - return; - } - - bool bChanged = item != m_pPrevSelectedItem || bForceReload; - - if (!bChanged) - { - return; - } - - m_pPrevSelectedItem = item; - - // Empty preview control. - //m_previewCtrl.SetEntity(0); - m_pMatManager->SetCurrentMaterial((CMaterial*)item); - - if (!item) - { - m_statusBar->clearMessage(); - m_propsCtrl->setEnabled(false); - m_propsCtrl->hide(); - m_pMaterialImageListCtrl->hide(); - m_placeHolderLabel->setText(tr("Select a material in the Material Editor hierarchy to view properties")); - m_placeHolderLabel->show(); - return; - } - - // Render preview geometry with current material - CMaterial* mtl = (CMaterial*)item; - - QString statusText; - if (mtl->IsPureChild() && mtl->GetParent()) - { - statusText = mtl->GetParent()->GetName() + " [" + mtl->GetName() + "]"; - } - else - { - statusText = mtl->GetName(); - } - - - if (mtl->IsDummy()) - { - statusText += " (Not Found)"; - } - else if (!mtl->CanModify()) - { - statusText += " (Read Only)"; - } - m_statusBar->showMessage(statusText); - - if (mtl->IsMultiSubMaterial()) - { - // Cannot edit it. - m_propsCtrl->setEnabled(false); - m_propsCtrl->EnableUpdateCallback(false); - m_propsCtrl->hide(); - - m_placeHolderLabel->setText(tr("Select a material to view properties")); - m_placeHolderLabel->show(); - - //return; - } - else - { - m_propsCtrl->setEnabled(true); - m_propsCtrl->EnableUpdateCallback(false); - m_propsCtrl->show(); - m_placeHolderLabel->hide(); - } - m_pMaterialImageListCtrl->show(); - - if (m_bForceReloadPropsCtrl) - { - // CPropertyCtrlEx skip OnPaint and another methods for redraw - // OnSize method is forced to invalidate control for redraw - m_propsCtrl->InvalidateCtrl(); - m_bForceReloadPropsCtrl = false; - } - - UpdatePreview(); - - // Update variables. - m_propsCtrl->EnableUpdateCallback(false); - m_pMaterialUI->SetFromMaterial(mtl); - m_propsCtrl->EnableUpdateCallback(true); - - mtl->SetShaderParamPublicScript(); - - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // Set Shader Gen Params. - ////////////////////////////////////////////////////////////////////////// - UpdateShaderParamsUI(mtl); - ////////////////////////////////////////////////////////////////////////// - - m_propsCtrl->SetUpdateCallback(AZStd::bind(&CMaterialDialog::OnUpdateProperties, this, AZStd::placeholders::_1)); - m_propsCtrl->EnableUpdateCallback(true); - - if (mtl->IsDummy()) - { - m_propsCtrl->setEnabled(false); - } - else - { - m_propsCtrl->setEnabled(true); - m_propsCtrl->SetGrayed(!mtl->CanModify()); - } - if (mtl) - { - m_pMaterialImageListCtrl->SelectMaterial(mtl); - } -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnUpdateProperties(IVariable* var) -{ - CMaterial* mtl = GetSelectedMaterial(); - if (!mtl) - { - return; - } - - bool bShaderChanged = (m_pMaterialUI->shader == var); - bool bShaderGenMaskChanged = false; - if (m_shaderGenParamsVars) - { - bShaderGenMaskChanged = m_shaderGenParamsVars->IsContainsVariable(var); - } - - bool bMtlLayersChanged = false; - int nCurrLayer = -1; - - // Check for shader changes - for (int l(0); l < MTL_LAYER_MAX_SLOTS; ++l) - { - if ((m_pMaterialUI->materialLayers[l].shader == var)) - { - bMtlLayersChanged = true; - nCurrLayer = l; - break; - } - } - - ////////////////////////////////////////////////////////////////////////// - // Assign modified Shader Gen Params to shader. - ////////////////////////////////////////////////////////////////////////// - if (bShaderGenMaskChanged) - { - mtl->SetShaderGenParamsVars(m_shaderGenParamsVars); - } - ////////////////////////////////////////////////////////////////////////// - // Invalidate material and save changes. - //m_pMatManager->MarkMaterialAsModified(mtl); - // - - mtl->RecordUndo("Material parameter", true); - m_pMaterialUI->SetToMaterial(mtl); - mtl->Update(); - - // - ////////////////////////////////////////////////////////////////////////// - // Assign new public vars to material. - // Must be after material update. - ////////////////////////////////////////////////////////////////////////// - - GetIEditor()->SuspendUndo(); - - if (m_publicVars != NULL && !bShaderChanged) - { - mtl->SetPublicVars(m_publicVars, mtl); - } - - /* - bool bUpdateLayers = false; - for(int l(0); l < MTL_LAYER_MAX_SLOTS; ++l) - { - if ( m_varsMtlLayersShaderParams[l] != NULL && l != nCurrLayer) - { - SMaterialLayerResources *pCurrResource = pTemplateMtl ? &pTemplateMtl->GetMtlLayerResources()[l] : &pMtlLayerResources[l]; - SShaderItem &pCurrShaderItem = pCurrResource->m_pMatLayer->GetShaderItem(); - CVarBlock* pVarBlock = pTemplateMtl ? pTemplateMtl->GetPublicVars( pCurrResource->m_shaderResources ) : m_varsMtlLayersShaderParams[l]; - mtl->SetPublicVars( pVarBlock, pCurrResource->m_shaderResources, pCurrShaderItem.m_pShaderResources, pCurrShaderItem.m_pShader); - bUpdateLayers = true; - } - } - */ - //if( bUpdateLayers ) - { - mtl->UpdateMaterialLayers(); - } - - m_pMaterialUI->PropagateToLinkedMaterial(mtl, m_shaderGenParamsVars); - if (var) - { - GetIEditor()->GetMaterialManager()->HighlightedMaterialChanged(mtl); - m_pMaterialUI->NotifyObjectsAboutMaterialChange(var); - } - - GetIEditor()->ResumeUndo(); - - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - if (bShaderChanged || bShaderGenMaskChanged || bMtlLayersChanged) - { - m_pMaterialUI->SetFromMaterial(mtl); - } - //m_pMaterialUI->SetTextureNames( mtl ); - - UpdatePreview(); - - // When shader changed. - if (bShaderChanged || bShaderGenMaskChanged || bMtlLayersChanged) - { - ////////////////////////////////////////////////////////////////////////// - // Set material layers params - ////////////////////////////////////////////////////////////////////////// - /* - if( bMtlLayersChanged) // only update changed shader in material layers - { - SMaterialLayerResources *pCurrResource = &pMtlLayerResources[nCurrLayer]; - - // delete old property item - if ( m_varsMtlLayersShaderParamsItems[nCurrLayer] ) - { - m_propsCtrl->DeleteItem( m_varsMtlLayersShaderParamsItems[nCurrLayer] ); - m_varsMtlLayersShaderParamsItems[nCurrLayer] = 0; - } - - m_varsMtlLayersShaderParams[nCurrLayer] = mtl->GetPublicVars( pCurrResource->m_shaderResources ); - - if ( m_varsMtlLayersShaderParams[nCurrLayer] ) - { - m_varsMtlLayersShaderParamsItems[nCurrLayer] = m_propsCtrl->AddVarBlockAt( m_varsMtlLayersShaderParams[nCurrLayer], "Shader Params", m_varsMtlLayersShaderItems[nCurrLayer] ); - } - } - */ - - UpdateShaderParamsUI(mtl); - } - - if (bShaderGenMaskChanged || bShaderChanged || bMtlLayersChanged) - { - m_propsCtrl->InvalidateCtrl(); - } - - m_pMaterialImageListModel->InvalidateMaterial(mtl); -} - -////////////////////////////////////////////////////////////////////////// -CMaterial* CMaterialDialog::GetSelectedMaterial() -{ - CBaseLibraryItem* pItem = m_pMatManager->GetCurrentMaterial(); - return (CMaterial*)pItem; -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnAssignMaterialToSelection() -{ - CUndo undo("Assign Material To Selection"); - GetIEditor()->GetMaterialManager()->Command_AssignToSelection(); - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnSelectAssignedObjects() -{ - CUndo undo("Select Objects With Current Material"); - GetIEditor()->GetMaterialManager()->Command_SelectAssignedObjects(); - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnResetMaterialOnSelection() -{ - GetIEditor()->GetMaterialManager()->Command_ResetSelection(); - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnGetMaterialFromSelection() -{ - GetIEditor()->GetMaterialManager()->Command_SelectFromObject(); - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::DeleteItem([[maybe_unused]] CBaseLibraryItem* pItem) -{ - m_wndMtlBrowser->DeleteItem(); - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// - -void CMaterialDialog::UpdateActions() -{ - if (isHidden()) - { - return; - } - - CMaterial* mtl = GetSelectedMaterial(); - if (mtl && mtl->CanModify(false)) - { - m_saveAction->setEnabled(true); - } - else - { - m_saveAction->setEnabled(false); - } - - if (GetIEditor()->GetEditTool() && GetIEditor()->GetEditTool()->GetClassDesc() && QString::compare(GetIEditor()->GetEditTool()->GetClassDesc()->ClassName(), "EditTool.PickMaterial") == 0) - { - m_pickAction->setChecked(true); - } - else - { - m_pickAction->setChecked(false); - } - - if (mtl && (!GetIEditor()->GetSelection()->IsEmpty() || GetIEditor()->IsInPreviewMode())) - { - m_assignToSelectionAction->setEnabled(true); - } - else - { - m_assignToSelectionAction->setEnabled(false); - } - - if (!GetIEditor()->GetSelection()->IsEmpty() || GetIEditor()->IsInPreviewMode()) - { - m_resetAction->setEnabled(true); - m_getFromSelectionAction->setEnabled(true); - } - else - { - m_resetAction->setEnabled(false); - m_getFromSelectionAction->setEnabled(false); - } -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnPickMtl() -{ - if (GetIEditor()->GetEditTool() && QString::compare(GetIEditor()->GetEditTool()->GetClassDesc()->ClassName(), "EditTool.PickMaterial") == 0) - { - GetIEditor()->SetEditTool(NULL); - } - else - { - GetIEditor()->SetEditTool("EditTool.PickMaterial"); - } - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnCopy() -{ - m_wndMtlBrowser->OnCopy(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnPaste() -{ - m_wndMtlBrowser->OnPaste(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnMaterialPreview() -{ - if (!m_pPreviewDlg) - { - m_pPreviewDlg = new CMatEditPreviewDlg(this); - m_pPreviewDlg->show(); - } -} - -////////////////////////////////////////////////////////////////////////// -bool CMaterialDialog::SetItemName(CBaseLibraryItem* item, const QString& groupName, const QString& itemName) -{ - assert(item); - // Make prototype name. - QString fullName = groupName + "/" + itemName; - IDataBaseItem* pOtherItem = m_pMatManager->FindItemByName(fullName); - if (pOtherItem && pOtherItem != item) - { - // Ensure uniqness of name. - Warning("Duplicate Item Name %s", fullName.toUtf8().data()); - return false; - } - else - { - item->SetName(fullName); - } - return true; -} - - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnBrowserSelectItem(IDataBaseItem* pItem, bool bForce) -{ - SelectItem((CBaseLibraryItem*)pItem, bForce); - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::UpdatePreview() -{ -}; - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnChangedBrowserListType(int sel) -{ - m_wndMtlBrowser->ShowOnlyLevelMaterials(sel == 1); - m_pMatManager->SetCurrentMaterial(0); - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnUndo(IVariable* pVar) -{ - if (!m_pMatManager->GetCurrentMaterial()) - { - return; - } - - QString undoName; - if (pVar) - { - undoName = tr("%1 modified").arg(pVar->GetName()); - } - else - { - undoName = tr("Material parameter was modified"); - } - - if (!CUndo::IsRecording()) - { - if (!CUndo::IsSuspended()) - { - CUndo undo(undoName.toUtf8().data()); - m_pMatManager->GetCurrentMaterial()->RecordUndo(undoName.toUtf8().data(), true); - } - } - UpdateActions(); -} - -////////////////////////////////////////////////////////////////////////// -void CMaterialDialog::OnDataBaseItemEvent(IDataBaseItem* pItem, EDataBaseItemEvent event) -{ - switch (event) - { - case EDB_ITEM_EVENT_UPDATE_PROPERTIES: - if (pItem && pItem == m_pMatManager->GetCurrentMaterial()) - { - SelectItem(m_pMatManager->GetCurrentMaterial(), true); - } - break; - } -} - -// If an object is selected or de-selected, update the available actions in the Material Editor toolbar -void CMaterialDialog::OnEditorNotifyEvent(EEditorNotifyEvent event) -{ - switch (event) - { - case eNotify_OnSelectionChange: - UpdateActions(); - break; - case eNotify_OnCloseScene: - case eNotify_OnEndNewScene: - case eNotify_OnEndSceneOpen: - m_filterTypeSelection->setCurrentIndex(0); - break; - } -} - -void CMaterialDialog::OnResetMaterialViewport() -{ - m_pMaterialImageListCtrl->LoadModel(); -} - -#include diff --git a/Code/Sandbox/Editor/Material/MaterialDialog.h b/Code/Sandbox/Editor/Material/MaterialDialog.h deleted file mode 100644 index 48e68e2322..0000000000 --- a/Code/Sandbox/Editor/Material/MaterialDialog.h +++ /dev/null @@ -1,176 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#pragma once - -#if !defined(Q_MOC_RUN) -#include "MaterialBrowser.h" - -#include -#include -#include -#endif - -static const char* MATERIAL_EDITOR_NAME = "Material Editor"; -static const char* MATERIAL_EDITOR_VER = "1.00"; - - -class QComboBox; -class QLabel; - -class CMaterial; -class CMaterialManager; -class CMatEditPreviewDlg; -class CMaterialSender; -class CMaterialImageListCtrl; -class QMaterialImageListModel; -class TwoColumnPropertyControl; - -/** Dialog which hosts entity prototype library. -*/ - - -struct SMaterialExcludedVars -{ - CMaterial* pMaterial; - CVarBlock vars; - - SMaterialExcludedVars() - : pMaterial(nullptr) - { - } -}; - - -class CMaterialDialog - : public QMainWindow - , public IMaterialBrowserListener - , public IDataBaseManagerListener - , public IEditorNotifyListener -{ - Q_OBJECT -public: - CMaterialDialog(QWidget* parent = 0); - ~CMaterialDialog(); - - static void RegisterViewClass(); - static const GUID& GetClassID(); - -public slots: - void OnAssignMaterialToSelection(); - void OnResetMaterialOnSelection(); - void OnGetMaterialFromSelection(); - -protected: - BOOL OnInitDialog(); - void closeEvent(QCloseEvent *ev) override; - -protected slots: - void OnAddItem(); - void OnDeleteItem(); - void OnSaveItem(); - void OnPickMtl(); - void OnCopy(); - void OnPaste(); - void OnMaterialPreview(); - void OnSelectAssignedObjects(); - void OnChangedBrowserListType(int); - void OnResetMaterialViewport(); - - void UpdateActions(); - -protected: - ////////////////////////////////////////////////////////////////////////// - // Some functions can be overriden to modify standart functionality. - ////////////////////////////////////////////////////////////////////////// - virtual void InitToolbar(UINT nToolbarResID); - - virtual void SelectItem(CBaseLibraryItem* item, bool bForceReload = false); - virtual void DeleteItem(CBaseLibraryItem* pItem); - virtual bool SetItemName(CBaseLibraryItem* item, const QString& groupName, const QString& itemName); - virtual void ReloadItems(); - - ////////////////////////////////////////////////////////////////////////// - // IMaterialBrowserListener implementation. - ////////////////////////////////////////////////////////////////////////// - virtual void OnBrowserSelectItem(IDataBaseItem* pItem, bool bForce); - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // IDataBaseManagerListener implementation. - ////////////////////////////////////////////////////////////////////////// - virtual void OnDataBaseItemEvent(IDataBaseItem* pItem, EDataBaseItemEvent event); - ////////////////////////////////////////////////////////////////////////// - - // IEditorNotifyListener implementation. - virtual void OnEditorNotifyEvent(EEditorNotifyEvent event); - - ////////////////////////////////////////////////////////////////////////// - CMaterial* GetSelectedMaterial(); - void OnUpdateProperties(IVariable* var); - void OnUndo(IVariable* pVar); - - void UpdateShaderParamsUI(CMaterial* pMtl); - - void UpdatePreview(); - - //void SetTextureVars( CVariableArray *texVar,CMaterial *mtl,int id,const CString &name ); - void SetMaterialVars(CMaterial* mtl); - - MaterialBrowserWidget* m_wndMtlBrowser; - - QStatusBar* m_statusBar; - //CXTCaption m_wndCaption; - - TwoColumnPropertyControl* m_propsCtrl; - bool m_bForceReloadPropsCtrl; - - QLabel* m_placeHolderLabel; - - CBaseLibraryItem* m_pPrevSelectedItem; - - // Material manager. - CMaterialManager* m_pMatManager; - - CVarBlockPtr m_vars; - CVarBlockPtr m_publicVars; - - // collection of excluded vars from m_publicVars for remembering values - // when updating shader params - SMaterialExcludedVars m_excludedPublicVars; - - CVarBlockPtr m_shaderGenParamsVars; - CVarBlockPtr m_textureSlots; - - class CMaterialUI* m_pMaterialUI; - - QPointer m_pPreviewDlg; - - QScopedPointer m_pMaterialImageListCtrl; - QScopedPointer m_pMaterialImageListModel; - - QToolBar* m_toolbar; - QComboBox* m_filterTypeSelection; - QAction* m_addAction; - QAction* m_assignToSelectionAction; - QAction* m_copyAction; - QAction* m_getFromSelectionAction; - QAction* m_pasteAction; - QAction* m_pickAction; - QAction* m_previewAction; - QAction* m_removeAction; - QAction* m_resetAction; - QAction* m_saveAction; - QAction* m_resetViewporAction; -}; - diff --git a/Code/Sandbox/Editor/Material/MaterialDialog.qrc b/Code/Sandbox/Editor/Material/MaterialDialog.qrc index 43bfbd6ea0..c99e5b052a 100644 --- a/Code/Sandbox/Editor/Material/MaterialDialog.qrc +++ b/Code/Sandbox/Editor/Material/MaterialDialog.qrc @@ -1,39 +1,4 @@ - - images/materialdialog_add_disabled.png - images/materialdialog_copy_disabled.png - images/materialdialog_paste_disabled.png - images/materialdialog_preview_disabled.png - images/materialdialog_remove_disabled.png - images/materialdialog_save_disabled.png - images/materialdialog_assignselection_disabled.png - images/materialdialog_getfromselection_disabled.png - images/materialdialog_pick_disabled.png - images/materialdialog_reset_disabled.png - images/materialdialog_assignselection_active.png - images/materialdialog_assignselection_normal.png - images/materialdialog_add_active.png - images/materialdialog_add_normal.png - images/materialdialog_copy_active.png - images/materialdialog_copy_normal.png - images/materialdialog_getfromselection_active.png - images/materialdialog_getfromselection_normal.png - images/materialdialog_paste_active.png - images/materialdialog_paste_normal.png - images/materialdialog_pick_active.png - images/materialdialog_pick_normal.png - images/materialdialog_preview_active.png - images/materialdialog_preview_normal.png - images/materialdialog_remove_active.png - images/materialdialog_remove_normal.png - images/materialdialog_reset_active.png - images/materialdialog_reset_normal.png - images/materialdialog_save_active.png - images/materialdialog_save_normal.png - images/materialdialog_reset_viewport_active.png - images/materialdialog_reset_viewport_disabled.png - images/materialdialog_reset_viewport_normal.png - images/material_browser_00.png images/material_browser_01.png diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_add.png b/Code/Sandbox/Editor/Material/images/materialdialog_add.png deleted file mode 100644 index aa8d657f23..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_add.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:703f6875258486629bc1db68ce80fe1653f0d2876cd1252d03f72f6eae04dd84 -size 392 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_add_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_add_active.png deleted file mode 100644 index 467365d1ad..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_add_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3f3c05f8425956e9c1e380fde9a65df8f0d341868900a3589d9f629f34a0ddf6 -size 251 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_add_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_add_disabled.png deleted file mode 100644 index 399e45469e..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_add_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:25554e93a4f0d9b904a2a3628c315ee55c0ad8831bb5891a9d7e27e5cb9a5416 -size 261 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_add_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_add_normal.png deleted file mode 100644 index 1eb8d63ef5..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_add_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b2ee886c6e487a6490361609fdd44c64438e40c7e5a4c40fda866ec399ec4727 -size 256 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_assignselection.png b/Code/Sandbox/Editor/Material/images/materialdialog_assignselection.png deleted file mode 100644 index 72fdb0537a..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_assignselection.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:943ff19774cbe8d47c1e8001a48e6d137fdac2c0af63c9092911c37be0d6d6a8 -size 471 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_assignselection_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_assignselection_active.png deleted file mode 100644 index 605107f750..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_assignselection_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:400d669d7a658968549f6ee776ee415b871b207c444d8797a404b76d536131b1 -size 325 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_assignselection_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_assignselection_disabled.png deleted file mode 100644 index 3505f577a4..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_assignselection_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:02bdc8aad92bb75b118c4a703a3e5b1369376620b3836a125faedc7f6b42b49b -size 330 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_assignselection_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_assignselection_normal.png deleted file mode 100644 index 0e9c984e1d..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_assignselection_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:38097d3041defeec0179390a73bb463e54e7f4c1f0b1a20e77ab3f69ea9cf13c -size 332 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_copy.png b/Code/Sandbox/Editor/Material/images/materialdialog_copy.png deleted file mode 100644 index 08fc0c6987..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_copy.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e1d9fe8e97655bf776b20e242d66900980721ba2f3ee93c02cd4062a8b872eed -size 433 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_copy_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_copy_active.png deleted file mode 100644 index 67a010be86..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_copy_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:468b68c44d8ef183b292c1bc6ca4dc583357f693db9ea2cd198fb2af22537be1 -size 249 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_copy_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_copy_disabled.png deleted file mode 100644 index d585dbae6e..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_copy_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b27a1346f2edebe34ee06d7892a467bfc67952d0f8e4458e09a74a6dbf62fe98 -size 336 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_copy_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_copy_normal.png deleted file mode 100644 index 4b42f5c9a2..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_copy_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c3f40524a96689b8c8549bc662415df654494baeeda6eed47e66b455ac902eeb -size 254 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection.png b/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection.png deleted file mode 100644 index 76c343a718..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cebe97de0d879d239fcd61595fd28b73760aa6452dcf4dabc54bfe034e2e33c1 -size 476 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection_active.png deleted file mode 100644 index cc58f4f767..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:699ee40aeedfc50b7766e94ef66e645762eb183ddd6ce134b4bdab01c3957ab9 -size 327 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection_disabled.png deleted file mode 100644 index 6e4a425058..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5f1fd8a7cecb22901c6d73f2e6129f3bada0f94cf73d9a8fd2676a972faa5719 -size 348 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection_normal.png deleted file mode 100644 index 1c319c319d..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_getfromselection_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d432de9e921d23fbbf3c1b805f644b9554aa206011a87c063d167c30c7c4579e -size 335 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_paste.png b/Code/Sandbox/Editor/Material/images/materialdialog_paste.png deleted file mode 100644 index 95740d44d8..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_paste.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c006e70efd8bdb1dd5aac867db9d97de587e8d518ba0693d19c319e34a74c7d0 -size 501 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_paste_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_paste_active.png deleted file mode 100644 index aabb4f2520..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_paste_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:00c291361664d357502f5267fccd0a6fff0c3f2e906c0402d57ad9fa5ca7f023 -size 255 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_paste_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_paste_disabled.png deleted file mode 100644 index 9abc336f71..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_paste_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d68fc8604a23eb3bcc0cac9bb6e83dd4dc4cdab70b0bdaec3c456559727c6b5b -size 354 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_paste_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_paste_normal.png deleted file mode 100644 index 158bf9d690..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_paste_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4055c7f029d7711e5c32f3f74901bf1dcc1540fd2c0f3f30dc74743d7f2cc042 -size 355 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_pick.png b/Code/Sandbox/Editor/Material/images/materialdialog_pick.png deleted file mode 100644 index e08b45ac66..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_pick.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:99e2c0378137bef94eb6f281e0168852540bf1ca823b9bcd4365ef2849db9956 -size 420 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_pick_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_pick_active.png deleted file mode 100644 index 392b4ab63e..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_pick_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:34075016c93f1914fe4d12ead7c5ee322a18466f08a476eff7c127e4e1429224 -size 290 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_pick_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_pick_disabled.png deleted file mode 100644 index 865a91152d..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_pick_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:dc289621f8a9d3e714cd985651d7d6f20495fb7be46e1f60c283d8920c730d0b -size 307 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_pick_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_pick_normal.png deleted file mode 100644 index 5c1086b22d..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_pick_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7e9d5c878acf9fee4252cb854f192690d3f50d46dc4e5f5b1b5812b79fc2cdf7 -size 296 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_preview.png b/Code/Sandbox/Editor/Material/images/materialdialog_preview.png deleted file mode 100644 index c7d79780ee..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_preview.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e2e912c40f07ca3d2a9b2aa1c5caf3acc181436b6a1b560fc021450701331b4c -size 403 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_preview_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_preview_active.png deleted file mode 100644 index d2e1d8230d..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_preview_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:00663e473803ba6c2798c494676b0a65fd62d7484f6d7b51d9fc8955ad586477 -size 273 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_preview_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_preview_disabled.png deleted file mode 100644 index 56716582bb..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_preview_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:34b7d5520cfc8f00ff580558db4f0ec4297458d310321471204daa8678db5fc1 -size 298 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_preview_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_preview_normal.png deleted file mode 100644 index f54cd90c2a..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_preview_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7bca1a8811739949aa2e87486f8697dfae5bc5238894dd1b95ae80aa6f80d517 -size 279 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_remove.png b/Code/Sandbox/Editor/Material/images/materialdialog_remove.png deleted file mode 100644 index d530169b78..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_remove.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:db86d857b651a2fec80418f8b251447bb3fcf4c0cf64bdee12c3b656adbde29a -size 422 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_remove_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_remove_active.png deleted file mode 100644 index 78ec0e0806..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_remove_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fef72444f077879d5c0186c9583f67aa45aafc23214d9e7de90a7c595609270f -size 258 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_remove_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_remove_disabled.png deleted file mode 100644 index a69ef52e75..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_remove_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d2117fda3ed6a28032ae8f03ed7f9a7a0960f4691e49903c63b2150027dfe1ea -size 302 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_remove_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_remove_normal.png deleted file mode 100644 index b84a504285..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_remove_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:06b384ecc11ed2547a9bf466f585889d647c29a4883840070e444a382e80c41c -size 266 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_reset.png b/Code/Sandbox/Editor/Material/images/materialdialog_reset.png deleted file mode 100644 index e2eedad0bf..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_reset.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4b9ee01e7fe2f19b0e736efe09c2b81d3243e369375b4f26346e6abd499e54a6 -size 476 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_reset_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_reset_active.png deleted file mode 100644 index e86ed4dcb8..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_reset_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:935a041332be1fe11ed01c09a3cd367fb9ede7e7eb04909614943f80e741d35f -size 334 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_reset_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_reset_disabled.png deleted file mode 100644 index 2e4e403a30..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_reset_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2b343233ab25a73fcdb4fff5509011497814fc4cb591065bdb3043a0f1092577 -size 342 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_reset_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_reset_normal.png deleted file mode 100644 index 8d8b8a1bd9..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_reset_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1cc0183d7f57f15c4efeffb32795921f2f4e9c7965955fd0a392f826d5f6b6c8 -size 337 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_reset_viewport_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_reset_viewport_active.png deleted file mode 100644 index 41590634f5..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_reset_viewport_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9a8467c1dcc343f637e0f7f5071a20b8881a43d567fb32fd96f5383f7b69bbb6 -size 430 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_reset_viewport_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_reset_viewport_disabled.png deleted file mode 100644 index c6518416c0..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_reset_viewport_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0fd5ec79fc2c679f99ac5eb63d725f2cc815b09286bd0f3b5d2921eeb2e1e8cc -size 406 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_reset_viewport_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_reset_viewport_normal.png deleted file mode 100644 index eef1d5236f..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_reset_viewport_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3e19713b6586581d2336e833d8ecbd78b4b8f15b1c49a29d80acbf05e8aae3df -size 418 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_save.png b/Code/Sandbox/Editor/Material/images/materialdialog_save.png deleted file mode 100644 index 4408a8ba1d..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_save.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4de0f4a102e5c4990d5d23e22b5cdd16532192f3a125758b608cd8c731278898 -size 355 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_save_active.png b/Code/Sandbox/Editor/Material/images/materialdialog_save_active.png deleted file mode 100644 index b0961d34a9..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_save_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d0b6f7c69112d124eac1123ffa840268c16148fef9ded3a67f84d3ad8d73eb96 -size 212 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_save_disabled.png b/Code/Sandbox/Editor/Material/images/materialdialog_save_disabled.png deleted file mode 100644 index cc694f079f..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_save_disabled.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0b795fb88a6f301d7ecc9ce75141bdcf9e6dca25043730661aa4d1f09b055d6f -size 222 diff --git a/Code/Sandbox/Editor/Material/images/materialdialog_save_normal.png b/Code/Sandbox/Editor/Material/images/materialdialog_save_normal.png deleted file mode 100644 index 6293be8be5..0000000000 --- a/Code/Sandbox/Editor/Material/images/materialdialog_save_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:88fbce753cdd9381a814e3b2ec5d16df7cc26f2a37ad30b7010be71ae9183510 -size 214 diff --git a/Code/Sandbox/Editor/editor_lib_files.cmake b/Code/Sandbox/Editor/editor_lib_files.cmake index 9084a566ae..c91d6ce428 100644 --- a/Code/Sandbox/Editor/editor_lib_files.cmake +++ b/Code/Sandbox/Editor/editor_lib_files.cmake @@ -316,8 +316,6 @@ set(FILES Material/MaterialHelpers.cpp Material/MaterialHelpers.h Material/MaterialDialog.qrc - Material/MaterialDialog.cpp - Material/MaterialDialog.h Material/MaterialPreviewModelView.cpp Material/MaterialPreviewModelView.h Material/PreviewModelView.cpp @@ -632,8 +630,6 @@ set(FILES LensFlareEditor/LensFlareView.h LogFileImpl.cpp LogFileImpl.h - MatEditMainDlg.cpp - MatEditMainDlg.h MatEditPreviewDlg.cpp MatEditPreviewDlg.h Material/MaterialBrowser.cpp From 4232fa4232cbb71c2302e5de387489fa48e45590 Mon Sep 17 00:00:00 2001 From: spham Date: Mon, 19 Apr 2021 14:52:13 -0700 Subject: [PATCH 08/32] - Renamed install-awscli.sh to install-ubuntu-awscli.sh - Update to use $EUID instead of 'whoami' to determine if script is running as sudo - Tagging cmake version 3.20.1 specifically --- .../Linux/{install-awscli.sh => install-ubuntu-awscli.sh} | 2 +- .../Platform/Linux/install-ubuntu-build-libraries.sh | 2 +- .../Platform/Linux/install-ubuntu-build-tools.sh | 7 ++++--- .../build/build_node/Platform/Linux/install-ubuntu-git.sh | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) rename scripts/build/build_node/Platform/Linux/{install-awscli.sh => install-ubuntu-awscli.sh} (97%) diff --git a/scripts/build/build_node/Platform/Linux/install-awscli.sh b/scripts/build/build_node/Platform/Linux/install-ubuntu-awscli.sh similarity index 97% rename from scripts/build/build_node/Platform/Linux/install-awscli.sh rename to scripts/build/build_node/Platform/Linux/install-ubuntu-awscli.sh index c9addedc82..4c2f350859 100644 --- a/scripts/build/build_node/Platform/Linux/install-awscli.sh +++ b/scripts/build/build_node/Platform/Linux/install-ubuntu-awscli.sh @@ -10,7 +10,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # This script must be run as root -if [ "`whoami`" != "root" ] +if [[ $EUID -ne 0 ]] then echo "This script must be run as root (sudo)" exit 1 diff --git a/scripts/build/build_node/Platform/Linux/install-ubuntu-build-libraries.sh b/scripts/build/build_node/Platform/Linux/install-ubuntu-build-libraries.sh index 7b78a53802..90786a675a 100644 --- a/scripts/build/build_node/Platform/Linux/install-ubuntu-build-libraries.sh +++ b/scripts/build/build_node/Platform/Linux/install-ubuntu-build-libraries.sh @@ -10,7 +10,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # This script must be run as root -if [ "`whoami`" != "root" ] +if [[ $EUID -ne 0 ]] then echo "This script must be run as root (sudo)" exit 1 diff --git a/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh b/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh index eb9229d90b..0b341c089e 100644 --- a/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh +++ b/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh @@ -10,7 +10,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # This script must be run as root -if [ "`whoami`" != "root" ] +if [[ $EUID -ne 0 ]] then echo "This script must be run as root (sudo)" exit 1 @@ -41,7 +41,8 @@ fi # # Always install the latest version of cmake (from kitware) # -echo Installing the latest version of CMake +CMAKE_DISTRO_VERSION=3.20.1-0kitware1ubuntu20.04.1 +echo Installing CMake package $CMAKE_DISTRO_VERSION # Remove any pre-existing version of cmake apt purge --auto-remove cmake -y @@ -59,7 +60,7 @@ fi apt-get update # Install cmake -apt-get install cmake -y +apt-get install cmake $CMAKE_DISTRO_VERSION -y # diff --git a/scripts/build/build_node/Platform/Linux/install-ubuntu-git.sh b/scripts/build/build_node/Platform/Linux/install-ubuntu-git.sh index a1c2923c13..53554f4175 100644 --- a/scripts/build/build_node/Platform/Linux/install-ubuntu-git.sh +++ b/scripts/build/build_node/Platform/Linux/install-ubuntu-git.sh @@ -10,7 +10,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # This script must be run as root -if [ "`whoami`" != "root" ] +if [[ $EUID -ne 0 ]] then echo "This script must be run as root (sudo)" exit 1 From 86be2647c59251bfcf9e70307334fc577a6598f9 Mon Sep 17 00:00:00 2001 From: spham Date: Mon, 19 Apr 2021 14:56:54 -0700 Subject: [PATCH 09/32] Fix apt-get command for installing specific version of cmake based on distro of ubuntu --- .../build_node/Platform/Linux/install-ubuntu-build-tools.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh b/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh index 0b341c089e..36832bb9ac 100644 --- a/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh +++ b/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh @@ -41,7 +41,6 @@ fi # # Always install the latest version of cmake (from kitware) # -CMAKE_DISTRO_VERSION=3.20.1-0kitware1ubuntu20.04.1 echo Installing CMake package $CMAKE_DISTRO_VERSION # Remove any pre-existing version of cmake @@ -52,9 +51,11 @@ CMAKE_DEB_REPO="'deb https://apt.kitware.com/ubuntu/ $UBUNTU_DISTRO main'" # Add the appropriate kitware repository to apt if [ "$UBUNTU_DISTRO" == "bionic" ] then + CMAKE_DISTRO_VERSION=3.20.1-0kitware1ubuntu20.04.1 apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' elif [ "$UBUNTU_DISTRO" == "focal" ] then + CMAKE_DISTRO_VERSION=3.20.1-0kitware1ubuntu18.04.1 apt-add-repository 'deb https://apt.kitware.com/ubuntu/ focal main' fi apt-get update From 8fc69113c9d91a7fd64948787488e8f742962b3a Mon Sep 17 00:00:00 2001 From: nvsickle Date: Mon, 19 Apr 2021 15:08:06 -0700 Subject: [PATCH 10/32] Get the default viewport context on demand in FFont, as it may change --- .../AtomLyIntegration/AtomFont/FFont.h | 31 ++--------------- .../AtomFont/Code/Source/FFont.cpp | 33 +++++++++++++------ 2 files changed, 26 insertions(+), 38 deletions(-) diff --git a/Gems/AtomLyIntegration/AtomFont/Code/Include/AtomLyIntegration/AtomFont/FFont.h b/Gems/AtomLyIntegration/AtomFont/Code/Include/AtomLyIntegration/AtomFont/FFont.h index 96f5e09fc3..a6066984c7 100644 --- a/Gems/AtomLyIntegration/AtomFont/Code/Include/AtomLyIntegration/AtomFont/FFont.h +++ b/Gems/AtomLyIntegration/AtomFont/Code/Include/AtomLyIntegration/AtomFont/FFont.h @@ -277,11 +277,11 @@ namespace AZ void ScaleCoord(const RHI::Viewport& viewport, float& x, float& y) const; - void InitDefaultWindowContext(); - void InitDefaultViewportContext(); - void OnBootstrapSceneReady(AZ::RPI::Scene* bootstrapScene) override; + RPI::WindowContextSharedPtr GetDefaultWindowContext() const; + RPI::ViewportContextPtr GetDefaultViewportContext() const; + private: static constexpr uint32_t NumBuffers = 2; static constexpr float WindowScaleWidth = 800.0f; @@ -294,9 +294,6 @@ namespace AZ size_t m_fontBufferSize = 0; unsigned char* m_fontBuffer = nullptr; - AZStd::shared_ptr m_defaultWindowContext; - AZStd::shared_ptr m_defaultViewportContext; - AZ::Data::Instance m_fontStreamingImage; AZ::RHI::Ptr m_fontImage; uint32_t m_fontImageVersion = 0; @@ -345,26 +342,4 @@ namespace AZ } } -inline void AZ::FFont::InitDefaultWindowContext() -{ - if (!m_defaultWindowContext) - { - // font is created before window & viewport in the editor so need to do late init - // TODO need to deal with multiple windows, such as the editor - AZ::Render::Bootstrap::DefaultWindowBus::BroadcastResult(m_defaultWindowContext, &AZ::Render::Bootstrap::DefaultWindowInterface::GetDefaultWindowContext); - AZ_Assert(m_defaultWindowContext, "Unable to get the main window context"); - } -} - -inline void AZ::FFont::InitDefaultViewportContext() -{ - if (!m_defaultViewportContext) - { - // font is created before window & viewport in the editor so need to do late init - auto viewContextManager = AZ::Interface::Get(); - m_defaultViewportContext = viewContextManager->GetViewportContextByName(viewContextManager->GetDefaultViewportContextName()); - AZ_Assert(m_defaultViewportContext, "Unable to get the viewport context"); - } -} - #endif diff --git a/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp b/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp index d32302a07b..38024393fa 100644 --- a/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp +++ b/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp @@ -84,6 +84,20 @@ AZ::FFont::FFont(AtomFont* atomFont, const char* fontName) AZ::Render::Bootstrap::NotificationBus::Handler::BusConnect(); } +AZ::RPI::ViewportContextPtr AZ::FFont::GetDefaultViewportContext() const +{ + auto viewContextManager = AZ::Interface::Get(); + return viewContextManager->GetDefaultViewportContext(); +} + +AZ::RPI::WindowContextSharedPtr AZ::FFont::GetDefaultWindowContext() const +{ + if (auto defaultViewportContext = GetDefaultViewportContext()) + { + return defaultViewportContext->GetWindowContext(); + } + return {}; +} bool AZ::FFont::InitFont() { @@ -92,11 +106,8 @@ bool AZ::FFont::InitFont() return true; } - InitDefaultWindowContext(); - InitDefaultViewportContext(); - // Create and initialize DynamicDrawContext for font draw - AZ::RPI::Ptr dynamicDraw = m_atomFont->GetOrCreateDynamicDrawForScene(m_defaultViewportContext->GetRenderScene().get()); + AZ::RPI::Ptr dynamicDraw = m_atomFont->GetOrCreateDynamicDrawForScene(GetDefaultViewportContext()->GetRenderScene().get()); // Save draw srg input indices for later use Data::Instance drawSrg = dynamicDraw->NewDrawSrg(); @@ -259,7 +270,7 @@ void AZ::FFont::DrawString(float x, float y, const char* str, const bool asciiMu return; } - DrawStringUInternal(m_defaultWindowContext->GetViewport(), m_defaultViewportContext.get(), x, y, 1.0f, str, asciiMultiLine, ctx); + DrawStringUInternal(GetDefaultWindowContext()->GetViewport(), GetDefaultViewportContext().get(), x, y, 1.0f, str, asciiMultiLine, ctx); } void AZ::FFont::DrawString(float x, float y, float z, const char* str, const bool asciiMultiLine, const TextDrawContext& ctx) @@ -269,7 +280,7 @@ void AZ::FFont::DrawString(float x, float y, float z, const char* str, const boo return; } - DrawStringUInternal(m_defaultWindowContext->GetViewport(), m_defaultViewportContext.get(), x, y, z, str, asciiMultiLine, ctx); + DrawStringUInternal(GetDefaultWindowContext()->GetViewport(), GetDefaultViewportContext().get(), x, y, z, str, asciiMultiLine, ctx); } void AZ::FFont::DrawStringUInternal( @@ -282,6 +293,8 @@ void AZ::FFont::DrawStringUInternal( const bool asciiMultiLine, const TextDrawContext& ctx) { + InitFont(); + if (!str || !m_vertexBuffer // vertex buffer isn't created until BootstrapScene is ready, Editor tries to render text before that. || !m_fontTexture @@ -400,7 +413,7 @@ Vec2 AZ::FFont::GetTextSize(const char* str, const bool asciiMultiLine, const Te return Vec2(0.0f, 0.0f); } - return GetTextSizeUInternal(m_defaultWindowContext->GetViewport(), str, asciiMultiLine, ctx); + return GetTextSizeUInternal(GetDefaultWindowContext()->GetViewport(), str, asciiMultiLine, ctx); } Vec2 AZ::FFont::GetTextSizeUInternal( @@ -746,7 +759,7 @@ uint32_t AZ::FFont::WriteTextQuadsToBuffers(SVF_P2F_C4B_T2F_F4B* verts, uint16_t return true; }; - CreateQuadsForText(m_defaultWindowContext->GetViewport(), x, y, z, str, asciiMultiLine, ctx, AddQuad); + CreateQuadsForText(GetDefaultWindowContext()->GetViewport(), x, y, z, str, asciiMultiLine, ctx, AddQuad); return numQuadsWritten; } @@ -1438,7 +1451,7 @@ void AZ::FFont::AddCharsToFontTexture(const char* chars, int glyphSizeX, int gly Vec2 AZ::FFont::GetKerning(uint32_t leftGlyph, uint32_t rightGlyph, const TextDrawContext& ctx) const { - return GetKerningInternal(m_defaultWindowContext->GetViewport(), leftGlyph, rightGlyph, ctx); + return GetKerningInternal(GetDefaultWindowContext()->GetViewport(), leftGlyph, rightGlyph, ctx); } Vec2 AZ::FFont::GetKerningInternal(const RHI::Viewport& viewport, uint32_t leftGlyph, uint32_t rightGlyph, const TextDrawContext& ctx) const @@ -1454,7 +1467,7 @@ float AZ::FFont::GetAscender(const TextDrawContext& ctx) const float AZ::FFont::GetBaseline(const TextDrawContext& ctx) const { - return GetBaselineInternal(m_defaultWindowContext->GetViewport(), ctx); + return GetBaselineInternal(GetDefaultWindowContext()->GetViewport(), ctx); } float AZ::FFont::GetBaselineInternal(const RHI::Viewport& viewport, const TextDrawContext& ctx) const From c05d4b44e4789eafdad6168bba28e46870d257cd Mon Sep 17 00:00:00 2001 From: nvsickle Date: Mon, 19 Apr 2021 15:08:40 -0700 Subject: [PATCH 11/32] Move supplemental EditorViewportWidget rendering to OnBeginPrepareRender to avoid sync issues --- Code/Sandbox/Editor/EditorViewportWidget.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Code/Sandbox/Editor/EditorViewportWidget.cpp b/Code/Sandbox/Editor/EditorViewportWidget.cpp index 695a0fa5f1..897b3c569d 100644 --- a/Code/Sandbox/Editor/EditorViewportWidget.cpp +++ b/Code/Sandbox/Editor/EditorViewportWidget.cpp @@ -276,9 +276,6 @@ void EditorViewportWidget::paintEvent([[maybe_unused]] QPaintEvent* event) if ((ge && ge->IsLevelLoaded()) || (GetType() != ET_ViewportCamera)) { setRenderOverlayVisible(true); - m_isOnPaint = true; - Update(); - m_isOnPaint = false; } else { @@ -809,6 +806,10 @@ void EditorViewportWidget::OnBeginPrepareRender() return; } + m_isOnPaint = true; + Update(); + m_isOnPaint = false; + float fNearZ = GetIEditor()->GetConsoleVar("cl_DefaultNearPlane"); float fFarZ = m_Camera.GetFarPlane(); From 482e423ec9294a416697a37f0f08054814963b55 Mon Sep 17 00:00:00 2001 From: nvsickle Date: Fri, 16 Apr 2021 12:00:13 -0700 Subject: [PATCH 12/32] Fix crash on default layout restore --- Code/Sandbox/Editor/LayoutWnd.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Code/Sandbox/Editor/LayoutWnd.cpp b/Code/Sandbox/Editor/LayoutWnd.cpp index 56c0bcb849..dc3ae14d90 100644 --- a/Code/Sandbox/Editor/LayoutWnd.cpp +++ b/Code/Sandbox/Editor/LayoutWnd.cpp @@ -418,8 +418,9 @@ void CLayoutWnd::CreateLayout(EViewLayout layout, bool bBindViewports, EViewport QRect rcView = rect(); rcView.setBottom(rcView.bottom() - m_infoBar->height()); + // Ensure we delete our old view immediately so it can relinquish its backing ViewportContext if (m_maximizedView) - m_maximizedView->deleteLater(); + delete m_maximizedView; m_maximizedView = new CLayoutViewPane(this); m_maximizedView->SetId(0); From d2fadcb0e37bc78b035e9b0cb3c37fa960a7b190 Mon Sep 17 00:00:00 2001 From: nvsickle Date: Fri, 16 Apr 2021 12:02:55 -0700 Subject: [PATCH 13/32] Fix context menu handling in multi-viewport scenarios (the logic bugs here were many and nuanced, but we're narrowing in on something robust). Specifically this: -Ensures key/mouse up event propagation works across multiple viewports -Ensures that mouse up events for manipulators only get delivered if there's a corresponding mouse down event -Also tidies up the "are we done processing events this tick?" logic in ViewportManipulatorController --- .../Editor/ViewportManipulatorController.cpp | 26 +++++++++++++++---- .../Source/Viewport/RenderViewportWidget.cpp | 19 +++++++++++--- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/Code/Sandbox/Editor/ViewportManipulatorController.cpp b/Code/Sandbox/Editor/ViewportManipulatorController.cpp index 910d037670..8ce2ea1cd9 100644 --- a/Code/Sandbox/Editor/ViewportManipulatorController.cpp +++ b/Code/Sandbox/Editor/ViewportManipulatorController.cpp @@ -95,6 +95,11 @@ bool ViewportManipulatorControllerInstance::HandleInputChannelEvent(const AzFram AZStd::optional overrideButton; AZStd::optional eventType; + // Because we receive events multiple times at separate priorities for manipulator events and + // viewport interaction events, we want to avoid updating our "last tick state" until we're on our last event, + // which currently is the low priority Interaction processor. + const bool finishedProcessingEvents = event.m_priority == InteractionPriority; + if (IsMouseMove(event.m_inputChannel)) { // Cache the ray trace results when doing manipulator interaction checks, no need to recalculate after @@ -120,10 +125,11 @@ bool ViewportManipulatorControllerInstance::HandleInputChannelEvent(const AzFram } else if (auto mouseButton = GetMouseButton(event.m_inputChannel); mouseButton != MouseButton::None) { + const AZ::u32 mouseButtonValue = static_cast(mouseButton); overrideButton = mouseButton; if (event.m_inputChannel.GetState() == InputChannel::State::Began) { - m_state.m_mouseButtons.m_mouseButtons |= static_cast(mouseButton); + m_state.m_mouseButtons.m_mouseButtons |= mouseButtonValue; if (IsDoubleClick(mouseButton)) { // Only remove the double click flag once we're done processing both Manipulator and Interaction events @@ -135,8 +141,8 @@ bool ViewportManipulatorControllerInstance::HandleInputChannelEvent(const AzFram } else { - // Only insert the double click timing once we're done processing both Manipulator and Interaction events, to avoid a false IsDoubleClick positive - if (event.m_priority == InteractionPriority) + // Only insert the double click timing once we're done processing events, to avoid a false IsDoubleClick positive + if (finishedProcessingEvents) { m_pendingDoubleClicks[mouseButton] = m_curTime; } @@ -145,8 +151,18 @@ bool ViewportManipulatorControllerInstance::HandleInputChannelEvent(const AzFram } else if (event.m_inputChannel.GetState() == InputChannel::State::Ended) { - m_state.m_mouseButtons.m_mouseButtons &= ~static_cast(mouseButton); - eventType = MouseEvent::Up; + // If we've actually logged a mouse down event, forward a mouse up event. + // This prevents corner cases like the context menu thinking it should be opened even though no one clicked in this viewport, + // due to RenderViewportWidget ensuring all controllers get InputChannel::State::Ended events. + if (m_state.m_mouseButtons.m_mouseButtons & mouseButtonValue) + { + // Erase the button from our state if we're done processing events. + if (event.m_priority == InteractionPriority) + { + m_state.m_mouseButtons.m_mouseButtons &= ~mouseButtonValue; + } + eventType = MouseEvent::Up; + } } } else if (auto keyboardModifier = GetKeyboardModifier(event.m_inputChannel); keyboardModifier != KeyboardModifier::None) diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp index e08a5a045c..9ea2144289 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp @@ -164,6 +164,8 @@ namespace AtomToolsFramework bool RenderViewportWidget::OnInputChannelEventFiltered(const AzFramework::InputChannel& inputChannel) { + bool shouldConsumeEvent = true; + // Grab keyboard focus if we've been clicked on. // Qt normally handles this for us, but we're filtering native events before they get // synthesized into QMouseEvents. @@ -175,9 +177,18 @@ namespace AtomToolsFramework // Don't consume new input events if we don't currently have focus. // We do forward Ended events, as they may be relevant to our current state // (e.g. a key gets released after we lose focus, it shouldn't remain "stuck"). - if (!hasFocus() && inputChannel.GetState() != AzFramework::InputChannel::State::Ended) + if (!hasFocus()) { - return false; + if (inputChannel.GetState() == AzFramework::InputChannel::State::Ended) + { + // Forward the input ended event to our controllers, but don't prevent other viewports from receiving it. + shouldConsumeEvent = false; + } + else + { + // Not an event we should listen to, abort + return false; + } } // If we receive a mouse button event from outside of our viewport, ignore it even if we have focus. @@ -196,7 +207,9 @@ namespace AtomToolsFramework } AzFramework::NativeWindowHandle windowId = reinterpret_cast(winId()); - return m_controllerList->HandleInputChannelEvent({GetId(), windowId, inputChannel}); + const bool eventHandled = m_controllerList->HandleInputChannelEvent({GetId(), windowId, inputChannel}); + // If our controllers handled the event and it's one we can safely consume (i.e. it's not an Ended event that other viewports might need), consume it. + return eventHandled && shouldConsumeEvent; } void RenderViewportWidget::OnTick([[maybe_unused]]float deltaTime, AZ::ScriptTimePoint time) From dd7334471f9920b6312738c5abcf9d5fc37e0b1d Mon Sep 17 00:00:00 2001 From: nvsickle Date: Fri, 16 Apr 2021 12:17:35 -0700 Subject: [PATCH 14/32] Fix comment punctuation --- .../Code/Source/Viewport/RenderViewportWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp index 9ea2144289..bf46ece27b 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp @@ -186,7 +186,7 @@ namespace AtomToolsFramework } else { - // Not an event we should listen to, abort + // Not an event we should listen to, abort. return false; } } From ebf41d2bdf58dcc3f7899bf94cf84e380c0f8428 Mon Sep 17 00:00:00 2001 From: nvsickle Date: Fri, 16 Apr 2021 14:26:58 -0700 Subject: [PATCH 15/32] Update code style --- Code/Sandbox/Editor/LayoutWnd.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Code/Sandbox/Editor/LayoutWnd.cpp b/Code/Sandbox/Editor/LayoutWnd.cpp index dc3ae14d90..34a96bca53 100644 --- a/Code/Sandbox/Editor/LayoutWnd.cpp +++ b/Code/Sandbox/Editor/LayoutWnd.cpp @@ -420,7 +420,9 @@ void CLayoutWnd::CreateLayout(EViewLayout layout, bool bBindViewports, EViewport // Ensure we delete our old view immediately so it can relinquish its backing ViewportContext if (m_maximizedView) + { delete m_maximizedView; + } m_maximizedView = new CLayoutViewPane(this); m_maximizedView->SetId(0); From ddb08789d207b6553293a121676f0f917faca774 Mon Sep 17 00:00:00 2001 From: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> Date: Mon, 19 Apr 2021 15:14:48 -0700 Subject: [PATCH 16/32] SPEC-6395 GameLauncher monolithic build failure in CreateModuleClass_Gem_Blas (#137) --- .../Source/Authentication/AuthenticationProviderManager.cpp | 2 +- Gems/Blast/Code/Source/BlastModule.cpp | 2 +- Gems/Blast/Code/Source/BlastModuleUnsupported.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gems/AWSClientAuth/Code/Source/Authentication/AuthenticationProviderManager.cpp b/Gems/AWSClientAuth/Code/Source/Authentication/AuthenticationProviderManager.cpp index f6e5efd106..d4d2d0d67b 100644 --- a/Gems/AWSClientAuth/Code/Source/Authentication/AuthenticationProviderManager.cpp +++ b/Gems/AWSClientAuth/Code/Source/Authentication/AuthenticationProviderManager.cpp @@ -48,7 +48,7 @@ namespace AWSClientAuth m_settingsRegistry = AZStd::make_shared(); AZStd::array resolvedPath{}; - AZ::IO::FileIOBase::GetInstance()->ResolvePath(settingsRegistryPath.data(), resolvedPath.data(), resolvedPath.size()); + fileIO->ResolvePath(settingsRegistryPath.data(), resolvedPath.data(), resolvedPath.size()); if (!m_settingsRegistry->MergeSettingsFile(resolvedPath.data(), AZ::SettingsRegistryInterface::Format::JsonMergePatch)) diff --git a/Gems/Blast/Code/Source/BlastModule.cpp b/Gems/Blast/Code/Source/BlastModule.cpp index a95b5205a4..7188d82fbd 100644 --- a/Gems/Blast/Code/Source/BlastModule.cpp +++ b/Gems/Blast/Code/Source/BlastModule.cpp @@ -69,4 +69,4 @@ namespace Blast // DO NOT MODIFY THIS LINE UNLESS YOU RENAME THE GEM // The first parameter should be GemName_GemIdLower // The second should be the fully qualified name of the class above -AZ_DECLARE_MODULE_CLASS(Blast_414bd211c99d4f74aef3a266b9ca208c, Blast::BlastModule) +AZ_DECLARE_MODULE_CLASS(Gem_Blast, Blast::BlastModule) diff --git a/Gems/Blast/Code/Source/BlastModuleUnsupported.cpp b/Gems/Blast/Code/Source/BlastModuleUnsupported.cpp index 6e5b76877f..429583ceda 100644 --- a/Gems/Blast/Code/Source/BlastModuleUnsupported.cpp +++ b/Gems/Blast/Code/Source/BlastModuleUnsupported.cpp @@ -14,4 +14,4 @@ // DO NOT MODIFY THIS LINE UNLESS YOU RENAME THE GEM // The first parameter should be GemName_GemIdLower // The second should be the fully qualified name of the class above -AZ_DECLARE_MODULE_CLASS(Blast_414bd211c99d4f74aef3a266b9ca208c, AZ::Module) +AZ_DECLARE_MODULE_CLASS(Gem_Blast, AZ::Module) From 6abf17439a836ddbccd4258ebb97b1bc926cf1ea Mon Sep 17 00:00:00 2001 From: mnaumov Date: Mon, 19 Apr 2021 15:22:32 -0700 Subject: [PATCH 17/32] Adding "Create New Material" context menu option to folder in Material Editor Improving MaterialBrowser filter to show empty folders --- .../AssetBrowser/Search/SearchWidget.cpp | 9 +++++++++ .../AssetBrowser/Search/SearchWidget.h | 4 ++++ .../CreateMaterialDialog.cpp | 9 +++++++-- .../CreateMaterialDialog.h | 3 +++ .../Window/MaterialBrowserInteractions.cpp | 19 +++++++++++++++++++ .../Source/Window/MaterialBrowserWidget.cpp | 14 ++++++++++++-- 6 files changed, 54 insertions(+), 4 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/SearchWidget.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/SearchWidget.cpp index 7c2f26042f..d2edbcce32 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/SearchWidget.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/SearchWidget.cpp @@ -170,6 +170,15 @@ namespace AzToolsFramework return m_filter; } + QSharedPointer SearchWidget::GetStringFilter() const + { + return m_stringFilter; + } + + QSharedPointer SearchWidget::GetTypesFilter() const + { + return m_typesFilter; + } } // namespace AssetBrowser } // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/SearchWidget.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/SearchWidget.h index 0453333c94..be649bc81d 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/SearchWidget.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/SearchWidget.h @@ -39,6 +39,10 @@ namespace AzToolsFramework QSharedPointer GetFilter() const; + QSharedPointer GetStringFilter() const; + + QSharedPointer GetTypesFilter() const; + QString GetFilterString() const { return textFilter(); } void ClearStringFilter() { ClearTextFilter(); } diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/CreateMaterialDialog/CreateMaterialDialog.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/CreateMaterialDialog/CreateMaterialDialog.cpp index 76aee99e52..6c30540392 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/CreateMaterialDialog/CreateMaterialDialog.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/CreateMaterialDialog/CreateMaterialDialog.cpp @@ -26,8 +26,14 @@ namespace MaterialEditor { CreateMaterialDialog::CreateMaterialDialog(QWidget* parent) + : CreateMaterialDialog(QString(AZ::IO::FileIOBase::GetInstance()->GetAlias("@devassets@")) + AZ_CORRECT_FILESYSTEM_SEPARATOR + "Materials", parent) + { + } + + CreateMaterialDialog::CreateMaterialDialog(const QString& path, QWidget* parent) : QDialog(parent) , m_ui(new Ui::CreateMaterialDialog) + , m_path(path) { m_ui->setupUi(this); @@ -77,8 +83,7 @@ namespace MaterialEditor { //Select a default location and unique name for the new material m_materialFileInfo = AtomToolsFramework::GetUniqueFileInfo( - QString(AZ::IO::FileIOBase::GetInstance()->GetAlias("@devassets@")) + - AZ_CORRECT_FILESYSTEM_SEPARATOR + "Materials" + + m_path + AZ_CORRECT_FILESYSTEM_SEPARATOR + "untitled." + AZ::RPI::MaterialSourceData::Extension).absoluteFilePath(); diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/CreateMaterialDialog/CreateMaterialDialog.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/CreateMaterialDialog/CreateMaterialDialog.h index 54d7c2175d..63d166e95c 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/CreateMaterialDialog/CreateMaterialDialog.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/CreateMaterialDialog/CreateMaterialDialog.h @@ -27,6 +27,7 @@ namespace MaterialEditor Q_OBJECT public: CreateMaterialDialog(QWidget* parent = nullptr); + CreateMaterialDialog(const QString& path, QWidget* parent = nullptr); ~CreateMaterialDialog() = default; QFileInfo m_materialFileInfo; @@ -34,6 +35,8 @@ namespace MaterialEditor private: QScopedPointer m_ui; + QString m_path; + void InitMaterialTypeSelection(); void InitMaterialFileSelection(); void UpdateMaterialTypeSelection(); diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserInteractions.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserInteractions.cpp index b0412c001c..167f7d38f5 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserInteractions.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserInteractions.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -246,6 +247,24 @@ namespace MaterialEditor } } }); + + menu->addSeparator(); + + QAction* createMaterialAction = menu->addAction(QObject::tr("Create New Material")); + QObject::connect(createMaterialAction, &QAction::triggered, caller, [caller, entry]() + { + CreateMaterialDialog createDialog(entry->GetFullPath().c_str(), caller); + createDialog.adjustSize(); + + if (createDialog.exec() == QDialog::Accepted && + !createDialog.m_materialFileInfo.absoluteFilePath().isEmpty() && + !createDialog.m_materialTypeFileInfo.absoluteFilePath().isEmpty()) + { + MaterialDocumentSystemRequestBus::Broadcast(&MaterialDocumentSystemRequestBus::Events::CreateDocumentFromFile, + createDialog.m_materialTypeFileInfo.absoluteFilePath().toUtf8().constData(), + createDialog.m_materialFileInfo.absoluteFilePath().toUtf8().constData()); + } + }); } void MaterialBrowserInteractions::AddPerforceMenuActions([[maybe_unused]] QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserWidget.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserWidget.cpp index 6272312b90..1d579e5a10 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserWidget.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserWidget.cpp @@ -115,19 +115,29 @@ namespace MaterialEditor { using namespace AzToolsFramework::AssetBrowser; + // Material Browser uses the following filters: + // 1. [All source files (no products) that contain products matching the assetType specified by searchWidget (default is materials and textures)] + // 2. [All folders (including empty folders)] + // 3. [All Sources and folders matching the search text typed in search widget] + // Final filter = ((1 OR 2) AND 3) + QSharedPointer sourceFilter(new EntryTypeFilter); sourceFilter->SetEntryType(AssetBrowserEntry::AssetEntryType::Source); + QSharedPointer assetTypeFilter(new CompositeFilter(CompositeFilter::LogicOperatorType::AND)); + assetTypeFilter->AddFilter(sourceFilter); + assetTypeFilter->AddFilter(m_ui->m_searchWidget->GetTypesFilter()); + QSharedPointer folderFilter(new EntryTypeFilter); folderFilter->SetEntryType(AssetBrowserEntry::AssetEntryType::Folder); QSharedPointer sourceOrFolderFilter(new CompositeFilter(CompositeFilter::LogicOperatorType::OR)); - sourceOrFolderFilter->AddFilter(sourceFilter); + sourceOrFolderFilter->AddFilter(assetTypeFilter); sourceOrFolderFilter->AddFilter(folderFilter); QSharedPointer finalFilter(new CompositeFilter(CompositeFilter::LogicOperatorType::AND)); finalFilter->AddFilter(sourceOrFolderFilter); - finalFilter->AddFilter(m_ui->m_searchWidget->GetFilter()); + finalFilter->AddFilter(m_ui->m_searchWidget->GetStringFilter()); return finalFilter; } From e2a76299938d5e7a2f942917e434f9f4f2f8cb3f Mon Sep 17 00:00:00 2001 From: nvsickle Date: Mon, 19 Apr 2021 15:24:08 -0700 Subject: [PATCH 18/32] Remove statistics rendering from EditorViewportWidget - it's wrong at the moment, and needs to be moved to a controller --- Code/Sandbox/Editor/EditorViewportWidget.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Code/Sandbox/Editor/EditorViewportWidget.cpp b/Code/Sandbox/Editor/EditorViewportWidget.cpp index 897b3c569d..3c714b1d4c 100644 --- a/Code/Sandbox/Editor/EditorViewportWidget.cpp +++ b/Code/Sandbox/Editor/EditorViewportWidget.cpp @@ -906,11 +906,6 @@ void EditorViewportWidget::OnBeginPrepareRender() m_debugDisplay->DepthTestOn(); PostWidgetRendering(); - - if (!m_renderer->IsStereoEnabled()) - { - GetIEditor()->GetSystem()->RenderStatistics(); - } } ////////////////////////////////////////////////////////////////////////// From 34be0cd4b5feeb370a14873a90a37898de440bf9 Mon Sep 17 00:00:00 2001 From: mnaumov Date: Mon, 19 Apr 2021 15:31:45 -0700 Subject: [PATCH 19/32] Fixing string search --- .../MaterialEditor/Code/Source/Window/MaterialBrowserWidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserWidget.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserWidget.cpp index 1d579e5a10..406c585b73 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserWidget.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserWidget.cpp @@ -138,6 +138,7 @@ namespace MaterialEditor QSharedPointer finalFilter(new CompositeFilter(CompositeFilter::LogicOperatorType::AND)); finalFilter->AddFilter(sourceOrFolderFilter); finalFilter->AddFilter(m_ui->m_searchWidget->GetStringFilter()); + finalFilter->SetFilterPropagation(AssetBrowserEntryFilter::PropagateDirection::Down); return finalFilter; } From 6aabf2ee3db06bc56725b7cecea2e45f4d508621 Mon Sep 17 00:00:00 2001 From: nvsickle Date: Mon, 19 Apr 2021 15:36:25 -0700 Subject: [PATCH 20/32] Don't attempt to render manipulators in game mode --- Code/Sandbox/Editor/EditorViewportWidget.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Code/Sandbox/Editor/EditorViewportWidget.cpp b/Code/Sandbox/Editor/EditorViewportWidget.cpp index 3c714b1d4c..91c70b720f 100644 --- a/Code/Sandbox/Editor/EditorViewportWidget.cpp +++ b/Code/Sandbox/Editor/EditorViewportWidget.cpp @@ -881,6 +881,11 @@ void EditorViewportWidget::OnBeginPrepareRender() GetIEditor()->GetSystem()->SetViewCamera(m_Camera); + if (GetIEditor()->IsInGameMode()) + { + return; + } + PreWidgetRendering(); RenderAll(); From d1ba2155c52c410e91452ed0b130e692500d30d4 Mon Sep 17 00:00:00 2001 From: mnaumov Date: Mon, 19 Apr 2021 15:55:58 -0700 Subject: [PATCH 21/32] PR feedback --- .../Code/Source/Window/MaterialBrowserInteractions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserInteractions.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserInteractions.cpp index 167f7d38f5..39654af211 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserInteractions.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialBrowserInteractions.cpp @@ -250,7 +250,7 @@ namespace MaterialEditor menu->addSeparator(); - QAction* createMaterialAction = menu->addAction(QObject::tr("Create New Material")); + QAction* createMaterialAction = menu->addAction(QObject::tr("Create Material...")); QObject::connect(createMaterialAction, &QAction::triggered, caller, [caller, entry]() { CreateMaterialDialog createDialog(entry->GetFullPath().c_str(), caller); From dee0f8470448c5ce4d60944f0db6df091e17c3f0 Mon Sep 17 00:00:00 2001 From: nvsickle Date: Mon, 19 Apr 2021 17:00:36 -0700 Subject: [PATCH 22/32] Clarified lazy initialization and added some thread sanity logic after discussion with @rgba16f --- .../Include/AtomLyIntegration/AtomFont/FFont.h | 1 + .../AtomFont/Code/Source/FFont.cpp | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Gems/AtomLyIntegration/AtomFont/Code/Include/AtomLyIntegration/AtomFont/FFont.h b/Gems/AtomLyIntegration/AtomFont/Code/Include/AtomLyIntegration/AtomFont/FFont.h index a6066984c7..91fc0834ec 100644 --- a/Gems/AtomLyIntegration/AtomFont/Code/Include/AtomLyIntegration/AtomFont/FFont.h +++ b/Gems/AtomLyIntegration/AtomFont/Code/Include/AtomLyIntegration/AtomFont/FFont.h @@ -302,6 +302,7 @@ namespace AZ bool m_fontTexDirty = false; bool m_fontInitialized = false; + AZStd::atomic_bool m_fontInitializing = false; FontEffects m_effects; diff --git a/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp b/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp index 38024393fa..edbf148940 100644 --- a/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp +++ b/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp @@ -106,6 +106,14 @@ bool AZ::FFont::InitFont() return true; } + // If we're being initialized in another thread, abort. + if (m_fontInitializing) + { + return false; + } + + m_fontInitializing = true; + // Create and initialize DynamicDrawContext for font draw AZ::RPI::Ptr dynamicDraw = m_atomFont->GetOrCreateDynamicDrawForScene(GetDefaultViewportContext()->GetRenderScene().get()); @@ -129,6 +137,7 @@ bool AZ::FFont::InitFont() m_indexCount = 0; m_fontInitialized = true; + m_fontInitializing = false; return true; } @@ -293,7 +302,11 @@ void AZ::FFont::DrawStringUInternal( const bool asciiMultiLine, const TextDrawContext& ctx) { - InitFont(); + // Lazily ensure we're initialized before attempting to render. + if (!InitFont()) + { + return; + } if (!str || !m_vertexBuffer // vertex buffer isn't created until BootstrapScene is ready, Editor tries to render text before that. From 7e48bee48fbef40e281ffb3f68aa82dcedf7e515 Mon Sep 17 00:00:00 2001 From: mnaumov Date: Mon, 19 Apr 2021 18:24:23 -0700 Subject: [PATCH 23/32] Fixing thumbnail pixelation --- .../AzToolsFramework/Thumbnails/ThumbnailWidget.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailWidget.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailWidget.cpp index f2b81fdb98..1aefa6f189 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailWidget.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/ThumbnailWidget.cpp @@ -79,7 +79,9 @@ namespace AzToolsFramework int realHeight = qMin(aznumeric_cast(originalWidth /aspectRatio), originalHeight); int realWidth = aznumeric_cast(realHeight * aspectRatio); int x = (originalWidth - realWidth) / 2; - painter.drawPixmap(QRect(x, 0, realHeight, realWidth), pixmap); + // pixmap needs to be manually scaled to produce smoother result and avoid looking pixelated + // using painter.setRenderHint(QPainter::SmoothPixmapTransform); does not seem to work + painter.drawPixmap(QPoint(x, 0), pixmap.scaled(realWidth, realHeight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); } QWidget::paintEvent(event); } From 7901fe8625b3bbd31a569f0c7dd89a7d43cd8830 Mon Sep 17 00:00:00 2001 From: AMZN-daimini <82231674+AMZN-daimini@users.noreply.github.com> Date: Mon, 19 Apr 2021 21:52:10 -0700 Subject: [PATCH 24/32] Reset the whole Qt model when an entry in the EditorEntityModel is removed. (#48) (#82) An optimization introduced in Prefab mode currently changes the relative ordering of children, causing stale QModelIndex variables to still be referenced and crash the Editor sporadically. This change is theoretically a bit slower, but still much faster than the pre-optimization times. Co-authored-by: Shirang Jia Co-authored-by: Shirang Jia --- .../AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp index ea281aacf7..de10ae18b4 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp @@ -1344,14 +1344,15 @@ namespace AzToolsFramework emit EnableSelectionUpdates(false); auto parentIndex = GetIndexFromEntity(parentId); auto childIndex = GetIndexFromEntity(childId); - beginRemoveRows(parentIndex, childIndex.row(), childIndex.row()); + beginResetModel(); } void EntityOutlinerListModel::OnEntityInfoUpdatedRemoveChildEnd(AZ::EntityId parentId, AZ::EntityId childId) { (void)childId; AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework); - endRemoveRows(); + + endResetModel(); //must refresh partial lock/visibility of parents m_isFilterDirty = true; From 5aa4642c12df54a6f7c53986bbe6dd5169f89d5f Mon Sep 17 00:00:00 2001 From: mbalfour Date: Wed, 14 Apr 2021 16:05:50 -0500 Subject: [PATCH 25/32] Added another implicit converter to MaterialPropertyValue so that generated images can be used with material properties more easily. (cherry picked from commit 66d7e9672ca0d6ced068dd95d8b52f88b5492c1f) --- .../Include/Atom/RPI.Reflect/Material/MaterialPropertyValue.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialPropertyValue.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialPropertyValue.h index cafd31d8a5..758afb1c66 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialPropertyValue.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialPropertyValue.h @@ -65,6 +65,7 @@ namespace AZ MaterialPropertyValue(const Vector4& value) : m_value(value) {} MaterialPropertyValue(const Color& value) : m_value(value) {} MaterialPropertyValue(const Data::Asset& value) : m_value(value) {} + MaterialPropertyValue(const Data::Instance& value) : m_value(value) {} MaterialPropertyValue(const AZStd::string& value) : m_value(value) {} //! Copy constructor From 1256994696a847a0c82662a1994555ecccda22ba Mon Sep 17 00:00:00 2001 From: Aaron Ruiz Mora Date: Tue, 20 Apr 2021 15:38:26 +0100 Subject: [PATCH 26/32] Cleaning up NvCloth gem. Removed any reference to LmbrCentral and legacy renderer since now it uses Atom. (#154) - Removed any usage of LmbCentral and legacy renderer from NvCloth gem. - Cloth rule can only be added to Mesh groups, not allowed in Actor groups anymore. - Removed ActorAssetHelper since actors now share the mesh model format and therefore they also use MeshAssetHelper. - Updated NvCloth gem.json file with the fields from the template. - Updated cloth chicken asset to not convert axis. --- .../cloth/Chicken/Actor/chicken.fbx.assetinfo | 94 ++++++- Gems/NvCloth/Code/CMakeLists.txt | 20 +- .../ClothComponentMesh/ClothDebugDisplay.cpp | 27 +-- Gems/NvCloth/Code/Source/Module.cpp | 2 - .../Pipeline/RCExt/CgfClothExporter.cpp | 120 --------- .../Source/Pipeline/RCExt/CgfClothExporter.h | 50 ---- .../SceneAPIExt/ClothRuleBehavior.cpp | 6 +- .../Code/Source/System/SystemComponent.cpp | 3 - .../Code/Source/Utils/ActorAssetHelper.cpp | 229 ------------------ .../Code/Source/Utils/ActorAssetHelper.h | 49 ---- .../NvCloth/Code/Source/Utils/AssetHelper.cpp | 1 - Gems/NvCloth/Code/Source/Utils/AssetHelper.h | 3 - .../Code/Source/Utils/MeshAssetHelper.cpp | 6 - .../Code/Source/Utils/MeshAssetHelper.h | 6 - .../ClothComponentMeshTest.cpp | 7 +- Gems/NvCloth/Code/Tests/CryRenderMeshStub.h | 130 ---------- .../Tests/NvClothEditorTestEnvironment.cpp | 2 - .../Code/Tests/Utils/ActorAssetHelperTest.cpp | 16 -- Gems/NvCloth/Code/nvcloth_editor_files.cmake | 2 - Gems/NvCloth/Code/nvcloth_files.cmake | 2 - Gems/NvCloth/Code/nvcloth_tests_files.cmake | 1 - Gems/NvCloth/gem.json | 47 +--- 22 files changed, 104 insertions(+), 719 deletions(-) delete mode 100644 Gems/NvCloth/Code/Source/Pipeline/RCExt/CgfClothExporter.cpp delete mode 100644 Gems/NvCloth/Code/Source/Pipeline/RCExt/CgfClothExporter.h delete mode 100644 Gems/NvCloth/Code/Source/Utils/ActorAssetHelper.cpp delete mode 100644 Gems/NvCloth/Code/Source/Utils/ActorAssetHelper.h delete mode 100644 Gems/NvCloth/Code/Tests/CryRenderMeshStub.h diff --git a/Gems/NvCloth/Assets/Objects/cloth/Chicken/Actor/chicken.fbx.assetinfo b/Gems/NvCloth/Assets/Objects/cloth/Chicken/Actor/chicken.fbx.assetinfo index a6024e0c5f..92c20c02ac 100644 --- a/Gems/NvCloth/Assets/Objects/cloth/Chicken/Actor/chicken.fbx.assetinfo +++ b/Gems/NvCloth/Assets/Objects/cloth/Chicken/Actor/chicken.fbx.assetinfo @@ -8,7 +8,7 @@ "rules": [ { "$type": "MetaDataRule", - "metaData": "AdjustActor -actorID $(ACTORID) -name \"chicken\"\r\nActorSetCollisionMeshes -actorID $(ACTORID) -lod 0 -nodeList \"\"\r\nAdjustActor -actorID $(ACTORID) -nodesExcludedFromBounds \"\" -nodeAction \"select\"\r\nAdjustActor -actorID $(ACTORID) -nodeAction \"replace\" -attachmentNodes \"\"\r\n" + "metaData": "AdjustActor -actorID $(ACTORID) -name \"chicken\"\nActorSetCollisionMeshes -actorID $(ACTORID) -lod 0 -nodeList \"\"\nAdjustActor -actorID $(ACTORID) -nodesExcludedFromBounds \"\" -nodeAction \"select\"\nAdjustActor -actorID $(ACTORID) -nodeAction \"replace\" -attachmentNodes \"\"\nAdjustActor -actorID $(ACTORID) -mirrorSetup \"\"\n" }, { "$type": "ActorPhysicsSetupRule", @@ -50,15 +50,15 @@ { "Visible": true, "Position": [ - -0.03810190036892891, - 0.0, - -0.03132440149784088 + 0.08189810067415238, + -2.4586914726398847e-9, + -0.4713243842124939 ], "propertyVisibilityFlags": 248 }, { "$type": "SphereShapeConfiguration", - "Radius": 0.16069939732551576 + "Radius": 0.2406993955373764 } ] ] @@ -82,14 +82,38 @@ } ] ] + }, + { + "name": "def_c_feather2_joint", + "shapes": [ + [ + { + "Visible": true, + "Position": [ + 0.06151500344276428, + 0.1300000101327896, + 7.729977369308472e-8 + ], + "Rotation": [ + 0.0, + 0.7071062922477722, + 0.0, + 0.7071072459220886 + ], + "propertyVisibilityFlags": 248 + }, + { + "$type": "CapsuleShapeConfiguration", + "Height": 0.5730299949645996, + "Radius": 0.06151498109102249 + } + ] + ] } ] } } } - }, - { - "$type": "CoordinateSystemRule" } ] } @@ -99,47 +123,94 @@ "name": "chicken", "nodeSelectionList": { "selectedNodes": [ - {}, "RootNode", "RootNode.chicken_skeleton", "RootNode.chicken_feet_skin", "RootNode.chicken_eyes_skin", "RootNode.chicken_body_skin", "RootNode.chicken_mohawk", + "RootNode.chicken_skeleton.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint", + "RootNode.chicken_feet_skin.SkinWeight_0", + "RootNode.chicken_feet_skin.map1", + "RootNode.chicken_feet_skin.chicken_body_mat", + "RootNode.chicken_eyes_skin.SkinWeight_0", + "RootNode.chicken_eyes_skin.uvSet1", + "RootNode.chicken_eyes_skin.chicken_eye_mat", + "RootNode.chicken_body_skin.SkinWeight_0", + "RootNode.chicken_body_skin.map1", + "RootNode.chicken_body_skin.chicken_body_mat", + "RootNode.chicken_mohawk.SkinWeight_0", + "RootNode.chicken_mohawk.colorSet1", + "RootNode.chicken_mohawk.map1", + "RootNode.chicken_mohawk.mohawkMat", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_l_uprLeg_joint", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_r_uprLeg_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_l_uprLeg_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_l_uprLeg_joint.def_l_lwrLeg_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_r_uprLeg_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_r_uprLeg_joint.def_r_lwrLeg_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_l_wing1_joint", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_r_wing1_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_l_uprLeg_joint.def_l_lwrLeg_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_l_uprLeg_joint.def_l_lwrLeg_joint.def_l_foot_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_r_uprLeg_joint.def_r_lwrLeg_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_r_uprLeg_joint.def_r_lwrLeg_joint.def_r_foot_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_tail1_joint", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_l_wing1_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_l_wing1_joint.def_l_wing2_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_r_wing1_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_r_wing1_joint.def_r_wing2_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_l_uprLeg_joint.def_l_lwrLeg_joint.def_l_foot_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_l_uprLeg_joint.def_l_lwrLeg_joint.def_l_foot_joint.def_l_ball_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_r_uprLeg_joint.def_r_lwrLeg_joint.def_r_foot_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_r_uprLeg_joint.def_r_lwrLeg_joint.def_r_foot_joint.def_r_ball_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_tail1_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_tail1_joint.def_c_tail2_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_l_wing1_joint.def_l_wing2_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_l_wing1_joint.def_l_wing2_joint.def_l_wing_end", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_r_wing1_joint.def_r_wing2_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_r_wing1_joint.def_r_wing2_joint.def_r_wing_end", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_l_uprLeg_joint.def_l_lwrLeg_joint.def_l_foot_joint.def_l_ball_joint.transform", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_r_uprLeg_joint.def_r_lwrLeg_joint.def_r_foot_joint.def_r_ball_joint.transform", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_tail1_joint.def_c_tail2_joint.transform", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_feather1_joint", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_mouth_joint", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_waddle1_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_l_wing1_joint.def_l_wing2_joint.def_l_wing_end.transform", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_r_wing1_joint.def_r_wing2_joint.def_r_wing_end.transform", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_feather1_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_feather1_joint.def_c_feather2_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_mouth_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_mouth_joint.def_c_mouth_end", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_waddle1_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_waddle1_joint.def_c_waddle2_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_feather1_joint.def_c_feather2_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_feather1_joint.def_c_feather2_joint.def_c_feather3_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_mouth_joint.def_c_mouth_end.transform", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_waddle1_joint.def_c_waddle2_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_waddle1_joint.def_c_waddle2_joint.def_c_waddle3_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_feather1_joint.def_c_feather2_joint.def_c_feather3_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_feather1_joint.def_c_feather2_joint.def_c_feather3_joint.def_c_feather4_joint", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_waddle1_joint.def_c_waddle2_joint.def_c_waddle3_joint.transform", "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_waddle1_joint.def_c_waddle2_joint.def_c_waddle3_joint.def_c_waddle_end", - "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_feather1_joint.def_c_feather2_joint.def_c_feather3_joint.def_c_feather4_joint.def_c_feather_end" + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_feather1_joint.def_c_feather2_joint.def_c_feather3_joint.def_c_feather4_joint.transform", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_feather1_joint.def_c_feather2_joint.def_c_feather3_joint.def_c_feather4_joint.def_c_feather_end", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_waddle1_joint.def_c_waddle2_joint.def_c_waddle3_joint.def_c_waddle_end.transform", + "RootNode.chicken_skeleton.def_c_chickenRoot_joint.def_c_spine1_joint.def_c_spine2_joint.def_c_spine3_joint.def_c_spine_end.def_c_neck_joint.def_c_head_joint.def_c_feather1_joint.def_c_feather2_joint.def_c_feather3_joint.def_c_feather4_joint.def_c_feather_end.transform" ] }, "rules": { @@ -154,9 +225,6 @@ { "$type": "MaterialRule" }, - { - "$type": "CoordinateSystemRule" - }, { "$type": "ClothRule", "meshNodeName": "RootNode.chicken_mohawk", diff --git a/Gems/NvCloth/Code/CMakeLists.txt b/Gems/NvCloth/Code/CMakeLists.txt index 8c2c5cafab..983e7ff8f8 100644 --- a/Gems/NvCloth/Code/CMakeLists.txt +++ b/Gems/NvCloth/Code/CMakeLists.txt @@ -30,8 +30,12 @@ ly_add_target( BUILD_DEPENDENCIES PUBLIC 3rdParty::NvCloth - Gem::LmbrCentral - Gem::AtomLyIntegration_CommonFeatures.Static + # CryCommon required for 'gEnv->IsDedicated()'. + # Because of this the module will need CrySystemEventBus to initialize gEnv + # and tests targets will need to fake gEnv. To be removed when there is + # an AZ replacement for asking if the game is running on a server or not. + Legacy::CryCommon + Gem::AtomLyIntegration_CommonFeatures.Public PRIVATE Gem::EMotionFXStaticLib ) @@ -50,10 +54,9 @@ ly_add_target( PUBLIC AZ::AzCore PRIVATE - Legacy::CryCommon Gem::NvCloth.Static RUNTIME_DEPENDENCIES - Gem::LmbrCentral + Gem::AtomLyIntegration_CommonFeatures ) if(PAL_TRAIT_BUILD_HOST_TOOLS) @@ -76,8 +79,6 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS) Gem::NvCloth.Static AZ::AzToolsFramework AZ::SceneCore - PRIVATE - Gem::EMotionFXStaticLib ) ly_add_target( @@ -95,10 +96,9 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS) NVCLOTH_EDITOR BUILD_DEPENDENCIES PRIVATE - Legacy::CryCommon Gem::NvCloth.Editor.Static RUNTIME_DEPENDENCIES - Gem::LmbrCentral.Editor + Gem::AtomLyIntegration_CommonFeatures.Editor ) endif() @@ -118,7 +118,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) Source BUILD_DEPENDENCIES PRIVATE - Legacy::CryCommon AZ::AzTestShared AZ::AzTest Gem::NvCloth.Static @@ -126,7 +125,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) Gem::EMotionFX.Tests.Static RUNTIME_DEPENDENCIES Gem::EMotionFX - Gem::LmbrCentral ) ly_add_googletest( NAME Gem::NvCloth.Tests @@ -148,7 +146,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) NVCLOTH_EDITOR BUILD_DEPENDENCIES PRIVATE - Legacy::CryCommon AZ::AzTestShared AZ::AzTest AZ::AzToolsFrameworkTestCommon @@ -157,7 +154,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) Gem::EMotionFX.Tests.Static RUNTIME_DEPENDENCIES Gem::EMotionFX.Editor - Gem::LmbrCentral.Editor ) ly_add_googletest( NAME Gem::NvCloth.Editor.Tests diff --git a/Gems/NvCloth/Code/Source/Components/ClothComponentMesh/ClothDebugDisplay.cpp b/Gems/NvCloth/Code/Source/Components/ClothComponentMesh/ClothDebugDisplay.cpp index d5f891e117..809a3a5129 100644 --- a/Gems/NvCloth/Code/Source/Components/ClothComponentMesh/ClothDebugDisplay.cpp +++ b/Gems/NvCloth/Code/Source/Components/ClothComponentMesh/ClothDebugDisplay.cpp @@ -13,7 +13,6 @@ #include #include -#include #include #include @@ -285,29 +284,11 @@ namespace NvCloth AzFramework::DebugDisplayRequests& debugDisplay, float radius, float height, const AZ::Transform& transform, - const AZ::Color& color) + [[maybe_unused]] const AZ::Color& color) { - debugDisplay.PushMatrix(transform); + const float heightStraightSection = AZStd::max(AZ::Constants::FloatEpsilon, height - 2.0f * radius); - AZStd::vector capsuleVertexBuffer; - AZStd::vector capsuleIndexBuffer; - AZStd::vector capsuleLineBuffer; - const AZ::u32 sides = 16; - const AZ::u32 capSegments = 8; - - LmbrCentral::CapsuleGeometrySystemRequestBus::Broadcast( - &LmbrCentral::CapsuleGeometrySystemRequestBus::Events::GenerateCapsuleMesh, - radius, - height, - sides, capSegments, - capsuleVertexBuffer, - capsuleIndexBuffer, - capsuleLineBuffer - ); - - debugDisplay.DrawTrianglesIndexed(capsuleVertexBuffer, capsuleIndexBuffer, color); - debugDisplay.DrawLines(capsuleLineBuffer, AzFramework::ViewportColors::WireColor); - - debugDisplay.PopMatrix(); + debugDisplay.SetColor(AzFramework::ViewportColors::WireColor); + debugDisplay.DrawWireCapsule(transform.GetTranslation(), transform.GetBasisZ(), radius, heightStraightSection); } } // namespace NvCloth diff --git a/Gems/NvCloth/Code/Source/Module.cpp b/Gems/NvCloth/Code/Source/Module.cpp index 3a884b306c..08d673fd07 100644 --- a/Gems/NvCloth/Code/Source/Module.cpp +++ b/Gems/NvCloth/Code/Source/Module.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #endif //NVCLOTH_EDITOR namespace NvCloth @@ -59,7 +58,6 @@ namespace NvCloth EditorSystemComponent::CreateDescriptor(), EditorClothComponent::CreateDescriptor(), Pipeline::ClothRuleBehavior::CreateDescriptor(), - Pipeline::CgfClothExporter::CreateDescriptor(), #endif //NVCLOTH_EDITOR }); } diff --git a/Gems/NvCloth/Code/Source/Pipeline/RCExt/CgfClothExporter.cpp b/Gems/NvCloth/Code/Source/Pipeline/RCExt/CgfClothExporter.cpp deleted file mode 100644 index 9c4e44998f..0000000000 --- a/Gems/NvCloth/Code/Source/Pipeline/RCExt/CgfClothExporter.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ - -#include - -#include // Needed for CGFContent.h -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace NvCloth -{ - namespace Pipeline - { - namespace - { - // Index for the Vertex color stream that contains the cloth inverse masses. - const int ClothVertexBufferStreamIndex = 1; - } - - CgfClothExporter::CgfClothExporter() - { - // Binding the processing functions so when exporters call - // SceneAPI::Events::Process() these functions will - // get called if their Context was used. - BindToCall(&CgfClothExporter::ProcessMeshNodeContext); - BindToCall(&CgfClothExporter::ProcessContainerContext); - } - - void CgfClothExporter::Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serializeContext = azrtti_cast(context); - if (serializeContext) - { - serializeContext->Class()->Version(1); - } - } - - AZ::SceneAPI::Events::ProcessingResult CgfClothExporter::ProcessContainerContext(AZ::RC::ContainerExportContext& context) const - { - if (!context.m_group.GetRuleContainerConst().ContainsRuleOfType()) - { - return AZ::SceneAPI::Events::ProcessingResult::Ignored; - } - - if (context.m_phase == AZ::RC::Phase::Finalizing) - { - if (context.m_container.GetExportInfo()->bMergeAllNodes) - { - AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, - "Mesh group '%s' has cloth rules and trying to merge all nodes.", - context.m_group.GetName().c_str()); - return AZ::SceneAPI::Events::ProcessingResult::Failure; - } - } - else - { - // If the current mesh group contains a cloth rule it should not merge all the nodes. - context.m_container.GetExportInfo()->bMergeAllNodes = false; - } - - return AZ::SceneAPI::Events::ProcessingResult::Success; - } - - AZ::SceneAPI::Events::ProcessingResult CgfClothExporter::ProcessMeshNodeContext(AZ::RC::MeshNodeExportContext& context) const - { - if (context.m_phase != AZ::RC::Phase::Filling) - { - return AZ::SceneAPI::Events::ProcessingResult::Ignored; - } - - AZStd::vector clothData = - AZ::SceneAPI::DataTypes::IClothRule::FindClothData( - context.m_scene.GetGraph(), - context.m_nodeIndex, - static_cast(context.m_mesh.GetVertexCount()), - context.m_group.GetRuleContainerConst()); - - if (!clothData.empty()) - { - const int numVertices = context.m_mesh.GetVertexCount(); - - // Allocate and get the vertex color stream for cloth - context.m_mesh.ReallocStream(CMesh::COLORS, ClothVertexBufferStreamIndex, numVertices); - auto meshColorStream = context.m_mesh.GetStreamPtr(CMesh::COLORS, ClothVertexBufferStreamIndex); - AZ_Assert(meshColorStream, "Mesh color stream is invalid"); - - for (int i = 0; i < numVertices; ++i) - { - const auto& clothVertexData = clothData[i]; - meshColorStream[i] = SMeshColor( - clothVertexData.GetR8(), - clothVertexData.GetG8(), - clothVertexData.GetB8(), - clothVertexData.GetA8()); - } - } - - return AZ::SceneAPI::Events::ProcessingResult::Success; - } - } // namespace Pipeline -} // namespace NvCloth diff --git a/Gems/NvCloth/Code/Source/Pipeline/RCExt/CgfClothExporter.h b/Gems/NvCloth/Code/Source/Pipeline/RCExt/CgfClothExporter.h deleted file mode 100644 index d02f8d7f99..0000000000 --- a/Gems/NvCloth/Code/Source/Pipeline/RCExt/CgfClothExporter.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ - -#pragma once - -#include - -namespace AZ -{ - namespace RC - { - struct MeshNodeExportContext; - struct ContainerExportContext; - } -} - -namespace NvCloth -{ - namespace Pipeline - { - //! This class processes the Scene graph to export cloth data into CGF. - class CgfClothExporter - : public AZ::SceneAPI::SceneCore::RCExportingComponent - { - public: - AZ_COMPONENT(CgfClothExporter, "{3D7287BB-1109-4220-AC44-AEBA59E03FFF}", AZ::SceneAPI::SceneCore::RCExportingComponent); - - CgfClothExporter(); - - static void Reflect(AZ::ReflectContext* context); - - //! Process call at CGF Container level. - //! This function gets called once per Mesh Group from CGF Group Exporter when it's processing meshes. - AZ::SceneAPI::Events::ProcessingResult ProcessContainerContext(AZ::RC::ContainerExportContext& context) const; - - //! Process call at Mesh Node level. - //! This function gets called once per Mesh Node inside a Mesh Group from CGF Group Exporter when it's processing meshes. - AZ::SceneAPI::Events::ProcessingResult ProcessMeshNodeContext(AZ::RC::MeshNodeExportContext& context) const; - }; - } // namespace Pipeline -} // namespace NvCloth diff --git a/Gems/NvCloth/Code/Source/Pipeline/SceneAPIExt/ClothRuleBehavior.cpp b/Gems/NvCloth/Code/Source/Pipeline/SceneAPIExt/ClothRuleBehavior.cpp index c04b7f71ef..63aa651aa2 100644 --- a/Gems/NvCloth/Code/Source/Pipeline/SceneAPIExt/ClothRuleBehavior.cpp +++ b/Gems/NvCloth/Code/Source/Pipeline/SceneAPIExt/ClothRuleBehavior.cpp @@ -15,7 +15,6 @@ #include #include -#include #include #include @@ -100,9 +99,8 @@ namespace NvCloth bool ClothRuleBehavior::IsValidGroupType(const AZ::SceneAPI::DataTypes::ISceneNodeGroup& group) const { - // Cloth rules are available in Mesh and Actor Groups - return group.RTTI_IsTypeOf(AZ::SceneAPI::DataTypes::IMeshGroup::TYPEINFO_Uuid()) - || group.RTTI_IsTypeOf(EMotionFX::Pipeline::Group::IActorGroup::TYPEINFO_Uuid()); + // Cloth rules are available in Mesh Groups + return group.RTTI_IsTypeOf(AZ::SceneAPI::DataTypes::IMeshGroup::TYPEINFO_Uuid()); } bool ClothRuleBehavior::UpdateClothRules(AZ::SceneAPI::Containers::Scene& scene) diff --git a/Gems/NvCloth/Code/Source/System/SystemComponent.cpp b/Gems/NvCloth/Code/Source/System/SystemComponent.cpp index b73622b883..dbddb62d2b 100644 --- a/Gems/NvCloth/Code/Source/System/SystemComponent.cpp +++ b/Gems/NvCloth/Code/Source/System/SystemComponent.cpp @@ -10,9 +10,6 @@ * */ -#include -#include - #include #include #include diff --git a/Gems/NvCloth/Code/Source/Utils/ActorAssetHelper.cpp b/Gems/NvCloth/Code/Source/Utils/ActorAssetHelper.cpp deleted file mode 100644 index 5a60b6d7e5..0000000000 --- a/Gems/NvCloth/Code/Source/Utils/ActorAssetHelper.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* - * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or - * its licensors. - * - * For complete copyright and license terms please see the LICENSE at the root of this - * distribution (the "License"). All use of this software is governed by the License, - * or, if provided, by the license below or the license accompanying this file. Do not - * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - */ - -#include - -// Needed to access the Mesh information inside Actor. -#include -#include -#include -#include - -#include - -namespace NvCloth -{ - ActorAssetHelper::ActorAssetHelper(AZ::EntityId entityId) - : AssetHelper(entityId) - { - } - - void ActorAssetHelper::GatherClothMeshNodes(MeshNodeList& meshNodes) - { - EMotionFX::ActorInstance* actorInstance = nullptr; - EMotionFX::Integration::ActorComponentRequestBus::EventResult( - actorInstance, m_entityId, &EMotionFX::Integration::ActorComponentRequestBus::Events::GetActorInstance); - if (!actorInstance) - { - return; - } - - const EMotionFX::Actor* actor = actorInstance->GetActor(); - if (!actor) - { - return; - } - - const uint32 numNodes = actor->GetNumNodes(); - const uint32 numLODs = actor->GetNumLODLevels(); - - for (uint32 lodLevel = 0; lodLevel < numLODs; ++lodLevel) - { - for (uint32 nodeIndex = 0; nodeIndex < numNodes; ++nodeIndex) - { - const EMotionFX::Mesh* mesh = actor->GetMesh(lodLevel, nodeIndex); - if (!mesh) - { - continue; - } - - const bool hasClothData = (mesh->FindOriginalVertexData(EMotionFX::Mesh::ATTRIB_CLOTH_DATA) != nullptr); - if (hasClothData) - { - const EMotionFX::Node* node = actor->GetSkeleton()->GetNode(nodeIndex); - AZ_Assert(node, "Invalid node %u in actor '%s'", nodeIndex, actor->GetFileNameString().c_str()); - meshNodes.push_back(node->GetNameString()); - } - } - } - } - - bool ActorAssetHelper::ObtainClothMeshNodeInfo( - const AZStd::string& meshNode, - MeshNodeInfo& meshNodeInfo, - MeshClothInfo& meshClothInfo) - { - AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Cloth); - - EMotionFX::ActorInstance* actorInstance = nullptr; - EMotionFX::Integration::ActorComponentRequestBus::EventResult( - actorInstance, m_entityId, &EMotionFX::Integration::ActorComponentRequestBus::Events::GetActorInstance); - if (!actorInstance) - { - return false; - } - - const EMotionFX::Actor* actor = actorInstance->GetActor(); - if (!actor) - { - return false; - } - - const uint32 numNodes = actor->GetNumNodes(); - const uint32 numLODs = actor->GetNumLODLevels(); - - const EMotionFX::Mesh* emfxMesh = nullptr; - uint32 meshFirstPrimitiveIndex = 0; - - // Find the render data of the mesh node - for (uint32 lodLevel = 0; lodLevel < numLODs; ++lodLevel) - { - meshFirstPrimitiveIndex = 0; - - for (uint32 nodeIndex = 0; nodeIndex < numNodes; ++nodeIndex) - { - const EMotionFX::Mesh* mesh = actor->GetMesh(lodLevel, nodeIndex); - if (!mesh || mesh->GetIsCollisionMesh()) - { - // Skip invalid and collision meshes. - continue; - } - - const EMotionFX::Node* node = actor->GetSkeleton()->GetNode(nodeIndex); - if (meshNode != node->GetNameString()) - { - // Skip. Increase the index of all primitives of the mesh we're skipping. - meshFirstPrimitiveIndex += mesh->GetNumSubMeshes(); - continue; - } - - // Mesh found, save the lod in mesh info - meshNodeInfo.m_lodLevel = lodLevel; - emfxMesh = mesh; - break; - } - - if (emfxMesh) - { - break; - } - } - - bool infoObtained = false; - - if (emfxMesh) - { - bool dataCopied = CopyDataFromEMotionFXMesh(*emfxMesh, meshClothInfo); - - if (dataCopied) - { - const uint32 numSubMeshes = emfxMesh->GetNumSubMeshes(); - for (uint32 subMeshIndex = 0; subMeshIndex < numSubMeshes; ++subMeshIndex) - { - const EMotionFX::SubMesh* emfxSubMesh = emfxMesh->GetSubMesh(subMeshIndex); - - MeshNodeInfo::SubMesh subMesh; - subMesh.m_primitiveIndex = static_cast(meshFirstPrimitiveIndex + subMeshIndex); - subMesh.m_verticesFirstIndex = emfxSubMesh->GetStartVertex(); - subMesh.m_numVertices = emfxSubMesh->GetNumVertices(); - subMesh.m_indicesFirstIndex = emfxSubMesh->GetStartIndex(); - subMesh.m_numIndices = emfxSubMesh->GetNumIndices(); - - meshNodeInfo.m_subMeshes.push_back(subMesh); - } - - infoObtained = true; - } - else - { - AZ_Error("ActorAssetHelper", false, "Failed to extract data from node %s in actor %s", - meshNode.c_str(), actor->GetFileNameString().c_str()); - } - } - - return infoObtained; - } - - bool ActorAssetHelper::CopyDataFromEMotionFXMesh( - const EMotionFX::Mesh& emfxMesh, - MeshClothInfo& meshClothInfo) - { - const int numVertices = emfxMesh.GetNumVertices(); - const int numIndices = emfxMesh.GetNumIndices(); - if (numVertices == 0 || numIndices == 0) - { - return false; - } - - const uint32* sourceIndices = emfxMesh.GetIndices(); - const AZ::Vector3* sourcePositions = static_cast(emfxMesh.FindOriginalVertexData(EMotionFX::Mesh::ATTRIB_POSITIONS)); - const AZ::u32* sourceClothData = static_cast(emfxMesh.FindOriginalVertexData(EMotionFX::Mesh::ATTRIB_CLOTH_DATA)); - const AZ::Vector2* sourceUVs = static_cast(emfxMesh.FindOriginalVertexData(EMotionFX::Mesh::ATTRIB_UVCOORDS, 0)); // first UV set - - if (!sourceIndices || !sourcePositions || !sourceClothData) - { - return false; - } - - const SimUVType uvZero(0.0f, 0.0f); - - meshClothInfo.m_particles.resize_no_construct(numVertices); - meshClothInfo.m_uvs.resize_no_construct(numVertices); - meshClothInfo.m_motionConstraints.resize_no_construct(numVertices); - meshClothInfo.m_backstopData.resize_no_construct(numVertices); - for (int index = 0; index < numVertices; ++index) - { - AZ::Color clothVertexData; - clothVertexData.FromU32(sourceClothData[index]); - - const float inverseMass = clothVertexData.GetR(); - const float motionConstraint = clothVertexData.GetG(); - const float backstopRadius = clothVertexData.GetA(); - const float backstopOffset = ConvertBackstopOffset(clothVertexData.GetB()); - - meshClothInfo.m_particles[index].Set( - sourcePositions[index], - inverseMass); - - meshClothInfo.m_motionConstraints[index] = motionConstraint; - meshClothInfo.m_backstopData[index].Set(backstopOffset, backstopRadius); - - meshClothInfo.m_uvs[index] = (sourceUVs) ? SimUVType(sourceUVs[index].GetX(), sourceUVs[index].GetY()) : uvZero; - } - - meshClothInfo.m_indices.resize_no_construct(numIndices); - // Fast copy when SimIndexType is the same size as the EMFX indices type. - if constexpr (sizeof(SimIndexType) == sizeof(uint32)) - { - memcpy(meshClothInfo.m_indices.data(), sourceIndices, numIndices * sizeof(SimIndexType)); - } - else - { - for (int index = 0; index < numIndices; ++index) - { - meshClothInfo.m_indices[index] = static_cast(sourceIndices[index]); - } - } - - return true; - } -} // namespace NvCloth diff --git a/Gems/NvCloth/Code/Source/Utils/ActorAssetHelper.h b/Gems/NvCloth/Code/Source/Utils/ActorAssetHelper.h deleted file mode 100644 index ce2ede8e4b..0000000000 --- a/Gems/NvCloth/Code/Source/Utils/ActorAssetHelper.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or - * its licensors. - * - * For complete copyright and license terms please see the LICENSE at the root of this - * distribution (the "License"). All use of this software is governed by the License, - * or, if provided, by the license below or the license accompanying this file. Do not - * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - */ - -#pragma once - -#include - -namespace EMotionFX -{ - class Mesh; -} - -namespace NvCloth -{ - //! Helper class to obtain cloth information from an Actor Asset. - class ActorAssetHelper - : public AssetHelper - { - public: - AZ_RTTI(ActorAssetHelper, "{3246EAC6-595F-4AFB-BA10-44EB0B824398}", AssetHelper); - - explicit ActorAssetHelper(AZ::EntityId entityId); - - // AssetHelper overrides ... - void GatherClothMeshNodes(MeshNodeList& meshNodes) override; - bool ObtainClothMeshNodeInfo( - const AZStd::string& meshNode, - MeshNodeInfo& meshNodeInfo, - MeshClothInfo& meshClothInfo) override; - bool DoesSupportSkinnedAnimation() const override - { - return true; - } - - private: - bool CopyDataFromEMotionFXMesh( - const EMotionFX::Mesh& emfxMesh, - MeshClothInfo& meshClothInfo); - }; -} // namespace NvCloth diff --git a/Gems/NvCloth/Code/Source/Utils/AssetHelper.cpp b/Gems/NvCloth/Code/Source/Utils/AssetHelper.cpp index c7558580b3..d75144a5ff 100644 --- a/Gems/NvCloth/Code/Source/Utils/AssetHelper.cpp +++ b/Gems/NvCloth/Code/Source/Utils/AssetHelper.cpp @@ -14,7 +14,6 @@ #include - namespace NvCloth { const int InvalidIndex = -1; diff --git a/Gems/NvCloth/Code/Source/Utils/AssetHelper.h b/Gems/NvCloth/Code/Source/Utils/AssetHelper.h index 253245426c..9630eeb5e1 100644 --- a/Gems/NvCloth/Code/Source/Utils/AssetHelper.h +++ b/Gems/NvCloth/Code/Source/Utils/AssetHelper.h @@ -88,9 +88,6 @@ namespace NvCloth MeshNodeInfo& meshNodeInfo, MeshClothInfo& meshClothInfo) = 0; - //! Returns whether the asset has support for skinned animation or not. - virtual bool DoesSupportSkinnedAnimation() const = 0; - protected: static float ConvertBackstopOffset(float backstopOffset); diff --git a/Gems/NvCloth/Code/Source/Utils/MeshAssetHelper.cpp b/Gems/NvCloth/Code/Source/Utils/MeshAssetHelper.cpp index 6852d245d2..fa8d6e5455 100644 --- a/Gems/NvCloth/Code/Source/Utils/MeshAssetHelper.cpp +++ b/Gems/NvCloth/Code/Source/Utils/MeshAssetHelper.cpp @@ -14,17 +14,11 @@ #include -#include - namespace NvCloth { MeshAssetHelper::MeshAssetHelper(AZ::EntityId entityId) : AssetHelper(entityId) { - EMotionFX::ActorInstance* actorInstance = nullptr; - EMotionFX::Integration::ActorComponentRequestBus::EventResult( - actorInstance, entityId, &EMotionFX::Integration::ActorComponentRequestBus::Events::GetActorInstance); - m_supportSkinnedAnimation = actorInstance != nullptr; } void MeshAssetHelper::GatherClothMeshNodes(MeshNodeList& meshNodes) diff --git a/Gems/NvCloth/Code/Source/Utils/MeshAssetHelper.h b/Gems/NvCloth/Code/Source/Utils/MeshAssetHelper.h index a7849583e7..724f8598c8 100644 --- a/Gems/NvCloth/Code/Source/Utils/MeshAssetHelper.h +++ b/Gems/NvCloth/Code/Source/Utils/MeshAssetHelper.h @@ -33,16 +33,10 @@ namespace NvCloth const AZStd::string& meshNode, MeshNodeInfo& meshNodeInfo, MeshClothInfo& meshClothInfo) override; - bool DoesSupportSkinnedAnimation() const override - { - return m_supportSkinnedAnimation; - } private: bool CopyDataFromMeshes( const AZStd::vector& meshes, MeshClothInfo& meshClothInfo); - - bool m_supportSkinnedAnimation = false; }; } // namespace NvCloth diff --git a/Gems/NvCloth/Code/Tests/Components/ClothComponentMesh/ClothComponentMeshTest.cpp b/Gems/NvCloth/Code/Tests/Components/ClothComponentMesh/ClothComponentMeshTest.cpp index 3d5b7713b3..9916029d3b 100644 --- a/Gems/NvCloth/Code/Tests/Components/ClothComponentMesh/ClothComponentMeshTest.cpp +++ b/Gems/NvCloth/Code/Tests/Components/ClothComponentMesh/ClothComponentMeshTest.cpp @@ -19,7 +19,6 @@ #include #include -#include #include #include @@ -465,14 +464,15 @@ namespace UnitTest AZ::ScriptTimePoint(AZStd::chrono::system_clock::now())); } + /* CryRenderMeshStub renderMesh(MeshVertices); - /*LmbrCentral::MeshModificationNotificationBus::Event( + LmbrCentral::MeshModificationNotificationBus::Event( m_actorComponent->GetEntityId(), &LmbrCentral::MeshModificationNotificationBus::Events::ModifyMesh, LodLevel, 0, - &renderMesh);*/ + &renderMesh); const AZStd::vector& clothParticles = clothComponentMesh.GetRenderData().m_particles; const AZStd::vector& renderMeshPositions = renderMesh.m_positions; @@ -482,5 +482,6 @@ namespace UnitTest { EXPECT_THAT(LYVec3ToAZVec3(renderMeshPositions[i]), IsCloseTolerance(clothParticles[i].GetAsVector3(), Tolerance)); } + */ } } // namespace UnitTest diff --git a/Gems/NvCloth/Code/Tests/CryRenderMeshStub.h b/Gems/NvCloth/Code/Tests/CryRenderMeshStub.h deleted file mode 100644 index a81495c79f..0000000000 --- a/Gems/NvCloth/Code/Tests/CryRenderMeshStub.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or - * its licensors. - * - * For complete copyright and license terms please see the LICENSE at the root of this - * distribution (the "License"). All use of this software is governed by the License, - * or, if provided, by the license below or the license accompanying this file. Do not - * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - */ -#pragma once - -#include -#include - -namespace UnitTest -{ - class CryRenderMeshStub - : public IRenderMesh - { - public: - explicit CryRenderMeshStub(const AZStd::vector& vertices) - { - m_positions.reserve(vertices.size()); - for (const auto& vertex : vertices) - { - m_positions.emplace_back(AZVec3ToLYVec3(vertex)); - } - } - - int GetNumVerts() const override - { - return static_cast(m_positions.size()); - } - - byte* GetPosPtr(int32& nStride, uint32 /*nFlags*/) override - { - nStride = sizeof(Vec3); - return reinterpret_cast(m_positions.data()); - } - - AZStd::vector m_positions; - - // ---------------------------------------- - // IRenderMesh unused functions ... - void AddRef() override {} - int Release() override { return 0; } - bool CanRender() override { return false; } - const char* GetTypeName() override { return ""; } - const char* GetSourceName() const override { return ""; } - int GetIndicesCount() override { return 0; } - int GetVerticesCount() override { return 0; } - AZ::Vertex::Format GetVertexFormat() override { return {}; } - ERenderMeshType GetMeshType() override { return eRMT_Dynamic; } - float GetGeometricMeanFaceArea() const override { return 0.0f; } - bool CheckUpdate(uint32 /*nStreamMask*/) override { return false; } - int GetStreamStride(int /*nStream*/) const override { return 0; } - const uintptr_t GetVBStream(int /*nStream*/) const override { return 0; } - const uintptr_t GetIBStream() const override { return 0; } - int GetNumInds() const override { return 0; } - const eRenderPrimitiveType GetPrimitiveType() const override { return static_cast(0); } - void SetSkinned(bool /*bSkinned*/ = true) override {} - uint GetSkinningWeightCount() const override { return 0; } - size_t SetMesh(CMesh& /*mesh*/, int /*nSecColorsSetOffset*/, uint32 /*flags*/, bool /*requiresLock*/) override { return 0; } - void CopyTo(IRenderMesh* /*pDst*/, int /*nAppendVtx*/ = 0, bool /*bDynamic*/ = false, bool /*fullCopy*/ = true) override {} - void SetSkinningDataVegetation(struct SMeshBoneMapping_uint8* /*pBoneMapping*/) override {} - void SetSkinningDataCharacter(CMesh& /*mesh*/, struct SMeshBoneMapping_uint16* /*pBoneMapping*/, struct SMeshBoneMapping_uint16* /*pExtraBoneMapping*/) override {} - IIndexedMesh* GetIndexedMesh(IIndexedMesh* /*pIdxMesh*/ = 0) override { return nullptr; } - int GetRenderChunksCount(_smart_ptr /*pMat*/, int& /*nRenderTrisCount*/) override { return 0; } - IRenderMesh* GenerateMorphWeights() override { return nullptr; } - IRenderMesh* GetMorphBuddy() override { return nullptr; } - void SetMorphBuddy(IRenderMesh* /*pMorph*/) override {} - bool UpdateVertices(const void* /*pVertBuffer*/, int /*nVertCount*/, int /*nOffset*/, int /*nStream*/, uint32 /*copyFlags*/, bool /*requiresLock*/ = true) override { return false; } - bool UpdateIndices(const vtx_idx* /*pNewInds*/, int /*nInds*/, int /*nOffsInd*/, uint32 /*copyFlags*/, bool /*requiresLock*/ = true) override { return false; } - void SetCustomTexID(int /*nCustomTID*/) override {} - void SetChunk(int /*nIndex*/, CRenderChunk& /*chunk*/) override {} - void SetChunk(_smart_ptr /*pNewMat*/, int /*nFirstVertId*/, int /*nVertCount*/, int /*nFirstIndexId*/, int /*nIndexCount*/, float /*texelAreaDensity*/, const AZ::Vertex::Format& /*vertexFormat*/, int /*nMatID*/ = 0) override {} - void SetRenderChunks(CRenderChunk* /*pChunksArray*/, int /*nCount*/, bool /*bSubObjectChunks*/) override {} - void GenerateQTangents() override {} - void CreateChunksSkinned() override {} - void NextDrawSkinned() override {} - IRenderMesh* GetVertexContainer() override { return nullptr; } - void SetVertexContainer(IRenderMesh* /*pBuf*/) override {} - TRenderChunkArray m_chunk; - TRenderChunkArray& GetChunks() override { return m_chunk; } - TRenderChunkArray& GetChunksSkinned() override { return m_chunk; } - TRenderChunkArray& GetChunksSubObjects() override { return m_chunk; } - void SetBBox(const Vec3& /*vBoxMin*/, const Vec3& /*vBoxMax*/) override {} - void GetBBox(Vec3& /*vBoxMin*/, Vec3& /*vBoxMax*/) override {} - void UpdateBBoxFromMesh() override {} - uint32* GetPhysVertexMap() override { return nullptr; } - bool IsEmpty() override { return false; } - byte* GetPosPtrNoCache(int32& /*nStride*/, uint32 /*nFlags*/) override { return nullptr; } - byte* GetColorPtr(int32& /*nStride*/, uint32 /*nFlags*/) override { return nullptr; } - byte* GetNormPtr(int32& /*nStride*/, uint32 /*nFlags*/) override { return nullptr; } - byte* GetUVPtrNoCache(int32& /*nStride*/, uint32 /*nFlags*/, uint32 /*uvSetIndex*/ = 0) override { return nullptr; } - byte* GetUVPtr(int32& /*nStride*/, uint32 /*nFlags*/, uint32 /*uvSetIndex*/ = 0) override { return nullptr; } - byte* GetTangentPtr(int32& /*nStride*/, uint32 /*nFlags*/) override { return nullptr; } - byte* GetQTangentPtr(int32& /*nStride*/, uint32 /*nFlags*/) override { return nullptr; } - byte* GetHWSkinPtr(int32& /*nStride*/, uint32 /*nFlags*/, bool /*remapped*/ = false) override { return nullptr; } - byte* GetVelocityPtr(int32& /*nStride*/, uint32 /*nFlags*/) override { return nullptr; } - void UnlockStream(int /*nStream*/) override {} - void UnlockIndexStream() override {} - vtx_idx* GetIndexPtr(uint32 /*nFlags*/, int32 /*nOffset*/ = 0) override { return nullptr; } - const PodArray >* GetTrisForPosition(const Vec3& /*vPos*/, _smart_ptr /*pMaterial*/) override { return nullptr; } - float GetExtent(EGeomForm /*eForm*/) override { return 0.0f; } - void GetRandomPos(PosNorm& /*ran*/, EGeomForm /*eForm*/, SSkinningData const* /*pSkinning*/ = NULL) override {} - void Render(const struct SRendParams& /*rParams*/, CRenderObject* /*pObj*/, _smart_ptr /*pMaterial*/, const SRenderingPassInfo& /*passInfo*/, bool /*bSkinned*/ = false) override {} - void Render(CRenderObject* /*pObj*/, const SRenderingPassInfo& /*passInfo*/, const SRendItemSorter& /*rendItemSorter*/) override {} - void AddRenderElements(_smart_ptr /*pIMatInfo*/, CRenderObject* /*pObj*/, const SRenderingPassInfo& /*passInfo*/, int /*nSortId*/ = EFSLIST_GENERAL, int /*nAW*/ = 1) override {} - void AddRE(_smart_ptr /*pMaterial*/, CRenderObject* /*pObj*/, IShader* /*pEf*/, const SRenderingPassInfo& /*passInfo*/, int /*nList*/, int /*nAW*/, const SRendItemSorter& /*rendItemSorter*/) override {} - void SetREUserData(float* /*pfCustomData*/, float /*fFogScale*/ = 0, float /*fAlpha*/ = 1) override {} - void DebugDraw(const struct SGeometryDebugDrawInfo& /*info*/, uint32 /*nVisibleChunksMask*/ = ~0, float /*fExtrdueScale*/ = 0.01f) override {} - size_t GetMemoryUsage(ICrySizer* /*pSizer*/, EMemoryUsageArgument /*nType*/) const override { return 0; } - void GetMemoryUsage(ICrySizer* /*pSizer*/) const override {} - int GetAllocatedBytes(bool /*bVideoMem*/) const override { return 0; } - float GetAverageTrisNumPerChunk(_smart_ptr /*pMat*/) override { return 0.0f; } - int GetTextureMemoryUsage(const _smart_ptr /*pMaterial*/, ICrySizer* /*pSizer*/ = NULL, bool /*bStreamedIn*/ = true) const override { return 0; } - void KeepSysMesh(bool /*keep*/) override {} - void UnKeepSysMesh() override {} - void SetMeshLod(int /*nLod*/) override {} - void LockForThreadAccess() override {} - void UnLockForThreadAccess() override {} - volatile int* SetAsyncUpdateState(void) override { return nullptr; } - void CreateRemappedBoneIndicesPair(const DynArray& /*arrRemapTable*/, const uint /*pairGuid*/) override {} - void ReleaseRemappedBoneIndicesPair(const uint /*pairGuid*/) override {} - void OffsetPosition(const Vec3& /*delta*/) override {} - }; -} // namespace UnitTest diff --git a/Gems/NvCloth/Code/Tests/NvClothEditorTestEnvironment.cpp b/Gems/NvCloth/Code/Tests/NvClothEditorTestEnvironment.cpp index e65385722d..1afbe1f476 100644 --- a/Gems/NvCloth/Code/Tests/NvClothEditorTestEnvironment.cpp +++ b/Gems/NvCloth/Code/Tests/NvClothEditorTestEnvironment.cpp @@ -25,7 +25,6 @@ #include #include #include -#include namespace UnitTest { @@ -80,7 +79,6 @@ namespace UnitTest NvCloth::EditorSystemComponent::CreateDescriptor(), NvCloth::EditorClothComponent::CreateDescriptor(), NvCloth::Pipeline::ClothRuleBehavior::CreateDescriptor(), - NvCloth::Pipeline::CgfClothExporter::CreateDescriptor(), }); AddRequiredComponents({ diff --git a/Gems/NvCloth/Code/Tests/Utils/ActorAssetHelperTest.cpp b/Gems/NvCloth/Code/Tests/Utils/ActorAssetHelperTest.cpp index de0ba9031e..ad3a87d5ff 100644 --- a/Gems/NvCloth/Code/Tests/Utils/ActorAssetHelperTest.cpp +++ b/Gems/NvCloth/Code/Tests/Utils/ActorAssetHelperTest.cpp @@ -108,7 +108,6 @@ namespace UnitTest EXPECT_TRUE(assetHelper.get() != nullptr); EXPECT_TRUE(azrtti_cast(assetHelper.get()) != nullptr); - EXPECT_FALSE(assetHelper->DoesSupportSkinnedAnimation()); } TEST_F(NvClothMeshAssetHelper, MeshAssetHelper_CreateAssetHelperWithActor_ReturnsValidMeshAssetHelper) @@ -124,21 +123,6 @@ namespace UnitTest EXPECT_TRUE(assetHelper.get() != nullptr); EXPECT_TRUE(azrtti_cast(assetHelper.get()) != nullptr); - EXPECT_TRUE(assetHelper->DoesSupportSkinnedAnimation()); - } - - TEST_F(NvClothMeshAssetHelper, MeshAssetHelper_DoesSupportSkinnedAnimation_ReturnsTrue) - { - { - auto actor = AZStd::make_unique("actor_test"); - actor->FinishSetup(); - - m_actorComponent->SetActorAsset(CreateAssetFromActor(AZStd::move(actor))); - } - - AZStd::unique_ptr assetHelper = NvCloth::AssetHelper::CreateAssetHelper(m_actorComponent->GetEntityId()); - - EXPECT_TRUE(assetHelper->DoesSupportSkinnedAnimation()); } TEST_F(NvClothMeshAssetHelper, MeshAssetHelper_GatherClothMeshNodesWithEmptyActor_ReturnsEmptyInfo) diff --git a/Gems/NvCloth/Code/nvcloth_editor_files.cmake b/Gems/NvCloth/Code/nvcloth_editor_files.cmake index 8048241f98..c2383f876f 100644 --- a/Gems/NvCloth/Code/nvcloth_editor_files.cmake +++ b/Gems/NvCloth/Code/nvcloth_editor_files.cmake @@ -10,8 +10,6 @@ # set(FILES - Source/Pipeline/RCExt/CgfClothExporter.h - Source/Pipeline/RCExt/CgfClothExporter.cpp Source/Pipeline/SceneAPIExt/ClothRule.h Source/Pipeline/SceneAPIExt/ClothRule.cpp Source/Pipeline/SceneAPIExt/ClothRuleBehavior.h diff --git a/Gems/NvCloth/Code/nvcloth_files.cmake b/Gems/NvCloth/Code/nvcloth_files.cmake index 347ff27b6f..47d4fecdc6 100644 --- a/Gems/NvCloth/Code/nvcloth_files.cmake +++ b/Gems/NvCloth/Code/nvcloth_files.cmake @@ -51,6 +51,4 @@ set(FILES Source/Utils/AssetHelper.cpp Source/Utils/MeshAssetHelper.cpp Source/Utils/MeshAssetHelper.h - Source/Utils/ActorAssetHelper.cpp - Source/Utils/ActorAssetHelper.h ) diff --git a/Gems/NvCloth/Code/nvcloth_tests_files.cmake b/Gems/NvCloth/Code/nvcloth_tests_files.cmake index d027251389..abe1789a66 100644 --- a/Gems/NvCloth/Code/nvcloth_tests_files.cmake +++ b/Gems/NvCloth/Code/nvcloth_tests_files.cmake @@ -18,7 +18,6 @@ set(FILES Tests/ActorHelper.cpp Tests/TriangleInputHelper.h Tests/TriangleInputHelper.cpp - Tests/CryRenderMeshStub.h Tests/System/ClothSystemTest.cpp Tests/System/ClothTest.cpp Tests/System/FabricCookerTest.cpp diff --git a/Gems/NvCloth/gem.json b/Gems/NvCloth/gem.json index a97e9c979d..f71d71e592 100644 --- a/Gems/NvCloth/gem.json +++ b/Gems/NvCloth/gem.json @@ -1,45 +1,8 @@ { "gem_name": "NvCloth", - "GemFormatVersion": 4, - "Uuid": "6ab53783d9f54c9e97a15ad729e7c182", - "Name": "NvCloth", - "DisplayName": "NVIDIA Cloth [PREVIEW]", - "Version": "0.1.0", - "LinkType": "Dynamic", - "Summary": "Provides the functionality needed to add cloth simulation.", - "Tags": ["Physics"], - "IconPath": "preview.png", - "Modules": [ - { - "Type": "GameModule" - }, - { - "Name": "Editor", - "Type": "EditorModule", - "Extends": "GameModule" - } - ], - "Dependencies": [ - { - "Uuid": "ff06785f7145416b9d46fde39098cb0c", - "VersionConstraints": [ - "~>0.1" - ], - "_comment": "LmbrCentral" - }, - { - "Uuid": "4e981f3b17394f5d84d674fff0f54f4f", - "VersionConstraints": [ - "~>0.1" - ], - "_comment": "AtomLyIntegration_CommonFeatures" - }, - { - "Uuid": "044a63ea67d04479aa5daf62ded9d9ca", - "VersionConstraints": [ - "~>0.1" - ], - "_comment": "EMotionFX" - } - ] + "display_name": "NVIDIA Cloth [PREVIEW]", + "summary": "Provides the functionality needed to add cloth simulation.", + "canonical_tags": ["Gem"], + "user_tags": ["Physics"], + "icon_path": "preview.png" } From fd7d3a41ee89305e1f16e78981d15924fc49b24d Mon Sep 17 00:00:00 2001 From: spham Date: Tue, 20 Apr 2021 08:06:27 -0700 Subject: [PATCH 27/32] Removing 'periodic_test_profile' job from Android due to the fact that the Android Virtual Device is not supported on virtualized systems (Windows) --- .../build/Platform/Android/build_config.json | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/scripts/build/Platform/Android/build_config.json b/scripts/build/Platform/Android/build_config.json index e5b41973e0..0b71268a43 100644 --- a/scripts/build/Platform/Android/build_config.json +++ b/scripts/build/Platform/Android/build_config.json @@ -145,23 +145,5 @@ "GRADLE_BUILD_CMD": "build", "ADDITIONAL_GENERATE_ARGS": "" } - }, - "periodic_test_profile": { - "TAGS":[ - "nightly", - "weekly-build-metrics" - ], - "COMMAND":"build_and_run_unit_tests.cmd", - "PARAMETERS": { - "CONFIGURATION":"profile", - "OUTPUT_DIRECTORY":"build\\android_unittest", - "GAME_PROJECT": "AutomatedTesting", - "ANDROID_NDK_PLATFORM": "21", - "ANDROID_SDK_PLATFORM": "29", - "SIGN_APK": "true", - "GRADLE_BUILD_CMD": "assemble", - "ADDITIONAL_GENERATE_ARGS": "--unit-test" - } } - } From 37949abe2505033e6c23205bc9f3c0fdbef6ce2a Mon Sep 17 00:00:00 2001 From: spham Date: Tue, 20 Apr 2021 08:48:52 -0700 Subject: [PATCH 28/32] Restoring original periodic_test_profile block but with the TAGS removed --- scripts/build/Platform/Android/build_config.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/build/Platform/Android/build_config.json b/scripts/build/Platform/Android/build_config.json index 0b71268a43..0fa4d9ade3 100644 --- a/scripts/build/Platform/Android/build_config.json +++ b/scripts/build/Platform/Android/build_config.json @@ -145,5 +145,20 @@ "GRADLE_BUILD_CMD": "build", "ADDITIONAL_GENERATE_ARGS": "" } + }, + "periodic_test_profile": { + "TAGS":[ + ], + "COMMAND":"build_and_run_unit_tests.cmd", + "PARAMETERS": { + "CONFIGURATION":"profile", + "OUTPUT_DIRECTORY":"build\\android_unittest", + "GAME_PROJECT": "AutomatedTesting", + "ANDROID_NDK_PLATFORM": "21", + "ANDROID_SDK_PLATFORM": "29", + "SIGN_APK": "true", + "GRADLE_BUILD_CMD": "assemble", + "ADDITIONAL_GENERATE_ARGS": "--unit-test" + } } } From 1a359ac50d6463cfafed4801ed69c794b2245a8c Mon Sep 17 00:00:00 2001 From: garrieta Date: Tue, 20 Apr 2021 10:51:20 -0500 Subject: [PATCH 29/32] [ATOM-15285] ShaderVariantAssetBuilder code merge bug Fixing what appears to be a code merge/integration bug. Signed-off-by: garrieta --- .../Source/Editor/ShaderVariantAssetBuilder.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderVariantAssetBuilder.cpp b/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderVariantAssetBuilder.cpp index 1e3c7b6759..3572fb72ae 100644 --- a/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderVariantAssetBuilder.cpp +++ b/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderVariantAssetBuilder.cpp @@ -407,17 +407,20 @@ namespace AZ const auto& jobParameters = request.m_jobDescription.m_jobParameters; if (jobParameters.find(ShaderVariantLoadErrorParam) != jobParameters.end()) { - if (jobParameters.find(ShouldExitEarlyFromProcessJobParam) != jobParameters.end()) - { - AZ_TracePrintf(ShaderVariantAssetBuilderName, "Doing nothing on behalf of [%s] because it's been overriden by game project.", jobParameters.at(ShaderVariantLoadErrorParam).c_str()); - response.m_resultCode = AssetBuilderSDK::ProcessJobResult_Success; - return; - } AZ_Error(ShaderVariantAssetBuilderName, false, "Error during CreateJobs: %s", jobParameters.at(ShaderVariantLoadErrorParam).c_str()); response.m_resultCode = AssetBuilderSDK::ProcessJobResult_Failed; return; } + if (jobParameters.find(ShouldExitEarlyFromProcessJobParam) != jobParameters.end()) + { + AZ_TracePrintf( + ShaderVariantAssetBuilderName, "Doing nothing on behalf of [%s] because it's been overriden by game project.", + jobParameters.at(ShaderVariantLoadErrorParam).c_str()); + response.m_resultCode = AssetBuilderSDK::ProcessJobResult_Success; + return; + } + AssetBuilderSDK::JobCancelListener jobCancelListener(request.m_jobId); if (jobCancelListener.IsCancelled()) { From fbc69e5fd7f692d5e93acf3e8ec0a62f4d5be971 Mon Sep 17 00:00:00 2001 From: Chris Galvan Date: Tue, 20 Apr 2021 11:08:51 -0500 Subject: [PATCH 30/32] [LYN-3079] Removed IPickObjectCallback and edit tools that used it. --- Code/Sandbox/Editor/AlignTool.cpp | 142 --------- Code/Sandbox/Editor/AlignTool.h | 40 --- .../Editor/Core/LevelEditorMenuHandler.cpp | 1 - Code/Sandbox/Editor/CryEdit.cpp | 67 ---- Code/Sandbox/Editor/CryEdit.h | 6 - Code/Sandbox/Editor/IEditor.h | 29 -- Code/Sandbox/Editor/IEditorImpl.cpp | 35 --- Code/Sandbox/Editor/IEditorImpl.h | 4 - Code/Sandbox/Editor/Lib/Tests/IEditorMock.h | 3 - Code/Sandbox/Editor/LinkTool.cpp | 286 ------------------ Code/Sandbox/Editor/LinkTool.h | 85 ------ Code/Sandbox/Editor/MainWindow.cpp | 18 -- Code/Sandbox/Editor/PickObjectTool.cpp | 173 ----------- Code/Sandbox/Editor/PickObjectTool.h | 76 ----- Code/Sandbox/Editor/Resource.h | 3 - Code/Sandbox/Editor/ToolbarManager.cpp | 8 - Code/Sandbox/Editor/editor_lib_files.cmake | 6 - 17 files changed, 982 deletions(-) delete mode 100644 Code/Sandbox/Editor/AlignTool.cpp delete mode 100644 Code/Sandbox/Editor/AlignTool.h delete mode 100644 Code/Sandbox/Editor/LinkTool.cpp delete mode 100644 Code/Sandbox/Editor/LinkTool.h delete mode 100644 Code/Sandbox/Editor/PickObjectTool.cpp delete mode 100644 Code/Sandbox/Editor/PickObjectTool.h diff --git a/Code/Sandbox/Editor/AlignTool.cpp b/Code/Sandbox/Editor/AlignTool.cpp deleted file mode 100644 index 4b3aedfbfa..0000000000 --- a/Code/Sandbox/Editor/AlignTool.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "EditorDefs.h" - -#include "AlignTool.h" - -// Editor -#include "Objects/BaseObject.h" -#include "Objects/SelectionGroup.h" - -////////////////////////////////////////////////////////////////////////// -bool CAlignPickCallback::m_bActive = false; - -////////////////////////////////////////////////////////////////////////// -//! Called when object picked. -void CAlignPickCallback::OnPick(CBaseObject* picked) -{ - Matrix34 pickedTM(picked->GetWorldTM()); - - AABB pickedAABB; - picked->GetBoundBox(pickedAABB); - pickedAABB.Move(-pickedTM.GetTranslation()); - Vec3 pickedPivot = pickedAABB.GetCenter(); - - AABB pickedLocalAABB; - picked->GetLocalBounds(pickedLocalAABB); - - const Quat& pickedRot = picked->GetRotation(); - const Vec3& pickedScale = picked->GetScale(); - const Vec3& pickedPos = picked->GetPos(); - - bool bKeepScale = CheckVirtualKey(Qt::Key_Shift); - bool bKeepRotation = CheckVirtualKey(Qt::Key_Alt); - bool bAlignToBoundBox = CheckVirtualKey(Qt::Key_Control); - bool bApplyTransform = !bKeepScale && !bKeepRotation && !bAlignToBoundBox; - - { - bool bUndo = !CUndo::IsRecording(); - if (bUndo) - { - GetIEditor()->BeginUndo(); - } - - CSelectionGroup* selGroup = GetIEditor()->GetSelection(); - selGroup->FilterParents(); - - for (int i = 0; i < selGroup->GetFilteredCount(); i++) - { - CBaseObject* pMovedObj = selGroup->GetFilteredObject(i); - - if (bKeepScale || bKeepRotation || bApplyTransform) - { - if (bKeepScale && bKeepRotation) // Keep scale and rotation of a moved object - { - pMovedObj->SetWorldTM(Matrix34::Create(pMovedObj->GetScale(), pMovedObj->GetRotation(), pickedPos), eObjectUpdateFlags_UserInput); - } - else if (bKeepScale) // Keep only scale of a moved object - { - pMovedObj->SetWorldTM(Matrix34::Create(pMovedObj->GetScale(), pickedRot, pickedPos), eObjectUpdateFlags_UserInput); - } - else if (bKeepRotation) // Keep only rotation of a moved object - { - pMovedObj->SetWorldTM(Matrix34::Create(pickedScale, pMovedObj->GetRotation(), pickedPos), eObjectUpdateFlags_UserInput); - } - else // Scale, Rotation and Position of a picked object are applied to a moved object. - { - pMovedObj->SetWorldTM(pickedTM, eObjectUpdateFlags_UserInput); - } - } - else if (bAlignToBoundBox) // align to the bounding box. - { - if (pickedLocalAABB.GetVolume() == 0.0f) - { - continue; - } - - AABB movedLocalAABB; - pMovedObj->GetLocalBounds(movedLocalAABB); - if (fabs(movedLocalAABB.max.x - movedLocalAABB.min.x) < VEC_EPSILON && - fabs(movedLocalAABB.max.y - movedLocalAABB.min.y) < VEC_EPSILON && - fabs(movedLocalAABB.max.z - movedLocalAABB.min.z) < VEC_EPSILON) - { - continue; - } - - const Vec3& movedScale(pMovedObj->GetScale()); - Matrix34 movedScaleTM = Matrix34::CreateScale(movedScale); - AABB movedLocalScaledAABB; - movedLocalScaledAABB.min = movedScaleTM.TransformVector(movedLocalAABB.min); - movedLocalScaledAABB.max = movedScaleTM.TransformVector(movedLocalAABB.max); - - float fMovedWidth = movedLocalScaledAABB.max.x - movedLocalScaledAABB.min.x; - float fMovedHeight = movedLocalScaledAABB.max.z - movedLocalScaledAABB.min.z; - float fMovedLength = movedLocalScaledAABB.max.y - movedLocalScaledAABB.min.y; - - Matrix34 pickedScaleTM = Matrix34::CreateScale(picked->GetScale()); - AABB pickedLocalScaledAABB; - pickedLocalScaledAABB.min = pickedScaleTM.TransformVector(pickedLocalAABB.min); - pickedLocalScaledAABB.max = pickedScaleTM.TransformVector(pickedLocalAABB.max); - float fScaledPickedtWidth = pickedLocalScaledAABB.max.x - pickedLocalScaledAABB.min.x; - float fScaledPickedHeight = pickedLocalScaledAABB.max.z - pickedLocalScaledAABB.min.z; - float fScaledPickedLength = pickedLocalScaledAABB.max.y - pickedLocalScaledAABB.min.y; - - Vec3 scale((fScaledPickedtWidth / fMovedWidth) * movedScale.x, (fScaledPickedLength / fMovedLength) * movedScale.y, (fScaledPickedHeight / fMovedHeight) * movedScale.z); - Matrix34 scaleRotTM = Matrix34::Create(scale, pickedRot, Vec3(0, 0, 0)); - Vec3 movedPivot = scaleRotTM.TransformVector(movedLocalAABB.GetCenter()); - - pMovedObj->SetWorldTM(Matrix34::Create(scale, pickedRot, Vec3(pickedPos + (pickedPivot - movedPivot))), eObjectUpdateFlags_UserInput); - } - } - m_bActive = false; - if (bUndo) - { - GetIEditor()->AcceptUndo("Align To Object"); - } - } - delete this; -} - -//! Called when pick mode cancelled. -void CAlignPickCallback::OnCancelPick() -{ - m_bActive = false; - delete this; -} - -//! Return true if specified object is pickable. -bool CAlignPickCallback::OnPickFilter([[maybe_unused]] CBaseObject* filterObject) -{ - return true; -}; diff --git a/Code/Sandbox/Editor/AlignTool.h b/Code/Sandbox/Editor/AlignTool.h deleted file mode 100644 index 43cd01013d..0000000000 --- a/Code/Sandbox/Editor/AlignTool.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#ifndef CRYINCLUDE_EDITOR_ALIGNTOOL_H -#define CRYINCLUDE_EDITOR_ALIGNTOOL_H - -#pragma once - -////////////////////////////////////////////////////////////////////////// -class CAlignPickCallback - : public IPickObjectCallback -{ -public: - CAlignPickCallback() { m_bActive = true; }; - //! Called when object picked. - virtual void OnPick(CBaseObject* picked); - //! Called when pick mode cancelled. - virtual void OnCancelPick(); - //! Return true if specified object is pickable. - virtual bool OnPickFilter(CBaseObject* filterObject); - - static bool IsActive() { return m_bActive; } - - virtual bool IsNeedSpecificBehaviorForSpaceAcce() { return true; } -private: - static bool m_bActive; -}; - - -#endif // CRYINCLUDE_EDITOR_ALIGNTOOL_H diff --git a/Code/Sandbox/Editor/Core/LevelEditorMenuHandler.cpp b/Code/Sandbox/Editor/Core/LevelEditorMenuHandler.cpp index 1c9e7d90d2..f00085d5ad 100644 --- a/Code/Sandbox/Editor/Core/LevelEditorMenuHandler.cpp +++ b/Code/Sandbox/Editor/Core/LevelEditorMenuHandler.cpp @@ -580,7 +580,6 @@ void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMe auto alignMenu = modifyMenu.AddMenu(tr("Align")); alignMenu.AddAction(ID_OBJECTMODIFY_ALIGNTOGRID); - alignMenu.AddAction(ID_OBJECTMODIFY_ALIGN); alignMenu.AddAction(ID_MODIFY_ALIGNOBJTOSURF); auto constrainMenu = modifyMenu.AddMenu(tr("Constrain")); diff --git a/Code/Sandbox/Editor/CryEdit.cpp b/Code/Sandbox/Editor/CryEdit.cpp index e4f06a1bc3..7aefcffb5a 100644 --- a/Code/Sandbox/Editor/CryEdit.cpp +++ b/Code/Sandbox/Editor/CryEdit.cpp @@ -95,8 +95,6 @@ AZ_POP_DISABLE_WARNING #include "Core/QtEditorApplication.h" #include "StringDlg.h" -#include "LinkTool.h" -#include "AlignTool.h" #include "VoxelAligningTool.h" #include "NewLevelDialog.h" #include "GridSettingsDialog.h" @@ -400,8 +398,6 @@ void CCryEditApp::RegisterActionHandlers() ON_COMMAND(ID_EDITMODE_MOVE, OnEditmodeMove) ON_COMMAND(ID_EDITMODE_ROTATE, OnEditmodeRotate) ON_COMMAND(ID_EDITMODE_SCALE, OnEditmodeScale) - ON_COMMAND(ID_EDITTOOL_LINK, OnEditToolLink) - ON_COMMAND(ID_EDITTOOL_UNLINK, OnEditToolUnlink) ON_COMMAND(ID_EDITMODE_SELECT, OnEditmodeSelect) ON_COMMAND(ID_EDIT_ESCAPE, OnEditEscape) ON_COMMAND(ID_OBJECTMODIFY_SETAREA, OnObjectSetArea) @@ -421,7 +417,6 @@ void CCryEditApp::RegisterActionHandlers() ON_COMMAND(ID_SELECTION_SAVE, OnSelectionSave) ON_COMMAND(ID_IMPORT_ASSET, OnOpenAssetImporter) ON_COMMAND(ID_SELECTION_LOAD, OnSelectionLoad) - ON_COMMAND(ID_OBJECTMODIFY_ALIGN, OnAlignObject) ON_COMMAND(ID_MODIFY_ALIGNOBJTOSURF, OnAlignToVoxel) ON_COMMAND(ID_OBJECTMODIFY_ALIGNTOGRID, OnAlignToGrid) ON_COMMAND(ID_LOCK_SELECTION, OnLockSelection) @@ -2896,51 +2891,6 @@ void CCryEditApp::OnEditmodeScale() } } -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnEditToolLink() -{ - // TODO: Add your command handler code here - if (qobject_cast(GetIEditor()->GetEditTool())) - { - GetIEditor()->SetEditTool(0); - } - else - { - GetIEditor()->SetEditTool(new CLinkTool()); - } -} - -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnUpdateEditToolLink(QAction* action) -{ - if (!GetIEditor()->GetDocument()) - { - action->setEnabled(false); - return; - } - action->setEnabled(GetIEditor()->GetDocument()->IsDocumentReady()); - CEditTool* pEditTool = GetIEditor()->GetEditTool(); - action->setChecked(qobject_cast(pEditTool) != nullptr); -} - -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnEditToolUnlink() -{ - CUndo undo("Unlink Object(s)"); - CSelectionGroup* pSelection = GetIEditor()->GetObjectManager()->GetSelection(); - for (int i = 0; i < pSelection->GetCount(); i++) - { - CBaseObject* pBaseObj = pSelection->GetObject(i); - pBaseObj->DetachThis(); - } -} - -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnUpdateEditToolUnlink(QAction* action) -{ - action->setEnabled(false); -} - ////////////////////////////////////////////////////////////////////////// void CCryEditApp::OnEditmodeSelect() { @@ -3510,14 +3460,6 @@ void CCryEditApp::OnUpdateSelected(QAction* action) action->setEnabled(!GetIEditor()->GetSelection()->IsEmpty()); } -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnAlignObject() -{ - // Align pick callback will release itself. - CAlignPickCallback* alignCallback = new CAlignPickCallback; - GetIEditor()->PickObject(alignCallback, 0, "Align to Object"); -} - ////////////////////////////////////////////////////////////////////////// void CCryEditApp::OnAlignToGrid() { @@ -3538,15 +3480,6 @@ void CCryEditApp::OnAlignToGrid() } } -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnUpdateAlignObject(QAction* action) -{ - Q_ASSERT(action->isCheckable()); - action->setChecked(CAlignPickCallback::IsActive()); - - action->setEnabled(!GetIEditor()->GetSelection()->IsEmpty()); -} - ////////////////////////////////////////////////////////////////////////// void CCryEditApp::OnAlignToVoxel() { diff --git a/Code/Sandbox/Editor/CryEdit.h b/Code/Sandbox/Editor/CryEdit.h index 6a17f9a8bf..94c39991e9 100644 --- a/Code/Sandbox/Editor/CryEdit.h +++ b/Code/Sandbox/Editor/CryEdit.h @@ -224,10 +224,6 @@ public: void OnEditmodeMove(); void OnEditmodeRotate(); void OnEditmodeScale(); - void OnEditToolLink(); - void OnUpdateEditToolLink(QAction* action); - void OnEditToolUnlink(); - void OnUpdateEditToolUnlink(QAction* action); void OnEditmodeSelect(); void OnEditEscape(); void OnObjectSetArea(); @@ -256,10 +252,8 @@ public: void OnOpenAssetImporter(); void OnSelectionLoad(); void OnUpdateSelected(QAction* action); - void OnAlignObject(); void OnAlignToVoxel(); void OnAlignToGrid(); - void OnUpdateAlignObject(QAction* action); void OnUpdateAlignToVoxel(QAction* action); void OnLockSelection(); void OnEditLevelData(); diff --git a/Code/Sandbox/Editor/IEditor.h b/Code/Sandbox/Editor/IEditor.h index 7715e64fe5..722f2a7c25 100644 --- a/Code/Sandbox/Editor/IEditor.h +++ b/Code/Sandbox/Editor/IEditor.h @@ -391,21 +391,6 @@ enum EModifiedModule eModifiedAll = -1 }; -//! Callback class passed to PickObject. -struct IPickObjectCallback -{ - virtual ~IPickObjectCallback() = default; - - //! Called when object picked. - virtual void OnPick(CBaseObject* picked) = 0; - //! Called when pick mode cancelled. - virtual void OnCancelPick() = 0; - //! Return true if specified object is pickable. - virtual bool OnPickFilter([[maybe_unused]] CBaseObject* filterObject) { return true; }; - //! If need a specific behavior when holding space, return true or if not, return false. - virtual bool IsNeedSpecificBehaviorForSpaceAcce() { return false; } -}; - //! Class provided by editor for various registration functions. struct CRegistrationContext { @@ -570,20 +555,6 @@ struct IEditor //! Get access to object manager. virtual struct IObjectManager* GetObjectManager() = 0; virtual CSettingsManager* GetSettingsManager() = 0; - //! Set pick object mode. - //! When object picked callback will be called, with OnPick - //! If pick operation is canceled Cancel will be called - //! @param targetClass specifies objects of which class are supposed to be picked - //! @param bMultipick if true pick tool will pick multiple object - virtual void PickObject( - IPickObjectCallback* callback, - const QMetaObject* targetClass = 0, - const char* statusText = 0, - bool bMultipick = false) = 0; - //! Cancel current pick operation - virtual void CancelPick() = 0; - //! Return true if editor now in object picking mode - virtual bool IsPicking() = 0; //! Get DB manager that own items of specified type. virtual IDataBaseManager* GetDBItemManager(EDataBaseItemType itemType) = 0; //! Get Manager of Materials. diff --git a/Code/Sandbox/Editor/IEditorImpl.cpp b/Code/Sandbox/Editor/IEditorImpl.cpp index 4a0a73c9ac..399ac45794 100644 --- a/Code/Sandbox/Editor/IEditorImpl.cpp +++ b/Code/Sandbox/Editor/IEditorImpl.cpp @@ -65,7 +65,6 @@ AZ_POP_DISABLE_WARNING #include "UIEnumsDatabase.h" #include "Util/Ruler.h" #include "RenderHelpers/AxisHelper.h" -#include "PickObjectTool.h" #include "Settings.h" #include "Include/IObjectManager.h" #include "Include/ISourceControl.h" @@ -170,7 +169,6 @@ CEditorImpl::CEditorImpl() , m_pShaderEnum(nullptr) , m_pIconManager(nullptr) , m_bSelectionLocked(true) - , m_pPickTool(nullptr) , m_pAxisGizmo(nullptr) , m_pGameEngine(nullptr) , m_pAnimationContext(nullptr) @@ -794,11 +792,6 @@ void CEditorImpl::SetEditTool(CEditTool* tool, bool bStopCurrentTool) m_pEditTool->BeginEditParams(this, 0); } - // Make sure pick is aborted. - if (tool != m_pPickTool) - { - m_pPickTool = nullptr; - } Notify(eNotify_OnEditToolChange); } @@ -1069,34 +1062,6 @@ bool CEditorImpl::IsSelectionLocked() return m_bSelectionLocked; } -void CEditorImpl::PickObject(IPickObjectCallback* callback, const QMetaObject* targetClass, const char* statusText, bool bMultipick) -{ - m_pPickTool = new CPickObjectTool(callback, targetClass); - - static_cast(m_pPickTool.get())->SetMultiplePicks(bMultipick); - if (statusText) - { - m_pPickTool.get()->SetStatusText(statusText); - } - - SetEditTool(m_pPickTool); -} - -void CEditorImpl::CancelPick() -{ - SetEditTool(0); - m_pPickTool = 0; -} - -bool CEditorImpl::IsPicking() -{ - if (GetEditTool() == m_pPickTool && m_pPickTool != 0) - { - return true; - } - return false; -} - CViewManager* CEditorImpl::GetViewManager() { return m_pViewManager; diff --git a/Code/Sandbox/Editor/IEditorImpl.h b/Code/Sandbox/Editor/IEditorImpl.h index 9e3b3abc66..4a8d5fa191 100644 --- a/Code/Sandbox/Editor/IEditorImpl.h +++ b/Code/Sandbox/Editor/IEditorImpl.h @@ -181,10 +181,7 @@ public: void SelectObject(CBaseObject* obj); void LockSelection(bool bLock); bool IsSelectionLocked(); - void PickObject(IPickObjectCallback* callback, const QMetaObject* targetClass = 0, const char* statusText = 0, bool bMultipick = false); - void CancelPick(); - bool IsPicking(); IDataBaseManager* GetDBItemManager(EDataBaseItemType itemType); CMaterialManager* GetMaterialManager() { return m_pMaterialManager; } CMusicManager* GetMusicManager() { return m_pMusicManager; }; @@ -409,7 +406,6 @@ protected: QString m_primaryCDFolder; QString m_userFolder; bool m_bSelectionLocked; - _smart_ptr m_pPickTool; class CAxisGizmo* m_pAxisGizmo; CGameEngine* m_pGameEngine; CAnimationContext* m_pAnimationContext; diff --git a/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h b/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h index a290ef5de5..e48fb5fec1 100644 --- a/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h +++ b/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h @@ -90,9 +90,6 @@ public: MOCK_METHOD0(IsSelectionLocked, bool()); MOCK_METHOD0(GetObjectManager, struct IObjectManager* ()); MOCK_METHOD0(GetSettingsManager, CSettingsManager* ()); - MOCK_METHOD4(PickObject, void(IPickObjectCallback*,const QMetaObject*,const char* ,bool bMultipick)); - MOCK_METHOD0(CancelPick, void()); - MOCK_METHOD0(IsPicking, bool()); MOCK_METHOD1(GetDBItemManager, IDataBaseManager* (EDataBaseItemType)); MOCK_METHOD0(GetMaterialManager, CMaterialManager* ()); MOCK_METHOD0(GetMaterialManagerLibrary, IBaseLibraryManager* ()); diff --git a/Code/Sandbox/Editor/LinkTool.cpp b/Code/Sandbox/Editor/LinkTool.cpp deleted file mode 100644 index 4602875b77..0000000000 --- a/Code/Sandbox/Editor/LinkTool.cpp +++ /dev/null @@ -1,286 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "EditorDefs.h" - -#include "LinkTool.h" - -// Editor -#include "Viewport.h" -#include "Objects/EntityObject.h" -#include "Objects/SelectionGroup.h" -#include - -// AzCore -#include - -#ifdef LoadCursor -#undef LoadCursor -#endif - -namespace -{ - const float kGeomCacheNodePivotSizeScale = 0.0025f; -} - -////////////////////////////////////////////////////////////////////////// -CLinkTool::CLinkTool() - : m_nodeName(nullptr) - , m_pGeomCacheRenderNode(nullptr) -{ - m_pChild = NULL; - SetStatusText("Click on object and drag a link to a new parent"); - - m_hLinkCursor = CMFCUtils::LoadCursor(IDC_POINTER_LINK); - m_hLinkNowCursor = CMFCUtils::LoadCursor(IDC_POINTER_LINKNOW); - m_hCurrCursor = &m_hLinkCursor; - AZ::EntitySystemBus::Handler::BusConnect(); -} - -////////////////////////////////////////////////////////////////////////// -CLinkTool::~CLinkTool() -{ - AZ::EntitySystemBus::Handler::BusDisconnect(); -} - -////////////////////////////////////////////////////////////////////////// -void CLinkTool::LinkObject(CBaseObject* pChild, CBaseObject* pParent) -{ - if (pChild == NULL) - { - return; - } - - if (ChildIsValid(pParent, pChild)) - { - CUndo undo("Link Object"); - - if (qobject_cast(pChild)) - { - static_cast(pChild)->SetAttachTarget(""); - static_cast(pChild)->SetAttachType(CEntityObject::eAT_Pivot); - } - - pParent->AttachChild(pChild, true); - - QString str; - str = tr("%1 attached to %2").arg(pChild->GetName(), pParent->GetName()); - SetStatusText(str); - } - else - { - SetStatusText("Error: Cyclic linking or already linked."); - } -} - -////////////////////////////////////////////////////////////////////////// -void CLinkTool::LinkSelectedToParent(CBaseObject* pParent) -{ - if (pParent) - { - if (IsRelevant(pParent)) - { - CSelectionGroup* pSel = GetIEditor()->GetSelection(); - if (!pSel->GetCount()) - { - return; - } - CUndo undo("Link Object(s)"); - for (int i = 0; i < pSel->GetCount(); i++) - { - CBaseObject* pChild = pSel->GetObject(i); - if (pChild == pParent) - { - continue; - } - LinkObject(pChild, pParent); - } - } - } -} - -////////////////////////////////////////////////////////////////////////// -bool CLinkTool::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, [[maybe_unused]] int flags) -{ - view->SetCursorString(""); - - m_hCurrCursor = &m_hLinkCursor; - if (event == eMouseLDown) - { - HitContext hitInfo; - view->HitTest(point, hitInfo); - CBaseObject* obj = hitInfo.object; - if (obj) - { - if (IsRelevant(obj)) - { - m_StartDrag = obj->GetWorldPos(); - m_pChild = obj; - } - } - } - else if (event == eMouseLUp) - { - HitContext hitInfo; - view->HitTest(point, hitInfo); - CBaseObject* obj = hitInfo.object; - if (obj) - { - if (IsRelevant(obj)) - { - CSelectionGroup* pSelectionGroup = GetIEditor()->GetSelection(); - int nGroupCount = pSelectionGroup->GetCount(); - if (pSelectionGroup && nGroupCount > 1) - { - LinkSelectedToParent(obj); - } - if (!pSelectionGroup || nGroupCount <= 1 || !pSelectionGroup->IsContainObject(m_pChild)) - { - LinkObject(m_pChild, obj); - } - } - } - m_pChild = NULL; - } - else if (event == eMouseMove) - { - m_EndDrag = view->ViewToWorld(point); - m_nodeName = nullptr; - m_pGeomCacheRenderNode = nullptr; - - HitContext hitInfo; - if (view->HitTest(point, hitInfo)) - { - m_EndDrag = hitInfo.raySrc + hitInfo.rayDir * hitInfo.dist; - } - - CBaseObject* obj = hitInfo.object; - if (obj) - { - if (IsRelevant(obj)) - { - QString name = obj->GetName(); - if (hitInfo.name) - { - name += QString("\n ") + hitInfo.name; - } - - // Set Cursors. - view->SetCursorString(name); - if (m_pChild) - { - if (ChildIsValid(obj, m_pChild)) - { - m_hCurrCursor = &m_hLinkNowCursor; - } - } - } - } - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CLinkTool::OnKeyDown([[maybe_unused]] CViewport* view, uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) -{ - if (nChar == VK_ESCAPE) - { - // Cancel selection. - GetIEditor()->SetEditTool(nullptr); - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -void CLinkTool::Display(DisplayContext& dc) -{ - if (m_pChild && m_EndDrag != Vec3(ZERO)) - { - ColorF lineColor = (m_hCurrCursor == &m_hLinkNowCursor) ? ColorF(0, 1, 0) : ColorF(1, 0, 0); - dc.DrawLine(m_StartDrag, m_EndDrag, lineColor, lineColor); - } -} - -////////////////////////////////////////////////////////////////////////// -void CLinkTool::OnEntityDestruction(const AZ::EntityId& entityId) -{ - if (m_pChild && (m_pChild->GetType() == OBJTYPE_AZENTITY)) - { - CComponentEntityObject* childComponentEntity = static_cast(m_pChild); - AZ::EntityId childEntityId = childComponentEntity->GetAssociatedEntityId(); - if(entityId == childEntityId) - { - GetIEditor()->SetEditTool(nullptr); - } - } -} - -////////////////////////////////////////////////////////////////////////// -bool CLinkTool::ChildIsValid(CBaseObject* pParent, CBaseObject* pChild, int nDir) -{ - if (!pParent) - { - return false; - } - if (!pChild) - { - return false; - } - if (pParent == pChild) - { - return false; - } - - // Legacy entities and AZ entities shouldn't be linked. - if ((pParent->GetType() == OBJTYPE_AZENTITY) != (pChild->GetType() == OBJTYPE_AZENTITY)) - { - return false; - } - - CBaseObject* pObj; - if (nDir & 1) - { - pObj = pChild->GetParent(); - if (pObj) - { - if (!ChildIsValid(pParent, pObj, 1)) - { - return false; - } - } - } - if (nDir & 2) - { - for (int i = 0; i < pChild->GetChildCount(); i++) - { - pObj = pChild->GetChild(i); - if (pObj) - { - if (!ChildIsValid(pParent, pObj, 2)) - { - return false; - } - } - } - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CLinkTool::OnSetCursor(CViewport* vp) -{ - vp->SetCursor(*m_hCurrCursor); - return true; -} - -#include diff --git a/Code/Sandbox/Editor/LinkTool.h b/Code/Sandbox/Editor/LinkTool.h deleted file mode 100644 index a24370f7fe..0000000000 --- a/Code/Sandbox/Editor/LinkTool.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : Definition of CLinkTool, tool used to link objects. - - -#ifndef CRYINCLUDE_EDITOR_LINKTOOL_H -#define CRYINCLUDE_EDITOR_LINKTOOL_H - -#pragma once - -#if !defined(Q_MOC_RUN) -#include -#include "EditTool.h" -#include "Include/IObjectManager.h" -#endif - -class CEntityObject; - -////////////////////////////////////////////////////////////////////////// -class CLinkTool - : public CEditTool - , public IObjectSelectCallback - , private AZ::EntitySystemBus::Handler -{ - Q_OBJECT -public: - Q_INVOKABLE CLinkTool(); // IPickObjectCallback *callback,CRuntimeClass *targetClass=NULL ); - - // Ovverides from CEditTool - bool MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags); - - virtual void BeginEditParams([[maybe_unused]] IEditor* ie, [[maybe_unused]] int flags) {}; - virtual void EndEditParams() {}; - - virtual void Display(DisplayContext& dc); - virtual bool OnKeyDown(CViewport* view, uint32 nChar, uint32 nRepCnt, uint32 nFlags); - virtual bool OnKeyUp([[maybe_unused]] CViewport* view, [[maybe_unused]] uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) { return false; }; - - virtual bool OnSelectObject([[maybe_unused]] CBaseObject* obj) {return false; } - virtual bool CanSelectObject([[maybe_unused]] CBaseObject* obj) { return true; }; - - virtual bool OnSetCursor(CViewport* vp); - - void LinkSelectedToParent(CBaseObject* pParent); - -protected: - virtual ~CLinkTool(); - // Delete itself. - void DeleteThis() { delete this; }; - -private: - bool IsRelevant([[maybe_unused]] CBaseObject* obj) { return true; } - bool ChildIsValid(CBaseObject* pParent, CBaseObject* pChild, int nDir = 3); - void LinkObject(CBaseObject* pChild, CBaseObject* pParent); - void LinkToNode(CEntityObject* pChild, CEntityObject* pParent, const char* nodeName); - - // AZ::EntitySystemBus::Handler - void OnEntityDestruction(const AZ::EntityId& entityId) override; - - - CBaseObject* m_pChild; - Vec3 m_StartDrag; - Vec3 m_EndDrag; - - QCursor m_hLinkCursor; - QCursor m_hLinkNowCursor; - QCursor* m_hCurrCursor; - - const char* m_nodeName; - IGeomCacheRenderNode* m_pGeomCacheRenderNode; -}; - - -#endif // CRYINCLUDE_EDITOR_LINKTOOL_H diff --git a/Code/Sandbox/Editor/MainWindow.cpp b/Code/Sandbox/Editor/MainWindow.cpp index b926c00fc8..6acd8cfc20 100644 --- a/Code/Sandbox/Editor/MainWindow.cpp +++ b/Code/Sandbox/Editor/MainWindow.cpp @@ -1104,15 +1104,6 @@ void MainWindow::InitActions() .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSelected) .SetIcon(Style::icon("Align_to_grid")) .SetApplyHoverEffect(); - am->AddAction(ID_OBJECTMODIFY_ALIGN, tr("Align to object")).SetCheckable(true) -#if AZ_TRAIT_OS_PLATFORM_APPLE - .SetStatusTip(tr(u8"\u2318: Align an object to a bounding box, \u2325 : Keep Rotation of the moved object, Shift : Keep Scale of the moved object")) -#else - .SetStatusTip(tr("Ctrl: Align an object to a bounding box, Alt : Keep Rotation of the moved object, Shift : Keep Scale of the moved object")) -#endif - .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateAlignObject) - .SetIcon(Style::icon("Align_to_Object")) - .SetApplyHoverEffect(); am->AddAction(ID_MODIFY_ALIGNOBJTOSURF, tr("Align object to surface (Hold CTRL)")).SetCheckable(true) .SetToolTip(tr("Align object to surface (Hold CTRL)")) .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateAlignToVoxel) @@ -1449,15 +1440,6 @@ void MainWindow::InitActions() .SetApplyHoverEffect(); // Edit Mode Toolbar Actions - am->AddAction(ID_EDITTOOL_LINK, tr("Link an object to parent")) - .SetIcon(Style::icon("add_link")) - .SetApplyHoverEffect() - .SetCheckable(true) - .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateEditToolLink); - am->AddAction(ID_EDITTOOL_UNLINK, tr("Unlink all selected objects")) - .SetIcon(Style::icon("remove_link")) - .SetApplyHoverEffect() - .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateEditToolUnlink); am->AddAction(IDC_SELECTION_MASK, tr("Selected Object Types")); am->AddAction(ID_REF_COORDS_SYS, tr("Reference coordinate system")) .SetShortcut(tr("Ctrl+W")) diff --git a/Code/Sandbox/Editor/PickObjectTool.cpp b/Code/Sandbox/Editor/PickObjectTool.cpp deleted file mode 100644 index dc1fce110e..0000000000 --- a/Code/Sandbox/Editor/PickObjectTool.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "EditorDefs.h" - -#include "PickObjectTool.h" - -// Editor -#include "Viewport.h" -#include "Include/HitContext.h" -#include "Objects/BaseObject.h" - - -////////////////////////////////////////////////////////////////////////// -CPickObjectTool::CPickObjectTool(IPickObjectCallback* callback, const QMetaObject* targetClass) -{ - assert(callback != 0); - m_callback = callback; - m_targetClass = targetClass; - m_bMultiPick = false; -} - -////////////////////////////////////////////////////////////////////////// -CPickObjectTool::~CPickObjectTool() -{ - GetIEditor()->GetObjectManager()->SetSelectCallback(0); - //m_prevSelectCallback = 0; - if (m_callback) - { - m_callback->OnCancelPick(); - } -} - -////////////////////////////////////////////////////////////////////////// -void CPickObjectTool::BeginEditParams([[maybe_unused]] IEditor* ie, [[maybe_unused]] int flags) -{ - QString str = "Pick object"; - if (m_targetClass) - { - str = tr("Pick %1 object").arg(m_targetClass->className()); - } - SetStatusText(str); - - //m_prevSelectCallback = - GetIEditor()->GetObjectManager()->SetSelectCallback(this); -} - -////////////////////////////////////////////////////////////////////////// -bool CPickObjectTool::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, [[maybe_unused]] int flags) -{ - if (event == eMouseLDown) - { - HitContext hitInfo; - view->HitTest(point, hitInfo); - CBaseObject* obj = hitInfo.object; - if (obj) - { - if (IsRelevant(obj)) - { - if (m_callback) - { - // Can pick this one. - m_callback->OnPick(obj); - } - if (!m_bMultiPick) - { - m_callback = 0; - GetIEditor()->SetEditTool(0); - } - } - } - } - else if (event == eMouseMove) - { - HitContext hitInfo; - view->HitTest(point, hitInfo); - CBaseObject* obj = hitInfo.object; - if (obj) - { - if (IsRelevant(obj)) - { - // Set Cursors. - view->SetCurrentCursor(STD_CURSOR_HIT, obj->GetName()); - } - } - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CPickObjectTool::OnSelectObject(CBaseObject* obj) -{ - if (IsRelevant(obj)) - { - // Can pick this one. - if (m_callback) - { - m_callback->OnPick(obj); - m_callback = 0; - } - if (!m_bMultiPick) - { - GetIEditor()->SetEditTool(0); - } - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CPickObjectTool::CanSelectObject(CBaseObject* obj) -{ - return IsRelevant(obj); -} - -////////////////////////////////////////////////////////////////////////// -bool CPickObjectTool::OnKeyDown([[maybe_unused]] CViewport* view, uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) -{ - if (nChar == VK_ESCAPE) - { - // Cancel selection. - GetIEditor()->SetEditTool(0); - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CPickObjectTool::IsRelevant(CBaseObject* obj) -{ - assert(obj != 0); - if (obj == NULL) - { - return false; - } - if (!m_callback) - { - return false; - } - - if (!m_targetClass) - { - return m_callback->OnPickFilter(obj); - } - else - { - if (obj->metaObject() == m_targetClass || m_targetClass->cast(obj)) - { - return m_callback->OnPickFilter(obj); - } - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CPickObjectTool::IsNeedSpecificBehaviorForSpaceAcce() -{ - if (m_callback && m_callback->IsNeedSpecificBehaviorForSpaceAcce()) - { - return true; - } - return false; -} - -#include diff --git a/Code/Sandbox/Editor/PickObjectTool.h b/Code/Sandbox/Editor/PickObjectTool.h deleted file mode 100644 index 3b0241042a..0000000000 --- a/Code/Sandbox/Editor/PickObjectTool.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : Definition of PickObjectTool, tool used to pick objects. - - -#ifndef CRYINCLUDE_EDITOR_PICKOBJECTTOOL_H -#define CRYINCLUDE_EDITOR_PICKOBJECTTOOL_H - -#if !defined(Q_MOC_RUN) -#include "EditTool.h" -#include "IObjectManager.h" -#endif - -#pragma once - -////////////////////////////////////////////////////////////////////////// -class CPickObjectTool - : public CEditTool - , public IObjectSelectCallback -{ - Q_OBJECT -public: - CPickObjectTool(IPickObjectCallback* callback, const QMetaObject* targetClass = NULL); - - //! If set to true, pick tool will not stop picking after first pick. - void SetMultiplePicks(bool bEnable) { m_bMultiPick = bEnable; }; - - // Ovverides from CEditTool - bool MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags); - - virtual void BeginEditParams(IEditor* ie, int flags); - virtual void EndEditParams() {}; - - virtual void Display([[maybe_unused]] DisplayContext& dc) {}; - virtual bool OnKeyDown(CViewport* view, uint32 nChar, uint32 nRepCnt, uint32 nFlags); - virtual bool OnKeyUp([[maybe_unused]] CViewport* view, [[maybe_unused]] uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) { return false; }; - - ////////////////////////////////////////////////////////////////////////// - // IObjectSelectCallback - ////////////////////////////////////////////////////////////////////////// - virtual bool OnSelectObject(CBaseObject* obj); - virtual bool CanSelectObject(CBaseObject* obj); - ////////////////////////////////////////////////////////////////////////// - - virtual bool IsNeedSpecificBehaviorForSpaceAcce(); - -protected: - virtual ~CPickObjectTool(); - // Delete itself. - void DeleteThis() { delete this; }; - -private: - bool IsRelevant(CBaseObject* obj); - - //! Object that requested pick. - IPickObjectCallback* m_callback; - - //! If target class specified, will pick only objects that belongs to that runtime class. - const QMetaObject* m_targetClass; - - bool m_bMultiPick; -}; - - -#endif // CRYINCLUDE_EDITOR_PICKOBJECTTOOL_H diff --git a/Code/Sandbox/Editor/Resource.h b/Code/Sandbox/Editor/Resource.h index a4bd2c1143..afcd0c7a6f 100644 --- a/Code/Sandbox/Editor/Resource.h +++ b/Code/Sandbox/Editor/Resource.h @@ -181,8 +181,6 @@ #define ID_TV_STOP 33568 #define ID_TV_PAUSE 33569 #define ID_ADDNODE 33570 -#define ID_EDITTOOL_LINK 33571 -#define ID_EDITTOOL_UNLINK 33572 #define ID_ADDSCENETRACK 33573 #define ID_FIND 33574 #define ID_SNAP_TO_GRID 33575 @@ -214,7 +212,6 @@ #define ID_TV_JUMPSTART 33601 #define ID_TV_PREVKEY 33602 #define ID_TV_NEXTKEY 33603 -#define ID_OBJECTMODIFY_ALIGN 33604 #define ID_PLAY_LOOP 33607 #define ID_TERRAIN 33611 #define ID_OBJECTMODIFY_ALIGNTOGRID 33619 diff --git a/Code/Sandbox/Editor/ToolbarManager.cpp b/Code/Sandbox/Editor/ToolbarManager.cpp index 4679f9cb6a..d39dabf034 100644 --- a/Code/Sandbox/Editor/ToolbarManager.cpp +++ b/Code/Sandbox/Editor/ToolbarManager.cpp @@ -585,13 +585,6 @@ AmazonToolbar ToolbarManager::GetEditModeToolbar() const t.AddAction(ID_TOOLBAR_WIDGET_UNDO, ORIGINAL_TOOLBAR_VERSION); t.AddAction(ID_TOOLBAR_WIDGET_REDO, ORIGINAL_TOOLBAR_VERSION); - if (!GetIEditor()->IsNewViewportInteractionModelEnabled()) - { - t.AddAction(ID_TOOLBAR_SEPARATOR, ORIGINAL_TOOLBAR_VERSION); - t.AddAction(ID_EDITTOOL_LINK, ORIGINAL_TOOLBAR_VERSION); - t.AddAction(ID_EDITTOOL_UNLINK, ORIGINAL_TOOLBAR_VERSION); - } - t.AddAction(ID_TOOLBAR_SEPARATOR, ORIGINAL_TOOLBAR_VERSION); if (!GetIEditor()->IsNewViewportInteractionModelEnabled()) @@ -630,7 +623,6 @@ AmazonToolbar ToolbarManager::GetObjectToolbar() const AmazonToolbar t = AmazonToolbar("Object", QObject::tr("Object Toolbar")); t.SetMainToolbar(true); t.AddAction(ID_GOTO_SELECTED, ORIGINAL_TOOLBAR_VERSION); - t.AddAction(ID_OBJECTMODIFY_ALIGN, ORIGINAL_TOOLBAR_VERSION); t.AddAction(ID_OBJECTMODIFY_ALIGNTOGRID, ORIGINAL_TOOLBAR_VERSION); t.AddAction(ID_OBJECTMODIFY_SETHEIGHT, ORIGINAL_TOOLBAR_VERSION); t.AddAction(ID_MODIFY_ALIGNOBJTOSURF, ORIGINAL_TOOLBAR_VERSION); diff --git a/Code/Sandbox/Editor/editor_lib_files.cmake b/Code/Sandbox/Editor/editor_lib_files.cmake index c91d6ce428..5696931f26 100644 --- a/Code/Sandbox/Editor/editor_lib_files.cmake +++ b/Code/Sandbox/Editor/editor_lib_files.cmake @@ -533,8 +533,6 @@ set(FILES Dialogs/PythonScriptsDialog.ui Dialogs/Generic/UserOptions.cpp Dialogs/Generic/UserOptions.h - AlignTool.cpp - AlignTool.h ObjectCloneTool.cpp ObjectCloneTool.h EditMode/SubObjectSelectionReferenceFrameCalculator.cpp @@ -545,10 +543,6 @@ set(FILES RotateTool.h EditTool.cpp EditTool.h - LinkTool.cpp - LinkTool.h - PickObjectTool.cpp - PickObjectTool.h VoxelAligningTool.cpp VoxelAligningTool.h Export/ExportManager.cpp From 8804ab8f1f6990418df4afba0a5e9b889c8f0cbe Mon Sep 17 00:00:00 2001 From: Brian Herrera Date: Tue, 20 Apr 2021 09:56:46 -0700 Subject: [PATCH 31/32] Add script to sync repo with upstream --- scripts/build/tools/sync_repo.py | 153 +++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 scripts/build/tools/sync_repo.py diff --git a/scripts/build/tools/sync_repo.py b/scripts/build/tools/sync_repo.py new file mode 100644 index 0000000000..0275cc6661 --- /dev/null +++ b/scripts/build/tools/sync_repo.py @@ -0,0 +1,153 @@ +# +# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +# its licensors. +# +# For complete copyright and license terms please see the LICENSE at the root of this +# distribution (the "License"). All use of this software is governed by the License, +# or, if provided, by the license below or the license accompanying this file. Do not +# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# + +import argparse +import boto3 +import logging +import os +import subprocess +import sys + +from botocore.exceptions import ClientError +from urllib.parse import urlparse, urlunparse + +log = logging.getLogger(__name__) +log.setLevel(logging.INFO) + +DEFAULT_BRANCH = "main" +DEFAULT_WORKSPACE_ROOT = "." + + +class MergeError(Exception): + pass + + +class SyncRepo: + """A git repo with configured remotes to sync with GitHub. + + Used by the sync pipeline to push branches to GitHub and pull down latest from main. Changes flow from + the upstream remote down to origin. Remotes can be swapped to pull changes in the other direction. + + Attributes: + origin: URL for the origin repo. This is the target for the sync. + upstream: URL for the upstream repo. This is the source with the latest changes. + workspace_root: Path to the parent directory for the local workspace. + parameter: Name of the parameter used to store GitHub credentials. + + """ + + def __init__(self, origin, upstream, workspace_root, region=None, parameter=None): + self.workspace_root = workspace_root + self.parameter = parameter + self.region = region + + if self.parameter and self.region: + log.info(f"Adding credentials from {self.parameter} in {self.region}") + self.origin = self._add_credentials(origin) + self.upstream = self._add_credentials(upstream) + else: + self.origin = origin + self.upstream = upstream + + self.origin_name = self.origin.split("/")[-1] + self.upstream_name = self.upstream.split("/")[-1] + self.workspace = os.path.join(workspace_root, self.origin_name) + + def _add_credentials(self, url): + """Add credentials to a github repo URL from parameter store.""" + parsed_url = urlparse(url) + if parsed_url.netloc == "github.com": + try: + ssm = boto3.client("ssm", self.region) + credentials = ssm.get_parameter( + Name=self.parameter, + WithDecryption=True + )["Parameter"]["Value"] + url = urlunparse(parsed_url._replace(netloc=f"{credentials}@github.com")) + except ClientError as e: + log.error(f"Error retrieving credentials from parameter store: {e}") + return url + + def clone(self): + """Clones repo to the instance workspace. Refreshes remote configs for existing repos.""" + if not os.path.exists(self.workspace): + os.mkdir(self.workspace) + + if subprocess.run(["git", "rev-parse", "--is-inside-work-tree"], cwd=self.workspace).returncode != 0: + log.info(f"Cloning repo {self.origin} to {self.workspace}.") + subprocess.run(["git", "clone", self.origin, self.origin_name], cwd=self.workspace_root, check=True) + subprocess.run(["git", "remote", "add", "upstream", self.upstream], cwd=self.workspace) + else: + log.info("Update remote config for existing repos.") + subprocess.run(["git", "remote", "set-url", "origin", self.origin], cwd=self.workspace) + subprocess.run(["git", "remote", "set-url", "upstream", self.upstream], cwd=self.workspace) + + def sync(self, branch): + """Fetches latest from upstream and syncs changes to origin. + + Syncs are one-way and conflicts are not expected. Fast-forward merges are performed if possible. If a + fast-forward merge is not possible, a merge will not be attempted and will raise an exception. + + The checkout command will create a new branch from upstream/ if it does not exist in origin. The + remote will be remapped to origin during the push. + + Args: + branch: Name of the upstream branch to sync with origin. + + Raises: + MergeError: An error occured when attempting to merge to the target branch. + + """ + subprocess.run(["git", "fetch", "origin"], cwd=self.workspace, check=True) + subprocess.run(["git", "fetch", "upstream"], cwd=self.workspace, check=True) + subprocess.run(["git", "checkout", branch], cwd=self.workspace, check=True) + + # If the branch exists in origin, merge from upstream. New branches do not require a merge. + if subprocess.run(["git", "ls-remote", "--exit-code", "-h", "origin", branch], cwd=self.workspace).returncode == 0: + subprocess.run(["git", "reset", "--hard", "HEAD"], cwd=self.workspace, check=True) + subprocess.run(["git", "pull"], cwd=self.workspace, check=True) + + if subprocess.run(["git", "merge", "--ff-only", f"upstream/{branch}"], cwd=self.workspace).returncode != 0: + raise MergeError(f"Unable to perform ff merge to target branch: {self.origin}/{branch} Intervention required.") + + subprocess.run(["git", "push", "-u", "origin", branch], cwd=self.workspace, check=True) + + +def process_args(): + """Process arguements. + + Example: + sync_repo.py [Options] + + """ + parser = argparse.ArgumentParser() + parser.add_argument("upstream") + parser.add_argument("origin") + parser.add_argument("-b", "--branch", default=DEFAULT_BRANCH) + parser.add_argument("-w", "--workspace-root", default=DEFAULT_WORKSPACE_ROOT) + parser.add_argument("-r", "--region", default=None) + parser.add_argument("-p", "--parameter", default=None) + return parser.parse_args() + + +def main(): + args = process_args() + + repo = SyncRepo(args.origin, args.upstream, args.workspace_root, args.region, args.parameter) + repo.clone() + try: + repo.sync(args.branch) + except MergeError as e: + log.error(e) + + +if __name__ == "__main__": + sys.exit(main()) From 33b485767f584bef006049ed3beb792325190830 Mon Sep 17 00:00:00 2001 From: nvsickle Date: Tue, 20 Apr 2021 11:49:59 -0700 Subject: [PATCH 32/32] Address reviewer feedback, make FFont initialization state an atomic state machine --- .../AtomLyIntegration/AtomFont/FFont.h | 9 +++++-- .../AtomFont/Code/Source/FFont.cpp | 24 ++++++++----------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Gems/AtomLyIntegration/AtomFont/Code/Include/AtomLyIntegration/AtomFont/FFont.h b/Gems/AtomLyIntegration/AtomFont/Code/Include/AtomLyIntegration/AtomFont/FFont.h index 91fc0834ec..8e60cc2055 100644 --- a/Gems/AtomLyIntegration/AtomFont/Code/Include/AtomLyIntegration/AtomFont/FFont.h +++ b/Gems/AtomLyIntegration/AtomFont/Code/Include/AtomLyIntegration/AtomFont/FFont.h @@ -301,8 +301,13 @@ namespace AZ AtomFont* m_atomFont = nullptr; bool m_fontTexDirty = false; - bool m_fontInitialized = false; - AZStd::atomic_bool m_fontInitializing = false; + enum class InitializationState : AZ::u8 + { + Uninitialized, + Initializing, + Initialized + }; + AZStd::atomic m_fontInitializationState = InitializationState::Uninitialized; FontEffects m_effects; diff --git a/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp b/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp index edbf148940..20879876e7 100644 --- a/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp +++ b/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp @@ -101,19 +101,16 @@ AZ::RPI::WindowContextSharedPtr AZ::FFont::GetDefaultWindowContext() const bool AZ::FFont::InitFont() { - if (m_fontInitialized) + auto initializationState = InitializationState::Uninitialized; + // Do an atomic transition to Initializing if we're in the Uninitialized state. + // Otherwise, check the current state. + // If we're Initialized, there's no more work to be done, return true to indicate we're good to go. + // If we're Initializing (on another thread), return false to let the consumer know it's not safe for us to be used yet. + if (!m_fontInitializationState.compare_exchange_strong(initializationState, InitializationState::Initializing)) { - return true; + return initializationState == InitializationState::Initialized; } - // If we're being initialized in another thread, abort. - if (m_fontInitializing) - { - return false; - } - - m_fontInitializing = true; - // Create and initialize DynamicDrawContext for font draw AZ::RPI::Ptr dynamicDraw = m_atomFont->GetOrCreateDynamicDrawForScene(GetDefaultViewportContext()->GetRenderScene().get()); @@ -136,8 +133,7 @@ bool AZ::FFont::InitFont() m_vertexCount = 0; m_indexCount = 0; - m_fontInitialized = true; - m_fontInitializing = false; + m_fontInitializationState = InitializationState::Initialized; return true; } @@ -1522,7 +1518,7 @@ bool AZ::FFont::UpdateTexture() { using namespace AZ; - if (!m_fontInitialized || !m_fontImage) + if (m_fontInitializationState != InitializationState::Initialized || !m_fontImage) { return false; } @@ -1590,7 +1586,7 @@ void AZ::FFont::Prepare(const char* str, bool updateTexture, const AtomFont::Gly const bool rerenderGlyphs = m_sizeBehavior == SizeBehavior::Rerender; const AtomFont::GlyphSize usedGlyphSize = rerenderGlyphs ? glyphSize : AtomFont::defaultGlyphSize; bool texUpdateNeeded = m_fontTexture->PreCacheString(str, nullptr, m_sizeRatio, usedGlyphSize, m_fontHintParams) == 1 || m_fontTexDirty; - if (m_fontInitialized && updateTexture && texUpdateNeeded && m_fontImage) + if (m_fontInitializationState == InitializationState::Initialized && updateTexture && texUpdateNeeded && m_fontImage) { UpdateTexture(); m_fontTexDirty = false;