RavEngine
Loading...
Searching...
No Matches
PxJointLimit.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef PX_JOINT_LIMIT_H
30#define PX_JOINT_LIMIT_H
35#include "foundation/PxMath.h"
36#include "common/PxTolerancesScale.h"
37#include "extensions/PxJoint.h"
38#include "PxPhysXConfig.h"
39
40#if !PX_DOXYGEN
41namespace physx
42{
43#endif
44
52{
53//= ATTENTION! =====================================================================================
54// Changing the data layout of this class breaks the binary serialization format. See comments for
55// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
56// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
57// accordingly.
58//==================================================================================================
59public:
80
85
92 PxReal stiffness;
93
100 PxReal damping;
101
120
122 restitution (0.0f),
123 bounceThreshold (0.0f),
124 stiffness (0.0f),
125 damping (0.0f),
127 {
128 }
129
134 damping (p.damping),
136 {
137 }
138
152
153 PX_INLINE bool isSoft() const
154 {
155 return damping>0 || stiffness>0;
156 }
157
158protected:
159 ~PxJointLimitParameters() {}
160};
161
162
167{
168//= ATTENTION! =====================================================================================
169// Changing the data layout of this class breaks the binary serialization format. See comments for
170// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
171// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
172// accordingly.
173//==================================================================================================
174public:
181 PxReal value;
182
192 PxJointLinearLimit(const PxTolerancesScale& scale, PxReal extent, PxReal contactDist_deprecated = -1.0f)
193 : value(extent)
194 {
195 PxJointLimitParameters::contactDistance_deprecated = contactDist_deprecated == -1.0f ? 0.01f*scale.length : contactDist_deprecated;
196 }
197
206 PxJointLinearLimit(PxReal extent, const PxSpring& spring) : value(extent)
207 {
208 stiffness = spring.stiffness;
209 damping = spring.damping;
210 }
211
217 PX_INLINE bool isValid() const
218 {
220 PxIsFinite(value) &&
221 value > 0.0f;
222 }
223};
224
225
230{
231//= ATTENTION! =====================================================================================
232// Changing the data layout of this class breaks the binary serialization format. See comments for
233// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
234// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
235// accordingly.
236//==================================================================================================
237public:
245 PxReal upper, lower;
246
257 PxJointLinearLimitPair(const PxTolerancesScale& scale, PxReal lowerLimit = -PX_MAX_F32/3.0f, PxReal upperLimit = PX_MAX_F32/3.0f, PxReal contactDist_deprecated = -1.0f) :
258 upper(upperLimit),
259 lower(lowerLimit)
260 {
261 PxJointLimitParameters::contactDistance_deprecated = contactDist_deprecated == -1.0f ? PxMin(scale.length * 0.01f, (upperLimit*0.49f-lowerLimit*0.49f)) : contactDist_deprecated;
262 bounceThreshold = 2.0f*scale.length;
263 }
264
274 PxJointLinearLimitPair(PxReal lowerLimit, PxReal upperLimit, const PxSpring& spring) :
275 upper(upperLimit),
276 lower(lowerLimit)
277 {
278 stiffness = spring.stiffness;
279 damping = spring.damping;
280 }
281
287 PX_INLINE bool isValid() const
288 {
290 PxIsFinite(upper) && PxIsFinite(lower) && upper >= lower &&
291 PxIsFinite(upper - lower);
292 }
293};
294
295
297{
298//= ATTENTION! =====================================================================================
299// Changing the data layout of this class breaks the binary serialization format. See comments for
300// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
301// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
302// accordingly.
303//==================================================================================================
304public:
312 PxReal upper, lower;
313
325 PxJointAngularLimitPair(PxReal lowerLimit, PxReal upperLimit, PxReal contactDist_deprecated = -1.0f) :
326 upper(upperLimit),
327 lower(lowerLimit)
328 {
329 PxJointLimitParameters::contactDistance_deprecated = contactDist_deprecated ==-1.0f ? PxMin(0.1f, 0.49f*(upperLimit-lowerLimit)) : contactDist_deprecated;
330 bounceThreshold = 0.5f;
331 }
332
344 PxJointAngularLimitPair(PxReal lowerLimit, PxReal upperLimit, const PxSpring& spring) :
345 upper(upperLimit),
346 lower(lowerLimit)
347 {
348 stiffness = spring.stiffness;
349 damping = spring.damping;
350 }
351
357 PX_INLINE bool isValid() const
358 {
360 PxIsFinite(upper) && PxIsFinite(lower) && upper >= lower;
361 }
362};
363
371{
372//= ATTENTION! =====================================================================================
373// Changing the data layout of this class breaks the binary serialization format. See comments for
374// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
375// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
376// accordingly.
377//==================================================================================================
378public:
386 PxReal yAngle;
387
395 PxReal zAngle;
396
406 PxJointLimitCone(PxReal yLimitAngle, PxReal zLimitAngle, PxReal contactDist_deprecated = -1.0f) :
407 yAngle(yLimitAngle),
408 zAngle(zLimitAngle)
409 {
410 PxJointLimitParameters::contactDistance_deprecated = contactDist_deprecated == -1.0f ? PxMin(0.1f, PxMin(yLimitAngle, zLimitAngle)*0.49f) : contactDist_deprecated;
411 bounceThreshold = 0.5f;
412 }
413
423 PxJointLimitCone(PxReal yLimitAngle, PxReal zLimitAngle, const PxSpring& spring) :
424 yAngle(yLimitAngle),
425 zAngle(zLimitAngle)
426 {
427 stiffness = spring.stiffness;
428 damping = spring.damping;
429 }
430
436 PX_INLINE bool isValid() const
437 {
439 PxIsFinite(yAngle) && yAngle>0 && yAngle<PxPi &&
440 PxIsFinite(zAngle) && zAngle>0 && zAngle<PxPi;
441 }
442};
443
450{
451//= ATTENTION! =====================================================================================
452// Changing the data layout of this class breaks the binary serialization format. See comments for
453// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
454// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
455// accordingly.
456//==================================================================================================
457public:
465 PxReal yAngleMin;
466
474 PxReal yAngleMax;
475
483 PxReal zAngleMin;
484
492 PxReal zAngleMax;
493
505 PxJointLimitPyramid(PxReal yLimitAngleMin, PxReal yLimitAngleMax, PxReal zLimitAngleMin, PxReal zLimitAngleMax, PxReal contactDist_deprecated = -1.0f) :
506 yAngleMin(yLimitAngleMin),
507 yAngleMax(yLimitAngleMax),
508 zAngleMin(zLimitAngleMin),
509 zAngleMax(zLimitAngleMax)
510 {
511 if(contactDist_deprecated == -1.0f)
512 {
513 const PxReal contactDistY = PxMin(0.1f, 0.49f*(yLimitAngleMax - yLimitAngleMin));
514 const PxReal contactDistZ = PxMin(0.1f, 0.49f*(zLimitAngleMax - zLimitAngleMin));
515 PxJointLimitParameters::contactDistance_deprecated = contactDist_deprecated == PxMin(contactDistY, contactDistZ);
516 }
517 else
518 {
520 }
521
522 bounceThreshold = 0.5f;
523 }
524
536 PxJointLimitPyramid(PxReal yLimitAngleMin, PxReal yLimitAngleMax, PxReal zLimitAngleMin, PxReal zLimitAngleMax, const PxSpring& spring) :
537 yAngleMin(yLimitAngleMin),
538 yAngleMax(yLimitAngleMax),
539 zAngleMin(zLimitAngleMin),
540 zAngleMax(zLimitAngleMax)
541 {
542 stiffness = spring.stiffness;
543 damping = spring.damping;
544 }
545
551 PX_INLINE bool isValid() const
552 {
554 PxIsFinite(yAngleMin) && yAngleMin>-PxPi && yAngleMin<PxPi &&
555 PxIsFinite(yAngleMax) && yAngleMax>-PxPi && yAngleMax<PxPi &&
556 PxIsFinite(zAngleMin) && zAngleMin>-PxPi && zAngleMin<PxPi &&
557 PxIsFinite(zAngleMax) && zAngleMax>-PxPi && zAngleMax<PxPi &&
559 }
560};
561
562#if !PX_DOXYGEN
563} // namespace physx
564#endif
565
567#endif
Definition PxJointLimit.h:297
PxJointAngularLimitPair(PxReal lowerLimit, PxReal upperLimit, const PxSpring &spring)
construct an angular soft limit pair.
Definition PxJointLimit.h:344
PX_INLINE bool isValid() const
Returns true if the limit is valid.
Definition PxJointLimit.h:357
PxReal upper
the range of the limit. The upper limit must be no lower than the lower limit.
Definition PxJointLimit.h:312
PxJointAngularLimitPair(PxReal lowerLimit, PxReal upperLimit, PxReal contactDist_deprecated=-1.0f)
construct an angular hard limit pair.
Definition PxJointLimit.h:325
Describes an elliptical conical joint limit. Note that very small or highly elliptical limit cones ma...
Definition PxJointLimit.h:371
PxJointLimitCone(PxReal yLimitAngle, PxReal zLimitAngle, PxReal contactDist_deprecated=-1.0f)
Construct a cone hard limit.
Definition PxJointLimit.h:406
PX_INLINE bool isValid() const
Returns true if the limit is valid.
Definition PxJointLimit.h:436
PxJointLimitCone(PxReal yLimitAngle, PxReal zLimitAngle, const PxSpring &spring)
Construct a cone soft limit.
Definition PxJointLimit.h:423
PxReal yAngle
the maximum angle from the Y axis of the constraint frame.
Definition PxJointLimit.h:386
PxReal zAngle
the maximum angle from the Z-axis of the constraint frame.
Definition PxJointLimit.h:395
Describes the parameters for a joint limit.
Definition PxJointLimit.h:52
PxReal bounceThreshold
Definition PxJointLimit.h:84
PX_INLINE bool isValid() const
Returns true if the current settings are valid.
Definition PxJointLimit.h:144
PxReal restitution
Controls the amount of bounce when the joint hits a limit.
Definition PxJointLimit.h:79
PxReal damping
if spring is greater than zero, this is the damping of the limit spring
Definition PxJointLimit.h:100
PxReal stiffness
if greater than zero, the limit is soft, i.e. a spring pulls the joint back to the limit
Definition PxJointLimit.h:92
PxReal contactDistance_deprecated
The distance inside the limit value at which the limit will be considered to be active by the solver....
Definition PxJointLimit.h:119
Describes a pyramidal joint limit.
Definition PxJointLimit.h:450
PxReal zAngleMax
the maximum angle from the Z-axis of the constraint frame.
Definition PxJointLimit.h:492
PX_INLINE bool isValid() const
Returns true if the limit is valid.
Definition PxJointLimit.h:551
PxReal yAngleMax
the maximum angle from the Y axis of the constraint frame.
Definition PxJointLimit.h:474
PxJointLimitPyramid(PxReal yLimitAngleMin, PxReal yLimitAngleMax, PxReal zLimitAngleMin, PxReal zLimitAngleMax, PxReal contactDist_deprecated=-1.0f)
Construct a pyramid hard limit.
Definition PxJointLimit.h:505
PxReal zAngleMin
the minimum angle from the Z-axis of the constraint frame.
Definition PxJointLimit.h:483
PxReal yAngleMin
the minimum angle from the Y axis of the constraint frame.
Definition PxJointLimit.h:465
PxJointLimitPyramid(PxReal yLimitAngleMin, PxReal yLimitAngleMax, PxReal zLimitAngleMin, PxReal zLimitAngleMax, const PxSpring &spring)
Construct a pyramid soft limit.
Definition PxJointLimit.h:536
Describes a two-sided limit.
Definition PxJointLimit.h:230
PxReal upper
the range of the limit. The upper limit must be no lower than the lower limit, and if they are equal ...
Definition PxJointLimit.h:245
PxJointLinearLimitPair(PxReal lowerLimit, PxReal upperLimit, const PxSpring &spring)
construct a linear soft limit pair
Definition PxJointLimit.h:274
PxJointLinearLimitPair(const PxTolerancesScale &scale, PxReal lowerLimit=-PX_MAX_F32/3.0f, PxReal upperLimit=PX_MAX_F32/3.0f, PxReal contactDist_deprecated=-1.0f)
Construct a linear hard limit pair. The lower distance value must be less than the upper distance val...
Definition PxJointLimit.h:257
PX_INLINE bool isValid() const
Returns true if the limit is valid.
Definition PxJointLimit.h:287
Describes a one-sided linear limit.
Definition PxJointLimit.h:167
PxJointLinearLimit(const PxTolerancesScale &scale, PxReal extent, PxReal contactDist_deprecated=-1.0f)
construct a linear hard limit
Definition PxJointLimit.h:192
PX_INLINE bool isValid() const
Returns true if the limit is valid.
Definition PxJointLimit.h:217
PxReal value
the extent of the limit.
Definition PxJointLimit.h:181
PxJointLinearLimit(PxReal extent, const PxSpring &spring)
construct a linear soft limit
Definition PxJointLimit.h:206
Definition PxJoint.h:385
Class to define the scale at which simulation runs. Most simulation tolerances are calculated in term...
Definition PxTolerancesScale.h:53
#define PX_INLINE
Definition PxPreprocessor.h:320
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PX_CUDA_CALLABLE PX_FORCE_INLINE bool PxIsFinite(float f)
returns true if the passed number is a finite floating point number as opposed to INF,...
Definition PxMath.h:326
PX_CUDA_CALLABLE PX_FORCE_INLINE T PxMin(T a, T b)
The return value is the lesser of the two specified values.
Definition PxMath.h:88