3
0

EditorWhiteBoxColliderComponent.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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/TransformBus.h>
  11. #include <AzFramework/Physics/Shape.h>
  12. #include <AzFramework/Physics/Common/PhysicsTypes.h>
  13. #include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
  14. #include <WhiteBox/EditorWhiteBoxColliderBus.h>
  15. #include <WhiteBox/WhiteBoxToolApi.h>
  16. namespace AzPhysics
  17. {
  18. class SceneInterface;
  19. }
  20. namespace WhiteBox
  21. {
  22. //! Generates physics from white box mesh.
  23. class EditorWhiteBoxColliderComponent
  24. : public AzToolsFramework::Components::EditorComponentBase
  25. , private EditorWhiteBoxColliderRequestBus::Handler
  26. , private AZ::TransformNotificationBus::Handler
  27. {
  28. public:
  29. AZ_EDITOR_COMPONENT(
  30. EditorWhiteBoxColliderComponent, "{4EF53472-6ED4-4740-B956-F6AE5B4A4BB1}", EditorComponentBase);
  31. static void Reflect(AZ::ReflectContext* context);
  32. EditorWhiteBoxColliderComponent() = default;
  33. EditorWhiteBoxColliderComponent(const EditorWhiteBoxColliderComponent&) = delete;
  34. EditorWhiteBoxColliderComponent& operator=(const EditorWhiteBoxColliderComponent&) = delete;
  35. private:
  36. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  37. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  38. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  39. // AZ::Component ...
  40. void Activate() override;
  41. void Deactivate() override;
  42. // EditorComponentBase ...
  43. void BuildGameEntity(AZ::Entity* gameEntity) override;
  44. // TransformBus ...
  45. void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
  46. // EditorWhiteBoxColliderRequestBus ...
  47. void CreatePhysics(const WhiteBoxMesh& whiteBox) override;
  48. void DestroyPhysics() override;
  49. void ConvertToPhysicsMesh(const WhiteBoxMesh& whiteBox);
  50. AzPhysics::SceneInterface* m_sceneInterface = nullptr;
  51. AzPhysics::SceneHandle m_editorSceneHandle = AzPhysics::InvalidSceneHandle;
  52. Physics::ColliderConfiguration
  53. m_physicsColliderConfiguration; //!< General physics collider configuration information.
  54. Physics::CookedMeshShapeConfiguration m_meshShapeConfiguration; //!< The physics representation of the mesh.
  55. AzPhysics::SimulatedBodyHandle m_rigidBodyHandle = AzPhysics::InvalidSimulatedBodyHandle; //!< Handle to a static rigid body to represent the White Box Mesh at edit time.
  56. WhiteBoxColliderConfiguration
  57. m_whiteBoxColliderConfiguration; //!< White Box specific collider configuration information.
  58. };
  59. } // namespace WhiteBox