DebugDrawObbComponent.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. DebugDrawObbElement()
  29. : m_duration(0.1f)
  30. , m_color(1.0f, 1.0f, 1.0f, 1.0f) // AZ::Color::White
  31. , m_worldLocation(AZ::Vector3::CreateZero())
  32. , m_owningEditorComponent(AZ::InvalidComponentId)
  33. , m_scale(AZ::Vector3(1.0f, 1.0f, 1.0f))
  34. , m_obb(AZ::Obb::CreateFromPositionRotationAndHalfLengths(m_worldLocation, AZ::Quaternion::CreateIdentity(), AZ::Vector3::CreateOne()))
  35. {}
  36. };
  37. class DebugDrawObbComponent
  38. : public AZ::Component
  39. {
  40. friend class DebugDrawSystemComponent;
  41. public:
  42. AZ_COMPONENT(DebugDrawObbComponent, "{B1574E9A-C9A1-4A9C-9866-23735ED6FD69}");
  43. static void Reflect(AZ::ReflectContext* context);
  44. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  45. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  46. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  47. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  48. DebugDrawObbComponent() = default;
  49. explicit DebugDrawObbComponent(const DebugDrawObbElement& element);
  50. ~DebugDrawObbComponent() override = default;
  51. ////////////////////////////////////////////////////////////////////////
  52. // AZ::Component interface implementation
  53. void Init() override;
  54. void Activate() override;
  55. void Deactivate() override;
  56. ////////////////////////////////////////////////////////////////////////
  57. protected:
  58. DebugDrawObbElement m_element;
  59. };
  60. }