PxJointLimit.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
3  *
4  * NVIDIA CORPORATION and its licensors retain all intellectual property
5  * and proprietary rights in and to this software, related documentation
6  * and any modifications thereto. Any use, reproduction, disclosure or
7  * distribution of this software and related documentation without an express
8  * license agreement from NVIDIA CORPORATION is strictly prohibited.
9  */
10 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
11 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
12 
13 
14 #ifndef PX_EXTENSIONS_JOINT_LIMIT
15 #define PX_EXTENSIONS_JOINT_LIMIT
16 
20 #include "foundation/PxMath.h"
21 #include "PxPhysXConfig.h"
23 #include "PxJoint.h"
24 
25 #ifndef PX_DOXYGEN
26 namespace physx
27 {
28 #endif
29 
40 {
41 //= ATTENTION! =====================================================================================
42 // Changing the data layout of this class breaks the binary serialization format. See comments for
43 // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
44 // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
45 // accordingly.
46 //==================================================================================================
47 public:
68 
69 
82 
90 
108 
109 
110 
112  : restitution(0)
113  , bounceThreshold(0)
114  , stiffness(0)
115  , damping(0)
116  , contactDistance(0)
117  {
118  }
119 
125  PX_INLINE bool isValid() const
126  {
127  return PxIsFinite(restitution) && restitution >= 0 && restitution <= 1 &&
128  PxIsFinite(stiffness) && stiffness >= 0 &&
129  PxIsFinite(damping) && damping >= 0 &&
130  PxIsFinite(bounceThreshold) && bounceThreshold >= 0 &&
131  PxIsFinite(contactDistance) && contactDistance >= 0;
132  }
133 
134  PX_INLINE bool isSoft() const
135  {
136  return damping>0 || stiffness>0;
137  }
138 
139 protected:
141 };
142 
143 
148 {
149 //= ATTENTION! =====================================================================================
150 // Changing the data layout of this class breaks the binary serialization format. See comments for
151 // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
152 // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
153 // accordingly.
154 //==================================================================================================
155 public:
163 
174  PxJointLinearLimit(const PxTolerancesScale& scale, PxReal extent, PxReal contactDist = -1)
175  : value(extent)
176  {
177  PxJointLimitParameters::contactDistance = contactDist == -1 ? 0.01f*scale.length : contactDist;
178  }
179 
180 
191  : value(extent)
192  {
193  stiffness = spring.stiffness;
194  damping = spring.damping;
195  }
196 
197 
198 
204  PX_INLINE bool isValid() const
205  {
207  PxIsFinite(value) &&
208  value > 0;
209  }
210 };
211 
212 
218 {
219 //= ATTENTION! =====================================================================================
220 // Changing the data layout of this class breaks the binary serialization format. See comments for
221 // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
222 // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
223 // accordingly.
224 //==================================================================================================
225 public:
234  PxReal upper, lower;
235 
236 
248  PxJointLinearLimitPair(const PxTolerancesScale& scale, PxReal lowerLimit, PxReal upperLimit, PxReal contactDist = -1)
249  : upper(upperLimit)
250  , lower(lowerLimit)
251  {
252  PxJointLimitParameters::contactDistance = contactDist == -1 ? PxMin(scale.length * 0.01f, (upperLimit*0.49f-lowerLimit*0.49f)) : contactDist;
253  bounceThreshold = 2*scale.length;
254  }
255 
256 
267  PxJointLinearLimitPair(PxReal lowerLimit, PxReal upperLimit, const PxSpring& spring)
268  : upper(upperLimit)
269  , lower(lowerLimit)
270  {
271  stiffness = spring.stiffness;
272  damping = spring.damping;
273  }
274 
275 
281  PX_INLINE bool isValid() const
282  {
284  PxIsFinite(upper) && PxIsFinite(lower) && upper >= lower &&
285  PxIsFinite(upper - lower) &&
286  PxIsFinite(contactDistance) && contactDistance <= upper - lower;
287  }
288 };
289 
290 
292 {
293 //= ATTENTION! =====================================================================================
294 // Changing the data layout of this class breaks the binary serialization format. See comments for
295 // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
296 // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
297 // accordingly.
298 //==================================================================================================
299 public:
307  PxReal upper, lower;
308 
309 
322  PxJointAngularLimitPair(PxReal lowerLimit, PxReal upperLimit, PxReal contactDist = -1)
323  : upper(upperLimit)
324  , lower(lowerLimit)
325  {
326  PxJointLimitParameters::contactDistance = contactDist ==-1 ? PxMin(0.1f, 0.49f*(upperLimit-lowerLimit)) : contactDist;
327  bounceThreshold = 0.5f;
328  }
329 
330 
343  PxJointAngularLimitPair(PxReal lowerLimit, PxReal upperLimit, const PxSpring& spring)
344  : upper(upperLimit)
345  , lower(lowerLimit)
346  {
347  stiffness = spring.stiffness;
348  damping = spring.damping;
349  }
350 
351 
357  PX_INLINE bool isValid() const
358  {
360  PxIsFinite(upper) && PxIsFinite(lower) && upper >= lower &&
361  PxIsFinite(contactDistance) && contactDistance <= upper - lower;
362  }
363 };
364 
365 
366 
375 {
376 //= ATTENTION! =====================================================================================
377 // Changing the data layout of this class breaks the binary serialization format. See comments for
378 // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
379 // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
380 // accordingly.
381 //==================================================================================================
382 public:
391 
392 
401 
412  PxJointLimitCone(PxReal yLimitAngle, PxReal zLimitAngle, PxReal contactDist = -1):
413  yAngle(yLimitAngle),
414  zAngle(zLimitAngle)
415  {
416  PxJointLimitParameters::contactDistance = contactDist == -1 ? PxMin(0.1f, PxMin(yLimitAngle, zLimitAngle)*0.49f) : contactDist;
417  bounceThreshold = 0.5f;
418  }
419 
420 
421 
432  PxJointLimitCone(PxReal yLimitAngle, PxReal zLimitAngle, const PxSpring& spring):
433  yAngle(yLimitAngle),
434  zAngle(zLimitAngle)
435  {
436  stiffness = spring.stiffness;
437  damping = spring.damping;
438  }
439 
440 
446  PX_INLINE bool isValid() const
447  {
449  PxIsFinite(yAngle) && yAngle>0 && yAngle<PxPi &&
450  PxIsFinite(zAngle) && zAngle>0 && zAngle<PxPi;
451  }
452 };
453 
454 #ifndef PX_DOXYGEN
455 } // namespace physx
456 #endif
457 
459 #endif


Copyright © 2008-2015 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com