1//
2// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions
4// are met:
5// * Redistributions of source code must retain the above copyright
6// notice, this list of conditions and the following disclaimer.
7// * Redistributions in binary form must reproduce the above copyright
8// notice, this list of conditions and the following disclaimer in the
9// documentation and/or other materials provided with the distribution.
10// * Neither the name of NVIDIA CORPORATION nor the names of its
11// contributors may be used to endorse or promote products derived
12// from this software without specific prior written permission.
13//
14// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
15// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25//
26// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
27// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
28// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
29
30#ifndef PX_DISTANCEJOINT_H
31#define PX_DISTANCEJOINT_H
32/** \addtogroup extensions
33 @{
34*/
35
36#include "extensions/PxJoint.h"
37
38#if !PX_DOXYGEN
39namespace physx
40{
41#endif
42
43class PxDistanceJoint;
44
45/**
46\brief Create a distance Joint.
47
48 \param[in] physics The physics SDK
49 \param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
50 \param[in] localFrame0 The position and orientation of the joint relative to actor0
51 \param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
52 \param[in] localFrame1 The position and orientation of the joint relative to actor1
53
54@see PxDistanceJoint
55*/
56PxDistanceJoint* PxDistanceJointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1);
57
58
59/**
60\brief flags for configuring the drive of a PxDistanceJoint
61
62@see PxDistanceJoint
63*/
64struct PxDistanceJointFlag
65{
66 enum Enum
67 {
68 eMAX_DISTANCE_ENABLED = 1<<1,
69 eMIN_DISTANCE_ENABLED = 1<<2,
70 eSPRING_ENABLED = 1<<3
71 };
72};
73
74typedef PxFlags<PxDistanceJointFlag::Enum, PxU16> PxDistanceJointFlags;
75PX_FLAGS_OPERATORS(PxDistanceJointFlag::Enum, PxU16)
76
77/**
78\brief a joint that maintains an upper or lower bound (or both) on the distance between two points on different objects
79
80@see PxDistanceJointCreate PxJoint
81*/
82class PxDistanceJoint : public PxJoint
83{
84public:
85
86 /**
87 \brief Return the current distance of the joint
88 */
89 virtual PxReal getDistance() const = 0;
90
91 /**
92 \brief Set the allowed minimum distance for the joint.
93
94 The minimum distance must be no more than the maximum distance
95
96 <b>Default</b> 0.0f
97 <b>Range</b> [0, PX_MAX_F32)
98
99 \param[in] distance the minimum distance
100
101 @see PxDistanceJoint::minDistance, PxDistanceJointFlag::eMIN_DISTANCE_ENABLED getMinDistance()
102 */
103 virtual void setMinDistance(PxReal distance) = 0;
104
105 /**
106 \brief Get the allowed minimum distance for the joint.
107
108 \return the allowed minimum distance
109
110 @see PxDistanceJoint::minDistance, PxDistanceJointFlag::eMIN_DISTANCE_ENABLED setMinDistance()
111 */
112 virtual PxReal getMinDistance() const = 0;
113
114 /**
115 \brief Set the allowed maximum distance for the joint.
116
117 The maximum distance must be no less than the minimum distance.
118
119 <b>Default</b> 0.0f
120 <b>Range</b> [0, PX_MAX_F32)
121
122 \param[in] distance the maximum distance
123
124 @see PxDistanceJoint::maxDistance, PxDistanceJointFlag::eMAX_DISTANCE_ENABLED getMinDistance()
125 */
126 virtual void setMaxDistance(PxReal distance) = 0;
127
128 /**
129 \brief Get the allowed maximum distance for the joint.
130
131 \return the allowed maximum distance
132
133 @see PxDistanceJoint::maxDistance, PxDistanceJointFlag::eMAX_DISTANCE_ENABLED setMaxDistance()
134 */
135 virtual PxReal getMaxDistance() const = 0;
136
137 /**
138 \brief Set the error tolerance of the joint.
139
140 \param[in] tolerance the distance beyond the allowed range at which the joint becomes active
141
142 @see PxDistanceJoint::tolerance, getTolerance()
143 */
144 virtual void setTolerance(PxReal tolerance) = 0;
145
146 /**
147 \brief Get the error tolerance of the joint.
148
149 the distance beyond the joint's [min, max] range before the joint becomes active.
150
151 <b>Default</b> 0.25f * PxTolerancesScale::length
152 <b>Range</b> (0, PX_MAX_F32)
153
154 This value should be used to ensure that if the minimum distance is zero and the
155 spring function is in use, the rest length of the spring is non-zero.
156
157 @see PxDistanceJoint::tolerance, setTolerance()
158 */
159 virtual PxReal getTolerance() const = 0;
160
161 /**
162 \brief Set the strength of the joint spring.
163
164 The spring is used if enabled, and the distance exceeds the range [min-error, max+error].
165
166 <b>Default</b> 0.0f
167 <b>Range</b> [0, PX_MAX_F32)
168
169 \param[in] stiffness the spring strength of the joint
170
171 @see PxDistanceJointFlag::eSPRING_ENABLED getStiffness()
172 */
173 virtual void setStiffness(PxReal stiffness) = 0;
174
175 /**
176 \brief Get the strength of the joint spring.
177
178 \return stiffness the spring strength of the joint
179
180 @see PxDistanceJointFlag::eSPRING_ENABLED setStiffness()
181 */
182 virtual PxReal getStiffness() const = 0;
183
184 /**
185 \brief Set the damping of the joint spring.
186
187 The spring is used if enabled, and the distance exceeds the range [min-error, max+error].
188
189 <b>Default</b> 0.0f
190 <b>Range</b> [0, PX_MAX_F32)
191
192 \param[in] damping the degree of damping of the joint spring of the joint
193
194 @see PxDistanceJointFlag::eSPRING_ENABLED setDamping()
195 */
196 virtual void setDamping(PxReal damping) = 0;
197
198 /**
199 \brief Get the damping of the joint spring.
200
201 \return the degree of damping of the joint spring of the joint
202
203 @see PxDistanceJointFlag::eSPRING_ENABLED setDamping()
204 */
205 virtual PxReal getDamping() const = 0;
206
207 /**
208 \brief Set the flags specific to the Distance Joint.
209
210 <b>Default</b> PxDistanceJointFlag::eMAX_DISTANCE_ENABLED
211
212 \param[in] flags The joint flags.
213
214 @see PxDistanceJointFlag setFlag() getFlags()
215 */
216 virtual void setDistanceJointFlags(PxDistanceJointFlags flags) = 0;
217
218 /**
219 \brief Set a single flag specific to a Distance Joint to true or false.
220
221 \param[in] flag The flag to set or clear.
222 \param[in] value the value to which to set the flag
223
224 @see PxDistanceJointFlag, getFlags() setFlags()
225 */
226 virtual void setDistanceJointFlag(PxDistanceJointFlag::Enum flag, bool value) = 0;
227
228 /**
229 \brief Get the flags specific to the Distance Joint.
230
231 \return the joint flags
232
233 @see PxDistanceJoint::flags, PxDistanceJointFlag setFlag() setFlags()
234 */
235 virtual PxDistanceJointFlags getDistanceJointFlags() const = 0;
236
237 /**
238 \brief Returns string name of PxDistanceJoint, used for serialization
239 */
240 virtual const char* getConcreteTypeName() const { return "PxDistanceJoint"; }
241
242protected:
243
244 //serialization
245
246 /**
247 \brief Constructor
248 */
249 PX_INLINE PxDistanceJoint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {}
250
251 /**
252 \brief Deserialization constructor
253 */
254 PX_INLINE PxDistanceJoint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {}
255
256 /**
257 \brief Returns whether a given type name matches with the type of this instance
258 */
259 virtual bool isKindOf(const char* name) const { return !::strcmp(s1: "PxDistanceJoint", s2: name) || PxJoint::isKindOf(name); }
260
261 //~serialization
262};
263
264#if !PX_DOXYGEN
265} // namespace physx
266#endif
267
268/** @} */
269#endif
270

source code of qtquick3dphysics/src/3rdparty/PhysX/include/extensions/PxDistanceJoint.h