BsSphericalJoint.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 "Physics/BsJoint.h"
  6. namespace bs
  7. {
  8. /** @addtogroup Physics
  9. * @{
  10. */
  11. struct SPHERICAL_JOINT_DESC;
  12. /** Flags that control options for the spherical joint */
  13. enum class BS_SCRIPT_EXPORT(m:Physics) SphericalJointFlag
  14. {
  15. Limit = 0x1 /**< Enables the cone range limit. */
  16. };
  17. /**
  18. * A spherical joint removes all translational degrees of freedom but allows all rotational degrees of freedom.
  19. * Essentially this ensures that the anchor points of the two bodies are always coincident. Bodies are allowed to
  20. * rotate around the anchor points, and their rotatation can be limited by an elliptical cone.
  21. */
  22. class BS_CORE_EXPORT SphericalJoint : public Joint
  23. {
  24. public:
  25. SphericalJoint(const SPHERICAL_JOINT_DESC& desc) { }
  26. virtual ~SphericalJoint() { }
  27. /** @copydoc setLimit() */
  28. virtual LimitConeRange getLimit() const = 0;
  29. /**
  30. * Determines the limit of the joint. This clamps the rotation inside an eliptical angular cone. You must enable
  31. * limit flag on the joint in order for this to be recognized.
  32. */
  33. virtual void setLimit(const LimitConeRange& limit) = 0;
  34. /** Enables or disables a flag that controls the joint's behaviour. */
  35. virtual void setFlag(SphericalJointFlag flag, bool enabled) = 0;
  36. /** Checks is the specified flag enabled. */
  37. virtual bool hasFlag(SphericalJointFlag flag) const = 0;
  38. /** Creates a new spherical joint. */
  39. static SPtr<SphericalJoint> create(const SPHERICAL_JOINT_DESC& desc);
  40. };
  41. /** Structure used for initializing a new SphericalJoint. */
  42. struct SPHERICAL_JOINT_DESC : JOINT_DESC
  43. {
  44. LimitConeRange limit;
  45. SphericalJointFlag flag = (SphericalJointFlag)0;
  46. };
  47. /** @} */
  48. }