3
0

WhiteBoxColliderComponent.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 "WhiteBoxColliderConfiguration.h"
  10. #include <AzCore/Component/Component.h>
  11. #include <AzCore/Component/TransformBus.h>
  12. #include <AzFramework/Physics/Shape.h>
  13. #include <AzFramework/Physics/Common/PhysicsTypes.h>
  14. #include <AzFramework/Physics/SimulatedBodies/RigidBody.h>
  15. namespace WhiteBox
  16. {
  17. //! Component that provides a White box Collider.
  18. //! It covers the rigid body functionality as well, but it can be refactored out
  19. //! once EditorStaticRigidBodyComponent handles the creation of the simulated body.
  20. class WhiteBoxColliderComponent
  21. : public AZ::Component
  22. , private AZ::TransformNotificationBus::Handler
  23. {
  24. public:
  25. AZ_COMPONENT(WhiteBoxColliderComponent, "{B60C4D82-3299-414A-B91B-0299AA51BEF6}");
  26. static void Reflect(AZ::ReflectContext* context);
  27. WhiteBoxColliderComponent() = default;
  28. WhiteBoxColliderComponent(
  29. const Physics::CookedMeshShapeConfiguration& meshShape,
  30. const Physics::ColliderConfiguration& physicsColliderConfiguration,
  31. const WhiteBoxColliderConfiguration& whiteBoxColliderConfiguration);
  32. WhiteBoxColliderComponent(const WhiteBoxColliderComponent&) = delete;
  33. WhiteBoxColliderComponent& operator=(const WhiteBoxColliderComponent&) = delete;
  34. private:
  35. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  36. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  37. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  38. // AZ::Component ...
  39. void Activate() override;
  40. void Deactivate() override;
  41. // AZ::TransformNotificationBus ...
  42. void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
  43. Physics::CookedMeshShapeConfiguration m_shapeConfiguration; //!< The physics representation of the mesh.
  44. Physics::ColliderConfiguration
  45. m_physicsColliderConfiguration; //!< General physics collider configuration information.
  46. AzPhysics::SimulatedBodyHandle m_simulatedBodyHandle = AzPhysics::InvalidSimulatedBodyHandle; //!< Simulated body to represent the White Box Mesh at runtime.
  47. WhiteBoxColliderConfiguration
  48. m_whiteBoxColliderConfiguration; //!< White Box specific collider configuration information.
  49. };
  50. } // namespace WhiteBox