BsDistanceJoint.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 DISTANCE_JOINT_DESC;
  12. /** Controls distance joint options. */
  13. enum class BS_SCRIPT_EXPORT(m:Physics) DistanceJointFlag
  14. {
  15. MinDistance = 0x1, /**< Enables minimum distance limit. */
  16. MaxDistance = 0x2, /**< Enables maximum distance limit. */
  17. Spring = 0x4 /**< Enables spring when maintaining limits. */
  18. };
  19. /** A joint that maintains an upper or lower (or both) bound on the distance between two bodies. */
  20. class BS_CORE_EXPORT DistanceJoint : public Joint
  21. {
  22. public:
  23. DistanceJoint(const DISTANCE_JOINT_DESC& desc) { }
  24. virtual ~DistanceJoint() { }
  25. /** Returns the current distance between the two joint bodies. */
  26. virtual float getDistance() const = 0;
  27. /** @copydoc setMinDistance() */
  28. virtual float getMinDistance() const = 0;
  29. /**
  30. * Determines the minimum distance the bodies are allowed to be at, they will get no closer. You must enable min
  31. * distance flag in order for this limit to be applied.
  32. */
  33. virtual void setMinDistance(float value) = 0;
  34. /** @copydoc setMaxDistance() */
  35. virtual float getMaxDistance() const = 0;
  36. /**
  37. * Determines the maximum distance the bodies are allowed to be at, they will get no further. You must enable max
  38. * distance flag in order for this limit to be applied.
  39. */
  40. virtual void setMaxDistance(float value) = 0;
  41. /** @copydoc setTolerance() */
  42. virtual float getTolerance() const = 0;
  43. /**
  44. * Determines the error tolerance of the joint at which the joint becomes active. This value slightly extends the
  45. * lower and upper limit.
  46. */
  47. virtual void setTolerance(float value) = 0;
  48. /** @copydoc setSpring() */
  49. virtual Spring getSpring() const = 0;
  50. /**
  51. * Determines a spring that controls how the joint responds when a limit is reached. You must enable the spring
  52. * flag on the joint in order for this to be recognized.
  53. *
  54. * @see Spring
  55. */
  56. virtual void setSpring(const Spring& value) = 0;
  57. /** Enables or disables a flag that controls joint behaviour. */
  58. virtual void setFlag(DistanceJointFlag flag, bool enabled) = 0;
  59. /** Checks whether a certain joint flag is enabled. */
  60. virtual bool hasFlag(DistanceJointFlag flag) const = 0;
  61. /** Creates a new distance joint. */
  62. static SPtr<DistanceJoint> create(const DISTANCE_JOINT_DESC& desc);
  63. };
  64. /** Structure used for initializing a new DistanceJoint. */
  65. struct DISTANCE_JOINT_DESC : JOINT_DESC
  66. {
  67. float minDistance = 0.0f;
  68. float maxDistance = 0.0f;
  69. float tolerance = 0.25f;
  70. Spring spring;
  71. DistanceJointFlag flag = (DistanceJointFlag)0;
  72. };
  73. /** @} */
  74. }