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

[Pointcloud] Fixes in Pointcloud Gem #62

Merged
merged 6 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
4 changes: 0 additions & 4 deletions Gems/Pointcloud/Code/Source/Clients/PointcloudComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@

#include "PointcloudComponent.h"
#include <Atom/RPI.Public/Scene.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <Pointcloud/PointcloudComponentControllerConfigurationBus.h>
#include <Pointcloud/PointcloudTypeIds.h>
#include <Render/PointcloudFeatureProcessor.h>

namespace Pointcloud
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ namespace Pointcloud
AZ::SystemTickBus::QueueFunction(
[this]()
{
m_scene = AZ::RPI::Scene::GetSceneForEntityId(m_config.m_editorEntityId);
if (m_scene)
m_featureProcessor = AZ::RPI::Scene::GetFeatureProcessorForEntity<PointcloudFeatureProcessor>(m_config.m_editorEntityId);
if (!m_featureProcessor)
{
m_featureProcessor = m_scene->EnableFeatureProcessor<PointcloudFeatureProcessor>();

AZ_Assert(m_featureProcessor, "Failed to enable PointcloudFeatureProcessorInterface.");
OnAssetChanged();
if (auto* scene = AZ::RPI::Scene::GetSceneForEntityId(m_config.m_editorEntityId))
{
m_featureProcessor = scene->EnableFeatureProcessor<PointcloudFeatureProcessor>();
AZ_Assert(m_featureProcessor, "Failed to enable PointcloudFeatureProcessorInterface.");
}
}
OnAssetChanged();
});
}

Expand Down Expand Up @@ -119,14 +121,16 @@ namespace Pointcloud
AZ::SystemTickBus::QueueFunction(
[this]()
{
m_scene = AZ::RPI::Scene::GetSceneForEntityId(m_config.m_editorEntityId);
if (m_scene)
m_featureProcessor = AZ::RPI::Scene::GetFeatureProcessorForEntity<PointcloudFeatureProcessor>(m_config.m_editorEntityId);
if (!m_featureProcessor)
{
m_featureProcessor = m_scene->EnableFeatureProcessor<PointcloudFeatureProcessor>();

AZ_Assert(m_featureProcessor, "Failed to enable PointcloudFeatureProcessorInterface.");
OnAssetChanged();
if (auto* scene = AZ::RPI::Scene::GetSceneForEntityId(m_config.m_editorEntityId))
{
m_featureProcessor = scene->EnableFeatureProcessor<PointcloudFeatureProcessor>();
AZ_Assert(m_featureProcessor, "Failed to enable PointcloudFeatureProcessorInterface.");
}
}
OnAssetChanged();
});
}

