DebugDrawObbComponent.cpp 3.5 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 "DebugDrawObbComponent.h"
  11. namespace DebugDraw
  12. {
  13. void DebugDrawObbElement::Reflect(AZ::ReflectContext* context)
  14. {
  15. AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
  16. if (serializeContext)
  17. {
  18. serializeContext->Class<DebugDrawObbElement>()
  19. ->Version(0)
  20. ->Field("TargetEntityId", &DebugDrawObbElement::m_targetEntityId)
  21. ->Field("Color", &DebugDrawObbElement::m_color)
  22. ->Field("WorldLocation", &DebugDrawObbElement::m_worldLocation)
  23. ->Field("Scale", &DebugDrawObbElement::m_scale)
  24. ->Field("IsRayTracingEnabled", &DebugDrawObbElement::m_isRayTracingEnabled)
  25. ;
  26. AZ::EditContext* editContext = serializeContext->GetEditContext();
  27. if (editContext)
  28. {
  29. editContext->Class<DebugDrawObbElement>("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, &DebugDrawObbElement::m_color, "Color", "Display color for the line.")
  33. ->DataElement(0, &DebugDrawObbElement::m_scale, "Scale", "The scale of the box.")
  34. ->DataElement(0, &DebugDrawObbElement::m_isRayTracingEnabled, "Use ray tracing", "Includes this object in ray tracing calculations.")
  35. ;
  36. }
  37. }
  38. }
  39. void DebugDrawObbComponent::Reflect(AZ::ReflectContext* context)
  40. {
  41. DebugDrawObbElement::Reflect(context);
  42. if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
  43. {
  44. serialize->Class<DebugDrawObbComponent, AZ::Component>()
  45. ->Version(0)
  46. ->Field("Element", &DebugDrawObbComponent::m_element)
  47. ;
  48. }
  49. }
  50. DebugDrawObbComponent::DebugDrawObbComponent(const DebugDrawObbElement& element)
  51. : m_element(element)
  52. {
  53. m_element.m_owningEditorComponent = AZ::InvalidComponentId;
  54. }
  55. void DebugDrawObbComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  56. {
  57. provided.push_back(AZ_CRC_CE("DebugDrawObbService"));
  58. }
  59. void DebugDrawObbComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  60. {
  61. incompatible.push_back(AZ_CRC_CE("NonUniformScaleService"));
  62. }
  63. void DebugDrawObbComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  64. {
  65. (void)required;
  66. }
  67. void DebugDrawObbComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
  68. {
  69. (void)dependent;
  70. }
  71. void DebugDrawObbComponent::Init()
  72. {
  73. }
  74. void DebugDrawObbComponent::Activate()
  75. {
  76. DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::RegisterDebugDrawComponent, this);
  77. }
  78. void DebugDrawObbComponent::Deactivate()
  79. {
  80. DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::UnregisterDebugDrawComponent, this);
  81. }
  82. } // namespace DebugDraw