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

Add pass template mapping handler initialization #416

Merged
merged 1 commit into from
Jul 19, 2023
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
1 change: 1 addition & 0 deletions Gems/ROS2/Code/Source/ROS2EditorSystemComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ namespace ROS2
void ROS2EditorSystemComponent::Activate()
{
AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusConnect();
ROS2SystemComponent::InitPassTemplateMappingsHandler();
}

void ROS2EditorSystemComponent::Deactivate()
Expand Down
29 changes: 20 additions & 9 deletions Gems/ROS2/Code/Source/ROS2SystemComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <AzCore/Time/ITime.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <AzCore/std/string/string_view.h>
#include <AzFramework/API/ApplicationAPI.h>

namespace ROS2
{
Expand Down Expand Up @@ -112,6 +113,19 @@ namespace ROS2
m_simulationClock = AZStd::make_unique<SimulationClock>();
}

void ROS2SystemComponent::InitPassTemplateMappingsHandler()
{
auto* passSystem = AZ::RPI::PassSystemInterface::Get();
AZ_Assert(passSystem, "Cannot get the pass system.");

m_loadTemplatesHandler = AZ::RPI::PassSystemInterface::OnReadyLoadTemplatesEvent::Handler(
[this]()
{
this->LoadPassTemplateMappings();
});
passSystem->ConnectEvent(m_loadTemplatesHandler);
}

void ROS2SystemComponent::Activate()
{
InitClock();
Expand All @@ -123,15 +137,12 @@ namespace ROS2
m_staticTFBroadcaster = AZStd::make_unique<tf2_ros::StaticTransformBroadcaster>(m_ros2Node);
m_dynamicTFBroadcaster = AZStd::make_unique<tf2_ros::TransformBroadcaster>(m_ros2Node);

auto* passSystem = AZ::RPI::PassSystemInterface::Get();
AZ_Assert(passSystem, "Cannot get the pass system.");

m_loadTemplatesHandler = AZ::RPI::PassSystemInterface::OnReadyLoadTemplatesEvent::Handler(
[this]()
{
this->LoadPassTemplateMappings();
});
passSystem->ConnectEvent(m_loadTemplatesHandler);
AZ::ApplicationTypeQuery appType;
AZ::ComponentApplicationBus::Broadcast(&AZ::ComponentApplicationBus::Events::QueryApplicationType, appType);
if (appType.IsGame())
{
InitPassTemplateMappingsHandler();
}

ROS2RequestBus::Handler::BusConnect();
AZ::TickBus::Handler::BusConnect();
Expand Down
2 changes: 2 additions & 0 deletions Gems/ROS2/Code/Source/ROS2SystemComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ namespace ROS2
const SimulationClock& GetSimulationClock() const override;
//////////////////////////////////////////////////////////////////////////

void InitPassTemplateMappingsHandler();

protected:
////////////////////////////////////////////////////////////////////////
// AZ::Component override
Expand Down