Expand All @@ -153,7 +157,6 @@ namespace Pointcloud
{
if (m_featureProcessor)
{
printf("Feature processor exists\n");
m_featureProcessor->ReleasePointcloud(m_config.m_pointcloudHandle);
if (m_config.m_pointcloudAsset.GetId().IsValid())
{
Expand Down Expand Up @@ -189,6 +192,7 @@ namespace Pointcloud
{
m_config.m_pointcloudAsset = asset;
}

void PointcloudComponentController::SetPointSize(float pointSize)
{
m_config.m_pointSize = pointSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,12 @@

#pragma once

#include "AzCore/Math/Aabb.h"

#include <AzCore/Component/ComponentBus.h>
#include <AzCore/Component/EntityId.h>
#include <AzCore/Component/TransformBus.h>
#include <AzCore/Memory/Memory_fwd.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/base.h>
#include <AzFramework/Spawnable/Spawnable.h>
#include <Pointcloud/PointcloudComponentControllerConfigurationBus.h>
#include <AzCore/Math/Aabb.h>
#include <Pointcloud/PointcloudConfigurationBus.h>
#include <Pointcloud/PointcloudFeatureProcessorInterface.h>
#include <Pointcloud/PointcloudTypeIds.h>

namespace Pointcloud
{
Expand All @@ -37,7 +31,7 @@ namespace Pointcloud
float m_pointSize = 1.0f;
PointcloudFeatureProcessorInterface::PointcloudHandle m_pointcloudHandle =
PointcloudFeatureProcessorInterface::InvalidPointcloudHandle;
AZ::Data::Asset<PointcloudAsset> m_pointcloudAsset;
AZ::Data::Asset<PointcloudAsset> m_pointcloudAsset = {};
};

class PointcloudComponentController
Expand All @@ -61,7 +55,8 @@ namespace Pointcloud
//////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////
void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world);
// AZ::TransformNotificationBus::Handler overrides ...
void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;

// AzToolsFramework::EditorEntityInfoNotificationBus overrides ...
void OnEntityInfoUpdatedVisibility(AZ::EntityId entityId, bool visible);
Expand All @@ -77,7 +72,6 @@ namespace Pointcloud

private:
PointcloudFeatureProcessorInterface* m_featureProcessor = nullptr;
AZ::RPI::Scene* m_scene = nullptr;
PointcloudComponentConfig m_config;
bool visibility = true;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "PointcloudEditorComponent.h"
#include "Clients/PointcloudComponent.h"

#include <Atom/RPI.Public/Scene.h>
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
#include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
#include <Render/PointcloudFeatureProcessor.h>
Expand Down Expand Up @@ -61,17 +60,16 @@ namespace Pointcloud
AzToolsFramework::EditorComponentSelectionRequestsBus::Handler::BusDisconnect();
AzFramework::BoundsRequestBus::Handler::BusDisconnect();
}
bool PointcloudEditorComponent::ShouldActivateController() const
{
return false;
}

AZ::Aabb PointcloudEditorComponent::GetWorldBounds()
{
AZ::Transform transform = AZ::Transform::CreateIdentity();
AZ::TransformBus::EventResult(transform, GetEntityId(), &AZ::TransformBus::Events::GetWorldTM);
AZ::Aabb bounds = m_controller.GetBounds();
bounds.ApplyTransform(transform);
if (bounds.IsValid())
{
bounds.ApplyTransform(transform);
}
return bounds;
}

Expand All @@ -80,7 +78,10 @@ namespace Pointcloud
AZ::Transform transform = AZ::Transform::CreateIdentity();
AZ::TransformBus::EventResult(transform, GetEntityId(), &AZ::TransformBus::Events::GetLocalTM);
AZ::Aabb bounds = m_controller.GetBounds();
bounds.ApplyTransform(transform);
if (bounds.IsValid())
{
bounds.ApplyTransform(transform);
}
zakmat marked this conversation as resolved.
Show resolved Hide resolved
return bounds;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,15 @@

#include "PointcloudComponentController.h"

#include "../../Clients/PointcloudComponent.h"
#include <AzToolsFramework/API/ComponentEntitySelectionBus.h>

#include <AzFramework/Visibility/BoundsBus.h>
#include "Clients/PointcloudComponent.h"

#include <AzCore/Asset/AssetCommon.h>
#include <AzCore/Component/TickBus.h>
#include <AzCore/Component/TransformBus.h>
#include <AzFramework/Entity/EntityContextBus.h>
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
#include <AzFramework/Scene/Scene.h>
#include <AzFramework/Spawnable/SpawnableEntitiesInterface.h>
#include <AzFramework/Visibility/BoundsBus.h>
#include <AzToolsFramework/API/ComponentEntitySelectionBus.h>
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
#include <AzToolsFramework/ToolsComponents/EditorComponentAdapter.h>
#include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
#include <Pointcloud/PointcloudComponentControllerConfigurationBus.h>
#include <Pointcloud/PointcloudFeatureProcessorInterface.h>
#include <Pointcloud/PointcloudTypeIds.h>

Expand Down Expand Up @@ -47,18 +40,20 @@ namespace Pointcloud
// EditorComponentBase interface overrides ...
void Activate() override;
void Deactivate() override;
bool ShouldActivateController() const override;

// AzFramework::BoundsRequestBus overrides ...
AZ::Aabb GetWorldBounds() override;
AZ::Aabb GetLocalBounds() override;

// AzToolsFramework::EditorComponentSelectionRequestsBus overrides ...
AZ::Aabb GetEditorSelectionBoundsViewport(const AzFramework::ViewportInfo& viewportInfo) override;
bool EditorSelectionIntersectRayViewport(
const AzFramework::ViewportInfo& viewportInfo, const AZ::Vector3& src, const AZ::Vector3& dir, float& distance) override;

bool SupportsEditorRayIntersect() override;
bool SupportsEditorRayIntersectViewport(const AzFramework::ViewportInfo& viewportInfo) override;

// AzFramework::EntityDebugDisplayEventBus overrides ...
void DisplayEntityViewport(const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay) override;

private:
Expand Down