PhysicsJoint.h 978 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/Physics/Common.h>
  7. #include <AnKi/Util/ClassWrapper.h>
  8. namespace anki {
  9. /// @addtogroup physics
  10. /// @{
  11. /// Wrapper on top of Jolt joints.
  12. class PhysicsJoint : public PhysicsObjectBase
  13. {
  14. ANKI_PHYSICS_COMMON_FRIENDS
  15. friend class PhysicsJointPtrDeleter;
  16. private:
  17. union
  18. {
  19. ClassWrapper<JPH::TwoBodyConstraint> m_base;
  20. ClassWrapper<JPH::PointConstraint> m_point;
  21. ClassWrapper<JPH::HingeConstraint> m_hinge;
  22. };
  23. PhysicsBodyPtr m_body1;
  24. PhysicsBodyPtr m_body2;
  25. PhysicsJoint()
  26. : PhysicsObjectBase(PhysicsObjectType::kJoint)
  27. {
  28. ANKI_ASSERT(&m_base == static_cast<JPH::TwoBodyConstraint*>(&m_point));
  29. ANKI_ASSERT(&m_base == static_cast<JPH::TwoBodyConstraint*>(&m_hinge));
  30. }
  31. ~PhysicsJoint()
  32. {
  33. m_base.destroy();
  34. }
  35. };
  36. /// @}
  37. } // end namespace anki