You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Gems/LmbrCentral/Code/Source/Rendering/EntityDebugDisplayComponent...

58 lines
2.0 KiB
C++

/*
* 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 "EntityDebugDisplayComponent.h"
#include <AzCore/Serialization/SerializeContext.h>
#include <Shape/ShapeDisplay.h>
namespace LmbrCentral
{
void EntityDebugDisplayComponent::Activate()
{
m_currentEntityTransform = AZ::Transform::CreateIdentity();
AZ::TransformBus::EventResult(m_currentEntityTransform, GetEntityId(), &AZ::TransformInterface::GetWorldTM);
AZ::TransformNotificationBus::Handler::BusConnect(GetEntityId());
AzFramework::EntityDebugDisplayEventBus::Handler::BusConnect(GetEntityId());
}
void EntityDebugDisplayComponent::Deactivate()
{
AZ::TransformNotificationBus::Handler::BusDisconnect();
AzFramework::EntityDebugDisplayEventBus::Handler::BusDisconnect();
}
void EntityDebugDisplayComponent::OnTransformChanged(const AZ::Transform& /*local*/, const AZ::Transform& world)
{
m_currentEntityTransform = world;
}
void EntityDebugDisplayComponent::DisplayEntityViewport(
[[maybe_unused]] const AzFramework::ViewportInfo& viewportInfo,
AzFramework::DebugDisplayRequests& debugDisplay)
{
DisplayShape(
debugDisplay,
[]() { return true; }, // canDraw function - in game mode/view we always want to draw, so just return true
[this](AzFramework::DebugDisplayRequests& debugDisplay)
{
Draw(debugDisplay);
},
m_currentEntityTransform);
}
void EntityDebugDisplayComponent::Reflect(AZ::ReflectContext* context)
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<EntityDebugDisplayComponent, AZ::Component>()
->Version(1);
}
}
}