From 724ab7192fd08582e5e81598471e539d862d9015 Mon Sep 17 00:00:00 2001 From: Norbert Prokopiuk Date: Thu, 1 Aug 2024 13:06:22 +0200 Subject: [PATCH 1/2] Added bus which allows for passing configuration to pointCloudEditorComponent Signed-off-by: Norbert Prokopiuk --- .../PointcloudComponentConfigurationBus.h | 20 +++++++++++++++++++ .../Include/Pointcloud/PointcloudTypeIds.h | 6 ++++++ .../Source/Clients/PointcloudComponent.cpp | 17 ---------------- .../Code/Source/Clients/PointcloudComponent.h | 3 ++- .../Components/PointcloudEditorComponent.cpp | 13 ++++++++++++ .../Components/PointcloudEditorComponent.h | 9 ++++++++- 6 files changed, 49 insertions(+), 19 deletions(-) create mode 100644 Gems/Pointcloud/Code/Include/Pointcloud/PointcloudComponentConfigurationBus.h diff --git a/Gems/Pointcloud/Code/Include/Pointcloud/PointcloudComponentConfigurationBus.h b/Gems/Pointcloud/Code/Include/Pointcloud/PointcloudComponentConfigurationBus.h new file mode 100644 index 0000000..388be13 --- /dev/null +++ b/Gems/Pointcloud/Code/Include/Pointcloud/PointcloudComponentConfigurationBus.h @@ -0,0 +1,20 @@ +#pragma once + +#include +#include +#include +#include + +namespace Pointcloud +{ + class PointCloudEditorComponentRequests : public AZ::ComponentBus + { + public: + AZ_RTTI(PointCloudEditorComponentRequests, PointCloudEditorComponentRequestsTypeId); + virtual ~PointCloudEditorComponentRequests() = default; + virtual void SetPointcloudAsset(AZ::Data::Asset asset) = 0; + virtual void SetPointSize(float pointSize) = 0; + }; + + using PointcloudEditorComponentConfigurationBus = AZ::EBus; +} // namespace Pointcloud \ No newline at end of file diff --git a/Gems/Pointcloud/Code/Include/Pointcloud/PointcloudTypeIds.h b/Gems/Pointcloud/Code/Include/Pointcloud/PointcloudTypeIds.h index f458968..18bde03 100644 --- a/Gems/Pointcloud/Code/Include/Pointcloud/PointcloudTypeIds.h +++ b/Gems/Pointcloud/Code/Include/Pointcloud/PointcloudTypeIds.h @@ -21,6 +21,12 @@ namespace Pointcloud // so they use the Same TypeId inline constexpr const char* PointcloudEditorModuleTypeId = PointcloudModuleTypeId; + // Components TypeIds + inline constexpr const char* PointcloudComponentTypeId = "{0190c091-83aa-7c6e-a6da-5efea1f23473}"; + inline constexpr const char* PointcloudEditorComponentTypeId = "{018fba15-560f-78cb-afb4-cf4d00cefc17}"; + // Interface TypeIds inline constexpr const char* PointcloudRequestsTypeId = "{86CA76D8-2225-4C50-86E4-B1C8EFDEA8EF}"; + // component buses + inline constexpr const char* PointCloudEditorComponentRequestsTypeId = "{5985443b-feab-444f-a633-4b2a8142c560}"; } // namespace Pointcloud diff --git a/Gems/Pointcloud/Code/Source/Clients/PointcloudComponent.cpp b/Gems/Pointcloud/Code/Source/Clients/PointcloudComponent.cpp index 5a329f5..364c431 100644 --- a/Gems/Pointcloud/Code/Source/Clients/PointcloudComponent.cpp +++ b/Gems/Pointcloud/Code/Source/Clients/PointcloudComponent.cpp @@ -29,23 +29,6 @@ namespace Pointcloud ->Version(0) ->Field("PointcloudAsset", &PointcloudComponent::m_pointcloudAsset) ->Field("PointSize", &PointcloudComponent::m_pointSize); - if (AZ::EditContext* editContext = serializeContext->GetEditContext()) - { - editContext->Class("PointcloudComponent", "PointcloudComponent") - ->ClassElement(AZ::Edit::ClassElements::EditorData, "PointcloudComponent") - ->Attribute(AZ::Edit::Attributes::Category, "RobotecTools") - ->Attribute(AZ::Edit::Attributes::AutoExpand, true) - ->DataElement( - AZ::Edit::UIHandlers::Default, - &PointcloudComponent::m_pointcloudAsset, - "Pointcloud Asset", - "Asset containing the pointcloud data") - ->DataElement( - AZ::Edit::UIHandlers::Default, - &PointcloudComponent::m_pointSize, - "Point Size", - "Size of the points in the pointcloud"); - } } } diff --git a/Gems/Pointcloud/Code/Source/Clients/PointcloudComponent.h b/Gems/Pointcloud/Code/Source/Clients/PointcloudComponent.h index 719f567..2c4de60 100644 --- a/Gems/Pointcloud/Code/Source/Clients/PointcloudComponent.h +++ b/Gems/Pointcloud/Code/Source/Clients/PointcloudComponent.h @@ -9,6 +9,7 @@ #include #include #include +#include namespace Pointcloud { @@ -17,7 +18,7 @@ namespace Pointcloud , private AZ::TransformNotificationBus::Handler { public: - AZ_COMPONENT(PointcloudComponent, "{0190c091-83aa-7c6e-a6da-5efea1f23473}"); + AZ_COMPONENT(PointcloudComponent, PointcloudComponentTypeId); PointcloudComponent() = default; PointcloudComponent(const AZ::Data::Asset& pointcloudAsset, const float pointSize); ~PointcloudComponent() = default; diff --git a/Gems/Pointcloud/Code/Source/Tools/Components/PointcloudEditorComponent.cpp b/Gems/Pointcloud/Code/Source/Tools/Components/PointcloudEditorComponent.cpp index 992438e..e4ac8ce 100644 --- a/Gems/Pointcloud/Code/Source/Tools/Components/PointcloudEditorComponent.cpp +++ b/Gems/Pointcloud/Code/Source/Tools/Components/PointcloudEditorComponent.cpp @@ -86,12 +86,14 @@ namespace Pointcloud }); AzToolsFramework::EditorEntityInfoNotificationBus::Handler::BusConnect(); AZ::TransformNotificationBus::Handler::BusConnect(GetEntityId()); + PointcloudEditorComponentConfigurationBus::Handler::BusConnect(GetEntityId()); } void PointcloudEditorComponent::Deactivate() { AZ::TransformNotificationBus::Handler::BusDisconnect(); AzToolsFramework::EditorEntityInfoNotificationBus::Handler::BusDisconnect(); + PointcloudEditorComponentConfigurationBus::Handler::BusDisconnect(); m_featureProcessor->ReleasePointcloud(m_pointcloudHandle); } @@ -108,6 +110,7 @@ namespace Pointcloud } return AZ::Edit::PropertyRefreshLevels::None; } + AZ::Crc32 PointcloudEditorComponent::OnAssetChanged() { if (m_featureProcessor) @@ -148,4 +151,14 @@ namespace Pointcloud m_featureProcessor->SetTransform(m_pointcloudHandle, world); } } + + void PointcloudEditorComponent::SetPointcloudAsset(AZ::Data::Asset asset) + { + m_pointcloudAsset = asset; + } + void PointcloudEditorComponent::SetPointSize(float pointSize) + { + m_pointSize = pointSize; + } + } // namespace Pointcloud diff --git a/Gems/Pointcloud/Code/Source/Tools/Components/PointcloudEditorComponent.h b/Gems/Pointcloud/Code/Source/Tools/Components/PointcloudEditorComponent.h index 68a92e6..6d8df10 100644 --- a/Gems/Pointcloud/Code/Source/Tools/Components/PointcloudEditorComponent.h +++ b/Gems/Pointcloud/Code/Source/Tools/Components/PointcloudEditorComponent.h @@ -9,7 +9,9 @@ #include #include #include +#include #include +#include namespace Pointcloud { @@ -18,9 +20,10 @@ namespace Pointcloud : public AzToolsFramework::Components::EditorComponentBase , private AZ::TransformNotificationBus::Handler , private AzToolsFramework::EditorEntityInfoNotificationBus::Handler + , private PointcloudEditorComponentConfigurationBus::Handler { public: - AZ_EDITOR_COMPONENT(PointcloudEditorComponent, "{018fba15-560f-78cb-afb4-cf4d00cefc17}"); + AZ_EDITOR_COMPONENT(PointcloudEditorComponent, PointcloudEditorComponentTypeId); PointcloudEditorComponent() = default; ~PointcloudEditorComponent() = default; @@ -39,6 +42,10 @@ namespace Pointcloud // AzToolsFramework::EditorEntityInfoNotificationBus overrides ... void OnEntityInfoUpdatedVisibility(AZ::EntityId entityId, bool visible) override; + // PointcloudEditorComponentConfigurationBus::Handler overrides ... + void SetPointcloudAsset(AZ::Data::Asset asset) override; + void SetPointSize(float pointSize) override; + AZ::Crc32 OnSetPointSize(); AZ::Crc32 OnAssetChanged(); From 7c507c8cc96af233debd1dcf0adc4a26ae81d813 Mon Sep 17 00:00:00 2001 From: Norbert Prokopiuk Date: Thu, 1 Aug 2024 15:40:35 +0200 Subject: [PATCH 2/2] Changed order of buses disconnection Signed-off-by: Norbert Prokopiuk --- .../Include/Pointcloud/PointcloudComponentConfigurationBus.h | 2 +- .../Code/Source/Tools/Components/PointcloudEditorComponent.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Gems/Pointcloud/Code/Include/Pointcloud/PointcloudComponentConfigurationBus.h b/Gems/Pointcloud/Code/Include/Pointcloud/PointcloudComponentConfigurationBus.h index 388be13..ba1bb21 100644 --- a/Gems/Pointcloud/Code/Include/Pointcloud/PointcloudComponentConfigurationBus.h +++ b/Gems/Pointcloud/Code/Include/Pointcloud/PointcloudComponentConfigurationBus.h @@ -17,4 +17,4 @@ namespace Pointcloud }; using PointcloudEditorComponentConfigurationBus = AZ::EBus; -} // namespace Pointcloud \ No newline at end of file +} // namespace Pointcloud diff --git a/Gems/Pointcloud/Code/Source/Tools/Components/PointcloudEditorComponent.cpp b/Gems/Pointcloud/Code/Source/Tools/Components/PointcloudEditorComponent.cpp index e4ac8ce..050a32a 100644 --- a/Gems/Pointcloud/Code/Source/Tools/Components/PointcloudEditorComponent.cpp +++ b/Gems/Pointcloud/Code/Source/Tools/Components/PointcloudEditorComponent.cpp @@ -91,9 +91,10 @@ namespace Pointcloud void PointcloudEditorComponent::Deactivate() { + PointcloudEditorComponentConfigurationBus::Handler::BusDisconnect(); AZ::TransformNotificationBus::Handler::BusDisconnect(); AzToolsFramework::EditorEntityInfoNotificationBus::Handler::BusDisconnect(); - PointcloudEditorComponentConfigurationBus::Handler::BusDisconnect(); + m_featureProcessor->ReleasePointcloud(m_pointcloudHandle); }