BsDistanceJoint.h 3.0 KB

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