| 1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
| 2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
| 3 | #pragma once |
| 4 | |
| 5 | #include "BsCorePrerequisites.h" |
| 6 | #include "Physics/BsJoint.h" |
| 7 | |
| 8 | namespace bs |
| 9 | { |
| 10 | class PhysicsScene; |
| 11 | /** @addtogroup Physics |
| 12 | * @{ |
| 13 | */ |
| 14 | |
| 15 | struct SLIDER_JOINT_DESC; |
| 16 | |
| 17 | /** Flag that controls slider joint's behaviour. */ |
| 18 | enum class BS_SCRIPT_EXPORT(m:Physics) SliderJointFlag |
| 19 | { |
| 20 | Limit = 0x1 /**< Enables the linear range limit. */ |
| 21 | }; |
| 22 | |
| 23 | /** |
| 24 | * Joint that removes all but a single translational degree of freedom. Bodies are allowed to move along a single axis. |
| 25 | */ |
| 26 | class BS_CORE_EXPORT SliderJoint : public Joint |
| 27 | { |
| 28 | public: |
| 29 | SliderJoint(const SLIDER_JOINT_DESC& desc) { } |
| 30 | virtual ~SliderJoint() = default; |
| 31 | |
| 32 | /** Returns the current position of the slider. */ |
| 33 | virtual float getPosition() const = 0; |
| 34 | |
| 35 | /** Returns the current speed of the slider. */ |
| 36 | virtual float getSpeed() const = 0; |
| 37 | |
| 38 | /** @copydoc setLimit() */ |
| 39 | virtual LimitLinearRange getLimit() const = 0; |
| 40 | |
| 41 | /** |
| 42 | * Determines a limit that constrains the movement of the joint to a specific minimum and maximum distance. You must |
| 43 | * enable the limit flag on the joint in order for this to be recognized. |
| 44 | * |
| 45 | * @see LimitLinearRange |
| 46 | */ |
| 47 | virtual void setLimit(const LimitLinearRange& limit) = 0; |
| 48 | |
| 49 | /** Enables or disables a flag that controls the joint's behaviour. */ |
| 50 | virtual void setFlag(SliderJointFlag flag, bool enabled) = 0; |
| 51 | |
| 52 | /** Checks is the specified flag enabled. */ |
| 53 | virtual bool hasFlag(SliderJointFlag flag) const = 0; |
| 54 | |
| 55 | /** |
| 56 | * Creates a new spherical joint. |
| 57 | * |
| 58 | * @param[in] scene Scene to which to add the joint. |
| 59 | * @param[in] desc Settings describing the joint. |
| 60 | */ |
| 61 | static SPtr<SliderJoint> create(PhysicsScene& scene, const SLIDER_JOINT_DESC& desc); |
| 62 | }; |
| 63 | |
| 64 | /** Structure used for initializing a new SliderJoint. */ |
| 65 | struct SLIDER_JOINT_DESC : JOINT_DESC |
| 66 | { |
| 67 | LimitLinearRange limit; |
| 68 | SliderJointFlag flag = (SliderJointFlag)0; |
| 69 | }; |
| 70 | |
| 71 | /** @} */ |
| 72 | } |