From 5b88d96eec29a5b6359243f5413693f3acf619f0 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Mon, 2 Aug 2021 13:36:10 -0700 Subject: [PATCH 01/53] Exposed fields to the mesh component giving greater Lod control from the editor Signed-off-by: Kyle B --- .../Atom/Feature/Mesh/MeshFeatureProcessor.h | 12 ++- .../Mesh/MeshFeatureProcessorInterface.h | 7 ++ .../Code/Source/Mesh/MeshFeatureProcessor.cpp | 74 +++++++++++++++++-- .../Code/Include/Atom/RPI.Public/Culling.h | 5 ++ .../CommonFeatures/Mesh/MeshComponentBus.h | 6 ++ .../Code/Source/Mesh/EditorMeshComponent.cpp | 7 ++ .../Source/Mesh/MeshComponentController.cpp | 32 ++++++++ .../Source/Mesh/MeshComponentController.h | 7 ++ .../Code/Source/AtomActorInstance.cpp | 20 +++++ .../Code/Source/AtomActorInstance.h | 4 + 10 files changed, 167 insertions(+), 7 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h index a2d9517ec4..3cdff52ba7 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h @@ -63,8 +63,12 @@ namespace AZ void SetRayTracingData(); void SetSortKey(RHI::DrawItemSortKey sortKey); RHI::DrawItemSortKey GetSortKey(); - void SetLodOverride(RPI::Cullable::LodOverride lodOverride); + void SetLodOverride( RPI::Cullable::LodOverride lodOverride); RPI::Cullable::LodOverride GetLodOverride(); + void SetMinimumScreenCoverage(float minimumScreenCoverage); + float GetMinimumScreenCoverage(); + void SetQualityDecayRate(float qualityDecayRate); + float GetQualityDecayRate(); void UpdateDrawPackets(bool forceUpdate = false); void BuildCullable(); void UpdateCullBounds(const TransformServiceFeatureProcessor* transformService); @@ -158,6 +162,12 @@ namespace AZ void SetLodOverride(const MeshHandle& meshHandle, RPI::Cullable::LodOverride lodOverride) override; RPI::Cullable::LodOverride GetLodOverride(const MeshHandle& meshHandle) override; + void SetMinimumScreenCoverage(const MeshHandle& meshHandle, float minimumScreenCoverage) override; + float GetMinimumScreenCoverage(const MeshHandle& meshHandle) override; + + void SetQualityDecayRate(const MeshHandle& meshHandle, float qualityDecayRate) override; + float GetQualityDecayRate(const MeshHandle& meshHandle) override; + void SetExcludeFromReflectionCubeMaps(const MeshHandle& meshHandle, bool excludeFromReflectionCubeMaps) override; void SetRayTracingEnabled(const MeshHandle& meshHandle, bool rayTracingEnabled) override; void SetVisible(const MeshHandle& meshHandle, bool visible) override; diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h index 4e74302276..b71b420625 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h @@ -98,6 +98,13 @@ namespace AZ virtual void SetLodOverride(const MeshHandle& meshHandle, RPI::Cullable::LodOverride lodOverride) = 0; //! Gets the LOD override for a given mesh handle. virtual RPI::Cullable::LodOverride GetLodOverride(const MeshHandle& meshHandle) = 0; + + virtual void SetMinimumScreenCoverage(const MeshHandle& meshHandle, float minimumScreenCoverage) = 0; + virtual float GetMinimumScreenCoverage(const MeshHandle& meshHandle) = 0; + + virtual void SetQualityDecayRate(const MeshHandle& meshHandle, float qualityDecayRate) = 0; + virtual float GetQualityDecayRate(const MeshHandle& meshHandle) = 0; + //! Sets the option to exclude this mesh from baked reflection probe cubemaps virtual void SetExcludeFromReflectionCubeMaps(const MeshHandle& meshHandle, bool excludeFromReflectionCubeMaps) = 0; //! Sets the option to exclude this mesh from raytracing diff --git a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp index c6362f3a5d..ce8ead9318 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp @@ -380,6 +380,48 @@ namespace AZ } } + void MeshFeatureProcessor::SetMinimumScreenCoverage( const MeshHandle& meshHandle, float minimumScreenCoverage) + { + if (meshHandle.IsValid()) + { + meshHandle->SetMinimumScreenCoverage(minimumScreenCoverage); + } + } + + float MeshFeatureProcessor::GetMinimumScreenCoverage(const MeshHandle& meshHandle) + { + if (meshHandle.IsValid()) + { + return meshHandle->GetMinimumScreenCoverage(); + } + else + { + AZ_Assert(false, "Invalid mesh handle"); + return 0; + } + } + + void MeshFeatureProcessor::SetQualityDecayRate(const MeshHandle& meshHandle, float qualityDecayRate) + { + if (meshHandle.IsValid()) + { + meshHandle->SetQualityDecayRate(qualityDecayRate); + } + } + + float MeshFeatureProcessor::GetQualityDecayRate(const MeshHandle& meshHandle) + { + if (meshHandle.IsValid()) + { + return meshHandle->GetQualityDecayRate(); + } + else + { + AZ_Assert(false, "Invalid mesh handle"); + return 0; + } + } + void MeshFeatureProcessor::SetExcludeFromReflectionCubeMaps(const MeshHandle& meshHandle, bool excludeFromReflectionCubeMaps) { if (meshHandle.IsValid()) @@ -1001,6 +1043,26 @@ namespace AZ return m_cullable.m_lodData.m_lodOverride; } + void MeshDataInstance::SetMinimumScreenCoverage(float minimumScreenCoverage) + { + m_cullable.m_lodData.m_minimumScreenCoverage = minimumScreenCoverage; + } + + float MeshDataInstance::GetMinimumScreenCoverage() + { + return m_cullable.m_lodData.m_minimumScreenCoverage; + } + + void MeshDataInstance::SetQualityDecayRate(float qualityDecayRate) + { + m_cullable.m_lodData.m_qualityDecayRate = qualityDecayRate; + } + + float MeshDataInstance::GetQualityDecayRate() + { + return m_cullable.m_lodData.m_qualityDecayRate; + } + void MeshDataInstance::UpdateDrawPackets(bool forceUpdate /*= false*/) { AZ_PROFILE_FUNCTION(Debug::ProfileCategory::AzRender); @@ -1036,13 +1098,11 @@ namespace AZ cullData.m_drawListMask.reset(); const size_t lodCount = lodAssets.size(); + for (size_t lodIndex = 0; lodIndex < lodCount; ++lodIndex) { //initialize the lod RPI::Cullable::LodData::Lod& lod = lodData.m_lods[lodIndex]; - //[GFX TODO][ATOM-5562] - Level of detail: override lod distances and add global lod multiplier(s) - static const float MinimumScreenCoverage = 1.0f/1080.0f; //mesh should cover at least a screen pixel at 1080p to be drawn - static const float ReductionFactor = 0.5f; if (lodIndex == 0) { //first lod @@ -1051,17 +1111,19 @@ namespace AZ else { //every other lod: use the previous lod's min - lod.m_screenCoverageMax = AZStd::GetMax(lodData.m_lods[lodIndex-1].m_screenCoverageMin, MinimumScreenCoverage); + lod.m_screenCoverageMax = AZStd::GetMax(lodData.m_lods[lodIndex - 1].m_screenCoverageMin, lodData.m_minimumScreenCoverage); } + if (lodIndex < lodAssets.size() - 1) { //first and middle lods: compute a stepdown value for the min - lod.m_screenCoverageMin = AZStd::GetMax(ReductionFactor * lod.m_screenCoverageMax, MinimumScreenCoverage); + lod.m_screenCoverageMin = + AZStd::GetMax(lodData.m_qualityDecayRate * lod.m_screenCoverageMax, lodData.m_minimumScreenCoverage); } else { //last lod: use MinimumScreenCoverage for the min - lod.m_screenCoverageMin = MinimumScreenCoverage; + lod.m_screenCoverageMin = lodData.m_minimumScreenCoverage; } lod.m_drawPackets.clear(); diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h index bcc4dfb89f..30cf091735 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h @@ -88,6 +88,11 @@ namespace AZ //! Suggest setting to: 0.5f*localAabb.GetExtents().GetMaxElement() float m_lodSelectionRadius = 1.0f; + // the minimum possibe area a sphere enclosing a mesh projected onto the screen should have before it is culled. + float m_minimumScreenCoverage = 1.0f / 1080.0f; + // The screen area decay between 0 and 1, i.e. closer to 1 -> lose quality immediately, closer to 0 -> never lose quality + float m_qualityDecayRate = 0.5f; + LodOverride m_lodOverride = NoLodOverride; }; LodData m_lodData; diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/Mesh/MeshComponentBus.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/Mesh/MeshComponentBus.h index ff75f7f45a..baef507b7a 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/Mesh/MeshComponentBus.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/Mesh/MeshComponentBus.h @@ -39,6 +39,12 @@ namespace AZ virtual void SetLodOverride(RPI::Cullable::LodOverride lodOverride) = 0; virtual RPI::Cullable::LodOverride GetLodOverride() const = 0; + virtual void SetMinimumScreenCoverage(float minimumScreenCoverage) = 0; + virtual float GetMinimumScreenCoverage() const = 0; + + virtual void SetQualityDecayRate(float qualityDecayRate) = 0; + virtual float GetQualityDecayRate() const = 0; + virtual void SetVisibility(bool visible) = 0; virtual bool GetVisibility() const = 0; diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp index fc62690cc4..bdbf445b7f 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp @@ -76,6 +76,13 @@ namespace AZ ->DataElement(AZ::Edit::UIHandlers::ComboBox, &MeshComponentConfig::m_lodOverride, "Lod Override", "Allows the rendered LOD to be overridden instead of being calculated automatically.") ->Attribute(AZ::Edit::Attributes::EnumValues, &MeshComponentConfig::GetLodOverrideValues) ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::IsAssetSet) + ->DataElement(AZ::Edit::UIHandlers::Default, &MeshComponentConfig::m_minimumScreenCoverage, "Minimum Screen Coverage", "Minimum proportion of screen area an entitiy takes up, after that the entitiy is culled.") + ->Attribute(AZ::Edit::Attributes::Min, 0.f) + ->Attribute(AZ::Edit::Attributes::Max, 1.f) + ->DataElement(AZ::Edit::UIHandlers::Default, &MeshComponentConfig::m_qualityDecayRate, "Quality Decay Rate", + "Rate at which mesh quality decays (0 -> always stay highest quality, 1 -> quality falls off to lowest quality immediately).") + ->Attribute(AZ::Edit::Attributes::Min, 0.f) + ->Attribute(AZ::Edit::Attributes::Max, 1.f) ->DataElement(AZ::Edit::UIHandlers::CheckBox, &MeshComponentConfig::m_excludeFromReflectionCubeMaps, "Exclude from reflection cubemaps", "Mesh will not be visible in baked reflection probe cubemaps") ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly) ->DataElement(AZ::Edit::UIHandlers::CheckBox, &MeshComponentConfig::m_useForwardPassIblSpecular, "Use Forward Pass IBL Specular", diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index 29bd9a839b..5fde185e4c 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -40,6 +40,8 @@ namespace AZ ->Field("ModelAsset", &MeshComponentConfig::m_modelAsset) ->Field("SortKey", &MeshComponentConfig::m_sortKey) ->Field("LodOverride", &MeshComponentConfig::m_lodOverride) + ->Field("MinimumScreenCoverage", &MeshComponentConfig::m_minimumScreenCoverage) + ->Field("QualityDecayRate", &MeshComponentConfig::m_qualityDecayRate) ->Field("ExcludeFromReflectionCubeMaps", &MeshComponentConfig::m_excludeFromReflectionCubeMaps) ->Field("UseForwardPassIBLSpecular", &MeshComponentConfig::m_useForwardPassIblSpecular); } @@ -116,10 +118,16 @@ namespace AZ ->Event("GetSortKey", &MeshComponentRequestBus::Events::GetSortKey) ->Event("SetLodOverride", &MeshComponentRequestBus::Events::SetLodOverride) ->Event("GetLodOverride", &MeshComponentRequestBus::Events::GetLodOverride) + ->Event("SetMinimumScreenCoverage", &MeshComponentRequestBus::Events::SetMinimumScreenCoverage) + ->Event("GetMinimumScreenCoverage", &MeshComponentRequestBus::Events::GetMinimumScreenCoverage) + ->Event("SetQualityDecayRate", &MeshComponentRequestBus::Events::SetQualityDecayRate) + ->Event("GetQualityDecayRate", &MeshComponentRequestBus::Events::GetQualityDecayRate) ->VirtualProperty("ModelAssetId", "GetModelAssetId", "SetModelAssetId") ->VirtualProperty("ModelAssetPath", "GetModelAssetPath", "SetModelAssetPath") ->VirtualProperty("SortKey", "GetSortKey", "SetSortKey") ->VirtualProperty("LodOverride", "GetLodOverride", "SetLodOverride") + ->VirtualProperty("MinimumScreenCoverage", "GetMinimumScreenCoverage", "SetMinimumScreenCoverage") + ->VirtualProperty("QualityDecayRate", "GetQualityDecayRate", "SetQualityDecayRate") ; } } @@ -325,6 +333,8 @@ namespace AZ m_meshFeatureProcessor->SetTransform(m_meshHandle, transform, m_cachedNonUniformScale); m_meshFeatureProcessor->SetSortKey(m_meshHandle, m_configuration.m_sortKey); m_meshFeatureProcessor->SetLodOverride(m_meshHandle, m_configuration.m_lodOverride); + m_meshFeatureProcessor->SetMinimumScreenCoverage(m_meshHandle, m_configuration.m_minimumScreenCoverage); + m_meshFeatureProcessor->SetQualityDecayRate(m_meshHandle, m_configuration.m_qualityDecayRate); m_meshFeatureProcessor->SetExcludeFromReflectionCubeMaps(m_meshHandle, m_configuration.m_excludeFromReflectionCubeMaps); m_meshFeatureProcessor->SetVisible(m_meshHandle, m_isVisible); @@ -426,6 +436,28 @@ namespace AZ return m_meshFeatureProcessor->GetSortKey(m_meshHandle); } + void MeshComponentController::SetMinimumScreenCoverage(float minimumScreenCoverage) + { + m_configuration.m_minimumScreenCoverage = minimumScreenCoverage; + m_meshFeatureProcessor->SetMinimumScreenCoverage(m_meshHandle, minimumScreenCoverage); + } + + float MeshComponentController::GetMinimumScreenCoverage() const + { + return m_meshFeatureProcessor->GetMinimumScreenCoverage(m_meshHandle); + } + + void MeshComponentController::SetQualityDecayRate(float qualityDecayRate) + { + m_configuration.m_qualityDecayRate = qualityDecayRate; + m_meshFeatureProcessor->SetQualityDecayRate(m_meshHandle, qualityDecayRate); + } + + float MeshComponentController::GetQualityDecayRate() const + { + return m_meshFeatureProcessor->GetQualityDecayRate(m_meshHandle); + } + void MeshComponentController::SetVisibility(bool visible) { if (m_isVisible != visible) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h index 80b483452f..f94771b3e5 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h @@ -46,6 +46,8 @@ namespace AZ Data::Asset m_modelAsset = { AZ::Data::AssetLoadBehavior::QueueLoad }; RHI::DrawItemSortKey m_sortKey = 0; RPI::Cullable::LodOverride m_lodOverride = RPI::Cullable::NoLodOverride; + float m_minimumScreenCoverage = 1.0f / 1080.0f; + float m_qualityDecayRate = 0.5f; bool m_excludeFromReflectionCubeMaps = false; bool m_useForwardPassIblSpecular = false; }; @@ -97,6 +99,11 @@ namespace AZ void SetLodOverride(RPI::Cullable::LodOverride lodOverride) override; RPI::Cullable::LodOverride GetLodOverride() const override; + void SetMinimumScreenCoverage(float minimumScreenCoverage) override; + float GetMinimumScreenCoverage() const override; + void SetQualityDecayRate(float qualityDecayRate) override; + float GetQualityDecayRate() const override; + void SetVisibility(bool visible) override; bool GetVisibility() const override; diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp index 4c6045d7ce..63912aa8a6 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp @@ -415,6 +415,26 @@ namespace AZ return m_meshFeatureProcessor->GetLodOverride(*m_meshHandle); } + void AtomActorInstance::SetMinimumScreenCoverage(float minimumScreenCoverage) + { + m_meshFeatureProcessor->SetMinimumScreenCoverage(*m_meshHandle, minimumScreenCoverage); + } + + float AtomActorInstance::GetMinimumScreenCoverage() const + { + return m_meshFeatureProcessor->GetMinimumScreenCoverage(*m_meshHandle); + } + + void AtomActorInstance::SetQualityDecayRate(float qualityDecayRate) + { + m_meshFeatureProcessor->SetQualityDecayRate(*m_meshHandle, qualityDecayRate); + } + + float AtomActorInstance::GetQualityDecayRate() const + { + return m_meshFeatureProcessor->GetQualityDecayRate(*m_meshHandle); + } + void AtomActorInstance::SetVisibility(bool visible) { SetIsVisible(visible); diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.h b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.h index c854fed3c1..bd9afc668e 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.h +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.h @@ -140,6 +140,10 @@ namespace AZ RHI::DrawItemSortKey GetSortKey() const override; void SetLodOverride(RPI::Cullable::LodOverride lodOverride) override; RPI::Cullable::LodOverride GetLodOverride() const override; + void SetMinimumScreenCoverage(float minimumScreenCoverage) override; + float GetMinimumScreenCoverage() const override; + void SetQualityDecayRate(float qualityDecayRate) override; + float GetQualityDecayRate() const override; void SetVisibility(bool visible) override; bool GetVisibility() const override; // GetWorldBounds/GetLocalBounds already overridden by BoundsRequestBus::Handler From 1a48118ece6816993409a08a90a0f2161b2229de Mon Sep 17 00:00:00 2001 From: Kyle B Date: Mon, 2 Aug 2021 14:01:38 -0700 Subject: [PATCH 02/53] Added comments and formatted as close to the original Signed-off-by: Kyle B --- .../Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h | 2 +- .../Atom/Feature/Mesh/MeshFeatureProcessorInterface.h | 7 ++++--- .../Common/Code/Source/Mesh/MeshFeatureProcessor.cpp | 4 +--- .../Code/Source/Mesh/EditorMeshComponent.cpp | 1 + .../Code/Source/Mesh/MeshComponentController.h | 1 + 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h index 3cdff52ba7..e7e794c76e 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h @@ -63,7 +63,7 @@ namespace AZ void SetRayTracingData(); void SetSortKey(RHI::DrawItemSortKey sortKey); RHI::DrawItemSortKey GetSortKey(); - void SetLodOverride( RPI::Cullable::LodOverride lodOverride); + void SetLodOverride(RPI::Cullable::LodOverride lodOverride); RPI::Cullable::LodOverride GetLodOverride(); void SetMinimumScreenCoverage(float minimumScreenCoverage); float GetMinimumScreenCoverage(); diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h index b71b420625..dd64472161 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h @@ -98,13 +98,14 @@ namespace AZ virtual void SetLodOverride(const MeshHandle& meshHandle, RPI::Cullable::LodOverride lodOverride) = 0; //! Gets the LOD override for a given mesh handle. virtual RPI::Cullable::LodOverride GetLodOverride(const MeshHandle& meshHandle) = 0; - + //! Sets the minimum screen percentage for a given mesh handle. This property is the minimum screen percentage the object can take up before culled. virtual void SetMinimumScreenCoverage(const MeshHandle& meshHandle, float minimumScreenCoverage) = 0; + //! Gets the minimum screen percentage for a given mesh handle. virtual float GetMinimumScreenCoverage(const MeshHandle& meshHandle) = 0; - + //! Sets the quality decay rate. This property is the speed at which the quality of the mesh with degrade if you are linearly moving away. virtual void SetQualityDecayRate(const MeshHandle& meshHandle, float qualityDecayRate) = 0; + //! Gets the quality decay rate. virtual float GetQualityDecayRate(const MeshHandle& meshHandle) = 0; - //! Sets the option to exclude this mesh from baked reflection probe cubemaps virtual void SetExcludeFromReflectionCubeMaps(const MeshHandle& meshHandle, bool excludeFromReflectionCubeMaps) = 0; //! Sets the option to exclude this mesh from raytracing diff --git a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp index ce8ead9318..7d1d7ed851 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp @@ -1098,7 +1098,6 @@ namespace AZ cullData.m_drawListMask.reset(); const size_t lodCount = lodAssets.size(); - for (size_t lodIndex = 0; lodIndex < lodCount; ++lodIndex) { //initialize the lod @@ -1117,8 +1116,7 @@ namespace AZ if (lodIndex < lodAssets.size() - 1) { //first and middle lods: compute a stepdown value for the min - lod.m_screenCoverageMin = - AZStd::GetMax(lodData.m_qualityDecayRate * lod.m_screenCoverageMax, lodData.m_minimumScreenCoverage); + lod.m_screenCoverageMin = AZStd::GetMax(lodData.m_qualityDecayRate * lod.m_screenCoverageMax, lodData.m_minimumScreenCoverage); } else { diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp index bdbf445b7f..d46017af16 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp @@ -79,6 +79,7 @@ namespace AZ ->DataElement(AZ::Edit::UIHandlers::Default, &MeshComponentConfig::m_minimumScreenCoverage, "Minimum Screen Coverage", "Minimum proportion of screen area an entitiy takes up, after that the entitiy is culled.") ->Attribute(AZ::Edit::Attributes::Min, 0.f) ->Attribute(AZ::Edit::Attributes::Max, 1.f) + ->Attribute(AZ::Edit::Attributes::Suffix, " percent") ->DataElement(AZ::Edit::UIHandlers::Default, &MeshComponentConfig::m_qualityDecayRate, "Quality Decay Rate", "Rate at which mesh quality decays (0 -> always stay highest quality, 1 -> quality falls off to lowest quality immediately).") ->Attribute(AZ::Edit::Attributes::Min, 0.f) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h index f94771b3e5..888d4bb154 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h @@ -101,6 +101,7 @@ namespace AZ void SetMinimumScreenCoverage(float minimumScreenCoverage) override; float GetMinimumScreenCoverage() const override; + void SetQualityDecayRate(float qualityDecayRate) override; float GetQualityDecayRate() const override; From 36abde95a9a312ed56625d422138a86150752ff6 Mon Sep 17 00:00:00 2001 From: Chris Santora Date: Fri, 23 Jul 2021 16:09:24 -0700 Subject: [PATCH 03/53] Added a new registry setting that disables automatic conversion of materials from model files like FBX. By default, processing of model files (like FBX) automatically convert the included materials to Atom materials, using StandardPBR. This adds a job dependency on StandardPBR.materialtype, which propagates to any related azsl files as well. Thus any change to azsl code will cause all model files in the project to rebuild. Some game teams have no interest in using the auto-converted materials; they always use a Material Component to apply material overrides for every mesh. This new setting allows teams to disable material auto-conversion for the entire project, thus removing the job dependency on StandardPBR.materialtype. Instead, every mesh will be assigned the same default material. Any change to azsl code will cause that one default material to rebuild, but this will not trigger any models to rebuild. Details: - Added /O3DE/SceneAPI/MaterialConverter registry settings for configuring the scene material converter. It includes an enable flag, and a default material to use when conversion is disabled. - Added SceneBuilderDependencyRequests::AddFingerprintInfo which allows ScenePI components to modify the scene builder analysis fingerprint. We use this to reprocess scene files when the material converter settings change. - Updated SceneAPI's material asset builder to skip the StandardPBR dependency when material conversion is disabled. - Added some code to MaterialComponentController to handle an edge case that may when disabling material conversion on an existing project, and assigned materials disappear. Testing: - Changing the registery setting does trigger a rebuild of the fbx files. - When material conversion is disabled, changing an azsl file does not cause fbx files to rebuild, but the shader still reloads as expected. - Made a test level using multiple models with multiple meshes, made various adjustments to the material slots for each mesh, and tried switcihng the material conversion registry setting from true to false. (Details below) - TODO: Will merge this change to a customer's fork and test on their existing content. Details about my test level: - Made a new test level AtomTest project - Added two entities, both using multi-mat_mesh-groups_1m_cubes.fbx - Added a material component to both entities - Entity 1 material assignments - Blue_Zaxis: left as-is - Green_Yaxis: exported the material - Red_Xaxis: exported the material, and changed the material instance color to pink - StingrayPBS1: exported the material, scaled the UVs in the exported material source, and changed the material instance color to green. - With_Texture: selected an existing brick material, changed the material instance color to red. - Entity 2 material assignments - Default Material: set to an existing brick material - Blue_Zaxis: manually assigned built-in material that was converted from fbx - Green_Yaxis: manually assigned built-in material that was converted from fbx, and changed the material instance color to orange Signed-off-by: santorac <55155825+santorac@users.noreply.github.com> --- .../SceneCore/SceneBuilderDependencyBus.h | 7 +- .../MaterialConverterSystemComponent.cpp | 56 +++++++- .../MaterialConverterSystemComponent.h | 17 +++ .../RPI.Edit/Material/MaterialConverterBus.h | 13 +- .../RPI.Reflect/Model/ModelMaterialSlot.h | 2 + .../Model/MaterialAssetBuilderComponent.cpp | 129 ++++++++++++++++-- .../Model/MaterialAssetBuilderComponent.h | 8 ++ .../Model/ModelExporterComponent.cpp | 10 +- .../Material/MaterialComponentController.cpp | 93 ++++++++++++- .../Material/MaterialComponentController.h | 9 +- .../SceneBuilder/SceneBuilderComponent.cpp | 7 + .../SceneBuilder/SceneBuilderComponent.h | 1 + .../SceneBuilder/SceneBuilderWorker.cpp | 2 + Registry/sceneassetimporter.setreg | 5 + 14 files changed, 335 insertions(+), 24 deletions(-) diff --git a/Code/Tools/SceneAPI/SceneCore/SceneBuilderDependencyBus.h b/Code/Tools/SceneAPI/SceneCore/SceneBuilderDependencyBus.h index 6500b5ca28..752d4a431f 100644 --- a/Code/Tools/SceneAPI/SceneCore/SceneBuilderDependencyBus.h +++ b/Code/Tools/SceneAPI/SceneCore/SceneBuilderDependencyBus.h @@ -24,7 +24,12 @@ namespace AZ : public AZ::EBusTraits { public: - virtual void ReportJobDependencies(JobDependencyList& jobDependencyList, const char* platformIdentifier) = 0; + //! Builders can implement this function to add job dependencies on other assets that may be used in the scene file conversion process. + virtual void ReportJobDependencies(JobDependencyList& jobDependencyList, const char* platformIdentifier) { AZ_UNUSED(jobDependencyList); AZ_UNUSED(platformIdentifier); } + + //! Builders can implement this function to append to the job analysis fingerprint. This can be used to trigger rebuilds when global configuration changes. + //! See also AssetBuilderDesc::m_analysisFingerprint. + virtual void AddFingerprintInfo(AZStd::set& fingerprintInfo) { AZ_UNUSED(fingerprintInfo); } }; using SceneBuilderDependencyBus = EBus; } // namespace SceneAPI diff --git a/Gems/Atom/Feature/Common/Code/Source/Material/MaterialConverterSystemComponent.cpp b/Gems/Atom/Feature/Common/Code/Source/Material/MaterialConverterSystemComponent.cpp index d173018ef7..d5fdcd9e41 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Material/MaterialConverterSystemComponent.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Material/MaterialConverterSystemComponent.cpp @@ -12,12 +12,26 @@ #include #include #include +#include #include +#include + namespace AZ { namespace Render { + void MaterialConverterSettings::Reflect(AZ::ReflectContext* context) + { + if (auto serializeContext = azrtti_cast(context); serializeContext) + { + serializeContext->Class() + ->Version(1) + ->Field("Enable", &MaterialConverterSettings::m_enable) + ->Field("DefaultMaterial", &MaterialConverterSettings::m_defaultMaterial); + } + } + void MaterialConverterSystemComponent::Reflect(AZ::ReflectContext* context) { if (auto* serialize = azrtti_cast(context)) @@ -26,10 +40,22 @@ namespace AZ ->Version(3) ->Attribute(Edit::Attributes::SystemComponentTags, AZStd::vector({ AssetBuilderSDK::ComponentTags::AssetBuilder })); } + + MaterialConverterSettings::Reflect(context); + } + + void MaterialConverterSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services) + { + services.emplace_back(AZ_CRC_CE("FingerprintModification")); } void MaterialConverterSystemComponent::Activate() { + if (auto* settingsRegistry = AZ::SettingsRegistry::Get()) + { + settingsRegistry->GetObject(m_settings, "/O3DE/SceneAPI/MaterialConverter"); + } + RPI::MaterialConverterBus::Handler::BusConnect(); } @@ -37,11 +63,21 @@ namespace AZ { RPI::MaterialConverterBus::Handler::BusDisconnect(); } + + bool MaterialConverterSystemComponent::IsEnabled() const + { + return m_settings.m_enable; + } bool MaterialConverterSystemComponent::ConvertMaterial( const AZ::SceneAPI::DataTypes::IMaterialData& materialData, RPI::MaterialSourceData& sourceData) { using namespace AZ::RPI; + + if (!m_settings.m_enable) + { + return false; + } // The source data for generating material asset sourceData.m_materialType = GetMaterialTypePath(); @@ -142,7 +178,25 @@ namespace AZ const char* MaterialConverterSystemComponent::GetMaterialTypePath() const { - return "Materials/Types/StandardPBR.materialtype"; + if (m_settings.m_enable) + { + return "Materials/Types/StandardPBR.materialtype"; + } + else + { + return nullptr; + } + } + + AZStd::string MaterialConverterSystemComponent::GetDefaultMaterialPath() const + { + if (m_settings.m_defaultMaterial.empty()) + { + AZ_Error("MaterialConverterSystemComponent", m_settings.m_enable, + "Material conversion is disabled but a default material not specified in registry /O3DE/SceneAPI/MaterialConverter/DefaultMaterial"); + } + + return m_settings.m_defaultMaterial; } } } diff --git a/Gems/Atom/Feature/Common/Code/Source/Material/MaterialConverterSystemComponent.h b/Gems/Atom/Feature/Common/Code/Source/Material/MaterialConverterSystemComponent.h index 38d4faedc8..e7e5c63732 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Material/MaterialConverterSystemComponent.h +++ b/Gems/Atom/Feature/Common/Code/Source/Material/MaterialConverterSystemComponent.h @@ -18,6 +18,16 @@ namespace AZ { namespace Render { + struct MaterialConverterSettings + { + AZ_TYPE_INFO(MaterialConverterSettings, "{8D91601D-570A-4557-99C8-631DB4928040}"); + + static void Reflect(AZ::ReflectContext* context); + + bool m_enable = true; + AZStd::string m_defaultMaterial; + }; + //! Atom's implementation of converting SceneAPI data into Atom's default material: StandardPBR class MaterialConverterSystemComponent final : public AZ::Component @@ -27,13 +37,20 @@ namespace AZ AZ_COMPONENT(MaterialConverterSystemComponent, "{C2338D45-6456-4521-B469-B000A13F2493}"); static void Reflect(AZ::ReflectContext* context); + + static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services); void Activate() override; void Deactivate() override; // MaterialConverterBus overrides ... + bool IsEnabled() const override; bool ConvertMaterial(const AZ::SceneAPI::DataTypes::IMaterialData& materialData, RPI::MaterialSourceData& out) override; const char* GetMaterialTypePath() const override; + AZStd::string GetDefaultMaterialPath() const override; + + private: + MaterialConverterSettings m_settings; }; } } diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Edit/Material/MaterialConverterBus.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Edit/Material/MaterialConverterBus.h index 120c1ee28b..e5aa32c175 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Edit/Material/MaterialConverterBus.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Edit/Material/MaterialConverterBus.h @@ -29,10 +29,19 @@ namespace AZ : public AZ::EBusTraits { public: - //! Returns true if the converion was successful + + virtual bool IsEnabled() const = 0; + + //! Converts data from a IMaterialData object to an Atom MaterialSourceData. + //! Only works when IsEnabled() is true. + //! @return true if the MaterialSourceData output was populated with converted material data. virtual bool ConvertMaterial(const AZ::SceneAPI::DataTypes::IMaterialData& materialData, MaterialSourceData& out) = 0; - //! Returns the path to the .materialtype file that the materials are based on, such as StandardPBR.materialtype, etc. + + //! Returns the path to the .materialtype file that the converted materials are based on, such as StandardPBR.materialtype, etc. Or nullptr when conversion is disabled. virtual const char* GetMaterialTypePath() const = 0; + + //! Returns the path to a .material file to use as the default material when conversion is disabled. + virtual AZStd::string GetDefaultMaterialPath() const = 0; }; using MaterialConverterBus = AZ::EBus; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Model/ModelMaterialSlot.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Model/ModelMaterialSlot.h index dd46aca6cd..30088d2d52 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Model/ModelMaterialSlot.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Model/ModelMaterialSlot.h @@ -25,6 +25,8 @@ namespace AZ static void Reflect(AZ::ReflectContext* context); + // Note that StableId is uint32_t for legacy reasons: we used to use AssetId::m_subId as the material slot ID. But actually the original MaterialUid + // is 64 bit so we might want to switch this to be uint64_t at some point. using StableId = uint32_t; static const StableId InvalidStableId; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/MaterialAssetBuilderComponent.cpp b/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/MaterialAssetBuilderComponent.cpp index 7187cb391a..3eb60956ad 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/MaterialAssetBuilderComponent.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/MaterialAssetBuilderComponent.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -70,28 +71,74 @@ namespace AZ void MaterialAssetDependenciesComponent::ReportJobDependencies(SceneAPI::JobDependencyList& jobDependencyList, const char* platformIdentifier) { - AssetBuilderSDK::SourceFileDependency materialTypeSource; + bool conversionEnabled = false; + RPI::MaterialConverterBus::BroadcastResult(conversionEnabled, &RPI::MaterialConverterBus::Events::IsEnabled); + // Right now, scene file importing only supports a single material type, once that changes, this will have to be re-designed, see ATOM-3554 - RPI::MaterialConverterBus::BroadcastResult(materialTypeSource.m_sourceFileDependencyPath, &RPI::MaterialConverterBus::Events::GetMaterialTypePath); + const char* materialTypePath = nullptr; + RPI::MaterialConverterBus::BroadcastResult(materialTypePath, &RPI::MaterialConverterBus::Events::GetMaterialTypePath); - AssetBuilderSDK::JobDependency jobDependency; - jobDependency.m_jobKey = "Atom Material Builder"; - jobDependency.m_sourceFile = materialTypeSource; - jobDependency.m_platformIdentifier = platformIdentifier; - jobDependency.m_type = AssetBuilderSDK::JobDependencyType::Order; - - if (!materialTypeSource.m_sourceFileDependencyPath.empty()) + if (conversionEnabled && materialTypePath) { + AssetBuilderSDK::SourceFileDependency materialTypeSource; + materialTypeSource.m_sourceFileDependencyPath = materialTypePath; + + AssetBuilderSDK::JobDependency jobDependency; + jobDependency.m_jobKey = "Atom Material Builder"; + jobDependency.m_sourceFile = materialTypeSource; + jobDependency.m_platformIdentifier = platformIdentifier; + jobDependency.m_type = AssetBuilderSDK::JobDependencyType::Order; + jobDependencyList.push_back(jobDependency); } } + + void MaterialAssetDependenciesComponent::AddFingerprintInfo(AZStd::set& fingerprintInfo) + { + // This will cause scene files to be reprocessed whenever the global MaterialConverter settings change. + + bool conversionEnabled = false; + RPI::MaterialConverterBus::BroadcastResult(conversionEnabled, &RPI::MaterialConverterBus::Events::IsEnabled); + fingerprintInfo.insert(AZStd::string::format("[MaterialConverter enabled=%d]", conversionEnabled)); + + if (!conversionEnabled) + { + AZStd::string defaultMaterialPath; + RPI::MaterialConverterBus::BroadcastResult(defaultMaterialPath, &RPI::MaterialConverterBus::Events::GetDefaultMaterialPath); + fingerprintInfo.insert(AZStd::string::format("[MaterialConverter defaultMaterial=%s]", defaultMaterialPath.c_str())); + } + } void MaterialAssetBuilderComponent::Reflect(ReflectContext* context) { if (auto* serialize = azrtti_cast(context)) { serialize->Class() - ->Version(16); // Optional material conversion + ->Version(16); // Optional material conversion + } + } + + Data::Asset MaterialAssetBuilderComponent::GetDefaultMaterialAsset() const + { + AZStd::string defaultMaterialPath; + RPI::MaterialConverterBus::BroadcastResult(defaultMaterialPath, &RPI::MaterialConverterBus::Events::GetDefaultMaterialPath); + + if (defaultMaterialPath.empty()) + { + return {}; + } + else + { + auto defaultMaterialAssetId = RPI::AssetUtils::MakeAssetId(defaultMaterialPath, 0); + if (!defaultMaterialAssetId.IsSuccess()) + { + AZ_Error("MaterialAssetBuilderComponent", false, "Could not find asset '%s'", defaultMaterialPath.c_str()); + return {}; + } + else + { + return Data::AssetManager::Instance().CreateAsset(defaultMaterialAssetId.GetValue(), Data::AssetLoadBehaviorNamespace::PreLoad); + } } } @@ -119,8 +166,8 @@ namespace AZ BindToCall(&MaterialAssetBuilderComponent::BuildMaterials); } - - SceneAPI::Events::ProcessingResult MaterialAssetBuilderComponent::BuildMaterials(MaterialAssetBuilderContext& context) const + + SceneAPI::Events::ProcessingResult MaterialAssetBuilderComponent::ConvertMaterials(MaterialAssetBuilderContext& context) const { const auto& scene = context.m_scene; const Uuid sourceSceneUuid = scene.GetSourceGuid(); @@ -193,6 +240,64 @@ namespace AZ return SceneAPI::Events::ProcessingResult::Success; } + + SceneAPI::Events::ProcessingResult MaterialAssetBuilderComponent::AssignDefaultMaterials(MaterialAssetBuilderContext& context) const + { + Data::Asset defaultMaterialAsset = GetDefaultMaterialAsset(); + + if (!defaultMaterialAsset.GetId().IsValid()) + { + AZ_Warning("MaterialAssetBuilderComponent", false, "Material conversion is disabled but no default material was provided. The model will likely be invisible by default."); + // Return success because it's just a warning. + return SceneAPI::Events::ProcessingResult::Success; + } + + const auto& scene = context.m_scene; + const Uuid sourceSceneUuid = scene.GetSourceGuid(); + const auto& sceneGraph = scene.GetGraph(); + + auto names = sceneGraph.GetNameStorage(); + auto content = sceneGraph.GetContentStorage(); + auto pairView = SceneAPI::Containers::Views::MakePairView(names, content); + + auto view = SceneAPI::Containers::Views::MakeSceneGraphDownwardsView< + SceneAPI::Containers::Views::BreadthFirst>( + sceneGraph, sceneGraph.GetRoot(), pairView.cbegin(), true); + + for (const auto& viewIt : view) + { + if (viewIt.second == nullptr) + { + continue; + } + + if (azrtti_istypeof(viewIt.second.get())) + { + auto materialData = AZStd::static_pointer_cast(viewIt.second); + uint64_t materialUid = materialData->GetUniqueId(); + + context.m_outputMaterialsByUid[materialUid] = { defaultMaterialAsset, materialData->GetMaterialName() }; + } + } + + return SceneAPI::Events::ProcessingResult::Success; + } + + SceneAPI::Events::ProcessingResult MaterialAssetBuilderComponent::BuildMaterials(MaterialAssetBuilderContext& context) const + { + bool conversionEnabled = false; + RPI::MaterialConverterBus::BroadcastResult(conversionEnabled, &RPI::MaterialConverterBus::Events::IsEnabled); + + if (conversionEnabled) + { + return ConvertMaterials(context); + } + else + { + return AssignDefaultMaterials(context); + } + + } } // namespace RPI } // namespace AZ diff --git a/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/MaterialAssetBuilderComponent.h b/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/MaterialAssetBuilderComponent.h index f02034c35d..f89ae1cde9 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/MaterialAssetBuilderComponent.h +++ b/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/MaterialAssetBuilderComponent.h @@ -39,6 +39,13 @@ namespace AZ // Required for ExportingComponent static void Reflect(AZ::ReflectContext* context); + + private: + + SceneAPI::Events::ProcessingResult ConvertMaterials(MaterialAssetBuilderContext& context) const; + SceneAPI::Events::ProcessingResult AssignDefaultMaterials(MaterialAssetBuilderContext& context) const; + + Data::Asset GetDefaultMaterialAsset() const; }; /** @@ -65,6 +72,7 @@ namespace AZ // SceneAPI::SceneBuilderDependencyBus::Handler overrides... void ReportJobDependencies(SceneAPI::JobDependencyList& jobDependencyList, const char* platformIdentifier) override; + void AddFingerprintInfo(AZStd::set& fingerprintInfo) override; }; } // namespace RPI } // namespace AZ diff --git a/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/ModelExporterComponent.cpp b/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/ModelExporterComponent.cpp index ea39ea9031..f7e672ab32 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/ModelExporterComponent.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/ModelExporterComponent.cpp @@ -78,9 +78,17 @@ namespace AZ //Export MaterialAssets for (auto& materialPair : materialsByUid) { + const Data::Asset& asset = materialPair.second.m_asset; + + // MaterialAssetBuilderContext could attach an independent material asset rather than + // generate one using the scene data, so we must skip the export step in that case. + if (asset.GetId().m_guid != exportEventContext.GetScene().GetSourceGuid()) + { + continue; + } + uint64_t materialUid = materialPair.first; const AZStd::string& sceneName = exportEventContext.GetScene().GetName(); - const Data::Asset& asset = materialPair.second.m_asset; // escape the material name acceptable for a filename AZStd::string materialName = materialPair.second.m_name; diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.cpp index e39f5cfad5..5d4e7883b0 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.cpp @@ -8,8 +8,10 @@ #include #include +#include #include #include +#include namespace AZ { @@ -85,6 +87,7 @@ namespace AZ void MaterialComponentController::Deactivate() { MaterialComponentRequestBus::Handler::BusDisconnect(); + MeshComponentNotificationBus::Handler::BusDisconnect(); TickBus::Handler::BusDisconnect(); ReleaseMaterials(); @@ -111,6 +114,55 @@ namespace AZ { InitializeMaterialInstance(asset); } + + void MaterialComponentController::OnModelReady(const Data::Asset&, const Data::Instance&) + { + MeshComponentNotificationBus::Handler::BusDisconnect(); + + // If there is a circumstance where the saved material assignments are empty, fill them in with the default material. + // (This could happen as a result of LoadMaterials() clearing the asset reference to deal with an edge case) + + // Now that a model asset is ready, see if there are any empty assignments that need to be filled... + RPI::ModelMaterialSlotMap modelMaterialSlots; + MaterialReceiverRequestBus::EventResult(modelMaterialSlots, m_entityId, &MaterialReceiverRequestBus::Events::GetModelMaterialSlots); + + AZStd::vector> newMaterialAssets; + newMaterialAssets.reserve(m_configuration.m_materials.size()); + + // First we fill the empty slots but don't connect to AssetBus yet. If the same material asset appears multiple times, + // AssetBus will call OnAssetReady only the *first* time we connect for that asset. The full list of m_configuration.m_materials + // needs to be updated before that happens. + for (auto& materialPair : m_configuration.m_materials) + { + auto& materialAsset = materialPair.second.m_materialAsset; + + if (!materialAsset.GetId().IsValid()) + { + auto slotIter = modelMaterialSlots.find(materialPair.first.m_materialSlotStableId); + if (slotIter != modelMaterialSlots.end()) + { + materialAsset = slotIter->second.m_defaultMaterialAsset; + newMaterialAssets.push_back(materialAsset); + } + else + { + AZ_Error("MaterialComponentController", false, "Could not find material slot %d", materialPair.first.m_materialSlotStableId); + } + } + } + + // Now that the configuration is updated with all the default material assets, we can load and connect them. + // If there are duplicates in this list, the redundant calls will be ignored. + for (auto& materialAsset : newMaterialAssets) + { + if (!materialAsset.IsReady()) + { + materialAsset.QueueLoad(); + } + + Data::AssetBus::MultiHandler::BusConnect(materialAsset.GetId()); + } + } void MaterialComponentController::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time) { @@ -186,11 +238,42 @@ namespace AZ for (auto& materialPair : m_configuration.m_materials) { auto& materialAsset = materialPair.second.m_materialAsset; - if (materialAsset.GetId().IsValid() && !Data::AssetBus::MultiHandler::BusIsConnectedId(materialAsset.GetId())) + + // This is a special case where a material was auto-generated from the model file, connected to a Material Component by the user, + // and then later a setting was changed to NOT auto-generate the model materials anymore. We need to switch to the new default + // material rather than trying to use the old default material which no longer exists. If that's the case, we reset the asset + // and OnModelReady will fill in the appropriate default material asset later. { - anyQueued = true; - materialAsset.QueueLoad(); - Data::AssetBus::MultiHandler::BusConnect(materialAsset.GetId()); + Data::AssetId modelAssetId; + MeshComponentRequestBus::EventResult(modelAssetId, m_entityId, &MeshComponentRequestBus::Events::GetModelAssetId); + bool materialWasGeneratedFromModel = (modelAssetId.m_guid == materialAsset.GetId().m_guid); + + Data::AssetInfo assetInfo; + Data::AssetCatalogRequestBus::BroadcastResult(assetInfo, &Data::AssetCatalogRequestBus::Events::GetAssetInfoById, materialAsset.GetId()); + bool materialAssetExists = assetInfo.m_assetId.IsValid(); + + if (materialWasGeneratedFromModel && !materialAssetExists) + { + AZ_Warning("MaterialComponentController", false, "The default material assignment for this slot has changed and will be replaced (was '%s').", + materialAsset.ToString().c_str()); + materialAsset.Reset(); + } + } + + if (materialAsset.GetId().IsValid()) + { + if (!Data::AssetBus::MultiHandler::BusIsConnectedId(materialAsset.GetId())) + { + anyQueued = true; + materialAsset.QueueLoad(); + Data::AssetBus::MultiHandler::BusConnect(materialAsset.GetId()); + } + } + else + { + // Since a material asset wasn't found, we'll need to supply a default material. But the default materials + // won't be known until after the mesh component has loaded the model data. + MeshComponentNotificationBus::Handler::BusConnect(m_entityId); } } @@ -199,7 +282,7 @@ namespace AZ ReleaseMaterials(); } } - + void MaterialComponentController::InitializeMaterialInstance(const Data::Asset& asset) { bool allReady = true; diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.h index de7f991d60..b2177d1191 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.h @@ -13,6 +13,7 @@ #include #include #include +#include namespace AZ { @@ -22,6 +23,7 @@ namespace AZ //! to provide material overrides on a per-entity basis. class MaterialComponentController final : MaterialComponentRequestBus::Handler + , MeshComponentNotificationBus::Handler , Data::AssetBus::MultiHandler , TickBus::Handler { @@ -68,13 +70,16 @@ namespace AZ AZ_DISABLE_COPY(MaterialComponentController); - //! Data::AssetBus interface + //! Data::AssetBus overrides... void OnAssetReady(Data::Asset asset) override; void OnAssetReloaded(Data::Asset asset) override; - //! AZ::TickBus interface implementation + // AZ::TickBus overrides... void OnTick(float deltaTime, AZ::ScriptTimePoint time) override; + // MeshComponentNotificationBus overrides... + void OnModelReady(const Data::Asset& modelAsset, const Data::Instance& model) override; + void LoadMaterials(); void InitializeMaterialInstance(const Data::Asset& asset); void ReleaseMaterials(); diff --git a/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderComponent.cpp b/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderComponent.cpp index 524b79b012..430733f3a1 100644 --- a/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderComponent.cpp +++ b/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderComponent.cpp @@ -73,6 +73,13 @@ namespace SceneBuilder required.emplace_back(AZ_CRC_CE("AssetImportRequestHandler")); } + void BuilderPluginComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& services) + { + // Any components that can modify the analysis fingerprint via SceneBuilderDependencyRequests::AddFingerprintInfo must be activated first, + // so they contribute to the fingerprint calculated in BuilderPluginComponent::Activate(). + services.emplace_back(AZ_CRC_CE("FingerprintModification")); + } + void BuilderPluginComponent::Reflect(AZ::ReflectContext* context) { AZ::SerializeContext* serializeContext = azrtti_cast(context); diff --git a/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderComponent.h b/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderComponent.h index b4eee64bc6..0bfe118a4c 100644 --- a/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderComponent.h +++ b/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderComponent.h @@ -29,6 +29,7 @@ namespace SceneBuilder void Deactivate() override; static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required); + static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& services); private: SceneBuilderWorker m_sceneBuilder; diff --git a/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderWorker.cpp b/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderWorker.cpp index 18ee0285b8..2af4613e9e 100644 --- a/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderWorker.cpp +++ b/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderWorker.cpp @@ -69,6 +69,8 @@ namespace SceneBuilder context->EnumerateDerived(callback, azrtti_typeid(), azrtti_typeid()); context->EnumerateDerived(callback, azrtti_typeid(), azrtti_typeid()); } + + AZ::SceneAPI::SceneBuilderDependencyBus::Broadcast(&AZ::SceneAPI::SceneBuilderDependencyRequests::AddFingerprintInfo, fragments); for (const AZStd::string& element : fragments) { diff --git a/Registry/sceneassetimporter.setreg b/Registry/sceneassetimporter.setreg index bd7c4d0705..6fef3a40dc 100644 --- a/Registry/sceneassetimporter.setreg +++ b/Registry/sceneassetimporter.setreg @@ -10,6 +10,11 @@ ".fbx", ".stl" ] + }, + "MaterialConverter": + { + "Enable": true, + "DefaultMaterial": "Materials/Presets/PBR/default_grid.material" } } } From 3db93a564d1a7b5e8c7b87eccb56ce6009a4dd47 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Tue, 3 Aug 2021 18:28:55 -0700 Subject: [PATCH 04/53] Made formatting changes per pull comments, incuding adding comments, changing spacing, and changing the ui type of component fields Signed-off-by: Kyle B --- .../Include/Atom/Feature/Mesh/MeshFeatureProcessor.h | 8 ++++---- .../Common/Code/Source/Mesh/MeshFeatureProcessor.cpp | 12 ++++++------ Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h | 2 +- .../Code/Source/Mesh/EditorMeshComponent.cpp | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h index e7e794c76e..08f2dde474 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h @@ -62,13 +62,13 @@ namespace AZ void BuildDrawPacketList(size_t modelLodIndex); void SetRayTracingData(); void SetSortKey(RHI::DrawItemSortKey sortKey); - RHI::DrawItemSortKey GetSortKey(); + RHI::DrawItemSortKey GetSortKey() const; void SetLodOverride(RPI::Cullable::LodOverride lodOverride); - RPI::Cullable::LodOverride GetLodOverride(); + RPI::Cullable::LodOverride GetLodOverride() const; void SetMinimumScreenCoverage(float minimumScreenCoverage); - float GetMinimumScreenCoverage(); + float GetMinimumScreenCoverage() const; void SetQualityDecayRate(float qualityDecayRate); - float GetQualityDecayRate(); + float GetQualityDecayRate() const; void UpdateDrawPackets(bool forceUpdate = false); void BuildCullable(); void UpdateCullBounds(const TransformServiceFeatureProcessor* transformService); diff --git a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp index 7d1d7ed851..286724b06a 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp @@ -380,7 +380,7 @@ namespace AZ } } - void MeshFeatureProcessor::SetMinimumScreenCoverage( const MeshHandle& meshHandle, float minimumScreenCoverage) + void MeshFeatureProcessor::SetMinimumScreenCoverage(const MeshHandle& meshHandle, float minimumScreenCoverage) { if (meshHandle.IsValid()) { @@ -388,7 +388,7 @@ namespace AZ } } - float MeshFeatureProcessor::GetMinimumScreenCoverage(const MeshHandle& meshHandle) + float MeshFeatureProcessor::GetMinimumScreenCoverage(const MeshHandle& meshHandle) const { if (meshHandle.IsValid()) { @@ -1028,7 +1028,7 @@ namespace AZ } } - RHI::DrawItemSortKey MeshDataInstance::GetSortKey() + RHI::DrawItemSortKey MeshDataInstance::GetSortKey() const { return m_sortKey; } @@ -1038,7 +1038,7 @@ namespace AZ m_cullable.m_lodData.m_lodOverride = lodOverride; } - RPI::Cullable::LodOverride MeshDataInstance::GetLodOverride() + RPI::Cullable::LodOverride MeshDataInstance::GetLodOverride() const { return m_cullable.m_lodData.m_lodOverride; } @@ -1048,7 +1048,7 @@ namespace AZ m_cullable.m_lodData.m_minimumScreenCoverage = minimumScreenCoverage; } - float MeshDataInstance::GetMinimumScreenCoverage() + float MeshDataInstance::GetMinimumScreenCoverage() const { return m_cullable.m_lodData.m_minimumScreenCoverage; } @@ -1058,7 +1058,7 @@ namespace AZ m_cullable.m_lodData.m_qualityDecayRate = qualityDecayRate; } - float MeshDataInstance::GetQualityDecayRate() + float MeshDataInstance::GetQualityDecayRate() const { return m_cullable.m_lodData.m_qualityDecayRate; } diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h index 30cf091735..4a39a21e0b 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h @@ -89,7 +89,7 @@ namespace AZ float m_lodSelectionRadius = 1.0f; // the minimum possibe area a sphere enclosing a mesh projected onto the screen should have before it is culled. - float m_minimumScreenCoverage = 1.0f / 1080.0f; + float m_minimumScreenCoverage = 1.0f / 1080.0f; //For default, mesh should cover at least a screen pixel at 1080p to be drawn // The screen area decay between 0 and 1, i.e. closer to 1 -> lose quality immediately, closer to 0 -> never lose quality float m_qualityDecayRate = 0.5f; diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp index d46017af16..3308767de9 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp @@ -76,11 +76,11 @@ namespace AZ ->DataElement(AZ::Edit::UIHandlers::ComboBox, &MeshComponentConfig::m_lodOverride, "Lod Override", "Allows the rendered LOD to be overridden instead of being calculated automatically.") ->Attribute(AZ::Edit::Attributes::EnumValues, &MeshComponentConfig::GetLodOverrideValues) ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::IsAssetSet) - ->DataElement(AZ::Edit::UIHandlers::Default, &MeshComponentConfig::m_minimumScreenCoverage, "Minimum Screen Coverage", "Minimum proportion of screen area an entitiy takes up, after that the entitiy is culled.") + ->DataElement(AZ::Edit::UIHandlers::Slider, &MeshComponentConfig::m_minimumScreenCoverage, "Minimum Screen Coverage", "Minimum proportion of screen area an entitiy takes up, after that the entitiy is culled.") ->Attribute(AZ::Edit::Attributes::Min, 0.f) ->Attribute(AZ::Edit::Attributes::Max, 1.f) ->Attribute(AZ::Edit::Attributes::Suffix, " percent") - ->DataElement(AZ::Edit::UIHandlers::Default, &MeshComponentConfig::m_qualityDecayRate, "Quality Decay Rate", + ->DataElement(AZ::Edit::UIHandlers::Slider, &MeshComponentConfig::m_qualityDecayRate, "Quality Decay Rate", "Rate at which mesh quality decays (0 -> always stay highest quality, 1 -> quality falls off to lowest quality immediately).") ->Attribute(AZ::Edit::Attributes::Min, 0.f) ->Attribute(AZ::Edit::Attributes::Max, 1.f) From 9c5c2e7de651c2d4c643ec2859ee763af5cc063b Mon Sep 17 00:00:00 2001 From: Kyle B Date: Tue, 3 Aug 2021 19:34:17 -0700 Subject: [PATCH 05/53] un-did const on function that did not need it Signed-off-by: Kyle B --- .../Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp index 286724b06a..166c5610b1 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp @@ -388,7 +388,7 @@ namespace AZ } } - float MeshFeatureProcessor::GetMinimumScreenCoverage(const MeshHandle& meshHandle) const + float MeshFeatureProcessor::GetMinimumScreenCoverage(const MeshHandle& meshHandle) { if (meshHandle.IsValid()) { From baab204c0bf79a7932ad5ddbb57931e68c47802c Mon Sep 17 00:00:00 2001 From: Kyle B Date: Thu, 5 Aug 2021 00:07:54 -0700 Subject: [PATCH 06/53] updated Mock with new interface values Signed-off-by: Kyle B --- .../Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h index 72e547fc1b..0eea0df514 100644 --- a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h @@ -32,9 +32,13 @@ namespace UnitTest MOCK_METHOD2(SetLocalAabb, void(const MeshHandle&, const AZ::Aabb&)); MOCK_CONST_METHOD1(GetLocalAabb, AZ::Aabb(const MeshHandle&)); MOCK_METHOD2(SetSortKey, void (const MeshHandle&, AZ::RHI::DrawItemSortKey)); - MOCK_METHOD1(GetSortKey, AZ::RHI::DrawItemSortKey(const MeshHandle&)); + MOCK_CONST_METHOD1(GetSortKey, AZ::RHI::DrawItemSortKey(const MeshHandle&)); MOCK_METHOD2(SetLodOverride, void(const MeshHandle&, AZ::RPI::Cullable::LodOverride)); - MOCK_METHOD1(GetLodOverride, AZ::RPI::Cullable::LodOverride(const MeshHandle&)); + MOCK_CONST_METHOD1(GetLodOverride, AZ::RPI::Cullable::LodOverride(const MeshHandle&)); + MOCK_METHOD2(SetMinimumScreenCoverage, void(const MeshHandle&, float)); + MOCK_CONST_METHOD1(GetMinimumScreenCoverage, float(const MeshHandle&)); + MOCK_METHOD2(SetQualityDecayRate, void(const MeshHandle&, float)); + MOCK_CONST_METHOD1(GetQualityDecayRate, float(const MeshHandle&)); MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Render::MaterialAssignmentMap&)); MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Data::Instance&)); MOCK_METHOD2(SetRayTracingEnabled, void (const MeshHandle&, bool)); From 39907f4ca1439785c29638bdbc7a027fa5f18d07 Mon Sep 17 00:00:00 2001 From: nggieber Date: Thu, 5 Aug 2021 09:12:52 -0700 Subject: [PATCH 07/53] Removes focus from tabs in o3de.exe Signed-off-by: nggieber --- Code/Tools/ProjectManager/Source/ScreensCtrl.cpp | 1 + Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/Code/Tools/ProjectManager/Source/ScreensCtrl.cpp b/Code/Tools/ProjectManager/Source/ScreensCtrl.cpp index 30b8ef1d34..8b8b8ac78b 100644 --- a/Code/Tools/ProjectManager/Source/ScreensCtrl.cpp +++ b/Code/Tools/ProjectManager/Source/ScreensCtrl.cpp @@ -30,6 +30,7 @@ namespace O3DE::ProjectManager // add a tab widget at the bottom of the stack m_tabWidget = new QTabWidget(); + m_tabWidget->tabBar()->setFocusPolicy(Qt::NoFocus); m_screenStack->addWidget(m_tabWidget); connect(m_tabWidget, &QTabWidget::currentChanged, this, &ScreensCtrl::TabChanged); } diff --git a/Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp b/Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp index 6aba261cd2..28c9d342e6 100644 --- a/Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp +++ b/Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp @@ -54,6 +54,7 @@ namespace O3DE::ProjectManager QTabWidget* tabWidget = new QTabWidget(); tabWidget->setObjectName("projectSettingsTab"); tabWidget->tabBar()->setObjectName("projectSettingsTabBar"); + tabWidget->tabBar()->setFocusPolicy(Qt::NoFocus); tabWidget->addTab(m_updateSettingsScreen, tr("General")); QPushButton* gemsButton = new QPushButton(tr("Configure Gems"), this); From 1768dc5980bf66c0f8c517d250369885abd87978 Mon Sep 17 00:00:00 2001 From: nggieber Date: Thu, 5 Aug 2021 09:29:48 -0700 Subject: [PATCH 08/53] Reenabled focusing of tab but removed focus rect Signed-off-by: nggieber --- Code/Tools/ProjectManager/Resources/ProjectManager.qss | 5 +++++ Code/Tools/ProjectManager/Source/ScreensCtrl.cpp | 1 - Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp | 1 - 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Code/Tools/ProjectManager/Resources/ProjectManager.qss b/Code/Tools/ProjectManager/Resources/ProjectManager.qss index 74acc1c7ef..e18bf34931 100644 --- a/Code/Tools/ProjectManager/Resources/ProjectManager.qss +++ b/Code/Tools/ProjectManager/Resources/ProjectManager.qss @@ -53,6 +53,11 @@ QTabBar::tab:pressed { color: #0e60eb; } +QTabBar::focus { + outline: 0px; + outline: none; + outline-style: none; + } /************** General (Forms) **************/ diff --git a/Code/Tools/ProjectManager/Source/ScreensCtrl.cpp b/Code/Tools/ProjectManager/Source/ScreensCtrl.cpp index 8b8b8ac78b..30b8ef1d34 100644 --- a/Code/Tools/ProjectManager/Source/ScreensCtrl.cpp +++ b/Code/Tools/ProjectManager/Source/ScreensCtrl.cpp @@ -30,7 +30,6 @@ namespace O3DE::ProjectManager // add a tab widget at the bottom of the stack m_tabWidget = new QTabWidget(); - m_tabWidget->tabBar()->setFocusPolicy(Qt::NoFocus); m_screenStack->addWidget(m_tabWidget); connect(m_tabWidget, &QTabWidget::currentChanged, this, &ScreensCtrl::TabChanged); } diff --git a/Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp b/Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp index 28c9d342e6..6aba261cd2 100644 --- a/Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp +++ b/Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp @@ -54,7 +54,6 @@ namespace O3DE::ProjectManager QTabWidget* tabWidget = new QTabWidget(); tabWidget->setObjectName("projectSettingsTab"); tabWidget->tabBar()->setObjectName("projectSettingsTabBar"); - tabWidget->tabBar()->setFocusPolicy(Qt::NoFocus); tabWidget->addTab(m_updateSettingsScreen, tr("General")); QPushButton* gemsButton = new QPushButton(tr("Configure Gems"), this); From 51271fa15bec613f96c269d0cf1487e9ed524876 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Fri, 6 Aug 2021 16:57:00 -0700 Subject: [PATCH 09/53] Created group for Lod component data Signed-off-by: Kyle B --- .../Atom/Feature/Mesh/MeshFeatureProcessor.h | 18 +--- .../Mesh/MeshFeatureProcessorInterface.h | 16 +--- .../Code/Mocks/MockMeshFeatureProcessor.h | 8 +- .../Code/Source/Mesh/MeshFeatureProcessor.cpp | 86 +++---------------- .../Code/Include/Atom/RPI.Public/Culling.h | 16 +++- .../RPI/Code/Source/RPI.Public/Culling.cpp | 6 +- .../CommonFeatures/Mesh/MeshComponentBus.h | 3 + .../Code/Source/Mesh/EditorMeshComponent.cpp | 40 +++++---- .../Source/Mesh/MeshComponentController.cpp | 73 ++++++++++++---- .../Source/Mesh/MeshComponentController.h | 29 +++++-- .../Code/Source/AtomActorInstance.cpp | 30 +++++-- .../Code/Source/AtomActorInstance.h | 2 + 12 files changed, 167 insertions(+), 160 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h index 08f2dde474..daf4a493c2 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h @@ -63,12 +63,8 @@ namespace AZ void SetRayTracingData(); void SetSortKey(RHI::DrawItemSortKey sortKey); RHI::DrawItemSortKey GetSortKey() const; - void SetLodOverride(RPI::Cullable::LodOverride lodOverride); - RPI::Cullable::LodOverride GetLodOverride() const; - void SetMinimumScreenCoverage(float minimumScreenCoverage); - float GetMinimumScreenCoverage() const; - void SetQualityDecayRate(float qualityDecayRate); - float GetQualityDecayRate() const; + void SetMeshLodConfiguration(RPI::Cullable::LodConfiguration meshLodConfig); + RPI::Cullable::LodConfiguration GetMeshLodConfiguration() const; void UpdateDrawPackets(bool forceUpdate = false); void BuildCullable(); void UpdateCullBounds(const TransformServiceFeatureProcessor* transformService); @@ -159,14 +155,8 @@ namespace AZ void SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey) override; RHI::DrawItemSortKey GetSortKey(const MeshHandle& meshHandle) override; - void SetLodOverride(const MeshHandle& meshHandle, RPI::Cullable::LodOverride lodOverride) override; - RPI::Cullable::LodOverride GetLodOverride(const MeshHandle& meshHandle) override; - - void SetMinimumScreenCoverage(const MeshHandle& meshHandle, float minimumScreenCoverage) override; - float GetMinimumScreenCoverage(const MeshHandle& meshHandle) override; - - void SetQualityDecayRate(const MeshHandle& meshHandle, float qualityDecayRate) override; - float GetQualityDecayRate(const MeshHandle& meshHandle) override; + void SetMeshLodConfiguration(const MeshHandle& meshHandle, RPI::Cullable::LodConfiguration meshLodConfig); + RPI::Cullable::LodConfiguration GetMeshLodConfiguration(const MeshHandle& meshHandle) const; void SetExcludeFromReflectionCubeMaps(const MeshHandle& meshHandle, bool excludeFromReflectionCubeMaps) override; void SetRayTracingEnabled(const MeshHandle& meshHandle, bool rayTracingEnabled) override; diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h index dd64472161..8c7a200ff5 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h @@ -94,18 +94,10 @@ namespace AZ virtual void SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey) = 0; //! Gets the sort key for a given mesh handle. virtual RHI::DrawItemSortKey GetSortKey(const MeshHandle& meshHandle) = 0; - //! Sets an LOD override for a given mesh handle. This LOD will always be rendered instead being automatically determined. - virtual void SetLodOverride(const MeshHandle& meshHandle, RPI::Cullable::LodOverride lodOverride) = 0; - //! Gets the LOD override for a given mesh handle. - virtual RPI::Cullable::LodOverride GetLodOverride(const MeshHandle& meshHandle) = 0; - //! Sets the minimum screen percentage for a given mesh handle. This property is the minimum screen percentage the object can take up before culled. - virtual void SetMinimumScreenCoverage(const MeshHandle& meshHandle, float minimumScreenCoverage) = 0; - //! Gets the minimum screen percentage for a given mesh handle. - virtual float GetMinimumScreenCoverage(const MeshHandle& meshHandle) = 0; - //! Sets the quality decay rate. This property is the speed at which the quality of the mesh with degrade if you are linearly moving away. - virtual void SetQualityDecayRate(const MeshHandle& meshHandle, float qualityDecayRate) = 0; - //! Gets the quality decay rate. - virtual float GetQualityDecayRate(const MeshHandle& meshHandle) = 0; + //! Sets LOD mesh configurations to be used in the Mesh Feature Processor + virtual void SetMeshLodConfiguration(const MeshHandle& meshHandle, RPI::Cullable::LodConfiguration meshLodConfig) = 0; + //! Gets the LOD mesh configurations being used in the Mesh Feature Processor + virtual RPI::Cullable::LodConfiguration GetMeshLodConfiguration(const MeshHandle& meshHandle) const = 0; //! Sets the option to exclude this mesh from baked reflection probe cubemaps virtual void SetExcludeFromReflectionCubeMaps(const MeshHandle& meshHandle, bool excludeFromReflectionCubeMaps) = 0; //! Sets the option to exclude this mesh from raytracing diff --git a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h index 0eea0df514..0c03e767e7 100644 --- a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h @@ -33,12 +33,8 @@ namespace UnitTest MOCK_CONST_METHOD1(GetLocalAabb, AZ::Aabb(const MeshHandle&)); MOCK_METHOD2(SetSortKey, void (const MeshHandle&, AZ::RHI::DrawItemSortKey)); MOCK_CONST_METHOD1(GetSortKey, AZ::RHI::DrawItemSortKey(const MeshHandle&)); - MOCK_METHOD2(SetLodOverride, void(const MeshHandle&, AZ::RPI::Cullable::LodOverride)); - MOCK_CONST_METHOD1(GetLodOverride, AZ::RPI::Cullable::LodOverride(const MeshHandle&)); - MOCK_METHOD2(SetMinimumScreenCoverage, void(const MeshHandle&, float)); - MOCK_CONST_METHOD1(GetMinimumScreenCoverage, float(const MeshHandle&)); - MOCK_METHOD2(SetQualityDecayRate, void(const MeshHandle&, float)); - MOCK_CONST_METHOD1(GetQualityDecayRate, float(const MeshHandle&)); + MOCK_METHOD2(SetMeshLodConfiguration, void(const MeshHandle&, RPI::Cullable::LodConfiguration)); + MOCK_CONST_METHOD1(GetMeshLodConfiguration, RPI::Cullable::LodConfiguration(const MeshHandle&)); MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Render::MaterialAssignmentMap&)); MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Data::Instance&)); MOCK_METHOD2(SetRayTracingEnabled, void (const MeshHandle&, bool)); diff --git a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp index 166c5610b1..679e64e283 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp @@ -359,66 +359,24 @@ namespace AZ } } - void MeshFeatureProcessor::SetLodOverride(const MeshHandle& meshHandle, RPI::Cullable::LodOverride lodOverride) + void MeshFeatureProcessor::SetMeshLodConfiguration(const MeshHandle& meshHandle, RPI::Cullable::LodConfiguration meshLodConfig) { if (meshHandle.IsValid()) { - meshHandle->SetLodOverride(lodOverride); + meshHandle->SetMeshLodConfiguration(meshLodConfig); } } - RPI::Cullable::LodOverride MeshFeatureProcessor::GetLodOverride(const MeshHandle& meshHandle) + RPI::Cullable::LodConfiguration MeshFeatureProcessor::GetMeshLodConfiguration(const MeshHandle& meshHandle) const { if (meshHandle.IsValid()) { - return meshHandle->GetLodOverride(); + return meshHandle->GetMeshLodConfiguration(); } else { AZ_Assert(false, "Invalid mesh handle"); - return 0; - } - } - - void MeshFeatureProcessor::SetMinimumScreenCoverage(const MeshHandle& meshHandle, float minimumScreenCoverage) - { - if (meshHandle.IsValid()) - { - meshHandle->SetMinimumScreenCoverage(minimumScreenCoverage); - } - } - - float MeshFeatureProcessor::GetMinimumScreenCoverage(const MeshHandle& meshHandle) - { - if (meshHandle.IsValid()) - { - return meshHandle->GetMinimumScreenCoverage(); - } - else - { - AZ_Assert(false, "Invalid mesh handle"); - return 0; - } - } - - void MeshFeatureProcessor::SetQualityDecayRate(const MeshHandle& meshHandle, float qualityDecayRate) - { - if (meshHandle.IsValid()) - { - meshHandle->SetQualityDecayRate(qualityDecayRate); - } - } - - float MeshFeatureProcessor::GetQualityDecayRate(const MeshHandle& meshHandle) - { - if (meshHandle.IsValid()) - { - return meshHandle->GetQualityDecayRate(); - } - else - { - AZ_Assert(false, "Invalid mesh handle"); - return 0; + return {0,0,0.0f,0.0f}; } } @@ -1033,34 +991,14 @@ namespace AZ return m_sortKey; } - void MeshDataInstance::SetLodOverride(RPI::Cullable::LodOverride lodOverride) + void MeshDataInstance::SetMeshLodConfiguration(RPI::Cullable::LodConfiguration meshLodConfig) { - m_cullable.m_lodData.m_lodOverride = lodOverride; + m_cullable.m_lodData.m_lodConfiguration = meshLodConfig; } - RPI::Cullable::LodOverride MeshDataInstance::GetLodOverride() const + RPI::Cullable::LodConfiguration MeshDataInstance::GetMeshLodConfiguration() const { - return m_cullable.m_lodData.m_lodOverride; - } - - void MeshDataInstance::SetMinimumScreenCoverage(float minimumScreenCoverage) - { - m_cullable.m_lodData.m_minimumScreenCoverage = minimumScreenCoverage; - } - - float MeshDataInstance::GetMinimumScreenCoverage() const - { - return m_cullable.m_lodData.m_minimumScreenCoverage; - } - - void MeshDataInstance::SetQualityDecayRate(float qualityDecayRate) - { - m_cullable.m_lodData.m_qualityDecayRate = qualityDecayRate; - } - - float MeshDataInstance::GetQualityDecayRate() const - { - return m_cullable.m_lodData.m_qualityDecayRate; + return m_cullable.m_lodData.m_lodConfiguration; } void MeshDataInstance::UpdateDrawPackets(bool forceUpdate /*= false*/) @@ -1110,18 +1048,18 @@ namespace AZ else { //every other lod: use the previous lod's min - lod.m_screenCoverageMax = AZStd::GetMax(lodData.m_lods[lodIndex - 1].m_screenCoverageMin, lodData.m_minimumScreenCoverage); + lod.m_screenCoverageMax = AZStd::GetMax(lodData.m_lods[lodIndex - 1].m_screenCoverageMin, lodData.m_lodConfiguration.m_minimumScreenCoverage); } if (lodIndex < lodAssets.size() - 1) { //first and middle lods: compute a stepdown value for the min - lod.m_screenCoverageMin = AZStd::GetMax(lodData.m_qualityDecayRate * lod.m_screenCoverageMax, lodData.m_minimumScreenCoverage); + lod.m_screenCoverageMin = AZStd::GetMax(lodData.m_lodConfiguration.m_qualityDecayRate * lod.m_screenCoverageMax, lodData.m_lodConfiguration.m_minimumScreenCoverage); } else { //last lod: use MinimumScreenCoverage for the min - lod.m_screenCoverageMin = lodData.m_minimumScreenCoverage; + lod.m_screenCoverageMin = lodData.m_lodConfiguration.m_minimumScreenCoverage; } lod.m_drawPackets.clear(); diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h index 4a39a21e0b..e89e180540 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h @@ -70,8 +70,18 @@ namespace AZ }; CullData m_cullData; + using LodType = uint8_t; using LodOverride = uint8_t; static constexpr uint8_t NoLodOverride = AZStd::numeric_limits::max(); + static constexpr uint8_t DefaultLodType = AZStd::numeric_limits::max(); + + struct LodConfiguration + { + LodType m_lodType; + LodOverride m_lodOverride; + float m_minimumScreenCoverage; + float m_qualityDecayRate; + }; struct LodData { @@ -89,11 +99,11 @@ namespace AZ float m_lodSelectionRadius = 1.0f; // the minimum possibe area a sphere enclosing a mesh projected onto the screen should have before it is culled. - float m_minimumScreenCoverage = 1.0f / 1080.0f; //For default, mesh should cover at least a screen pixel at 1080p to be drawn + static constexpr float DefaultMinimumScreenCoverage = 1.0f / 1080.0f; //For default, mesh should cover at least a screen pixel at 1080p to be drawn // The screen area decay between 0 and 1, i.e. closer to 1 -> lose quality immediately, closer to 0 -> never lose quality - float m_qualityDecayRate = 0.5f; + static constexpr float DefaultQualityDecayRate = 0.5f; - LodOverride m_lodOverride = NoLodOverride; + LodConfiguration m_lodConfiguration = { DefaultLodType, NoLodOverride, DefaultMinimumScreenCoverage, DefaultQualityDecayRate }; }; LodData m_lodData; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp index e192e71fc4..f22d5c7224 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp @@ -672,7 +672,7 @@ namespace AZ } }; - if (lodData.m_lodOverride == Cullable::NoLodOverride) + if (lodData.m_lodConfiguration.m_lodOverride == Cullable::NoLodOverride) { for (const Cullable::LodData::Lod& lod : lodData.m_lods) { @@ -683,9 +683,9 @@ namespace AZ } } } - else if(lodData.m_lodOverride < lodData.m_lods.size()) + else if(lodData.m_lodConfiguration.m_lodOverride < lodData.m_lods.size()) { - addLodToDrawPacket(lodData.m_lods.at(lodData.m_lodOverride)); + addLodToDrawPacket(lodData.m_lods.at(lodData.m_lodConfiguration.m_lodOverride)); } return numVisibleDrawPackets; diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/Mesh/MeshComponentBus.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/Mesh/MeshComponentBus.h index baef507b7a..cc9c78d356 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/Mesh/MeshComponentBus.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/Mesh/MeshComponentBus.h @@ -36,6 +36,9 @@ namespace AZ virtual void SetSortKey(RHI::DrawItemSortKey sortKey) = 0; virtual RHI::DrawItemSortKey GetSortKey() const = 0; + virtual void SetLodType(RPI::Cullable::LodType lodType) = 0; + virtual RPI::Cullable::LodType GetLodType() const = 0; + virtual void SetLodOverride(RPI::Cullable::LodOverride lodOverride) = 0; virtual RPI::Cullable::LodOverride GetLodOverride() const = 0; diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp index 3308767de9..0719d9f2bb 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp @@ -71,24 +71,28 @@ namespace AZ "MeshComponentConfig", "") ->ClassElement(AZ::Edit::ClassElements::EditorData, "") ->Attribute(AZ::Edit::Attributes::AutoExpand, true) - ->DataElement(AZ::Edit::UIHandlers::Default, &MeshComponentConfig::m_modelAsset, "Mesh Asset", "Mesh asset reference") - ->DataElement(AZ::Edit::UIHandlers::Default, &MeshComponentConfig::m_sortKey, "Sort Key", "Transparent meshes are drawn by sort key then depth. Used this to force certain transparent meshes to draw before or after others.") - ->DataElement(AZ::Edit::UIHandlers::ComboBox, &MeshComponentConfig::m_lodOverride, "Lod Override", "Allows the rendered LOD to be overridden instead of being calculated automatically.") - ->Attribute(AZ::Edit::Attributes::EnumValues, &MeshComponentConfig::GetLodOverrideValues) - ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::IsAssetSet) - ->DataElement(AZ::Edit::UIHandlers::Slider, &MeshComponentConfig::m_minimumScreenCoverage, "Minimum Screen Coverage", "Minimum proportion of screen area an entitiy takes up, after that the entitiy is culled.") - ->Attribute(AZ::Edit::Attributes::Min, 0.f) - ->Attribute(AZ::Edit::Attributes::Max, 1.f) - ->Attribute(AZ::Edit::Attributes::Suffix, " percent") - ->DataElement(AZ::Edit::UIHandlers::Slider, &MeshComponentConfig::m_qualityDecayRate, "Quality Decay Rate", - "Rate at which mesh quality decays (0 -> always stay highest quality, 1 -> quality falls off to lowest quality immediately).") - ->Attribute(AZ::Edit::Attributes::Min, 0.f) - ->Attribute(AZ::Edit::Attributes::Max, 1.f) - ->DataElement(AZ::Edit::UIHandlers::CheckBox, &MeshComponentConfig::m_excludeFromReflectionCubeMaps, "Exclude from reflection cubemaps", "Mesh will not be visible in baked reflection probe cubemaps") - ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly) - ->DataElement(AZ::Edit::UIHandlers::CheckBox, &MeshComponentConfig::m_useForwardPassIblSpecular, "Use Forward Pass IBL Specular", - "Renders IBL specular reflections in the forward pass, using only the most influential probe (based on the position of the entity) and the global IBL cubemap. Can reduce rendering costs, but only recommended for static objects that are affected by at most one reflection probe.") - ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly) + ->DataElement(AZ::Edit::UIHandlers::Default, &MeshComponentConfig::m_modelAsset, "Mesh Asset", "Mesh asset reference") + ->DataElement(AZ::Edit::UIHandlers::Default, &MeshComponentConfig::m_sortKey, "Sort Key", "Transparent meshes are drawn by sort key then depth. Used this to force certain transparent meshes to draw before or after others.") + ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::IsAssetSet) + ->DataElement(AZ::Edit::UIHandlers::CheckBox, &MeshComponentConfig::m_excludeFromReflectionCubeMaps, "Exclude from reflection cubemaps", "Mesh will not be visible in baked reflection probe cubemaps") + ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly) + ->DataElement(AZ::Edit::UIHandlers::CheckBox, &MeshComponentConfig::m_useForwardPassIblSpecular, "Use Forward Pass IBL Specular", + "Renders IBL specular reflections in the forward pass, using only the most influential probe (based on the position of the entity) and the global IBL cubemap. Can reduce rendering costs, but only recommended for static objects that are affected by at most one reflection probe.") + ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly) + ->ClassElement(AZ::Edit::ClassElements::Group, "Lod Configuration") + ->Attribute(AZ::Edit::Attributes::AutoExpand, false) + ->DataElement(AZ::Edit::UIHandlers::ComboBox, &MeshComponentConfig::m_lodType, "Lod Type", "Lod Method.") + ->Attribute(AZ::Edit::Attributes::EnumValues, &MeshComponentConfig::GetLodTypeValues) + ->DataElement(AZ::Edit::UIHandlers::ComboBox, &MeshComponentConfig::m_lodOverride, "Lod Override", "Allows the rendered LOD to be overridden instead of being calculated automatically.") + ->Attribute(AZ::Edit::Attributes::EnumValues, &MeshComponentConfig::GetLodOverrideValues) + ->DataElement(AZ::Edit::UIHandlers::Slider, &MeshComponentConfig::m_minimumScreenCoverage, "Minimum Screen Coverage", "Minimum proportion of screen area an entitiy takes up, after that the entitiy is culled.") + ->Attribute(AZ::Edit::Attributes::Min, 0.f) + ->Attribute(AZ::Edit::Attributes::Max, 1.f) + ->Attribute(AZ::Edit::Attributes::Suffix, " percent") + ->DataElement(AZ::Edit::UIHandlers::Slider, &MeshComponentConfig::m_qualityDecayRate, "Quality Decay Rate", + "Rate at which mesh quality decays (0 -> always stay highest quality, 1 -> quality falls off to lowest quality immediately).") + ->Attribute(AZ::Edit::Attributes::Min, 0.f) + ->Attribute(AZ::Edit::Attributes::Max, 1.f) ; } } diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index 5fde185e4c..adcf570899 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -39,11 +39,12 @@ namespace AZ ->Version(1) ->Field("ModelAsset", &MeshComponentConfig::m_modelAsset) ->Field("SortKey", &MeshComponentConfig::m_sortKey) + ->Field("ExcludeFromReflectionCubeMaps", &MeshComponentConfig::m_excludeFromReflectionCubeMaps) + ->Field("UseForwardPassIBLSpecular", &MeshComponentConfig::m_useForwardPassIblSpecular) + ->Field("LodType", &MeshComponentConfig::m_lodType) ->Field("LodOverride", &MeshComponentConfig::m_lodOverride) ->Field("MinimumScreenCoverage", &MeshComponentConfig::m_minimumScreenCoverage) - ->Field("QualityDecayRate", &MeshComponentConfig::m_qualityDecayRate) - ->Field("ExcludeFromReflectionCubeMaps", &MeshComponentConfig::m_excludeFromReflectionCubeMaps) - ->Field("UseForwardPassIBLSpecular", &MeshComponentConfig::m_useForwardPassIblSpecular); + ->Field("QualityDecayRate", &MeshComponentConfig::m_qualityDecayRate); } } @@ -85,6 +86,13 @@ namespace AZ return values; } + AZStd::vector> MeshComponentConfig::GetLodTypeValues() + { + return { + {RPI::Cullable::DefaultLodType, "Default"} + }; + } + MeshComponentController::~MeshComponentController() { // Release memory, disconnect from buses in the right order and broadcast events so that other components are aware. @@ -109,6 +117,11 @@ namespace AZ ->Attribute(AZ::Script::Attributes::Category, "render") ->Attribute(AZ::Script::Attributes::Module, "render"); + behaviorContext->ConstantProperty("DefaultLodType", BehaviorConstant(RPI::Cullable::DefaultLodType)) + ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) + ->Attribute(AZ::Script::Attributes::Category, "render") + ->Attribute(AZ::Script::Attributes::Module, "render"); + behaviorContext->EBus("RenderMeshComponentRequestBus") ->Event("GetModelAssetId", &MeshComponentRequestBus::Events::GetModelAssetId) ->Event("SetModelAssetId", &MeshComponentRequestBus::Events::SetModelAssetId) @@ -116,6 +129,8 @@ namespace AZ ->Event("SetModelAssetPath", &MeshComponentRequestBus::Events::SetModelAssetPath) ->Event("SetSortKey", &MeshComponentRequestBus::Events::SetSortKey) ->Event("GetSortKey", &MeshComponentRequestBus::Events::GetSortKey) + ->Event("SetLodType", &MeshComponentRequestBus::Events::SetLodType) + ->Event("GetLodType", &MeshComponentRequestBus::Events::GetLodType) ->Event("SetLodOverride", &MeshComponentRequestBus::Events::SetLodOverride) ->Event("GetLodOverride", &MeshComponentRequestBus::Events::GetLodOverride) ->Event("SetMinimumScreenCoverage", &MeshComponentRequestBus::Events::SetMinimumScreenCoverage) @@ -125,6 +140,7 @@ namespace AZ ->VirtualProperty("ModelAssetId", "GetModelAssetId", "SetModelAssetId") ->VirtualProperty("ModelAssetPath", "GetModelAssetPath", "SetModelAssetPath") ->VirtualProperty("SortKey", "GetSortKey", "SetSortKey") + ->VirtualProperty("LodType", "GetLodType", "SetLodType") ->VirtualProperty("LodOverride", "GetLodOverride", "SetLodOverride") ->VirtualProperty("MinimumScreenCoverage", "GetMinimumScreenCoverage", "SetMinimumScreenCoverage") ->VirtualProperty("QualityDecayRate", "GetQualityDecayRate", "SetQualityDecayRate") @@ -332,9 +348,7 @@ namespace AZ m_meshFeatureProcessor->SetTransform(m_meshHandle, transform, m_cachedNonUniformScale); m_meshFeatureProcessor->SetSortKey(m_meshHandle, m_configuration.m_sortKey); - m_meshFeatureProcessor->SetLodOverride(m_meshHandle, m_configuration.m_lodOverride); - m_meshFeatureProcessor->SetMinimumScreenCoverage(m_meshHandle, m_configuration.m_minimumScreenCoverage); - m_meshFeatureProcessor->SetQualityDecayRate(m_meshHandle, m_configuration.m_qualityDecayRate); + m_meshFeatureProcessor->SetMeshLodConfiguration(m_meshHandle, GetMeshLodConfiguration()); m_meshFeatureProcessor->SetExcludeFromReflectionCubeMaps(m_meshHandle, m_configuration.m_excludeFromReflectionCubeMaps); m_meshFeatureProcessor->SetVisible(m_meshHandle, m_isVisible); @@ -425,37 +439,66 @@ namespace AZ return m_meshFeatureProcessor->GetSortKey(m_meshHandle); } + RPI::Cullable::LodConfiguration MeshComponentController::GetMeshLodConfiguration() const + { + return { + m_configuration.m_lodType, + m_configuration.m_lodOverride, + m_configuration.m_minimumScreenCoverage, + m_configuration.m_qualityDecayRate + }; + } + // ----------------------- + void MeshComponentController::SetLodType(RPI::Cullable::LodType lodType) + { + RPI::Cullable::LodConfiguration lodConfig = GetMeshLodConfiguration(); + lodConfig.m_lodType = lodType; + m_meshFeatureProcessor->SetMeshLodConfiguration(m_meshHandle, lodConfig); + } + + RPI::Cullable::LodType MeshComponentController::GetLodType() const + { + RPI::Cullable::LodConfiguration lodConfig = m_meshFeatureProcessor->GetMeshLodConfiguration(m_meshHandle); + return lodConfig.m_lodType; + } + void MeshComponentController::SetLodOverride(RPI::Cullable::LodOverride lodOverride) { - m_configuration.m_lodOverride = lodOverride; // Save for serialization - m_meshFeatureProcessor->SetLodOverride(m_meshHandle, lodOverride); + RPI::Cullable::LodConfiguration lodConfig = GetMeshLodConfiguration(); + lodConfig.m_lodOverride = lodOverride; + m_meshFeatureProcessor->SetMeshLodConfiguration(m_meshHandle, lodConfig); } RPI::Cullable::LodOverride MeshComponentController::GetLodOverride() const { - return m_meshFeatureProcessor->GetSortKey(m_meshHandle); + RPI::Cullable::LodConfiguration lodConfig = m_meshFeatureProcessor->GetMeshLodConfiguration(m_meshHandle); + return lodConfig.m_lodOverride; } void MeshComponentController::SetMinimumScreenCoverage(float minimumScreenCoverage) { - m_configuration.m_minimumScreenCoverage = minimumScreenCoverage; - m_meshFeatureProcessor->SetMinimumScreenCoverage(m_meshHandle, minimumScreenCoverage); + RPI::Cullable::LodConfiguration lodConfig = GetMeshLodConfiguration(); + lodConfig.m_minimumScreenCoverage = minimumScreenCoverage; + m_meshFeatureProcessor->SetMeshLodConfiguration(m_meshHandle, lodConfig); } float MeshComponentController::GetMinimumScreenCoverage() const { - return m_meshFeatureProcessor->GetMinimumScreenCoverage(m_meshHandle); + RPI::Cullable::LodConfiguration lodConfig = m_meshFeatureProcessor->GetMeshLodConfiguration(m_meshHandle); + return lodConfig.m_minimumScreenCoverage; } void MeshComponentController::SetQualityDecayRate(float qualityDecayRate) { - m_configuration.m_qualityDecayRate = qualityDecayRate; - m_meshFeatureProcessor->SetQualityDecayRate(m_meshHandle, qualityDecayRate); + RPI::Cullable::LodConfiguration lodConfig = GetMeshLodConfiguration(); + lodConfig.m_qualityDecayRate = qualityDecayRate; + m_meshFeatureProcessor->SetMeshLodConfiguration(m_meshHandle, lodConfig); } float MeshComponentController::GetQualityDecayRate() const { - return m_meshFeatureProcessor->GetQualityDecayRate(m_meshHandle); + RPI::Cullable::LodConfiguration lodConfig = m_meshFeatureProcessor->GetMeshLodConfiguration(m_meshHandle); + return lodConfig.m_qualityDecayRate; } void MeshComponentController::SetVisibility(bool visible) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h index 888d4bb154..1b479ed3eb 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h @@ -30,6 +30,9 @@ namespace AZ { namespace Render { + + + //! A configuration structure for the MeshComponentController class MeshComponentConfig final : public AZ::ComponentConfig @@ -42,14 +45,17 @@ namespace AZ // Editor helper functions bool IsAssetSet(); AZStd::vector> GetLodOverrideValues(); + AZStd::vector> GetLodTypeValues(); Data::Asset m_modelAsset = { AZ::Data::AssetLoadBehavior::QueueLoad }; RHI::DrawItemSortKey m_sortKey = 0; - RPI::Cullable::LodOverride m_lodOverride = RPI::Cullable::NoLodOverride; - float m_minimumScreenCoverage = 1.0f / 1080.0f; - float m_qualityDecayRate = 0.5f; bool m_excludeFromReflectionCubeMaps = false; bool m_useForwardPassIblSpecular = false; + + RPI::Cullable::LodType m_lodType = RPI::Cullable::DefaultLodType; + RPI::Cullable::LodOverride m_lodOverride = RPI::Cullable::NoLodOverride; + float m_minimumScreenCoverage = RPI::Cullable::LodData::DefaultMinimumScreenCoverage; + float m_qualityDecayRate = RPI::Cullable::LodData::DefaultQualityDecayRate; }; class MeshComponentController final @@ -96,14 +102,17 @@ namespace AZ void SetSortKey(RHI::DrawItemSortKey sortKey) override; RHI::DrawItemSortKey GetSortKey() const override; - void SetLodOverride(RPI::Cullable::LodOverride lodOverride) override; - RPI::Cullable::LodOverride GetLodOverride() const override; + void SetLodType(RPI::Cullable::LodType lodType) override; + RPI::Cullable::LodType GetLodType() const override; - void SetMinimumScreenCoverage(float minimumScreenCoverage) override; - float GetMinimumScreenCoverage() const override; + virtual void SetLodOverride(RPI::Cullable::LodOverride lodOverride); + virtual RPI::Cullable::LodOverride GetLodOverride() const; - void SetQualityDecayRate(float qualityDecayRate) override; - float GetQualityDecayRate() const override; + virtual void SetMinimumScreenCoverage(float minimumScreenCoverage); + virtual float GetMinimumScreenCoverage() const; + + virtual void SetQualityDecayRate(float qualityDecayRate); + virtual float GetQualityDecayRate() const; void SetVisibility(bool visible) override; bool GetVisibility() const override; @@ -137,6 +146,8 @@ namespace AZ void UnregisterModel(); void RefreshModelRegistration(); + RPI::Cullable::LodConfiguration MeshComponentController::GetMeshLodConfiguration() const; + void HandleNonUniformScaleChange(const AZ::Vector3& nonUniformScale); Render::MeshFeatureProcessorInterface* m_meshFeatureProcessor = nullptr; diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp index 63912aa8a6..e2debacb83 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp @@ -404,35 +404,53 @@ namespace AZ { return m_meshFeatureProcessor->GetSortKey(*m_meshHandle); } + + void AtomActorInstance::SetLodType(RPI::Cullable::LodType lodType) + { + RPI::Cullable::LodConfiguration config = m_meshFeatureProcessor->GetMeshLodConfiguration(*m_meshHandle); + config.m_lodType = lodType; + m_meshFeatureProcessor->SetMeshLodConfiguration(*m_meshHandle, config); + } + + RPI::Cullable::LodType AtomActorInstance::GetLodType() const + { + return m_meshFeatureProcessor->GetMeshLodConfiguration(*m_meshHandle).m_lodType; + } void AtomActorInstance::SetLodOverride(RPI::Cullable::LodOverride lodOverride) { - m_meshFeatureProcessor->SetLodOverride(*m_meshHandle, lodOverride); + RPI::Cullable::LodConfiguration config = m_meshFeatureProcessor->GetMeshLodConfiguration(*m_meshHandle); + config.m_lodOverride = lodOverride; + m_meshFeatureProcessor->SetMeshLodConfiguration(*m_meshHandle, config); } RPI::Cullable::LodOverride AtomActorInstance::GetLodOverride() const { - return m_meshFeatureProcessor->GetLodOverride(*m_meshHandle); + return m_meshFeatureProcessor->GetMeshLodConfiguration(*m_meshHandle).m_lodOverride; } void AtomActorInstance::SetMinimumScreenCoverage(float minimumScreenCoverage) { - m_meshFeatureProcessor->SetMinimumScreenCoverage(*m_meshHandle, minimumScreenCoverage); + RPI::Cullable::LodConfiguration config = m_meshFeatureProcessor->GetMeshLodConfiguration(*m_meshHandle); + config.m_minimumScreenCoverage = minimumScreenCoverage; + m_meshFeatureProcessor->SetMeshLodConfiguration(*m_meshHandle, config); } float AtomActorInstance::GetMinimumScreenCoverage() const { - return m_meshFeatureProcessor->GetMinimumScreenCoverage(*m_meshHandle); + return m_meshFeatureProcessor->GetMeshLodConfiguration(*m_meshHandle).m_minimumScreenCoverage; } void AtomActorInstance::SetQualityDecayRate(float qualityDecayRate) { - m_meshFeatureProcessor->SetQualityDecayRate(*m_meshHandle, qualityDecayRate); + RPI::Cullable::LodConfiguration config = m_meshFeatureProcessor->GetMeshLodConfiguration(*m_meshHandle); + config.m_qualityDecayRate = qualityDecayRate; + m_meshFeatureProcessor->SetMeshLodConfiguration(*m_meshHandle, config); } float AtomActorInstance::GetQualityDecayRate() const { - return m_meshFeatureProcessor->GetQualityDecayRate(*m_meshHandle); + return m_meshFeatureProcessor->GetMeshLodConfiguration(*m_meshHandle).m_qualityDecayRate; } void AtomActorInstance::SetVisibility(bool visible) diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.h b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.h index bd9afc668e..bf832e9def 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.h +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.h @@ -138,6 +138,8 @@ namespace AZ AZ::Data::Instance GetModel() const override; void SetSortKey(RHI::DrawItemSortKey sortKey) override; RHI::DrawItemSortKey GetSortKey() const override; + void SetLodType(RPI::Cullable::LodType lodType) override; + RPI::Cullable::LodType GetLodType() const override; void SetLodOverride(RPI::Cullable::LodOverride lodOverride) override; RPI::Cullable::LodOverride GetLodOverride() const override; void SetMinimumScreenCoverage(float minimumScreenCoverage) override; From 0c05c9f20462a708de228e5ff06acd96d9b3a533 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Wed, 11 Aug 2021 15:49:50 -0700 Subject: [PATCH 10/53] [not working] Made lod selection more generic for further work Signed-off-by: Kyle B --- .../Code/Source/Mesh/MeshFeatureProcessor.cpp | 2 +- .../Code/Include/Atom/RPI.Public/Culling.h | 26 +++++------ .../RPI/Code/Source/RPI.Public/Culling.cpp | 27 ++++++----- .../QuadSphere_Default.material | 28 +++++++++++ .../Code/Source/Mesh/EditorMeshComponent.cpp | 9 +++- .../Source/Mesh/MeshComponentController.cpp | 46 +++++++++++++++++-- .../Source/Mesh/MeshComponentController.h | 11 +++-- 7 files changed, 113 insertions(+), 36 deletions(-) create mode 100644 Gems/Atom/Tools/MaterialEditor/Assets/MaterialEditor/ViewportModels/QuadSphere_Default.material diff --git a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp index 679e64e283..363723f7da 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp @@ -376,7 +376,7 @@ namespace AZ else { AZ_Assert(false, "Invalid mesh handle"); - return {0,0,0.0f,0.0f}; + return {RPI::Cullable::LodType::Default, 0, 0.0f, 0.0f }; } } diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h index e89e180540..82e9c733c8 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h @@ -70,17 +70,22 @@ namespace AZ }; CullData m_cullData; - using LodType = uint8_t; + enum LodType : uint8_t + { + Default = 0, + ScreenCoverage, + SpecificLod, + }; using LodOverride = uint8_t; - static constexpr uint8_t NoLodOverride = AZStd::numeric_limits::max(); - static constexpr uint8_t DefaultLodType = AZStd::numeric_limits::max(); struct LodConfiguration { - LodType m_lodType; - LodOverride m_lodOverride; - float m_minimumScreenCoverage; - float m_qualityDecayRate; + LodType m_lodType = LodType::Default; + LodOverride m_lodOverride = 0; + // the minimum possibe area a sphere enclosing a mesh projected onto the screen should have before it is culled. + float m_minimumScreenCoverage = 1.0f / 1080.0f; // For default, mesh should cover at least a screen pixel at 1080p to be drawn; + // The screen area decay between 0 and 1, i.e. closer to 1 -> lose quality immediately, closer to 0 -> never lose quality + float m_qualityDecayRate = 0.5f; }; struct LodData @@ -98,12 +103,7 @@ namespace AZ //! Suggest setting to: 0.5f*localAabb.GetExtents().GetMaxElement() float m_lodSelectionRadius = 1.0f; - // the minimum possibe area a sphere enclosing a mesh projected onto the screen should have before it is culled. - static constexpr float DefaultMinimumScreenCoverage = 1.0f / 1080.0f; //For default, mesh should cover at least a screen pixel at 1080p to be drawn - // The screen area decay between 0 and 1, i.e. closer to 1 -> lose quality immediately, closer to 0 -> never lose quality - static constexpr float DefaultQualityDecayRate = 0.5f; - - LodConfiguration m_lodConfiguration = { DefaultLodType, NoLodOverride, DefaultMinimumScreenCoverage, DefaultQualityDecayRate }; + LodConfiguration m_lodConfiguration; }; LodData m_lodData; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp index f22d5c7224..c0d9023fa9 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp @@ -672,20 +672,25 @@ namespace AZ } }; - if (lodData.m_lodConfiguration.m_lodOverride == Cullable::NoLodOverride) + switch (lodData.m_lodConfiguration.m_lodType) { - for (const Cullable::LodData::Lod& lod : lodData.m_lods) - { - //Note that this supports overlapping lod ranges (to suport cross-fading lods, for example) - if (approxScreenPercentage >= lod.m_screenCoverageMin && approxScreenPercentage <= lod.m_screenCoverageMax) + case Cullable::LodType::SpecificLod: + if (lodData.m_lodConfiguration.m_lodOverride < lodData.m_lods.size()) { - addLodToDrawPacket(lod); + addLodToDrawPacket(lodData.m_lods.at(lodData.m_lodConfiguration.m_lodOverride)); } - } - } - else if(lodData.m_lodConfiguration.m_lodOverride < lodData.m_lods.size()) - { - addLodToDrawPacket(lodData.m_lods.at(lodData.m_lodConfiguration.m_lodOverride)); + break; + case Cullable::LodType::ScreenCoverage: + default: + for (const Cullable::LodData::Lod& lod : lodData.m_lods) + { + // Note that this supports overlapping lod ranges (to suport cross-fading lods, for example) + if (approxScreenPercentage >= lod.m_screenCoverageMin && approxScreenPercentage <= lod.m_screenCoverageMax) + { + addLodToDrawPacket(lod); + } + } + break; } return numVisibleDrawPackets; diff --git a/Gems/Atom/Tools/MaterialEditor/Assets/MaterialEditor/ViewportModels/QuadSphere_Default.material b/Gems/Atom/Tools/MaterialEditor/Assets/MaterialEditor/ViewportModels/QuadSphere_Default.material new file mode 100644 index 0000000000..4905c302fe --- /dev/null +++ b/Gems/Atom/Tools/MaterialEditor/Assets/MaterialEditor/ViewportModels/QuadSphere_Default.material @@ -0,0 +1,28 @@ +{ + "description": "", + "materialType": "Materials/Types/StandardPBR.materialtype", + "parentMaterial": "", + "propertyLayoutVersion": 3, + "properties": { + "baseColor": { + "color": [ + 0.800000011920929, + 0.800000011920929, + 0.800000011920929, + 1.0 + ], + "textureMap": "MaterialEditor/ViewportModels/_dev_shaderball_00_basecolor.png" + }, + "emissive": { + "color": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "opacity": { + "factor": 1.0 + } + } +} \ No newline at end of file diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp index 0719d9f2bb..ff0741fc31 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp @@ -79,20 +79,25 @@ namespace AZ ->DataElement(AZ::Edit::UIHandlers::CheckBox, &MeshComponentConfig::m_useForwardPassIblSpecular, "Use Forward Pass IBL Specular", "Renders IBL specular reflections in the forward pass, using only the most influential probe (based on the position of the entity) and the global IBL cubemap. Can reduce rendering costs, but only recommended for static objects that are affected by at most one reflection probe.") ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly) - ->ClassElement(AZ::Edit::ClassElements::Group, "Lod Configuration") - ->Attribute(AZ::Edit::Attributes::AutoExpand, false) ->DataElement(AZ::Edit::UIHandlers::ComboBox, &MeshComponentConfig::m_lodType, "Lod Type", "Lod Method.") ->Attribute(AZ::Edit::Attributes::EnumValues, &MeshComponentConfig::GetLodTypeValues) + ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::IsAssetSet) + ->ClassElement(AZ::Edit::ClassElements::Group, "Lod Configuration") + ->Attribute(AZ::Edit::Attributes::AutoExpand, false) + ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::ShowLodConfig) ->DataElement(AZ::Edit::UIHandlers::ComboBox, &MeshComponentConfig::m_lodOverride, "Lod Override", "Allows the rendered LOD to be overridden instead of being calculated automatically.") ->Attribute(AZ::Edit::Attributes::EnumValues, &MeshComponentConfig::GetLodOverrideValues) + ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::LodTypeIsSpecificLOD) ->DataElement(AZ::Edit::UIHandlers::Slider, &MeshComponentConfig::m_minimumScreenCoverage, "Minimum Screen Coverage", "Minimum proportion of screen area an entitiy takes up, after that the entitiy is culled.") ->Attribute(AZ::Edit::Attributes::Min, 0.f) ->Attribute(AZ::Edit::Attributes::Max, 1.f) ->Attribute(AZ::Edit::Attributes::Suffix, " percent") + ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::LodTypeIsScreenCoverage) ->DataElement(AZ::Edit::UIHandlers::Slider, &MeshComponentConfig::m_qualityDecayRate, "Quality Decay Rate", "Rate at which mesh quality decays (0 -> always stay highest quality, 1 -> quality falls off to lowest quality immediately).") ->Attribute(AZ::Edit::Attributes::Min, 0.f) ->Attribute(AZ::Edit::Attributes::Max, 1.f) + ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::LodTypeIsScreenCoverage) ; } } diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index adcf570899..3d049d0f97 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -31,11 +31,30 @@ namespace AZ { namespace Render { + + namespace MeshComponentControllerVersionUtility + { + bool VersionConverter(AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& classElement) + { + if (classElement.GetVersion() < 2) + { + RPI::Cullable::LodOverride lodOverride = classElement.FindElement(AZ_CRC("LodOverride")); + static constexpr uint8_t old_NoLodOverride = AZStd::numeric_limits ::max(); + if (lodOverride == old_NoLodOverride) + { + classElement.AddElementWithData(context, "LodType", RPI::Cullable::LodType::SpecificLod); + } + } + return true; + } + } // namespace MeshComponentControllerVersionUtility + void MeshComponentConfig::Reflect(ReflectContext* context) { if (auto* serializeContext = azrtti_cast(context)) { serializeContext->Class() + //->Version(2, &MeshComponentControllerVersionUtility::VersionConverter) ->Version(1) ->Field("ModelAsset", &MeshComponentConfig::m_modelAsset) ->Field("SortKey", &MeshComponentConfig::m_sortKey) @@ -53,6 +72,21 @@ namespace AZ return m_modelAsset.GetId().IsValid(); } + bool MeshComponentConfig::LodTypeIsScreenCoverage() + { + return m_lodType == RPI::Cullable::LodType::ScreenCoverage; + } + + bool MeshComponentConfig::LodTypeIsSpecificLOD() + { + return m_lodType == RPI::Cullable::LodType::SpecificLod; + } + + bool MeshComponentConfig::ShowLodConfig() + { + return LodTypeIsScreenCoverage() && LodTypeIsSpecificLOD(); + } + AZStd::vector> MeshComponentConfig::GetLodOverrideValues() { AZStd::vector> values; @@ -75,9 +109,9 @@ namespace AZ } values.reserve(lodCount + 1); - values.push_back({ RPI::Cullable::NoLodOverride, "Not Set" }); + values.push_back({0, "Default (Highest)" }); - for (uint32_t i = 0; i < lodCount; ++i) + for (uint32_t i = 1; i < lodCount; ++i) { AZStd::string enumDescription = AZStd::string::format("Lod %i", i); values.push_back({ aznumeric_cast(i), enumDescription.c_str() }); @@ -89,7 +123,9 @@ namespace AZ AZStd::vector> MeshComponentConfig::GetLodTypeValues() { return { - {RPI::Cullable::DefaultLodType, "Default"} + {aznumeric_cast(0), "Default"}, + {aznumeric_cast(1), "Screen Coverage" }, + {aznumeric_cast(2), "Specific Lod" } }; } @@ -112,12 +148,12 @@ namespace AZ if (AZ::BehaviorContext* behaviorContext = azrtti_cast(context)) { - behaviorContext->ConstantProperty("NoLodOverride", BehaviorConstant(RPI::Cullable::NoLodOverride)) + behaviorContext->ConstantProperty("DefaultLodOverride", BehaviorConstant(0)) ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) ->Attribute(AZ::Script::Attributes::Category, "render") ->Attribute(AZ::Script::Attributes::Module, "render"); - behaviorContext->ConstantProperty("DefaultLodType", BehaviorConstant(RPI::Cullable::DefaultLodType)) + behaviorContext->ConstantProperty("DefaultLodType", BehaviorConstant(RPI::Cullable::LodType::Default)) ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) ->Attribute(AZ::Script::Attributes::Category, "render") ->Attribute(AZ::Script::Attributes::Module, "render"); diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h index 1b479ed3eb..5f38088ca3 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h @@ -44,6 +44,9 @@ namespace AZ // Editor helper functions bool IsAssetSet(); + bool LodTypeIsScreenCoverage(); + bool LodTypeIsSpecificLOD(); + bool ShowLodConfig(); AZStd::vector> GetLodOverrideValues(); AZStd::vector> GetLodTypeValues(); @@ -52,10 +55,10 @@ namespace AZ bool m_excludeFromReflectionCubeMaps = false; bool m_useForwardPassIblSpecular = false; - RPI::Cullable::LodType m_lodType = RPI::Cullable::DefaultLodType; - RPI::Cullable::LodOverride m_lodOverride = RPI::Cullable::NoLodOverride; - float m_minimumScreenCoverage = RPI::Cullable::LodData::DefaultMinimumScreenCoverage; - float m_qualityDecayRate = RPI::Cullable::LodData::DefaultQualityDecayRate; + RPI::Cullable::LodType m_lodType = RPI::Cullable::LodType::Default; + RPI::Cullable::LodOverride m_lodOverride = aznumeric_cast(0); + float m_minimumScreenCoverage = 1.0f / 1080.0f; + float m_qualityDecayRate = 0.5f; }; class MeshComponentController final From cea334dbc40d076b0d4d3fc052f89a660466f662 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Wed, 11 Aug 2021 22:23:06 -0700 Subject: [PATCH 11/53] Fixed enum value problems Signed-off-by: Kyle B --- .../Code/Source/Mesh/EditorMeshComponent.cpp | 4 +++- .../Code/Source/Mesh/MeshComponentController.cpp | 13 ++----------- .../Code/Source/Mesh/MeshComponentController.h | 1 - 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp index ff0741fc31..63b32f6892 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp @@ -80,7 +80,9 @@ namespace AZ "Renders IBL specular reflections in the forward pass, using only the most influential probe (based on the position of the entity) and the global IBL cubemap. Can reduce rendering costs, but only recommended for static objects that are affected by at most one reflection probe.") ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly) ->DataElement(AZ::Edit::UIHandlers::ComboBox, &MeshComponentConfig::m_lodType, "Lod Type", "Lod Method.") - ->Attribute(AZ::Edit::Attributes::EnumValues, &MeshComponentConfig::GetLodTypeValues) + ->EnumAttribute(RPI::Cullable::LodType::Default, "Default") + ->EnumAttribute(RPI::Cullable::LodType::ScreenCoverage, "Screen Coverage") + ->EnumAttribute(RPI::Cullable::LodType::SpecificLod, "Specific Lod") ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::IsAssetSet) ->ClassElement(AZ::Edit::ClassElements::Group, "Lod Configuration") ->Attribute(AZ::Edit::Attributes::AutoExpand, false) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index 3d049d0f97..9aa3685c34 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -54,8 +54,7 @@ namespace AZ if (auto* serializeContext = azrtti_cast(context)) { serializeContext->Class() - //->Version(2, &MeshComponentControllerVersionUtility::VersionConverter) - ->Version(1) + ->Version(2, &MeshComponentControllerVersionUtility::VersionConverter) ->Field("ModelAsset", &MeshComponentConfig::m_modelAsset) ->Field("SortKey", &MeshComponentConfig::m_sortKey) ->Field("ExcludeFromReflectionCubeMaps", &MeshComponentConfig::m_excludeFromReflectionCubeMaps) @@ -65,6 +64,7 @@ namespace AZ ->Field("MinimumScreenCoverage", &MeshComponentConfig::m_minimumScreenCoverage) ->Field("QualityDecayRate", &MeshComponentConfig::m_qualityDecayRate); } + } bool MeshComponentConfig::IsAssetSet() @@ -120,15 +120,6 @@ namespace AZ return values; } - AZStd::vector> MeshComponentConfig::GetLodTypeValues() - { - return { - {aznumeric_cast(0), "Default"}, - {aznumeric_cast(1), "Screen Coverage" }, - {aznumeric_cast(2), "Specific Lod" } - }; - } - MeshComponentController::~MeshComponentController() { // Release memory, disconnect from buses in the right order and broadcast events so that other components are aware. diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h index 5f38088ca3..aba560b6e8 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h @@ -48,7 +48,6 @@ namespace AZ bool LodTypeIsSpecificLOD(); bool ShowLodConfig(); AZStd::vector> GetLodOverrideValues(); - AZStd::vector> GetLodTypeValues(); Data::Asset m_modelAsset = { AZ::Data::AssetLoadBehavior::QueueLoad }; RHI::DrawItemSortKey m_sortKey = 0; From bdbab1090a6970f057de0ac65e074204eefdbc2c Mon Sep 17 00:00:00 2001 From: Kyle B Date: Thu, 12 Aug 2021 14:49:25 -0700 Subject: [PATCH 12/53] removed accidental file addition Signed-off-by: Kyle B --- .../QuadSphere_Default.material | 28 ------------------- 1 file changed, 28 deletions(-) delete mode 100644 Gems/Atom/Tools/MaterialEditor/Assets/MaterialEditor/ViewportModels/QuadSphere_Default.material diff --git a/Gems/Atom/Tools/MaterialEditor/Assets/MaterialEditor/ViewportModels/QuadSphere_Default.material b/Gems/Atom/Tools/MaterialEditor/Assets/MaterialEditor/ViewportModels/QuadSphere_Default.material deleted file mode 100644 index 4905c302fe..0000000000 --- a/Gems/Atom/Tools/MaterialEditor/Assets/MaterialEditor/ViewportModels/QuadSphere_Default.material +++ /dev/null @@ -1,28 +0,0 @@ -{ - "description": "", - "materialType": "Materials/Types/StandardPBR.materialtype", - "parentMaterial": "", - "propertyLayoutVersion": 3, - "properties": { - "baseColor": { - "color": [ - 0.800000011920929, - 0.800000011920929, - 0.800000011920929, - 1.0 - ], - "textureMap": "MaterialEditor/ViewportModels/_dev_shaderball_00_basecolor.png" - }, - "emissive": { - "color": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "opacity": { - "factor": 1.0 - } - } -} \ No newline at end of file From 6acbea722ef101227896366bd6e9518f9d691da7 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Thu, 12 Aug 2021 18:15:17 -0700 Subject: [PATCH 13/53] minor syntax changes and adding a refresh tree attributeto the editor component Signed-off-by: Kyle B --- .../Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h | 2 +- .../Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h | 2 +- .../Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp | 2 +- .../CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h index daf4a493c2..a448f7121f 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h @@ -155,7 +155,7 @@ namespace AZ void SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey) override; RHI::DrawItemSortKey GetSortKey(const MeshHandle& meshHandle) override; - void SetMeshLodConfiguration(const MeshHandle& meshHandle, RPI::Cullable::LodConfiguration meshLodConfig); + void SetMeshLodConfiguration(const MeshHandle& meshHandle, const RPI::Cullable::LodConfiguration meshLodConfig); RPI::Cullable::LodConfiguration GetMeshLodConfiguration(const MeshHandle& meshHandle) const; void SetExcludeFromReflectionCubeMaps(const MeshHandle& meshHandle, bool excludeFromReflectionCubeMaps) override; diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h index 8c7a200ff5..c341cd8854 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h @@ -95,7 +95,7 @@ namespace AZ //! Gets the sort key for a given mesh handle. virtual RHI::DrawItemSortKey GetSortKey(const MeshHandle& meshHandle) = 0; //! Sets LOD mesh configurations to be used in the Mesh Feature Processor - virtual void SetMeshLodConfiguration(const MeshHandle& meshHandle, RPI::Cullable::LodConfiguration meshLodConfig) = 0; + virtual void SetMeshLodConfiguration(const MeshHandle& meshHandle, const RPI::Cullable::LodConfiguration meshLodConfig) = 0; //! Gets the LOD mesh configurations being used in the Mesh Feature Processor virtual RPI::Cullable::LodConfiguration GetMeshLodConfiguration(const MeshHandle& meshHandle) const = 0; //! Sets the option to exclude this mesh from baked reflection probe cubemaps diff --git a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp index 363723f7da..e07c7a0309 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp @@ -359,7 +359,7 @@ namespace AZ } } - void MeshFeatureProcessor::SetMeshLodConfiguration(const MeshHandle& meshHandle, RPI::Cullable::LodConfiguration meshLodConfig) + void MeshFeatureProcessor::SetMeshLodConfiguration(const MeshHandle& meshHandle, const RPI::Cullable::LodConfiguration meshLodConfig) { if (meshHandle.IsValid()) { diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp index 63b32f6892..8f81bd620d 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp @@ -84,6 +84,7 @@ namespace AZ ->EnumAttribute(RPI::Cullable::LodType::ScreenCoverage, "Screen Coverage") ->EnumAttribute(RPI::Cullable::LodType::SpecificLod, "Specific Lod") ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::IsAssetSet) + ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::EntireTree) ->ClassElement(AZ::Edit::ClassElements::Group, "Lod Configuration") ->Attribute(AZ::Edit::Attributes::AutoExpand, false) ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::ShowLodConfig) From 1322a59e9e1ea9c1368da59c8a180bf513ee54a3 Mon Sep 17 00:00:00 2001 From: Pinfel Date: Sat, 14 Aug 2021 16:20:15 -0400 Subject: [PATCH 14/53] Corrected audio component links to documentation Note that the "Audio Animation" component has no documentation so I did not add for it. Signed-off-by: Pinfel --- Gems/LmbrCentral/Code/Source/Audio/AudioProxyComponent.cpp | 2 +- .../Code/Source/Audio/EditorAudioAreaEnvironmentComponent.cpp | 2 +- .../Code/Source/Audio/EditorAudioEnvironmentComponent.cpp | 2 +- .../Code/Source/Audio/EditorAudioListenerComponent.cpp | 2 +- .../Code/Source/Audio/EditorAudioMultiPositionComponent.cpp | 2 +- .../Code/Source/Audio/EditorAudioPreloadComponent.cpp | 2 +- Gems/LmbrCentral/Code/Source/Audio/EditorAudioRtpcComponent.cpp | 2 +- .../Code/Source/Audio/EditorAudioSwitchComponent.cpp | 2 +- .../Code/Source/Audio/EditorAudioTriggerComponent.cpp | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Gems/LmbrCentral/Code/Source/Audio/AudioProxyComponent.cpp b/Gems/LmbrCentral/Code/Source/Audio/AudioProxyComponent.cpp index 8be8aa042e..659fff55d9 100644 --- a/Gems/LmbrCentral/Code/Source/Audio/AudioProxyComponent.cpp +++ b/Gems/LmbrCentral/Code/Source/Audio/AudioProxyComponent.cpp @@ -39,7 +39,7 @@ namespace LmbrCentral ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/AudioProxy.svg") ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c)) ->Attribute(AZ::Edit::Attributes::AddableByUser, true) - ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/audio-proxy/") + ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/audio/proxy/") ; } } diff --git a/Gems/LmbrCentral/Code/Source/Audio/EditorAudioAreaEnvironmentComponent.cpp b/Gems/LmbrCentral/Code/Source/Audio/EditorAudioAreaEnvironmentComponent.cpp index 2b4741331f..7861244ea4 100644 --- a/Gems/LmbrCentral/Code/Source/Audio/EditorAudioAreaEnvironmentComponent.cpp +++ b/Gems/LmbrCentral/Code/Source/Audio/EditorAudioAreaEnvironmentComponent.cpp @@ -40,7 +40,7 @@ namespace LmbrCentral ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/AudioAreaEnvironment.svg") ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c)) ->Attribute(AZ::Edit::Attributes::AutoExpand, true) - ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/audio-area-environment/") + ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/audio/area-environment/") ->DataElement(AZ::Edit::UIHandlers::Default, &EditorAudioAreaEnvironmentComponent::m_broadPhaseTriggerArea, "Broad-phase trigger area", "The entity that contains a Trigger Area component for broad-phase checks") ->Attribute(AZ::Edit::Attributes::RequiredService, AZ_CRC("ProximityTriggerService", 0x561f262c)) diff --git a/Gems/LmbrCentral/Code/Source/Audio/EditorAudioEnvironmentComponent.cpp b/Gems/LmbrCentral/Code/Source/Audio/EditorAudioEnvironmentComponent.cpp index b4dd5c4d74..b2633a9cb0 100644 --- a/Gems/LmbrCentral/Code/Source/Audio/EditorAudioEnvironmentComponent.cpp +++ b/Gems/LmbrCentral/Code/Source/Audio/EditorAudioEnvironmentComponent.cpp @@ -33,7 +33,7 @@ namespace LmbrCentral ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/AudioEnvironment.png") ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c)) ->Attribute(AZ::Edit::Attributes::AutoExpand, true) - ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/audio-environment/") + ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/audio/environment/") ->DataElement("AudioControl", &EditorAudioEnvironmentComponent::m_defaultEnvironment, "Default Environment", "Name of the default ATL Environment control to use") ; } diff --git a/Gems/LmbrCentral/Code/Source/Audio/EditorAudioListenerComponent.cpp b/Gems/LmbrCentral/Code/Source/Audio/EditorAudioListenerComponent.cpp index 205267db73..c9f80ed398 100644 --- a/Gems/LmbrCentral/Code/Source/Audio/EditorAudioListenerComponent.cpp +++ b/Gems/LmbrCentral/Code/Source/Audio/EditorAudioListenerComponent.cpp @@ -36,7 +36,7 @@ namespace LmbrCentral ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/AudioListener.svg") ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c)) ->Attribute(AZ::Edit::Attributes::AutoExpand, true) - ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/audio-listener/") + ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/audio/listener/") ->DataElement(AZ::Edit::UIHandlers::Default, &EditorAudioListenerComponent::m_rotationEntity, "Rotation Entity", "The Entity whose rotation the audio listener will adopt. If none set, will assume 'this' Entity") ->DataElement(AZ::Edit::UIHandlers::Default, &EditorAudioListenerComponent::m_positionEntity, diff --git a/Gems/LmbrCentral/Code/Source/Audio/EditorAudioMultiPositionComponent.cpp b/Gems/LmbrCentral/Code/Source/Audio/EditorAudioMultiPositionComponent.cpp index 987fa6e0e4..51386b1c02 100644 --- a/Gems/LmbrCentral/Code/Source/Audio/EditorAudioMultiPositionComponent.cpp +++ b/Gems/LmbrCentral/Code/Source/Audio/EditorAudioMultiPositionComponent.cpp @@ -38,7 +38,7 @@ namespace LmbrCentral ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/AudioMultiPosition.svg") ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c)) ->Attribute(AZ::Edit::Attributes::AutoExpand, true) - // Followup: Need Help URL + ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/audio/multi-position/") ->DataElement(AZ::Edit::UIHandlers::Default, &EditorAudioMultiPositionComponent::m_entityRefs, "Entity References", "The entities from which positions will be obtained for multi-position audio") ->DataElement(AZ::Edit::UIHandlers::ComboBox, &EditorAudioMultiPositionComponent::m_behaviorType, "Behavior Type", "Determines how multi-postion sounds are treated, Separate or Blended") ; diff --git a/Gems/LmbrCentral/Code/Source/Audio/EditorAudioPreloadComponent.cpp b/Gems/LmbrCentral/Code/Source/Audio/EditorAudioPreloadComponent.cpp index a5d137c1b2..a24acac292 100644 --- a/Gems/LmbrCentral/Code/Source/Audio/EditorAudioPreloadComponent.cpp +++ b/Gems/LmbrCentral/Code/Source/Audio/EditorAudioPreloadComponent.cpp @@ -43,7 +43,7 @@ namespace LmbrCentral // Icon todo: //->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/AudioPreload.png") - ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/audio-preload/") + ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/audio/preload/") ->DataElement("AudioControl", &EditorAudioPreloadComponent::m_defaultPreload, "Preload Name", "The default ATL Preload control to use") ->DataElement(AZ::Edit::UIHandlers::ComboBox, &EditorAudioPreloadComponent::m_loadType, "Load Type", "Automatically when the component activates/deactivates, or Manually at user's request") diff --git a/Gems/LmbrCentral/Code/Source/Audio/EditorAudioRtpcComponent.cpp b/Gems/LmbrCentral/Code/Source/Audio/EditorAudioRtpcComponent.cpp index ab98692a50..4426c21ff6 100644 --- a/Gems/LmbrCentral/Code/Source/Audio/EditorAudioRtpcComponent.cpp +++ b/Gems/LmbrCentral/Code/Source/Audio/EditorAudioRtpcComponent.cpp @@ -34,7 +34,7 @@ namespace LmbrCentral ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/AudioRtpc.svg") ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c)) ->Attribute(AZ::Edit::Attributes::AutoExpand, true) - ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/audio-rtpc/") + ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/audio/rtpc/") ->DataElement("AudioControl", &EditorAudioRtpcComponent::m_defaultRtpc, "Default Rtpc", "The default ATL Rtpc control to use") ; } diff --git a/Gems/LmbrCentral/Code/Source/Audio/EditorAudioSwitchComponent.cpp b/Gems/LmbrCentral/Code/Source/Audio/EditorAudioSwitchComponent.cpp index 6ea89ee31e..1aafbd5c21 100644 --- a/Gems/LmbrCentral/Code/Source/Audio/EditorAudioSwitchComponent.cpp +++ b/Gems/LmbrCentral/Code/Source/Audio/EditorAudioSwitchComponent.cpp @@ -34,7 +34,7 @@ namespace LmbrCentral ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/AudioSwitch.svg") ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c)) ->Attribute(AZ::Edit::Attributes::AutoExpand, true) - ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/audio-switch/") + ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/audio/switch/") ->DataElement("AudioControl", &EditorAudioSwitchComponent::m_defaultSwitch, "Default Switch", "The default ATL Switch to use when Activated") ->DataElement("AudioControl", &EditorAudioSwitchComponent::m_defaultState, "Default State", "The default ATL State to set on the default Switch when Activated") ; diff --git a/Gems/LmbrCentral/Code/Source/Audio/EditorAudioTriggerComponent.cpp b/Gems/LmbrCentral/Code/Source/Audio/EditorAudioTriggerComponent.cpp index e38caf303b..adecf3c4d0 100644 --- a/Gems/LmbrCentral/Code/Source/Audio/EditorAudioTriggerComponent.cpp +++ b/Gems/LmbrCentral/Code/Source/Audio/EditorAudioTriggerComponent.cpp @@ -43,7 +43,7 @@ namespace LmbrCentral ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/AudioTrigger.svg") ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c)) ->Attribute(AZ::Edit::Attributes::AutoExpand, true) - ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/audio-trigger/") + ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/audio/trigger/") ->DataElement("AudioControl", &EditorAudioTriggerComponent::m_defaultPlayTrigger, "Default 'play' Trigger", "The default ATL Trigger control used by 'Play'") ->DataElement("AudioControl", &EditorAudioTriggerComponent::m_defaultStopTrigger, "Default 'stop' Trigger", "The default ATL Trigger control used by 'Stop'") ->DataElement(AZ::Edit::UIHandlers::ComboBox, &EditorAudioTriggerComponent::m_obstructionType, "Obstruction Type", "Ray-casts used in calculation of obstruction and occlusion") From e2a9c58cae300317f0b3b80ea3cccaae26926512 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Mon, 16 Aug 2021 23:01:18 -0700 Subject: [PATCH 15/53] fixed unnessisary qualifier error Signed-off-by: Kyle B --- .../CommonFeatures/Code/Source/Mesh/MeshComponentController.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h index aba560b6e8..c7f9c8f993 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h @@ -148,7 +148,7 @@ namespace AZ void UnregisterModel(); void RefreshModelRegistration(); - RPI::Cullable::LodConfiguration MeshComponentController::GetMeshLodConfiguration() const; + RPI::Cullable::LodConfiguration GetMeshLodConfiguration() const; void HandleNonUniformScaleChange(const AZ::Vector3& nonUniformScale); From 01ad7c5e4efcb95a185588c5e9ff13633e7667fd Mon Sep 17 00:00:00 2001 From: Kyle B Date: Mon, 16 Aug 2021 23:09:25 -0700 Subject: [PATCH 16/53] fixed namespace issue with the mocks Signed-off-by: Kyle B --- .../Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h index 0c03e767e7..75ce42daed 100644 --- a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h @@ -33,8 +33,8 @@ namespace UnitTest MOCK_CONST_METHOD1(GetLocalAabb, AZ::Aabb(const MeshHandle&)); MOCK_METHOD2(SetSortKey, void (const MeshHandle&, AZ::RHI::DrawItemSortKey)); MOCK_CONST_METHOD1(GetSortKey, AZ::RHI::DrawItemSortKey(const MeshHandle&)); - MOCK_METHOD2(SetMeshLodConfiguration, void(const MeshHandle&, RPI::Cullable::LodConfiguration)); - MOCK_CONST_METHOD1(GetMeshLodConfiguration, RPI::Cullable::LodConfiguration(const MeshHandle&)); + MOCK_METHOD2(SetMeshLodConfiguration, void(const MeshHandle&, AZ::RPI::Cullable::LodConfiguration)); + MOCK_CONST_METHOD1(GetMeshLodConfiguration, AZ::RPI::Cullable::LodConfiguration(const MeshHandle&)); MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Render::MaterialAssignmentMap&)); MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Data::Instance&)); MOCK_METHOD2(SetRayTracingEnabled, void (const MeshHandle&, bool)); From c515ead27e1a64f146529f6933214be23972c0d5 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Tue, 17 Aug 2021 22:44:41 -0700 Subject: [PATCH 17/53] attempt to fixed mock errors Signed-off-by: Kyle B --- .../Code/Mocks/MockMeshFeatureProcessor.h | 2 +- Gems/Vegetation/Code/Tests/VegetationMocks.h | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h index 75ce42daed..49d615a37f 100644 --- a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h @@ -33,7 +33,7 @@ namespace UnitTest MOCK_CONST_METHOD1(GetLocalAabb, AZ::Aabb(const MeshHandle&)); MOCK_METHOD2(SetSortKey, void (const MeshHandle&, AZ::RHI::DrawItemSortKey)); MOCK_CONST_METHOD1(GetSortKey, AZ::RHI::DrawItemSortKey(const MeshHandle&)); - MOCK_METHOD2(SetMeshLodConfiguration, void(const MeshHandle&, AZ::RPI::Cullable::LodConfiguration)); + MOCK_METHOD2(SetMeshLodConfiguration, void(const MeshHandle&, const AZ::RPI::Cullable::LodConfiguration)); MOCK_CONST_METHOD1(GetMeshLodConfiguration, AZ::RPI::Cullable::LodConfiguration(const MeshHandle&)); MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Render::MaterialAssignmentMap&)); MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Data::Instance&)); diff --git a/Gems/Vegetation/Code/Tests/VegetationMocks.h b/Gems/Vegetation/Code/Tests/VegetationMocks.h index 37bacef21a..cd438335c6 100644 --- a/Gems/Vegetation/Code/Tests/VegetationMocks.h +++ b/Gems/Vegetation/Code/Tests/VegetationMocks.h @@ -554,6 +554,16 @@ namespace UnitTest return m_drawItemSortKeyOutput; } + AZ::RPI::Cullable::LodType m_lodTypeOutput; + void SetLodOverride(AZ::RPI::Cullable::LodType lodType) override + { + m_lodTypeOutput = lodType; + } + AZ::RPI::Cullable::LodType GetLodType() const override + { + return m_lodTypeOutput; + } + AZ::RPI::Cullable::LodOverride m_lodOverrideOutput; void SetLodOverride(AZ::RPI::Cullable::LodOverride lodOverride) override { @@ -563,6 +573,26 @@ namespace UnitTest { return m_lodOverrideOutput; } + + float m_minimumScreenCoverageOutput; + void SetMinimumScreenCoverage(float minimumScreenCoverage) override + { + m_minimumScreenCoverageOutput = minimumScreenCoverage; + } + float GetMinimumScreenCoverage() const override + { + return m_minimumScreenCoverageOutput; + } + + float m_qualityDecayRateOutput; + void SetQualityDecayRate(float qualityDecayRate) override + { + m_qualityDecayRateOutput = qualityDecayRate; + } + float GetQualityDecayRate() const override + { + return m_qualityDecayRateOutput; + } }; struct MockTransformBus From 8064cbcf167dbdac358d823683864d9aea450b79 Mon Sep 17 00:00:00 2001 From: William Hayward Date: Wed, 18 Aug 2021 19:32:30 -0400 Subject: [PATCH 18/53] Update readme Signed-off-by: William Hayward --- README.md | 96 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index a783139eef..af6956c850 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,9 @@ git clone https://github.com/o3de/o3de.git ``` ## Building the Engine -### Build Requirements and redistributables + +### Build requirements and redistributables + #### Windows * Visual Studio 2019 16.9.2 minimum (All versions supported, including Community): [https://visualstudio.microsoft.com/downloads/](https://visualstudio.microsoft.com/downloads/) @@ -49,58 +51,76 @@ git clone https://github.com/o3de/o3de.git * The `LY_WWISE_INSTALL_PATH` CMake cache variable -- this is checked first * The `WWISEROOT` environment variable which is set when installing Wwise SDK -### Quick Start Build Steps +For more details and the latest requirements, refer to [System Requirements](https://o3de.org/docs/welcome-guide/requirements/) in the documentation. -1. Create a writable folder to cache 3rd Party dependencies. You can also use this to store other redistributable SDKs. +### Quick start engine setup + +To build a project-centric source engine, complete the following steps. For other build options, refer to [Setting up O3DE from GitHub](https://o3de.org/docs/welcome-guide/setup/setup-from-github/) in the documentation. + +1. Create a writable folder to cache downloadable packages. You can also use this to store other redistributable SDKs. -1. Install the following redistributables to the following: - - Visual Studio and VC++ redistributable can be installed to any location - - CMake can be installed to any location, as long as it's available in the system path +1. Install the following redistributables: + - Visual Studio and VC++ redistributable can be installed to any location. + - CMake can be installed to any location, as long as it's available in the system path. -1. Configure the source into a solution using this command line, replacing and <3rdParty cache path> to a path you've created: +1. Configure the engine source into a solution using this command line, replacing ``, ``, and `<3rdParty cache path>` with the paths you've created: ``` cmake -B -S -G "Visual Studio 16" -DLY_3RDPARTY_PATH=<3rdParty cache path> -DLY_UNITY_BUILD=ON -DLY_PROJECTS=AutomatedTesting ``` - > Note: Do not use trailing slashes for the <3rdParty cache path> + + Example: + ``` + cmake -B C:\o3de\build\windows_vs2019 -S C:\o3de -G "Visual Studio 16" -DLY_3RDPARTY_PATH=C:\o3de-packages -DLY_UNITY_BUILD=ON + ``` + + > Note: Do not use trailing slashes for the <3rdParty cache path>. 1. Alternatively, you can do this through the CMake GUI: - 1. Start `cmake-gui.exe` - 1. Select the local path of the repo under "Where is the source code" - 1. Select a path where to build binaries under "Where to build the binaries" - 1. Click "Configure" - 1. Wait for the key values to populate. Fill in the fields that are relevant, including `LY_3RDPARTY_PATH` and `LY_PROJECTS` - 1. Click "Generate" + 1. Start `cmake-gui.exe`. + 1. Select the local path of the repo under "Where is the source code". + 1. Select a path where to build binaries under "Where to build the binaries". + 1. Click **Configure**. + 1. Wait for the key values to populate. Fill in the fields that are relevant, including `LY_3RDPARTY_PATH`. + 1. Click **Generate**. -1. The configuration of the solution is complete. To build the Editor and AssetProcessor to binaries, run this command inside your repo: - ``` - cmake --build --target AutomatedTesting.GameLauncher AssetProcessor Editor --config profile -- /m - ``` - -1. This will compile after some time and binaries will be available in the build path you've specified - -### Setting up new projects -1. While still within the repo folder, register the engine with this command: +1. Register the engine with this command: ``` scripts\o3de.bat register --this-engine ``` -1. Setup new projects using the `o3de create-project` command. - ``` - \scripts\o3de.bat create-project --project-path - ``` -1. Register the engine to the project - ``` - \scripts\o3de.bat register --project-path - ``` -1. Once you're ready to build the project, run the same set of commands to configure and build: - ``` - cmake -B -S -G "Visual Studio 16" -DLY_3RDPARTY_PATH=<3rdParty cache path> - cmake --build --target .GameLauncher --config profile -- /m +1. The configuration of the solution is complete. You are now ready to create a project and build the engine. + +For more details, refer to [Setting up O3DE from GitHub](https://o3de.org/docs/welcome-guide/setup/setup-from-github/) in the documentation. + +### Setting up new projects and building the engine + +1. From the O3DE repo folder, set up a new project using the `o3de create-project` command. ``` - -For a tutorial on project configuration, see [Creating Projects Using the Command Line](https://docs.o3de.org/docs/welcome-guide/get-started/project-config/creating-projects-using-cli) in the documentation. + scripts\o3de.bat create-project --project-path + ``` + +1. Configure a solution for your project. + ``` + cmake -B -S -G "Visual Studio 16" -DLY_3RDPARTY_PATH=<3rdParty cache path> -DLY_UNITY_BUILD=ON + ``` + + Example: + ``` + cmake -B C:\my-project\build\windows_vs2019 -S C:\my-project -G "Visual Studio 16" -DLY_3RDPARTY_PATH=C:\o3de-packages -DLY_UNITY_BUILD=ON + ``` + + > Note: Do not use trailing slashes for the <3rdParty cache path>. + +1. Build the project, Asset Processor, and Editor to binaries by running this command inside your project: + ``` + cmake --build --target .GameLauncher Editor --config profile -- /m + ``` + +This will compile after some time and binaries will be available in the project build path you've specified, under `bin/profile`. + +For a complete tutorial on project configuration, see [Creating Projects Using the Command Line Interface](https://o3de.org/docs/welcome-guide/create/creating-projects-using-cli/) in the documentation. ## License -For terms please see the LICENSE*.TXT file at the root of this distribution. +For terms please see the LICENSE*.TXT files at the root of this distribution. From 98f9f9ecbbf718460fefb7836503788e340e6a19 Mon Sep 17 00:00:00 2001 From: lsemp3d <58790905+lsemp3d@users.noreply.github.com> Date: Wed, 18 Aug 2021 17:37:03 -0700 Subject: [PATCH 19/53] Fixed category attribute application on NodeableNodes Signed-off-by: lsemp3d <58790905+lsemp3d@users.noreply.github.com> --- .../ScriptCanvas/AutoGen/ScriptCanvasNodeable_Source.jinja | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasNodeable_Source.jinja b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasNodeable_Source.jinja index 5394ea2355..1c1c2609dd 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasNodeable_Source.jinja +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasNodeable_Source.jinja @@ -197,7 +197,8 @@ void {{attribute_QualifiedName}}::Reflect(AZ::ReflectContext* context) {% if item.attrib['Description'] is defined %} {% set description = item.attrib['Description'] %} {% endif %} - // {{ item.attrib['Name'] }} + + // {{ item.attrib['Name'] }} {{preEdit}}->DataElement({{ uihandler }}, &{{ attribute_Name }}::{{ item.attrib['Name'] }}, "{{ item.attrib['Name'] }}", "{{ description }}"){{postEdit}} {% for EditAttribute in item.iter('EditAttribute') %} {{preEdit}}->Attribute({{ EditAttribute.attrib['Key'] }}, {{ EditAttribute.attrib['Value'] }}){{postEdit}} @@ -272,6 +273,9 @@ void Nodes::{{ nodeableNodeName }}::Reflect(AZ::ReflectContext* context) { {% if ExtendReflectionEdit is defined %}auto {{preEdit}} = {%endif%}editContext->Class<{{ nodeableNodeName }}>("{{ attribute_PreferredClassName }}", "{{ attribute_Description }}"){{postEdit}} {{preEdit}}->ClassElement(AZ::Edit::ClassElements::EditorData, ""){{postEdit}} +{% if attribute_Category is defined %} + {{preEdit}}->Attribute(AZ::Edit::Attribute::Category, "{{ attribute_Category }}") +{% endif %} {{preEdit}}->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly){{postEdit}} {{preEdit}}->Attribute(AZ::Edit::Attributes::AutoExpand, true){{postEdit}} ; From 13f4f3b37a70f82bbce1acbfdeb2ea3dccfcbb4a Mon Sep 17 00:00:00 2001 From: Kyle B Date: Wed, 18 Aug 2021 19:35:51 -0700 Subject: [PATCH 20/53] fixed typo in vegitation mock Signed-off-by: Kyle B --- Gems/Vegetation/Code/Tests/VegetationMocks.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/Vegetation/Code/Tests/VegetationMocks.h b/Gems/Vegetation/Code/Tests/VegetationMocks.h index cd438335c6..ebc51d1b3b 100644 --- a/Gems/Vegetation/Code/Tests/VegetationMocks.h +++ b/Gems/Vegetation/Code/Tests/VegetationMocks.h @@ -555,7 +555,7 @@ namespace UnitTest } AZ::RPI::Cullable::LodType m_lodTypeOutput; - void SetLodOverride(AZ::RPI::Cullable::LodType lodType) override + void SetLodType(AZ::RPI::Cullable::LodType lodType) override { m_lodTypeOutput = lodType; } From aa4aca6c396e778173f8bd2dae747954153c71cb Mon Sep 17 00:00:00 2001 From: William Hayward Date: Thu, 19 Aug 2021 10:32:41 -0400 Subject: [PATCH 21/53] A few more fixes in README.md Signed-off-by: William Hayward --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index af6956c850..57f24d7c83 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ O3DE (Open 3D Engine) is an open-source, real-time, multi-platform 3D engine that enables developers and content creators to build AAA games, cinema-quality 3D worlds, and high-fidelity simulations without any fees or commercial obligations. ## Contribute -For information about contributing to Open 3D Engine, visit https://o3de.org/docs/contributing/ +For information about contributing to Open 3D Engine, visit https://o3de.org/docs/contributing/. ## Download and Install @@ -55,7 +55,7 @@ For more details and the latest requirements, refer to [System Requirements](htt ### Quick start engine setup -To build a project-centric source engine, complete the following steps. For other build options, refer to [Setting up O3DE from GitHub](https://o3de.org/docs/welcome-guide/setup/setup-from-github/) in the documentation. +To set up a project-centric source engine, complete the following steps. For other build options, refer to [Setting up O3DE from GitHub](https://o3de.org/docs/welcome-guide/setup/setup-from-github/) in the documentation. 1. Create a writable folder to cache downloadable packages. You can also use this to store other redistributable SDKs. @@ -65,7 +65,7 @@ To build a project-centric source engine, complete the following steps. For othe 1. Configure the engine source into a solution using this command line, replacing ``, ``, and `<3rdParty cache path>` with the paths you've created: ``` - cmake -B -S -G "Visual Studio 16" -DLY_3RDPARTY_PATH=<3rdParty cache path> -DLY_UNITY_BUILD=ON -DLY_PROJECTS=AutomatedTesting + cmake -B -S -G "Visual Studio 16" -DLY_3RDPARTY_PATH=<3rdParty cache path> -DLY_UNITY_BUILD=ON ``` Example: @@ -91,7 +91,7 @@ To build a project-centric source engine, complete the following steps. For othe 1. The configuration of the solution is complete. You are now ready to create a project and build the engine. -For more details, refer to [Setting up O3DE from GitHub](https://o3de.org/docs/welcome-guide/setup/setup-from-github/) in the documentation. +For more details on the steps above, refer to [Setting up O3DE from GitHub](https://o3de.org/docs/welcome-guide/setup/setup-from-github/) in the documentation. ### Setting up new projects and building the engine From 351ceee3b59eb6f8d21bd5b3c7ce31d3253d93c2 Mon Sep 17 00:00:00 2001 From: William Hayward Date: Thu, 19 Aug 2021 11:19:25 -0400 Subject: [PATCH 22/53] Remove LY_UNITY_BUILD parameter Signed-off-by: William Hayward --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 57f24d7c83..f37fdf6c8b 100644 --- a/README.md +++ b/README.md @@ -65,12 +65,12 @@ To set up a project-centric source engine, complete the following steps. For oth 1. Configure the engine source into a solution using this command line, replacing ``, ``, and `<3rdParty cache path>` with the paths you've created: ``` - cmake -B -S -G "Visual Studio 16" -DLY_3RDPARTY_PATH=<3rdParty cache path> -DLY_UNITY_BUILD=ON + cmake -B -S -G "Visual Studio 16" -DLY_3RDPARTY_PATH=<3rdParty cache path> ``` Example: ``` - cmake -B C:\o3de\build\windows_vs2019 -S C:\o3de -G "Visual Studio 16" -DLY_3RDPARTY_PATH=C:\o3de-packages -DLY_UNITY_BUILD=ON + cmake -B C:\o3de\build\windows_vs2019 -S C:\o3de -G "Visual Studio 16" -DLY_3RDPARTY_PATH=C:\o3de-packages ``` > Note: Do not use trailing slashes for the <3rdParty cache path>. @@ -102,12 +102,12 @@ For more details on the steps above, refer to [Setting up O3DE from GitHub](http 1. Configure a solution for your project. ``` - cmake -B -S -G "Visual Studio 16" -DLY_3RDPARTY_PATH=<3rdParty cache path> -DLY_UNITY_BUILD=ON + cmake -B -S -G "Visual Studio 16" -DLY_3RDPARTY_PATH=<3rdParty cache path> ``` Example: ``` - cmake -B C:\my-project\build\windows_vs2019 -S C:\my-project -G "Visual Studio 16" -DLY_3RDPARTY_PATH=C:\o3de-packages -DLY_UNITY_BUILD=ON + cmake -B C:\my-project\build\windows_vs2019 -S C:\my-project -G "Visual Studio 16" -DLY_3RDPARTY_PATH=C:\o3de-packages ``` > Note: Do not use trailing slashes for the <3rdParty cache path>. @@ -116,6 +116,8 @@ For more details on the steps above, refer to [Setting up O3DE from GitHub](http ``` cmake --build --target .GameLauncher Editor --config profile -- /m ``` + + > Note: Your project name used in the build target is the same as the directory name of your project. This will compile after some time and binaries will be available in the project build path you've specified, under `bin/profile`. From f0d80ea550af4fcdb04c1b00d816606584359665 Mon Sep 17 00:00:00 2001 From: William Hayward Date: Thu, 19 Aug 2021 14:26:36 -0400 Subject: [PATCH 23/53] Refer readers to Wwise Gem docs for requirements and setup Signed-off-by: William Hayward --- README.md | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f37fdf6c8b..37934aa2d0 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,8 @@ git clone https://github.com/o3de/o3de.git ### Build requirements and redistributables +For the latest details and system requirements, refer to [System Requirements](https://o3de.org/docs/welcome-guide/requirements/) in the documentation. + #### Windows * Visual Studio 2019 16.9.2 minimum (All versions supported, including Community): [https://visualstudio.microsoft.com/downloads/](https://visualstudio.microsoft.com/downloads/) @@ -43,15 +45,8 @@ git clone https://github.com/o3de/o3de.git #### Optional -* Wwise version 2021.1.1.7601 minimum: [https://www.audiokinetic.com/download/](https://www.audiokinetic.com/download/) - * Note: This requires registration and installation of a client application to download - * Note: It is generally okay to use a more recent version of Wwise, but some SDK updates will require code changes - * Make sure to select the `SDK(C++)` component during installation of Wwise - * CMake can find the Wwise install location in two ways: - * The `LY_WWISE_INSTALL_PATH` CMake cache variable -- this is checked first - * The `WWISEROOT` environment variable which is set when installing Wwise SDK - -For more details and the latest requirements, refer to [System Requirements](https://o3de.org/docs/welcome-guide/requirements/) in the documentation. +* Wwise audio SDK + * For the latest version requirements and setup instructions, refer to the [Wwise Audio Engine Gem](https://o3de.org/docs/user-guide/gems/reference/audio/wwise/audio-engine-wwise/) reference in the documentation. ### Quick start engine setup From a1edb9e036f1f590cde0a7927901a98fe3312da0 Mon Sep 17 00:00:00 2001 From: santorac <55155825+santorac@users.noreply.github.com> Date: Thu, 19 Aug 2021 11:26:58 -0700 Subject: [PATCH 24/53] Updated build scripts to use new 3rdParty package for RapidJSON. Signed-off-by: santorac <55155825+santorac@users.noreply.github.com> --- cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake | 2 +- cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake | 2 +- cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake | 2 +- cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake | 2 +- cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake b/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake index ab7432e09e..f7ebd26da2 100644 --- a/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake +++ b/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake @@ -8,7 +8,7 @@ # shared by other platforms: ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf) -ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 18b0aef4e6e849389916ff6de6682ab9c591ebe15af6ea6017014453c1119ea1) +ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH e8909dd5b523028831f33cfb257c2db0b1ce7e5fbdd1c95d425968d6f1acefee) ly_associate_package(PACKAGE_NAME RapidXML-1.13-multiplatform TARGETS RapidXML PACKAGE_HASH 510b3c12f8872c54b34733e34f2f69dd21837feafa55bfefa445c98318d96ebf) ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cityhash PACKAGE_HASH 0ace9e6f0b2438c5837510032d2d4109125845c0efd7d807f4561ec905512dd2) ly_associate_package(PACKAGE_NAME lz4-r128-multiplatform TARGETS lz4 PACKAGE_HASH d7b1d5651191db2c339827ad24f669d9d37754143e9173abc986184532f57c9d) diff --git a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake index bb70a54d6f..c9a138d1c6 100644 --- a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake +++ b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake @@ -13,7 +13,7 @@ ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev11-multiplatform ly_associate_package(PACKAGE_NAME squish-ccr-20150601-rev3-multiplatform TARGETS squish-ccr PACKAGE_HASH c878c6c0c705e78403c397d03f5aa7bc87e5978298710e14d09c9daf951a83b3) ly_associate_package(PACKAGE_NAME ASTCEncoder-2017_11_14-rev2-multiplatform TARGETS ASTCEncoder PACKAGE_HASH c240ffc12083ee39a5ce9dc241de44d116e513e1e3e4cc1d05305e7aa3bdc326) ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf) -ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 18b0aef4e6e849389916ff6de6682ab9c591ebe15af6ea6017014453c1119ea1) +ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH e8909dd5b523028831f33cfb257c2db0b1ce7e5fbdd1c95d425968d6f1acefee) ly_associate_package(PACKAGE_NAME RapidXML-1.13-multiplatform TARGETS RapidXML PACKAGE_HASH 510b3c12f8872c54b34733e34f2f69dd21837feafa55bfefa445c98318d96ebf) ly_associate_package(PACKAGE_NAME pybind11-2.4.3-rev2-multiplatform TARGETS pybind11 PACKAGE_HASH d8012f907b6c54ac990b899a0788280857e7c93a9595405a28114b48c354eb1b) ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cityhash PACKAGE_HASH 0ace9e6f0b2438c5837510032d2d4109125845c0efd7d807f4561ec905512dd2) diff --git a/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake b/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake index a0001d3e4e..03cae88fb9 100644 --- a/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake +++ b/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake @@ -13,7 +13,7 @@ ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev11-multiplatform ly_associate_package(PACKAGE_NAME squish-ccr-20150601-rev3-multiplatform TARGETS squish-ccr PACKAGE_HASH c878c6c0c705e78403c397d03f5aa7bc87e5978298710e14d09c9daf951a83b3) ly_associate_package(PACKAGE_NAME ASTCEncoder-2017_11_14-rev2-multiplatform TARGETS ASTCEncoder PACKAGE_HASH c240ffc12083ee39a5ce9dc241de44d116e513e1e3e4cc1d05305e7aa3bdc326) ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf) -ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 18b0aef4e6e849389916ff6de6682ab9c591ebe15af6ea6017014453c1119ea1) +ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH e8909dd5b523028831f33cfb257c2db0b1ce7e5fbdd1c95d425968d6f1acefee) ly_associate_package(PACKAGE_NAME RapidXML-1.13-multiplatform TARGETS RapidXML PACKAGE_HASH 510b3c12f8872c54b34733e34f2f69dd21837feafa55bfefa445c98318d96ebf) ly_associate_package(PACKAGE_NAME pybind11-2.4.3-rev2-multiplatform TARGETS pybind11 PACKAGE_HASH d8012f907b6c54ac990b899a0788280857e7c93a9595405a28114b48c354eb1b) ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cityhash PACKAGE_HASH 0ace9e6f0b2438c5837510032d2d4109125845c0efd7d807f4561ec905512dd2) diff --git a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake index 4ac5fea18c..932e633496 100644 --- a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake +++ b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake @@ -13,7 +13,7 @@ ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev11-multiplatform ly_associate_package(PACKAGE_NAME squish-ccr-20150601-rev3-multiplatform TARGETS squish-ccr PACKAGE_HASH c878c6c0c705e78403c397d03f5aa7bc87e5978298710e14d09c9daf951a83b3) ly_associate_package(PACKAGE_NAME ASTCEncoder-2017_11_14-rev2-multiplatform TARGETS ASTCEncoder PACKAGE_HASH c240ffc12083ee39a5ce9dc241de44d116e513e1e3e4cc1d05305e7aa3bdc326) ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf) -ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 18b0aef4e6e849389916ff6de6682ab9c591ebe15af6ea6017014453c1119ea1) +ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH e8909dd5b523028831f33cfb257c2db0b1ce7e5fbdd1c95d425968d6f1acefee) ly_associate_package(PACKAGE_NAME RapidXML-1.13-multiplatform TARGETS RapidXML PACKAGE_HASH 510b3c12f8872c54b34733e34f2f69dd21837feafa55bfefa445c98318d96ebf) ly_associate_package(PACKAGE_NAME pybind11-2.4.3-rev2-multiplatform TARGETS pybind11 PACKAGE_HASH d8012f907b6c54ac990b899a0788280857e7c93a9595405a28114b48c354eb1b) ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cityhash PACKAGE_HASH 0ace9e6f0b2438c5837510032d2d4109125845c0efd7d807f4561ec905512dd2) diff --git a/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake b/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake index ac7a7427ca..e75c623c66 100644 --- a/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake +++ b/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake @@ -8,7 +8,7 @@ # shared by other platforms: ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf) -ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 18b0aef4e6e849389916ff6de6682ab9c591ebe15af6ea6017014453c1119ea1) +ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH e8909dd5b523028831f33cfb257c2db0b1ce7e5fbdd1c95d425968d6f1acefee) ly_associate_package(PACKAGE_NAME RapidXML-1.13-multiplatform TARGETS RapidXML PACKAGE_HASH 510b3c12f8872c54b34733e34f2f69dd21837feafa55bfefa445c98318d96ebf) ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cityhash PACKAGE_HASH 0ace9e6f0b2438c5837510032d2d4109125845c0efd7d807f4561ec905512dd2) ly_associate_package(PACKAGE_NAME lz4-r128-multiplatform TARGETS lz4 PACKAGE_HASH d7b1d5651191db2c339827ad24f669d9d37754143e9173abc986184532f57c9d) From 1d3f8a5f5583e570c258cc28c90b794dbbbdfbc8 Mon Sep 17 00:00:00 2001 From: santorac <55155825+santorac@users.noreply.github.com> Date: Thu, 19 Aug 2021 11:45:15 -0700 Subject: [PATCH 25/53] Update RapidJSON package hash after adding readme.txt to the package. Signed-off-by: santorac <55155825+santorac@users.noreply.github.com> --- cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake | 2 +- cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake | 2 +- cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake | 2 +- cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake | 2 +- cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake b/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake index f7ebd26da2..fc925e5b2d 100644 --- a/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake +++ b/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake @@ -8,7 +8,7 @@ # shared by other platforms: ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf) -ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH e8909dd5b523028831f33cfb257c2db0b1ce7e5fbdd1c95d425968d6f1acefee) +ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 406369fc962e6f95d3e09bdf2f10f99d9b430ca8b60e90bd273c78f7f974b91a) ly_associate_package(PACKAGE_NAME RapidXML-1.13-multiplatform TARGETS RapidXML PACKAGE_HASH 510b3c12f8872c54b34733e34f2f69dd21837feafa55bfefa445c98318d96ebf) ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cityhash PACKAGE_HASH 0ace9e6f0b2438c5837510032d2d4109125845c0efd7d807f4561ec905512dd2) ly_associate_package(PACKAGE_NAME lz4-r128-multiplatform TARGETS lz4 PACKAGE_HASH d7b1d5651191db2c339827ad24f669d9d37754143e9173abc986184532f57c9d) diff --git a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake index c9a138d1c6..4fd28a3baa 100644 --- a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake +++ b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake @@ -13,7 +13,7 @@ ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev11-multiplatform ly_associate_package(PACKAGE_NAME squish-ccr-20150601-rev3-multiplatform TARGETS squish-ccr PACKAGE_HASH c878c6c0c705e78403c397d03f5aa7bc87e5978298710e14d09c9daf951a83b3) ly_associate_package(PACKAGE_NAME ASTCEncoder-2017_11_14-rev2-multiplatform TARGETS ASTCEncoder PACKAGE_HASH c240ffc12083ee39a5ce9dc241de44d116e513e1e3e4cc1d05305e7aa3bdc326) ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf) -ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH e8909dd5b523028831f33cfb257c2db0b1ce7e5fbdd1c95d425968d6f1acefee) +ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 406369fc962e6f95d3e09bdf2f10f99d9b430ca8b60e90bd273c78f7f974b91a) ly_associate_package(PACKAGE_NAME RapidXML-1.13-multiplatform TARGETS RapidXML PACKAGE_HASH 510b3c12f8872c54b34733e34f2f69dd21837feafa55bfefa445c98318d96ebf) ly_associate_package(PACKAGE_NAME pybind11-2.4.3-rev2-multiplatform TARGETS pybind11 PACKAGE_HASH d8012f907b6c54ac990b899a0788280857e7c93a9595405a28114b48c354eb1b) ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cityhash PACKAGE_HASH 0ace9e6f0b2438c5837510032d2d4109125845c0efd7d807f4561ec905512dd2) diff --git a/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake b/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake index 03cae88fb9..a05215bf81 100644 --- a/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake +++ b/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake @@ -13,7 +13,7 @@ ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev11-multiplatform ly_associate_package(PACKAGE_NAME squish-ccr-20150601-rev3-multiplatform TARGETS squish-ccr PACKAGE_HASH c878c6c0c705e78403c397d03f5aa7bc87e5978298710e14d09c9daf951a83b3) ly_associate_package(PACKAGE_NAME ASTCEncoder-2017_11_14-rev2-multiplatform TARGETS ASTCEncoder PACKAGE_HASH c240ffc12083ee39a5ce9dc241de44d116e513e1e3e4cc1d05305e7aa3bdc326) ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf) -ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH e8909dd5b523028831f33cfb257c2db0b1ce7e5fbdd1c95d425968d6f1acefee) +ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 406369fc962e6f95d3e09bdf2f10f99d9b430ca8b60e90bd273c78f7f974b91a) ly_associate_package(PACKAGE_NAME RapidXML-1.13-multiplatform TARGETS RapidXML PACKAGE_HASH 510b3c12f8872c54b34733e34f2f69dd21837feafa55bfefa445c98318d96ebf) ly_associate_package(PACKAGE_NAME pybind11-2.4.3-rev2-multiplatform TARGETS pybind11 PACKAGE_HASH d8012f907b6c54ac990b899a0788280857e7c93a9595405a28114b48c354eb1b) ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cityhash PACKAGE_HASH 0ace9e6f0b2438c5837510032d2d4109125845c0efd7d807f4561ec905512dd2) diff --git a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake index 932e633496..37577c9f3a 100644 --- a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake +++ b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake @@ -13,7 +13,7 @@ ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev11-multiplatform ly_associate_package(PACKAGE_NAME squish-ccr-20150601-rev3-multiplatform TARGETS squish-ccr PACKAGE_HASH c878c6c0c705e78403c397d03f5aa7bc87e5978298710e14d09c9daf951a83b3) ly_associate_package(PACKAGE_NAME ASTCEncoder-2017_11_14-rev2-multiplatform TARGETS ASTCEncoder PACKAGE_HASH c240ffc12083ee39a5ce9dc241de44d116e513e1e3e4cc1d05305e7aa3bdc326) ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf) -ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH e8909dd5b523028831f33cfb257c2db0b1ce7e5fbdd1c95d425968d6f1acefee) +ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 406369fc962e6f95d3e09bdf2f10f99d9b430ca8b60e90bd273c78f7f974b91a) ly_associate_package(PACKAGE_NAME RapidXML-1.13-multiplatform TARGETS RapidXML PACKAGE_HASH 510b3c12f8872c54b34733e34f2f69dd21837feafa55bfefa445c98318d96ebf) ly_associate_package(PACKAGE_NAME pybind11-2.4.3-rev2-multiplatform TARGETS pybind11 PACKAGE_HASH d8012f907b6c54ac990b899a0788280857e7c93a9595405a28114b48c354eb1b) ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cityhash PACKAGE_HASH 0ace9e6f0b2438c5837510032d2d4109125845c0efd7d807f4561ec905512dd2) diff --git a/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake b/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake index e75c623c66..8e21e08d70 100644 --- a/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake +++ b/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake @@ -8,7 +8,7 @@ # shared by other platforms: ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf) -ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH e8909dd5b523028831f33cfb257c2db0b1ce7e5fbdd1c95d425968d6f1acefee) +ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 406369fc962e6f95d3e09bdf2f10f99d9b430ca8b60e90bd273c78f7f974b91a) ly_associate_package(PACKAGE_NAME RapidXML-1.13-multiplatform TARGETS RapidXML PACKAGE_HASH 510b3c12f8872c54b34733e34f2f69dd21837feafa55bfefa445c98318d96ebf) ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cityhash PACKAGE_HASH 0ace9e6f0b2438c5837510032d2d4109125845c0efd7d807f4561ec905512dd2) ly_associate_package(PACKAGE_NAME lz4-r128-multiplatform TARGETS lz4 PACKAGE_HASH d7b1d5651191db2c339827ad24f669d9d37754143e9173abc986184532f57c9d) From ec7b76c1e94faf0bab1d86fa50d61c41cca8b5b4 Mon Sep 17 00:00:00 2001 From: lsemp3d <58790905+lsemp3d@users.noreply.github.com> Date: Thu, 19 Aug 2021 15:14:52 -0700 Subject: [PATCH 26/53] Fixed typo in previous commit Signed-off-by: lsemp3d <58790905+lsemp3d@users.noreply.github.com> --- .../ScriptCanvas/AutoGen/ScriptCanvasNodeable_Source.jinja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasNodeable_Source.jinja b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasNodeable_Source.jinja index 1c1c2609dd..e099e96f94 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasNodeable_Source.jinja +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasNodeable_Source.jinja @@ -274,7 +274,7 @@ void Nodes::{{ nodeableNodeName }}::Reflect(AZ::ReflectContext* context) {% if ExtendReflectionEdit is defined %}auto {{preEdit}} = {%endif%}editContext->Class<{{ nodeableNodeName }}>("{{ attribute_PreferredClassName }}", "{{ attribute_Description }}"){{postEdit}} {{preEdit}}->ClassElement(AZ::Edit::ClassElements::EditorData, ""){{postEdit}} {% if attribute_Category is defined %} - {{preEdit}}->Attribute(AZ::Edit::Attribute::Category, "{{ attribute_Category }}") + {{preEdit}}->Attribute(AZ::Edit::Attributes::Category, "{{ attribute_Category }}") {% endif %} {{preEdit}}->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly){{postEdit}} {{preEdit}}->Attribute(AZ::Edit::Attributes::AutoExpand, true){{postEdit}} From b5491a4081415238785a86c6ebe5dbdd77006c06 Mon Sep 17 00:00:00 2001 From: William Hayward Date: Thu, 19 Aug 2021 19:09:04 -0400 Subject: [PATCH 27/53] Updates to CMake GUI instructions and other minor edits Signed-off-by: William Hayward --- README.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 37934aa2d0..d466b7a41a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ O3DE (Open 3D Engine) is an open-source, real-time, multi-platform 3D engine that enables developers and content creators to build AAA games, cinema-quality 3D worlds, and high-fidelity simulations without any fees or commercial obligations. ## Contribute -For information about contributing to Open 3D Engine, visit https://o3de.org/docs/contributing/. +For information about contributing to Open 3D Engine, visit [https://o3de.org/docs/contributing/](https://o3de.org/docs/contributing/). ## Download and Install @@ -14,7 +14,7 @@ Verify you have Git LFS installed by running the following command to print the git lfs --version ``` -If Git LFS is not installed, download and run the installer from: https://git-lfs.github.com/. +If Git LFS is not installed, download and run the installer from: [https://git-lfs.github.com/](https://git-lfs.github.com/). ### Install Git LFS hooks ``` @@ -36,12 +36,13 @@ For the latest details and system requirements, refer to [System Requirements](h #### Windows -* Visual Studio 2019 16.9.2 minimum (All versions supported, including Community): [https://visualstudio.microsoft.com/downloads/](https://visualstudio.microsoft.com/downloads/) +* Visual Studio 2019 16.9.2 minimum (All editions supported, including Community): [https://visualstudio.microsoft.com/downloads/](https://visualstudio.microsoft.com/downloads/) + * Check [System Requirements](https://o3de.org/docs/welcome-guide/requirements/) for other supported versions. * Install the following workloads: * Game Development with C++ * MSVC v142 - VS 2019 C++ x64/x86 * C++ 2019 redistributable update -* CMake 3.20 minimum: [https://cmake.org/download/](https://cmake.org/download/) +* CMake 3.20.5 minimum: [https://cmake.org/download/](https://cmake.org/download/) #### Optional @@ -52,15 +53,15 @@ For the latest details and system requirements, refer to [System Requirements](h To set up a project-centric source engine, complete the following steps. For other build options, refer to [Setting up O3DE from GitHub](https://o3de.org/docs/welcome-guide/setup/setup-from-github/) in the documentation. -1. Create a writable folder to cache downloadable packages. You can also use this to store other redistributable SDKs. +1. Create a writable folder to cache downloadable third-party packages. You can also use this to store other redistributable SDKs. 1. Install the following redistributables: - Visual Studio and VC++ redistributable can be installed to any location. - CMake can be installed to any location, as long as it's available in the system path. -1. Configure the engine source into a solution using this command line, replacing ``, ``, and `<3rdParty cache path>` with the paths you've created: +1. Configure the engine source into a solution using this command line, replacing ``, ``, and `<3rdParty package path>` with the paths you've created: ``` - cmake -B -S -G "Visual Studio 16" -DLY_3RDPARTY_PATH=<3rdParty cache path> + cmake -B -S -G "Visual Studio 16" -DLY_3RDPARTY_PATH=<3rdParty package path> ``` Example: @@ -68,15 +69,19 @@ To set up a project-centric source engine, complete the following steps. For oth cmake -B C:\o3de\build\windows_vs2019 -S C:\o3de -G "Visual Studio 16" -DLY_3RDPARTY_PATH=C:\o3de-packages ``` - > Note: Do not use trailing slashes for the <3rdParty cache path>. + > Note: Do not use trailing slashes for the <3rdParty package path>. 1. Alternatively, you can do this through the CMake GUI: 1. Start `cmake-gui.exe`. 1. Select the local path of the repo under "Where is the source code". 1. Select a path where to build binaries under "Where to build the binaries". + 1. Click **Add Entry** and add a cache entry for the <3rdParty package path> folder you created, using the following values: + 1. **Name:** LY_3RDPARTY_PATH + 1. **Type:** STRING + 1. **Value:** `<3rdParty package path>` 1. Click **Configure**. - 1. Wait for the key values to populate. Fill in the fields that are relevant, including `LY_3RDPARTY_PATH`. + 1. Wait for the key values to populate. Fill in any additional fields that are needed for your project. 1. Click **Generate**. 1. Register the engine with this command: From 53ea897371af52ebb02b39b416ee24891a36b2ed Mon Sep 17 00:00:00 2001 From: William Hayward Date: Thu, 19 Aug 2021 19:13:23 -0400 Subject: [PATCH 28/53] Clarify CMake GUI step Signed-off-by: William Hayward --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d466b7a41a..1191a0f0ee 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ To set up a project-centric source engine, complete the following steps. For oth 1. **Type:** STRING 1. **Value:** `<3rdParty package path>` 1. Click **Configure**. - 1. Wait for the key values to populate. Fill in any additional fields that are needed for your project. + 1. Wait for the key values to populate. Update or add any additional fields that are needed for your project. 1. Click **Generate**. 1. Register the engine with this command: From 15af7e692e972995dcc89d0ac2c061389a0c1fc8 Mon Sep 17 00:00:00 2001 From: lsemp3d <58790905+lsemp3d@users.noreply.github.com> Date: Thu, 19 Aug 2021 16:38:19 -0700 Subject: [PATCH 29/53] Removed old codegen tags and documented the only required Nodeable preprocessor definition Signed-off-by: lsemp3d <58790905+lsemp3d@users.noreply.github.com> --- .../ScriptCanvas/CodeGen/NodeableCodegen.h | 363 ++---------------- 1 file changed, 23 insertions(+), 340 deletions(-) diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/CodeGen/NodeableCodegen.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/CodeGen/NodeableCodegen.h index c09386a5a9..3fdcbc0605 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/CodeGen/NodeableCodegen.h +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/CodeGen/NodeableCodegen.h @@ -11,345 +11,28 @@ #include #include + +/* + Any class that implements a nodeable AzAutoGen driver (i.e. *.ScriptCanvasNodeable.xml) + requires that the SCRIPTCANVAS_NODE macro be declared within its class declaration. + + Example: + + class CustomNode + : public ScriptCanvas::Nodeable + { + public: + SCRIPTCANVAS_NODE(CustomNode); + }; + + What will happen is that when AzAutoGen runs it will generate a preprocessor directive: + + SCRIPTCANVAS_NODE_CustomNode + + Which will define all of the node's boilerplate code and definitions. When CustomNode + is compiled, the preprocessor will replace the macro with the auto generated + code. +*/ + #define SCRIPTCANVAS_NODE(ClassName) SCRIPTCANVAS_NODE_##ClassName -/* ---------------------------------------------------------------------------------------------------------- -* -* BaseDefinition -* This tag must be included within the body of any custom nodeable class. It generates nodeable code only and it -* should be used as a base class only. -* -* Note: This tag does not generate a node class, so it will be hidden during edit time. -* -* Example: -* BaseDefinition(BaseHelloWorld, "Base Hello World", "My BaseHelloWorld.") -* -* ----------------------------------------------------------------------------------------------------------- */ -#define BaseDefinition(ClassName, Name, Description, ...) AZ_JOIN(AZ_GENERATED_, ClassName) - -/* ---------------------------------------------------------------------------------------------------------- -* -* NodeDefinition -* This tag must be included within the body of any custom nodeable class. It generates the necessary code to support nodes -* and customizes the serialization and reflection parameters(version, converter). -* -* Example: -* NodeDefinition(HelloWorld, "Hello World", "My HelloWorld Node.") -* NodeDefinition(HelloWorld, "Hello World", "My HelloWorld Node.", -* NodeTags::Icon("Icons/ScriptCanvas/HelloWorld.png") -* NodeTags::Version(3, VersionConverter)) -* -* ----------------------------------------------------------------------------------------------------------- */ -#define NodeDefinition(ClassName, Name, Description, ...) AZ_JOIN(AZ_GENERATED_, ClassName) - -/* ---------------------------------------------------------------------------------------------------------- -* InputMethod -* Using InputMethod on a method will create execution in&out slots that is invoked -* automatically. It will also allow the automatic generation of input or output data -* slots according to the method's signature. -* -* Example -* InputMethod("Do Something", "My DoSomething Function.") -* InputMethod("Do Something", "My DoSomething Function.") -* DataInput(int, "DoSomething:Arg", 0, "My DoSomething argument.") -* -* ----------------------------------------------------------------------------------------------------------- */ -#define InputMethod(Name, Description, ...) - -/* ---------------------------------------------------------------------------------------------------------- -* BranchMethod -* Using BranchMethod on a method will create execution input&output slots that is invoked -* automatically. It will also allow the automatic generation of input data -* slots according to the method's signature. BranchMethod should not be used on method -* having return type. -* -* Coupled with macro ExecutionOutput to generate branch out execution slots. -* -* Example -* BranchMethod("Branches", "My Branches Function.") -* ExecutionOutput("Branch1", "My Branch1 Function.", SlotTags::BranchOf("Branches")) -* ExecutionOutput("Branch2", "My Branch2 Function.", SlotTags::BranchOf("Branches")) -* -* ----------------------------------------------------------------------------------------------------------- */ -#define BranchMethod(Name, Description, ...) - -/* ---------------------------------------------------------------------------------------------------------- -* OnInputChangeMethod -* Using OnInputChangeMethod on a method will create one data input slot that is invoked -* automatically, and it should be used only with one input method. -* -* Example -* OnInputChangeMethod("MyInputChangeMethod", "My OnInputChange Function.") -* DataInput(int, "MyInputChangeMethod:Arg", 0, "My MyInputChangeMethod argument.", SlotTags::DisplayGroup("MyInputChangeMethod")) -* -* ----------------------------------------------------------------------------------------------------------- */ -#define OnInputChangeMethod(Name, Description, ...) - -/* -*---------------------------------------------------------------------------------------------------------- -* -* ExecutionInput -* This is a shorthand macro to easily create an execution input slot. -* -* Examples: -* ExecutionInput("Start Process", "Signals this node to begin processing.") -* -* ---------------------------------------------------------------------------------------------------------- */ -#define ExecutionInput(Name, Description, ...) - -/* -*---------------------------------------------------------------------------------------------------------- -* -* ExecutionOutput -* This is a shorthand macro to easily create an execution output slot. -* -* Examples: -* ExecutionOutput("On Start Process", "Output of start process execution."); -* -* ---------------------------------------------------------------------------------------------------------- */ -#define ExecutionOutput(Name, Description, ...) - -/* -*---------------------------------------------------------------------------------------------------------- -* -* ExecutionLatentOutput -* Similar to ExecutionOutput however it is used to make it explicit that the output slot will be latent, -* this means that the node maintains state and may not signal this slot immediately. -* -* Example: -* ExecutionLatentOutput("On Finished", "Will be signaled when the operation is complete."); -* -* ---------------------------------------------------------------------------------------------------------- */ -#define ExecutionLatentOutput(Name, Description, ...) - -/* -*---------------------------------------------------------------------------------------------------------- -* -* Data -* Provides shorthand for exposing data to serialize context and edit context, -* mainly used with SlotTags::PropertyReference for property data. -* -* Example: -* int m_data = 1; -* PropertyData(int, "My Data", "My Serialized Data.", SlotTags::PropertyReference(m_data)); -* -* ---------------------------------------------------------------------------------------------------------- */ -#define PropertyData(Type, Name, Description, ...) - -/* -*---------------------------------------------------------------------------------------------------------- -* -* DataInput -* Provides shorthand for creating an input data slot. -* -* Coupled with macro InputMethod/BranchMethod/OnInputChangeMethod to give parameter editor definition -* -* Example: -* InputMethod("Do Something", "My DoSomething Function.") -* DataInput(int, "DoSomething:Arg", 0, "My DoSomething argument.") -* -* ---------------------------------------------------------------------------------------------------------- */ -#define DataInput(Type, Name, DefaultVal, Description, ...) - -/* -*---------------------------------------------------------------------------------------------------------- -* -* DataOutput -* Provides shorthand for creating an output data slot. -* -* Coupled with macro InputMethod/BranchMethod/OnInputChangeMethod to give result editor definition -* -* Example: -* InputMethod("Do Something", "My DoSomething Function.") -* DataOutput(int, "DoSomething:Result", 0, "My DoSomething result.") -* -* ---------------------------------------------------------------------------------------------------------- */ -#define DataOutput(Type, Name, Description, ...) - -/* -*---------------------------------------------------------------------------------------------------------- -* -* DynamicValueDataInput -* Provides shorthand for creating an input dynamic value data slot. -* -* Examples: -* DynamicValueDataInput("ValueData", "A generic value data.") -* -* ---------------------------------------------------------------------------------------------------------- */ -#define DynamicValueDataInput(Name, Description, ...) - -/* -*---------------------------------------------------------------------------------------------------------- -* -* DynamicValueDataOutput -* Provides shorthand for creating an output dynamic value data slot. -* -* Examples: -* DynamicValueDataOutput("ValueData", "A generic value data.") -* -* ---------------------------------------------------------------------------------------------------------- */ -#define DynamicValueDataOutput(Name, Description, ...) - -/* -*---------------------------------------------------------------------------------------------------------- -* -* DynamicContainerDataInput -* Provides shorthand for creating an input dynamic container data slot. -* -* Coupled with macro ExecutionInput/ExecutionOutput/ExecutionLatentOutput to generate dynamic data input slot -* -* Examples: -* DynamicContainerDataInput("ContainerData", "A generic container data.") -* -* ---------------------------------------------------------------------------------------------------------- */ -#define DynamicContainerDataInput(Name, Description, ...) - -/* -*---------------------------------------------------------------------------------------------------------- -* -* DynamicContainerDataOutput -* Provides shorthand for creating an output dynamic container data slot. -* -* Coupled with macro ExecutionInput/ExecutionOutput/ExecutionLatentOutput to generate dynamic data output slot -* -* Examples: -* DynamicContainerDataOutput("ContainerData", "A generic container data.") -* -* ---------------------------------------------------------------------------------------------------------- */ -#define DynamicContainerDataOutput(Name, Description, ...) - -/* -*---------------------------------------------------------------------------------------------------------- -* -* DynamicAnyDataInput -* Provides shorthand for creating an input dynamic any data slot. -* -* Coupled with macro ExecutionInput/ExecutionOutput/ExecutionLatentOutput to generate dynamic data input slot -* -* Examples: -* DynamicAnyDataInput("AnyData", "A generic any data.") -* -* ---------------------------------------------------------------------------------------------------------- */ -#define DynamicAnyDataInput(Name, Description, ...) - -/* -*---------------------------------------------------------------------------------------------------------- -* -* DynamicAnyDataOutput -* Provides shorthand for creating an output dynamic any data slot. -* -* Coupled with macro ExecutionInput/ExecutionOutput/ExecutionLatentOutput to generate dynamic data output slot -* -* Examples: -* DynamicAnyDataOutput("AnyData", "A generic any data.") -* -* ---------------------------------------------------------------------------------------------------------- */ -#define DynamicAnyDataOutput(Name, Description, ...) - -// Intellisense helpers, the following definitions exist to provide code completion details regarding what attributes are -// supported by the different tags. - -// Revisited common tags, we should be able to remove NodeableCodegen eventually -namespace NodeableCodegen -{ - namespace ScriptCanvasTags - { - using OverrideName = const char*; - using Uuid = const char*; - using Category = const char*; - using Icon = const char*; - using Deprecated = const char*; - - struct Version - { - using ConverterFunction = bool(class AZ::SerializeContext& context, class AZ::SerializeContext::DataElementNode& classElement); - Version(unsigned int /*version*/) {} - Version(unsigned int /*version*/, ConverterFunction /*converter*/) {} - }; - - template - struct EventHandler - { - EventHandler() = default; - }; - - namespace Edit - { - struct UIHandler - { - UIHandler([[maybe_unused]] const AZ::Crc32& uiHandler = AZ::Edit::UIHandlers::Default) {} - }; - } - - struct EditAttributes - { - template - EditAttributes(Args&& ... args) {} - }; - - struct BaseClass - { - BaseClass(AZStd::initializer_list) {} - }; - - //struct Contracts - //{ - // explicit Contracts(AZStd::initializer_list) {} - //}; - - //struct RestrictedTypeContractTag - //{ - // explicit RestrictedTypeContractTag(AZStd::initializer_list) {} - //}; - - struct SupportsMethodContractTag - { - explicit SupportsMethodContractTag(const char*) {} - }; - } -} - -namespace NodeTags -{ - using NodeableCodegen::ScriptCanvasTags::OverrideName; - using NodeableCodegen::ScriptCanvasTags::Uuid; - using NodeableCodegen::ScriptCanvasTags::Version; - using NodeableCodegen::ScriptCanvasTags::Icon; - using NodeableCodegen::ScriptCanvasTags::EditAttributes; - using NodeableCodegen::ScriptCanvasTags::Category; - using NodeableCodegen::ScriptCanvasTags::Deprecated; - - using GraphEntryPoint = bool; -} - -namespace SlotTags -{ - using NodeableCodegen::ScriptCanvasTags::OverrideName; - //using NodeableCodegen::ScriptCanvasTags::Contracts; - - // Data specific - using DisplayGroup = const char*; - - // PropertyData specific - using PropertyReference = const char*; - using PropertyInterface = const char*; - - // ExecutionSlot specific - using BranchOf = const char*; - - // EditContext specific - using NodeableCodegen::ScriptCanvasTags::EditAttributes; - using NodeableCodegen::ScriptCanvasTags::Edit::UIHandler; - using AzCommon::Attributes::ChangeNotify; - using AzCommon::Attributes::Visibility; - using AzCommon::Attributes::AutoExpand; - using AzCommon::Attributes::DescriptionTextOverride; - using AzCommon::Attributes::NameLabelOverride; - using AzCommon::Attributes::Min; - using AzCommon::Attributes::Max; - - // DynamicData specific - //using NodeableCodegen::ScriptCanvasTags::RestrictedTypeContractTag; - using NodeableCodegen::ScriptCanvasTags::SupportsMethodContractTag; - using DynamicGroup = const char*; -} From dad24fb927eb5c3ab4314f56761c61a789e47567 Mon Sep 17 00:00:00 2001 From: santorac <55155825+santorac@users.noreply.github.com> Date: Thu, 19 Aug 2021 16:56:49 -0700 Subject: [PATCH 30/53] Updated the RapidJSON hashes again due to iteration on my 3p-package-source changes. Signed-off-by: santorac <55155825+santorac@users.noreply.github.com> --- cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake | 2 +- cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake | 2 +- cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake | 2 +- cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake | 2 +- cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake b/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake index fc925e5b2d..4057674382 100644 --- a/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake +++ b/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake @@ -8,7 +8,7 @@ # shared by other platforms: ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf) -ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 406369fc962e6f95d3e09bdf2f10f99d9b430ca8b60e90bd273c78f7f974b91a) +ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 630d0e17e6cddce4dabe9bbd6c9835b7fc58be5e56508e6ef1a21ef191e90136) ly_associate_package(PACKAGE_NAME RapidXML-1.13-multiplatform TARGETS RapidXML PACKAGE_HASH 510b3c12f8872c54b34733e34f2f69dd21837feafa55bfefa445c98318d96ebf) ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cityhash PACKAGE_HASH 0ace9e6f0b2438c5837510032d2d4109125845c0efd7d807f4561ec905512dd2) ly_associate_package(PACKAGE_NAME lz4-r128-multiplatform TARGETS lz4 PACKAGE_HASH d7b1d5651191db2c339827ad24f669d9d37754143e9173abc986184532f57c9d) diff --git a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake index 4fd28a3baa..3dce5aee3a 100644 --- a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake +++ b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake @@ -13,7 +13,7 @@ ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev11-multiplatform ly_associate_package(PACKAGE_NAME squish-ccr-20150601-rev3-multiplatform TARGETS squish-ccr PACKAGE_HASH c878c6c0c705e78403c397d03f5aa7bc87e5978298710e14d09c9daf951a83b3) ly_associate_package(PACKAGE_NAME ASTCEncoder-2017_11_14-rev2-multiplatform TARGETS ASTCEncoder PACKAGE_HASH c240ffc12083ee39a5ce9dc241de44d116e513e1e3e4cc1d05305e7aa3bdc326) ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf) -ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 406369fc962e6f95d3e09bdf2f10f99d9b430ca8b60e90bd273c78f7f974b91a) +ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 630d0e17e6cddce4dabe9bbd6c9835b7fc58be5e56508e6ef1a21ef191e90136) ly_associate_package(PACKAGE_NAME RapidXML-1.13-multiplatform TARGETS RapidXML PACKAGE_HASH 510b3c12f8872c54b34733e34f2f69dd21837feafa55bfefa445c98318d96ebf) ly_associate_package(PACKAGE_NAME pybind11-2.4.3-rev2-multiplatform TARGETS pybind11 PACKAGE_HASH d8012f907b6c54ac990b899a0788280857e7c93a9595405a28114b48c354eb1b) ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cityhash PACKAGE_HASH 0ace9e6f0b2438c5837510032d2d4109125845c0efd7d807f4561ec905512dd2) diff --git a/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake b/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake index a05215bf81..bd7d36b7d1 100644 --- a/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake +++ b/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake @@ -13,7 +13,7 @@ ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev11-multiplatform ly_associate_package(PACKAGE_NAME squish-ccr-20150601-rev3-multiplatform TARGETS squish-ccr PACKAGE_HASH c878c6c0c705e78403c397d03f5aa7bc87e5978298710e14d09c9daf951a83b3) ly_associate_package(PACKAGE_NAME ASTCEncoder-2017_11_14-rev2-multiplatform TARGETS ASTCEncoder PACKAGE_HASH c240ffc12083ee39a5ce9dc241de44d116e513e1e3e4cc1d05305e7aa3bdc326) ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf) -ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 406369fc962e6f95d3e09bdf2f10f99d9b430ca8b60e90bd273c78f7f974b91a) +ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 630d0e17e6cddce4dabe9bbd6c9835b7fc58be5e56508e6ef1a21ef191e90136) ly_associate_package(PACKAGE_NAME RapidXML-1.13-multiplatform TARGETS RapidXML PACKAGE_HASH 510b3c12f8872c54b34733e34f2f69dd21837feafa55bfefa445c98318d96ebf) ly_associate_package(PACKAGE_NAME pybind11-2.4.3-rev2-multiplatform TARGETS pybind11 PACKAGE_HASH d8012f907b6c54ac990b899a0788280857e7c93a9595405a28114b48c354eb1b) ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cityhash PACKAGE_HASH 0ace9e6f0b2438c5837510032d2d4109125845c0efd7d807f4561ec905512dd2) diff --git a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake index 37577c9f3a..e5dbff762b 100644 --- a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake +++ b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake @@ -13,7 +13,7 @@ ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev11-multiplatform ly_associate_package(PACKAGE_NAME squish-ccr-20150601-rev3-multiplatform TARGETS squish-ccr PACKAGE_HASH c878c6c0c705e78403c397d03f5aa7bc87e5978298710e14d09c9daf951a83b3) ly_associate_package(PACKAGE_NAME ASTCEncoder-2017_11_14-rev2-multiplatform TARGETS ASTCEncoder PACKAGE_HASH c240ffc12083ee39a5ce9dc241de44d116e513e1e3e4cc1d05305e7aa3bdc326) ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf) -ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 406369fc962e6f95d3e09bdf2f10f99d9b430ca8b60e90bd273c78f7f974b91a) +ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 630d0e17e6cddce4dabe9bbd6c9835b7fc58be5e56508e6ef1a21ef191e90136) ly_associate_package(PACKAGE_NAME RapidXML-1.13-multiplatform TARGETS RapidXML PACKAGE_HASH 510b3c12f8872c54b34733e34f2f69dd21837feafa55bfefa445c98318d96ebf) ly_associate_package(PACKAGE_NAME pybind11-2.4.3-rev2-multiplatform TARGETS pybind11 PACKAGE_HASH d8012f907b6c54ac990b899a0788280857e7c93a9595405a28114b48c354eb1b) ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cityhash PACKAGE_HASH 0ace9e6f0b2438c5837510032d2d4109125845c0efd7d807f4561ec905512dd2) diff --git a/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake b/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake index 8e21e08d70..c3b2ffdc9e 100644 --- a/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake +++ b/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake @@ -8,7 +8,7 @@ # shared by other platforms: ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf) -ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 406369fc962e6f95d3e09bdf2f10f99d9b430ca8b60e90bd273c78f7f974b91a) +ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 630d0e17e6cddce4dabe9bbd6c9835b7fc58be5e56508e6ef1a21ef191e90136) ly_associate_package(PACKAGE_NAME RapidXML-1.13-multiplatform TARGETS RapidXML PACKAGE_HASH 510b3c12f8872c54b34733e34f2f69dd21837feafa55bfefa445c98318d96ebf) ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cityhash PACKAGE_HASH 0ace9e6f0b2438c5837510032d2d4109125845c0efd7d807f4561ec905512dd2) ly_associate_package(PACKAGE_NAME lz4-r128-multiplatform TARGETS lz4 PACKAGE_HASH d7b1d5651191db2c339827ad24f669d9d37754143e9173abc986184532f57c9d) From fd97a7688cab27d776008cc054db2a581b96b3d3 Mon Sep 17 00:00:00 2001 From: lsemp3d <58790905+lsemp3d@users.noreply.github.com> Date: Thu, 19 Aug 2021 17:02:39 -0700 Subject: [PATCH 31/53] Added missing reflection tag Signed-off-by: lsemp3d <58790905+lsemp3d@users.noreply.github.com> --- .../ScriptCanvas/AutoGen/ScriptCanvasNodeable_Source.jinja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasNodeable_Source.jinja b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasNodeable_Source.jinja index e099e96f94..8bb72bb37f 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasNodeable_Source.jinja +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasNodeable_Source.jinja @@ -274,7 +274,7 @@ void Nodes::{{ nodeableNodeName }}::Reflect(AZ::ReflectContext* context) {% if ExtendReflectionEdit is defined %}auto {{preEdit}} = {%endif%}editContext->Class<{{ nodeableNodeName }}>("{{ attribute_PreferredClassName }}", "{{ attribute_Description }}"){{postEdit}} {{preEdit}}->ClassElement(AZ::Edit::ClassElements::EditorData, ""){{postEdit}} {% if attribute_Category is defined %} - {{preEdit}}->Attribute(AZ::Edit::Attributes::Category, "{{ attribute_Category }}") + {{preEdit}}->Attribute(AZ::Edit::Attributes::Category, "{{ attribute_Category }}"){{postEdit}} {% endif %} {{preEdit}}->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly){{postEdit}} {{preEdit}}->Attribute(AZ::Edit::Attributes::AutoExpand, true){{postEdit}} From 47758ab7a6f3c0867b9d760863417f8a1e8e543f Mon Sep 17 00:00:00 2001 From: santorac <55155825+santorac@users.noreply.github.com> Date: Thu, 19 Aug 2021 17:42:41 -0700 Subject: [PATCH 32/53] Updated RapidJSON package name and hashes. Signed-off-by: santorac <55155825+santorac@users.noreply.github.com> --- cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake | 2 +- cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake | 2 +- cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake | 2 +- cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake | 2 +- cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake b/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake index 4057674382..a65e8b45e4 100644 --- a/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake +++ b/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake @@ -8,7 +8,7 @@ # shared by other platforms: ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf) -ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 630d0e17e6cddce4dabe9bbd6c9835b7fc58be5e56508e6ef1a21ef191e90136) +ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-rev1-multiplatform TARGETS RapidJSON PACKAGE_HASH 2f5e26ecf86c3b7a262753e7da69ac59928e78e9534361f3d00c1ad5879e4023) ly_associate_package(PACKAGE_NAME RapidXML-1.13-multiplatform TARGETS RapidXML PACKAGE_HASH 510b3c12f8872c54b34733e34f2f69dd21837feafa55bfefa445c98318d96ebf) ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cityhash PACKAGE_HASH 0ace9e6f0b2438c5837510032d2d4109125845c0efd7d807f4561ec905512dd2) ly_associate_package(PACKAGE_NAME lz4-r128-multiplatform TARGETS lz4 PACKAGE_HASH d7b1d5651191db2c339827ad24f669d9d37754143e9173abc986184532f57c9d) diff --git a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake index 3dce5aee3a..5e4b85b33e 100644 --- a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake +++ b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake @@ -13,7 +13,7 @@ ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev11-multiplatform ly_associate_package(PACKAGE_NAME squish-ccr-20150601-rev3-multiplatform TARGETS squish-ccr PACKAGE_HASH c878c6c0c705e78403c397d03f5aa7bc87e5978298710e14d09c9daf951a83b3) ly_associate_package(PACKAGE_NAME ASTCEncoder-2017_11_14-rev2-multiplatform TARGETS ASTCEncoder PACKAGE_HASH c240ffc12083ee39a5ce9dc241de44d116e513e1e3e4cc1d05305e7aa3bdc326) ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf) -ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 630d0e17e6cddce4dabe9bbd6c9835b7fc58be5e56508e6ef1a21ef191e90136) +ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-rev1-multiplatform TARGETS RapidJSON PACKAGE_HASH 2f5e26ecf86c3b7a262753e7da69ac59928e78e9534361f3d00c1ad5879e4023) ly_associate_package(PACKAGE_NAME RapidXML-1.13-multiplatform TARGETS RapidXML PACKAGE_HASH 510b3c12f8872c54b34733e34f2f69dd21837feafa55bfefa445c98318d96ebf) ly_associate_package(PACKAGE_NAME pybind11-2.4.3-rev2-multiplatform TARGETS pybind11 PACKAGE_HASH d8012f907b6c54ac990b899a0788280857e7c93a9595405a28114b48c354eb1b) ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cityhash PACKAGE_HASH 0ace9e6f0b2438c5837510032d2d4109125845c0efd7d807f4561ec905512dd2) diff --git a/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake b/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake index bd7d36b7d1..75bd07123a 100644 --- a/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake +++ b/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake @@ -13,7 +13,7 @@ ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev11-multiplatform ly_associate_package(PACKAGE_NAME squish-ccr-20150601-rev3-multiplatform TARGETS squish-ccr PACKAGE_HASH c878c6c0c705e78403c397d03f5aa7bc87e5978298710e14d09c9daf951a83b3) ly_associate_package(PACKAGE_NAME ASTCEncoder-2017_11_14-rev2-multiplatform TARGETS ASTCEncoder PACKAGE_HASH c240ffc12083ee39a5ce9dc241de44d116e513e1e3e4cc1d05305e7aa3bdc326) ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf) -ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 630d0e17e6cddce4dabe9bbd6c9835b7fc58be5e56508e6ef1a21ef191e90136) +ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-rev1-multiplatform TARGETS RapidJSON PACKAGE_HASH 2f5e26ecf86c3b7a262753e7da69ac59928e78e9534361f3d00c1ad5879e4023) ly_associate_package(PACKAGE_NAME RapidXML-1.13-multiplatform TARGETS RapidXML PACKAGE_HASH 510b3c12f8872c54b34733e34f2f69dd21837feafa55bfefa445c98318d96ebf) ly_associate_package(PACKAGE_NAME pybind11-2.4.3-rev2-multiplatform TARGETS pybind11 PACKAGE_HASH d8012f907b6c54ac990b899a0788280857e7c93a9595405a28114b48c354eb1b) ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cityhash PACKAGE_HASH 0ace9e6f0b2438c5837510032d2d4109125845c0efd7d807f4561ec905512dd2) diff --git a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake index e5dbff762b..02111cbb82 100644 --- a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake +++ b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake @@ -13,7 +13,7 @@ ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev11-multiplatform ly_associate_package(PACKAGE_NAME squish-ccr-20150601-rev3-multiplatform TARGETS squish-ccr PACKAGE_HASH c878c6c0c705e78403c397d03f5aa7bc87e5978298710e14d09c9daf951a83b3) ly_associate_package(PACKAGE_NAME ASTCEncoder-2017_11_14-rev2-multiplatform TARGETS ASTCEncoder PACKAGE_HASH c240ffc12083ee39a5ce9dc241de44d116e513e1e3e4cc1d05305e7aa3bdc326) ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf) -ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 630d0e17e6cddce4dabe9bbd6c9835b7fc58be5e56508e6ef1a21ef191e90136) +ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-rev1-multiplatform TARGETS RapidJSON PACKAGE_HASH 2f5e26ecf86c3b7a262753e7da69ac59928e78e9534361f3d00c1ad5879e4023) ly_associate_package(PACKAGE_NAME RapidXML-1.13-multiplatform TARGETS RapidXML PACKAGE_HASH 510b3c12f8872c54b34733e34f2f69dd21837feafa55bfefa445c98318d96ebf) ly_associate_package(PACKAGE_NAME pybind11-2.4.3-rev2-multiplatform TARGETS pybind11 PACKAGE_HASH d8012f907b6c54ac990b899a0788280857e7c93a9595405a28114b48c354eb1b) ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cityhash PACKAGE_HASH 0ace9e6f0b2438c5837510032d2d4109125845c0efd7d807f4561ec905512dd2) diff --git a/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake b/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake index c3b2ffdc9e..c288460dd0 100644 --- a/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake +++ b/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake @@ -8,7 +8,7 @@ # shared by other platforms: ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf) -ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-multiplatform TARGETS RapidJSON PACKAGE_HASH 630d0e17e6cddce4dabe9bbd6c9835b7fc58be5e56508e6ef1a21ef191e90136) +ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-rev1-multiplatform TARGETS RapidJSON PACKAGE_HASH 2f5e26ecf86c3b7a262753e7da69ac59928e78e9534361f3d00c1ad5879e4023) ly_associate_package(PACKAGE_NAME RapidXML-1.13-multiplatform TARGETS RapidXML PACKAGE_HASH 510b3c12f8872c54b34733e34f2f69dd21837feafa55bfefa445c98318d96ebf) ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cityhash PACKAGE_HASH 0ace9e6f0b2438c5837510032d2d4109125845c0efd7d807f4561ec905512dd2) ly_associate_package(PACKAGE_NAME lz4-r128-multiplatform TARGETS lz4 PACKAGE_HASH d7b1d5651191db2c339827ad24f669d9d37754143e9173abc986184532f57c9d) From e410eecd93c5db984cfab09374bfab64df8d1cb2 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Thu, 19 Aug 2021 23:41:30 -0700 Subject: [PATCH 33/53] fixed mesh feature processor abstract interface Signed-off-by: Kyle B --- .../Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h | 6 +++--- .../Atom/Feature/Mesh/MeshFeatureProcessorInterface.h | 4 ++-- .../Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h | 2 +- .../Common/Code/Source/Mesh/MeshFeatureProcessor.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h index a448f7121f..389c5902f9 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h @@ -153,10 +153,10 @@ namespace AZ AZ::Aabb GetLocalAabb(const MeshHandle& meshHandle) const override; void SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey) override; - RHI::DrawItemSortKey GetSortKey(const MeshHandle& meshHandle) override; + RHI::DrawItemSortKey GetSortKey(const MeshHandle& meshHandle) const override; - void SetMeshLodConfiguration(const MeshHandle& meshHandle, const RPI::Cullable::LodConfiguration meshLodConfig); - RPI::Cullable::LodConfiguration GetMeshLodConfiguration(const MeshHandle& meshHandle) const; + void SetMeshLodConfiguration(const MeshHandle& meshHandle, const RPI::Cullable::LodConfiguration& meshLodConfig) override; + RPI::Cullable::LodConfiguration GetMeshLodConfiguration(const MeshHandle& meshHandle) const override; void SetExcludeFromReflectionCubeMaps(const MeshHandle& meshHandle, bool excludeFromReflectionCubeMaps) override; void SetRayTracingEnabled(const MeshHandle& meshHandle, bool rayTracingEnabled) override; diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h index c341cd8854..cffbe5c3c5 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h @@ -93,9 +93,9 @@ namespace AZ //! Sets the sort key for a given mesh handle. virtual void SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey) = 0; //! Gets the sort key for a given mesh handle. - virtual RHI::DrawItemSortKey GetSortKey(const MeshHandle& meshHandle) = 0; + virtual RHI::DrawItemSortKey GetSortKey(const MeshHandle& meshHandle) const = 0; //! Sets LOD mesh configurations to be used in the Mesh Feature Processor - virtual void SetMeshLodConfiguration(const MeshHandle& meshHandle, const RPI::Cullable::LodConfiguration meshLodConfig) = 0; + virtual void SetMeshLodConfiguration(const MeshHandle& meshHandle, const RPI::Cullable::LodConfiguration& meshLodConfig) = 0; //! Gets the LOD mesh configurations being used in the Mesh Feature Processor virtual RPI::Cullable::LodConfiguration GetMeshLodConfiguration(const MeshHandle& meshHandle) const = 0; //! Sets the option to exclude this mesh from baked reflection probe cubemaps diff --git a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h index 49d615a37f..35e399997f 100644 --- a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h @@ -33,7 +33,7 @@ namespace UnitTest MOCK_CONST_METHOD1(GetLocalAabb, AZ::Aabb(const MeshHandle&)); MOCK_METHOD2(SetSortKey, void (const MeshHandle&, AZ::RHI::DrawItemSortKey)); MOCK_CONST_METHOD1(GetSortKey, AZ::RHI::DrawItemSortKey(const MeshHandle&)); - MOCK_METHOD2(SetMeshLodConfiguration, void(const MeshHandle&, const AZ::RPI::Cullable::LodConfiguration)); + MOCK_METHOD2(SetMeshLodConfiguration, void(const MeshHandle&, const AZ::RPI::Cullable::LodConfiguration&)); MOCK_CONST_METHOD1(GetMeshLodConfiguration, AZ::RPI::Cullable::LodConfiguration(const MeshHandle&)); MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Render::MaterialAssignmentMap&)); MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Data::Instance&)); diff --git a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp index e07c7a0309..18b87d0cea 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp @@ -346,7 +346,7 @@ namespace AZ } } - RHI::DrawItemSortKey MeshFeatureProcessor::GetSortKey(const MeshHandle& meshHandle) + RHI::DrawItemSortKey MeshFeatureProcessor::GetSortKey(const MeshHandle& meshHandle) const { if (meshHandle.IsValid()) { @@ -359,7 +359,7 @@ namespace AZ } } - void MeshFeatureProcessor::SetMeshLodConfiguration(const MeshHandle& meshHandle, const RPI::Cullable::LodConfiguration meshLodConfig) + void MeshFeatureProcessor::SetMeshLodConfiguration(const MeshHandle& meshHandle, const RPI::Cullable::LodConfiguration& meshLodConfig) { if (meshHandle.IsValid()) { From 6b23e07af4781de2393367e4c269c53f37ed4889 Mon Sep 17 00:00:00 2001 From: santorac <55155825+santorac@users.noreply.github.com> Date: Fri, 20 Aug 2021 17:22:11 -0700 Subject: [PATCH 34/53] Changed MaterialConverterBus GetMaterialTypePath() to return a string instead of char* Minor code cleanup. Signed-off-by: santorac <55155825+santorac@users.noreply.github.com> --- .../MaterialConverterSystemComponent.cpp | 19 ++++++------------- .../MaterialConverterSystemComponent.h | 2 +- .../RPI.Edit/Material/MaterialConverterBus.h | 4 ++-- .../Model/MaterialAssetBuilderComponent.cpp | 4 ++-- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Source/Material/MaterialConverterSystemComponent.cpp b/Gems/Atom/Feature/Common/Code/Source/Material/MaterialConverterSystemComponent.cpp index d5fdcd9e41..e26a0fb274 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Material/MaterialConverterSystemComponent.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Material/MaterialConverterSystemComponent.cpp @@ -23,12 +23,12 @@ namespace AZ { void MaterialConverterSettings::Reflect(AZ::ReflectContext* context) { - if (auto serializeContext = azrtti_cast(context); serializeContext) + if (auto serializeContext = azrtti_cast(context)) { serializeContext->Class() - ->Version(1) - ->Field("Enable", &MaterialConverterSettings::m_enable) - ->Field("DefaultMaterial", &MaterialConverterSettings::m_defaultMaterial); + ->Version(1) + ->Field("Enable", &MaterialConverterSettings::m_enable) + ->Field("DefaultMaterial", &MaterialConverterSettings::m_defaultMaterial); } } @@ -176,16 +176,9 @@ namespace AZ return true; } - const char* MaterialConverterSystemComponent::GetMaterialTypePath() const + AZStd::string MaterialConverterSystemComponent::GetMaterialTypePath() const { - if (m_settings.m_enable) - { - return "Materials/Types/StandardPBR.materialtype"; - } - else - { - return nullptr; - } + return "Materials/Types/StandardPBR.materialtype"; } AZStd::string MaterialConverterSystemComponent::GetDefaultMaterialPath() const diff --git a/Gems/Atom/Feature/Common/Code/Source/Material/MaterialConverterSystemComponent.h b/Gems/Atom/Feature/Common/Code/Source/Material/MaterialConverterSystemComponent.h index e7e5c63732..7d95024759 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Material/MaterialConverterSystemComponent.h +++ b/Gems/Atom/Feature/Common/Code/Source/Material/MaterialConverterSystemComponent.h @@ -46,7 +46,7 @@ namespace AZ // MaterialConverterBus overrides ... bool IsEnabled() const override; bool ConvertMaterial(const AZ::SceneAPI::DataTypes::IMaterialData& materialData, RPI::MaterialSourceData& out) override; - const char* GetMaterialTypePath() const override; + AZStd::string GetMaterialTypePath() const override; AZStd::string GetDefaultMaterialPath() const override; private: diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Edit/Material/MaterialConverterBus.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Edit/Material/MaterialConverterBus.h index e5aa32c175..8052fc4feb 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Edit/Material/MaterialConverterBus.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Edit/Material/MaterialConverterBus.h @@ -37,8 +37,8 @@ namespace AZ //! @return true if the MaterialSourceData output was populated with converted material data. virtual bool ConvertMaterial(const AZ::SceneAPI::DataTypes::IMaterialData& materialData, MaterialSourceData& out) = 0; - //! Returns the path to the .materialtype file that the converted materials are based on, such as StandardPBR.materialtype, etc. Or nullptr when conversion is disabled. - virtual const char* GetMaterialTypePath() const = 0; + //! Returns the path to the .materialtype file that the converted materials are based on, such as StandardPBR.materialtype, etc. + virtual AZStd::string GetMaterialTypePath() const = 0; //! Returns the path to a .material file to use as the default material when conversion is disabled. virtual AZStd::string GetDefaultMaterialPath() const = 0; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/MaterialAssetBuilderComponent.cpp b/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/MaterialAssetBuilderComponent.cpp index 3eb60956ad..4a4c2156ce 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/MaterialAssetBuilderComponent.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/MaterialAssetBuilderComponent.cpp @@ -75,10 +75,10 @@ namespace AZ RPI::MaterialConverterBus::BroadcastResult(conversionEnabled, &RPI::MaterialConverterBus::Events::IsEnabled); // Right now, scene file importing only supports a single material type, once that changes, this will have to be re-designed, see ATOM-3554 - const char* materialTypePath = nullptr; + AZStd::string materialTypePath; RPI::MaterialConverterBus::BroadcastResult(materialTypePath, &RPI::MaterialConverterBus::Events::GetMaterialTypePath); - if (conversionEnabled && materialTypePath) + if (conversionEnabled && !materialTypePath.empty()) { AssetBuilderSDK::SourceFileDependency materialTypeSource; materialTypeSource.m_sourceFileDependencyPath = materialTypePath; From 8ab9a88683f98e69703857e716ca43a33c7f9431 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Sat, 21 Aug 2021 00:19:07 -0700 Subject: [PATCH 35/53] added cast to version change system lodoverride Signed-off-by: Kyle B --- .../CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index 11ac73d034..b1bfb30285 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -38,7 +38,7 @@ namespace AZ { if (classElement.GetVersion() < 2) { - RPI::Cullable::LodOverride lodOverride = classElement.FindElement(AZ_CRC("LodOverride")); + RPI::Cullable::LodOverride lodOverride = aznumeric_cast(classElement.FindElement(AZ_CRC("LodOverride"))); static constexpr uint8_t old_NoLodOverride = AZStd::numeric_limits ::max(); if (lodOverride == old_NoLodOverride) { From e3a7e7cd30720abb32deef6007a69794f06e0ae8 Mon Sep 17 00:00:00 2001 From: Guthrie Adams Date: Sat, 21 Aug 2021 17:50:31 -0500 Subject: [PATCH 36/53] copied main window class from material editor Signed-off-by: Guthrie Adams --- .../Document/AtomToolsDocumentMainWindow.h | 100 ++++ .../Document/AtomToolsDocumentMainWindow.cpp | 531 ++++++++++++++++++ .../Code/atomtoolsframework_files.cmake | 2 + 3 files changed, 633 insertions(+) create mode 100644 Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h create mode 100644 Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h new file mode 100644 index 0000000000..b7d0cbf8da --- /dev/null +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#pragma once + +#if !defined(Q_MOC_RUN) +#include +#include +#include + +AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT +#include +#include +AZ_POP_DISABLE_WARNING +#endif + +namespace MaterialEditor +{ + /** + * MaterialEditorWindow is the main class. Its responsibility is limited to initializing and connecting + * its panels, managing selection of assets, and performing high-level actions like saving. It contains... + * 1) MaterialBrowser - The user browses for Material (.material) assets. + * 2) MaterialViewport - The user can see the selected Material applied to a model. + * 3) MaterialPropertyInspector - The user edits the properties of the selected Material. + */ + class MaterialEditorWindow + : public AtomToolsFramework::AtomToolsMainWindow + , private AtomToolsFramework::AtomToolsDocumentNotificationBus::Handler + { + Q_OBJECT + public: + AZ_CLASS_ALLOCATOR(MaterialEditorWindow, AZ::SystemAllocator, 0); + + using Base = AtomToolsFramework::AtomToolsMainWindow; + + MaterialEditorWindow(QWidget* parent = 0); + ~MaterialEditorWindow(); + + private: + void ResizeViewportRenderTarget(uint32_t width, uint32_t height) override; + void LockViewportRenderTargetSize(uint32_t width, uint32_t height) override; + void UnlockViewportRenderTargetSize() override; + + // AtomToolsFramework::AtomToolsDocumentNotificationBus::Handler overrides... + void OnDocumentOpened(const AZ::Uuid& documentId) override; + void OnDocumentClosed(const AZ::Uuid& documentId) override; + void OnDocumentModified(const AZ::Uuid& documentId) override; + void OnDocumentUndoStateChanged(const AZ::Uuid& documentId) override; + void OnDocumentSaved(const AZ::Uuid& documentId) override; + + void CreateMenu() override; + void CreateTabBar() override; + + QString GetDocumentPath(const AZ::Uuid& documentId) const; + + void OpenTabContextMenu() override; + + void closeEvent(QCloseEvent* closeEvent) override; + + MaterialViewportWidget* m_materialViewport = nullptr; + MaterialEditorToolBar* m_toolBar = nullptr; + + QMenu* m_menuFile = {}; + QAction* m_actionNew = {}; + QAction* m_actionOpen = {}; + QAction* m_actionOpenRecent = {}; + QAction* m_actionClose = {}; + QAction* m_actionCloseAll = {}; + QAction* m_actionCloseOthers = {}; + QAction* m_actionSave = {}; + QAction* m_actionSaveAsCopy = {}; + QAction* m_actionSaveAsChild = {}; + QAction* m_actionSaveAll = {}; + QAction* m_actionExit = {}; + + QMenu* m_menuEdit = {}; + QAction* m_actionUndo = {}; + QAction* m_actionRedo = {}; + QAction* m_actionSettings = {}; + + QMenu* m_menuView = {}; + QAction* m_actionAssetBrowser = {}; + QAction* m_actionInspector = {}; + QAction* m_actionConsole = {}; + QAction* m_actionPythonTerminal = {}; + QAction* m_actionPerfMonitor = {}; + QAction* m_actionViewportSettings = {}; + QAction* m_actionNextTab = {}; + QAction* m_actionPreviousTab = {}; + + QMenu* m_menuHelp = {}; + QAction* m_actionHelp = {}; + QAction* m_actionAbout = {}; + }; +} // namespace MaterialEditor diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp new file mode 100644 index 0000000000..8922591580 --- /dev/null +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp @@ -0,0 +1,531 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#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 +AZ_POP_DISABLE_WARNING + +namespace MaterialEditor +{ + MaterialEditorWindow::MaterialEditorWindow(QWidget* parent /* = 0 */) + : AtomToolsFramework::AtomToolsMainWindow(parent) + { + resize(1280, 1024); + + // Among other things, we need the window wrapper to save the main window size, position, and state + auto mainWindowWrapper = + new AzQtComponents::WindowDecorationWrapper(AzQtComponents::WindowDecorationWrapper::OptionAutoTitleBarButtons); + mainWindowWrapper->setGuest(this); + mainWindowWrapper->enableSaveRestoreGeometry("O3DE", "MaterialEditor", "mainWindowGeometry"); + + // set the style sheet for RPE highlighting and other styling + AzQtComponents::StyleManager::setStyleSheet(this, QStringLiteral(":/MaterialEditor.qss")); + + QApplication::setWindowIcon(QIcon(":/Icons/materialeditor.svg")); + + AZ::Name apiName = AZ::RHI::Factory::Get().GetName(); + if (!apiName.IsEmpty()) + { + QString title = QString{ "%1 (%2)" }.arg(QApplication::applicationName()).arg(apiName.GetCStr()); + setWindowTitle(title); + } + else + { + AZ_Assert(false, "Render API name not found"); + setWindowTitle(QApplication::applicationName()); + } + + setObjectName("MaterialEditorWindow"); + + m_toolBar = new MaterialEditorToolBar(this); + m_toolBar->setObjectName("ToolBar"); + addToolBar(m_toolBar); + + CreateMenu(); + CreateTabBar(); + + m_materialViewport = new MaterialViewportWidget(centralWidget()); + m_materialViewport->setObjectName("Viewport"); + m_materialViewport->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + centralWidget()->layout()->addWidget(m_materialViewport); + + AddDockWidget("Asset Browser", new MaterialBrowserWidget, Qt::BottomDockWidgetArea, Qt::Vertical); + AddDockWidget("Inspector", new MaterialInspector, Qt::RightDockWidgetArea, Qt::Horizontal); + AddDockWidget("Viewport Settings", new ViewportSettingsInspector, Qt::LeftDockWidgetArea, Qt::Horizontal); + AddDockWidget("Performance Monitor", new PerformanceMonitorWidget, Qt::RightDockWidgetArea, Qt::Horizontal); + AddDockWidget("Python Terminal", new AzToolsFramework::CScriptTermDialog, Qt::BottomDockWidgetArea, Qt::Horizontal); + + SetDockWidgetVisible("Viewport Settings", false); + SetDockWidgetVisible("Performance Monitor", false); + SetDockWidgetVisible("Python Terminal", false); + + // Restore geometry and show the window + mainWindowWrapper->showFromSettings(); + + // Restore additional state for docked windows + auto windowSettings = AZ::UserSettings::CreateFind( + AZ::Crc32("MaterialEditorWindowSettings"), AZ::UserSettings::CT_GLOBAL); + + if (!windowSettings->m_mainWindowState.empty()) + { + QByteArray windowState(windowSettings->m_mainWindowState.data(), static_cast(windowSettings->m_mainWindowState.size())); + m_advancedDockManager->restoreState(windowState); + } + + AtomToolsFramework::AtomToolsDocumentNotificationBus::Handler::BusConnect(); + OnDocumentOpened(AZ::Uuid::CreateNull()); + } + + MaterialEditorWindow::~MaterialEditorWindow() + { + AtomToolsFramework::AtomToolsDocumentNotificationBus::Handler::BusDisconnect(); + } + + + void MaterialEditorWindow::ResizeViewportRenderTarget(uint32_t width, uint32_t height) + { + QSize requestedViewportSize = QSize(width, height) / devicePixelRatioF(); + QSize currentViewportSize = m_materialViewport->size(); + QSize offset = requestedViewportSize - currentViewportSize; + QSize requestedWindowSize = size() + offset; + resize(requestedWindowSize); + + AZ_Assert( + m_materialViewport->size() == requestedViewportSize, + "Resizing the window did not give the expected viewport size. Requested %d x %d but got %d x %d.", + requestedViewportSize.width(), requestedViewportSize.height(), m_materialViewport->size().width(), + m_materialViewport->size().height()); + + QSize newDeviceSize = m_materialViewport->size(); + AZ_Warning( + "Material Editor", static_cast(newDeviceSize.width()) == width && static_cast(newDeviceSize.height()) == height, + "Resizing the window did not give the expected frame size. Requested %d x %d but got %d x %d.", width, height, + newDeviceSize.width(), newDeviceSize.height()); + } + + void MaterialEditorWindow::LockViewportRenderTargetSize(uint32_t width, uint32_t height) + { + m_materialViewport->LockRenderTargetSize(width, height); + } + + void MaterialEditorWindow::UnlockViewportRenderTargetSize() + { + m_materialViewport->UnlockRenderTargetSize(); + } + + void MaterialEditorWindow::closeEvent(QCloseEvent* closeEvent) + { + bool didClose = true; + AtomToolsFramework::AtomToolsDocumentSystemRequestBus::BroadcastResult(didClose, &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseAllDocuments); + if (!didClose) + { + closeEvent->ignore(); + return; + } + + // Capture docking state before shutdown + auto windowSettings = AZ::UserSettings::CreateFind( + AZ::Crc32("MaterialEditorWindowSettings"), AZ::UserSettings::CT_GLOBAL); + + QByteArray windowState = m_advancedDockManager->saveState(); + windowSettings->m_mainWindowState.assign(windowState.begin(), windowState.end()); + + AtomToolsFramework::AtomToolsMainWindowNotificationBus::Broadcast( + &AtomToolsFramework::AtomToolsMainWindowNotifications::OnMainWindowClosing); + } + + void MaterialEditorWindow::OnDocumentOpened(const AZ::Uuid& documentId) + { + bool isOpen = false; + AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(isOpen, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsOpen); + bool isSavable = false; + AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(isSavable, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsSavable); + bool isModified = false; + AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(isModified, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsModified); + bool canUndo = false; + AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(canUndo, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::CanUndo); + bool canRedo = false; + AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(canRedo, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::CanRedo); + AZStd::string absolutePath; + AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::GetAbsolutePath); + AZStd::string filename; + AzFramework::StringFunc::Path::GetFullFileName(absolutePath.c_str(), filename); + + // Update UI to display the new document + if (!documentId.IsNull() && isOpen) + { + // Create a new tab for the document ID and assign it's label to the file name of the document. + AddTabForDocumentId(documentId, filename, absolutePath, [this]{ + // The tab widget requires a dummy page per tab + auto contentWidget = new QWidget(centralWidget()); + contentWidget->setContentsMargins(0, 0, 0, 0); + contentWidget->setFixedSize(0, 0); + return contentWidget; + }); + } + + UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); + + const bool hasTabs = m_tabWidget->count() > 0; + + // Update menu options + m_actionNew->setEnabled(true); + m_actionOpen->setEnabled(true); + m_actionOpenRecent->setEnabled(false); + m_actionClose->setEnabled(hasTabs); + m_actionCloseAll->setEnabled(hasTabs); + m_actionCloseOthers->setEnabled(hasTabs); + + m_actionSave->setEnabled(isOpen && isSavable); + m_actionSaveAsCopy->setEnabled(isOpen && isSavable); + m_actionSaveAsChild->setEnabled(isOpen); + m_actionSaveAll->setEnabled(hasTabs); + + m_actionExit->setEnabled(true); + + m_actionUndo->setEnabled(canUndo); + m_actionRedo->setEnabled(canRedo); + m_actionSettings->setEnabled(true); + + m_actionAssetBrowser->setEnabled(true); + m_actionInspector->setEnabled(true); + m_actionConsole->setEnabled(false); + m_actionPythonTerminal->setEnabled(true); + m_actionPerfMonitor->setEnabled(true); + m_actionViewportSettings->setEnabled(true); + m_actionPreviousTab->setEnabled(m_tabWidget->count() > 1); + m_actionNextTab->setEnabled(m_tabWidget->count() > 1); + + m_actionAbout->setEnabled(false); + + activateWindow(); + raise(); + + const QString documentPath = GetDocumentPath(documentId); + if (!documentPath.isEmpty()) + { + SetStatusMessage(tr("Document opened: %1").arg(documentPath)); + } + } + + void MaterialEditorWindow::OnDocumentClosed(const AZ::Uuid& documentId) + { + RemoveTabForDocumentId(documentId); + SetStatusMessage(tr("Document closed: %1").arg(GetDocumentPath(documentId))); + } + + void MaterialEditorWindow::OnDocumentModified(const AZ::Uuid& documentId) + { + bool isModified = false; + AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(isModified, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsModified); + AZStd::string absolutePath; + AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::GetAbsolutePath); + AZStd::string filename; + AzFramework::StringFunc::Path::GetFullFileName(absolutePath.c_str(), filename); + UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); + } + + void MaterialEditorWindow::OnDocumentUndoStateChanged(const AZ::Uuid& documentId) + { + if (documentId == GetDocumentIdFromTab(m_tabWidget->currentIndex())) + { + bool canUndo = false; + AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(canUndo, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::CanUndo); + bool canRedo = false; + AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(canRedo, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::CanRedo); + m_actionUndo->setEnabled(canUndo); + m_actionRedo->setEnabled(canRedo); + } + } + + void MaterialEditorWindow::OnDocumentSaved(const AZ::Uuid& documentId) + { + bool isModified = false; + AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(isModified, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsModified); + AZStd::string absolutePath; + AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::GetAbsolutePath); + AZStd::string filename; + AzFramework::StringFunc::Path::GetFullFileName(absolutePath.c_str(), filename); + UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); + SetStatusMessage(tr("Document saved: %1").arg(GetDocumentPath(documentId))); + } + + void MaterialEditorWindow::CreateMenu() + { + Base::CreateMenu(); + + // Generating the main menu manually because it's easier and we will have some dynamic or data driven entries + m_menuFile = menuBar()->addMenu("&File"); + + m_actionNew = m_menuFile->addAction("&New...", [this]() { + CreateMaterialDialog createDialog(this); + createDialog.adjustSize(); + + if (createDialog.exec() == QDialog::Accepted && + !createDialog.m_materialFileInfo.absoluteFilePath().isEmpty() && + !createDialog.m_materialTypeFileInfo.absoluteFilePath().isEmpty()) + { + AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CreateDocumentFromFile, + createDialog.m_materialTypeFileInfo.absoluteFilePath().toUtf8().constData(), + createDialog.m_materialFileInfo.absoluteFilePath().toUtf8().constData()); + } + }, QKeySequence::New); + + m_actionOpen = m_menuFile->addAction("&Open...", [this]() { + const AZStd::vector assetTypes = { azrtti_typeid() }; + const AZStd::string filePath = AtomToolsFramework::GetOpenFileInfo(assetTypes).absoluteFilePath().toUtf8().constData(); + if (!filePath.empty()) + { + AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::OpenDocument, filePath); + } + }, QKeySequence::Open); + + m_actionOpenRecent = m_menuFile->addAction("Open &Recent"); + + m_menuFile->addSeparator(); + + m_actionSave = m_menuFile->addAction("&Save", [this]() { + const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); + bool result = false; + AtomToolsFramework::AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::SaveDocument, documentId); + if (!result) + { + SetStatusError(tr("Document save failed: %1").arg(GetDocumentPath(documentId))); + } + }, QKeySequence::Save); + + m_actionSaveAsCopy = m_menuFile->addAction("Save &As...", [this]() { + const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); + const QString documentPath = GetDocumentPath(documentId); + + bool result = false; + AtomToolsFramework::AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::SaveDocumentAsCopy, + documentId, AtomToolsFramework::GetSaveFileInfo(documentPath).absoluteFilePath().toUtf8().constData()); + if (!result) + { + SetStatusError(tr("Document save failed: %1").arg(GetDocumentPath(documentId))); + } + }, QKeySequence::SaveAs); + + m_actionSaveAsChild = m_menuFile->addAction("Save As &Child...", [this]() { + const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); + const QString documentPath = GetDocumentPath(documentId); + + bool result = false; + AtomToolsFramework::AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::SaveDocumentAsChild, + documentId, AtomToolsFramework::GetSaveFileInfo(documentPath).absoluteFilePath().toUtf8().constData()); + if (!result) + { + SetStatusError(tr("Document save failed: %1").arg(GetDocumentPath(documentId))); + } + }); + + m_actionSaveAll = m_menuFile->addAction("Save A&ll", [this]() { + bool result = false; + AtomToolsFramework::AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::SaveAllDocuments); + if (!result) + { + SetStatusError(tr("Document save all failed")); + } + }); + + m_menuFile->addSeparator(); + + m_actionClose = m_menuFile->addAction("&Close", [this]() { + const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); + AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseDocument, documentId); + }, QKeySequence::Close); + + m_actionCloseAll = m_menuFile->addAction("Close All", [this]() { + AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseAllDocuments); + }); + + m_actionCloseOthers = m_menuFile->addAction("Close Others", [this]() { + const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); + AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseAllDocumentsExcept, documentId); + }); + + m_menuFile->addSeparator(); + + m_menuFile->addAction("Run &Python...", [this]() { + const QString script = QFileDialog::getOpenFileName(this, "Run Script", QString(), QString("*.py")); + if (!script.isEmpty()) + { + AzToolsFramework::EditorPythonRunnerRequestBus::Broadcast(&AzToolsFramework::EditorPythonRunnerRequestBus::Events::ExecuteByFilename, script.toUtf8().constData()); + } + }); + + m_menuFile->addSeparator(); + + m_actionExit = m_menuFile->addAction("E&xit", [this]() { + close(); + }, QKeySequence::Quit); + + m_menuEdit = menuBar()->addMenu("&Edit"); + + m_actionUndo = m_menuEdit->addAction("&Undo", [this]() { + const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); + bool result = false; + AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(result, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::Undo); + if (!result) + { + SetStatusError(tr("Document undo failed: %1").arg(GetDocumentPath(documentId))); + } + }, QKeySequence::Undo); + + m_actionRedo = m_menuEdit->addAction("&Redo", [this]() { + const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); + bool result = false; + AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(result, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::Redo); + if (!result) + { + SetStatusError(tr("Document redo failed: %1").arg(GetDocumentPath(documentId))); + } + }, QKeySequence::Redo); + + m_menuEdit->addSeparator(); + + m_actionSettings = m_menuEdit->addAction("&Settings...", [this]() { + SettingsDialog dialog(this); + dialog.exec(); + }, QKeySequence::Preferences); + m_actionSettings->setEnabled(true); + + m_menuView = menuBar()->addMenu("&View"); + + m_actionAssetBrowser = m_menuView->addAction("&Asset Browser", [this]() { + const AZStd::string label = "Asset Browser"; + SetDockWidgetVisible(label, !IsDockWidgetVisible(label)); + }); + + m_actionInspector = m_menuView->addAction("&Inspector", [this]() { + const AZStd::string label = "Inspector"; + SetDockWidgetVisible(label, !IsDockWidgetVisible(label)); + }); + + m_actionConsole = m_menuView->addAction("&Console", [this]() { + }); + + m_actionPythonTerminal = m_menuView->addAction("Python &Terminal", [this]() { + const AZStd::string label = "Python Terminal"; + SetDockWidgetVisible(label, !IsDockWidgetVisible(label)); + }); + + m_actionPerfMonitor = m_menuView->addAction("Performance &Monitor", [this]() { + const AZStd::string label = "Performance Monitor"; + SetDockWidgetVisible(label, !IsDockWidgetVisible(label)); + }); + + m_actionViewportSettings = m_menuView->addAction("Viewport Settings", [this]() { + const AZStd::string label = "Viewport Settings"; + SetDockWidgetVisible(label, !IsDockWidgetVisible(label)); + }); + + m_menuView->addSeparator(); + + m_actionPreviousTab = m_menuView->addAction("&Previous Tab", [this]() { + SelectPreviousTab(); + }, Qt::CTRL | Qt::SHIFT | Qt::Key_Tab); //QKeySequence::PreviousChild is mapped incorrectly in Qt + + m_actionNextTab = m_menuView->addAction("&Next Tab", [this]() { + SelectNextTab(); + }, Qt::CTRL | Qt::Key_Tab); //QKeySequence::NextChild works as expected but mirroring Previous + + m_menuHelp = menuBar()->addMenu("&Help"); + + m_actionHelp = m_menuHelp->addAction("&Help...", [this]() { + HelpDialog dialog(this); + dialog.exec(); + }); + + m_actionAbout = m_menuHelp->addAction("&About...", [this]() { + }); + } + + void MaterialEditorWindow::CreateTabBar() + { + Base::CreateTabBar(); + + // This signal will be triggered whenever a tab is added, removed, selected, clicked, dragged + // When the last tab is removed tabIndex will be -1 and the document ID will be null + // This should automatically clear the active document + connect(m_tabWidget, &QTabWidget::currentChanged, this, [this](int tabIndex) { + const AZ::Uuid documentId = GetDocumentIdFromTab(tabIndex); + AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentOpened, documentId); + }); + + connect(m_tabWidget, &QTabWidget::tabCloseRequested, this, [this](int tabIndex) { + const AZ::Uuid documentId = GetDocumentIdFromTab(tabIndex); + AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseDocument, documentId); + }); + } + + QString MaterialEditorWindow::GetDocumentPath(const AZ::Uuid& documentId) const + { + AZStd::string absolutePath; + AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Handler::GetAbsolutePath); + return absolutePath.c_str(); + } + + void MaterialEditorWindow::OpenTabContextMenu() + { + const QTabBar* tabBar = m_tabWidget->tabBar(); + const QPoint position = tabBar->mapFromGlobal(QCursor::pos()); + const int clickedTabIndex = tabBar->tabAt(position); + const int currentTabIndex = tabBar->currentIndex(); + if (clickedTabIndex >= 0) + { + QMenu tabMenu; + const QString selectActionName = (currentTabIndex == clickedTabIndex) ? "Select in Browser" : "Select"; + tabMenu.addAction(selectActionName, [this, clickedTabIndex]() { + const AZ::Uuid documentId = GetDocumentIdFromTab(clickedTabIndex); + AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentOpened, documentId); + }); + tabMenu.addAction("Close", [this, clickedTabIndex]() { + const AZ::Uuid documentId = GetDocumentIdFromTab(clickedTabIndex); + AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseDocument, documentId); + }); + auto closeOthersAction = tabMenu.addAction("Close Others", [this, clickedTabIndex]() { + const AZ::Uuid documentId = GetDocumentIdFromTab(clickedTabIndex); + AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseAllDocumentsExcept, documentId); + }); + closeOthersAction->setEnabled(tabBar->count() > 1); + tabMenu.exec(QCursor::pos()); + } + } +} // namespace MaterialEditor + +#include diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/atomtoolsframework_files.cmake b/Gems/Atom/Tools/AtomToolsFramework/Code/atomtoolsframework_files.cmake index cd056f5fcf..3d4bb82eec 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/atomtoolsframework_files.cmake +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/atomtoolsframework_files.cmake @@ -12,6 +12,7 @@ set(FILES Include/AtomToolsFramework/Communication/LocalSocket.h Include/AtomToolsFramework/Debug/TraceRecorder.h Include/AtomToolsFramework/Document/AtomToolsDocument.h + Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h Include/AtomToolsFramework/Document/AtomToolsDocumentSystemSettings.h Include/AtomToolsFramework/Document/AtomToolsDocumentSystemRequestBus.h Include/AtomToolsFramework/Document/AtomToolsDocumentNotificationBus.h @@ -38,6 +39,7 @@ set(FILES Source/Communication/LocalSocket.cpp Source/Debug/TraceRecorder.cpp Source/Document/AtomToolsDocument.cpp + Source/Document/AtomToolsDocumentMainWindow.cpp Source/Document/AtomToolsDocumentSystemSettings.cpp Source/Document/AtomToolsDocumentSystemComponent.cpp Source/Document/AtomToolsDocumentSystemComponent.h From 9449b52011c6a155f31a5a16717c27d26440e1f0 Mon Sep 17 00:00:00 2001 From: Guthrie Adams Date: Sun, 22 Aug 2021 14:58:24 -0500 Subject: [PATCH 37/53] getting atom tools document main window compiling Signed-off-by: Guthrie Adams --- .../Document/AtomToolsDocumentMainWindow.h | 45 +-- .../Document/AtomToolsDocumentMainWindow.cpp | 295 +++++------------- 2 files changed, 84 insertions(+), 256 deletions(-) diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h index b7d0cbf8da..1c8f9a1f55 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h @@ -12,41 +12,27 @@ #include #include #include - -AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT -#include -#include -AZ_POP_DISABLE_WARNING #endif -namespace MaterialEditor +namespace AtomToolsFramework { - /** - * MaterialEditorWindow is the main class. Its responsibility is limited to initializing and connecting - * its panels, managing selection of assets, and performing high-level actions like saving. It contains... - * 1) MaterialBrowser - The user browses for Material (.material) assets. - * 2) MaterialViewport - The user can see the selected Material applied to a model. - * 3) MaterialPropertyInspector - The user edits the properties of the selected Material. - */ - class MaterialEditorWindow - : public AtomToolsFramework::AtomToolsMainWindow - , private AtomToolsFramework::AtomToolsDocumentNotificationBus::Handler + //! AtomToolsDocumentMainWindow + class AtomToolsDocumentMainWindow + : public AtomToolsMainWindow + , private AtomToolsDocumentNotificationBus::Handler { Q_OBJECT public: - AZ_CLASS_ALLOCATOR(MaterialEditorWindow, AZ::SystemAllocator, 0); + AZ_CLASS_ALLOCATOR(AtomToolsDocumentMainWindow, AZ::SystemAllocator, 0); - using Base = AtomToolsFramework::AtomToolsMainWindow; + using Base = AtomToolsMainWindow; - MaterialEditorWindow(QWidget* parent = 0); - ~MaterialEditorWindow(); + AtomToolsDocumentMainWindow(QWidget* parent = 0); + ~AtomToolsDocumentMainWindow(); private: - void ResizeViewportRenderTarget(uint32_t width, uint32_t height) override; - void LockViewportRenderTargetSize(uint32_t width, uint32_t height) override; - void UnlockViewportRenderTargetSize() override; - // AtomToolsFramework::AtomToolsDocumentNotificationBus::Handler overrides... + // AtomToolsDocumentNotificationBus::Handler overrides... void OnDocumentOpened(const AZ::Uuid& documentId) override; void OnDocumentClosed(const AZ::Uuid& documentId) override; void OnDocumentModified(const AZ::Uuid& documentId) override; @@ -62,9 +48,6 @@ namespace MaterialEditor void closeEvent(QCloseEvent* closeEvent) override; - MaterialViewportWidget* m_materialViewport = nullptr; - MaterialEditorToolBar* m_toolBar = nullptr; - QMenu* m_menuFile = {}; QAction* m_actionNew = {}; QAction* m_actionOpen = {}; @@ -84,12 +67,6 @@ namespace MaterialEditor QAction* m_actionSettings = {}; QMenu* m_menuView = {}; - QAction* m_actionAssetBrowser = {}; - QAction* m_actionInspector = {}; - QAction* m_actionConsole = {}; - QAction* m_actionPythonTerminal = {}; - QAction* m_actionPerfMonitor = {}; - QAction* m_actionViewportSettings = {}; QAction* m_actionNextTab = {}; QAction* m_actionPreviousTab = {}; @@ -97,4 +74,4 @@ namespace MaterialEditor QAction* m_actionHelp = {}; QAction* m_actionAbout = {}; }; -} // namespace MaterialEditor +} // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp index 8922591580..502f861f0a 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp @@ -6,28 +6,14 @@ * */ -#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 @@ -38,149 +24,48 @@ AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnin #include AZ_POP_DISABLE_WARNING -namespace MaterialEditor +namespace AtomToolsFramework { - MaterialEditorWindow::MaterialEditorWindow(QWidget* parent /* = 0 */) - : AtomToolsFramework::AtomToolsMainWindow(parent) + AtomToolsDocumentMainWindow::AtomToolsDocumentMainWindow(QWidget* parent /* = 0 */) + : AtomToolsMainWindow(parent) { - resize(1280, 1024); + setObjectName("AtomToolsDocumentMainWindow"); - // Among other things, we need the window wrapper to save the main window size, position, and state - auto mainWindowWrapper = - new AzQtComponents::WindowDecorationWrapper(AzQtComponents::WindowDecorationWrapper::OptionAutoTitleBarButtons); - mainWindowWrapper->setGuest(this); - mainWindowWrapper->enableSaveRestoreGeometry("O3DE", "MaterialEditor", "mainWindowGeometry"); - - // set the style sheet for RPE highlighting and other styling - AzQtComponents::StyleManager::setStyleSheet(this, QStringLiteral(":/MaterialEditor.qss")); - - QApplication::setWindowIcon(QIcon(":/Icons/materialeditor.svg")); - - AZ::Name apiName = AZ::RHI::Factory::Get().GetName(); - if (!apiName.IsEmpty()) - { - QString title = QString{ "%1 (%2)" }.arg(QApplication::applicationName()).arg(apiName.GetCStr()); - setWindowTitle(title); - } - else - { - AZ_Assert(false, "Render API name not found"); - setWindowTitle(QApplication::applicationName()); - } - - setObjectName("MaterialEditorWindow"); - - m_toolBar = new MaterialEditorToolBar(this); - m_toolBar->setObjectName("ToolBar"); - addToolBar(m_toolBar); - - CreateMenu(); - CreateTabBar(); - - m_materialViewport = new MaterialViewportWidget(centralWidget()); - m_materialViewport->setObjectName("Viewport"); - m_materialViewport->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - centralWidget()->layout()->addWidget(m_materialViewport); - - AddDockWidget("Asset Browser", new MaterialBrowserWidget, Qt::BottomDockWidgetArea, Qt::Vertical); - AddDockWidget("Inspector", new MaterialInspector, Qt::RightDockWidgetArea, Qt::Horizontal); - AddDockWidget("Viewport Settings", new ViewportSettingsInspector, Qt::LeftDockWidgetArea, Qt::Horizontal); - AddDockWidget("Performance Monitor", new PerformanceMonitorWidget, Qt::RightDockWidgetArea, Qt::Horizontal); - AddDockWidget("Python Terminal", new AzToolsFramework::CScriptTermDialog, Qt::BottomDockWidgetArea, Qt::Horizontal); - - SetDockWidgetVisible("Viewport Settings", false); - SetDockWidgetVisible("Performance Monitor", false); - SetDockWidgetVisible("Python Terminal", false); - - // Restore geometry and show the window - mainWindowWrapper->showFromSettings(); - - // Restore additional state for docked windows - auto windowSettings = AZ::UserSettings::CreateFind( - AZ::Crc32("MaterialEditorWindowSettings"), AZ::UserSettings::CT_GLOBAL); - - if (!windowSettings->m_mainWindowState.empty()) - { - QByteArray windowState(windowSettings->m_mainWindowState.data(), static_cast(windowSettings->m_mainWindowState.size())); - m_advancedDockManager->restoreState(windowState); - } - - AtomToolsFramework::AtomToolsDocumentNotificationBus::Handler::BusConnect(); - OnDocumentOpened(AZ::Uuid::CreateNull()); + AtomToolsDocumentNotificationBus::Handler::BusConnect(); } - MaterialEditorWindow::~MaterialEditorWindow() + AtomToolsDocumentMainWindow::~AtomToolsDocumentMainWindow() { - AtomToolsFramework::AtomToolsDocumentNotificationBus::Handler::BusDisconnect(); + AtomToolsDocumentNotificationBus::Handler::BusDisconnect(); } - - void MaterialEditorWindow::ResizeViewportRenderTarget(uint32_t width, uint32_t height) - { - QSize requestedViewportSize = QSize(width, height) / devicePixelRatioF(); - QSize currentViewportSize = m_materialViewport->size(); - QSize offset = requestedViewportSize - currentViewportSize; - QSize requestedWindowSize = size() + offset; - resize(requestedWindowSize); - - AZ_Assert( - m_materialViewport->size() == requestedViewportSize, - "Resizing the window did not give the expected viewport size. Requested %d x %d but got %d x %d.", - requestedViewportSize.width(), requestedViewportSize.height(), m_materialViewport->size().width(), - m_materialViewport->size().height()); - - QSize newDeviceSize = m_materialViewport->size(); - AZ_Warning( - "Material Editor", static_cast(newDeviceSize.width()) == width && static_cast(newDeviceSize.height()) == height, - "Resizing the window did not give the expected frame size. Requested %d x %d but got %d x %d.", width, height, - newDeviceSize.width(), newDeviceSize.height()); - } - - void MaterialEditorWindow::LockViewportRenderTargetSize(uint32_t width, uint32_t height) - { - m_materialViewport->LockRenderTargetSize(width, height); - } - - void MaterialEditorWindow::UnlockViewportRenderTargetSize() - { - m_materialViewport->UnlockRenderTargetSize(); - } - - void MaterialEditorWindow::closeEvent(QCloseEvent* closeEvent) + void AtomToolsDocumentMainWindow::closeEvent(QCloseEvent* closeEvent) { bool didClose = true; - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::BroadcastResult(didClose, &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseAllDocuments); + AtomToolsDocumentSystemRequestBus::BroadcastResult(didClose, &AtomToolsDocumentSystemRequestBus::Events::CloseAllDocuments); if (!didClose) { closeEvent->ignore(); return; } - // Capture docking state before shutdown - auto windowSettings = AZ::UserSettings::CreateFind( - AZ::Crc32("MaterialEditorWindowSettings"), AZ::UserSettings::CT_GLOBAL); - - QByteArray windowState = m_advancedDockManager->saveState(); - windowSettings->m_mainWindowState.assign(windowState.begin(), windowState.end()); - - AtomToolsFramework::AtomToolsMainWindowNotificationBus::Broadcast( - &AtomToolsFramework::AtomToolsMainWindowNotifications::OnMainWindowClosing); + AtomToolsMainWindowNotificationBus::Broadcast(&AtomToolsMainWindowNotifications::OnMainWindowClosing); } - void MaterialEditorWindow::OnDocumentOpened(const AZ::Uuid& documentId) + void AtomToolsDocumentMainWindow::OnDocumentOpened(const AZ::Uuid& documentId) { bool isOpen = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(isOpen, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsOpen); + AtomToolsDocumentRequestBus::EventResult(isOpen, documentId, &AtomToolsDocumentRequestBus::Events::IsOpen); bool isSavable = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(isSavable, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsSavable); + AtomToolsDocumentRequestBus::EventResult(isSavable, documentId, &AtomToolsDocumentRequestBus::Events::IsSavable); bool isModified = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(isModified, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsModified); + AtomToolsDocumentRequestBus::EventResult(isModified, documentId, &AtomToolsDocumentRequestBus::Events::IsModified); bool canUndo = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(canUndo, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::CanUndo); + AtomToolsDocumentRequestBus::EventResult(canUndo, documentId, &AtomToolsDocumentRequestBus::Events::CanUndo); bool canRedo = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(canRedo, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::CanRedo); + AtomToolsDocumentRequestBus::EventResult(canRedo, documentId, &AtomToolsDocumentRequestBus::Events::CanRedo); AZStd::string absolutePath; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::GetAbsolutePath); + AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsDocumentRequestBus::Events::GetAbsolutePath); AZStd::string filename; AzFramework::StringFunc::Path::GetFullFileName(absolutePath.c_str(), filename); @@ -195,9 +80,9 @@ namespace MaterialEditor contentWidget->setFixedSize(0, 0); return contentWidget; }); - } - UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); + UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); + } const bool hasTabs = m_tabWidget->count() > 0; @@ -220,12 +105,6 @@ namespace MaterialEditor m_actionRedo->setEnabled(canRedo); m_actionSettings->setEnabled(true); - m_actionAssetBrowser->setEnabled(true); - m_actionInspector->setEnabled(true); - m_actionConsole->setEnabled(false); - m_actionPythonTerminal->setEnabled(true); - m_actionPerfMonitor->setEnabled(true); - m_actionViewportSettings->setEnabled(true); m_actionPreviousTab->setEnabled(m_tabWidget->count() > 1); m_actionNextTab->setEnabled(m_tabWidget->count() > 1); @@ -241,49 +120,49 @@ namespace MaterialEditor } } - void MaterialEditorWindow::OnDocumentClosed(const AZ::Uuid& documentId) + void AtomToolsDocumentMainWindow::OnDocumentClosed(const AZ::Uuid& documentId) { RemoveTabForDocumentId(documentId); SetStatusMessage(tr("Document closed: %1").arg(GetDocumentPath(documentId))); } - void MaterialEditorWindow::OnDocumentModified(const AZ::Uuid& documentId) + void AtomToolsDocumentMainWindow::OnDocumentModified(const AZ::Uuid& documentId) { bool isModified = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(isModified, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsModified); + AtomToolsDocumentRequestBus::EventResult(isModified, documentId, &AtomToolsDocumentRequestBus::Events::IsModified); AZStd::string absolutePath; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::GetAbsolutePath); + AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsDocumentRequestBus::Events::GetAbsolutePath); AZStd::string filename; AzFramework::StringFunc::Path::GetFullFileName(absolutePath.c_str(), filename); UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); } - void MaterialEditorWindow::OnDocumentUndoStateChanged(const AZ::Uuid& documentId) + void AtomToolsDocumentMainWindow::OnDocumentUndoStateChanged(const AZ::Uuid& documentId) { if (documentId == GetDocumentIdFromTab(m_tabWidget->currentIndex())) { bool canUndo = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(canUndo, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::CanUndo); + AtomToolsDocumentRequestBus::EventResult(canUndo, documentId, &AtomToolsDocumentRequestBus::Events::CanUndo); bool canRedo = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(canRedo, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::CanRedo); + AtomToolsDocumentRequestBus::EventResult(canRedo, documentId, &AtomToolsDocumentRequestBus::Events::CanRedo); m_actionUndo->setEnabled(canUndo); m_actionRedo->setEnabled(canRedo); } } - void MaterialEditorWindow::OnDocumentSaved(const AZ::Uuid& documentId) + void AtomToolsDocumentMainWindow::OnDocumentSaved(const AZ::Uuid& documentId) { bool isModified = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(isModified, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsModified); + AtomToolsDocumentRequestBus::EventResult(isModified, documentId, &AtomToolsDocumentRequestBus::Events::IsModified); AZStd::string absolutePath; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::GetAbsolutePath); + AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsDocumentRequestBus::Events::GetAbsolutePath); AZStd::string filename; AzFramework::StringFunc::Path::GetFullFileName(absolutePath.c_str(), filename); UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); SetStatusMessage(tr("Document saved: %1").arg(GetDocumentPath(documentId))); } - void MaterialEditorWindow::CreateMenu() + void AtomToolsDocumentMainWindow::CreateMenu() { Base::CreateMenu(); @@ -291,26 +170,26 @@ namespace MaterialEditor m_menuFile = menuBar()->addMenu("&File"); m_actionNew = m_menuFile->addAction("&New...", [this]() { - CreateMaterialDialog createDialog(this); - createDialog.adjustSize(); + //CreateMaterialDialog createDialog(this); + //createDialog.adjustSize(); - if (createDialog.exec() == QDialog::Accepted && - !createDialog.m_materialFileInfo.absoluteFilePath().isEmpty() && - !createDialog.m_materialTypeFileInfo.absoluteFilePath().isEmpty()) - { - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CreateDocumentFromFile, - createDialog.m_materialTypeFileInfo.absoluteFilePath().toUtf8().constData(), - createDialog.m_materialFileInfo.absoluteFilePath().toUtf8().constData()); - } + //if (createDialog.exec() == QDialog::Accepted && + // !createDialog.m_materialFileInfo.absoluteFilePath().isEmpty() && + // !createDialog.m_materialTypeFileInfo.absoluteFilePath().isEmpty()) + //{ + // AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::CreateDocumentFromFile, + // createDialog.m_materialTypeFileInfo.absoluteFilePath().toUtf8().constData(), + // createDialog.m_materialFileInfo.absoluteFilePath().toUtf8().constData()); + //} }, QKeySequence::New); m_actionOpen = m_menuFile->addAction("&Open...", [this]() { - const AZStd::vector assetTypes = { azrtti_typeid() }; - const AZStd::string filePath = AtomToolsFramework::GetOpenFileInfo(assetTypes).absoluteFilePath().toUtf8().constData(); - if (!filePath.empty()) - { - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::OpenDocument, filePath); - } + //const AZStd::vector assetTypes = { azrtti_typeid() }; + //const AZStd::string filePath = GetOpenFileInfo(assetTypes).absoluteFilePath().toUtf8().constData(); + //if (!filePath.empty()) + //{ + // AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::OpenDocument, filePath); + //} }, QKeySequence::Open); m_actionOpenRecent = m_menuFile->addAction("Open &Recent"); @@ -320,7 +199,7 @@ namespace MaterialEditor m_actionSave = m_menuFile->addAction("&Save", [this]() { const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); bool result = false; - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::SaveDocument, documentId); + AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsDocumentSystemRequestBus::Events::SaveDocument, documentId); if (!result) { SetStatusError(tr("Document save failed: %1").arg(GetDocumentPath(documentId))); @@ -332,8 +211,8 @@ namespace MaterialEditor const QString documentPath = GetDocumentPath(documentId); bool result = false; - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::SaveDocumentAsCopy, - documentId, AtomToolsFramework::GetSaveFileInfo(documentPath).absoluteFilePath().toUtf8().constData()); + AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsDocumentSystemRequestBus::Events::SaveDocumentAsCopy, + documentId, GetSaveFileInfo(documentPath).absoluteFilePath().toUtf8().constData()); if (!result) { SetStatusError(tr("Document save failed: %1").arg(GetDocumentPath(documentId))); @@ -345,8 +224,8 @@ namespace MaterialEditor const QString documentPath = GetDocumentPath(documentId); bool result = false; - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::SaveDocumentAsChild, - documentId, AtomToolsFramework::GetSaveFileInfo(documentPath).absoluteFilePath().toUtf8().constData()); + AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsDocumentSystemRequestBus::Events::SaveDocumentAsChild, + documentId, GetSaveFileInfo(documentPath).absoluteFilePath().toUtf8().constData()); if (!result) { SetStatusError(tr("Document save failed: %1").arg(GetDocumentPath(documentId))); @@ -355,7 +234,7 @@ namespace MaterialEditor m_actionSaveAll = m_menuFile->addAction("Save A&ll", [this]() { bool result = false; - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::SaveAllDocuments); + AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsDocumentSystemRequestBus::Events::SaveAllDocuments); if (!result) { SetStatusError(tr("Document save all failed")); @@ -366,16 +245,16 @@ namespace MaterialEditor m_actionClose = m_menuFile->addAction("&Close", [this]() { const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseDocument, documentId); + AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::CloseDocument, documentId); }, QKeySequence::Close); m_actionCloseAll = m_menuFile->addAction("Close All", [this]() { - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseAllDocuments); + AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::CloseAllDocuments); }); m_actionCloseOthers = m_menuFile->addAction("Close Others", [this]() { const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseAllDocumentsExcept, documentId); + AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::CloseAllDocumentsExcept, documentId); }); m_menuFile->addSeparator(); @@ -399,7 +278,7 @@ namespace MaterialEditor m_actionUndo = m_menuEdit->addAction("&Undo", [this]() { const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); bool result = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(result, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::Undo); + AtomToolsDocumentRequestBus::EventResult(result, documentId, &AtomToolsDocumentRequestBus::Events::Undo); if (!result) { SetStatusError(tr("Document undo failed: %1").arg(GetDocumentPath(documentId))); @@ -409,7 +288,7 @@ namespace MaterialEditor m_actionRedo = m_menuEdit->addAction("&Redo", [this]() { const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); bool result = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(result, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::Redo); + AtomToolsDocumentRequestBus::EventResult(result, documentId, &AtomToolsDocumentRequestBus::Events::Redo); if (!result) { SetStatusError(tr("Document redo failed: %1").arg(GetDocumentPath(documentId))); @@ -419,41 +298,13 @@ namespace MaterialEditor m_menuEdit->addSeparator(); m_actionSettings = m_menuEdit->addAction("&Settings...", [this]() { - SettingsDialog dialog(this); - dialog.exec(); + //SettingsDialog dialog(this); + //dialog.exec(); }, QKeySequence::Preferences); m_actionSettings->setEnabled(true); m_menuView = menuBar()->addMenu("&View"); - m_actionAssetBrowser = m_menuView->addAction("&Asset Browser", [this]() { - const AZStd::string label = "Asset Browser"; - SetDockWidgetVisible(label, !IsDockWidgetVisible(label)); - }); - - m_actionInspector = m_menuView->addAction("&Inspector", [this]() { - const AZStd::string label = "Inspector"; - SetDockWidgetVisible(label, !IsDockWidgetVisible(label)); - }); - - m_actionConsole = m_menuView->addAction("&Console", [this]() { - }); - - m_actionPythonTerminal = m_menuView->addAction("Python &Terminal", [this]() { - const AZStd::string label = "Python Terminal"; - SetDockWidgetVisible(label, !IsDockWidgetVisible(label)); - }); - - m_actionPerfMonitor = m_menuView->addAction("Performance &Monitor", [this]() { - const AZStd::string label = "Performance Monitor"; - SetDockWidgetVisible(label, !IsDockWidgetVisible(label)); - }); - - m_actionViewportSettings = m_menuView->addAction("Viewport Settings", [this]() { - const AZStd::string label = "Viewport Settings"; - SetDockWidgetVisible(label, !IsDockWidgetVisible(label)); - }); - m_menuView->addSeparator(); m_actionPreviousTab = m_menuView->addAction("&Previous Tab", [this]() { @@ -467,15 +318,15 @@ namespace MaterialEditor m_menuHelp = menuBar()->addMenu("&Help"); m_actionHelp = m_menuHelp->addAction("&Help...", [this]() { - HelpDialog dialog(this); - dialog.exec(); + //HelpDialog dialog(this); + //dialog.exec(); }); m_actionAbout = m_menuHelp->addAction("&About...", [this]() { }); } - void MaterialEditorWindow::CreateTabBar() + void AtomToolsDocumentMainWindow::CreateTabBar() { Base::CreateTabBar(); @@ -484,23 +335,23 @@ namespace MaterialEditor // This should automatically clear the active document connect(m_tabWidget, &QTabWidget::currentChanged, this, [this](int tabIndex) { const AZ::Uuid documentId = GetDocumentIdFromTab(tabIndex); - AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentOpened, documentId); + AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsDocumentNotificationBus::Events::OnDocumentOpened, documentId); }); connect(m_tabWidget, &QTabWidget::tabCloseRequested, this, [this](int tabIndex) { const AZ::Uuid documentId = GetDocumentIdFromTab(tabIndex); - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseDocument, documentId); + AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::CloseDocument, documentId); }); } - QString MaterialEditorWindow::GetDocumentPath(const AZ::Uuid& documentId) const + QString AtomToolsDocumentMainWindow::GetDocumentPath(const AZ::Uuid& documentId) const { AZStd::string absolutePath; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Handler::GetAbsolutePath); + AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsDocumentRequestBus::Handler::GetAbsolutePath); return absolutePath.c_str(); } - void MaterialEditorWindow::OpenTabContextMenu() + void AtomToolsDocumentMainWindow::OpenTabContextMenu() { const QTabBar* tabBar = m_tabWidget->tabBar(); const QPoint position = tabBar->mapFromGlobal(QCursor::pos()); @@ -512,20 +363,20 @@ namespace MaterialEditor const QString selectActionName = (currentTabIndex == clickedTabIndex) ? "Select in Browser" : "Select"; tabMenu.addAction(selectActionName, [this, clickedTabIndex]() { const AZ::Uuid documentId = GetDocumentIdFromTab(clickedTabIndex); - AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentOpened, documentId); + AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsDocumentNotificationBus::Events::OnDocumentOpened, documentId); }); tabMenu.addAction("Close", [this, clickedTabIndex]() { const AZ::Uuid documentId = GetDocumentIdFromTab(clickedTabIndex); - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseDocument, documentId); + AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::CloseDocument, documentId); }); auto closeOthersAction = tabMenu.addAction("Close Others", [this, clickedTabIndex]() { const AZ::Uuid documentId = GetDocumentIdFromTab(clickedTabIndex); - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseAllDocumentsExcept, documentId); + AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::CloseAllDocumentsExcept, documentId); }); closeOthersAction->setEnabled(tabBar->count() > 1); tabMenu.exec(QCursor::pos()); } } -} // namespace MaterialEditor +} // namespace AtomToolsFramework -#include +//#include From 62a5c9061622fdce7dbaf799c65c90137153f94f Mon Sep 17 00:00:00 2001 From: Guthrie Adams Date: Sun, 22 Aug 2021 18:02:22 -0500 Subject: [PATCH 38/53] moving document related code from AtomToolsMainWindow to AtomToolsDocumentMainWindow adding virtual function stubs to customize actions Signed-off-by: Guthrie Adams --- .../Document/AtomToolsDocumentMainWindow.h | 39 +- .../Window/AtomToolsMainWindow.h | 21 +- .../Document/AtomToolsDocumentMainWindow.cpp | 447 ++++++++++++------ .../Source/Window/AtomToolsMainWindow.cpp | 144 +----- 4 files changed, 332 insertions(+), 319 deletions(-) diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h index 1c8f9a1f55..6beae2a69c 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h @@ -12,6 +12,7 @@ #include #include #include +#include #endif namespace AtomToolsFramework @@ -30,7 +31,35 @@ namespace AtomToolsFramework AtomToolsDocumentMainWindow(QWidget* parent = 0); ~AtomToolsDocumentMainWindow(); - private: + protected: + void AddDocumentMenus(); + void AddDocumentTabBar(); + + QString GetDocumentPath(const AZ::Uuid& documentId) const; + + AZ::Uuid GetDocumentIdFromTab(const int tabIndex) const; + + void AddTabForDocumentId( + const AZ::Uuid& documentId, + const AZStd::string& label, + const AZStd::string& toolTip); + + void RemoveTabForDocumentId(const AZ::Uuid& documentId); + + void UpdateTabForDocumentId( + const AZ::Uuid& documentId, const AZStd::string& label, const AZStd::string& toolTip, bool isModified); + + void SelectPreviousTab(); + + void SelectNextTab(); + + virtual void OpenTabContextMenu() const; + virtual bool GetCreateFileInfo(AZStd::string& openPath, AZStd::string& savePath) const; + virtual bool GetOpenFileInfo(AZStd::string& openPath) const; + virtual QWidget* CreateViewForDocumemt(const AZ::Uuid& documentId) const; + virtual void OpenSettings() const; + virtual void OpenHelp() const; + virtual void OpenAbout() const; // AtomToolsDocumentNotificationBus::Handler overrides... void OnDocumentOpened(const AZ::Uuid& documentId) override; @@ -39,13 +68,6 @@ namespace AtomToolsFramework void OnDocumentUndoStateChanged(const AZ::Uuid& documentId) override; void OnDocumentSaved(const AZ::Uuid& documentId) override; - void CreateMenu() override; - void CreateTabBar() override; - - QString GetDocumentPath(const AZ::Uuid& documentId) const; - - void OpenTabContextMenu() override; - void closeEvent(QCloseEvent* closeEvent) override; QMenu* m_menuFile = {}; @@ -73,5 +95,6 @@ namespace AtomToolsFramework QMenu* m_menuHelp = {}; QAction* m_actionHelp = {}; QAction* m_actionAbout = {}; + AzQtComponents::TabWidget* m_tabWidget = {}; }; } // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Window/AtomToolsMainWindow.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Window/AtomToolsMainWindow.h index 2a304c9a8c..c5b47fe7a4 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Window/AtomToolsMainWindow.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Window/AtomToolsMainWindow.h @@ -7,18 +7,14 @@ */ #pragma once + #include - #include - #include #include #include -#include #include -#include -#include namespace AtomToolsFramework { @@ -38,26 +34,11 @@ namespace AtomToolsFramework bool IsDockWidgetVisible(const AZStd::string& name) const override; AZStd::vector GetDockWidgetNames() const override; - virtual void CreateMenu(); - virtual void CreateTabBar(); - - virtual void AddTabForDocumentId( - const AZ::Uuid& documentId, const AZStd::string& label, const AZStd::string& toolTip, AZStd::function widgetCreator); - virtual void RemoveTabForDocumentId(const AZ::Uuid& documentId); - virtual void UpdateTabForDocumentId( - const AZ::Uuid& documentId, const AZStd::string& label, const AZStd::string& toolTip, bool isModified); - virtual AZ::Uuid GetDocumentIdFromTab(const int tabIndex) const; - - virtual void OpenTabContextMenu(); - virtual void SelectPreviousTab(); - virtual void SelectNextTab(); - void SetStatusMessage(const QString& message); void SetStatusWarning(const QString& message); void SetStatusError(const QString& message); AzQtComponents::FancyDocking* m_advancedDockManager = nullptr; - AzQtComponents::TabWidget* m_tabWidget = nullptr; QLabel* m_statusMessage = nullptr; AZStd::unordered_map m_dockWidgets; diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp index 502f861f0a..a35b65461a 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp @@ -21,6 +21,9 @@ AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnin #include #include #include +#include +#include +#include #include AZ_POP_DISABLE_WARNING @@ -30,7 +33,8 @@ namespace AtomToolsFramework : AtomToolsMainWindow(parent) { setObjectName("AtomToolsDocumentMainWindow"); - + AddDocumentMenus(); + AddDocumentTabBar(); AtomToolsDocumentNotificationBus::Handler::BusConnect(); } @@ -39,157 +43,27 @@ namespace AtomToolsFramework AtomToolsDocumentNotificationBus::Handler::BusDisconnect(); } - void AtomToolsDocumentMainWindow::closeEvent(QCloseEvent* closeEvent) + void AtomToolsDocumentMainWindow::AddDocumentMenus() { - bool didClose = true; - AtomToolsDocumentSystemRequestBus::BroadcastResult(didClose, &AtomToolsDocumentSystemRequestBus::Events::CloseAllDocuments); - if (!didClose) - { - closeEvent->ignore(); - return; - } - - AtomToolsMainWindowNotificationBus::Broadcast(&AtomToolsMainWindowNotifications::OnMainWindowClosing); - } - - void AtomToolsDocumentMainWindow::OnDocumentOpened(const AZ::Uuid& documentId) - { - bool isOpen = false; - AtomToolsDocumentRequestBus::EventResult(isOpen, documentId, &AtomToolsDocumentRequestBus::Events::IsOpen); - bool isSavable = false; - AtomToolsDocumentRequestBus::EventResult(isSavable, documentId, &AtomToolsDocumentRequestBus::Events::IsSavable); - bool isModified = false; - AtomToolsDocumentRequestBus::EventResult(isModified, documentId, &AtomToolsDocumentRequestBus::Events::IsModified); - bool canUndo = false; - AtomToolsDocumentRequestBus::EventResult(canUndo, documentId, &AtomToolsDocumentRequestBus::Events::CanUndo); - bool canRedo = false; - AtomToolsDocumentRequestBus::EventResult(canRedo, documentId, &AtomToolsDocumentRequestBus::Events::CanRedo); - AZStd::string absolutePath; - AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsDocumentRequestBus::Events::GetAbsolutePath); - AZStd::string filename; - AzFramework::StringFunc::Path::GetFullFileName(absolutePath.c_str(), filename); - - // Update UI to display the new document - if (!documentId.IsNull() && isOpen) - { - // Create a new tab for the document ID and assign it's label to the file name of the document. - AddTabForDocumentId(documentId, filename, absolutePath, [this]{ - // The tab widget requires a dummy page per tab - auto contentWidget = new QWidget(centralWidget()); - contentWidget->setContentsMargins(0, 0, 0, 0); - contentWidget->setFixedSize(0, 0); - return contentWidget; - }); - - UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); - } - - const bool hasTabs = m_tabWidget->count() > 0; - - // Update menu options - m_actionNew->setEnabled(true); - m_actionOpen->setEnabled(true); - m_actionOpenRecent->setEnabled(false); - m_actionClose->setEnabled(hasTabs); - m_actionCloseAll->setEnabled(hasTabs); - m_actionCloseOthers->setEnabled(hasTabs); - - m_actionSave->setEnabled(isOpen && isSavable); - m_actionSaveAsCopy->setEnabled(isOpen && isSavable); - m_actionSaveAsChild->setEnabled(isOpen); - m_actionSaveAll->setEnabled(hasTabs); - - m_actionExit->setEnabled(true); - - m_actionUndo->setEnabled(canUndo); - m_actionRedo->setEnabled(canRedo); - m_actionSettings->setEnabled(true); - - m_actionPreviousTab->setEnabled(m_tabWidget->count() > 1); - m_actionNextTab->setEnabled(m_tabWidget->count() > 1); - - m_actionAbout->setEnabled(false); - - activateWindow(); - raise(); - - const QString documentPath = GetDocumentPath(documentId); - if (!documentPath.isEmpty()) - { - SetStatusMessage(tr("Document opened: %1").arg(documentPath)); - } - } - - void AtomToolsDocumentMainWindow::OnDocumentClosed(const AZ::Uuid& documentId) - { - RemoveTabForDocumentId(documentId); - SetStatusMessage(tr("Document closed: %1").arg(GetDocumentPath(documentId))); - } - - void AtomToolsDocumentMainWindow::OnDocumentModified(const AZ::Uuid& documentId) - { - bool isModified = false; - AtomToolsDocumentRequestBus::EventResult(isModified, documentId, &AtomToolsDocumentRequestBus::Events::IsModified); - AZStd::string absolutePath; - AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsDocumentRequestBus::Events::GetAbsolutePath); - AZStd::string filename; - AzFramework::StringFunc::Path::GetFullFileName(absolutePath.c_str(), filename); - UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); - } - - void AtomToolsDocumentMainWindow::OnDocumentUndoStateChanged(const AZ::Uuid& documentId) - { - if (documentId == GetDocumentIdFromTab(m_tabWidget->currentIndex())) - { - bool canUndo = false; - AtomToolsDocumentRequestBus::EventResult(canUndo, documentId, &AtomToolsDocumentRequestBus::Events::CanUndo); - bool canRedo = false; - AtomToolsDocumentRequestBus::EventResult(canRedo, documentId, &AtomToolsDocumentRequestBus::Events::CanRedo); - m_actionUndo->setEnabled(canUndo); - m_actionRedo->setEnabled(canRedo); - } - } - - void AtomToolsDocumentMainWindow::OnDocumentSaved(const AZ::Uuid& documentId) - { - bool isModified = false; - AtomToolsDocumentRequestBus::EventResult(isModified, documentId, &AtomToolsDocumentRequestBus::Events::IsModified); - AZStd::string absolutePath; - AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsDocumentRequestBus::Events::GetAbsolutePath); - AZStd::string filename; - AzFramework::StringFunc::Path::GetFullFileName(absolutePath.c_str(), filename); - UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); - SetStatusMessage(tr("Document saved: %1").arg(GetDocumentPath(documentId))); - } - - void AtomToolsDocumentMainWindow::CreateMenu() - { - Base::CreateMenu(); - // Generating the main menu manually because it's easier and we will have some dynamic or data driven entries m_menuFile = menuBar()->addMenu("&File"); m_actionNew = m_menuFile->addAction("&New...", [this]() { - //CreateMaterialDialog createDialog(this); - //createDialog.adjustSize(); - - //if (createDialog.exec() == QDialog::Accepted && - // !createDialog.m_materialFileInfo.absoluteFilePath().isEmpty() && - // !createDialog.m_materialTypeFileInfo.absoluteFilePath().isEmpty()) - //{ - // AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::CreateDocumentFromFile, - // createDialog.m_materialTypeFileInfo.absoluteFilePath().toUtf8().constData(), - // createDialog.m_materialFileInfo.absoluteFilePath().toUtf8().constData()); - //} + AZStd::string openPath; + AZStd::string savePath; + if (GetCreateFileInfo(openPath, savePath)) + { + AtomToolsDocumentSystemRequestBus::Broadcast( + &AtomToolsDocumentSystemRequestBus::Events::CreateDocumentFromFile, openPath, savePath); + } }, QKeySequence::New); m_actionOpen = m_menuFile->addAction("&Open...", [this]() { - //const AZStd::vector assetTypes = { azrtti_typeid() }; - //const AZStd::string filePath = GetOpenFileInfo(assetTypes).absoluteFilePath().toUtf8().constData(); - //if (!filePath.empty()) - //{ - // AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::OpenDocument, filePath); - //} + AZStd::string openPath; + if (GetOpenFileInfo(openPath)) + { + AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::OpenDocument, openPath); + } }, QKeySequence::Open); m_actionOpenRecent = m_menuFile->addAction("Open &Recent"); @@ -298,10 +172,8 @@ namespace AtomToolsFramework m_menuEdit->addSeparator(); m_actionSettings = m_menuEdit->addAction("&Settings...", [this]() { - //SettingsDialog dialog(this); - //dialog.exec(); + OpenSettings(); }, QKeySequence::Preferences); - m_actionSettings->setEnabled(true); m_menuView = menuBar()->addMenu("&View"); @@ -318,17 +190,27 @@ namespace AtomToolsFramework m_menuHelp = menuBar()->addMenu("&Help"); m_actionHelp = m_menuHelp->addAction("&Help...", [this]() { - //HelpDialog dialog(this); - //dialog.exec(); + OpenHelp(); }); m_actionAbout = m_menuHelp->addAction("&About...", [this]() { + OpenAbout(); }); } - void AtomToolsDocumentMainWindow::CreateTabBar() + void AtomToolsDocumentMainWindow::AddDocumentTabBar() { - Base::CreateTabBar(); + m_tabWidget = new AzQtComponents::TabWidget(centralWidget()); + m_tabWidget->setObjectName("TabWidget"); + m_tabWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred); + m_tabWidget->setContentsMargins(0, 0, 0, 0); + + // The tab bar should only be visible if it has active documents + m_tabWidget->setVisible(false); + m_tabWidget->setTabBarAutoHide(false); + m_tabWidget->setMovable(true); + m_tabWidget->setTabsClosable(true); + m_tabWidget->setUsesScrollButtons(true); // This signal will be triggered whenever a tab is added, removed, selected, clicked, dragged // When the last tab is removed tabIndex will be -1 and the document ID will be null @@ -342,6 +224,14 @@ namespace AtomToolsFramework const AZ::Uuid documentId = GetDocumentIdFromTab(tabIndex); AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::CloseDocument, documentId); }); + + // Add context menu for right-clicking on tabs + m_tabWidget->setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu); + connect(m_tabWidget, &QWidget::customContextMenuRequested, this, [this]() { + OpenTabContextMenu(); + }); + + centralWidget()->layout()->addWidget(m_tabWidget); } QString AtomToolsDocumentMainWindow::GetDocumentPath(const AZ::Uuid& documentId) const @@ -351,7 +241,109 @@ namespace AtomToolsFramework return absolutePath.c_str(); } - void AtomToolsDocumentMainWindow::OpenTabContextMenu() + AZ::Uuid AtomToolsDocumentMainWindow::GetDocumentIdFromTab(const int tabIndex) const + { + const QVariant tabData = m_tabWidget->tabBar()->tabData(tabIndex); + if (!tabData.isNull()) + { + // We need to be able to convert between a UUID and a string to store and retrieve a document ID from the tab bar + const QString documentIdString = tabData.toString(); + const QByteArray documentIdBytes = documentIdString.toUtf8(); + const AZ::Uuid documentId(documentIdBytes.data(), documentIdBytes.size()); + return documentId; + } + return AZ::Uuid::CreateNull(); + } + + void AtomToolsDocumentMainWindow::AddTabForDocumentId( + const AZ::Uuid& documentId, const AZStd::string& label, const AZStd::string& toolTip) + { + // Blocking signals from the tab bar so the currentChanged signal is not sent while a document is already being opened. + // This prevents the OnDocumentOpened notification from being sent recursively. + const QSignalBlocker blocker(m_tabWidget); + + // If a tab for this document already exists then select it instead of creating a new one + for (int tabIndex = 0; tabIndex < m_tabWidget->count(); ++tabIndex) + { + if (documentId == GetDocumentIdFromTab(tabIndex)) + { + m_tabWidget->setCurrentIndex(tabIndex); + m_tabWidget->repaint(); + return; + } + } + + const int tabIndex = m_tabWidget->addTab(CreateViewForDocumemt(documentId), label.c_str()); + + // The user can manually reorder tabs which will invalidate any association by index. + // We need to store the document ID with the tab using the tab instead of a separate mapping. + m_tabWidget->tabBar()->setTabData(tabIndex, QVariant(documentId.ToString())); + m_tabWidget->setTabToolTip(tabIndex, toolTip.c_str()); + m_tabWidget->setCurrentIndex(tabIndex); + m_tabWidget->setVisible(true); + m_tabWidget->repaint(); + } + + void AtomToolsDocumentMainWindow::RemoveTabForDocumentId(const AZ::Uuid& documentId) + { + // We are not blocking signals here because we want closing tabs to close the associated document + // and automatically select the next document. + for (int tabIndex = 0; tabIndex < m_tabWidget->count(); ++tabIndex) + { + if (documentId == GetDocumentIdFromTab(tabIndex)) + { + m_tabWidget->removeTab(tabIndex); + m_tabWidget->setVisible(m_tabWidget->count() > 0); + m_tabWidget->repaint(); + break; + } + } + } + + void AtomToolsDocumentMainWindow::UpdateTabForDocumentId( + const AZ::Uuid& documentId, const AZStd::string& label, const AZStd::string& toolTip, bool isModified) + { + // Whenever a document is opened, saved, or modified we need to update the tab label + if (!documentId.IsNull()) + { + // Because tab order and indexes can change from user interactions, we cannot store a map + // between a tab index and document ID. + // We must iterate over all of the tabs to find the one associated with this document. + for (int tabIndex = 0; tabIndex < m_tabWidget->count(); ++tabIndex) + { + if (documentId == GetDocumentIdFromTab(tabIndex)) + { + // We use an asterisk prepended to the file name to denote modified document + // Appending is standard and preferred but the tabs elide from the + // end (instead of middle) and cut it off + const AZStd::string modifiedLabel = isModified ? "* " + label : label; + m_tabWidget->setTabText(tabIndex, modifiedLabel.c_str()); + m_tabWidget->setTabToolTip(tabIndex, toolTip.c_str()); + m_tabWidget->repaint(); + break; + } + } + } + } + + void AtomToolsDocumentMainWindow::SelectPreviousTab() + { + if (m_tabWidget->count() > 1) + { + // Adding count to wrap around when index <= 0 + m_tabWidget->setCurrentIndex((m_tabWidget->currentIndex() + m_tabWidget->count() - 1) % m_tabWidget->count()); + } + } + + void AtomToolsDocumentMainWindow::SelectNextTab() + { + if (m_tabWidget->count() > 1) + { + m_tabWidget->setCurrentIndex((m_tabWidget->currentIndex() + 1) % m_tabWidget->count()); + } + } + + void AtomToolsDocumentMainWindow::OpenTabContextMenu() const { const QTabBar* tabBar = m_tabWidget->tabBar(); const QPoint position = tabBar->mapFromGlobal(QCursor::pos()); @@ -377,6 +369,157 @@ namespace AtomToolsFramework tabMenu.exec(QCursor::pos()); } } + + inline bool AtomToolsDocumentMainWindow::GetCreateFileInfo(AZStd::string& openPath, AZStd::string& savePath) const + { + AZ_UNUSED(openPath); + AZ_UNUSED(savePath); + return false; + } + + inline bool AtomToolsDocumentMainWindow::GetOpenFileInfo(AZStd::string& openPath) const + { + AZ_UNUSED(openPath); + return false; + } + + inline QWidget* AtomToolsDocumentMainWindow::CreateViewForDocumemt(const AZ::Uuid& documentId) const + { + AZ_UNUSED(documentId); + auto contentWidget = new QWidget(centralWidget()); + contentWidget->setContentsMargins(0, 0, 0, 0); + contentWidget->setFixedSize(0, 0); + return contentWidget; + } + + inline void AtomToolsDocumentMainWindow::OpenSettings() const + { + } + + inline void AtomToolsDocumentMainWindow::OpenHelp() const + { + } + + inline void AtomToolsDocumentMainWindow::OpenAbout() const + { + } + + void AtomToolsDocumentMainWindow::OnDocumentOpened(const AZ::Uuid& documentId) + { + bool isOpen = false; + AtomToolsDocumentRequestBus::EventResult(isOpen, documentId, &AtomToolsDocumentRequestBus::Events::IsOpen); + bool isSavable = false; + AtomToolsDocumentRequestBus::EventResult(isSavable, documentId, &AtomToolsDocumentRequestBus::Events::IsSavable); + bool isModified = false; + AtomToolsDocumentRequestBus::EventResult(isModified, documentId, &AtomToolsDocumentRequestBus::Events::IsModified); + bool canUndo = false; + AtomToolsDocumentRequestBus::EventResult(canUndo, documentId, &AtomToolsDocumentRequestBus::Events::CanUndo); + bool canRedo = false; + AtomToolsDocumentRequestBus::EventResult(canRedo, documentId, &AtomToolsDocumentRequestBus::Events::CanRedo); + AZStd::string absolutePath; + AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsDocumentRequestBus::Events::GetAbsolutePath); + AZStd::string filename; + AzFramework::StringFunc::Path::GetFullFileName(absolutePath.c_str(), filename); + + // Update UI to display the new document + if (!documentId.IsNull() && isOpen) + { + // Create a new tab for the document ID and assign it's label to the file name of the document. + AddTabForDocumentId(documentId, filename, absolutePath); + UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); + } + + const bool hasTabs = m_tabWidget->count() > 0; + + // Update menu options + m_actionNew->setEnabled(true); + m_actionOpen->setEnabled(true); + m_actionOpenRecent->setEnabled(false); + m_actionClose->setEnabled(hasTabs); + m_actionCloseAll->setEnabled(hasTabs); + m_actionCloseOthers->setEnabled(hasTabs); + + m_actionSave->setEnabled(isOpen && isSavable); + m_actionSaveAsCopy->setEnabled(isOpen && isSavable); + m_actionSaveAsChild->setEnabled(isOpen); + m_actionSaveAll->setEnabled(hasTabs); + + m_actionExit->setEnabled(true); + + m_actionUndo->setEnabled(canUndo); + m_actionRedo->setEnabled(canRedo); + m_actionSettings->setEnabled(true); + + m_actionPreviousTab->setEnabled(m_tabWidget->count() > 1); + m_actionNextTab->setEnabled(m_tabWidget->count() > 1); + + m_actionAbout->setEnabled(false); + + activateWindow(); + raise(); + + const QString documentPath = GetDocumentPath(documentId); + if (!documentPath.isEmpty()) + { + SetStatusMessage(tr("Document opened: %1").arg(documentPath)); + } + } + + void AtomToolsDocumentMainWindow::OnDocumentClosed(const AZ::Uuid& documentId) + { + RemoveTabForDocumentId(documentId); + SetStatusMessage(tr("Document closed: %1").arg(GetDocumentPath(documentId))); + } + + void AtomToolsDocumentMainWindow::OnDocumentModified(const AZ::Uuid& documentId) + { + bool isModified = false; + AtomToolsDocumentRequestBus::EventResult(isModified, documentId, &AtomToolsDocumentRequestBus::Events::IsModified); + AZStd::string absolutePath; + AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsDocumentRequestBus::Events::GetAbsolutePath); + AZStd::string filename; + AzFramework::StringFunc::Path::GetFullFileName(absolutePath.c_str(), filename); + UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); + } + + void AtomToolsDocumentMainWindow::OnDocumentUndoStateChanged(const AZ::Uuid& documentId) + { + if (documentId == GetDocumentIdFromTab(m_tabWidget->currentIndex())) + { + bool canUndo = false; + AtomToolsDocumentRequestBus::EventResult(canUndo, documentId, &AtomToolsDocumentRequestBus::Events::CanUndo); + bool canRedo = false; + AtomToolsDocumentRequestBus::EventResult(canRedo, documentId, &AtomToolsDocumentRequestBus::Events::CanRedo); + m_actionUndo->setEnabled(canUndo); + m_actionRedo->setEnabled(canRedo); + } + } + + void AtomToolsDocumentMainWindow::OnDocumentSaved(const AZ::Uuid& documentId) + { + bool isModified = false; + AtomToolsDocumentRequestBus::EventResult(isModified, documentId, &AtomToolsDocumentRequestBus::Events::IsModified); + AZStd::string absolutePath; + AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsDocumentRequestBus::Events::GetAbsolutePath); + AZStd::string filename; + AzFramework::StringFunc::Path::GetFullFileName(absolutePath.c_str(), filename); + UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); + SetStatusMessage(tr("Document saved: %1").arg(GetDocumentPath(documentId))); + } + + + void AtomToolsDocumentMainWindow::closeEvent(QCloseEvent* closeEvent) + { + bool didClose = true; + AtomToolsDocumentSystemRequestBus::BroadcastResult(didClose, &AtomToolsDocumentSystemRequestBus::Events::CloseAllDocuments); + if (!didClose) + { + closeEvent->ignore(); + return; + } + + AtomToolsMainWindowNotificationBus::Broadcast(&AtomToolsMainWindowNotifications::OnMainWindowClosing); + } } // namespace AtomToolsFramework //#include diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Window/AtomToolsMainWindow.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Window/AtomToolsMainWindow.cpp index cd7d49d8d3..a8ddebfbf0 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Window/AtomToolsMainWindow.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Window/AtomToolsMainWindow.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include @@ -26,6 +27,10 @@ namespace AtomToolsFramework m_statusMessage = new QLabel(statusBar()); statusBar()->addPermanentWidget(m_statusMessage, 1); + auto menuBar = new QMenuBar(this); + menuBar->setObjectName("MenuBar"); + setMenuBar(menuBar); + auto centralWidget = new QWidget(this); auto centralWidgetLayout = new QVBoxLayout(centralWidget); centralWidgetLayout->setMargin(0); @@ -108,145 +113,6 @@ namespace AtomToolsFramework return names; } - void AtomToolsMainWindow::CreateMenu() - { - auto menuBar = new QMenuBar(this); - menuBar->setObjectName("MenuBar"); - setMenuBar(menuBar); - } - - void AtomToolsMainWindow::CreateTabBar() - { - m_tabWidget = new AzQtComponents::TabWidget(centralWidget()); - m_tabWidget->setObjectName("TabWidget"); - m_tabWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred); - m_tabWidget->setContentsMargins(0, 0, 0, 0); - - // The tab bar should only be visible if it has active documents - m_tabWidget->setVisible(false); - m_tabWidget->setTabBarAutoHide(false); - m_tabWidget->setMovable(true); - m_tabWidget->setTabsClosable(true); - m_tabWidget->setUsesScrollButtons(true); - - // Add context menu for right-clicking on tabs - m_tabWidget->setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu); - connect( - m_tabWidget, &QWidget::customContextMenuRequested, this, - [this]() - { - OpenTabContextMenu(); - }); - - centralWidget()->layout()->addWidget(m_tabWidget); - } - - void AtomToolsMainWindow::AddTabForDocumentId( - const AZ::Uuid& documentId, const AZStd::string& label, const AZStd::string& toolTip, AZStd::function widgetCreator) - { - // Blocking signals from the tab bar so the currentChanged signal is not sent while a document is already being opened. - // This prevents the OnDocumentOpened notification from being sent recursively. - const QSignalBlocker blocker(m_tabWidget); - - // If a tab for this document already exists then select it instead of creating a new one - for (int tabIndex = 0; tabIndex < m_tabWidget->count(); ++tabIndex) - { - if (documentId == GetDocumentIdFromTab(tabIndex)) - { - m_tabWidget->setCurrentIndex(tabIndex); - m_tabWidget->repaint(); - return; - } - } - - const int tabIndex = m_tabWidget->addTab(widgetCreator(), label.c_str()); - - // The user can manually reorder tabs which will invalidate any association by index. - // We need to store the document ID with the tab using the tab instead of a separate mapping. - m_tabWidget->tabBar()->setTabData(tabIndex, QVariant(documentId.ToString())); - m_tabWidget->setTabToolTip(tabIndex, toolTip.c_str()); - m_tabWidget->setCurrentIndex(tabIndex); - m_tabWidget->setVisible(true); - m_tabWidget->repaint(); - } - - void AtomToolsMainWindow::RemoveTabForDocumentId(const AZ::Uuid& documentId) - { - // We are not blocking signals here because we want closing tabs to close the associated document - // and automatically select the next document. - for (int tabIndex = 0; tabIndex < m_tabWidget->count(); ++tabIndex) - { - if (documentId == GetDocumentIdFromTab(tabIndex)) - { - m_tabWidget->removeTab(tabIndex); - m_tabWidget->setVisible(m_tabWidget->count() > 0); - m_tabWidget->repaint(); - break; - } - } - } - - void AtomToolsMainWindow::UpdateTabForDocumentId( - const AZ::Uuid& documentId, const AZStd::string& label, const AZStd::string& toolTip, bool isModified) - { - // Whenever a document is opened, saved, or modified we need to update the tab label - if (!documentId.IsNull()) - { - // Because tab order and indexes can change from user interactions, we cannot store a map - // between a tab index and document ID. - // We must iterate over all of the tabs to find the one associated with this document. - for (int tabIndex = 0; tabIndex < m_tabWidget->count(); ++tabIndex) - { - if (documentId == GetDocumentIdFromTab(tabIndex)) - { - // We use an asterisk prepended to the file name to denote modified document - // Appending is standard and preferred but the tabs elide from the - // end (instead of middle) and cut it off - const AZStd::string modifiedLabel = isModified ? "* " + label : label; - m_tabWidget->setTabText(tabIndex, modifiedLabel.c_str()); - m_tabWidget->setTabToolTip(tabIndex, toolTip.c_str()); - m_tabWidget->repaint(); - break; - } - } - } - } - - AZ::Uuid AtomToolsMainWindow::GetDocumentIdFromTab(const int tabIndex) const - { - const QVariant tabData = m_tabWidget->tabBar()->tabData(tabIndex); - if (!tabData.isNull()) - { - // We need to be able to convert between a UUID and a string to store and retrieve a document ID from the tab bar - const QString documentIdString = tabData.toString(); - const QByteArray documentIdBytes = documentIdString.toUtf8(); - const AZ::Uuid documentId(documentIdBytes.data(), documentIdBytes.size()); - return documentId; - } - return AZ::Uuid::CreateNull(); - } - - void AtomToolsMainWindow::OpenTabContextMenu() - { - } - - void AtomToolsMainWindow::SelectPreviousTab() - { - if (m_tabWidget->count() > 1) - { - // Adding count to wrap around when index <= 0 - m_tabWidget->setCurrentIndex((m_tabWidget->currentIndex() + m_tabWidget->count() - 1) % m_tabWidget->count()); - } - } - - void AtomToolsMainWindow::SelectNextTab() - { - if (m_tabWidget->count() > 1) - { - m_tabWidget->setCurrentIndex((m_tabWidget->currentIndex() + 1) % m_tabWidget->count()); - } - } - void AtomToolsMainWindow::SetStatusMessage(const QString& message) { m_statusMessage->setText(QString("%1").arg(message)); From 78f90f2707c836086b719a35fb89910cace165f5 Mon Sep 17 00:00:00 2001 From: Guthrie Adams Date: Sun, 22 Aug 2021 22:37:50 -0500 Subject: [PATCH 39/53] updated ME and SMC main window classes to use AtomToolsDocumentMainWindow separated common and document menu creation Signed-off-by: Guthrie Adams --- .../Document/AtomToolsDocumentMainWindow.h | 23 +- .../Window/AtomToolsMainWindow.h | 16 +- .../Document/AtomToolsDocumentMainWindow.cpp | 134 ++---- .../Source/Window/AtomToolsMainWindow.cpp | 56 ++- .../Source/Window/MaterialEditorWindow.cpp | 434 ++---------------- .../Code/Source/Window/MaterialEditorWindow.h | 62 +-- .../Window/ShaderManagementConsoleWindow.cpp | 359 +-------------- .../Window/ShaderManagementConsoleWindow.h | 56 +-- 8 files changed, 204 insertions(+), 936 deletions(-) diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h index 6beae2a69c..883a8833ab 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h @@ -53,13 +53,10 @@ namespace AtomToolsFramework void SelectNextTab(); - virtual void OpenTabContextMenu() const; - virtual bool GetCreateFileInfo(AZStd::string& openPath, AZStd::string& savePath) const; - virtual bool GetOpenFileInfo(AZStd::string& openPath) const; - virtual QWidget* CreateViewForDocumemt(const AZ::Uuid& documentId) const; - virtual void OpenSettings() const; - virtual void OpenHelp() const; - virtual void OpenAbout() const; + virtual void OpenTabContextMenu(); + virtual bool GetCreateFileInfo(AZStd::string& openPath, AZStd::string& savePath); + virtual bool GetOpenFileInfo(AZStd::string& openPath); + virtual QWidget* CreateViewForDocumemt(const AZ::Uuid& documentId); // AtomToolsDocumentNotificationBus::Handler overrides... void OnDocumentOpened(const AZ::Uuid& documentId) override; @@ -70,10 +67,11 @@ namespace AtomToolsFramework void closeEvent(QCloseEvent* closeEvent) override; - QMenu* m_menuFile = {}; + template + QAction* CreateAction(const QString& text, Functor functor, const QKeySequence& shortcut = 0); + QAction* m_actionNew = {}; QAction* m_actionOpen = {}; - QAction* m_actionOpenRecent = {}; QAction* m_actionClose = {}; QAction* m_actionCloseAll = {}; QAction* m_actionCloseOthers = {}; @@ -81,20 +79,13 @@ namespace AtomToolsFramework QAction* m_actionSaveAsCopy = {}; QAction* m_actionSaveAsChild = {}; QAction* m_actionSaveAll = {}; - QAction* m_actionExit = {}; - QMenu* m_menuEdit = {}; QAction* m_actionUndo = {}; QAction* m_actionRedo = {}; - QAction* m_actionSettings = {}; - QMenu* m_menuView = {}; QAction* m_actionNextTab = {}; QAction* m_actionPreviousTab = {}; - QMenu* m_menuHelp = {}; - QAction* m_actionHelp = {}; - QAction* m_actionAbout = {}; AzQtComponents::TabWidget* m_tabWidget = {}; }; } // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Window/AtomToolsMainWindow.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Window/AtomToolsMainWindow.h index c5b47fe7a4..8d30e42bbb 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Window/AtomToolsMainWindow.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Window/AtomToolsMainWindow.h @@ -38,8 +38,20 @@ namespace AtomToolsFramework void SetStatusWarning(const QString& message); void SetStatusError(const QString& message); - AzQtComponents::FancyDocking* m_advancedDockManager = nullptr; - QLabel* m_statusMessage = nullptr; + void AddCommonMenus(); + + virtual void OpenSettings(); + virtual void OpenHelp(); + virtual void OpenAbout(); + + AzQtComponents::FancyDocking* m_advancedDockManager = {}; + + QLabel* m_statusMessage = {}; + + QMenu* m_menuFile = {}; + QMenu* m_menuEdit = {}; + QMenu* m_menuView = {}; + QMenu* m_menuHelp = {}; AZStd::unordered_map m_dockWidgets; }; diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp index a35b65461a..4e7bc8edbd 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp @@ -12,15 +12,11 @@ #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 @@ -45,10 +41,10 @@ namespace AtomToolsFramework void AtomToolsDocumentMainWindow::AddDocumentMenus() { - // Generating the main menu manually because it's easier and we will have some dynamic or data driven entries - m_menuFile = menuBar()->addMenu("&File"); + QAction* insertPostion = !m_menuFile->actions().empty() ? m_menuFile->actions().front() : nullptr; - m_actionNew = m_menuFile->addAction("&New...", [this]() { + // Generating the main menu manually because it's easier and we will have some dynamic or data driven entries + m_actionNew = CreateAction("&New...", [this]() { AZStd::string openPath; AZStd::string savePath; if (GetCreateFileInfo(openPath, savePath)) @@ -57,20 +53,19 @@ namespace AtomToolsFramework &AtomToolsDocumentSystemRequestBus::Events::CreateDocumentFromFile, openPath, savePath); } }, QKeySequence::New); + m_menuFile->insertAction(insertPostion, m_actionNew); - m_actionOpen = m_menuFile->addAction("&Open...", [this]() { + m_actionOpen = CreateAction("&Open...", [this]() { AZStd::string openPath; if (GetOpenFileInfo(openPath)) { AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::OpenDocument, openPath); } }, QKeySequence::Open); + m_menuFile->insertAction(insertPostion, m_actionOpen); + m_menuFile->insertSeparator(insertPostion); - m_actionOpenRecent = m_menuFile->addAction("Open &Recent"); - - m_menuFile->addSeparator(); - - m_actionSave = m_menuFile->addAction("&Save", [this]() { + m_actionSave = CreateAction("&Save", [this]() { const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); bool result = false; AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsDocumentSystemRequestBus::Events::SaveDocument, documentId); @@ -79,8 +74,9 @@ namespace AtomToolsFramework SetStatusError(tr("Document save failed: %1").arg(GetDocumentPath(documentId))); } }, QKeySequence::Save); + m_menuFile->insertAction(insertPostion, m_actionSave); - m_actionSaveAsCopy = m_menuFile->addAction("Save &As...", [this]() { + m_actionSaveAsCopy = CreateAction("Save &As...", [this]() { const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); const QString documentPath = GetDocumentPath(documentId); @@ -92,8 +88,9 @@ namespace AtomToolsFramework SetStatusError(tr("Document save failed: %1").arg(GetDocumentPath(documentId))); } }, QKeySequence::SaveAs); + m_menuFile->insertAction(insertPostion, m_actionSaveAsCopy); - m_actionSaveAsChild = m_menuFile->addAction("Save As &Child...", [this]() { + m_actionSaveAsChild = CreateAction("Save As &Child...", [this]() { const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); const QString documentPath = GetDocumentPath(documentId); @@ -105,8 +102,9 @@ namespace AtomToolsFramework SetStatusError(tr("Document save failed: %1").arg(GetDocumentPath(documentId))); } }); + m_menuFile->insertAction(insertPostion, m_actionSaveAsChild); - m_actionSaveAll = m_menuFile->addAction("Save A&ll", [this]() { + m_actionSaveAll = CreateAction("Save A&ll", [this]() { bool result = false; AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsDocumentSystemRequestBus::Events::SaveAllDocuments); if (!result) @@ -114,42 +112,30 @@ namespace AtomToolsFramework SetStatusError(tr("Document save all failed")); } }); + m_menuFile->insertAction(insertPostion, m_actionSaveAll); + m_menuFile->insertSeparator(insertPostion); - m_menuFile->addSeparator(); - - m_actionClose = m_menuFile->addAction("&Close", [this]() { + m_actionClose = CreateAction("&Close", [this]() { const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::CloseDocument, documentId); }, QKeySequence::Close); + m_menuFile->insertAction(insertPostion, m_actionClose); - m_actionCloseAll = m_menuFile->addAction("Close All", [this]() { + m_actionCloseAll = CreateAction("Close All", [this]() { AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::CloseAllDocuments); }); + m_menuFile->insertAction(insertPostion, m_actionCloseAll); - m_actionCloseOthers = m_menuFile->addAction("Close Others", [this]() { + m_actionCloseOthers = CreateAction("Close Others", [this]() { const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::CloseAllDocumentsExcept, documentId); }); + m_menuFile->insertAction(insertPostion, m_actionCloseOthers); + m_menuFile->insertSeparator(insertPostion); - m_menuFile->addSeparator(); + insertPostion = !m_menuEdit->actions().empty() ? m_menuEdit->actions().front() : nullptr; - m_menuFile->addAction("Run &Python...", [this]() { - const QString script = QFileDialog::getOpenFileName(this, "Run Script", QString(), QString("*.py")); - if (!script.isEmpty()) - { - AzToolsFramework::EditorPythonRunnerRequestBus::Broadcast(&AzToolsFramework::EditorPythonRunnerRequestBus::Events::ExecuteByFilename, script.toUtf8().constData()); - } - }); - - m_menuFile->addSeparator(); - - m_actionExit = m_menuFile->addAction("E&xit", [this]() { - close(); - }, QKeySequence::Quit); - - m_menuEdit = menuBar()->addMenu("&Edit"); - - m_actionUndo = m_menuEdit->addAction("&Undo", [this]() { + m_actionUndo = CreateAction("&Undo", [this]() { const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); bool result = false; AtomToolsDocumentRequestBus::EventResult(result, documentId, &AtomToolsDocumentRequestBus::Events::Undo); @@ -158,8 +144,9 @@ namespace AtomToolsFramework SetStatusError(tr("Document undo failed: %1").arg(GetDocumentPath(documentId))); } }, QKeySequence::Undo); + m_menuEdit->insertAction(insertPostion, m_actionUndo); - m_actionRedo = m_menuEdit->addAction("&Redo", [this]() { + m_actionRedo = CreateAction("&Redo", [this]() { const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); bool result = false; AtomToolsDocumentRequestBus::EventResult(result, documentId, &AtomToolsDocumentRequestBus::Events::Redo); @@ -168,34 +155,24 @@ namespace AtomToolsFramework SetStatusError(tr("Document redo failed: %1").arg(GetDocumentPath(documentId))); } }, QKeySequence::Redo); + m_menuEdit->insertAction(insertPostion, m_actionRedo); + m_menuEdit->insertSeparator(insertPostion); - m_menuEdit->addSeparator(); + insertPostion = !m_menuView->actions().empty() ? m_menuView->actions().front() : nullptr; - m_actionSettings = m_menuEdit->addAction("&Settings...", [this]() { - OpenSettings(); - }, QKeySequence::Preferences); - - m_menuView = menuBar()->addMenu("&View"); - - m_menuView->addSeparator(); - - m_actionPreviousTab = m_menuView->addAction("&Previous Tab", [this]() { + m_actionPreviousTab = CreateAction( + "&Previous Tab", + [this]() + { SelectPreviousTab(); }, Qt::CTRL | Qt::SHIFT | Qt::Key_Tab); //QKeySequence::PreviousChild is mapped incorrectly in Qt + m_menuView->insertAction(insertPostion, m_actionPreviousTab); - m_actionNextTab = m_menuView->addAction("&Next Tab", [this]() { + m_actionNextTab = CreateAction("&Next Tab", [this]() { SelectNextTab(); }, Qt::CTRL | Qt::Key_Tab); //QKeySequence::NextChild works as expected but mirroring Previous - - m_menuHelp = menuBar()->addMenu("&Help"); - - m_actionHelp = m_menuHelp->addAction("&Help...", [this]() { - OpenHelp(); - }); - - m_actionAbout = m_menuHelp->addAction("&About...", [this]() { - OpenAbout(); - }); + m_menuView->insertAction(insertPostion, m_actionNextTab); + m_menuView->insertSeparator(insertPostion); } void AtomToolsDocumentMainWindow::AddDocumentTabBar() @@ -343,7 +320,7 @@ namespace AtomToolsFramework } } - void AtomToolsDocumentMainWindow::OpenTabContextMenu() const + void AtomToolsDocumentMainWindow::OpenTabContextMenu() { const QTabBar* tabBar = m_tabWidget->tabBar(); const QPoint position = tabBar->mapFromGlobal(QCursor::pos()); @@ -370,20 +347,20 @@ namespace AtomToolsFramework } } - inline bool AtomToolsDocumentMainWindow::GetCreateFileInfo(AZStd::string& openPath, AZStd::string& savePath) const + inline bool AtomToolsDocumentMainWindow::GetCreateFileInfo(AZStd::string& openPath, AZStd::string& savePath) { AZ_UNUSED(openPath); AZ_UNUSED(savePath); return false; } - inline bool AtomToolsDocumentMainWindow::GetOpenFileInfo(AZStd::string& openPath) const + inline bool AtomToolsDocumentMainWindow::GetOpenFileInfo(AZStd::string& openPath) { AZ_UNUSED(openPath); return false; } - inline QWidget* AtomToolsDocumentMainWindow::CreateViewForDocumemt(const AZ::Uuid& documentId) const + inline QWidget* AtomToolsDocumentMainWindow::CreateViewForDocumemt(const AZ::Uuid& documentId) { AZ_UNUSED(documentId); auto contentWidget = new QWidget(centralWidget()); @@ -392,18 +369,6 @@ namespace AtomToolsFramework return contentWidget; } - inline void AtomToolsDocumentMainWindow::OpenSettings() const - { - } - - inline void AtomToolsDocumentMainWindow::OpenHelp() const - { - } - - inline void AtomToolsDocumentMainWindow::OpenAbout() const - { - } - void AtomToolsDocumentMainWindow::OnDocumentOpened(const AZ::Uuid& documentId) { bool isOpen = false; @@ -434,7 +399,6 @@ namespace AtomToolsFramework // Update menu options m_actionNew->setEnabled(true); m_actionOpen->setEnabled(true); - m_actionOpenRecent->setEnabled(false); m_actionClose->setEnabled(hasTabs); m_actionCloseAll->setEnabled(hasTabs); m_actionCloseOthers->setEnabled(hasTabs); @@ -444,17 +408,12 @@ namespace AtomToolsFramework m_actionSaveAsChild->setEnabled(isOpen); m_actionSaveAll->setEnabled(hasTabs); - m_actionExit->setEnabled(true); - m_actionUndo->setEnabled(canUndo); m_actionRedo->setEnabled(canRedo); - m_actionSettings->setEnabled(true); m_actionPreviousTab->setEnabled(m_tabWidget->count() > 1); m_actionNextTab->setEnabled(m_tabWidget->count() > 1); - m_actionAbout->setEnabled(false); - activateWindow(); raise(); @@ -520,6 +479,15 @@ namespace AtomToolsFramework AtomToolsMainWindowNotificationBus::Broadcast(&AtomToolsMainWindowNotifications::OnMainWindowClosing); } + + template + QAction* AtomToolsDocumentMainWindow::CreateAction(const QString& text, Functor functor, const QKeySequence& shortcut) + { + QAction* action = new QAction(text, this); + action->setShortcut(shortcut); + connect(action, &QAction::triggered, this, functor); + return action; + } } // namespace AtomToolsFramework //#include diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Window/AtomToolsMainWindow.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Window/AtomToolsMainWindow.cpp index a8ddebfbf0..e586dbc588 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Window/AtomToolsMainWindow.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Window/AtomToolsMainWindow.cpp @@ -7,6 +7,10 @@ */ #include +#include + +#include +#include #include #include #include @@ -24,13 +28,11 @@ namespace AtomToolsFramework setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea); setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); + AddCommonMenus(); + m_statusMessage = new QLabel(statusBar()); statusBar()->addPermanentWidget(m_statusMessage, 1); - auto menuBar = new QMenuBar(this); - menuBar->setObjectName("MenuBar"); - setMenuBar(menuBar); - auto centralWidget = new QWidget(this); auto centralWidgetLayout = new QVBoxLayout(centralWidget); centralWidgetLayout->setMargin(0); @@ -127,4 +129,50 @@ namespace AtomToolsFramework { m_statusMessage->setText(QString("%1").arg(message)); } + + void AtomToolsMainWindow::AddCommonMenus() + { + m_menuFile = menuBar()->addMenu("&File"); + m_menuEdit = menuBar()->addMenu("&Edit"); + m_menuView = menuBar()->addMenu("&View"); + m_menuHelp = menuBar()->addMenu("&Help"); + + m_menuFile->addAction("Run &Python...", [this]() { + const QString script = QFileDialog::getOpenFileName(this, "Run Script", QString(), QString("*.py")); + if (!script.isEmpty()) + { + AzToolsFramework::EditorPythonRunnerRequestBus::Broadcast(&AzToolsFramework::EditorPythonRunnerRequestBus::Events::ExecuteByFilename, script.toUtf8().constData()); + } + }); + + m_menuFile->addSeparator(); + + m_menuFile->addAction("E&xit", [this]() { + close(); + }, QKeySequence::Quit); + + m_menuEdit->addAction("&Settings...", [this]() { + OpenSettings(); + }, QKeySequence::Preferences); + + m_menuHelp->addAction("&Help...", [this]() { + OpenHelp(); + }); + + m_menuHelp->addAction("&About...", [this]() { + OpenAbout(); + }); + } + + void AtomToolsMainWindow::OpenSettings() + { + } + + void AtomToolsMainWindow::OpenHelp() + { + } + + void AtomToolsMainWindow::OpenAbout() + { + } } // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp index 8922591580..5f895ba804 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp @@ -9,15 +9,9 @@ #include #include #include -#include -#include #include -#include -#include #include #include -#include -#include #include #include #include @@ -33,7 +27,6 @@ AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnin #include #include #include -#include #include #include AZ_POP_DISABLE_WARNING @@ -41,7 +34,7 @@ AZ_POP_DISABLE_WARNING namespace MaterialEditor { MaterialEditorWindow::MaterialEditorWindow(QWidget* parent /* = 0 */) - : AtomToolsFramework::AtomToolsMainWindow(parent) + : AtomToolsFramework::AtomToolsDocumentMainWindow(parent) { resize(1280, 1024); @@ -74,9 +67,6 @@ namespace MaterialEditor m_toolBar->setObjectName("ToolBar"); addToolBar(m_toolBar); - CreateMenu(); - CreateTabBar(); - m_materialViewport = new MaterialViewportWidget(centralWidget()); m_materialViewport->setObjectName("Viewport"); m_materialViewport->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); @@ -105,15 +95,12 @@ namespace MaterialEditor m_advancedDockManager->restoreState(windowState); } - AtomToolsFramework::AtomToolsDocumentNotificationBus::Handler::BusConnect(); OnDocumentOpened(AZ::Uuid::CreateNull()); } MaterialEditorWindow::~MaterialEditorWindow() { - AtomToolsFramework::AtomToolsDocumentNotificationBus::Handler::BusDisconnect(); } - void MaterialEditorWindow::ResizeViewportRenderTarget(uint32_t width, uint32_t height) { @@ -146,16 +133,56 @@ namespace MaterialEditor m_materialViewport->UnlockRenderTargetSize(); } + bool MaterialEditorWindow::GetCreateFileInfo(AZStd::string& openPath, AZStd::string& savePath) + { + CreateMaterialDialog createDialog(this); + createDialog.adjustSize(); + + if (createDialog.exec() == QDialog::Accepted && + !createDialog.m_materialFileInfo.absoluteFilePath().isEmpty() && + !createDialog.m_materialTypeFileInfo.absoluteFilePath().isEmpty()) + { + savePath = createDialog.m_materialFileInfo.absoluteFilePath().toUtf8().constData(); + openPath = createDialog.m_materialTypeFileInfo.absoluteFilePath().toUtf8().constData(); + return true; + } + return false; + } + + bool MaterialEditorWindow::GetOpenFileInfo(AZStd::string& openPath) + { + const AZStd::vector assetTypes = { azrtti_typeid() }; + openPath = AtomToolsFramework::GetOpenFileInfo(assetTypes).absoluteFilePath().toUtf8().constData(); + return !openPath.empty(); + } + + QWidget* MaterialEditorWindow::CreateViewForDocumemt(const AZ::Uuid& documentId) + { + AZ_UNUSED(documentId); + auto contentWidget = new QWidget(centralWidget()); + contentWidget->setContentsMargins(0, 0, 0, 0); + contentWidget->setFixedSize(0, 0); + return contentWidget; + } + + void MaterialEditorWindow::OpenSettings() + { + SettingsDialog dialog(this); + dialog.exec(); + } + + void MaterialEditorWindow::OpenHelp() + { + HelpDialog dialog(this); + dialog.exec(); + } + + void MaterialEditorWindow::OpenAbout() + { + } + void MaterialEditorWindow::closeEvent(QCloseEvent* closeEvent) { - bool didClose = true; - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::BroadcastResult(didClose, &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseAllDocuments); - if (!didClose) - { - closeEvent->ignore(); - return; - } - // Capture docking state before shutdown auto windowSettings = AZ::UserSettings::CreateFind( AZ::Crc32("MaterialEditorWindowSettings"), AZ::UserSettings::CT_GLOBAL); @@ -163,368 +190,7 @@ namespace MaterialEditor QByteArray windowState = m_advancedDockManager->saveState(); windowSettings->m_mainWindowState.assign(windowState.begin(), windowState.end()); - AtomToolsFramework::AtomToolsMainWindowNotificationBus::Broadcast( - &AtomToolsFramework::AtomToolsMainWindowNotifications::OnMainWindowClosing); - } - - void MaterialEditorWindow::OnDocumentOpened(const AZ::Uuid& documentId) - { - bool isOpen = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(isOpen, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsOpen); - bool isSavable = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(isSavable, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsSavable); - bool isModified = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(isModified, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsModified); - bool canUndo = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(canUndo, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::CanUndo); - bool canRedo = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(canRedo, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::CanRedo); - AZStd::string absolutePath; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::GetAbsolutePath); - AZStd::string filename; - AzFramework::StringFunc::Path::GetFullFileName(absolutePath.c_str(), filename); - - // Update UI to display the new document - if (!documentId.IsNull() && isOpen) - { - // Create a new tab for the document ID and assign it's label to the file name of the document. - AddTabForDocumentId(documentId, filename, absolutePath, [this]{ - // The tab widget requires a dummy page per tab - auto contentWidget = new QWidget(centralWidget()); - contentWidget->setContentsMargins(0, 0, 0, 0); - contentWidget->setFixedSize(0, 0); - return contentWidget; - }); - } - - UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); - - const bool hasTabs = m_tabWidget->count() > 0; - - // Update menu options - m_actionNew->setEnabled(true); - m_actionOpen->setEnabled(true); - m_actionOpenRecent->setEnabled(false); - m_actionClose->setEnabled(hasTabs); - m_actionCloseAll->setEnabled(hasTabs); - m_actionCloseOthers->setEnabled(hasTabs); - - m_actionSave->setEnabled(isOpen && isSavable); - m_actionSaveAsCopy->setEnabled(isOpen && isSavable); - m_actionSaveAsChild->setEnabled(isOpen); - m_actionSaveAll->setEnabled(hasTabs); - - m_actionExit->setEnabled(true); - - m_actionUndo->setEnabled(canUndo); - m_actionRedo->setEnabled(canRedo); - m_actionSettings->setEnabled(true); - - m_actionAssetBrowser->setEnabled(true); - m_actionInspector->setEnabled(true); - m_actionConsole->setEnabled(false); - m_actionPythonTerminal->setEnabled(true); - m_actionPerfMonitor->setEnabled(true); - m_actionViewportSettings->setEnabled(true); - m_actionPreviousTab->setEnabled(m_tabWidget->count() > 1); - m_actionNextTab->setEnabled(m_tabWidget->count() > 1); - - m_actionAbout->setEnabled(false); - - activateWindow(); - raise(); - - const QString documentPath = GetDocumentPath(documentId); - if (!documentPath.isEmpty()) - { - SetStatusMessage(tr("Document opened: %1").arg(documentPath)); - } - } - - void MaterialEditorWindow::OnDocumentClosed(const AZ::Uuid& documentId) - { - RemoveTabForDocumentId(documentId); - SetStatusMessage(tr("Document closed: %1").arg(GetDocumentPath(documentId))); - } - - void MaterialEditorWindow::OnDocumentModified(const AZ::Uuid& documentId) - { - bool isModified = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(isModified, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsModified); - AZStd::string absolutePath; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::GetAbsolutePath); - AZStd::string filename; - AzFramework::StringFunc::Path::GetFullFileName(absolutePath.c_str(), filename); - UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); - } - - void MaterialEditorWindow::OnDocumentUndoStateChanged(const AZ::Uuid& documentId) - { - if (documentId == GetDocumentIdFromTab(m_tabWidget->currentIndex())) - { - bool canUndo = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(canUndo, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::CanUndo); - bool canRedo = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(canRedo, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::CanRedo); - m_actionUndo->setEnabled(canUndo); - m_actionRedo->setEnabled(canRedo); - } - } - - void MaterialEditorWindow::OnDocumentSaved(const AZ::Uuid& documentId) - { - bool isModified = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(isModified, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsModified); - AZStd::string absolutePath; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::GetAbsolutePath); - AZStd::string filename; - AzFramework::StringFunc::Path::GetFullFileName(absolutePath.c_str(), filename); - UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); - SetStatusMessage(tr("Document saved: %1").arg(GetDocumentPath(documentId))); - } - - void MaterialEditorWindow::CreateMenu() - { - Base::CreateMenu(); - - // Generating the main menu manually because it's easier and we will have some dynamic or data driven entries - m_menuFile = menuBar()->addMenu("&File"); - - m_actionNew = m_menuFile->addAction("&New...", [this]() { - CreateMaterialDialog createDialog(this); - createDialog.adjustSize(); - - if (createDialog.exec() == QDialog::Accepted && - !createDialog.m_materialFileInfo.absoluteFilePath().isEmpty() && - !createDialog.m_materialTypeFileInfo.absoluteFilePath().isEmpty()) - { - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CreateDocumentFromFile, - createDialog.m_materialTypeFileInfo.absoluteFilePath().toUtf8().constData(), - createDialog.m_materialFileInfo.absoluteFilePath().toUtf8().constData()); - } - }, QKeySequence::New); - - m_actionOpen = m_menuFile->addAction("&Open...", [this]() { - const AZStd::vector assetTypes = { azrtti_typeid() }; - const AZStd::string filePath = AtomToolsFramework::GetOpenFileInfo(assetTypes).absoluteFilePath().toUtf8().constData(); - if (!filePath.empty()) - { - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::OpenDocument, filePath); - } - }, QKeySequence::Open); - - m_actionOpenRecent = m_menuFile->addAction("Open &Recent"); - - m_menuFile->addSeparator(); - - m_actionSave = m_menuFile->addAction("&Save", [this]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); - bool result = false; - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::SaveDocument, documentId); - if (!result) - { - SetStatusError(tr("Document save failed: %1").arg(GetDocumentPath(documentId))); - } - }, QKeySequence::Save); - - m_actionSaveAsCopy = m_menuFile->addAction("Save &As...", [this]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); - const QString documentPath = GetDocumentPath(documentId); - - bool result = false; - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::SaveDocumentAsCopy, - documentId, AtomToolsFramework::GetSaveFileInfo(documentPath).absoluteFilePath().toUtf8().constData()); - if (!result) - { - SetStatusError(tr("Document save failed: %1").arg(GetDocumentPath(documentId))); - } - }, QKeySequence::SaveAs); - - m_actionSaveAsChild = m_menuFile->addAction("Save As &Child...", [this]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); - const QString documentPath = GetDocumentPath(documentId); - - bool result = false; - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::SaveDocumentAsChild, - documentId, AtomToolsFramework::GetSaveFileInfo(documentPath).absoluteFilePath().toUtf8().constData()); - if (!result) - { - SetStatusError(tr("Document save failed: %1").arg(GetDocumentPath(documentId))); - } - }); - - m_actionSaveAll = m_menuFile->addAction("Save A&ll", [this]() { - bool result = false; - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::SaveAllDocuments); - if (!result) - { - SetStatusError(tr("Document save all failed")); - } - }); - - m_menuFile->addSeparator(); - - m_actionClose = m_menuFile->addAction("&Close", [this]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseDocument, documentId); - }, QKeySequence::Close); - - m_actionCloseAll = m_menuFile->addAction("Close All", [this]() { - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseAllDocuments); - }); - - m_actionCloseOthers = m_menuFile->addAction("Close Others", [this]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseAllDocumentsExcept, documentId); - }); - - m_menuFile->addSeparator(); - - m_menuFile->addAction("Run &Python...", [this]() { - const QString script = QFileDialog::getOpenFileName(this, "Run Script", QString(), QString("*.py")); - if (!script.isEmpty()) - { - AzToolsFramework::EditorPythonRunnerRequestBus::Broadcast(&AzToolsFramework::EditorPythonRunnerRequestBus::Events::ExecuteByFilename, script.toUtf8().constData()); - } - }); - - m_menuFile->addSeparator(); - - m_actionExit = m_menuFile->addAction("E&xit", [this]() { - close(); - }, QKeySequence::Quit); - - m_menuEdit = menuBar()->addMenu("&Edit"); - - m_actionUndo = m_menuEdit->addAction("&Undo", [this]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); - bool result = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(result, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::Undo); - if (!result) - { - SetStatusError(tr("Document undo failed: %1").arg(GetDocumentPath(documentId))); - } - }, QKeySequence::Undo); - - m_actionRedo = m_menuEdit->addAction("&Redo", [this]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); - bool result = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(result, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::Redo); - if (!result) - { - SetStatusError(tr("Document redo failed: %1").arg(GetDocumentPath(documentId))); - } - }, QKeySequence::Redo); - - m_menuEdit->addSeparator(); - - m_actionSettings = m_menuEdit->addAction("&Settings...", [this]() { - SettingsDialog dialog(this); - dialog.exec(); - }, QKeySequence::Preferences); - m_actionSettings->setEnabled(true); - - m_menuView = menuBar()->addMenu("&View"); - - m_actionAssetBrowser = m_menuView->addAction("&Asset Browser", [this]() { - const AZStd::string label = "Asset Browser"; - SetDockWidgetVisible(label, !IsDockWidgetVisible(label)); - }); - - m_actionInspector = m_menuView->addAction("&Inspector", [this]() { - const AZStd::string label = "Inspector"; - SetDockWidgetVisible(label, !IsDockWidgetVisible(label)); - }); - - m_actionConsole = m_menuView->addAction("&Console", [this]() { - }); - - m_actionPythonTerminal = m_menuView->addAction("Python &Terminal", [this]() { - const AZStd::string label = "Python Terminal"; - SetDockWidgetVisible(label, !IsDockWidgetVisible(label)); - }); - - m_actionPerfMonitor = m_menuView->addAction("Performance &Monitor", [this]() { - const AZStd::string label = "Performance Monitor"; - SetDockWidgetVisible(label, !IsDockWidgetVisible(label)); - }); - - m_actionViewportSettings = m_menuView->addAction("Viewport Settings", [this]() { - const AZStd::string label = "Viewport Settings"; - SetDockWidgetVisible(label, !IsDockWidgetVisible(label)); - }); - - m_menuView->addSeparator(); - - m_actionPreviousTab = m_menuView->addAction("&Previous Tab", [this]() { - SelectPreviousTab(); - }, Qt::CTRL | Qt::SHIFT | Qt::Key_Tab); //QKeySequence::PreviousChild is mapped incorrectly in Qt - - m_actionNextTab = m_menuView->addAction("&Next Tab", [this]() { - SelectNextTab(); - }, Qt::CTRL | Qt::Key_Tab); //QKeySequence::NextChild works as expected but mirroring Previous - - m_menuHelp = menuBar()->addMenu("&Help"); - - m_actionHelp = m_menuHelp->addAction("&Help...", [this]() { - HelpDialog dialog(this); - dialog.exec(); - }); - - m_actionAbout = m_menuHelp->addAction("&About...", [this]() { - }); - } - - void MaterialEditorWindow::CreateTabBar() - { - Base::CreateTabBar(); - - // This signal will be triggered whenever a tab is added, removed, selected, clicked, dragged - // When the last tab is removed tabIndex will be -1 and the document ID will be null - // This should automatically clear the active document - connect(m_tabWidget, &QTabWidget::currentChanged, this, [this](int tabIndex) { - const AZ::Uuid documentId = GetDocumentIdFromTab(tabIndex); - AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentOpened, documentId); - }); - - connect(m_tabWidget, &QTabWidget::tabCloseRequested, this, [this](int tabIndex) { - const AZ::Uuid documentId = GetDocumentIdFromTab(tabIndex); - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseDocument, documentId); - }); - } - - QString MaterialEditorWindow::GetDocumentPath(const AZ::Uuid& documentId) const - { - AZStd::string absolutePath; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Handler::GetAbsolutePath); - return absolutePath.c_str(); - } - - void MaterialEditorWindow::OpenTabContextMenu() - { - const QTabBar* tabBar = m_tabWidget->tabBar(); - const QPoint position = tabBar->mapFromGlobal(QCursor::pos()); - const int clickedTabIndex = tabBar->tabAt(position); - const int currentTabIndex = tabBar->currentIndex(); - if (clickedTabIndex >= 0) - { - QMenu tabMenu; - const QString selectActionName = (currentTabIndex == clickedTabIndex) ? "Select in Browser" : "Select"; - tabMenu.addAction(selectActionName, [this, clickedTabIndex]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(clickedTabIndex); - AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentOpened, documentId); - }); - tabMenu.addAction("Close", [this, clickedTabIndex]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(clickedTabIndex); - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseDocument, documentId); - }); - auto closeOthersAction = tabMenu.addAction("Close Others", [this, clickedTabIndex]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(clickedTabIndex); - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseAllDocumentsExcept, documentId); - }); - closeOthersAction->setEnabled(tabBar->count() > 1); - tabMenu.exec(QCursor::pos()); - } + Base::closeEvent(closeEvent); } } // namespace MaterialEditor diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h index b7d0cbf8da..72fd525fce 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h @@ -9,9 +9,7 @@ #pragma once #if !defined(Q_MOC_RUN) -#include -#include -#include +#include AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT #include @@ -29,72 +27,32 @@ namespace MaterialEditor * 3) MaterialPropertyInspector - The user edits the properties of the selected Material. */ class MaterialEditorWindow - : public AtomToolsFramework::AtomToolsMainWindow - , private AtomToolsFramework::AtomToolsDocumentNotificationBus::Handler + : public AtomToolsFramework::AtomToolsDocumentMainWindow { Q_OBJECT public: AZ_CLASS_ALLOCATOR(MaterialEditorWindow, AZ::SystemAllocator, 0); - using Base = AtomToolsFramework::AtomToolsMainWindow; + using Base = AtomToolsFramework::AtomToolsDocumentMainWindow; MaterialEditorWindow(QWidget* parent = 0); ~MaterialEditorWindow(); - private: + protected: void ResizeViewportRenderTarget(uint32_t width, uint32_t height) override; void LockViewportRenderTargetSize(uint32_t width, uint32_t height) override; void UnlockViewportRenderTargetSize() override; - // AtomToolsFramework::AtomToolsDocumentNotificationBus::Handler overrides... - void OnDocumentOpened(const AZ::Uuid& documentId) override; - void OnDocumentClosed(const AZ::Uuid& documentId) override; - void OnDocumentModified(const AZ::Uuid& documentId) override; - void OnDocumentUndoStateChanged(const AZ::Uuid& documentId) override; - void OnDocumentSaved(const AZ::Uuid& documentId) override; - - void CreateMenu() override; - void CreateTabBar() override; - - QString GetDocumentPath(const AZ::Uuid& documentId) const; - - void OpenTabContextMenu() override; + bool GetCreateFileInfo(AZStd::string& openPath, AZStd::string& savePath) override; + bool GetOpenFileInfo(AZStd::string& openPath) override; + QWidget* CreateViewForDocumemt(const AZ::Uuid& documentId) override; + void OpenSettings() override; + void OpenHelp() override; + void OpenAbout() override; void closeEvent(QCloseEvent* closeEvent) override; MaterialViewportWidget* m_materialViewport = nullptr; MaterialEditorToolBar* m_toolBar = nullptr; - - QMenu* m_menuFile = {}; - QAction* m_actionNew = {}; - QAction* m_actionOpen = {}; - QAction* m_actionOpenRecent = {}; - QAction* m_actionClose = {}; - QAction* m_actionCloseAll = {}; - QAction* m_actionCloseOthers = {}; - QAction* m_actionSave = {}; - QAction* m_actionSaveAsCopy = {}; - QAction* m_actionSaveAsChild = {}; - QAction* m_actionSaveAll = {}; - QAction* m_actionExit = {}; - - QMenu* m_menuEdit = {}; - QAction* m_actionUndo = {}; - QAction* m_actionRedo = {}; - QAction* m_actionSettings = {}; - - QMenu* m_menuView = {}; - QAction* m_actionAssetBrowser = {}; - QAction* m_actionInspector = {}; - QAction* m_actionConsole = {}; - QAction* m_actionPythonTerminal = {}; - QAction* m_actionPerfMonitor = {}; - QAction* m_actionViewportSettings = {}; - QAction* m_actionNextTab = {}; - QAction* m_actionPreviousTab = {}; - - QMenu* m_menuHelp = {}; - QAction* m_actionHelp = {}; - QAction* m_actionAbout = {}; }; } // namespace MaterialEditor diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp index 6354f8beba..e44101c300 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp @@ -7,22 +7,13 @@ */ #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 @@ -32,7 +23,7 @@ AZ_POP_DISABLE_WARNING namespace ShaderManagementConsole { ShaderManagementConsoleWindow::ShaderManagementConsoleWindow(QWidget* parent /* = 0 */) - : AtomToolsFramework::AtomToolsMainWindow(parent) + : AtomToolsFramework::AtomToolsDocumentMainWindow(parent) { resize(1280, 1024); @@ -50,9 +41,6 @@ namespace ShaderManagementConsole m_toolBar->setObjectName("ToolBar"); addToolBar(m_toolBar); - CreateMenu(); - CreateTabBar(); - AddDockWidget("Asset Browser", new ShaderManagementConsoleBrowserWidget, Qt::BottomDockWidgetArea, Qt::Vertical); AddDockWidget("Python Terminal", new AzToolsFramework::CScriptTermDialog, Qt::BottomDockWidgetArea, Qt::Horizontal); @@ -61,356 +49,34 @@ namespace ShaderManagementConsole // Restore geometry and show the window mainWindowWrapper->showFromSettings(); - AtomToolsFramework::AtomToolsDocumentNotificationBus::Handler::BusConnect(); OnDocumentOpened(AZ::Uuid::CreateNull()); } ShaderManagementConsoleWindow::~ShaderManagementConsoleWindow() { - AtomToolsFramework::AtomToolsDocumentNotificationBus::Handler::BusDisconnect(); } - void ShaderManagementConsoleWindow::closeEvent(QCloseEvent* closeEvent) - { - bool didClose = true; - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::BroadcastResult(didClose, &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseAllDocuments); - if (!didClose) - { - closeEvent->ignore(); - return; - } - - AtomToolsFramework::AtomToolsMainWindowNotificationBus::Broadcast( - &AtomToolsFramework::AtomToolsMainWindowNotifications::OnMainWindowClosing); - } - - void ShaderManagementConsoleWindow::OnDocumentOpened(const AZ::Uuid& documentId) - { - bool isOpen = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(isOpen, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsOpen); - bool isSavable = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(isSavable, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsSavable); - bool isModified = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(isModified, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsModified); - bool canUndo = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(canUndo, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::CanUndo); - bool canRedo = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(canRedo, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::CanRedo); - AZStd::string absolutePath; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::GetAbsolutePath); - AZStd::string filename; - AzFramework::StringFunc::Path::GetFullFileName(absolutePath.c_str(), filename); - - // Update UI to display the new document - if (!documentId.IsNull() && isOpen) - { - // Create a new tab for the document ID and assign it's label to the file name of the document. - AddTabForDocumentId(documentId, filename, absolutePath, [this, documentId]{ - // The document tab contains a table view. - auto contentWidget = new QTableView(centralWidget()); - contentWidget->setSelectionBehavior(QAbstractItemView::SelectRows); - contentWidget->setModel(CreateDocumentContent(documentId)); - return contentWidget; - }); - } - - UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); - - const bool hasTabs = m_tabWidget->count() > 0; - - // Update menu options - m_actionOpen->setEnabled(true); - m_actionOpenRecent->setEnabled(false); - m_actionClose->setEnabled(hasTabs); - m_actionCloseAll->setEnabled(hasTabs); - m_actionCloseOthers->setEnabled(hasTabs); - - m_actionSave->setEnabled(isOpen && isSavable); - m_actionSaveAsCopy->setEnabled(isOpen && isSavable); - m_actionSaveAll->setEnabled(hasTabs); - - m_actionExit->setEnabled(true); - - m_actionUndo->setEnabled(canUndo); - m_actionRedo->setEnabled(canRedo); - m_actionSettings->setEnabled(false); - - m_actionAssetBrowser->setEnabled(true); - m_actionPythonTerminal->setEnabled(true); - m_actionPreviousTab->setEnabled(m_tabWidget->count() > 1); - m_actionNextTab->setEnabled(m_tabWidget->count() > 1); - - m_actionHelp->setEnabled(false); - m_actionAbout->setEnabled(false); - - activateWindow(); - raise(); - - const QString documentPath = GetDocumentPath(documentId); - if (!documentPath.isEmpty()) - { - SetStatusMessage(tr("Document opened: %1").arg(documentPath)); - } - } - - void ShaderManagementConsoleWindow::OnDocumentClosed(const AZ::Uuid& documentId) - { - RemoveTabForDocumentId(documentId); - SetStatusMessage(tr("Document closed: %1").arg(GetDocumentPath(documentId))); - } - - void ShaderManagementConsoleWindow::OnDocumentModified(const AZ::Uuid& documentId) - { - bool isModified = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(isModified, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsModified); - AZStd::string absolutePath; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::GetAbsolutePath); - AZStd::string filename; - AzFramework::StringFunc::Path::GetFullFileName(absolutePath.c_str(), filename); - UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); - } - - void ShaderManagementConsoleWindow::OnDocumentUndoStateChanged(const AZ::Uuid& documentId) - { - if (documentId == GetDocumentIdFromTab(m_tabWidget->currentIndex())) - { - bool canUndo = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(canUndo, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::CanUndo); - bool canRedo = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(canRedo, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::CanRedo); - m_actionUndo->setEnabled(canUndo); - m_actionRedo->setEnabled(canRedo); - } - } - - void ShaderManagementConsoleWindow::OnDocumentSaved(const AZ::Uuid& documentId) - { - bool isModified = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(isModified, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::IsModified); - AZStd::string absolutePath; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::GetAbsolutePath); - AZStd::string filename; - AzFramework::StringFunc::Path::GetFullFileName(absolutePath.c_str(), filename); - UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); - SetStatusMessage(tr("Document saved: %1").arg(GetDocumentPath(documentId))); - } - - void ShaderManagementConsoleWindow::CreateMenu() - { - Base::CreateMenu(); - - // Generating the main menu manually because it's easier and we will have some dynamic or data driven entries - m_menuFile = menuBar()->addMenu("&File"); - - m_actionOpen = m_menuFile->addAction("&Open...", [this]() { - const AZStd::vector assetTypes = { - }; - - const AZStd::string filePath = AtomToolsFramework::GetOpenFileInfo(assetTypes).absoluteFilePath().toUtf8().constData(); - if (!filePath.empty()) - { - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::OpenDocument, filePath); - } - }, QKeySequence::Open); - - m_actionOpenRecent = m_menuFile->addAction("Open &Recent"); - - m_menuFile->addSeparator(); - - m_actionSave = m_menuFile->addAction("&Save", [this]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); - bool result = false; - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::SaveDocument, documentId); - if (!result) - { - SetStatusError(tr("Document save failed: %1").arg(GetDocumentPath(documentId))); - } - }, QKeySequence::Save); - - m_actionSaveAsCopy = m_menuFile->addAction("Save &As...", [this]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); - const QString documentPath = GetDocumentPath(documentId); - - bool result = false; - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::SaveDocumentAsCopy, - documentId, AtomToolsFramework::GetSaveFileInfo(documentPath).absoluteFilePath().toUtf8().constData()); - if (!result) - { - SetStatusError(tr("Document save failed: %1").arg(GetDocumentPath(documentId))); - } - }, QKeySequence::SaveAs); - - m_actionSaveAll = m_menuFile->addAction("Save A&ll", [this]() { - bool result = false; - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::SaveAllDocuments); - if (!result) - { - SetStatusError(tr("Document save all failed")); - } - }); - - m_menuFile->addSeparator(); - - m_actionClose = m_menuFile->addAction("&Close", [this]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseDocument, documentId); - }, QKeySequence::Close); - - m_actionCloseAll = m_menuFile->addAction("Close All", [this]() { - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseAllDocuments); - }); - - m_actionCloseOthers = m_menuFile->addAction("Close Others", [this]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseAllDocumentsExcept, documentId); - }); - - m_menuFile->addSeparator(); - - m_menuFile->addAction("Run &Python...", [this]() { - const QString script = QFileDialog::getOpenFileName(this, "Run Script", QString(), QString("*.py")); - if (!script.isEmpty()) - { - AzToolsFramework::EditorPythonRunnerRequestBus::Broadcast(&AzToolsFramework::EditorPythonRunnerRequestBus::Events::ExecuteByFilename, script.toUtf8().constData()); - } - }); - - m_menuFile->addSeparator(); - - m_actionExit = m_menuFile->addAction("E&xit", [this]() { - close(); - }, QKeySequence::Quit); - - m_menuEdit = menuBar()->addMenu("&Edit"); - - m_actionUndo = m_menuEdit->addAction("&Undo", [this]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); - bool result = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(result, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::Undo); - if (!result) - { - SetStatusError(tr("Document undo failed: %1").arg(GetDocumentPath(documentId))); - } - }, QKeySequence::Undo); - - m_actionRedo = m_menuEdit->addAction("&Redo", [this]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); - bool result = false; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(result, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::Redo); - if (!result) - { - SetStatusError(tr("Document redo failed: %1").arg(GetDocumentPath(documentId))); - } - }, QKeySequence::Redo); - - m_menuEdit->addSeparator(); - - m_actionSettings = m_menuEdit->addAction("&Settings...", [this]() { - }, QKeySequence::Preferences); - m_actionSettings->setEnabled(false); - - m_menuView = menuBar()->addMenu("&View"); - - m_actionAssetBrowser = m_menuView->addAction("&Asset Browser", [this]() { - const AZStd::string label = "Asset Browser"; - SetDockWidgetVisible(label, !IsDockWidgetVisible(label)); - }); - - m_actionPythonTerminal = m_menuView->addAction("Python &Terminal", [this]() { - const AZStd::string label = "Python Terminal"; - SetDockWidgetVisible(label, !IsDockWidgetVisible(label)); - }); - - - m_menuView->addSeparator(); - - m_actionPreviousTab = m_menuView->addAction("&Previous Tab", [this]() { - SelectPreviousTab(); - }, Qt::CTRL | Qt::SHIFT | Qt::Key_Tab); //QKeySequence::PreviousChild is mapped incorrectly in Qt - - m_actionNextTab = m_menuView->addAction("&Next Tab", [this]() { - SelectNextTab(); - }, Qt::CTRL | Qt::Key_Tab); //QKeySequence::NextChild works as expected but mirroring Previous - - m_menuHelp = menuBar()->addMenu("&Help"); - - m_actionHelp = m_menuHelp->addAction("&Help...", [this]() { - }); - - m_actionAbout = m_menuHelp->addAction("&About...", [this]() { - }); - } - - void ShaderManagementConsoleWindow::CreateTabBar() - { - Base::CreateTabBar(); - - // This signal will be triggered whenever a tab is added, removed, selected, clicked, dragged - // When the last tab is removed tabIndex will be -1 and the document ID will be null - // This should automatically clear the active document - connect(m_tabWidget, &QTabWidget::currentChanged, this, [this](int tabIndex) { - const AZ::Uuid documentId = GetDocumentIdFromTab(tabIndex); - AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentOpened, documentId); - }); - - connect(m_tabWidget, &QTabWidget::tabCloseRequested, this, [this](int tabIndex) { - const AZ::Uuid documentId = GetDocumentIdFromTab(tabIndex); - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseDocument, documentId); - }); - } - - QString ShaderManagementConsoleWindow::GetDocumentPath(const AZ::Uuid& documentId) const - { - AZStd::string absolutePath; - AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Handler::GetAbsolutePath); - return absolutePath.c_str(); - } - - void ShaderManagementConsoleWindow::OpenTabContextMenu() - { - const QTabBar* tabBar = m_tabWidget->tabBar(); - const QPoint position = tabBar->mapFromGlobal(QCursor::pos()); - const int clickedTabIndex = tabBar->tabAt(position); - const int currentTabIndex = tabBar->currentIndex(); - if (clickedTabIndex >= 0) - { - QMenu tabMenu; - const QString selectActionName = (currentTabIndex == clickedTabIndex) ? "Select in Browser" : "Select"; - tabMenu.addAction(selectActionName, [this, clickedTabIndex]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(clickedTabIndex); - AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentOpened, documentId); - }); - tabMenu.addAction("Close", [this, clickedTabIndex]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(clickedTabIndex); - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseDocument, documentId); - }); - auto closeOthersAction = tabMenu.addAction("Close Others", [this, clickedTabIndex]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(clickedTabIndex); - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CloseAllDocumentsExcept, documentId); - }); - closeOthersAction->setEnabled(tabBar->count() > 1); - tabMenu.exec(QCursor::pos()); - } - } - - QStandardItemModel* ShaderManagementConsoleWindow::CreateDocumentContent(const AZ::Uuid& documentId) + QWidget* ShaderManagementConsoleWindow::CreateViewForDocumemt(const AZ::Uuid& documentId) { AZStd::unordered_set optionNames; size_t shaderOptionCount = 0; - ShaderManagementConsoleDocumentRequestBus::EventResult(shaderOptionCount, documentId, &ShaderManagementConsoleDocumentRequestBus::Events::GetShaderOptionCount); + ShaderManagementConsoleDocumentRequestBus::EventResult( + shaderOptionCount, documentId, &ShaderManagementConsoleDocumentRequestBus::Events::GetShaderOptionCount); for (size_t optionIndex = 0; optionIndex < shaderOptionCount; ++optionIndex) { AZ::RPI::ShaderOptionDescriptor shaderOptionDesc; - ShaderManagementConsoleDocumentRequestBus::EventResult(shaderOptionDesc, documentId, &ShaderManagementConsoleDocumentRequestBus::Events::GetShaderOptionDescriptor, optionIndex); + ShaderManagementConsoleDocumentRequestBus::EventResult( + shaderOptionDesc, documentId, &ShaderManagementConsoleDocumentRequestBus::Events::GetShaderOptionDescriptor, optionIndex); const char* optionName = shaderOptionDesc.GetName().GetCStr(); optionNames.insert(optionName); } size_t shaderVariantCount = 0; - ShaderManagementConsoleDocumentRequestBus::EventResult(shaderVariantCount, documentId, &ShaderManagementConsoleDocumentRequestBus::Events::GetShaderVariantCount); + ShaderManagementConsoleDocumentRequestBus::EventResult( + shaderVariantCount, documentId, &ShaderManagementConsoleDocumentRequestBus::Events::GetShaderVariantCount); auto model = new QStandardItemModel(); model->setRowCount(static_cast(shaderVariantCount)); @@ -425,7 +91,8 @@ namespace ShaderManagementConsole for (int variantIndex = 0; variantIndex < shaderVariantCount; ++variantIndex) { AZ::RPI::ShaderVariantListSourceData::VariantInfo shaderVariantInfo; - ShaderManagementConsoleDocumentRequestBus::EventResult(shaderVariantInfo, documentId, &ShaderManagementConsoleDocumentRequestBus::Events::GetShaderVariantInfo, variantIndex); + ShaderManagementConsoleDocumentRequestBus::EventResult( + shaderVariantInfo, documentId, &ShaderManagementConsoleDocumentRequestBus::Events::GetShaderVariantInfo, variantIndex); model->setHeaderData(variantIndex, Qt::Vertical, QString::number(variantIndex)); @@ -442,7 +109,11 @@ namespace ShaderManagementConsole } } - return model; + // The document tab contains a table view. + auto contentWidget = new QTableView(centralWidget()); + contentWidget->setSelectionBehavior(QAbstractItemView::SelectRows); + contentWidget->setModel(model); + return contentWidget; } } // namespace ShaderManagementConsole diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h index 2b682f6c09..e21fe8551d 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h @@ -11,9 +11,7 @@ #if !defined(Q_MOC_RUN) #include #include -#include -#include -#include +#include AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT #include @@ -30,64 +28,20 @@ namespace ShaderManagementConsole * its panels, managing selection of assets, and performing high-level actions like saving. It contains... */ class ShaderManagementConsoleWindow - : public AtomToolsFramework::AtomToolsMainWindow - , private AtomToolsFramework::AtomToolsDocumentNotificationBus::Handler + : public AtomToolsFramework::AtomToolsDocumentMainWindow { Q_OBJECT public: AZ_CLASS_ALLOCATOR(ShaderManagementConsoleWindow, AZ::SystemAllocator, 0); - using Base = AtomToolsFramework::AtomToolsMainWindow; + using Base = AtomToolsFramework::AtomToolsDocumentMainWindow; ShaderManagementConsoleWindow(QWidget* parent = 0); ~ShaderManagementConsoleWindow(); - private: - // AtomToolsFramework::AtomToolsDocumentNotificationBus::Handler overrides... - void OnDocumentOpened(const AZ::Uuid& documentId) override; - void OnDocumentClosed(const AZ::Uuid& documentId) override; - void OnDocumentModified(const AZ::Uuid& documentId) override; - void OnDocumentUndoStateChanged(const AZ::Uuid& documentId) override; - void OnDocumentSaved(const AZ::Uuid& documentId) override; - - void CreateMenu() override; - void CreateTabBar() override; - - QString GetDocumentPath(const AZ::Uuid& documentId) const; - - void OpenTabContextMenu() override; - - void closeEvent(QCloseEvent* closeEvent) override; - - QStandardItemModel* CreateDocumentContent(const AZ::Uuid& documentId); + protected: + QWidget* CreateViewForDocumemt(const AZ::Uuid& documentId) override; ShaderManagementConsoleToolBar* m_toolBar = nullptr; - - QMenu* m_menuFile = {}; - QMenu* m_menuNew = {}; - QAction* m_actionOpen = {}; - QAction* m_actionOpenRecent = {}; - QAction* m_actionClose = {}; - QAction* m_actionCloseAll = {}; - QAction* m_actionCloseOthers = {}; - QAction* m_actionSave = {}; - QAction* m_actionSaveAsCopy = {}; - QAction* m_actionSaveAll = {}; - QAction* m_actionExit = {}; - - QMenu* m_menuEdit = {}; - QAction* m_actionUndo = {}; - QAction* m_actionRedo = {}; - QAction* m_actionSettings = {}; - - QMenu* m_menuView = {}; - QAction* m_actionAssetBrowser = {}; - QAction* m_actionPythonTerminal = {}; - QAction* m_actionNextTab = {}; - QAction* m_actionPreviousTab = {}; - - QMenu* m_menuHelp = {}; - QAction* m_actionHelp = {}; - QAction* m_actionAbout = {}; }; } // namespace ShaderManagementConsole From 2c6e105d27400c1edffb51acb7e2605b740162f0 Mon Sep 17 00:00:00 2001 From: Guthrie Adams Date: Sun, 22 Aug 2021 23:53:20 -0500 Subject: [PATCH 40/53] restored view menu entries for dock widgets renamed document tab functions Signed-off-by: Guthrie Adams --- .../Document/AtomToolsDocumentMainWindow.h | 21 +++-- .../Window/AtomToolsMainWindow.h | 1 + .../Document/AtomToolsDocumentMainWindow.cpp | 90 +++++++++---------- .../Source/Window/AtomToolsMainWindow.cpp | 10 +++ .../Source/Window/MaterialEditorWindow.cpp | 21 +---- .../Code/Source/Window/MaterialEditorWindow.h | 20 ++--- .../Window/ShaderManagementConsoleWindow.cpp | 18 ++-- .../Window/ShaderManagementConsoleWindow.h | 10 +-- 8 files changed, 90 insertions(+), 101 deletions(-) diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h index 883a8833ab..826d2427b1 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h @@ -37,26 +37,25 @@ namespace AtomToolsFramework QString GetDocumentPath(const AZ::Uuid& documentId) const; - AZ::Uuid GetDocumentIdFromTab(const int tabIndex) const; + AZ::Uuid GetDocumentTabId(const int tabIndex) const; - void AddTabForDocumentId( + void AddDocumentTab( const AZ::Uuid& documentId, const AZStd::string& label, const AZStd::string& toolTip); - void RemoveTabForDocumentId(const AZ::Uuid& documentId); + void RemoveDocumentTab(const AZ::Uuid& documentId); - void UpdateTabForDocumentId( + void UpdateDocumentTab( const AZ::Uuid& documentId, const AZStd::string& label, const AZStd::string& toolTip, bool isModified); - void SelectPreviousTab(); + void SelectPrevDocumentTab(); + void SelectNextDocumentTab(); - void SelectNextTab(); - - virtual void OpenTabContextMenu(); - virtual bool GetCreateFileInfo(AZStd::string& openPath, AZStd::string& savePath); - virtual bool GetOpenFileInfo(AZStd::string& openPath); - virtual QWidget* CreateViewForDocumemt(const AZ::Uuid& documentId); + virtual QWidget* CreateDocumentTabView(const AZ::Uuid& documentId); + virtual void OpenDocumentTabContextMenu(); + virtual bool GetCreateDocumentParams(AZStd::string& openPath, AZStd::string& savePath); + virtual bool GetOpenDocumentParams(AZStd::string& openPath); // AtomToolsDocumentNotificationBus::Handler overrides... void OnDocumentOpened(const AZ::Uuid& documentId) override; diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Window/AtomToolsMainWindow.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Window/AtomToolsMainWindow.h index 8d30e42bbb..fab6e2fb01 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Window/AtomToolsMainWindow.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Window/AtomToolsMainWindow.h @@ -54,5 +54,6 @@ namespace AtomToolsFramework QMenu* m_menuHelp = {}; AZStd::unordered_map m_dockWidgets; + AZStd::unordered_map m_dockActions; }; } // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp index 4e7bc8edbd..f78950c2e9 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp @@ -47,7 +47,7 @@ namespace AtomToolsFramework m_actionNew = CreateAction("&New...", [this]() { AZStd::string openPath; AZStd::string savePath; - if (GetCreateFileInfo(openPath, savePath)) + if (GetCreateDocumentParams(openPath, savePath)) { AtomToolsDocumentSystemRequestBus::Broadcast( &AtomToolsDocumentSystemRequestBus::Events::CreateDocumentFromFile, openPath, savePath); @@ -57,7 +57,7 @@ namespace AtomToolsFramework m_actionOpen = CreateAction("&Open...", [this]() { AZStd::string openPath; - if (GetOpenFileInfo(openPath)) + if (GetOpenDocumentParams(openPath)) { AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::OpenDocument, openPath); } @@ -66,7 +66,7 @@ namespace AtomToolsFramework m_menuFile->insertSeparator(insertPostion); m_actionSave = CreateAction("&Save", [this]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); + const AZ::Uuid documentId = GetDocumentTabId(m_tabWidget->currentIndex()); bool result = false; AtomToolsDocumentSystemRequestBus::BroadcastResult(result, &AtomToolsDocumentSystemRequestBus::Events::SaveDocument, documentId); if (!result) @@ -77,7 +77,7 @@ namespace AtomToolsFramework m_menuFile->insertAction(insertPostion, m_actionSave); m_actionSaveAsCopy = CreateAction("Save &As...", [this]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); + const AZ::Uuid documentId = GetDocumentTabId(m_tabWidget->currentIndex()); const QString documentPath = GetDocumentPath(documentId); bool result = false; @@ -91,7 +91,7 @@ namespace AtomToolsFramework m_menuFile->insertAction(insertPostion, m_actionSaveAsCopy); m_actionSaveAsChild = CreateAction("Save As &Child...", [this]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); + const AZ::Uuid documentId = GetDocumentTabId(m_tabWidget->currentIndex()); const QString documentPath = GetDocumentPath(documentId); bool result = false; @@ -116,7 +116,7 @@ namespace AtomToolsFramework m_menuFile->insertSeparator(insertPostion); m_actionClose = CreateAction("&Close", [this]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); + const AZ::Uuid documentId = GetDocumentTabId(m_tabWidget->currentIndex()); AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::CloseDocument, documentId); }, QKeySequence::Close); m_menuFile->insertAction(insertPostion, m_actionClose); @@ -127,7 +127,7 @@ namespace AtomToolsFramework m_menuFile->insertAction(insertPostion, m_actionCloseAll); m_actionCloseOthers = CreateAction("Close Others", [this]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); + const AZ::Uuid documentId = GetDocumentTabId(m_tabWidget->currentIndex()); AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::CloseAllDocumentsExcept, documentId); }); m_menuFile->insertAction(insertPostion, m_actionCloseOthers); @@ -136,7 +136,7 @@ namespace AtomToolsFramework insertPostion = !m_menuEdit->actions().empty() ? m_menuEdit->actions().front() : nullptr; m_actionUndo = CreateAction("&Undo", [this]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); + const AZ::Uuid documentId = GetDocumentTabId(m_tabWidget->currentIndex()); bool result = false; AtomToolsDocumentRequestBus::EventResult(result, documentId, &AtomToolsDocumentRequestBus::Events::Undo); if (!result) @@ -147,7 +147,7 @@ namespace AtomToolsFramework m_menuEdit->insertAction(insertPostion, m_actionUndo); m_actionRedo = CreateAction("&Redo", [this]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(m_tabWidget->currentIndex()); + const AZ::Uuid documentId = GetDocumentTabId(m_tabWidget->currentIndex()); bool result = false; AtomToolsDocumentRequestBus::EventResult(result, documentId, &AtomToolsDocumentRequestBus::Events::Redo); if (!result) @@ -164,12 +164,12 @@ namespace AtomToolsFramework "&Previous Tab", [this]() { - SelectPreviousTab(); + SelectPrevDocumentTab(); }, Qt::CTRL | Qt::SHIFT | Qt::Key_Tab); //QKeySequence::PreviousChild is mapped incorrectly in Qt m_menuView->insertAction(insertPostion, m_actionPreviousTab); m_actionNextTab = CreateAction("&Next Tab", [this]() { - SelectNextTab(); + SelectNextDocumentTab(); }, Qt::CTRL | Qt::Key_Tab); //QKeySequence::NextChild works as expected but mirroring Previous m_menuView->insertAction(insertPostion, m_actionNextTab); m_menuView->insertSeparator(insertPostion); @@ -193,19 +193,19 @@ namespace AtomToolsFramework // When the last tab is removed tabIndex will be -1 and the document ID will be null // This should automatically clear the active document connect(m_tabWidget, &QTabWidget::currentChanged, this, [this](int tabIndex) { - const AZ::Uuid documentId = GetDocumentIdFromTab(tabIndex); + const AZ::Uuid documentId = GetDocumentTabId(tabIndex); AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsDocumentNotificationBus::Events::OnDocumentOpened, documentId); }); connect(m_tabWidget, &QTabWidget::tabCloseRequested, this, [this](int tabIndex) { - const AZ::Uuid documentId = GetDocumentIdFromTab(tabIndex); + const AZ::Uuid documentId = GetDocumentTabId(tabIndex); AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::CloseDocument, documentId); }); // Add context menu for right-clicking on tabs m_tabWidget->setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu); connect(m_tabWidget, &QWidget::customContextMenuRequested, this, [this]() { - OpenTabContextMenu(); + OpenDocumentTabContextMenu(); }); centralWidget()->layout()->addWidget(m_tabWidget); @@ -218,7 +218,7 @@ namespace AtomToolsFramework return absolutePath.c_str(); } - AZ::Uuid AtomToolsDocumentMainWindow::GetDocumentIdFromTab(const int tabIndex) const + AZ::Uuid AtomToolsDocumentMainWindow::GetDocumentTabId(const int tabIndex) const { const QVariant tabData = m_tabWidget->tabBar()->tabData(tabIndex); if (!tabData.isNull()) @@ -232,7 +232,7 @@ namespace AtomToolsFramework return AZ::Uuid::CreateNull(); } - void AtomToolsDocumentMainWindow::AddTabForDocumentId( + void AtomToolsDocumentMainWindow::AddDocumentTab( const AZ::Uuid& documentId, const AZStd::string& label, const AZStd::string& toolTip) { // Blocking signals from the tab bar so the currentChanged signal is not sent while a document is already being opened. @@ -242,7 +242,7 @@ namespace AtomToolsFramework // If a tab for this document already exists then select it instead of creating a new one for (int tabIndex = 0; tabIndex < m_tabWidget->count(); ++tabIndex) { - if (documentId == GetDocumentIdFromTab(tabIndex)) + if (documentId == GetDocumentTabId(tabIndex)) { m_tabWidget->setCurrentIndex(tabIndex); m_tabWidget->repaint(); @@ -250,7 +250,7 @@ namespace AtomToolsFramework } } - const int tabIndex = m_tabWidget->addTab(CreateViewForDocumemt(documentId), label.c_str()); + const int tabIndex = m_tabWidget->addTab(CreateDocumentTabView(documentId), label.c_str()); // The user can manually reorder tabs which will invalidate any association by index. // We need to store the document ID with the tab using the tab instead of a separate mapping. @@ -261,13 +261,13 @@ namespace AtomToolsFramework m_tabWidget->repaint(); } - void AtomToolsDocumentMainWindow::RemoveTabForDocumentId(const AZ::Uuid& documentId) + void AtomToolsDocumentMainWindow::RemoveDocumentTab(const AZ::Uuid& documentId) { // We are not blocking signals here because we want closing tabs to close the associated document // and automatically select the next document. for (int tabIndex = 0; tabIndex < m_tabWidget->count(); ++tabIndex) { - if (documentId == GetDocumentIdFromTab(tabIndex)) + if (documentId == GetDocumentTabId(tabIndex)) { m_tabWidget->removeTab(tabIndex); m_tabWidget->setVisible(m_tabWidget->count() > 0); @@ -277,7 +277,7 @@ namespace AtomToolsFramework } } - void AtomToolsDocumentMainWindow::UpdateTabForDocumentId( + void AtomToolsDocumentMainWindow::UpdateDocumentTab( const AZ::Uuid& documentId, const AZStd::string& label, const AZStd::string& toolTip, bool isModified) { // Whenever a document is opened, saved, or modified we need to update the tab label @@ -288,7 +288,7 @@ namespace AtomToolsFramework // We must iterate over all of the tabs to find the one associated with this document. for (int tabIndex = 0; tabIndex < m_tabWidget->count(); ++tabIndex) { - if (documentId == GetDocumentIdFromTab(tabIndex)) + if (documentId == GetDocumentTabId(tabIndex)) { // We use an asterisk prepended to the file name to denote modified document // Appending is standard and preferred but the tabs elide from the @@ -303,7 +303,7 @@ namespace AtomToolsFramework } } - void AtomToolsDocumentMainWindow::SelectPreviousTab() + void AtomToolsDocumentMainWindow::SelectPrevDocumentTab() { if (m_tabWidget->count() > 1) { @@ -312,7 +312,7 @@ namespace AtomToolsFramework } } - void AtomToolsDocumentMainWindow::SelectNextTab() + void AtomToolsDocumentMainWindow::SelectNextDocumentTab() { if (m_tabWidget->count() > 1) { @@ -320,7 +320,16 @@ namespace AtomToolsFramework } } - void AtomToolsDocumentMainWindow::OpenTabContextMenu() + inline QWidget* AtomToolsDocumentMainWindow::CreateDocumentTabView(const AZ::Uuid& documentId) + { + AZ_UNUSED(documentId); + auto contentWidget = new QWidget(centralWidget()); + contentWidget->setContentsMargins(0, 0, 0, 0); + contentWidget->setFixedSize(0, 0); + return contentWidget; + } + + void AtomToolsDocumentMainWindow::OpenDocumentTabContextMenu() { const QTabBar* tabBar = m_tabWidget->tabBar(); const QPoint position = tabBar->mapFromGlobal(QCursor::pos()); @@ -331,15 +340,15 @@ namespace AtomToolsFramework QMenu tabMenu; const QString selectActionName = (currentTabIndex == clickedTabIndex) ? "Select in Browser" : "Select"; tabMenu.addAction(selectActionName, [this, clickedTabIndex]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(clickedTabIndex); + const AZ::Uuid documentId = GetDocumentTabId(clickedTabIndex); AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsDocumentNotificationBus::Events::OnDocumentOpened, documentId); }); tabMenu.addAction("Close", [this, clickedTabIndex]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(clickedTabIndex); + const AZ::Uuid documentId = GetDocumentTabId(clickedTabIndex); AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::CloseDocument, documentId); }); auto closeOthersAction = tabMenu.addAction("Close Others", [this, clickedTabIndex]() { - const AZ::Uuid documentId = GetDocumentIdFromTab(clickedTabIndex); + const AZ::Uuid documentId = GetDocumentTabId(clickedTabIndex); AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::CloseAllDocumentsExcept, documentId); }); closeOthersAction->setEnabled(tabBar->count() > 1); @@ -347,28 +356,19 @@ namespace AtomToolsFramework } } - inline bool AtomToolsDocumentMainWindow::GetCreateFileInfo(AZStd::string& openPath, AZStd::string& savePath) + inline bool AtomToolsDocumentMainWindow::GetCreateDocumentParams(AZStd::string& openPath, AZStd::string& savePath) { AZ_UNUSED(openPath); AZ_UNUSED(savePath); return false; } - inline bool AtomToolsDocumentMainWindow::GetOpenFileInfo(AZStd::string& openPath) + inline bool AtomToolsDocumentMainWindow::GetOpenDocumentParams(AZStd::string& openPath) { AZ_UNUSED(openPath); return false; } - inline QWidget* AtomToolsDocumentMainWindow::CreateViewForDocumemt(const AZ::Uuid& documentId) - { - AZ_UNUSED(documentId); - auto contentWidget = new QWidget(centralWidget()); - contentWidget->setContentsMargins(0, 0, 0, 0); - contentWidget->setFixedSize(0, 0); - return contentWidget; - } - void AtomToolsDocumentMainWindow::OnDocumentOpened(const AZ::Uuid& documentId) { bool isOpen = false; @@ -390,8 +390,8 @@ namespace AtomToolsFramework if (!documentId.IsNull() && isOpen) { // Create a new tab for the document ID and assign it's label to the file name of the document. - AddTabForDocumentId(documentId, filename, absolutePath); - UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); + AddDocumentTab(documentId, filename, absolutePath); + UpdateDocumentTab(documentId, filename, absolutePath, isModified); } const bool hasTabs = m_tabWidget->count() > 0; @@ -426,7 +426,7 @@ namespace AtomToolsFramework void AtomToolsDocumentMainWindow::OnDocumentClosed(const AZ::Uuid& documentId) { - RemoveTabForDocumentId(documentId); + RemoveDocumentTab(documentId); SetStatusMessage(tr("Document closed: %1").arg(GetDocumentPath(documentId))); } @@ -438,12 +438,12 @@ namespace AtomToolsFramework AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsDocumentRequestBus::Events::GetAbsolutePath); AZStd::string filename; AzFramework::StringFunc::Path::GetFullFileName(absolutePath.c_str(), filename); - UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); + UpdateDocumentTab(documentId, filename, absolutePath, isModified); } void AtomToolsDocumentMainWindow::OnDocumentUndoStateChanged(const AZ::Uuid& documentId) { - if (documentId == GetDocumentIdFromTab(m_tabWidget->currentIndex())) + if (documentId == GetDocumentTabId(m_tabWidget->currentIndex())) { bool canUndo = false; AtomToolsDocumentRequestBus::EventResult(canUndo, documentId, &AtomToolsDocumentRequestBus::Events::CanUndo); @@ -462,7 +462,7 @@ namespace AtomToolsFramework AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsDocumentRequestBus::Events::GetAbsolutePath); AZStd::string filename; AzFramework::StringFunc::Path::GetFullFileName(absolutePath.c_str(), filename); - UpdateTabForDocumentId(documentId, filename, absolutePath, isModified); + UpdateDocumentTab(documentId, filename, absolutePath, isModified); SetStatusMessage(tr("Document saved: %1").arg(GetDocumentPath(documentId))); } diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Window/AtomToolsMainWindow.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Window/AtomToolsMainWindow.cpp index e586dbc588..aeca51230a 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Window/AtomToolsMainWindow.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Window/AtomToolsMainWindow.cpp @@ -72,6 +72,10 @@ namespace AtomToolsFramework addDockWidget(aznumeric_cast(area), dockWidget); resizeDocks({ dockWidget }, { 400 }, aznumeric_cast(orientation)); m_dockWidgets[name] = dockWidget; + + m_dockActions[name] = m_menuView->addAction(name.c_str(), [this, name](){ + SetDockWidgetVisible(name, !IsDockWidgetVisible(name)); + }); return true; } @@ -83,6 +87,12 @@ namespace AtomToolsFramework delete dockWidgetItr->second; m_dockWidgets.erase(dockWidgetItr); } + auto dockActionItr = m_dockActions.find(name); + if (dockActionItr != m_dockActions.end()) + { + delete dockActionItr->second; + m_dockActions.erase(dockActionItr); + } } void AtomToolsMainWindow::SetDockWidgetVisible(const AZStd::string& name, bool visible) diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp index 5f895ba804..0be6925701 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp @@ -98,10 +98,6 @@ namespace MaterialEditor OnDocumentOpened(AZ::Uuid::CreateNull()); } - MaterialEditorWindow::~MaterialEditorWindow() - { - } - void MaterialEditorWindow::ResizeViewportRenderTarget(uint32_t width, uint32_t height) { QSize requestedViewportSize = QSize(width, height) / devicePixelRatioF(); @@ -133,7 +129,7 @@ namespace MaterialEditor m_materialViewport->UnlockRenderTargetSize(); } - bool MaterialEditorWindow::GetCreateFileInfo(AZStd::string& openPath, AZStd::string& savePath) + bool MaterialEditorWindow::GetCreateDocumentParams(AZStd::string& openPath, AZStd::string& savePath) { CreateMaterialDialog createDialog(this); createDialog.adjustSize(); @@ -149,22 +145,13 @@ namespace MaterialEditor return false; } - bool MaterialEditorWindow::GetOpenFileInfo(AZStd::string& openPath) + bool MaterialEditorWindow::GetOpenDocumentParams(AZStd::string& openPath) { const AZStd::vector assetTypes = { azrtti_typeid() }; openPath = AtomToolsFramework::GetOpenFileInfo(assetTypes).absoluteFilePath().toUtf8().constData(); return !openPath.empty(); } - QWidget* MaterialEditorWindow::CreateViewForDocumemt(const AZ::Uuid& documentId) - { - AZ_UNUSED(documentId); - auto contentWidget = new QWidget(centralWidget()); - contentWidget->setContentsMargins(0, 0, 0, 0); - contentWidget->setFixedSize(0, 0); - return contentWidget; - } - void MaterialEditorWindow::OpenSettings() { SettingsDialog dialog(this); @@ -177,10 +164,6 @@ namespace MaterialEditor dialog.exec(); } - void MaterialEditorWindow::OpenAbout() - { - } - void MaterialEditorWindow::closeEvent(QCloseEvent* closeEvent) { // Capture docking state before shutdown diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h index 72fd525fce..bed2aa34e4 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h @@ -19,13 +19,11 @@ AZ_POP_DISABLE_WARNING namespace MaterialEditor { - /** - * MaterialEditorWindow is the main class. Its responsibility is limited to initializing and connecting - * its panels, managing selection of assets, and performing high-level actions like saving. It contains... - * 1) MaterialBrowser - The user browses for Material (.material) assets. - * 2) MaterialViewport - The user can see the selected Material applied to a model. - * 3) MaterialPropertyInspector - The user edits the properties of the selected Material. - */ + //! MaterialEditorWindow is the main class. Its responsibility is limited to initializing and connecting + //! its panels, managing selection of assets, and performing high-level actions like saving. It contains... + //! 1) MaterialBrowser - The user browses for Material (.material) assets. + //! 2) MaterialViewport - The user can see the selected Material applied to a model. + //! 3) MaterialPropertyInspector - The user edits the properties of the selected Material. class MaterialEditorWindow : public AtomToolsFramework::AtomToolsDocumentMainWindow { @@ -36,19 +34,17 @@ namespace MaterialEditor using Base = AtomToolsFramework::AtomToolsDocumentMainWindow; MaterialEditorWindow(QWidget* parent = 0); - ~MaterialEditorWindow(); + ~MaterialEditorWindow() = default; protected: void ResizeViewportRenderTarget(uint32_t width, uint32_t height) override; void LockViewportRenderTargetSize(uint32_t width, uint32_t height) override; void UnlockViewportRenderTargetSize() override; - bool GetCreateFileInfo(AZStd::string& openPath, AZStd::string& savePath) override; - bool GetOpenFileInfo(AZStd::string& openPath) override; - QWidget* CreateViewForDocumemt(const AZ::Uuid& documentId) override; + bool GetCreateDocumentParams(AZStd::string& openPath, AZStd::string& savePath) override; + bool GetOpenDocumentParams(AZStd::string& openPath) override; void OpenSettings() override; void OpenHelp() override; - void OpenAbout() override; void closeEvent(QCloseEvent* closeEvent) override; diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp index e44101c300..29dafe99fe 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp @@ -5,12 +5,12 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ - + +#include +#include #include #include #include -#include -#include #include AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT @@ -49,14 +49,16 @@ namespace ShaderManagementConsole // Restore geometry and show the window mainWindowWrapper->showFromSettings(); + // Disable unused actions + m_actionNew->setVisible(false); + m_actionNew->setEnabled(false); + m_actionSaveAsChild->setVisible(false); + m_actionSaveAsChild->setEnabled(false); + OnDocumentOpened(AZ::Uuid::CreateNull()); } - ShaderManagementConsoleWindow::~ShaderManagementConsoleWindow() - { - } - - QWidget* ShaderManagementConsoleWindow::CreateViewForDocumemt(const AZ::Uuid& documentId) + QWidget* ShaderManagementConsoleWindow::CreateDocumentTabView(const AZ::Uuid& documentId) { AZStd::unordered_set optionNames; diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h index e21fe8551d..3ba122674a 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h @@ -23,10 +23,8 @@ AZ_POP_DISABLE_WARNING namespace ShaderManagementConsole { - /** - * ShaderManagementConsoleWindow is the main class. Its responsibility is limited to initializing and connecting - * its panels, managing selection of assets, and performing high-level actions like saving. It contains... - */ + //! ShaderManagementConsoleWindow is the main class. Its responsibility is limited to initializing and connecting + //! its panels, managing selection of assets, and performing high-level actions like saving. It contains... class ShaderManagementConsoleWindow : public AtomToolsFramework::AtomToolsDocumentMainWindow { @@ -37,10 +35,10 @@ namespace ShaderManagementConsole using Base = AtomToolsFramework::AtomToolsDocumentMainWindow; ShaderManagementConsoleWindow(QWidget* parent = 0); - ~ShaderManagementConsoleWindow(); + ~ShaderManagementConsoleWindow() = default; protected: - QWidget* CreateViewForDocumemt(const AZ::Uuid& documentId) override; + QWidget* CreateDocumentTabView(const AZ::Uuid& documentId) override; ShaderManagementConsoleToolBar* m_toolBar = nullptr; }; From b38fc80418099e136f1e3f5bc2b43765e447b181 Mon Sep 17 00:00:00 2001 From: nggieber Date: Mon, 23 Aug 2021 07:15:44 -0700 Subject: [PATCH 41/53] Tabs are shown gray background when tab focused, Reworked ProjectsScreen to reuse Widgets instead of recreating it on each update, Sorting projects alphabetically Signed-off-by: nggieber --- .../Resources/ProjectManager.qss | 24 +- .../Source/ProjectBuilderController.cpp | 5 + .../Source/ProjectButtonWidget.cpp | 96 +++---- .../Source/ProjectButtonWidget.h | 33 +-- .../ProjectManager/Source/ProjectsScreen.cpp | 237 +++++++++++------- .../ProjectManager/Source/ProjectsScreen.h | 7 +- .../ProjectManager/Source/ScreensCtrl.cpp | 1 + .../Source/UpdateProjectCtrl.cpp | 1 + 8 files changed, 234 insertions(+), 170 deletions(-) diff --git a/Code/Tools/ProjectManager/Resources/ProjectManager.qss b/Code/Tools/ProjectManager/Resources/ProjectManager.qss index e18bf34931..1bd261da00 100644 --- a/Code/Tools/ProjectManager/Resources/ProjectManager.qss +++ b/Code/Tools/ProjectManager/Resources/ProjectManager.qss @@ -20,8 +20,7 @@ QPushButton:focus { QTabBar { background-color: transparent; } -QTabWidget::tab-bar -{ +QTabWidget::tab-bar { left: 78px; /* make room for the logo */ } QTabBar::tab { @@ -32,32 +31,35 @@ QTabBar::tab { margin-right:40px; border-bottom: 3px solid transparent; } -QTabBar::tab:text -{ +QTabBar::tab:text { text-align:left; } QTabWidget::pane { background-color: #333333; border:0 none; } -QTabBar::tab:selected -{ +QTabBar::tab:selected { + background-color: transparent; border-bottom: 3px solid #1e70eb; color: #1e70eb; + font-weight: 500; } -QTabBar::tab:hover -{ +QTabBar::tab:hover { color: #1e70eb; + font-weight: 500; } -QTabBar::tab:pressed -{ +QTabBar::tab:pressed { color: #0e60eb; } QTabBar::focus { outline: 0px; outline: none; outline-style: none; - } +} +QTabBar::tab:focus { + background-color: #525252; + color: #4082eb; +} /************** General (Forms) **************/ diff --git a/Code/Tools/ProjectManager/Source/ProjectBuilderController.cpp b/Code/Tools/ProjectManager/Source/ProjectBuilderController.cpp index 0ff963e539..7981e9d758 100644 --- a/Code/Tools/ProjectManager/Source/ProjectBuilderController.cpp +++ b/Code/Tools/ProjectManager/Source/ProjectBuilderController.cpp @@ -52,6 +52,7 @@ namespace O3DE::ProjectManager if (projectButton) { + projectButton->SetProjectBuilding(); projectButton->SetProjectButtonAction(tr("Cancel Build"), [this] { HandleCancel(); }); if (m_lastProgress != 0) @@ -111,6 +112,10 @@ namespace O3DE::ProjectManager emit Done(false); return; } + else + { + m_projectInfo.m_buildFailed = false; + } emit Done(true); } diff --git a/Code/Tools/ProjectManager/Source/ProjectButtonWidget.cpp b/Code/Tools/ProjectManager/Source/ProjectButtonWidget.cpp index 82b4e8d84a..5bae3b807a 100644 --- a/Code/Tools/ProjectManager/Source/ProjectButtonWidget.cpp +++ b/Code/Tools/ProjectManager/Source/ProjectButtonWidget.cpp @@ -162,22 +162,9 @@ namespace O3DE::ProjectManager QDesktopServices::openUrl(m_logUrl); } - ProjectButton::ProjectButton(const ProjectInfo& projectInfo, QWidget* parent, bool processing) + ProjectButton::ProjectButton(const ProjectInfo& projectInfo, QWidget* parent) : QFrame(parent) , m_projectInfo(projectInfo) - { - BaseSetup(); - if (processing) - { - ProcessingSetup(); - } - else - { - ReadySetup(); - } - } - - void ProjectButton::BaseSetup() { setObjectName("projectButton"); @@ -199,50 +186,63 @@ namespace O3DE::ProjectManager } m_projectImageLabel->setPixmap(QPixmap(projectPreviewPath).scaled(m_projectImageLabel->size(), Qt::KeepAspectRatioByExpanding)); - m_projectFooter = new QFrame(this); + QFrame* projectFooter = new QFrame(this); QHBoxLayout* hLayout = new QHBoxLayout(); hLayout->setContentsMargins(0, 0, 0, 0); - m_projectFooter->setLayout(hLayout); + projectFooter->setLayout(hLayout); { QLabel* projectNameLabel = new QLabel(m_projectInfo.GetProjectDisplayName(), this); hLayout->addWidget(projectNameLabel); + + QMenu* menu = new QMenu(this); + menu->addAction(tr("Edit Project Settings..."), this, [this]() { emit EditProject(m_projectInfo.m_path); }); + menu->addAction(tr("Build"), this, [this]() { emit BuildProject(m_projectInfo); }); + menu->addSeparator(); + menu->addAction(tr("Open Project folder..."), this, [this]() + { + AzQtComponents::ShowFileOnDesktop(m_projectInfo.m_path); + }); + menu->addSeparator(); + menu->addAction(tr("Duplicate"), this, [this]() { emit CopyProject(m_projectInfo); }); + menu->addSeparator(); + menu->addAction(tr("Remove from O3DE"), this, [this]() { emit RemoveProject(m_projectInfo.m_path); }); + menu->addAction(tr("Delete this Project"), this, [this]() { emit DeleteProject(m_projectInfo.m_path); }); + + m_projectMenuButton = new QPushButton(this); + m_projectMenuButton->setObjectName("projectMenuButton"); + m_projectMenuButton->setMenu(menu); + hLayout->addWidget(m_projectMenuButton); } - vLayout->addWidget(m_projectFooter); + vLayout->addWidget(projectFooter); + + connect(m_projectImageLabel->GetOpenEditorButton(), &QPushButton::clicked, [this](){ emit OpenProject(m_projectInfo.m_path); }); } - void ProjectButton::ProcessingSetup() + const ProjectInfo& ProjectButton::GetProjectInfo() const { - m_projectImageLabel->SetEnabled(false); - m_projectImageLabel->SetOverlayText(tr("Processing...\n\n")); + return m_projectInfo; + } + + void ProjectButton::RestoreDefaultState() + { + m_projectImageLabel->SetEnabled(true); + m_projectImageLabel->SetOverlayText(""); + m_projectMenuButton->setVisible(true); QProgressBar* progressBar = m_projectImageLabel->GetProgressBar(); - progressBar->setVisible(true); + progressBar->setVisible(false); progressBar->setValue(0); - } - void ProjectButton::ReadySetup() - { - connect(m_projectImageLabel->GetOpenEditorButton(), &QPushButton::clicked, [this](){ emit OpenProject(m_projectInfo.m_path); }); + QPushButton* projectActionButton = m_projectImageLabel->GetActionButton(); + projectActionButton->setVisible(false); + if (m_actionButtonConnection) + { + disconnect(m_actionButtonConnection); + } - QMenu* menu = new QMenu(this); - menu->addAction(tr("Edit Project Settings..."), this, [this]() { emit EditProject(m_projectInfo.m_path); }); - menu->addAction(tr("Build"), this, [this]() { emit BuildProject(m_projectInfo); }); - menu->addSeparator(); - menu->addAction(tr("Open Project folder..."), this, [this]() - { - AzQtComponents::ShowFileOnDesktop(m_projectInfo.m_path); - }); - menu->addSeparator(); - menu->addAction(tr("Duplicate"), this, [this]() { emit CopyProject(m_projectInfo); }); - menu->addSeparator(); - menu->addAction(tr("Remove from O3DE"), this, [this]() { emit RemoveProject(m_projectInfo.m_path); }); - menu->addAction(tr("Delete this Project"), this, [this]() { emit DeleteProject(m_projectInfo.m_path); }); - - QPushButton* projectMenuButton = new QPushButton(this); - projectMenuButton->setObjectName("projectMenuButton"); - projectMenuButton->setMenu(menu); - m_projectFooter->layout()->addWidget(projectMenuButton); + m_projectImageLabel->GetWarningIcon()->setVisible(false); + m_projectImageLabel->GetWarningLabel()->setVisible(false); } void ProjectButton::SetProjectButtonAction(const QString& text, AZStd::function lambda) @@ -292,9 +292,15 @@ namespace O3DE::ProjectManager SetProjectButtonAction(tr("Build Project"), [this]() { emit BuildProject(m_projectInfo); }); } - void ProjectButton::BuildThisProject() + void ProjectButton::SetProjectBuilding() { - emit BuildProject(m_projectInfo); + m_projectImageLabel->SetEnabled(false); + m_projectImageLabel->SetOverlayText(tr("Building...\n\n")); + m_projectMenuButton->setVisible(false); + + QProgressBar* progressBar = m_projectImageLabel->GetProgressBar(); + progressBar->setVisible(true); + progressBar->setValue(0); } void ProjectButton::SetLaunchButtonEnabled(bool enabled) diff --git a/Code/Tools/ProjectManager/Source/ProjectButtonWidget.h b/Code/Tools/ProjectManager/Source/ProjectButtonWidget.h index ff352e0afd..9f64b74eab 100644 --- a/Code/Tools/ProjectManager/Source/ProjectButtonWidget.h +++ b/Code/Tools/ProjectManager/Source/ProjectButtonWidget.h @@ -56,13 +56,14 @@ namespace O3DE::ProjectManager void OnLinkActivated(const QString& link); private: - QVBoxLayout* m_buildOverlayLayout; - QLabel* m_overlayLabel; - QProgressBar* m_progressBar; - QPushButton* m_openEditorButton; - QPushButton* m_actionButton; - QLabel* m_warningText; - QLabel* m_warningIcon; + QVBoxLayout* m_buildOverlayLayout = nullptr; + QLabel* m_overlayLabel = nullptr; + QProgressBar* m_progressBar = nullptr; + QPushButton* m_openEditorButton = nullptr; + QPushButton* m_actionButton = nullptr; + QLabel* m_warningText = nullptr; + QLabel* m_warningIcon = nullptr; + QUrl m_logUrl; bool m_enabled = true; }; @@ -73,13 +74,18 @@ namespace O3DE::ProjectManager Q_OBJECT // AUTOMOC public: - explicit ProjectButton(const ProjectInfo& m_projectInfo, QWidget* parent = nullptr, bool processing = false); + explicit ProjectButton(const ProjectInfo& m_projectInfo, QWidget* parent = nullptr); ~ProjectButton() = default; + const ProjectInfo& GetProjectInfo() const; + + void RestoreDefaultState(); + void SetProjectButtonAction(const QString& text, AZStd::function lambda); void SetProjectBuildButtonAction(); void SetBuildLogsLink(const QUrl& logUrl); void ShowBuildFailed(bool show, const QUrl& logUrl); + void SetProjectBuilding(); void SetLaunchButtonEnabled(bool enabled); void SetButtonOverlayText(const QString& text); @@ -95,17 +101,14 @@ namespace O3DE::ProjectManager void BuildProject(const ProjectInfo& projectInfo); private: - void BaseSetup(); - void ProcessingSetup(); - void ReadySetup(); void enterEvent(QEvent* event) override; void leaveEvent(QEvent* event) override; - void BuildThisProject(); ProjectInfo m_projectInfo; - LabelButton* m_projectImageLabel; - QFrame* m_projectFooter; - QLayout* m_requiresBuildLayout; + + LabelButton* m_projectImageLabel = nullptr; + QPushButton* m_projectMenuButton = nullptr; + QLayout* m_requiresBuildLayout = nullptr; QMetaObject::Connection m_actionButtonConnection; }; diff --git a/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp b/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp index e27eedd122..27e39926e4 100644 --- a/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp +++ b/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp @@ -68,9 +68,7 @@ namespace O3DE::ProjectManager } ProjectsScreen::~ProjectsScreen() - { - delete m_currentBuilder; } QFrame* ProjectsScreen::CreateFirstTimeContent() @@ -114,10 +112,8 @@ namespace O3DE::ProjectManager return frame; } - QFrame* ProjectsScreen::CreateProjectsContent(QString buildProjectPath, ProjectButton** projectButton) + QFrame* ProjectsScreen::CreateProjectsContent() { - RemoveInvalidProjects(); - QFrame* frame = new QFrame(this); frame->setObjectName("projectsContent"); { @@ -126,7 +122,7 @@ namespace O3DE::ProjectManager layout->setContentsMargins(0, 0, 0, 0); frame->setLayout(layout); - QFrame* header = new QFrame(this); + QFrame* header = new QFrame(frame); QHBoxLayout* headerLayout = new QHBoxLayout(); { QLabel* titleLabel = new QLabel(tr("My Projects"), this); @@ -150,87 +146,34 @@ namespace O3DE::ProjectManager layout->addWidget(header); - // Get all projects and create a horizontal scrolling list of them - auto projectsResult = PythonBindingsInterface::Get()->GetProjects(); - if (projectsResult.IsSuccess() && !projectsResult.GetValue().isEmpty()) - { - QScrollArea* projectsScrollArea = new QScrollArea(this); - QWidget* scrollWidget = new QWidget(); + QScrollArea* projectsScrollArea = new QScrollArea(this); + QWidget* scrollWidget = new QWidget(); - FlowLayout* flowLayout = new FlowLayout(0, s_spacerSize, s_spacerSize); - scrollWidget->setLayout(flowLayout); + m_projectsFlowLayout = new FlowLayout(0, s_spacerSize, s_spacerSize); + scrollWidget->setLayout(m_projectsFlowLayout); - projectsScrollArea->setWidget(scrollWidget); - projectsScrollArea->setWidgetResizable(true); + projectsScrollArea->setWidget(scrollWidget); + projectsScrollArea->setWidgetResizable(true); - QVector nonProcessingProjects; - buildProjectPath = QDir::fromNativeSeparators(buildProjectPath); - for (auto& project : projectsResult.GetValue()) - { - if (projectButton && !*projectButton) - { - if (QDir::fromNativeSeparators(project.m_path) == buildProjectPath) - { - *projectButton = CreateProjectButton(project, flowLayout, true); - continue; - } - } + ResetProjectsContent(); - nonProcessingProjects.append(project); - } - - for (auto& project : nonProcessingProjects) - { - ProjectButton* projectButtonWidget = CreateProjectButton(project, flowLayout); - - if (BuildQueueContainsProject(project.m_path)) - { - projectButtonWidget->SetProjectButtonAction(tr("Cancel Queued Build"), - [this, project] - { - UnqueueBuildProject(project); - SuggestBuildProjectMsg(project, false); - }); - } - else if (RequiresBuildProjectIterator(project.m_path) != m_requiresBuild.end()) - { - auto buildProjectIterator = RequiresBuildProjectIterator(project.m_path); - if (buildProjectIterator != m_requiresBuild.end()) - { - if (buildProjectIterator->m_buildFailed) - { - projectButtonWidget->ShowBuildFailed(true, buildProjectIterator->m_logUrl); - } - else - { - projectButtonWidget->SetProjectBuildButtonAction(); - } - } - - } - } - - layout->addWidget(projectsScrollArea); - } + layout->addWidget(projectsScrollArea); } return frame; } - ProjectButton* ProjectsScreen::CreateProjectButton(ProjectInfo& project, QLayout* flowLayout, bool processing) + ProjectButton* ProjectsScreen::CreateProjectButton(const ProjectInfo& project) { - ProjectButton* projectButton = new ProjectButton(project, this, processing); + ProjectButton* projectButton = new ProjectButton(project, this); + m_projectButtons.insert(project.m_path, projectButton); + m_projectsFlowLayout->addWidget(projectButton); - flowLayout->addWidget(projectButton); - - if (!processing) - { - connect(projectButton, &ProjectButton::OpenProject, this, &ProjectsScreen::HandleOpenProject); - connect(projectButton, &ProjectButton::EditProject, this, &ProjectsScreen::HandleEditProject); - connect(projectButton, &ProjectButton::CopyProject, this, &ProjectsScreen::HandleCopyProject); - connect(projectButton, &ProjectButton::RemoveProject, this, &ProjectsScreen::HandleRemoveProject); - connect(projectButton, &ProjectButton::DeleteProject, this, &ProjectsScreen::HandleDeleteProject); - } + connect(projectButton, &ProjectButton::OpenProject, this, &ProjectsScreen::HandleOpenProject); + connect(projectButton, &ProjectButton::EditProject, this, &ProjectsScreen::HandleEditProject); + connect(projectButton, &ProjectButton::CopyProject, this, &ProjectsScreen::HandleCopyProject); + connect(projectButton, &ProjectButton::RemoveProject, this, &ProjectsScreen::HandleRemoveProject); + connect(projectButton, &ProjectButton::DeleteProject, this, &ProjectsScreen::HandleDeleteProject); connect(projectButton, &ProjectButton::BuildProject, this, &ProjectsScreen::QueueBuildProject); return projectButton; @@ -238,29 +181,128 @@ namespace O3DE::ProjectManager void ProjectsScreen::ResetProjectsContent() { - // refresh the projects content by re-creating it for now - if (m_projectsContent) + RemoveInvalidProjects(); + + // Get all projects and create a vertical scrolling list of them + // Sort building and queued projects first + auto projectsResult = PythonBindingsInterface::Get()->GetProjects(); + if (projectsResult.IsSuccess() && !projectsResult.GetValue().isEmpty()) { - m_stack->removeWidget(m_projectsContent); - m_projectsContent->deleteLater(); + QVector projectsVector = projectsResult.GetValue(); + // If a project path is in this set then the button for it will be kept + QSet keepProject; + for (const ProjectInfo& project : projectsVector) + { + keepProject.insert(project.m_path); + } + + // Clear flow and delete buttons for removed projects + auto projectButtonsIter = m_projectButtons.begin(); + while (projectButtonsIter != m_projectButtons.end()) + { + m_projectsFlowLayout->removeWidget(projectButtonsIter.value()); + + if (!keepProject.contains(projectButtonsIter.key())) + { + projectButtonsIter = m_projectButtons.erase(projectButtonsIter); + } + else + { + ++projectButtonsIter; + } + } + + QString buildProjectPath = ""; + if (m_currentBuilder) + { + buildProjectPath = m_currentBuilder->GetProjectInfo().m_path; + } + + // Put currently building project in front, then queued projects, then sorts alphabetically + std::sort(projectsVector.begin(), projectsVector.end(), [buildProjectPath, this](const ProjectInfo& arg1, const ProjectInfo& arg2) + { + if (arg1.m_path == buildProjectPath) + { + return true; + } + else if (arg2.m_path == buildProjectPath) + { + return false; + } + + bool arg1InBuildQueue = BuildQueueContainsProject(arg1.m_path); + bool arg2InBuildQueue = BuildQueueContainsProject(arg2.m_path); + if (arg1InBuildQueue && !arg2InBuildQueue) + { + return true; + } + else if (!arg1InBuildQueue && arg2InBuildQueue) + { + return false; + } + else + { + return arg1.m_displayName.toLower() < arg2.m_displayName.toLower(); + } + }); + + // Add any missing project buttons and restore buttons to default state + for (const ProjectInfo& project : projectsVector) + { + if (!m_projectButtons.contains(project.m_path)) + { + m_projectButtons.insert(project.m_path, CreateProjectButton(project)); + } + else + { + auto projectButtonIter = m_projectButtons.find(project.m_path); + if (projectButtonIter != m_projectButtons.end()) + { + projectButtonIter.value()->RestoreDefaultState(); + m_projectsFlowLayout->addWidget(projectButtonIter.value()); + } + } + } + + // Setup building button again + auto buildProjectIter = m_projectButtons.find(buildProjectPath); + if (buildProjectIter != m_projectButtons.end()) + { + m_currentBuilder->SetProjectButton(buildProjectIter.value()); + } + + for (const ProjectInfo& project : m_buildQueue) + { + auto projectIter = m_projectButtons.find(project.m_path); + if (projectIter != m_projectButtons.end()) + { + projectIter.value()->SetProjectButtonAction( + tr("Cancel Queued Build"), + [this, project] + { + UnqueueBuildProject(project); + SuggestBuildProjectMsg(project, false); + }); + } + } + + for (const ProjectInfo& project : m_requiresBuild) + { + auto projectIter = m_projectButtons.find(project.m_path); + if (projectIter != m_projectButtons.end()) + { + if (project.m_buildFailed) + { + projectIter.value()->ShowBuildFailed(true, project.m_logUrl); + } + else + { + projectIter.value()->SetProjectBuildButtonAction(); + } + } + } } - m_background.load(":/Backgrounds/DefaultBackground.jpg"); - - // Make sure to update builder with latest Project Button - if (m_currentBuilder) - { - ProjectButton* projectButtonPtr = nullptr; - - m_projectsContent = CreateProjectsContent(m_currentBuilder->GetProjectInfo().m_path, &projectButtonPtr); - m_currentBuilder->SetProjectButton(projectButtonPtr); - } - else - { - m_projectsContent = CreateProjectsContent(); - } - - m_stack->addWidget(m_projectsContent); m_stack->setCurrentWidget(m_projectsContent); } @@ -466,7 +508,7 @@ namespace O3DE::ProjectManager if (m_buildQueue.empty() && !m_currentBuilder) { StartProjectBuild(projectInfo); - // Projects Content is already reset in fuction + // Projects Content is already reset in function } else { @@ -491,6 +533,7 @@ namespace O3DE::ProjectManager } else { + m_background.load(":/Backgrounds/DefaultBackground.jpg"); ResetProjectsContent(); } } diff --git a/Code/Tools/ProjectManager/Source/ProjectsScreen.h b/Code/Tools/ProjectManager/Source/ProjectsScreen.h index 45605ab678..859f8d0eae 100644 --- a/Code/Tools/ProjectManager/Source/ProjectsScreen.h +++ b/Code/Tools/ProjectManager/Source/ProjectsScreen.h @@ -18,6 +18,7 @@ QT_FORWARD_DECLARE_CLASS(QPaintEvent) QT_FORWARD_DECLARE_CLASS(QFrame) QT_FORWARD_DECLARE_CLASS(QStackedWidget) QT_FORWARD_DECLARE_CLASS(QLayout) +QT_FORWARD_DECLARE_CLASS(FlowLayout) namespace O3DE::ProjectManager { @@ -59,8 +60,8 @@ namespace O3DE::ProjectManager private: QFrame* CreateFirstTimeContent(); - QFrame* CreateProjectsContent(QString buildProjectPath = "", ProjectButton** projectButton = nullptr); - ProjectButton* CreateProjectButton(ProjectInfo& project, QLayout* flowLayout, bool processing = false); + QFrame* CreateProjectsContent(); + ProjectButton* CreateProjectButton(const ProjectInfo& project); void ResetProjectsContent(); bool ShouldDisplayFirstTimeContent(); bool RemoveInvalidProjects(); @@ -75,7 +76,9 @@ namespace O3DE::ProjectManager QPixmap m_background; QFrame* m_firstTimeContent = nullptr; QFrame* m_projectsContent = nullptr; + FlowLayout* m_projectsFlowLayout = nullptr; QStackedWidget* m_stack = nullptr; + QHash m_projectButtons; QList m_requiresBuild; QQueue m_buildQueue; ProjectBuilderController* m_currentBuilder = nullptr; diff --git a/Code/Tools/ProjectManager/Source/ScreensCtrl.cpp b/Code/Tools/ProjectManager/Source/ScreensCtrl.cpp index 30b8ef1d34..df0bdb29f4 100644 --- a/Code/Tools/ProjectManager/Source/ScreensCtrl.cpp +++ b/Code/Tools/ProjectManager/Source/ScreensCtrl.cpp @@ -30,6 +30,7 @@ namespace O3DE::ProjectManager // add a tab widget at the bottom of the stack m_tabWidget = new QTabWidget(); + m_tabWidget->tabBar()->setFocusPolicy(Qt::TabFocus); m_screenStack->addWidget(m_tabWidget); connect(m_tabWidget, &QTabWidget::currentChanged, this, &ScreensCtrl::TabChanged); } diff --git a/Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp b/Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp index 6aba261cd2..e1b6d740e2 100644 --- a/Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp +++ b/Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp @@ -54,6 +54,7 @@ namespace O3DE::ProjectManager QTabWidget* tabWidget = new QTabWidget(); tabWidget->setObjectName("projectSettingsTab"); tabWidget->tabBar()->setObjectName("projectSettingsTabBar"); + tabWidget->tabBar()->setFocusPolicy(Qt::TabFocus); tabWidget->addTab(m_updateSettingsScreen, tr("General")); QPushButton* gemsButton = new QPushButton(tr("Configure Gems"), this); From 6eb92737632d244a126b7fb954110886a9742039 Mon Sep 17 00:00:00 2001 From: nggieber Date: Mon, 23 Aug 2021 08:28:49 -0700 Subject: [PATCH 42/53] Improves Gem Catalog Search (searches, Name, DisplayName, Creator, Summary, and Features), Gem Display Names now used in Gem Catalog Signed-off-by: nggieber --- .../GemCatalog/GemCatalogHeaderWidget.cpp | 2 +- .../Source/GemCatalog/GemCatalogScreen.cpp | 4 ++-- .../Source/GemCatalog/GemInspector.cpp | 2 +- .../Source/GemCatalog/GemItemDelegate.cpp | 2 +- .../Source/GemCatalog/GemModel.cpp | 17 ++++++++++++++- .../Source/GemCatalog/GemModel.h | 2 ++ .../GemCatalog/GemRequirementDelegate.cpp | 2 +- .../GemCatalog/GemSortFilterProxyModel.cpp | 21 +++++++++++++++++-- 8 files changed, 43 insertions(+), 9 deletions(-) diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogHeaderWidget.cpp b/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogHeaderWidget.cpp index ac8cf5d794..909cd93cda 100644 --- a/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogHeaderWidget.cpp +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogHeaderWidget.cpp @@ -117,7 +117,7 @@ namespace O3DE::ProjectManager gemNames.reserve(gems.size()); for (const QModelIndex& modelIndex : gems) { - gemNames.push_back(GemModel::GetName(modelIndex)); + gemNames.push_back(GemModel::GetDisplayName(modelIndex)); } return gemNames; } diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogScreen.cpp b/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogScreen.cpp index 863f611ec8..04d4d6999b 100644 --- a/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogScreen.cpp +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogScreen.cpp @@ -156,7 +156,7 @@ namespace O3DE::ProjectManager if (!result.IsSuccess()) { QMessageBox::critical(nullptr, "Operation failed", - QString("Cannot add gem %1 to project.\n\nError:\n%2").arg(GemModel::GetName(modelIndex), result.GetError().c_str())); + QString("Cannot add gem %1 to project.\n\nError:\n%2").arg(GemModel::GetDisplayName(modelIndex), result.GetError().c_str())); return false; } @@ -169,7 +169,7 @@ namespace O3DE::ProjectManager if (!result.IsSuccess()) { QMessageBox::critical(nullptr, "Operation failed", - QString("Cannot remove gem %1 from project.\n\nError:\n%2").arg(GemModel::GetName(modelIndex), result.GetError().c_str())); + QString("Cannot remove gem %1 from project.\n\nError:\n%2").arg(GemModel::GetDisplayName(modelIndex), result.GetError().c_str())); return false; } diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemInspector.cpp b/Code/Tools/ProjectManager/Source/GemCatalog/GemInspector.cpp index 6c1f5f6fec..6dd6c52612 100644 --- a/Code/Tools/ProjectManager/Source/GemCatalog/GemInspector.cpp +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemInspector.cpp @@ -58,7 +58,7 @@ namespace O3DE::ProjectManager m_mainWidget->hide(); } - m_nameLabel->setText(m_model->GetName(modelIndex)); + m_nameLabel->setText(m_model->GetDisplayName(modelIndex)); m_creatorLabel->setText(m_model->GetCreator(modelIndex)); m_summaryLabel->setText(m_model->GetSummary(modelIndex)); diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemItemDelegate.cpp b/Code/Tools/ProjectManager/Source/GemCatalog/GemItemDelegate.cpp index 21bb56daef..99a2cd8db7 100644 --- a/Code/Tools/ProjectManager/Source/GemCatalog/GemItemDelegate.cpp +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemItemDelegate.cpp @@ -75,7 +75,7 @@ namespace O3DE::ProjectManager } // Gem name - QString gemName = GemModel::GetName(modelIndex); + QString gemName = GemModel::GetDisplayName(modelIndex); QFont gemNameFont(options.font); const int firstColumnMaxTextWidth = s_summaryStartX - 30; gemNameFont.setPixelSize(static_cast(s_gemNameFontSize)); diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemModel.cpp b/Code/Tools/ProjectManager/Source/GemCatalog/GemModel.cpp index 3781106bdc..7daea174e7 100644 --- a/Code/Tools/ProjectManager/Source/GemCatalog/GemModel.cpp +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemModel.cpp @@ -30,6 +30,7 @@ namespace O3DE::ProjectManager item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); item->setData(gemInfo.m_name, RoleName); + item->setData(gemInfo.m_displayName, RoleDisplayName); item->setData(gemInfo.m_creator, RoleCreator); item->setData(gemInfo.m_gemOrigin, RoleGemOrigin); item->setData(aznumeric_cast(gemInfo.m_platforms), RolePlatforms); @@ -64,6 +65,20 @@ namespace O3DE::ProjectManager return modelIndex.data(RoleName).toString(); } + QString GemModel::GetDisplayName(const QModelIndex& modelIndex) + { + QString displayName = modelIndex.data(RoleDisplayName).toString(); + + if (displayName.isEmpty()) + { + return GetName(modelIndex); + } + else + { + return displayName; + } + } + QString GemModel::GetCreator(const QModelIndex& modelIndex) { return modelIndex.data(RoleCreator).toString(); @@ -117,7 +132,7 @@ namespace O3DE::ProjectManager QModelIndex modelIndex = FindIndexByNameString(dependingGemString); if (modelIndex.isValid()) { - dependingGemString = GetName(modelIndex); + dependingGemString = GetDisplayName(modelIndex); } } } diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemModel.h b/Code/Tools/ProjectManager/Source/GemCatalog/GemModel.h index 19172d8073..ce004ee875 100644 --- a/Code/Tools/ProjectManager/Source/GemCatalog/GemModel.h +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemModel.h @@ -37,6 +37,7 @@ namespace O3DE::ProjectManager QStringList GetConflictingGemNames(const QModelIndex& modelIndex); static QString GetName(const QModelIndex& modelIndex); + static QString GetDisplayName(const QModelIndex& modelIndex); static QString GetCreator(const QModelIndex& modelIndex); static GemInfo::GemOrigin GetGemOrigin(const QModelIndex& modelIndex); static GemInfo::Platforms GetPlatforms(const QModelIndex& modelIndex); @@ -69,6 +70,7 @@ namespace O3DE::ProjectManager enum UserRole { RoleName = Qt::UserRole, + RoleDisplayName, RoleCreator, RoleGemOrigin, RolePlatforms, diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemRequirementDelegate.cpp b/Code/Tools/ProjectManager/Source/GemCatalog/GemRequirementDelegate.cpp index 0d5f752858..0ca5ca836f 100644 --- a/Code/Tools/ProjectManager/Source/GemCatalog/GemRequirementDelegate.cpp +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemRequirementDelegate.cpp @@ -51,7 +51,7 @@ namespace O3DE::ProjectManager painter->fillRect(itemRect, itemBackgroundColor); // Gem name - QString gemName = GemModel::GetName(modelIndex); + QString gemName = GemModel::GetDisplayName(modelIndex); QFont gemNameFont(options.font); const int firstColumnMaxTextWidth = s_summaryStartX - 30; gemName = QFontMetrics(gemNameFont).elidedText(gemName, Qt::TextElideMode::ElideRight, firstColumnMaxTextWidth); diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemSortFilterProxyModel.cpp b/Code/Tools/ProjectManager/Source/GemCatalog/GemSortFilterProxyModel.cpp index fbcf395910..6edfced6e5 100644 --- a/Code/Tools/ProjectManager/Source/GemCatalog/GemSortFilterProxyModel.cpp +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemSortFilterProxyModel.cpp @@ -28,9 +28,26 @@ namespace O3DE::ProjectManager return false; } - if (!m_sourceModel->GetName(sourceIndex).contains(m_searchString, Qt::CaseInsensitive)) + // Search Bar + if (!m_sourceModel->GetDisplayName(sourceIndex).contains(m_searchString, Qt::CaseInsensitive) && + !m_sourceModel->GetName(sourceIndex).contains(m_searchString, Qt::CaseInsensitive) && + !m_sourceModel->GetCreator(sourceIndex).contains(m_searchString, Qt::CaseInsensitive) && + !m_sourceModel->GetSummary(sourceIndex).contains(m_searchString, Qt::CaseInsensitive)) { - return false; + bool foundFeature = false; + for (const QString& feature : m_sourceModel->GetFeatures(sourceIndex)) + { + if (feature.contains(m_searchString, Qt::CaseInsensitive)) + { + foundFeature = true; + break; + } + } + + if (!foundFeature) + { + return false; + } } // Gem status From 3d2d2dd60fda3f5f1b7454c2718fe3f07b014eff Mon Sep 17 00:00:00 2001 From: Guthrie Adams Date: Mon, 23 Aug 2021 10:40:44 -0500 Subject: [PATCH 43/53] fixing linux non unity build Signed-off-by: Guthrie Adams --- .../Code/Source/Document/AtomToolsDocumentMainWindow.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp index f78950c2e9..c39bfc8327 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp @@ -320,7 +320,7 @@ namespace AtomToolsFramework } } - inline QWidget* AtomToolsDocumentMainWindow::CreateDocumentTabView(const AZ::Uuid& documentId) + QWidget* AtomToolsDocumentMainWindow::CreateDocumentTabView(const AZ::Uuid& documentId) { AZ_UNUSED(documentId); auto contentWidget = new QWidget(centralWidget()); @@ -356,14 +356,14 @@ namespace AtomToolsFramework } } - inline bool AtomToolsDocumentMainWindow::GetCreateDocumentParams(AZStd::string& openPath, AZStd::string& savePath) + bool AtomToolsDocumentMainWindow::GetCreateDocumentParams(AZStd::string& openPath, AZStd::string& savePath) { AZ_UNUSED(openPath); AZ_UNUSED(savePath); return false; } - inline bool AtomToolsDocumentMainWindow::GetOpenDocumentParams(AZStd::string& openPath) + bool AtomToolsDocumentMainWindow::GetOpenDocumentParams(AZStd::string& openPath) { AZ_UNUSED(openPath); return false; From c66dcc7413612e92c2aba3419064cd7cdb653c37 Mon Sep 17 00:00:00 2001 From: amzn-phist <52085794+amzn-phist@users.noreply.github.com> Date: Mon, 23 Aug 2021 13:28:54 -0500 Subject: [PATCH 44/53] Fix rpaths during o3de sdk install on Linux (#3370) * Fix rpaths during o3de sdk install on Linux Adds install code that modifies ly_copy commands to fix rpaths for things like qt plugins. Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com> * Add newline at end of file Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com> * Update to use bracket argument Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com> * Minor edit Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com> * Move the string configure call to inside override Per feedback. Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com> --- cmake/Platform/Linux/Install_linux.cmake | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cmake/Platform/Linux/Install_linux.cmake b/cmake/Platform/Linux/Install_linux.cmake index 08bb9f807e..b3e2093b65 100644 --- a/cmake/Platform/Linux/Install_linux.cmake +++ b/cmake/Platform/Linux/Install_linux.cmake @@ -6,4 +6,20 @@ # # -include(cmake/Platform/Common/Install_common.cmake) \ No newline at end of file +#! ly_install_code_function_override: Linux-specific copy function to handle RPATH fixes +set(ly_copy_template [[ +function(ly_copy source_file target_directory) + file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN) + get_filename_component(target_filename_ext "${source_file}" LAST_EXT) + if("${source_file}" MATCHES "qt/plugins" AND "${target_filename_ext}" STREQUAL ".so") + get_filename_component(target_filename "${source_file}" NAME) + file(RPATH_CHANGE FILE "${target_directory}/${target_filename}" OLD_RPATH "\$ORIGIN/../../lib" NEW_RPATH "\$ORIGIN/..") + endif() +endfunction()]]) + +function(ly_install_code_function_override) + string(CONFIGURE "${ly_copy_template}" ly_copy_function_linux @ONLY) + install(CODE "${ly_copy_function_linux}") +endfunction() + +include(cmake/Platform/Common/Install_common.cmake) From dfc5baae34dbbdc417d743a3c9e785aab95fb76b Mon Sep 17 00:00:00 2001 From: Kyle B Date: Mon, 23 Aug 2021 12:46:00 -0700 Subject: [PATCH 45/53] fixed casting errors Signed-off-by: Kyle B --- .../CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index b1bfb30285..ade4beaa33 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -109,7 +109,7 @@ namespace AZ } values.reserve(lodCount + 1); - values.push_back({0, "Default (Highest)" }); + values.push_back({ aznumeric_cast(0), "Default (Highest)" }); for (uint32_t i = 1; i < lodCount; ++i) { From de932c62b318ab0c02edb379cf5eb2ed617af209 Mon Sep 17 00:00:00 2001 From: santorac <55155825+santorac@users.noreply.github.com> Date: Mon, 23 Aug 2021 12:50:11 -0700 Subject: [PATCH 46/53] Reverted changes in MaterialComponentController for an obsucre edge case. We'll handle the case of missing material assets more generally as a separate task. Signed-off-by: santorac <55155825+santorac@users.noreply.github.com> --- .../Material/MaterialComponentController.cpp | 88 +------------------ .../Material/MaterialComponentController.h | 5 -- 2 files changed, 4 insertions(+), 89 deletions(-) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.cpp index 5d4e7883b0..8165eefb07 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.cpp @@ -87,7 +87,6 @@ namespace AZ void MaterialComponentController::Deactivate() { MaterialComponentRequestBus::Handler::BusDisconnect(); - MeshComponentNotificationBus::Handler::BusDisconnect(); TickBus::Handler::BusDisconnect(); ReleaseMaterials(); @@ -115,55 +114,6 @@ namespace AZ InitializeMaterialInstance(asset); } - void MaterialComponentController::OnModelReady(const Data::Asset&, const Data::Instance&) - { - MeshComponentNotificationBus::Handler::BusDisconnect(); - - // If there is a circumstance where the saved material assignments are empty, fill them in with the default material. - // (This could happen as a result of LoadMaterials() clearing the asset reference to deal with an edge case) - - // Now that a model asset is ready, see if there are any empty assignments that need to be filled... - RPI::ModelMaterialSlotMap modelMaterialSlots; - MaterialReceiverRequestBus::EventResult(modelMaterialSlots, m_entityId, &MaterialReceiverRequestBus::Events::GetModelMaterialSlots); - - AZStd::vector> newMaterialAssets; - newMaterialAssets.reserve(m_configuration.m_materials.size()); - - // First we fill the empty slots but don't connect to AssetBus yet. If the same material asset appears multiple times, - // AssetBus will call OnAssetReady only the *first* time we connect for that asset. The full list of m_configuration.m_materials - // needs to be updated before that happens. - for (auto& materialPair : m_configuration.m_materials) - { - auto& materialAsset = materialPair.second.m_materialAsset; - - if (!materialAsset.GetId().IsValid()) - { - auto slotIter = modelMaterialSlots.find(materialPair.first.m_materialSlotStableId); - if (slotIter != modelMaterialSlots.end()) - { - materialAsset = slotIter->second.m_defaultMaterialAsset; - newMaterialAssets.push_back(materialAsset); - } - else - { - AZ_Error("MaterialComponentController", false, "Could not find material slot %d", materialPair.first.m_materialSlotStableId); - } - } - } - - // Now that the configuration is updated with all the default material assets, we can load and connect them. - // If there are duplicates in this list, the redundant calls will be ignored. - for (auto& materialAsset : newMaterialAssets) - { - if (!materialAsset.IsReady()) - { - materialAsset.QueueLoad(); - } - - Data::AssetBus::MultiHandler::BusConnect(materialAsset.GetId()); - } - } - void MaterialComponentController::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time) { AZStd::unordered_set propertyOverrides; @@ -239,41 +189,11 @@ namespace AZ { auto& materialAsset = materialPair.second.m_materialAsset; - // This is a special case where a material was auto-generated from the model file, connected to a Material Component by the user, - // and then later a setting was changed to NOT auto-generate the model materials anymore. We need to switch to the new default - // material rather than trying to use the old default material which no longer exists. If that's the case, we reset the asset - // and OnModelReady will fill in the appropriate default material asset later. + if (materialAsset.GetId().IsValid() && !Data::AssetBus::MultiHandler::BusIsConnectedId(materialAsset.GetId())) { - Data::AssetId modelAssetId; - MeshComponentRequestBus::EventResult(modelAssetId, m_entityId, &MeshComponentRequestBus::Events::GetModelAssetId); - bool materialWasGeneratedFromModel = (modelAssetId.m_guid == materialAsset.GetId().m_guid); - - Data::AssetInfo assetInfo; - Data::AssetCatalogRequestBus::BroadcastResult(assetInfo, &Data::AssetCatalogRequestBus::Events::GetAssetInfoById, materialAsset.GetId()); - bool materialAssetExists = assetInfo.m_assetId.IsValid(); - - if (materialWasGeneratedFromModel && !materialAssetExists) - { - AZ_Warning("MaterialComponentController", false, "The default material assignment for this slot has changed and will be replaced (was '%s').", - materialAsset.ToString().c_str()); - materialAsset.Reset(); - } - } - - if (materialAsset.GetId().IsValid()) - { - if (!Data::AssetBus::MultiHandler::BusIsConnectedId(materialAsset.GetId())) - { - anyQueued = true; - materialAsset.QueueLoad(); - Data::AssetBus::MultiHandler::BusConnect(materialAsset.GetId()); - } - } - else - { - // Since a material asset wasn't found, we'll need to supply a default material. But the default materials - // won't be known until after the mesh component has loaded the model data. - MeshComponentNotificationBus::Handler::BusConnect(m_entityId); + anyQueued = true; + materialAsset.QueueLoad(); + Data::AssetBus::MultiHandler::BusConnect(materialAsset.GetId()); } } diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.h index b2177d1191..d8a32c7b78 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.h @@ -13,7 +13,6 @@ #include #include #include -#include namespace AZ { @@ -23,7 +22,6 @@ namespace AZ //! to provide material overrides on a per-entity basis. class MaterialComponentController final : MaterialComponentRequestBus::Handler - , MeshComponentNotificationBus::Handler , Data::AssetBus::MultiHandler , TickBus::Handler { @@ -77,9 +75,6 @@ namespace AZ // AZ::TickBus overrides... void OnTick(float deltaTime, AZ::ScriptTimePoint time) override; - // MeshComponentNotificationBus overrides... - void OnModelReady(const Data::Asset& modelAsset, const Data::Instance& model) override; - void LoadMaterials(); void InitializeMaterialInstance(const Data::Asset& asset); void ReleaseMaterials(); From b6dfb86007481ca705d37cd5b1efc24a1459adfa Mon Sep 17 00:00:00 2001 From: santorac <55155825+santorac@users.noreply.github.com> Date: Mon, 23 Aug 2021 12:53:33 -0700 Subject: [PATCH 47/53] Removed unnecessary #include Signed-off-by: santorac <55155825+santorac@users.noreply.github.com> --- .../Code/Source/Material/MaterialComponentController.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.cpp index 8165eefb07..536b5a3710 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.cpp @@ -11,7 +11,6 @@ #include #include #include -#include namespace AZ { From 89cc27fdef493136932573586ce52f57625ec85b Mon Sep 17 00:00:00 2001 From: michabr <82236305+michabr@users.noreply.github.com> Date: Mon, 23 Aug 2021 13:05:19 -0700 Subject: [PATCH 48/53] Fix input priority conflict with LyShine and ImGuiPass (#3329) * Fix input priority conflict with LyShine and ImGuiPass Signed-off-by: abrmich * Add GetPriorityDebugUI() input listener priority Signed-off-by: abrmich --- .../AzFramework/Input/Events/InputChannelEventListener.h | 1 + .../AzFramework/Input/Events/InputTextEventListener.h | 1 + Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.cpp | 9 ++------- Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.h | 1 - Gems/ImGui/Code/Source/ImGuiManager.h | 2 +- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Code/Framework/AzFramework/AzFramework/Input/Events/InputChannelEventListener.h b/Code/Framework/AzFramework/AzFramework/Input/Events/InputChannelEventListener.h index 2b45012fa3..00bdf30f0e 100644 --- a/Code/Framework/AzFramework/AzFramework/Input/Events/InputChannelEventListener.h +++ b/Code/Framework/AzFramework/AzFramework/Input/Events/InputChannelEventListener.h @@ -35,6 +35,7 @@ namespace AzFramework //! Predefined input event listener priority, used to sort handlers from highest to lowest inline static AZ::s32 GetPriorityFirst() { return std::numeric_limits::max(); } inline static AZ::s32 GetPriorityDebug() { return (GetPriorityFirst() / 4) * 3; } + inline static AZ::s32 GetPriorityDebugUI() { return (GetPriorityFirst() / 8) * 5; } inline static AZ::s32 GetPriorityUI() { return GetPriorityFirst() / 2; } inline static AZ::s32 GetPriorityDefault() { return 0; } inline static AZ::s32 GetPriorityLast() { return std::numeric_limits::min(); } diff --git a/Code/Framework/AzFramework/AzFramework/Input/Events/InputTextEventListener.h b/Code/Framework/AzFramework/AzFramework/Input/Events/InputTextEventListener.h index 32c44f83d4..4629a5a5c0 100644 --- a/Code/Framework/AzFramework/AzFramework/Input/Events/InputTextEventListener.h +++ b/Code/Framework/AzFramework/AzFramework/Input/Events/InputTextEventListener.h @@ -28,6 +28,7 @@ namespace AzFramework //! Predefined text event listener priority, used to sort handlers from highest to lowest inline static AZ::s32 GetPriorityFirst() { return std::numeric_limits::max(); } inline static AZ::s32 GetPriorityDebug() { return (GetPriorityFirst() / 4) * 3; } + inline static AZ::s32 GetPriorityDebugUI() { return (GetPriorityFirst() / 8) * 5; } inline static AZ::s32 GetPriorityUI() { return GetPriorityFirst() / 2; } inline static AZ::s32 GetPriorityDefault() { return 0; } inline static AZ::s32 GetPriorityLast() { return std::numeric_limits::min(); } diff --git a/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.cpp b/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.cpp index f73b0d71eb..a885708a47 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.cpp @@ -67,8 +67,8 @@ namespace AZ ImGuiPass::ImGuiPass(const RPI::PassDescriptor& descriptor) : Base(descriptor) - , AzFramework::InputChannelEventListener(AzFramework::InputChannelEventListener::GetPriorityUI()) - , AzFramework::InputTextEventListener(AzFramework::InputTextEventListener::GetPriorityUI()) + , AzFramework::InputChannelEventListener(AzFramework::InputChannelEventListener::GetPriorityDebugUI() - 1) // Give ImGui manager priority over the pass + , AzFramework::InputTextEventListener(AzFramework::InputTextEventListener::GetPriorityDebugUI() - 1) // Give ImGui manager priority over the pass { const ImGuiPassData* imguiPassData = RPI::PassUtils::GetPassData(descriptor); @@ -157,11 +157,6 @@ namespace AZ return io.WantTextInput; } - AZ::s32 ImGuiPass::GetPriority() const - { - return AzFramework::InputChannelEventListener::GetPriorityUI(); - } - bool ImGuiPass::OnInputChannelEventFiltered(const AzFramework::InputChannel& inputChannel) { if (!IsEnabled() || GetRenderPipeline()->GetScene() == nullptr) diff --git a/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.h b/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.h index 76cf29a573..0bde3edb4f 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.h @@ -84,7 +84,6 @@ namespace AZ // AzFramework::InputChannelEventListener overrides... bool OnInputChannelEventFiltered(const AzFramework::InputChannel& inputChannel) override; - AZ::s32 GetPriority() const override; protected: explicit ImGuiPass(const RPI::PassDescriptor& descriptor); diff --git a/Gems/ImGui/Code/Source/ImGuiManager.h b/Gems/ImGui/Code/Source/ImGuiManager.h index 20695c0825..1b24aa9806 100644 --- a/Gems/ImGui/Code/Source/ImGuiManager.h +++ b/Gems/ImGui/Code/Source/ImGuiManager.h @@ -67,7 +67,7 @@ namespace ImGui // -- AzFramework::InputChannelEventListener and AzFramework::InputTextEventListener Interface ------------ bool OnInputChannelEventFiltered(const AzFramework::InputChannel& inputChannel) override; bool OnInputTextEventFiltered(const AZStd::string& textUTF8) override; - int GetPriority() const override { return AzFramework::InputChannelEventListener::GetPriorityDebug(); } + int GetPriority() const override { return AzFramework::InputChannelEventListener::GetPriorityDebugUI(); } // -- AzFramework::InputChannelEventListener and AzFramework::InputTextEventListener Interface ------------ // AzFramework::WindowNotificationBus::Handler overrides... From 246621fda5362b59343fd5563432188d60f1ef5b Mon Sep 17 00:00:00 2001 From: Jacob Hilliard <64656371+jcbhl@users.noreply.github.com> Date: Mon, 23 Aug 2021 13:14:00 -0700 Subject: [PATCH 49/53] Visualizer: finish deserialization of captures (#3293) * Visualizer: Initial capture loading support Signed-off-by: Jacob Hilliard * Visualizer: Deserialize thread id Signed-off-by: Jacob Hilliard * Visualizer: Quality of life improvements throughout - Decrease row size for more information onscreen - Remove fudge factors in drawing logic - Add comments to deserialization logic - Fix Editor text scaling bug - Early out for data culling to avoid erase_if call Signed-off-by: Jacob Hilliard --- .../Code/Include/Atom/RHI/CpuProfilerImpl.h | 3 +- .../RHI/Code/Source/RHI/CpuProfilerImpl.cpp | 17 ++- .../Include/Atom/Utils/ImGuiCpuProfiler.h | 17 ++- .../Include/Atom/Utils/ImGuiCpuProfiler.inl | 125 +++++++++++++----- 4 files changed, 116 insertions(+), 46 deletions(-) diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/CpuProfilerImpl.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/CpuProfilerImpl.h index 9372977d8e..92b56880b7 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/CpuProfilerImpl.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/CpuProfilerImpl.h @@ -173,13 +173,14 @@ namespace AZ static void Reflect(AZ::ReflectContext* context); CpuProfilingStatisticsSerializerEntry() = default; - CpuProfilingStatisticsSerializerEntry(const RHI::CachedTimeRegion& cachedTimeRegion); + CpuProfilingStatisticsSerializerEntry(const RHI::CachedTimeRegion& cachedTimeRegion, AZStd::thread_id threadId); Name m_groupName; Name m_regionName; uint16_t m_stackDepth; AZStd::sys_time_t m_startTick; AZStd::sys_time_t m_endTick; + size_t m_threadId; }; AZ_TYPE_INFO(CpuProfilingStatisticsSerializer, "{D5B02946-0D27-474F-9A44-364C2706DD41}"); diff --git a/Gems/Atom/RHI/Code/Source/RHI/CpuProfilerImpl.cpp b/Gems/Atom/RHI/Code/Source/RHI/CpuProfilerImpl.cpp index 6cfd68d3c6..8099fc3a32 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/CpuProfilerImpl.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/CpuProfilerImpl.cpp @@ -417,14 +417,14 @@ namespace AZ // Create serializable entries for (const auto& timeRegionMap : continuousData) { - for (const auto& threadEntry : timeRegionMap) + for (const auto& [threadId, regionMap] : timeRegionMap) { - for (const auto& cachedRegionEntry : threadEntry.second) + for (const auto& [regionName, regionVec] : regionMap) { - m_cpuProfilingStatisticsSerializerEntries.insert( - m_cpuProfilingStatisticsSerializerEntries.end(), - cachedRegionEntry.second.begin(), - cachedRegionEntry.second.end()); + for (const auto& region : regionVec) + { + m_cpuProfilingStatisticsSerializerEntries.emplace_back(region, threadId); + } } } } @@ -445,13 +445,15 @@ namespace AZ // --- CpuProfilingStatisticsSerializerEntry --- - CpuProfilingStatisticsSerializer::CpuProfilingStatisticsSerializerEntry::CpuProfilingStatisticsSerializerEntry(const RHI::CachedTimeRegion& cachedTimeRegion) + CpuProfilingStatisticsSerializer::CpuProfilingStatisticsSerializerEntry::CpuProfilingStatisticsSerializerEntry( + const RHI::CachedTimeRegion& cachedTimeRegion, AZStd::thread_id threadId) { m_groupName = cachedTimeRegion.m_groupRegionName->m_groupName; m_regionName = cachedTimeRegion.m_groupRegionName->m_regionName; m_stackDepth = cachedTimeRegion.m_stackDepth; m_startTick = cachedTimeRegion.m_startTick; m_endTick = cachedTimeRegion.m_endTick; + m_threadId = AZStd::hash{}(threadId); } void CpuProfilingStatisticsSerializer::CpuProfilingStatisticsSerializerEntry::Reflect(AZ::ReflectContext* context) @@ -465,6 +467,7 @@ namespace AZ ->Field("stackDepth", &CpuProfilingStatisticsSerializerEntry::m_stackDepth) ->Field("startTick", &CpuProfilingStatisticsSerializerEntry::m_startTick) ->Field("endTick", &CpuProfilingStatisticsSerializerEntry::m_endTick) + ->Field("threadId", &CpuProfilingStatisticsSerializerEntry::m_threadId) ; } } diff --git a/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiCpuProfiler.h b/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiCpuProfiler.h index bdaf38a64a..ea4dd20250 100644 --- a/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiCpuProfiler.h +++ b/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiCpuProfiler.h @@ -43,7 +43,7 @@ namespace AZ }; // Update running statistics with new region data - void RecordRegion(const AZ::RHI::CachedTimeRegion& region, AZStd::thread_id threadId); + void RecordRegion(const AZ::RHI::CachedTimeRegion& region, size_t threadId); void ResetPerFrameStatistics(); @@ -58,7 +58,7 @@ namespace AZ u64 m_invocationsLastFrame = 0; // NOTE: set over unordered_set so the threads can be shown in increasing order in tooltip. - AZStd::set m_executingThreads; + AZStd::set m_executingThreads; AZStd::sys_time_t m_lastFrameTotalTicks = 0; @@ -95,7 +95,7 @@ namespace AZ void Draw(bool& keepDrawing, const AZ::RHI::CpuTimingStatistics& cpuTimingStatistics); private: - static constexpr float RowHeight = 50.0; + static constexpr float RowHeight = 35.0; static constexpr int DefaultFramesToCollect = 50; static constexpr float MediumFrameTimeLimit = 16.6; // 60 fps static constexpr float HighFrameTimeLimit = 33.3; // 30 fps @@ -134,7 +134,7 @@ namespace AZ void DrawThreadSeparator(u64 threadBoundary, u64 maxDepth); // Draw the "Thread XXXXX" label onto the viewport - void DrawThreadLabel(u64 baseRow, AZStd::thread_id threadId); + void DrawThreadLabel(u64 baseRow, size_t threadId); // Draw the vertical lines separating frames in the timeline void DrawFrameBoundaries(); @@ -169,7 +169,9 @@ namespace AZ AZStd::sys_time_t m_viewportEndTick; // Map to store each thread's TimeRegions, individual vectors are sorted by start tick - AZStd::unordered_map> m_savedData; + // note: we use size_t as a proxy for thread_id because native_thread_id_type differs differs from + // platform to platform, which causes problems when deserializing saved captures. + AZStd::unordered_map> m_savedData; // Region color cache AZStd::unordered_map m_regionColorMap; @@ -213,6 +215,11 @@ namespace AZ // Index into the file picker, used to determine which file to load when "Load File" is pressed. int m_currentFileIndex = 0; + + + // --- Loading capture state --- + AZStd::unordered_set m_deserializedStringPool; + AZStd::unordered_set m_deserializedGroupRegionNamePool; }; } // namespace Render } // namespace AZ diff --git a/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiCpuProfiler.inl b/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiCpuProfiler.inl index a225646761..638927d601 100644 --- a/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiCpuProfiler.inl +++ b/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiCpuProfiler.inl @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -30,19 +31,6 @@ namespace AZ { namespace CpuProfilerImGuiHelper { - // NOTE: Fix build error in case AZStd::thread_id is not of an arithmetic type, and instead a pointer - template::value>::type* = nullptr> - AZStd::string TextThreadId(ThreadId threadId) - { - return AZStd::string::format("Thread: %p", threadId); - } - - template::value>::type* = nullptr> - AZStd::string TextThreadId(ThreadId threadId) - { - return AZStd::string::format("Thread: %zu", static_cast(threadId)); - } - inline float TicksToMs(AZStd::sys_time_t ticks) { // Note: converting to microseconds integer before converting to milliseconds float @@ -231,6 +219,7 @@ namespace AZ m_lastCapturedFilePath = resolvedPath; AZ::Render::ProfilingCaptureRequestBus::Broadcast( &AZ::Render::ProfilingCaptureRequestBus::Events::EndContinuousCpuProfilingCapture, frameDataFilePath); + m_paused = true; } else @@ -447,13 +436,65 @@ namespace AZ inline void ImGuiCpuProfiler::LoadFile() { const IO::Path& pathToLoad = m_cachedCapturePaths[m_currentFileIndex]; - auto res = CpuProfilerImGuiHelper::LoadSavedCpuProfilingStatistics(pathToLoad.String()); - if (!res.IsSuccess()) + auto loadResult = CpuProfilerImGuiHelper::LoadSavedCpuProfilingStatistics(pathToLoad.String()); + if (!loadResult.IsSuccess()) { - AZ_TracePrintf("ImGuiCpuProfiler", "%s", res.GetError().c_str()); + AZ_TracePrintf("ImGuiCpuProfiler", "%s", loadResult.GetError().c_str()); return; } - // TODO ATOM-16022 Parse this data and display it in the visualizer widget. + + AZStd::vector deserializedData = loadResult.TakeValue(); + + // Clear visualizer and statistics view state + m_savedRegionCount = deserializedData.size(); + m_savedData.clear(); + m_paused = true; + AZ::RHI::CpuProfiler::Get()->SetProfilerEnabled(false); + m_frameEndTicks.clear(); + + m_tableData.clear(); + m_groupRegionMap.clear(); + + for (const auto& entry : deserializedData) + { + const auto [groupNameItr, wasGroupNameInserted] = m_deserializedStringPool.emplace(entry.m_groupName.GetCStr()); + const auto [regionNameItr, wasRegionNameInserted] = m_deserializedStringPool.emplace(entry.m_regionName.GetCStr()); + const auto [groupRegionNameItr, wasGroupRegionNameInserted] = + m_deserializedGroupRegionNamePool.emplace(groupNameItr->c_str(), regionNameItr->c_str()); + + const RHI::CachedTimeRegion newRegion(&(*groupRegionNameItr), entry.m_stackDepth, entry.m_startTick, entry.m_endTick); + m_savedData[entry.m_threadId].push_back(newRegion); + + // Since we don't serialize the frame boundaries, we need to use the RPI's OnSystemTick event as a heuristic. + const static Name frameBoundaryName = Name("RPISystem: OnSystemTick"); + if (entry.m_regionName == frameBoundaryName) + { + m_frameEndTicks.push_back(entry.m_endTick); + } + + // Update running statistics + if (!m_groupRegionMap[*groupNameItr].contains(*regionNameItr)) + { + m_groupRegionMap[*groupNameItr][*regionNameItr].m_groupName = *groupNameItr; + m_groupRegionMap[*groupNameItr][*regionNameItr].m_regionName = *regionNameItr; + m_tableData.push_back(&m_groupRegionMap[*groupNameItr][*regionNameItr]); + } + m_groupRegionMap[*groupNameItr][*regionNameItr].RecordRegion(newRegion, entry.m_threadId); + } + + // Update viewport bounds with some added UX fudge factor + m_viewportStartTick = deserializedData.back().m_startTick - 1000; + m_viewportEndTick = deserializedData.back().m_endTick + 1000; + + // Invariant: each vector in m_savedData must be sorted so that we can efficiently cull region data. + for (auto& [threadId, singleThreadData] : m_savedData) + { + AZStd::sort(singleThreadData.begin(), singleThreadData.end(), + [](const TimeRegion& lhs, const TimeRegion& rhs) + { + return lhs.m_startTick < rhs.m_startTick; + }); + } } // -- CPU Visualizer -- @@ -465,7 +506,7 @@ namespace AZ if (ImGui::BeginChild("Options and Statistics", { 0, 0 }, true)) { ImGui::Columns(3, "Options", true); - ImGui::SliderInt("Saved Frames", &m_framesToCollect, 10, 10000, "%d", ImGuiSliderFlags_AlwaysClamp | ImGuiSliderFlags_Logarithmic); + ImGui::SliderInt("Saved Frames", &m_framesToCollect, 10, 20000, "%d", ImGuiSliderFlags_AlwaysClamp | ImGuiSliderFlags_Logarithmic); m_visualizerHighlightFilter.Draw("Find Region"); ImGui::NextColumn(); @@ -631,6 +672,7 @@ namespace AZ // Iterate through the entire TimeRegionMap and copy the data since it will get deleted on the next frame for (const auto& [threadId, singleThreadRegionMap] : timeRegionMap) { + const size_t threadIdHashed = AZStd::hash{}(threadId); // The profiler can sometime return threads without any profiling events when dropping threads, FIXME(ATOM-15949) if (singleThreadRegionMap.size() == 0) { @@ -656,7 +698,7 @@ namespace AZ m_tableData.push_back(&m_groupRegionMap[groupName][regionName]); } - m_groupRegionMap[groupName][regionName].RecordRegion(region, threadId); + m_groupRegionMap[groupName][regionName].RecordRegion(region, threadIdHashed); } } @@ -676,7 +718,7 @@ namespace AZ m_savedRegionCount += newVisualizerData.size(); // Move onto the end of the current thread's saved data, sorted order maintained - AZStd::vector& savedDataVec = m_savedData[threadId]; + AZStd::vector& savedDataVec = m_savedData[threadIdHashed]; savedDataVec.insert( savedDataVec.end(), AZStd::make_move_iterator(newVisualizerData.begin()), AZStd::make_move_iterator(newVisualizerData.end())); } @@ -696,6 +738,12 @@ namespace AZ { AZStd::size_t sizeBeforeRemove = savedRegions.size(); + // Early out to avoid the linear erase_if call + if (savedRegions.size() >= 1 && savedRegions.at(0).m_startTick > deleteBeforeTick) + { + continue; + } + // Use erase_if over plain upper_bound + erase to avoid repeated shifts. erase requires a shift of all elements to the right // for each element that is erased, while erase_if squashes all removes into a single shift which significantly improves perf. AZStd::erase_if( @@ -732,12 +780,19 @@ namespace AZ const float startPixel = ConvertTickToPixelSpace(block.m_startTick, m_viewportStartTick, m_viewportEndTick); const float endPixel = ConvertTickToPixelSpace(block.m_endTick, m_viewportStartTick, m_viewportEndTick); - const ImVec2 startPoint = { startPixel, wy + targetRow * RowHeight }; - const ImVec2 endPoint = { endPixel, wy + targetRow * RowHeight + 40 }; + if (endPixel - startPixel < 0.5f) + { + return; + } + + const ImVec2 startPoint = { startPixel, wy + targetRow * RowHeight + 1}; + const ImVec2 endPoint = { endPixel, wy + (targetRow + 1) * RowHeight }; const ImU32 blockColor = GetBlockColor(block); drawList->AddRectFilled(startPoint, endPoint, blockColor, 0); + drawList->AddLine(startPoint, { endPixel, startPoint.y }, IM_COL32_BLACK, 0.5f); + drawList->AddLine({ startPixel, endPoint.y }, endPoint, IM_COL32_BLACK, 0.5f); // Draw the region name if possible // If the block's current width is too small, we skip drawing the label. @@ -751,11 +806,13 @@ namespace AZ if (regionPixelWidth < textWidth) // Not enough space in the block to draw the whole name, draw clipped text. { - // clipRect appears to only clip when a character is fully outside of its bounds which can lead to overflow - // for now subtract the width of a character const ImVec4 clipRect = { startPoint.x, startPoint.y, endPoint.x - maxCharWidth, endPoint.y }; - const float fontSize = ImGui::GetFont()->FontSize; + // NOTE: RenderText calls do not automatically account for the global scale (which is modified at high DPI) + // so we must adjust for the scale manually. + const float scaleFactor = ImGui::GetIO().FontGlobalScale; + const float fontSize = ImGui::GetFont()->FontSize * scaleFactor; + ImGui::GetFont()->RenderText(drawList, fontSize, startPoint, IM_COL32_WHITE, clipRect, label.c_str(), 0); } else // We have enough space to draw the entire label, draw and center text. @@ -815,18 +872,18 @@ namespace AZ auto [wx, wy] = ImGui::GetWindowPos(); wy -= ImGui::GetScrollY(); const float windowWidth = ImGui::GetWindowWidth(); - const float boundaryY = wy + (baseRow + maxDepth + 1) * RowHeight - 5; + const float boundaryY = wy + (baseRow + maxDepth + 1) * RowHeight; - ImGui::GetWindowDrawList()->AddLine({ wx, boundaryY }, { wx + windowWidth, boundaryY }, red, 2.0f); + ImGui::GetWindowDrawList()->AddLine({ wx, boundaryY }, { wx + windowWidth, boundaryY }, red, 1.0f); } - inline void ImGuiCpuProfiler::DrawThreadLabel(u64 baseRow, AZStd::thread_id threadId) + inline void ImGuiCpuProfiler::DrawThreadLabel(u64 baseRow, size_t threadId) { auto [wx, wy] = ImGui::GetWindowPos(); wy -= ImGui::GetScrollY(); - const AZStd::string threadIdText = CpuProfilerImGuiHelper::TextThreadId(threadId.m_id); + const AZStd::string threadIdText = AZStd::string::format("Thread: %zu", threadId); - ImGui::GetWindowDrawList()->AddText({ wx + 10, wy + baseRow * RowHeight + 5 }, IM_COL32_WHITE, threadIdText.c_str()); + ImGui::GetWindowDrawList()->AddText({ wx + 10, wy + baseRow * RowHeight}, IM_COL32_WHITE, threadIdText.c_str()); } inline void ImGuiCpuProfiler::DrawFrameBoundaries() @@ -884,8 +941,10 @@ namespace AZ const float textBeginPixel = lastFrameBoundaryPixel + offset; const float textEndPixel = textBeginPixel + labelWidth; + const float verticalOffset = (ImGui::GetWindowHeight() - ImGui::GetFontSize()) / 2; + // Execution time label - drawList->AddText({ textBeginPixel, wy + ImGui::GetWindowHeight() / 4 }, IM_COL32_WHITE, label.c_str()); + drawList->AddText({ textBeginPixel, wy + verticalOffset }, IM_COL32_WHITE, label.c_str()); // Left side drawList->AddLine( @@ -1043,7 +1102,7 @@ namespace AZ // ---- TableRow impl ---- - inline void TableRow::RecordRegion(const AZ::RHI::CachedTimeRegion& region, AZStd::thread_id threadId) + inline void TableRow::RecordRegion(const AZ::RHI::CachedTimeRegion& region, size_t threadId) { const AZStd::sys_time_t deltaTime = region.m_endTick - region.m_startTick; @@ -1072,7 +1131,7 @@ namespace AZ auto threadString = AZStd::string::format("Executed in %zu threads\n", m_executingThreads.size()); for (const auto& threadId : m_executingThreads) { - threadString.append(CpuProfilerImGuiHelper::TextThreadId(threadId.m_id) + "\n"); + threadString.append(AZStd::string::format("Thread: %zu\n", threadId)); } return threadString; } From 97a053a540f21f48413eb55e8b3c25e9cebeba0d Mon Sep 17 00:00:00 2001 From: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com> Date: Mon, 23 Aug 2021 15:41:57 -0500 Subject: [PATCH 50/53] Initial stub terrain gem (#3368) This is the initial Terrain Gem. In this PR, it doesn't do anything, but it contains all of the initial code, icons, and build scripts for the gem to compile and build successfully. The follow-up PR will contain the first round of functioning code. Also, with the creation of the gem, the TerrainSurfaceDataSystemComponent is getting relocated from the SurfaceData Gem to the Terrain Gem. This should have no impact, as that component has provided no active functionality in o3de. (It will start working again with the initial terrain system code in the next PR) This also adds a couple of null guards to prefab code to prevent AP crashes, and fixed an incorrect service dependency in the VegetationSystemComponent that was exposed by moving the TerrainSurfaceDataSystemComponent. Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com> --- .../Prefab/Instance/Instance.cpp | 5 +- .../Spawnable/PrefabCatchmentProcessor.cpp | 20 ++- .../Code/Source/SurfaceDataModule.cpp | 3 - Gems/SurfaceData/Code/surfacedata_files.cmake | 2 - .../Editor/Icons/Components/TerrainHeight.svg | 7 + .../Icons/Components/TerrainLayerRenderer.svg | 7 + .../Icons/Components/TerrainLayerSpawner.svg | 7 + .../Editor/Icons/Components/TerrainWorld.svg | 8 + .../Icons/Components/TerrainWorldDebugger.svg | 8 + .../Icons/Components/TerrainWorldRenderer.svg | 8 + .../Components/Viewport/TerrainHeight.svg | 25 ++++ .../Viewport/TerrainLayerRenderer.svg | 25 ++++ .../Viewport/TerrainLayerSpawner.svg | 25 ++++ .../Components/Viewport/TerrainWorld.svg | 25 ++++ .../Viewport/TerrainWorldDebugger.svg | 25 ++++ .../Viewport/TerrainWorldRenderer.svg | 25 ++++ Gems/Terrain/CMakeLists.txt | 8 + Gems/Terrain/Code/CMakeLists.txt | 139 ++++++++++++++++++ .../TerrainSurfaceDataSystemComponent.cpp | 12 +- .../TerrainSurfaceDataSystemComponent.h | 0 .../Components/TerrainSystemComponent.cpp | 68 +++++++++ .../Components/TerrainSystemComponent.h | 40 +++++ .../EditorTerrainSystemComponent.cpp | 32 ++++ .../EditorTerrainSystemComponent.h | 43 ++++++ .../Code/Source/EditorTerrainModule.cpp | 36 +++++ .../Terrain/Code/Source/EditorTerrainModule.h | 26 ++++ Gems/Terrain/Code/Source/TerrainModule.cpp | 42 ++++++ Gems/Terrain/Code/Source/TerrainModule.h | 26 ++++ Gems/Terrain/Code/Tests/TerrainEditorTest.cpp | 31 ++++ Gems/Terrain/Code/Tests/TerrainTest.cpp | 31 ++++ .../Code/terrain_editor_shared_files.cmake | 16 ++ .../Code/terrain_editor_tests_files.cmake | 11 ++ Gems/Terrain/Code/terrain_files.cmake | 14 ++ Gems/Terrain/Code/terrain_shared_files.cmake | 12 ++ Gems/Terrain/Code/terrain_tests_files.cmake | 11 ++ Gems/Terrain/gem.json | 10 ++ Gems/Terrain/preview.png | 3 + .../Code/Source/VegetationSystemComponent.cpp | 15 +- .../Code/Source/VegetationSystemComponent.h | 1 + engine.json | 1 + 40 files changed, 830 insertions(+), 23 deletions(-) create mode 100644 Gems/Terrain/Assets/Editor/Icons/Components/TerrainHeight.svg create mode 100644 Gems/Terrain/Assets/Editor/Icons/Components/TerrainLayerRenderer.svg create mode 100644 Gems/Terrain/Assets/Editor/Icons/Components/TerrainLayerSpawner.svg create mode 100644 Gems/Terrain/Assets/Editor/Icons/Components/TerrainWorld.svg create mode 100644 Gems/Terrain/Assets/Editor/Icons/Components/TerrainWorldDebugger.svg create mode 100644 Gems/Terrain/Assets/Editor/Icons/Components/TerrainWorldRenderer.svg create mode 100644 Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainHeight.svg create mode 100644 Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainLayerRenderer.svg create mode 100644 Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainLayerSpawner.svg create mode 100644 Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainWorld.svg create mode 100644 Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainWorldDebugger.svg create mode 100644 Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainWorldRenderer.svg create mode 100644 Gems/Terrain/CMakeLists.txt create mode 100644 Gems/Terrain/Code/CMakeLists.txt rename Gems/{SurfaceData/Code/Source => Terrain/Code/Source/Components}/TerrainSurfaceDataSystemComponent.cpp (96%) rename Gems/{SurfaceData/Code/Source => Terrain/Code/Source/Components}/TerrainSurfaceDataSystemComponent.h (100%) create mode 100644 Gems/Terrain/Code/Source/Components/TerrainSystemComponent.cpp create mode 100644 Gems/Terrain/Code/Source/Components/TerrainSystemComponent.h create mode 100644 Gems/Terrain/Code/Source/EditorComponents/EditorTerrainSystemComponent.cpp create mode 100644 Gems/Terrain/Code/Source/EditorComponents/EditorTerrainSystemComponent.h create mode 100644 Gems/Terrain/Code/Source/EditorTerrainModule.cpp create mode 100644 Gems/Terrain/Code/Source/EditorTerrainModule.h create mode 100644 Gems/Terrain/Code/Source/TerrainModule.cpp create mode 100644 Gems/Terrain/Code/Source/TerrainModule.h create mode 100644 Gems/Terrain/Code/Tests/TerrainEditorTest.cpp create mode 100644 Gems/Terrain/Code/Tests/TerrainTest.cpp create mode 100644 Gems/Terrain/Code/terrain_editor_shared_files.cmake create mode 100644 Gems/Terrain/Code/terrain_editor_tests_files.cmake create mode 100644 Gems/Terrain/Code/terrain_files.cmake create mode 100644 Gems/Terrain/Code/terrain_shared_files.cmake create mode 100644 Gems/Terrain/Code/terrain_tests_files.cmake create mode 100644 Gems/Terrain/gem.json create mode 100644 Gems/Terrain/preview.png diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp index 043f864245..54e7f7608c 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp @@ -650,7 +650,10 @@ namespace AzToolsFramework AZStd::unique_ptr Instance::DetachContainerEntity() { - m_instanceEntityMapper->UnregisterEntity(m_containerEntity->GetId()); + if (m_containerEntity) + { + m_instanceEntityMapper->UnregisterEntity(m_containerEntity->GetId()); + } return AZStd::move(m_containerEntity); } } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Spawnable/PrefabCatchmentProcessor.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Spawnable/PrefabCatchmentProcessor.cpp index c455873036..7b7107ae3e 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Spawnable/PrefabCatchmentProcessor.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Spawnable/PrefabCatchmentProcessor.cpp @@ -65,16 +65,24 @@ namespace AzToolsFramework::Prefab::PrefabConversionUtils AzFramework::Spawnable::EntityList& entities = spawnable->GetEntities(); for (auto it = entities.begin(); it != entities.end(); ) { - (*it)->InvalidateDependencies(); - AZ::Entity::DependencySortOutcome evaluation = (*it)->EvaluateDependenciesGetDetails(); - if (evaluation.IsSuccess()) + if (*it) { - ++it; + (*it)->InvalidateDependencies(); + AZ::Entity::DependencySortOutcome evaluation = (*it)->EvaluateDependenciesGetDetails(); + if (evaluation.IsSuccess()) + { + ++it; + } + else + { + AZ_Error( + "Prefabs", false, "Entity '%s' %s cannot be activated for the following reason: %s", (*it)->GetName().c_str(), + (*it)->GetId().ToString().c_str(), evaluation.GetError().m_message.c_str()); + it = entities.erase(it); + } } else { - AZ_Error("Prefabs", false, "Entity '%s' %s cannot be activated for the following reason: %s", - (*it)->GetName().c_str(), (*it)->GetId().ToString().c_str(), evaluation.GetError().m_message.c_str()); it = entities.erase(it); } } diff --git a/Gems/SurfaceData/Code/Source/SurfaceDataModule.cpp b/Gems/SurfaceData/Code/Source/SurfaceDataModule.cpp index 4eef54669a..35064bf4a4 100644 --- a/Gems/SurfaceData/Code/Source/SurfaceDataModule.cpp +++ b/Gems/SurfaceData/Code/Source/SurfaceDataModule.cpp @@ -10,7 +10,6 @@ #include #include #include -#include namespace SurfaceData { @@ -20,7 +19,6 @@ namespace SurfaceData SurfaceDataSystemComponent::CreateDescriptor(), SurfaceDataColliderComponent::CreateDescriptor(), SurfaceDataShapeComponent::CreateDescriptor(), - Terrain::TerrainSurfaceDataSystemComponent::CreateDescriptor(), }); } @@ -28,7 +26,6 @@ namespace SurfaceData { return AZ::ComponentTypeList{ azrtti_typeid(), - azrtti_typeid(), }; } } diff --git a/Gems/SurfaceData/Code/surfacedata_files.cmake b/Gems/SurfaceData/Code/surfacedata_files.cmake index 487dcb70e5..4b8ac914d7 100644 --- a/Gems/SurfaceData/Code/surfacedata_files.cmake +++ b/Gems/SurfaceData/Code/surfacedata_files.cmake @@ -19,8 +19,6 @@ set(FILES Include/SurfaceData/Utility/SurfaceDataUtility.h Source/SurfaceDataSystemComponent.cpp Source/SurfaceDataSystemComponent.h - Source/TerrainSurfaceDataSystemComponent.cpp - Source/TerrainSurfaceDataSystemComponent.h Source/SurfaceTag.cpp Source/Components/SurfaceDataColliderComponent.cpp Source/Components/SurfaceDataColliderComponent.h diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/TerrainHeight.svg b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainHeight.svg new file mode 100644 index 0000000000..57835e9c20 --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainHeight.svg @@ -0,0 +1,7 @@ + + + icon / Environmental / Terrain Height + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/TerrainLayerRenderer.svg b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainLayerRenderer.svg new file mode 100644 index 0000000000..fb9590ae7b --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainLayerRenderer.svg @@ -0,0 +1,7 @@ + + + icon / Environmental / Terrain Mesh + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/TerrainLayerSpawner.svg b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainLayerSpawner.svg new file mode 100644 index 0000000000..df73d78276 --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainLayerSpawner.svg @@ -0,0 +1,7 @@ + + + icon / Environmental / Generate Terrian + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/TerrainWorld.svg b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainWorld.svg new file mode 100644 index 0000000000..c6388d6215 --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainWorld.svg @@ -0,0 +1,8 @@ + + + icon / Environmental / Terrain Refactor + + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/TerrainWorldDebugger.svg b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainWorldDebugger.svg new file mode 100644 index 0000000000..bd1512afda --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainWorldDebugger.svg @@ -0,0 +1,8 @@ + + + icon / Environmental / Terrain World Debugger + + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/TerrainWorldRenderer.svg b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainWorldRenderer.svg new file mode 100644 index 0000000000..ab3716ad5d --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainWorldRenderer.svg @@ -0,0 +1,8 @@ + + + icon / Environmental / Terrain World Renderer + + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainHeight.svg b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainHeight.svg new file mode 100644 index 0000000000..b87a0b4d7e --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainHeight.svg @@ -0,0 +1,25 @@ + + + icon / Environmental / Terrain Height - box + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainLayerRenderer.svg b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainLayerRenderer.svg new file mode 100644 index 0000000000..521d56784c --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainLayerRenderer.svg @@ -0,0 +1,25 @@ + + + icon / Environmental / Terrain Mesh - box + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainLayerSpawner.svg b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainLayerSpawner.svg new file mode 100644 index 0000000000..c078d32fe5 --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainLayerSpawner.svg @@ -0,0 +1,25 @@ + + + icon / Environmental / Generate Terrian - box + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainWorld.svg b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainWorld.svg new file mode 100644 index 0000000000..2aee65f2a8 --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainWorld.svg @@ -0,0 +1,25 @@ + + + icon / Environmental / Terrain Refactor - box + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainWorldDebugger.svg b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainWorldDebugger.svg new file mode 100644 index 0000000000..1b729ab73f --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainWorldDebugger.svg @@ -0,0 +1,25 @@ + + + icon / Environmental / Terrain World Debugger - box + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainWorldRenderer.svg b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainWorldRenderer.svg new file mode 100644 index 0000000000..4287508f10 --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainWorldRenderer.svg @@ -0,0 +1,25 @@ + + + icon / Environmental / Terrain World Renderer - box + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Gems/Terrain/CMakeLists.txt b/Gems/Terrain/CMakeLists.txt new file mode 100644 index 0000000000..34bce0825f --- /dev/null +++ b/Gems/Terrain/CMakeLists.txt @@ -0,0 +1,8 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +add_subdirectory(Code) diff --git a/Gems/Terrain/Code/CMakeLists.txt b/Gems/Terrain/Code/CMakeLists.txt new file mode 100644 index 0000000000..f40dd17ede --- /dev/null +++ b/Gems/Terrain/Code/CMakeLists.txt @@ -0,0 +1,139 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +ly_add_target( + NAME Terrain.Static STATIC + NAMESPACE Gem + FILES_CMAKE + terrain_files.cmake + INCLUDE_DIRECTORIES + PUBLIC + Include + PRIVATE + Source + BUILD_DEPENDENCIES + PUBLIC + AZ::AzCore + AZ::AzFramework + Gem::Atom_RPI.Public + Gem::Atom_Utils.Static + Gem::GradientSignal + Gem::SurfaceData + Gem::LmbrCentral +) + +ly_add_target( + NAME Terrain ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE} + NAMESPACE Gem + FILES_CMAKE + terrain_shared_files.cmake + INCLUDE_DIRECTORIES + PUBLIC + Include + PRIVATE + Source + BUILD_DEPENDENCIES + PRIVATE + Gem::Terrain.Static + Gem::LmbrCentral + RUNTIME_DEPENDENCIES + Gem::LmbrCentral +) + +# the above module is for use in all client/server types +ly_create_alias(NAME Terrain.Servers NAMESPACE Gem TARGETS Gem::Terrain) +ly_create_alias(NAME Terrain.Clients NAMESPACE Gem TARGETS Gem::Terrain) + +# If we are on a host platform, we want to add the host tools targets like the Terrain.Editor target which +# will also depend on Terrain.Static +if(PAL_TRAIT_BUILD_HOST_TOOLS) + ly_add_target( + NAME Terrain.Editor MODULE + NAMESPACE Gem + AUTOMOC + OUTPUT_NAME Gem.Terrain.Editor + FILES_CMAKE + terrain_editor_shared_files.cmake + COMPILE_DEFINITIONS + PRIVATE + TERRAIN_EDITOR + INCLUDE_DIRECTORIES + PRIVATE + Source + PUBLIC + Include + BUILD_DEPENDENCIES + PUBLIC + AZ::AzToolsFramework + Gem::GradientSignal + Gem::LmbrCentral + Gem::Terrain.Static + ) + + # the above module is for use in dev tool situations + ly_create_alias(NAME Terrain.Builders NAMESPACE Gem TARGETS Gem::Terrain.Editor) + ly_create_alias(NAME Terrain.Tools NAMESPACE Gem TARGETS Gem::Terrain.Editor) +endif() + +################################################################################ +# Tests +################################################################################ +# See if globally, tests are supported +if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) + # We globally support tests, see if we support tests on this platform for Terrain.Static + if(PAL_TRAIT_TERRAIN_TEST_SUPPORTED) + # We support Terrain.Tests on this platform, add Terrain.Tests target which depends on Terrain.Static + ly_add_target( + NAME Terrain.Tests ${PAL_TRAIT_TEST_TARGET_TYPE} + NAMESPACE Gem + FILES_CMAKE + terrain_files.cmake + terrain_tests_files.cmake + INCLUDE_DIRECTORIES + PRIVATE + Tests + Source + BUILD_DEPENDENCIES + PRIVATE + AZ::AzTest + AZ::AzFramework + Gem::Terrain.Static + ) + + # Add Terrain.Tests to googletest + ly_add_googletest( + NAME Gem::Terrain.Tests + ) + endif() + + # If we are a host platform we want to add tools test like editor tests here + if(PAL_TRAIT_BUILD_HOST_TOOLS) + # We are a host platform, see if Editor tests are supported on this platform + if(PAL_TRAIT_TERRAIN_EDITOR_TEST_SUPPORTED) + # We support Terrain.Editor.Tests on this platform, add Terrain.Editor.Tests target which depends on Terrain.Editor + ly_add_target( + NAME Terrain.Editor.Tests ${PAL_TRAIT_TEST_TARGET_TYPE} + NAMESPACE Gem + FILES_CMAKE + terrain_editor_tests_files.cmake + INCLUDE_DIRECTORIES + PRIVATE + Tests + Source + BUILD_DEPENDENCIES + PRIVATE + AZ::AzTest + Gem::Terrain.Editor + ) + + # Add Terrain.Editor.Tests to googletest + ly_add_googletest( + NAME Gem::Terrain.Editor.Tests + ) + endif() + endif() +endif() diff --git a/Gems/SurfaceData/Code/Source/TerrainSurfaceDataSystemComponent.cpp b/Gems/Terrain/Code/Source/Components/TerrainSurfaceDataSystemComponent.cpp similarity index 96% rename from Gems/SurfaceData/Code/Source/TerrainSurfaceDataSystemComponent.cpp rename to Gems/Terrain/Code/Source/Components/TerrainSurfaceDataSystemComponent.cpp index a60bbc4034..04c94b24d6 100644 --- a/Gems/SurfaceData/Code/Source/TerrainSurfaceDataSystemComponent.cpp +++ b/Gems/Terrain/Code/Source/Components/TerrainSurfaceDataSystemComponent.cpp @@ -6,7 +6,7 @@ * */ -#include +#include #include #include #include @@ -58,7 +58,7 @@ namespace Terrain editContext->Class("Terrain Surface Data System", "Manages surface data requests against legacy terrain") ->ClassElement(AZ::Edit::ClassElements::EditorData, "") ->Attribute(AZ::Edit::Attributes::Category, "Surface Data") - ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System", 0xc94d118b)) + ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("System")) ->Attribute(AZ::Edit::Attributes::AutoExpand, true) ->DataElement(0, &TerrainSurfaceDataSystemComponent::m_configuration, "Configuration", "") ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly) @@ -78,18 +78,18 @@ namespace Terrain void TerrainSurfaceDataSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services) { - services.push_back(AZ_CRC("SurfaceDataProviderService", 0xfe9fb95e)); - services.push_back(AZ_CRC("TerrainSurfaceDataProviderService", 0xa1ac7717)); + services.push_back(AZ_CRC_CE("SurfaceDataProviderService")); + services.push_back(AZ_CRC_CE("TerrainSurfaceDataProviderService")); } void TerrainSurfaceDataSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& services) { - services.push_back(AZ_CRC("TerrainSurfaceDataProviderService", 0xa1ac7717)); + services.push_back(AZ_CRC_CE("TerrainSurfaceDataProviderService")); } void TerrainSurfaceDataSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& services) { - services.push_back(AZ_CRC("SurfaceDataSystemService", 0x1d44d25f)); + services.push_back(AZ_CRC_CE("SurfaceDataSystemService")); } void TerrainSurfaceDataSystemComponent::Activate() diff --git a/Gems/SurfaceData/Code/Source/TerrainSurfaceDataSystemComponent.h b/Gems/Terrain/Code/Source/Components/TerrainSurfaceDataSystemComponent.h similarity index 100% rename from Gems/SurfaceData/Code/Source/TerrainSurfaceDataSystemComponent.h rename to Gems/Terrain/Code/Source/Components/TerrainSurfaceDataSystemComponent.h diff --git a/Gems/Terrain/Code/Source/Components/TerrainSystemComponent.cpp b/Gems/Terrain/Code/Source/Components/TerrainSystemComponent.cpp new file mode 100644 index 0000000000..dea7babbbc --- /dev/null +++ b/Gems/Terrain/Code/Source/Components/TerrainSystemComponent.cpp @@ -0,0 +1,68 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + + +#include + +#include +#include +#include + +#include + +namespace Terrain +{ + void TerrainSystemComponent::Reflect(AZ::ReflectContext* context) + { + if (AZ::SerializeContext* serialize = azrtti_cast(context)) + { + serialize->Class() + ->Version(0); + + if (AZ::EditContext* ec = serialize->GetEditContext()) + { + ec->Class("Terrain", "The Terrain System Component enables Terrain.") + ->ClassElement(AZ::Edit::ClassElements::EditorData, "") + ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("System")) + ->Attribute(AZ::Edit::Attributes::AutoExpand, true) + ; + } + } + } + + void TerrainSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided) + { + provided.push_back(AZ_CRC_CE("TerrainService")); + } + + void TerrainSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible) + { + incompatible.push_back(AZ_CRC_CE("TerrainService")); + } + + void TerrainSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required) + { + required.push_back(AZ_CRC_CE("RPISystem")); + } + + void TerrainSystemComponent::GetDependentServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& dependent) + { + } + + void TerrainSystemComponent::Init() + { + } + + void TerrainSystemComponent::Activate() + { + } + + void TerrainSystemComponent::Deactivate() + { + } +} diff --git a/Gems/Terrain/Code/Source/Components/TerrainSystemComponent.h b/Gems/Terrain/Code/Source/Components/TerrainSystemComponent.h new file mode 100644 index 0000000000..b294c0473a --- /dev/null +++ b/Gems/Terrain/Code/Source/Components/TerrainSystemComponent.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#pragma once + +#include + +namespace Terrain +{ + class TerrainSystem; + + class TerrainSystemComponent + : public AZ::Component + { + public: + AZ_COMPONENT(TerrainSystemComponent, "{CD5A517E-3BD8-49AE-8F9B-33C6FC47EC67}"); + + static void Reflect(AZ::ReflectContext* context); + + static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided); + static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible); + static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required); + static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent); + + protected: + //////////////////////////////////////////////////////////////////////// + // AZ::Component interface implementation + void Init() override; + void Activate() override; + void Deactivate() override; + //////////////////////////////////////////////////////////////////////// + + TerrainSystem* m_terrainSystem{ nullptr }; + }; +} diff --git a/Gems/Terrain/Code/Source/EditorComponents/EditorTerrainSystemComponent.cpp b/Gems/Terrain/Code/Source/EditorComponents/EditorTerrainSystemComponent.cpp new file mode 100644 index 0000000000..7fa35cc81c --- /dev/null +++ b/Gems/Terrain/Code/Source/EditorComponents/EditorTerrainSystemComponent.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#include +#include + +namespace Terrain +{ + void EditorTerrainSystemComponent::Reflect(AZ::ReflectContext* context) + { + if (auto serializeContext = azrtti_cast(context)) + { + serializeContext->Class()->Version(1); + } + } + + void EditorTerrainSystemComponent::Activate() + { + AzToolsFramework::EditorEvents::Bus::Handler::BusConnect(); + } + + void EditorTerrainSystemComponent::Deactivate() + { + AzToolsFramework::EditorEvents::Bus::Handler::BusDisconnect(); + } + +} // namespace Terrain diff --git a/Gems/Terrain/Code/Source/EditorComponents/EditorTerrainSystemComponent.h b/Gems/Terrain/Code/Source/EditorComponents/EditorTerrainSystemComponent.h new file mode 100644 index 0000000000..274e561ace --- /dev/null +++ b/Gems/Terrain/Code/Source/EditorComponents/EditorTerrainSystemComponent.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#pragma once + +#include + +#include + +namespace Terrain +{ + /// System component for Terrain editor + class EditorTerrainSystemComponent + : public AZ::Component + , private AzToolsFramework::EditorEvents::Bus::Handler + { + public: + AZ_COMPONENT(EditorTerrainSystemComponent, "{5E9f2200-9099-4325-BABD-6A533A1ABEA8}"); + static void Reflect(AZ::ReflectContext* context); + + EditorTerrainSystemComponent() = default; + + private: + static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided) + { + provided.push_back(AZ_CRC_CE("TerrainEditorService")); + } + + static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required) + { + required.push_back(AZ_CRC_CE("TerrainService")); + } + + // AZ::Component + void Activate() override; + void Deactivate() override; + }; +} // namespace Terrain diff --git a/Gems/Terrain/Code/Source/EditorTerrainModule.cpp b/Gems/Terrain/Code/Source/EditorTerrainModule.cpp new file mode 100644 index 0000000000..bd4c94f4bf --- /dev/null +++ b/Gems/Terrain/Code/Source/EditorTerrainModule.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#include +#include + +namespace Terrain +{ + EditorTerrainModule::EditorTerrainModule() + { + m_descriptors.insert( + m_descriptors.end(), + { + Terrain::EditorTerrainSystemComponent::CreateDescriptor(), + }); + } + + AZ::ComponentTypeList EditorTerrainModule::GetRequiredSystemComponents() const + { + AZ::ComponentTypeList requiredComponents = TerrainModule::GetRequiredSystemComponents(); + requiredComponents.insert( + requiredComponents.end(), + { + azrtti_typeid(), + }); + + return requiredComponents; + } +} + +AZ_DECLARE_MODULE_CLASS(Gem_TerrainEditor, Terrain::EditorTerrainModule) diff --git a/Gems/Terrain/Code/Source/EditorTerrainModule.h b/Gems/Terrain/Code/Source/EditorTerrainModule.h new file mode 100644 index 0000000000..76c4706478 --- /dev/null +++ b/Gems/Terrain/Code/Source/EditorTerrainModule.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#pragma once + +#include + +namespace Terrain +{ + class EditorTerrainModule + : public TerrainModule + { + public: + AZ_RTTI(EditorTerrainModule, "{68693F28-7051-4C14-85EA-DE6FD8CFCBD6}", TerrainModule); + AZ_CLASS_ALLOCATOR(EditorTerrainModule, AZ::SystemAllocator, 0); + + EditorTerrainModule(); + + AZ::ComponentTypeList GetRequiredSystemComponents() const override; + }; +} diff --git a/Gems/Terrain/Code/Source/TerrainModule.cpp b/Gems/Terrain/Code/Source/TerrainModule.cpp new file mode 100644 index 0000000000..ec9325eb5c --- /dev/null +++ b/Gems/Terrain/Code/Source/TerrainModule.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#include +#include + +#include +#include +#include + +namespace Terrain +{ + TerrainModule::TerrainModule() + : AZ::Module() + { + m_descriptors.insert(m_descriptors.end(), { + TerrainSystemComponent::CreateDescriptor(), + TerrainSurfaceDataSystemComponent::CreateDescriptor(), + }); + } + + AZ::ComponentTypeList TerrainModule::GetRequiredSystemComponents() const + { + return AZ::ComponentTypeList{ + azrtti_typeid(), + azrtti_typeid(), + }; + } +} + +#if !defined(TERRAIN_EDITOR) +// 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(Gem_Terrain, Terrain::TerrainModule) +#endif + diff --git a/Gems/Terrain/Code/Source/TerrainModule.h b/Gems/Terrain/Code/Source/TerrainModule.h new file mode 100644 index 0000000000..c665ee44eb --- /dev/null +++ b/Gems/Terrain/Code/Source/TerrainModule.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#pragma once + +#include + +namespace Terrain +{ + class TerrainModule + : public AZ::Module + { + public: + AZ_RTTI(TerrainModule, "{B1CFB3A0-EA27-4AF0-A16D-E943C98FED88}", AZ::Module); + AZ_CLASS_ALLOCATOR(TerrainModule, AZ::SystemAllocator, 0); + + TerrainModule(); + + AZ::ComponentTypeList GetRequiredSystemComponents() const override; + }; +} diff --git a/Gems/Terrain/Code/Tests/TerrainEditorTest.cpp b/Gems/Terrain/Code/Tests/TerrainEditorTest.cpp new file mode 100644 index 0000000000..47492dfe40 --- /dev/null +++ b/Gems/Terrain/Code/Tests/TerrainEditorTest.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#include + +class TerrainEditorTest + : public ::testing::Test +{ +protected: + void SetUp() override + { + + } + + void TearDown() override + { + + } +}; + +TEST_F(TerrainEditorTest, SanityTest) +{ + ASSERT_TRUE(true); +} + +AZ_UNIT_TEST_HOOK(DEFAULT_UNIT_TEST_ENV); diff --git a/Gems/Terrain/Code/Tests/TerrainTest.cpp b/Gems/Terrain/Code/Tests/TerrainTest.cpp new file mode 100644 index 0000000000..9b47c91a31 --- /dev/null +++ b/Gems/Terrain/Code/Tests/TerrainTest.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#include + +class TerrainTest + : public ::testing::Test +{ +protected: + void SetUp() override + { + + } + + void TearDown() override + { + + } +}; + +TEST_F(TerrainTest, SanityTest) +{ + ASSERT_TRUE(true); +} + +AZ_UNIT_TEST_HOOK(DEFAULT_UNIT_TEST_ENV); diff --git a/Gems/Terrain/Code/terrain_editor_shared_files.cmake b/Gems/Terrain/Code/terrain_editor_shared_files.cmake new file mode 100644 index 0000000000..68ec9aeb54 --- /dev/null +++ b/Gems/Terrain/Code/terrain_editor_shared_files.cmake @@ -0,0 +1,16 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +set(FILES + Source/EditorComponents/EditorTerrainSystemComponent.cpp + Source/EditorComponents/EditorTerrainSystemComponent.h + Source/EditorTerrainModule.cpp + Source/EditorTerrainModule.h + Source/TerrainModule.cpp + Source/TerrainModule.h +) diff --git a/Gems/Terrain/Code/terrain_editor_tests_files.cmake b/Gems/Terrain/Code/terrain_editor_tests_files.cmake new file mode 100644 index 0000000000..d5d0ec5393 --- /dev/null +++ b/Gems/Terrain/Code/terrain_editor_tests_files.cmake @@ -0,0 +1,11 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +set(FILES + Tests/TerrainEditorTest.cpp +) diff --git a/Gems/Terrain/Code/terrain_files.cmake b/Gems/Terrain/Code/terrain_files.cmake new file mode 100644 index 0000000000..c67d0c63b4 --- /dev/null +++ b/Gems/Terrain/Code/terrain_files.cmake @@ -0,0 +1,14 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +set(FILES + Source/Components/TerrainSurfaceDataSystemComponent.cpp + Source/Components/TerrainSurfaceDataSystemComponent.h + Source/Components/TerrainSystemComponent.cpp + Source/Components/TerrainSystemComponent.h +) diff --git a/Gems/Terrain/Code/terrain_shared_files.cmake b/Gems/Terrain/Code/terrain_shared_files.cmake new file mode 100644 index 0000000000..211182b0fa --- /dev/null +++ b/Gems/Terrain/Code/terrain_shared_files.cmake @@ -0,0 +1,12 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +set(FILES + Source/TerrainModule.h + Source/TerrainModule.cpp +) diff --git a/Gems/Terrain/Code/terrain_tests_files.cmake b/Gems/Terrain/Code/terrain_tests_files.cmake new file mode 100644 index 0000000000..beed6bd83d --- /dev/null +++ b/Gems/Terrain/Code/terrain_tests_files.cmake @@ -0,0 +1,11 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +set(FILES + Tests/TerrainTest.cpp +) diff --git a/Gems/Terrain/gem.json b/Gems/Terrain/gem.json new file mode 100644 index 0000000000..ccf034d399 --- /dev/null +++ b/Gems/Terrain/gem.json @@ -0,0 +1,10 @@ +{ + "gem_name": "Terrain", + "display_name": "Terrain (WIP)", + "license": "Apache-2.0 Or MIT", + "origin": "Open 3D Engine - o3de.org", + "summary": "The Terrain Gem is a WIP (work-in-progress) Gem for providing terrain services including authoring workflows, rendering, and physics.", + "canonical_tags": [ "Gem" ], + "user_tags": [ "Environment", "Terrain" ], + "icon_path": "preview.png" +} diff --git a/Gems/Terrain/preview.png b/Gems/Terrain/preview.png new file mode 100644 index 0000000000..2f1ed47754 --- /dev/null +++ b/Gems/Terrain/preview.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6d6204c6730e5675791765ca194e9b1cbec282208e280507de830afc2805e5fa +size 41127 diff --git a/Gems/Vegetation/Code/Source/VegetationSystemComponent.cpp b/Gems/Vegetation/Code/Source/VegetationSystemComponent.cpp index dd0e63c15b..345c27d27a 100644 --- a/Gems/Vegetation/Code/Source/VegetationSystemComponent.cpp +++ b/Gems/Vegetation/Code/Source/VegetationSystemComponent.cpp @@ -47,19 +47,24 @@ namespace Vegetation void VegetationSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services) { - services.push_back(AZ_CRC("VegetationSystemService", 0xa2322728)); + services.push_back(AZ_CRC_CE("VegetationSystemService")); } void VegetationSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& services) { - services.push_back(AZ_CRC("VegetationSystemService", 0xa2322728)); + services.push_back(AZ_CRC_CE("VegetationSystemService")); } void VegetationSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& services) { - services.push_back(AZ_CRC("VegetationAreaSystemService", 0x36da2b62)); - services.push_back(AZ_CRC("VegetationInstanceSystemService", 0x823a6007)); - services.push_back(AZ_CRC("SurfaceDataProviderService", 0xfe9fb95e)); + services.push_back(AZ_CRC_CE("VegetationAreaSystemService")); + services.push_back(AZ_CRC_CE("VegetationInstanceSystemService")); + services.push_back(AZ_CRC_CE("SurfaceDataSystemService")); + } + + void VegetationSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& services) + { + services.push_back(AZ_CRC_CE("SurfaceDataProviderService")); } void VegetationSystemComponent::Reflect(AZ::ReflectContext* context) diff --git a/Gems/Vegetation/Code/Source/VegetationSystemComponent.h b/Gems/Vegetation/Code/Source/VegetationSystemComponent.h index ff4ab17586..bbe92e2cf8 100644 --- a/Gems/Vegetation/Code/Source/VegetationSystemComponent.h +++ b/Gems/Vegetation/Code/Source/VegetationSystemComponent.h @@ -22,6 +22,7 @@ namespace Vegetation static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services); static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& services); static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& services); + static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& services); static void Reflect(AZ::ReflectContext* context); VegetationSystemComponent(); diff --git a/engine.json b/engine.json index 29532347db..63bddc9548 100644 --- a/engine.json +++ b/engine.json @@ -76,6 +76,7 @@ "Gems/StartingPointInput", "Gems/StartingPointMovement", "Gems/SurfaceData", + "Gems/Terrain", "Gems/TestAssetBuilder", "Gems/TextureAtlas", "Gems/TickBusOrderViewer", From a92684c0b803c2f36f2cad6993a6d7453a7875c1 Mon Sep 17 00:00:00 2001 From: Mike Chang <62353586+amzn-changml@users.noreply.github.com> Date: Mon, 23 Aug 2021 16:07:02 -0700 Subject: [PATCH 51/53] Jenkinsfile LFS fix for iOS/Mac pulls (#3396) * Add git lfs install and pull into Jenkins Git pull stage Signed-off-by: Mike Chang --- scripts/build/Jenkins/Jenkinsfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/build/Jenkins/Jenkinsfile b/scripts/build/Jenkins/Jenkinsfile index 3d8c32f0f3..6231f9006d 100644 --- a/scripts/build/Jenkins/Jenkinsfile +++ b/scripts/build/Jenkins/Jenkinsfile @@ -338,6 +338,11 @@ def PreBuildCommonSteps(Map pipelineConfig, String snapshot, String repositoryNa else command += '.cmd' command += " -u ${pipelineConfig.BUILD_ENTRY_POINT} --platform ${platform} --type clean" palSh(command, "Running ${platform} clean") + + if(fileExists('.lfsconfig')) { + palSh("git lfs install", "LFS config exists. Installing LFS hooks to local repo") + palSh("git lfs pull", "Pulling new LFS objects") + } } } From ef9666cb105e4088efd426680313153aad15c344 Mon Sep 17 00:00:00 2001 From: amzn-sean <75276488+amzn-sean@users.noreply.github.com> Date: Tue, 24 Aug 2021 13:43:19 +0100 Subject: [PATCH 52/53] fixed case where the Physics Asset could not be set correctly (#3390) Signed-off-by: amzn-sean <75276488+amzn-sean@users.noreply.github.com> --- Gems/PhysX/Code/Source/EditorColliderComponent.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Gems/PhysX/Code/Source/EditorColliderComponent.cpp b/Gems/PhysX/Code/Source/EditorColliderComponent.cpp index 2445aba9bd..c337ab0a85 100644 --- a/Gems/PhysX/Code/Source/EditorColliderComponent.cpp +++ b/Gems/PhysX/Code/Source/EditorColliderComponent.cpp @@ -122,7 +122,10 @@ namespace PhysX if (m_shapeType != Physics::ShapeType::PhysicsAsset && m_lastShapeType == Physics::ShapeType::PhysicsAsset) { + //clean up any reference to a physics assets, and re-initialize to an empty Pipeline::MeshAsset asset. m_physicsAsset.m_pxAsset.Reset(); + m_physicsAsset.m_pxAsset = AZ::Data::Asset(AZ::Data::AssetLoadBehavior::QueueLoad); + m_physicsAsset.m_configuration = Physics::PhysicsAssetShapeConfiguration(); } m_lastShapeType = m_shapeType; From 8c573979a96c4dd12705668007e3268102f0ae04 Mon Sep 17 00:00:00 2001 From: hultonha <82228511+hultonha@users.noreply.github.com> Date: Tue, 24 Aug 2021 16:25:08 +0100 Subject: [PATCH 53/53] Updates to camera tests to support different delta times and some further tidy-up (#3324) * updates to camera tests to support different delta times and some further tidy-up Signed-off-by: hultonha * support variable delta time in mouse move test Signed-off-by: hultonha --- .../test_ModularViewportCameraController.cpp | 298 ++++++++++++------ .../AzFramework/Viewport/CameraInput.cpp | 1 - .../Viewport/ViewportMessages.h | 4 +- .../Viewport/RenderViewportWidget.h | 1 - .../Source/Viewport/RenderViewportWidget.cpp | 5 - 5 files changed, 198 insertions(+), 111 deletions(-) diff --git a/Code/Editor/Lib/Tests/test_ModularViewportCameraController.cpp b/Code/Editor/Lib/Tests/test_ModularViewportCameraController.cpp index 6fcf3faffd..28bc6fe3b3 100644 --- a/Code/Editor/Lib/Tests/test_ModularViewportCameraController.cpp +++ b/Code/Editor/Lib/Tests/test_ModularViewportCameraController.cpp @@ -19,6 +19,66 @@ namespace UnitTest using AzToolsFramework::ViewportInteraction::MouseInteractionEvent; + class ViewportMouseCursorRequestImpl : public AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Handler + { + public: + void Connect(const AzFramework::ViewportId viewportId, AzToolsFramework::QtEventToAzInputMapper* inputChannelMapper) + { + AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Handler::BusConnect(viewportId); + m_inputChannelMapper = inputChannelMapper; + } + + void Disconnect() + { + AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Handler::BusDisconnect(); + } + + // ViewportMouseCursorRequestBus overrides ... + void BeginCursorCapture() override; + void EndCursorCapture() override; + bool IsMouseOver() const override; + + private: + AzToolsFramework::QtEventToAzInputMapper* m_inputChannelMapper = nullptr; + }; + + void ViewportMouseCursorRequestImpl::BeginCursorCapture() + { + m_inputChannelMapper->SetCursorCaptureEnabled(true); + } + + void ViewportMouseCursorRequestImpl::EndCursorCapture() + { + m_inputChannelMapper->SetCursorCaptureEnabled(false); + } + + bool ViewportMouseCursorRequestImpl::IsMouseOver() const + { + return true; + } + + class TestModularCameraViewportContextImpl : public AtomToolsFramework::ModularCameraViewportContext + { + public: + AZ::Transform GetCameraTransform() const override + { + return m_cameraTransform; + } + + void SetCameraTransform(const AZ::Transform& transform) override + { + m_cameraTransform = transform; + } + + void ConnectViewMatrixChangedHandler(AZ::RPI::ViewportContext::MatrixChangedEvent::Handler&) override + { + // noop + } + + private: + AZ::Transform m_cameraTransform = AZ::Transform::CreateIdentity(); + }; + class ModularViewportCameraControllerFixture : public AllocatorsTestFixture { public: @@ -48,123 +108,159 @@ namespace UnitTest AllocatorsTestFixture::TearDown(); } + void PrepareCollaborators() + { + AzFramework::NativeWindowHandle nativeWindowHandle = nullptr; + + // listen for events signaled from QtEventToAzInputMapper and forward to the controller list + QObject::connect( + m_inputChannelMapper.get(), &AzToolsFramework::QtEventToAzInputMapper::InputChannelUpdated, m_rootWidget.get(), + [this, nativeWindowHandle](const AzFramework::InputChannel* inputChannel, [[maybe_unused]] QEvent* event) + { + m_controllerList->HandleInputChannelEvent( + AzFramework::ViewportControllerInputEvent{ TestViewportId, nativeWindowHandle, *inputChannel }); + }); + + m_mockWindowRequests.Connect(nativeWindowHandle); + + using ::testing::Return; + // note: WindowRequests is used internally by ModularViewportCameraController, this ensures it returns the viewport size we want + ON_CALL(m_mockWindowRequests, GetClientAreaSize()) + .WillByDefault(Return(AzFramework::WindowSize(WidgetSize.width(), WidgetSize.height()))); + + // respond to begin/end cursor capture events + m_viewportMouseCursorRequests.Connect(TestViewportId, m_inputChannelMapper.get()); + + // create editor modular camera + auto controller = CreateModularViewportCameraController(TestViewportId); + + // set some overrides for the test + controller->SetCameraViewportContextBuilderCallback( + [this](AZStd::unique_ptr& cameraViewportContext) + { + cameraViewportContext = AZStd::make_unique(); + m_cameraViewportContextView = cameraViewportContext.get(); + }); + + // disable smoothing in the test + controller->SetCameraPropsBuilderCallback( + [](AzFramework::CameraProps& cameraProps) + { + cameraProps.m_rotateSmoothingEnabledFn = [] + { + return false; + }; + + cameraProps.m_translateSmoothingEnabledFn = [] + { + return false; + }; + }); + + m_controllerList->Add(controller); + } + + void HaltCollaborators() + { + m_mockWindowRequests.Disconnect(); + m_viewportMouseCursorRequests.Disconnect(); + m_cameraViewportContextView = nullptr; + } + + void RepeatDiagonalMouseMovements(const AZStd::function& deltaTimeFn) + { + // move to the center of the screen + auto start = QPoint(WidgetSize.width() / 2, WidgetSize.height() / 2); + MouseMove(m_rootWidget.get(), start, QPoint(0, 0)); + m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(deltaTimeFn()), AZ::ScriptTimePoint() }); + + // move mouse diagonally to top right, then to bottom left and back repeatedly + auto current = start; + auto halfDelta = QPoint(200, -200); + const int iterationsPerDiagonal = 50; + for (int diagonals = 0; diagonals < 80; ++diagonals) + { + for (int i = 0; i < iterationsPerDiagonal; ++i) + { + MousePressAndMove(m_rootWidget.get(), current, halfDelta / iterationsPerDiagonal, Qt::MouseButton::RightButton); + m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(deltaTimeFn()), AZ::ScriptTimePoint() }); + current += halfDelta / iterationsPerDiagonal; + } + + if (diagonals % 2 == 0) + { + halfDelta.setX(halfDelta.x() * -1); + halfDelta.setY(halfDelta.y() * -1); + } + } + + QTest::mouseRelease(m_rootWidget.get(), Qt::MouseButton::RightButton, Qt::KeyboardModifier::NoModifier, current); + m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(deltaTimeFn()), AZ::ScriptTimePoint() }); + } + AZStd::unique_ptr m_rootWidget; AzFramework::ViewportControllerListPtr m_controllerList; AZStd::unique_ptr m_inputChannelMapper; + ::testing::NiceMock m_mockWindowRequests; + ViewportMouseCursorRequestImpl m_viewportMouseCursorRequests; + AtomToolsFramework::ModularCameraViewportContext* m_cameraViewportContextView = nullptr; }; const AzFramework::ViewportId ModularViewportCameraControllerFixture::TestViewportId = AzFramework::ViewportId(0); - class TestModularCameraViewportContextImpl : public AtomToolsFramework::ModularCameraViewportContext + TEST_F(ModularViewportCameraControllerFixture, MouseMovementDoesNotAccumulateExcessiveDriftInModularViewportCameraWithVaryingDeltaTime) { - public: - AZ::Transform GetCameraTransform() const override - { - return m_cameraTransform; - } - - void SetCameraTransform(const AZ::Transform& transform) override - { - m_cameraTransform = transform; - } - - void ConnectViewMatrixChangedHandler(AZ::RPI::ViewportContext::MatrixChangedEvent::Handler&) override - { - // noop - } - - private: - AZ::Transform m_cameraTransform = AZ::Transform::CreateIdentity(); - }; - - TEST_F(ModularViewportCameraControllerFixture, Mouse_movement_does_not_accumulate_excessive_drift_in_modular_viewport_camera) - { - AzFramework::NativeWindowHandle nativeWindowHandle = nullptr; - - const float deltaTime = 1.0f / 60.0f; // mimic 60fps - // Given - // listen for events signaled from QtEventToAzInputMapper and forward to the controller list - QObject::connect( - m_inputChannelMapper.get(), &AzToolsFramework::QtEventToAzInputMapper::InputChannelUpdated, m_rootWidget.get(), - [this, nativeWindowHandle](const AzFramework::InputChannel* inputChannel, [[maybe_unused]] QEvent* event) - { - m_controllerList->HandleInputChannelEvent( - AzFramework::ViewportControllerInputEvent{ TestViewportId, nativeWindowHandle, *inputChannel }); - }); - - using ::testing::NiceMock; - using ::testing::Return; - - NiceMock mockWindowRequests; - mockWindowRequests.Connect(nativeWindowHandle); - - // note: WindowRequests is used internally by ModularViewportCameraController, this ensures it returns the viewport size we want - ON_CALL(mockWindowRequests, GetClientAreaSize()) - .WillByDefault(Return(AzFramework::WindowSize(WidgetSize.width(), WidgetSize.height()))); - - // create editor modular camera - auto controller = CreateModularViewportCameraController(TestViewportId); - - // set some overrides for the test - AtomToolsFramework::ModularCameraViewportContext* cameraViewportContextView = nullptr; - controller->SetCameraViewportContextBuilderCallback( - [&cameraViewportContextView](AZStd::unique_ptr& cameraViewportContext) - { - cameraViewportContext = AZStd::make_unique(); - cameraViewportContextView = cameraViewportContext.get(); - }); - - controller->SetCameraPropsBuilderCallback( - [](AzFramework::CameraProps& cameraProps) - { - cameraProps.m_rotateSmoothingEnabledFn = [] - { - return false; - }; - - cameraProps.m_translateSmoothingEnabledFn = [] - { - return false; - }; - }); - - m_controllerList->Add(controller); - - // move to the center of the screen - auto start = QPoint(WidgetSize.width() / 2, WidgetSize.height() / 2); - MouseMove(m_rootWidget.get(), start, QPoint(0, 0)); - m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(deltaTime), AZ::ScriptTimePoint() }); + PrepareCollaborators(); // When - // move mouse diagonally to top right, then to bottom left and back repeatedly - auto current = start; - auto halfDelta = QPoint(200, -200); - const int iterationsPerDiagonal = 50; - for (int diagonals = 0; diagonals < 80; ++diagonals) - { - for (int i = 0; i < iterationsPerDiagonal; ++i) + RepeatDiagonalMouseMovements( + [t = 0.0f]() mutable { - MousePressAndMove(m_rootWidget.get(), current, halfDelta / iterationsPerDiagonal, Qt::MouseButton::RightButton); - m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(deltaTime), AZ::ScriptTimePoint() }); - current += halfDelta / iterationsPerDiagonal; - } - - if (diagonals % 2 == 0) - { - halfDelta.setX(halfDelta.x() * -1); - halfDelta.setY(halfDelta.y() * -1); - } - } - - QTest::mouseRelease(m_rootWidget.get(), Qt::MouseButton::RightButton, Qt::KeyboardModifier::NoModifier, current); - m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(deltaTime), AZ::ScriptTimePoint() }); + // vary between 30 and 50 fps (40 +/- 10) + const float fps = 40.0f + (10.0f * AZStd::sin(t)); + t += AZ::DegToRad(5.0f); + return 1.0f / fps; + }); // Then // ensure the camera rotation is the identity (no significant drift has occurred as we moved the mouse) - const AZ::Transform cameraRotation = cameraViewportContextView->GetCameraTransform(); + const AZ::Transform cameraRotation = m_cameraViewportContextView->GetCameraTransform(); EXPECT_THAT(cameraRotation.GetRotation(), IsClose(AZ::Quaternion::CreateIdentity())); - mockWindowRequests.Disconnect(); + // Clean-up + HaltCollaborators(); } + + class ModularViewportCameraControllerDeltaTimeParamFixture + : public ModularViewportCameraControllerFixture + , public ::testing::WithParamInterface // delta time + { + }; + + TEST_P( + ModularViewportCameraControllerDeltaTimeParamFixture, + MouseMovementDoesNotAccumulateExcessiveDriftInModularViewportCameraWithFixedDeltaTime) + { + // Given + PrepareCollaborators(); + + // When + RepeatDiagonalMouseMovements( + [this] + { + return GetParam(); + }); + + // Then + // ensure the camera rotation is the identity (no significant drift has occurred as we moved the mouse) + const AZ::Transform cameraRotation = m_cameraViewportContextView->GetCameraTransform(); + EXPECT_THAT(cameraRotation.GetRotation(), IsClose(AZ::Quaternion::CreateIdentity())); + + // Clean-up + HaltCollaborators(); + } + + INSTANTIATE_TEST_CASE_P( + All, ModularViewportCameraControllerDeltaTimeParamFixture, testing::Values(1.0f / 60.0f, 1.0f / 50.0f, 1.0f / 30.0f)); } // namespace UnitTest diff --git a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp index 74adcd9543..72984f8111 100644 --- a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp +++ b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp @@ -802,7 +802,6 @@ namespace AzFramework { return VerticalMotionEvent{ aznumeric_cast(inputChannel.GetValue()) }; } - else if (inputChannelId == InputDeviceMouse::Movement::Z) { return ScrollEvent{ inputChannel.GetValue() }; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.h index 543d5fb3a5..f6ba87a0ec 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.h @@ -275,9 +275,7 @@ namespace AzToolsFramework virtual void BeginCursorCapture() = 0; //! Restores the cursor and ends locking it in place, allowing it to be moved freely. virtual void EndCursorCapture() = 0; - //! Gets the most recent recorded cursor position in the viewport in screen space coordinates. - virtual AzFramework::ScreenPoint ViewportCursorScreenPosition() = 0; - //! Is mouse over viewport. + //! Is the mouse over the viewport. virtual bool IsMouseOver() const = 0; protected: diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/RenderViewportWidget.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/RenderViewportWidget.h index bb26e116af..b6db6b78ae 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/RenderViewportWidget.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/RenderViewportWidget.h @@ -109,7 +109,6 @@ namespace AtomToolsFramework // AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Handler ... void BeginCursorCapture() override; void EndCursorCapture() override; - AzFramework::ScreenPoint ViewportCursorScreenPosition() override; bool IsMouseOver() const override; // AzFramework::WindowRequestBus::Handler ... diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp index bf356d2b99..cbb30ba6da 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp @@ -403,11 +403,6 @@ namespace AtomToolsFramework return aznumeric_cast(devicePixelRatioF()); } - AzFramework::ScreenPoint RenderViewportWidget::ViewportCursorScreenPosition() - { - return AzToolsFramework::ViewportInteraction::ScreenPointFromQPoint(m_mousePosition.toPoint()); - } - bool RenderViewportWidget::IsMouseOver() const { return m_mouseOver;