DebugDrawSphereComponent.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AzCore/Serialization/SerializeContext.h>
  9. #include <AzCore/Serialization/EditContext.h>
  10. #include "DebugDrawSphereComponent.h"
  11. namespace DebugDraw
  12. {
  13. void DebugDrawSphereElement::Reflect(AZ::ReflectContext* context)
  14. {
  15. AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
  16. if (serializeContext)
  17. {
  18. serializeContext->Class<DebugDrawSphereElement>()
  19. ->Version(0)
  20. ->Field("TargetEntityId", &DebugDrawSphereElement::m_targetEntityId)
  21. ->Field("Color", &DebugDrawSphereElement::m_color)
  22. ->Field("WorldLocation", &DebugDrawSphereElement::m_worldLocation)
  23. ->Field("Radius", &DebugDrawSphereElement::m_radius)
  24. ->Field("IsRayTracingEnabled", &DebugDrawSphereElement::m_isRayTracingEnabled)
  25. ;
  26. AZ::EditContext* editContext = serializeContext->GetEditContext();
  27. if (editContext)
  28. {
  29. editContext->Class<DebugDrawSphereElement>("DebugDraw Sphere Element Settings", "Settings for DebugDraw sphere element.")
  30. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  31. ->Attribute(AZ::Edit::Attributes::Category, "Debugging")
  32. ->DataElement(0, &DebugDrawSphereElement::m_color, "Color", "Display color for the line.")
  33. ->DataElement(0, &DebugDrawSphereElement::m_radius, "Radius", "The size of the sphere.")
  34. ->DataElement(0, &DebugDrawSphereElement::m_isRayTracingEnabled, "Use ray tracing", "Includes this object in ray tracing calculations.")
  35. ;
  36. }
  37. }
  38. }
  39. void DebugDrawSphereComponent::Reflect(AZ::ReflectContext* context)
  40. {
  41. DebugDrawSphereElement::Reflect(context);
  42. if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
  43. {
  44. serialize->Class<DebugDrawSphereComponent, AZ::Component>()
  45. ->Version(0)
  46. ->Field("Element", &DebugDrawSphereComponent::m_element)
  47. ;
  48. }
  49. }
  50. DebugDrawSphereComponent::DebugDrawSphereComponent(const DebugDrawSphereElement& element)
  51. : m_element(element)
  52. {
  53. m_element.m_owningEditorComponent = AZ::InvalidComponentId;
  54. }
  55. void DebugDrawSphereComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  56. {
  57. provided.push_back(AZ_CRC_CE("DebugDrawSphereService"));
  58. }
  59. void DebugDrawSphereComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  60. {
  61. (void)incompatible;
  62. }
  63. void DebugDrawSphereComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  64. {
  65. (void)required;
  66. }
  67. void DebugDrawSphereComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
  68. {
  69. (void)dependent;
  70. }
  71. void DebugDrawSphereComponent::Init()
  72. {
  73. }
  74. void DebugDrawSphereComponent::Activate()
  75. {
  76. DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::RegisterDebugDrawComponent, this);
  77. }
  78. void DebugDrawSphereComponent::Deactivate()
  79. {
  80. DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::UnregisterDebugDrawComponent, this);
  81. }
  82. } // namespace DebugDraw