Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Point cloud component configuration bus #45

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include <AzCore/EBus/EBus.h>
#include <AzCore/Interface/Interface.h>
#include <Pointcloud/PointcloudAsset.h>
#include <Pointcloud/PointcloudTypeIds.h>

namespace Pointcloud
{
class PointCloudEditorComponentRequests : public AZ::ComponentBus
{
public:
AZ_RTTI(PointCloudEditorComponentRequests, PointCloudEditorComponentRequestsTypeId);
virtual ~PointCloudEditorComponentRequests() = default;
virtual void SetPointcloudAsset(AZ::Data::Asset<PointcloudAsset> asset) = 0;
virtual void SetPointSize(float pointSize) = 0;
};

using PointcloudEditorComponentConfigurationBus = AZ::EBus<PointCloudEditorComponentRequests>;
} // namespace Pointcloud
6 changes: 6 additions & 0 deletions Gems/Pointcloud/Code/Include/Pointcloud/PointcloudTypeIds.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 0 additions & 17 deletions Gems/Pointcloud/Code/Source/Clients/PointcloudComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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", "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");
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion Gems/Pointcloud/Code/Source/Clients/PointcloudComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <AzFramework/Scene/Scene.h>
#include <Pointcloud/PointcloudAsset.h>
#include <Pointcloud/PointcloudFeatureProcessorInterface.h>
#include <Pointcloud/PointcloudTypeIds.h>
namespace Pointcloud
{

Expand All @@ -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>& pointcloudAsset, const float pointSize);
~PointcloudComponent() = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,15 @@ namespace Pointcloud
});
AzToolsFramework::EditorEntityInfoNotificationBus::Handler::BusConnect();
AZ::TransformNotificationBus::Handler::BusConnect(GetEntityId());
PointcloudEditorComponentConfigurationBus::Handler::BusConnect(GetEntityId());
}

void PointcloudEditorComponent::Deactivate()
{
PointcloudEditorComponentConfigurationBus::Handler::BusDisconnect();
AZ::TransformNotificationBus::Handler::BusDisconnect();
AzToolsFramework::EditorEntityInfoNotificationBus::Handler::BusDisconnect();

m_featureProcessor->ReleasePointcloud(m_pointcloudHandle);
}

Expand All @@ -108,6 +111,7 @@ namespace Pointcloud
}
return AZ::Edit::PropertyRefreshLevels::None;
}

AZ::Crc32 PointcloudEditorComponent::OnAssetChanged()
{
if (m_featureProcessor)
Expand Down Expand Up @@ -148,4 +152,14 @@ namespace Pointcloud
m_featureProcessor->SetTransform(m_pointcloudHandle, world);
}
}

void PointcloudEditorComponent::SetPointcloudAsset(AZ::Data::Asset<PointcloudAsset> asset)
{
m_pointcloudAsset = asset;
}
void PointcloudEditorComponent::SetPointSize(float pointSize)
{
m_pointSize = pointSize;
}

} // namespace Pointcloud
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#include <AzFramework/Spawnable/SpawnableEntitiesInterface.h>
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
#include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
#include <Pointcloud/PointcloudComponentConfigurationBus.h>
#include <Pointcloud/PointcloudFeatureProcessorInterface.h>
#include <Pointcloud/PointcloudTypeIds.h>

namespace Pointcloud
{
Expand All @@ -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;

Expand All @@ -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<PointcloudAsset> asset) override;
void SetPointSize(float pointSize) override;

AZ::Crc32 OnSetPointSize();
AZ::Crc32 OnAssetChanged();

Expand Down