DebugDrawObbComponent.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #pragma once
  9. #include <AzCore/Component/Component.h>
  10. #include <AzCore/Script/ScriptTimePoint.h>
  11. #include <DebugDraw/DebugDrawBus.h>
  12. namespace DebugDraw
  13. {
  14. class DebugDrawObbElement
  15. {
  16. public:
  17. AZ_CLASS_ALLOCATOR(DebugDrawObbElement, AZ::SystemAllocator);
  18. AZ_TYPE_INFO(DebugDrawObbElement, "{C0B12E93-287A-4170-B1B6-3BF70D1D9433}");
  19. static void Reflect(AZ::ReflectContext* context);
  20. AZ::EntityId m_targetEntityId;
  21. AZ::Obb m_obb;
  22. float m_duration;
  23. AZ::ScriptTimePoint m_activateTime;
  24. AZ::Color m_color;
  25. AZ::Vector3 m_worldLocation;
  26. AZ::ComponentId m_owningEditorComponent;
  27. AZ::Vector3 m_scale;
  28. bool m_isRayTracingEnabled = false;
  29. DebugDrawObbElement()
  30. : m_duration(0.1f)
  31. , m_color(1.0f, 1.0f, 1.0f, 1.0f) // AZ::Color::White
  32. , m_worldLocation(AZ::Vector3::CreateZero())
  33. , m_owningEditorComponent(AZ::InvalidComponentId)
  34. , m_scale(AZ::Vector3(1.0f, 1.0f, 1.0f))
  35. , m_obb(AZ::Obb::CreateFromPositionRotationAndHalfLengths(m_worldLocation, AZ::Quaternion::CreateIdentity(), AZ::Vector3::CreateOne()))
  36. {}
  37. };
  38. class DebugDrawObbComponent
  39. : public AZ::Component
  40. {
  41. friend class DebugDrawSystemComponent;
  42. public:
  43. AZ_COMPONENT(DebugDrawObbComponent, "{B1574E9A-C9A1-4A9C-9866-23735ED6FD69}");
  44. static void Reflect(AZ::ReflectContext* context);
  45. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  46. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  47. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  48. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  49. DebugDrawObbComponent() = default;
  50. explicit DebugDrawObbComponent(const DebugDrawObbElement& element);
  51. ~DebugDrawObbComponent() override = default;
  52. ////////////////////////////////////////////////////////////////////////
  53. // AZ::Component interface implementation
  54. void Init() override;
  55. void Activate() override;
  56. void Deactivate() override;
  57. ////////////////////////////////////////////////////////////////////////
  58. protected:
  59. DebugDrawObbElement m_element;
  60. };
  61. }