Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,101 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "DebugDraw_precompiled.h"
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include "DebugDrawLineComponent.h"
namespace DebugDraw
{
void DebugDrawLineElement::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<DebugDrawLineElement>()
->Version(0)
->Field("StartEntityId", &DebugDrawLineElement::m_startEntityId)
->Field("EndEntityId", &DebugDrawLineElement::m_endEntityId)
->Field("StartWorldLocation", &DebugDrawLineElement::m_startWorldLocation)
->Field("EndWorldLocation", &DebugDrawLineElement::m_endWorldLocation)
->Field("Color", &DebugDrawLineElement::m_color)
;
AZ::EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<DebugDrawLineElement>("DebugDraw Line element settings", "Settings for DebugDraw line element.")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "Debugging")
->DataElement(0, &DebugDrawLineElement::m_endEntityId, "End Entity", "Which entity the line is drawn to (starts on this entity).")
->DataElement(0, &DebugDrawLineElement::m_color, "Color", "Display color for the line.")
;
}
}
}
void DebugDrawLineComponent::Reflect(AZ::ReflectContext* context)
{
DebugDrawLineElement::Reflect(context);
if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
{
serialize->Class<DebugDrawLineComponent, AZ::Component>()
->Version(0)
->Field("Element", &DebugDrawLineComponent::m_element)
;
}
}
DebugDrawLineComponent::DebugDrawLineComponent(const DebugDrawLineElement& element)
: m_element(element)
{
m_element.m_owningEditorComponent = AZ::InvalidComponentId;
}
void DebugDrawLineComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("DebugDrawLineService", 0xca14c559));
}
void DebugDrawLineComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
(void)incompatible;
}
void DebugDrawLineComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
(void)required;
}
void DebugDrawLineComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
(void)dependent;
}
void DebugDrawLineComponent::Init()
{
}
void DebugDrawLineComponent::Activate()
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::RegisterDebugDrawComponent, this);
}
void DebugDrawLineComponent::Deactivate()
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::UnregisterDebugDrawComponent, this);
}
} // namespace DebugDraw
@@ -0,0 +1,51 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Component/Component.h>
#include <AzCore/Script/ScriptTimePoint.h>
#include <DebugDraw/DebugDrawBus.h>
namespace DebugDraw
{
class DebugDrawLineComponent
: public AZ::Component
{
friend class DebugDrawSystemComponent;
public:
AZ_COMPONENT(DebugDrawLineComponent, "{E7CBA314-CD9C-4625-AF65-B28369FE272A}");
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
DebugDrawLineComponent() = default;
explicit DebugDrawLineComponent(const DebugDrawLineElement& element);
~DebugDrawLineComponent() override = default;
////////////////////////////////////////////////////////////////////////
// AZ::Component interface implementation
void Init() override;
void Activate() override;
void Deactivate() override;
////////////////////////////////////////////////////////////////////////
protected:
DebugDrawLineElement m_element;
};
}
@@ -0,0 +1,79 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "DebugDraw_precompiled.h"
#include "DebugDrawSystemComponent.h"
#include "DebugDrawLineComponent.h"
#include "DebugDrawRayComponent.h"
#include "DebugDrawSphereComponent.h"
#include "DebugDrawObbComponent.h"
#include "DebugDrawTextComponent.h"
#ifdef DEBUGDRAW_GEM_EDITOR
#include "EditorDebugDrawLineComponent.h"
#include "EditorDebugDrawRayComponent.h"
#include "EditorDebugDrawSphereComponent.h"
#include "EditorDebugDrawObbComponent.h"
#include "EditorDebugDrawTextComponent.h"
#endif // DEBUGDRAW_GEM_EDITOR
#include <IGem.h>
namespace DebugDraw
{
class DebugDrawModule
: public CryHooksModule
{
public:
AZ_RTTI(DebugDrawModule, "{07AC9E51-535C-402D-A2EB-529366ED9985}", CryHooksModule);
DebugDrawModule()
: CryHooksModule()
{
// Push results of [MyComponent]::CreateDescriptor() into m_descriptors here.
m_descriptors.insert(m_descriptors.end(), {
//DebugDrawSystemComponent::CreateDescriptor(),
DebugDrawLineComponent::CreateDescriptor(),
DebugDrawRayComponent::CreateDescriptor(),
DebugDrawSphereComponent::CreateDescriptor(),
DebugDrawObbComponent::CreateDescriptor(),
DebugDrawTextComponent::CreateDescriptor(),
DebugDrawSystemComponent::CreateDescriptor(),
#ifdef DEBUGDRAW_GEM_EDITOR
EditorDebugDrawLineComponent::CreateDescriptor(),
EditorDebugDrawRayComponent::CreateDescriptor(),
EditorDebugDrawSphereComponent::CreateDescriptor(),
EditorDebugDrawObbComponent::CreateDescriptor(),
EditorDebugDrawTextComponent::CreateDescriptor(),
#endif // DEBUGDRAW_GEM_EDITOR
});
}
/**
* Add required SystemComponents to the SystemEntity.
*/
AZ::ComponentTypeList GetRequiredSystemComponents() const override
{
return AZ::ComponentTypeList{
azrtti_typeid<DebugDrawSystemComponent>(),
};
}
};
}
// DO NOT MODIFY THIS LINE UNLESS YOU RENAME THE GEM
// The first parameter should be GemName_GemIdLower
// The second should be the fully qualified name of the class above
AZ_DECLARE_MODULE_CLASS(Gem_DebugDraw, DebugDraw::DebugDrawModule)
@@ -0,0 +1,101 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "DebugDraw_precompiled.h"
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include "DebugDrawObbComponent.h"
namespace DebugDraw
{
void DebugDrawObbElement::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<DebugDrawObbElement>()
->Version(0)
->Field("TargetEntityId", &DebugDrawObbElement::m_targetEntityId)
->Field("Color", &DebugDrawObbElement::m_color)
->Field("WorldLocation", &DebugDrawObbElement::m_worldLocation)
->Field("Scale", &DebugDrawObbElement::m_scale)
;
AZ::EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<DebugDrawObbElement>("DebugDraw Sphere Element Settings", "Settings for DebugDraw sphere element.")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "Debugging")
->DataElement(0, &DebugDrawObbElement::m_color, "Color", "Display color for the line.")
->DataElement(0, &DebugDrawObbElement::m_scale, "Scale", "The scale of the box.")
;
}
}
}
void DebugDrawObbComponent::Reflect(AZ::ReflectContext* context)
{
DebugDrawObbElement::Reflect(context);
if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
{
serialize->Class<DebugDrawObbComponent, AZ::Component>()
->Version(0)
->Field("Element", &DebugDrawObbComponent::m_element)
;
}
}
DebugDrawObbComponent::DebugDrawObbComponent(const DebugDrawObbElement& element)
: m_element(element)
{
m_element.m_owningEditorComponent = AZ::InvalidComponentId;
}
void DebugDrawObbComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("DebugDrawObbService", 0x1775ae66));
}
void DebugDrawObbComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
(void)incompatible;
}
void DebugDrawObbComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
(void)required;
}
void DebugDrawObbComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
(void)dependent;
}
void DebugDrawObbComponent::Init()
{
}
void DebugDrawObbComponent::Activate()
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::RegisterDebugDrawComponent, this);
}
void DebugDrawObbComponent::Deactivate()
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::UnregisterDebugDrawComponent, this);
}
} // namespace DebugDraw
@@ -0,0 +1,77 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Component/Component.h>
#include <AzCore/Script/ScriptTimePoint.h>
#include <DebugDraw/DebugDrawBus.h>
namespace DebugDraw
{
class DebugDrawObbElement
{
public:
AZ_CLASS_ALLOCATOR(DebugDrawObbElement, AZ::SystemAllocator, 0);
AZ_TYPE_INFO(DebugDrawObbElement, "{C0B12E93-287A-4170-B1B6-3BF70D1D9433}");
static void Reflect(AZ::ReflectContext* context);
AZ::EntityId m_targetEntityId;
AZ::Obb m_obb;
float m_duration;
AZ::ScriptTimePoint m_activateTime;
AZ::Color m_color;
AZ::Vector3 m_worldLocation;
AZ::ComponentId m_owningEditorComponent;
AZ::Vector3 m_scale;
DebugDrawObbElement()
: m_duration(0.1f)
, m_color(1.0f, 1.0f, 1.0f, 1.0f) // AZ::Color::White
, m_worldLocation(AZ::Vector3::CreateZero())
, m_owningEditorComponent(AZ::InvalidComponentId)
, m_scale(AZ::Vector3(1.0f, 1.0f, 1.0f))
{
m_obb.CreateFromPositionRotationAndHalfLengths(m_worldLocation, AZ::Quaternion::CreateIdentity(), AZ::Vector3::CreateOne());
}
};
class DebugDrawObbComponent
: public AZ::Component
{
friend class DebugDrawSystemComponent;
public:
AZ_COMPONENT(DebugDrawObbComponent, "{B1574E9A-C9A1-4A9C-9866-23735ED6FD69}");
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
DebugDrawObbComponent() = default;
explicit DebugDrawObbComponent(const DebugDrawObbElement& element);
~DebugDrawObbComponent() override = default;
////////////////////////////////////////////////////////////////////////
// AZ::Component interface implementation
void Init() override;
void Activate() override;
void Deactivate() override;
////////////////////////////////////////////////////////////////////////
protected:
DebugDrawObbElement m_element;
};
}
@@ -0,0 +1,101 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "DebugDraw_precompiled.h"
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include "DebugDrawRayComponent.h"
namespace DebugDraw
{
void DebugDrawRayElement::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<DebugDrawRayElement>()
->Version(0)
->Field("StartEntityId", &DebugDrawRayElement::m_startEntityId)
->Field("EndEntityId", &DebugDrawRayElement::m_endEntityId)
->Field("WorldLocation", &DebugDrawRayElement::m_worldLocation)
->Field("WorldDirection", &DebugDrawRayElement::m_worldDirection)
->Field("Color", &DebugDrawRayElement::m_color)
;
AZ::EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<DebugDrawRayElement>("DebugDraw Ray element settings", "Settings for DebugDraw ray element.")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "Debugging")
->DataElement(0, &DebugDrawRayElement::m_endEntityId, "End Entity", "Which entity the ray is drawn to (starts on this entity).")
->DataElement(0, &DebugDrawRayElement::m_color, "Color", "Display color for the line.")
;
}
}
}
void DebugDrawRayComponent::Reflect(AZ::ReflectContext* context)
{
DebugDrawRayElement::Reflect(context);
if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
{
serialize->Class<DebugDrawRayComponent, AZ::Component>()
->Version(0)
->Field("Element", &DebugDrawRayComponent::m_element)
;
}
}
DebugDrawRayComponent::DebugDrawRayComponent(const DebugDrawRayElement& element)
: m_element(element)
{
m_element.m_owningEditorComponent = AZ::InvalidComponentId;
}
void DebugDrawRayComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("DebugDrawRayService", 0xdd79b586));
}
void DebugDrawRayComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
(void)incompatible;
}
void DebugDrawRayComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
(void)required;
}
void DebugDrawRayComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
(void)dependent;
}
void DebugDrawRayComponent::Init()
{
}
void DebugDrawRayComponent::Activate()
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::RegisterDebugDrawComponent, this);
}
void DebugDrawRayComponent::Deactivate()
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::UnregisterDebugDrawComponent, this);
}
} // namespace DebugDraw
@@ -0,0 +1,76 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Component/Component.h>
#include <AzCore/Script/ScriptTimePoint.h>
#include <DebugDraw/DebugDrawBus.h>
namespace DebugDraw
{
class DebugDrawRayElement
{
public:
AZ_CLASS_ALLOCATOR(DebugDrawRayElement, AZ::SystemAllocator, 0);
AZ_TYPE_INFO(DebugDrawRayElement, "{BFA68022-208C-4A25-8A33-CF411164F994}");
static void Reflect(AZ::ReflectContext* context);
AZ::EntityId m_startEntityId;
AZ::EntityId m_endEntityId;
float m_duration;
AZ::ScriptTimePoint m_activateTime;
AZ::Color m_color;
AZ::Vector3 m_worldLocation;
AZ::Vector3 m_worldDirection;
AZ::ComponentId m_owningEditorComponent;
DebugDrawRayElement()
: m_duration(0.f)
, m_color(1.0f, 1.0f, 1.0f, 1.0f) // AZ::Color::White
, m_worldLocation(AZ::Vector3::CreateZero())
, m_worldDirection(AZ::Vector3::CreateZero())
, m_owningEditorComponent(AZ::InvalidComponentId)
{
}
};
class DebugDrawRayComponent
: public AZ::Component
{
friend class DebugDrawSystemComponent;
public:
AZ_COMPONENT(DebugDrawRayComponent, "{7D1C2FE7-541D-4C0A-B10C-D0EA4DE40BA8}");
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
DebugDrawRayComponent() = default;
explicit DebugDrawRayComponent(const DebugDrawRayElement& element);
~DebugDrawRayComponent() override = default;
////////////////////////////////////////////////////////////////////////
// AZ::Component interface implementation
void Init() override;
void Activate() override;
void Deactivate() override;
////////////////////////////////////////////////////////////////////////
protected:
DebugDrawRayElement m_element;
};
}
@@ -0,0 +1,101 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "DebugDraw_precompiled.h"
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include "DebugDrawSphereComponent.h"
namespace DebugDraw
{
void DebugDrawSphereElement::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<DebugDrawSphereElement>()
->Version(0)
->Field("TargetEntityId", &DebugDrawSphereElement::m_targetEntityId)
->Field("Color", &DebugDrawSphereElement::m_color)
->Field("WorldLocation", &DebugDrawSphereElement::m_worldLocation)
->Field("Radius", &DebugDrawSphereElement::m_radius)
;
AZ::EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<DebugDrawSphereElement>("DebugDraw Sphere Element Settings", "Settings for DebugDraw sphere element.")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "Debugging")
->DataElement(0, &DebugDrawSphereElement::m_color, "Color", "Display color for the line.")
->DataElement(0, &DebugDrawSphereElement::m_radius, "Radius", "The size of the sphere.")
;
}
}
}
void DebugDrawSphereComponent::Reflect(AZ::ReflectContext* context)
{
DebugDrawSphereElement::Reflect(context);
if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
{
serialize->Class<DebugDrawSphereComponent, AZ::Component>()
->Version(0)
->Field("Element", &DebugDrawSphereComponent::m_element)
;
}
}
DebugDrawSphereComponent::DebugDrawSphereComponent(const DebugDrawSphereElement& element)
: m_element(element)
{
m_element.m_owningEditorComponent = AZ::InvalidComponentId;
}
void DebugDrawSphereComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("DebugDrawSphereService", 0x15765c23));
}
void DebugDrawSphereComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
(void)incompatible;
}
void DebugDrawSphereComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
(void)required;
}
void DebugDrawSphereComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
(void)dependent;
}
void DebugDrawSphereComponent::Init()
{
}
void DebugDrawSphereComponent::Activate()
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::RegisterDebugDrawComponent, this);
}
void DebugDrawSphereComponent::Deactivate()
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::UnregisterDebugDrawComponent, this);
}
} // namespace DebugDraw
@@ -0,0 +1,77 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Component/Component.h>
#include <AzCore/Script/ScriptTimePoint.h>
#include <DebugDraw/DebugDrawBus.h>
namespace DebugDraw
{
class DebugDrawSphereElement
{
public:
AZ_CLASS_ALLOCATOR(DebugDrawSphereElement, AZ::SystemAllocator, 0);
AZ_TYPE_INFO(DebugDrawSphereElement, "{CB6F2781-DC26-4A10-8C5F-E07032574087}");
static void Reflect(AZ::ReflectContext* context);
float m_duration;
AZ::ScriptTimePoint m_activateTime;
AZ::Color m_color;
AZ::EntityId m_targetEntityId;
AZ::Vector3 m_worldLocation;
float m_radius;
AZ::ComponentId m_owningEditorComponent;
DebugDrawSphereElement()
: m_duration(0.f)
, m_radius(1.0f)
, m_color(1.0f, 1.0f, 1.0f, 1.0f) // AZ::Color::White
, m_worldLocation(AZ::Vector3::CreateZero())
{
}
};
class DebugDrawSphereComponent
: public AZ::Component
{
friend class DebugDrawSystemComponent;
public:
AZ_COMPONENT(DebugDrawSphereComponent, "{823F6C96-627E-4C98-A3B9-0168B5CB3706}");
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
DebugDrawSphereComponent() = default;
explicit DebugDrawSphereComponent(const DebugDrawSphereElement& element);
~DebugDrawSphereComponent() override = default;
////////////////////////////////////////////////////////////////////////
// AZ::Component interface implementation
void Init() override;
void Activate() override;
void Deactivate() override;
////////////////////////////////////////////////////////////////////////
protected:
DebugDrawSphereElement m_element;
};
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,160 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Component/Component.h>
#include <AzCore/Component/TickBus.h>
#include <AzCore/Component/EntityBus.h>
#include <AzCore/std/parallel/mutex.h>
#include <DebugDraw/DebugDrawBus.h>
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
// DebugDraw components
#include "DebugDrawLineComponent.h"
#include "DebugDrawRayComponent.h"
#include "DebugDrawSphereComponent.h"
#include "DebugDrawObbComponent.h"
#include "DebugDrawTextComponent.h"
#ifdef DEBUGDRAW_GEM_EDITOR
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
#endif // DEBUGDRAW_GEM_EDITOR
namespace DebugDraw
{
// DebugDraw elements that don't have corresponding component representations yet
class DebugDrawAabbElement
{
public:
AZ_CLASS_ALLOCATOR(DebugDrawAabbElement, AZ::SystemAllocator, 0);
AZ_TYPE_INFO(DebugDrawAabbElement, "{3B3E45AC-95B5-477F-BC34-58765A031BF1}");
AZ::EntityId m_targetEntityId;
AZ::Aabb m_aabb;
float m_duration;
AZ::ScriptTimePoint m_activateTime;
AZ::Color m_color;
AZ::Vector3 m_worldLocation;
AZ::ComponentId m_owningEditorComponent;
DebugDrawAabbElement()
: m_duration(0.f)
, m_color(1.0f, 1.0f, 1.0f, 1.0f)
, m_worldLocation(AZ::Vector3::CreateZero())
, m_owningEditorComponent(AZ::InvalidComponentId)
{
}
};
class DebugDrawSystemComponent
: public AZ::Component
, public AZ::TickBus::Handler
, public AZ::EntityBus::MultiHandler
, protected DebugDrawRequestBus::Handler
, protected DebugDrawInternalRequestBus::Handler
#ifdef DEBUGDRAW_GEM_EDITOR
, protected AzToolsFramework::EditorEntityContextNotificationBus::Handler
#endif // DEBUGDRAW_GEM_EDITOR
{
public:
AZ_COMPONENT(DebugDrawSystemComponent, "{48D54C3C-F284-43A5-B070-106F2CEB7154}");
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
#ifdef DEBUGDRAW_GEM_EDITOR
// EditorEntityContextNotificationBus interface implementation
void OnStopPlayInEditor() override;
#endif // DEBUGDRAW_GEM_EDITOR
protected:
// DebugDrawRequestBus interface implementation
void DrawAabb(const AZ::Aabb& aabb, const AZ::Color& color, float duration) override;
void DrawAabbOnEntity(const AZ::EntityId& targetEntity, const AZ::Aabb& aabb, const AZ::Color& color, float duration) override;
void DrawLineBatchLocationToLocation(const AZStd::vector<DebugDraw::DebugDrawLineElement>& lineBatch) override;
void DrawLineLocationToLocation(const AZ::Vector3& startLocation, const AZ::Vector3& endLocation, const AZ::Color& color, float duration) override;
void DrawLineEntityToLocation(const AZ::EntityId& startEntity, const AZ::Vector3& endLocation, const AZ::Color& color, float duration) override;
void DrawLineEntityToEntity(const AZ::EntityId& startEntity, const AZ::EntityId& endEntity, const AZ::Color& color, float duration) override;
void DrawObb(const AZ::Obb& obb, const AZ::Color& color, float duration) override;
void DrawObbOnEntity(const AZ::EntityId& targetEntity, const AZ::Obb& obb, const AZ::Color& color, float duration) override;
void DrawRayLocationToDirection(const AZ::Vector3& worldLocation, const AZ::Vector3& worldDirection, const AZ::Color& color, float duration) override;
void DrawRayEntityToDirection(const AZ::EntityId& startEntity, const AZ::Vector3& worldDirection, const AZ::Color& color, float duration) override;
void DrawRayEntityToEntity(const AZ::EntityId& startEntity, const AZ::EntityId& endEntity, const AZ::Color& color, float duration) override;
void DrawSphereAtLocation(const AZ::Vector3& worldLocation, float radius, const AZ::Color& color, float duration) override;
void DrawSphereOnEntity(const AZ::EntityId& targetEntity, float radius, const AZ::Color& color, float duration) override;
void DrawTextAtLocation(const AZ::Vector3& worldLocation, const AZStd::string& text, const AZ::Color& color, float duration) override;
void DrawTextOnEntity(const AZ::EntityId& targetEntity, const AZStd::string& text, const AZ::Color& color, float duration) override;
void DrawTextOnScreen(const AZStd::string& text, const AZ::Color& color, float duration) override;
// DebugDrawInternalRequestBus interface implementation
void RegisterDebugDrawComponent(AZ::Component* component) override;
void UnregisterDebugDrawComponent(AZ::Component* component) override;
// AZ::Component interface implementation
void Init() override;
void Activate() override;
void Deactivate() override;
// TickBus
void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
int GetTickOrder() override { return AZ::ComponentTickBus::TICK_DEFAULT; }
// EntityBus
void OnEntityDeactivated(const AZ::EntityId& entityId) override;
// Ticking functions for drawing debug elements
void OnTickAabbs();
void OnTickLines();
void OnTickObbs();
void OnTickRays();
void OnTickSpheres();
void OnTickText();
// Element creation functions, used when DebugDraw components register themselves
void CreateAabbEntryForComponent(const AZ::EntityId& componentEntityId, const DebugDrawAabbElement& element);
void CreateLineEntryForComponent(const AZ::EntityId& componentEntityId, const DebugDrawLineElement& element);
void CreateObbEntryForComponent(const AZ::EntityId& componentEntityId, const DebugDrawObbElement& element);
void CreateRayEntryForComponent(const AZ::EntityId& componentEntityId, const DebugDrawRayElement& element);
void CreateSphereEntryForComponent(const AZ::EntityId& componentEntityId, const DebugDrawSphereElement& element);
void CreateTextEntryForComponent(const AZ::EntityId& componentEntityId, const DebugDrawTextElement& element);
template <typename F>
void removeExpiredDebugElementsFromVector(AZStd::vector<F>& vectorToExpire);
AZStd::vector<DebugDrawAabbElement> m_activeAabbs;
AZStd::mutex m_activeAabbsMutex;
AZStd::vector<DebugDrawLineElement> m_activeLines;
AZStd::mutex m_activeLinesMutex;
AZStd::vector<DebugDrawObbElement> m_activeObbs;
AZStd::mutex m_activeObbsMutex;
AZStd::vector<DebugDrawRayElement> m_activeRays;
AZStd::mutex m_activeRaysMutex;
AZStd::vector<DebugDrawSphereElement> m_activeSpheres;
AZStd::mutex m_activeSpheresMutex;
AZStd::vector<DebugDrawTextElement> m_activeTexts;
AZStd::mutex m_activeTextsMutex;
double m_currentTime;
AZStd::vector<Vec3> m_batchPoints;
AZStd::vector<ColorB> m_batchColors;
};
}
@@ -0,0 +1,111 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "DebugDraw_precompiled.h"
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include "DebugDrawTextComponent.h"
namespace DebugDraw
{
void DebugDrawTextElement::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<DebugDrawTextElement>()
->Version(0)
->Field("Text", &DebugDrawTextElement::m_text)
->Field("Color", &DebugDrawTextElement::m_color)
->Field("DrawMode", &DebugDrawTextElement::m_drawMode)
->Field("WorldLocation", &DebugDrawTextElement::m_worldLocation)
->Field("TargetEntity", &DebugDrawTextElement::m_targetEntityId)
;
AZ::EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<DebugDrawTextElement>("DebugDraw Text element settings", "Settings for DebugDraw text element.")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "Debugging")
->DataElement(0, &DebugDrawTextElement::m_text, "Text", "The Debug Text.")
->DataElement(0, &DebugDrawTextElement::m_color, "Color", "Text Color.")
->DataElement(0, &DebugDrawTextElement::m_drawMode, "Draw Mode", "Draw Mode Preference.")
->DataElement(AZ::Edit::UIHandlers::ComboBox, &DebugDrawTextElement::m_drawMode, "Draw Mode", "Draw Mode Preference.")
->EnumAttribute(DrawMode::OnScreen, "Screen Space")
->EnumAttribute(DrawMode::InWorld, "World Space")
// Currently supports World Space placement on component owners location Or exact placement via behavior context / scripting (TBC)
//->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::EntireTree)
//->DataElement(AZ::Edit::UIHandlers::Default, &DebugDrawTextElement::m_targetEntityId, "TargetEntity", "The target entity to position debug text at.")
//->Attribute(AZ::Edit::Attributes::Visibility, &DebugDrawTextElement::isWorldSpace)
;
}
}
}
void DebugDrawTextComponent::Reflect(AZ::ReflectContext* context)
{
DebugDrawTextElement::Reflect(context);
if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
{
serialize->Class<DebugDrawTextComponent, AZ::Component>()
->Version(0)
->Field("TextElement", &DebugDrawTextComponent::m_element)
;
}
}
DebugDrawTextComponent::DebugDrawTextComponent(const DebugDrawTextElement& textElement)
: m_element(textElement)
{
m_element.m_owningEditorComponent = AZ::InvalidComponentId;
}
void DebugDrawTextComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("DebugDrawTextService", 0xabd60a17));
}
void DebugDrawTextComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
(void)incompatible;
}
void DebugDrawTextComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
(void)required;
}
void DebugDrawTextComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
(void)dependent;
}
void DebugDrawTextComponent::Init()
{
}
void DebugDrawTextComponent::Activate()
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::RegisterDebugDrawComponent, this);
}
void DebugDrawTextComponent::Deactivate()
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::UnregisterDebugDrawComponent, this);
}
} // namespace DebugDraw
@@ -0,0 +1,76 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Component/Component.h>
#include <AzCore/Script/ScriptTimePoint.h>
#include <DebugDraw/DebugDrawBus.h>
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
namespace DebugDraw
{
class DebugDrawTextElement
{
public:
AZ_CLASS_ALLOCATOR(DebugDrawTextElement, AZ::SystemAllocator, 0);
AZ_TYPE_INFO(DebugDrawTextElement, "{A49413DB-0AFC-4D38-BD4B-EDC8FA83B640}");
static void Reflect(AZ::ReflectContext* context);
enum class DrawMode
{
OnScreen,
InWorld,
};
DrawMode m_drawMode = DrawMode::OnScreen;
float m_duration = 0.0f;
AZStd::string m_text = "";
AZ::ScriptTimePoint m_activateTime;
AZ::Color m_color = AZ::Color(1.0f, 1.0f, 1.0f, 1.0f);
AZ::EntityId m_targetEntityId;
AZ::Vector3 m_worldLocation = AZ::Vector3::CreateZero();
AZ::ComponentId m_owningEditorComponent = AZ::InvalidComponentId;
};
class DebugDrawTextComponent
: public AZ::Component
{
friend class DebugDrawSystemComponent;
public:
AZ_COMPONENT(DebugDrawTextComponent, "{A705A8DF-31F1-49FF-8727-CC7783E09EF9}");
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
DebugDrawTextComponent() = default;
explicit DebugDrawTextComponent(const DebugDrawTextElement& textElement);
~DebugDrawTextComponent() override = default;
// AZ::Component interface implementation
void Init() override;
void Activate() override;
void Deactivate() override;
protected:
DebugDrawTextElement m_element;
};
}
@@ -0,0 +1,13 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "DebugDraw_precompiled.h"
@@ -0,0 +1,16 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <platform.h> // Many CryCommon files require that this is included first.
#include <Cry_Color.h>
@@ -0,0 +1,54 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "DebugDraw_precompiled.h"
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include "EditorDebugDrawComponentCommon.h"
namespace DebugDraw
{
EditorDebugDrawComponentSettings::EditorDebugDrawComponentSettings()
: m_visibleInGame(true)
, m_visibleInEditor(true)
{
}
void EditorDebugDrawComponentSettings::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<EditorDebugDrawComponentSettings>()
->Version(0)
->Field("VisibleInGame", &EditorDebugDrawComponentSettings::m_visibleInGame)
->Field("VisibleInEditor", &EditorDebugDrawComponentSettings::m_visibleInEditor)
;
AZ::EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<EditorDebugDrawComponentSettings>("DebugDraw Component Settings", "Common settings for DebugDraw components.")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "Debugging")
->DataElement(0, &EditorDebugDrawComponentSettings::m_visibleInGame,
"Visible In Game", "Whether this DebugDraw component is visible in game.")
->DataElement(0, &EditorDebugDrawComponentSettings::m_visibleInEditor,
"Visible In Editor", "Whether this DebugDraw component is visible in editor.")
;
}
}
}
} // namespace DebugDraw
@@ -0,0 +1,29 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
namespace DebugDraw
{
class EditorDebugDrawComponentSettings
{
public:
AZ_CLASS_ALLOCATOR(EditorDebugDrawComponentSettings, AZ::SystemAllocator, 0);
AZ_TYPE_INFO(EditorDebugDrawComponentSettings, "{39FF3385-9AD8-4C3F-AAFF-3CBE1D76B767}");
static void Reflect(AZ::ReflectContext* context);
EditorDebugDrawComponentSettings();
bool m_visibleInGame;
bool m_visibleInEditor;
};
}
@@ -0,0 +1,109 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "DebugDraw_precompiled.h"
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include "EditorDebugDrawLineComponent.h"
namespace DebugDraw
{
void EditorDebugDrawLineComponent::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<EditorDebugDrawLineComponent, EditorComponentBase>()
->Version(0)
->Field("Element", &EditorDebugDrawLineComponent::m_element)
->Field("Settings", &EditorDebugDrawLineComponent::m_settings)
;
AZ::EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<EditorDebugDrawLineComponent>(
"DebugDraw Line", "Draws debug line on the screen from this entity's location to specified end entity's location.")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "Debugging")
->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/DebugDrawLine.svg")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c))
->DataElement(0, &EditorDebugDrawLineComponent::m_element, "Line element settings", "Settings for the line element.")
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDebugDrawLineComponent::OnPropertyUpdate)
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(0, &EditorDebugDrawLineComponent::m_settings, "Visibility settings", "Common settings for DebugDraw components.")
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDebugDrawLineComponent::OnPropertyUpdate)
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
;
}
}
}
void EditorDebugDrawLineComponent::BuildGameEntity(AZ::Entity* gameEntity)
{
if (m_settings.m_visibleInGame)
{
gameEntity->CreateComponent<DebugDrawLineComponent>(m_element);
}
}
void EditorDebugDrawLineComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
DebugDrawLineComponent::GetProvidedServices(provided);
}
void EditorDebugDrawLineComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
DebugDrawLineComponent::GetIncompatibleServices(incompatible);
}
void EditorDebugDrawLineComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
DebugDrawLineComponent::GetRequiredServices(required);
}
void EditorDebugDrawLineComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
DebugDrawLineComponent::GetDependentServices(dependent);
}
void EditorDebugDrawLineComponent::Init()
{
m_element.m_owningEditorComponent = GetId();
}
void EditorDebugDrawLineComponent::Activate()
{
if (m_settings.m_visibleInEditor)
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::RegisterDebugDrawComponent, this);
}
}
void EditorDebugDrawLineComponent::Deactivate()
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::UnregisterDebugDrawComponent, this);
}
void EditorDebugDrawLineComponent::OnPropertyUpdate()
{
// Property updated, we need to update the system component (which handles drawing the components) with our new info
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::UnregisterDebugDrawComponent, this);
if (m_settings.m_visibleInEditor)
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::RegisterDebugDrawComponent, this);
}
}
} // namespace DebugDraw
@@ -0,0 +1,54 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
#include "DebugDrawLineComponent.h"
#include "EditorDebugDrawComponentCommon.h"
namespace DebugDraw
{
class EditorDebugDrawLineComponent
: public AzToolsFramework::Components::EditorComponentBase
{
friend class DebugDrawSystemComponent;
public:
AZ_EDITOR_COMPONENT(EditorDebugDrawLineComponent, "{EC80F970-9FB1-4424-87A0-C6073F042A93}", AzToolsFramework::Components::EditorComponentBase);
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
////////////////////////////////////////////////////////////////////////
// EditorComponentBase
void BuildGameEntity(AZ::Entity* gameEntity) override;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// AZ::Component interface implementation
void Init() override;
void Activate() override;
void Deactivate() override;
////////////////////////////////////////////////////////////////////////
protected:
void OnPropertyUpdate();
DebugDrawLineElement m_element;
EditorDebugDrawComponentSettings m_settings;
};
}
@@ -0,0 +1,109 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "DebugDraw_precompiled.h"
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include "EditorDebugDrawObbComponent.h"
namespace DebugDraw
{
void EditorDebugDrawObbComponent::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<EditorDebugDrawObbComponent, EditorComponentBase>()
->Version(0)
->Field("Element", &EditorDebugDrawObbComponent::m_element)
->Field("Settings", &EditorDebugDrawObbComponent::m_settings)
;
AZ::EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<EditorDebugDrawObbComponent>(
"DebugDraw Obb", "Draws debug obb on the screen from this entity's location to specified end entity's location.")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "Debugging")
->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/DebugDrawObb.svg")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c))
->DataElement(0, &EditorDebugDrawObbComponent::m_element, "Obb element settings", "Settings for the obb element.")
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDebugDrawObbComponent::OnPropertyUpdate)
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(0, &EditorDebugDrawObbComponent::m_settings, "Visibility settings", "Common settings for DebugDraw components.")
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDebugDrawObbComponent::OnPropertyUpdate)
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
;
}
}
}
void EditorDebugDrawObbComponent::BuildGameEntity(AZ::Entity* gameEntity)
{
if (m_settings.m_visibleInGame)
{
gameEntity->CreateComponent<DebugDrawObbComponent>(m_element);
}
}
void EditorDebugDrawObbComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
DebugDrawObbComponent::GetProvidedServices(provided);
}
void EditorDebugDrawObbComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
DebugDrawObbComponent::GetIncompatibleServices(incompatible);
}
void EditorDebugDrawObbComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
DebugDrawObbComponent::GetRequiredServices(required);
}
void EditorDebugDrawObbComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
DebugDrawObbComponent::GetDependentServices(dependent);
}
void EditorDebugDrawObbComponent::Init()
{
m_element.m_owningEditorComponent = GetId();
}
void EditorDebugDrawObbComponent::Activate()
{
if (m_settings.m_visibleInEditor)
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::RegisterDebugDrawComponent, this);
}
}
void EditorDebugDrawObbComponent::Deactivate()
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::UnregisterDebugDrawComponent, this);
}
void EditorDebugDrawObbComponent::OnPropertyUpdate()
{
// Property updated, we need to update the system component (which handles drawing the components) with our new info
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::UnregisterDebugDrawComponent, this);
if (m_settings.m_visibleInEditor)
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::RegisterDebugDrawComponent, this);
}
}
} // namespace DebugDraw
@@ -0,0 +1,54 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
#include "DebugDrawObbComponent.h"
#include "EditorDebugDrawComponentCommon.h"
namespace DebugDraw
{
class EditorDebugDrawObbComponent
: public AzToolsFramework::Components::EditorComponentBase
{
friend class DebugDrawSystemComponent;
public:
AZ_EDITOR_COMPONENT(EditorDebugDrawObbComponent, "{602AF187-693F-4E04-96A7-0B2D2028A937}", AzToolsFramework::Components::EditorComponentBase);
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
////////////////////////////////////////////////////////////////////////
// EditorComponentBase
void BuildGameEntity(AZ::Entity* gameEntity) override;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// AZ::Component interface implementation
void Init() override;
void Activate() override;
void Deactivate() override;
////////////////////////////////////////////////////////////////////////
protected:
void OnPropertyUpdate();
DebugDrawObbElement m_element;
EditorDebugDrawComponentSettings m_settings;
};
}
@@ -0,0 +1,109 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "DebugDraw_precompiled.h"
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include "EditorDebugDrawRayComponent.h"
namespace DebugDraw
{
void EditorDebugDrawRayComponent::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<EditorDebugDrawRayComponent, EditorComponentBase>()
->Version(0)
->Field("Element", &EditorDebugDrawRayComponent::m_element)
->Field("Settings", &EditorDebugDrawRayComponent::m_settings)
;
AZ::EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<EditorDebugDrawRayComponent>(
"DebugDraw Ray", "Draws debug ray on the screen from this entity's location to specified end entity's location.")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "Debugging")
->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/DebugDrawRay.svg")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c))
->DataElement(0, &EditorDebugDrawRayComponent::m_element, "Ray element settings", "Settings for the ray element.")
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDebugDrawRayComponent::OnPropertyUpdate)
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(0, &EditorDebugDrawRayComponent::m_settings, "Visibility settings", "Common settings for DebugDraw components.")
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDebugDrawRayComponent::OnPropertyUpdate)
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
;
}
}
}
void EditorDebugDrawRayComponent::BuildGameEntity(AZ::Entity* gameEntity)
{
if (m_settings.m_visibleInGame)
{
gameEntity->CreateComponent<DebugDrawRayComponent>(m_element);
}
}
void EditorDebugDrawRayComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
DebugDrawRayComponent::GetProvidedServices(provided);
}
void EditorDebugDrawRayComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
DebugDrawRayComponent::GetIncompatibleServices(incompatible);
}
void EditorDebugDrawRayComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
DebugDrawRayComponent::GetRequiredServices(required);
}
void EditorDebugDrawRayComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
DebugDrawRayComponent::GetDependentServices(dependent);
}
void EditorDebugDrawRayComponent::Init()
{
m_element.m_owningEditorComponent = GetId();
}
void EditorDebugDrawRayComponent::Activate()
{
if (m_settings.m_visibleInEditor)
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::RegisterDebugDrawComponent, this);
}
}
void EditorDebugDrawRayComponent::Deactivate()
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::UnregisterDebugDrawComponent, this);
}
void EditorDebugDrawRayComponent::OnPropertyUpdate()
{
// Property updated, we need to update the system component (which handles drawing the components) with our new info
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::UnregisterDebugDrawComponent, this);
if (m_settings.m_visibleInEditor)
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::RegisterDebugDrawComponent, this);
}
}
} // namespace DebugDraw
@@ -0,0 +1,54 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
#include "DebugDrawRayComponent.h"
#include "EditorDebugDrawComponentCommon.h"
namespace DebugDraw
{
class EditorDebugDrawRayComponent
: public AzToolsFramework::Components::EditorComponentBase
{
friend class DebugDrawSystemComponent;
public:
AZ_EDITOR_COMPONENT(EditorDebugDrawRayComponent, "{31EA0ECB-F1EE-4D58-807A-9CF98C7A52A7}", AzToolsFramework::Components::EditorComponentBase);
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
////////////////////////////////////////////////////////////////////////
// EditorComponentBase
void BuildGameEntity(AZ::Entity* gameEntity) override;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// AZ::Component interface implementation
void Init() override;
void Activate() override;
void Deactivate() override;
////////////////////////////////////////////////////////////////////////
protected:
void OnPropertyUpdate();
DebugDrawRayElement m_element;
EditorDebugDrawComponentSettings m_settings;
};
}
@@ -0,0 +1,109 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "DebugDraw_precompiled.h"
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include "EditorDebugDrawSphereComponent.h"
namespace DebugDraw
{
void EditorDebugDrawSphereComponent::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<EditorDebugDrawSphereComponent, EditorComponentBase>()
->Version(0)
->Field("Element", &EditorDebugDrawSphereComponent::m_element)
->Field("Settings", &EditorDebugDrawSphereComponent::m_settings)
;
AZ::EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<EditorDebugDrawSphereComponent>(
"DebugDraw Sphere", "Draws debug ray on the screen from this entity's location to specified end entity's location.")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "Debugging")
->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/DebugDrawSphere.svg")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c))
->DataElement(0, &EditorDebugDrawSphereComponent::m_element, "Sphere element settings", "Settings for the sphere element.")
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDebugDrawSphereComponent::OnPropertyUpdate)
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(0, &EditorDebugDrawSphereComponent::m_settings, "Visibility settings", "Common settings for DebugDraw components.")
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDebugDrawSphereComponent::OnPropertyUpdate)
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
;
}
}
}
void EditorDebugDrawSphereComponent::BuildGameEntity(AZ::Entity* gameEntity)
{
if (m_settings.m_visibleInGame)
{
gameEntity->CreateComponent<DebugDrawSphereComponent>(m_element);
}
}
void EditorDebugDrawSphereComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
DebugDrawSphereComponent::GetProvidedServices(provided);
}
void EditorDebugDrawSphereComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
DebugDrawSphereComponent::GetIncompatibleServices(incompatible);
}
void EditorDebugDrawSphereComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
DebugDrawSphereComponent::GetRequiredServices(required);
}
void EditorDebugDrawSphereComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
DebugDrawSphereComponent::GetDependentServices(dependent);
}
void EditorDebugDrawSphereComponent::Init()
{
m_element.m_owningEditorComponent = GetId();
}
void EditorDebugDrawSphereComponent::Activate()
{
if (m_settings.m_visibleInEditor)
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::RegisterDebugDrawComponent, this);
}
}
void EditorDebugDrawSphereComponent::Deactivate()
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::UnregisterDebugDrawComponent, this);
}
void EditorDebugDrawSphereComponent::OnPropertyUpdate()
{
// Property updated, we need to update the system component (which handles drawing the components) with our new info
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::UnregisterDebugDrawComponent, this);
if (m_settings.m_visibleInEditor)
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::RegisterDebugDrawComponent, this);
}
}
} // namespace DebugDraw
@@ -0,0 +1,54 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
#include "DebugDrawSphereComponent.h"
#include "EditorDebugDrawComponentCommon.h"
namespace DebugDraw
{
class EditorDebugDrawSphereComponent
: public AzToolsFramework::Components::EditorComponentBase
{
friend class DebugDrawSystemComponent;
public:
AZ_EDITOR_COMPONENT(EditorDebugDrawSphereComponent, "{9853D5B5-5028-4B1A-9937-8378F8638F27}", AzToolsFramework::Components::EditorComponentBase);
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
////////////////////////////////////////////////////////////////////////
// EditorComponentBase
void BuildGameEntity(AZ::Entity* gameEntity) override;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// AZ::Component interface implementation
void Init() override;
void Activate() override;
void Deactivate() override;
////////////////////////////////////////////////////////////////////////
protected:
void OnPropertyUpdate();
DebugDrawSphereElement m_element;
EditorDebugDrawComponentSettings m_settings;
};
}
@@ -0,0 +1,109 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "DebugDraw_precompiled.h"
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include "EditorDebugDrawTextComponent.h"
namespace DebugDraw
{
void EditorDebugDrawTextComponent::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<EditorDebugDrawTextComponent, EditorComponentBase>()
->Version(0)
->Field("Element", &EditorDebugDrawTextComponent::m_element)
->Field("Settings", &EditorDebugDrawTextComponent::m_settings)
;
AZ::EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<EditorDebugDrawTextComponent>(
"DebugDraw Text", "Draws debug text on the screen at this entity's location.")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "Debugging")
->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/DebugDrawText.svg")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c))
->DataElement(0, &EditorDebugDrawTextComponent::m_element, "Text element settings", "Settings for the text element.")
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDebugDrawTextComponent::OnPropertyUpdate)
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(0, &EditorDebugDrawTextComponent::m_settings, "Visibility settings", "Common settings for DebugDraw components.")
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDebugDrawTextComponent::OnPropertyUpdate)
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
;
}
}
}
void EditorDebugDrawTextComponent::BuildGameEntity(AZ::Entity* gameEntity)
{
if (m_settings.m_visibleInGame)
{
gameEntity->CreateComponent<DebugDrawTextComponent>(m_element);
}
}
void EditorDebugDrawTextComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
DebugDrawTextComponent::GetProvidedServices(provided);
}
void EditorDebugDrawTextComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
DebugDrawTextComponent::GetIncompatibleServices(incompatible);
}
void EditorDebugDrawTextComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
DebugDrawTextComponent::GetRequiredServices(required);
}
void EditorDebugDrawTextComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
DebugDrawTextComponent::GetDependentServices(dependent);
}
void EditorDebugDrawTextComponent::Init()
{
m_element.m_owningEditorComponent = GetId();
}
void EditorDebugDrawTextComponent::Activate()
{
if (m_settings.m_visibleInEditor)
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::RegisterDebugDrawComponent, this);
}
}
void EditorDebugDrawTextComponent::Deactivate()
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::UnregisterDebugDrawComponent, this);
}
void EditorDebugDrawTextComponent::OnPropertyUpdate()
{
// Property updated, we need to update the system component (which handles drawing the components) with our new info
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::UnregisterDebugDrawComponent, this);
if (m_settings.m_visibleInEditor)
{
DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::RegisterDebugDrawComponent, this);
}
}
} // namespace DebugDraw
@@ -0,0 +1,51 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
#include "DebugDrawTextComponent.h"
#include "EditorDebugDrawComponentCommon.h"
namespace DebugDraw
{
class EditorDebugDrawTextComponent
: public AzToolsFramework::Components::EditorComponentBase
{
friend class DebugDrawSystemComponent;
public:
AZ_EDITOR_COMPONENT(EditorDebugDrawTextComponent, "{1B61B17F-AEE3-4AEB-A4E4-2BB053FB45D9}", AzToolsFramework::Components::EditorComponentBase);
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
// EditorComponentBase
void BuildGameEntity(AZ::Entity* gameEntity) override;
// AZ::Component interface implementation
void Init() override;
void Activate() override;
void Deactivate() override;
protected:
void OnPropertyUpdate();
DebugDrawTextElement m_element;
EditorDebugDrawComponentSettings m_settings;
};
}