BsSphericalJoint.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. #include "BsJoint.h"
  6. namespace BansheeEngine
  7. {
  8. /** @addtogroup Physics
  9. * @{
  10. */
  11. struct SPHERICAL_JOINT_DESC;
  12. /**
  13. * A spherical joint removes all translational degrees of freedom but allows all rotational degrees of freedom.
  14. * Essentially this ensures that the anchor points of the two bodies are always coincident. Bodies are allowed to
  15. * rotate around the anchor points, and their rotatation can be limited by an elliptical cone.
  16. */
  17. class BS_CORE_EXPORT SphericalJoint : public Joint
  18. {
  19. public:
  20. /** Flags that control options for the spherical joint */
  21. enum class Flag
  22. {
  23. Limit = 0x1
  24. };
  25. public:
  26. SphericalJoint(const SPHERICAL_JOINT_DESC& desc) { }
  27. virtual ~SphericalJoint() { }
  28. /**
  29. * Returns the limit of the joint. This clamps the rotation inside an eliptical angular cone. You must enable limit
  30. * flag on the joint in order for this to be recognized.
  31. */
  32. virtual LimitConeRange getLimit() const = 0;
  33. /**
  34. * Sets the limit of the joint. This clamps the rotation inside an eliptical angular cone. You must enable limit
  35. * flag on the joint in order for this to be recognized.
  36. */
  37. virtual void setLimit(const LimitConeRange& limit) = 0;
  38. /** Enables or disables a flag that controls the joint's behaviour. */
  39. virtual void setFlag(Flag flag, bool enabled) = 0;
  40. /** Checks is the specified flag enabled. */
  41. virtual bool hasFlag(Flag flag) const = 0;
  42. /** Creates a new spherical joint. */
  43. static SPtr<SphericalJoint> create(const SPHERICAL_JOINT_DESC& desc);
  44. };
  45. /** Structure used for initializing a new SphericalJoint. */
  46. struct SPHERICAL_JOINT_DESC : JOINT_DESC
  47. {
  48. LimitConeRange limit;
  49. SphericalJoint::Flag flag = (SphericalJoint::Flag)0;
  50. };
  51. /** @} */
  52. }