NVIDIA(R) PhysX(R) SDK 3.4 API Reference: PxJointLimit.h Source File

NVIDIA PhysX SDK 3.4 API

PxJointLimit.h

Go to the documentation of this file.
00001 // This code contains NVIDIA Confidential Information and is disclosed to you
00002 // under a form of NVIDIA software license agreement provided separately to you.
00003 //
00004 // Notice
00005 // NVIDIA Corporation and its licensors retain all intellectual property and
00006 // proprietary rights in and to this software and related documentation and
00007 // any modifications thereto. Any use, reproduction, disclosure, or
00008 // distribution of this software and related documentation without an express
00009 // license agreement from NVIDIA Corporation is strictly prohibited.
00010 //
00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
00015 //
00016 // Information and code furnished is believed to be accurate and reliable.
00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
00018 // information or for any infringement of patents or other rights of third parties that may
00019 // result from its use. No license is granted by implication or otherwise under any patent
00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
00021 // This code supersedes and replaces all information previously supplied.
00022 // NVIDIA Corporation products are not authorized for use as critical
00023 // components in life support devices or systems without express written approval of
00024 // NVIDIA Corporation.
00025 //
00026 // Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
00027 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
00028 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.  
00029 
00030 
00031 #ifndef PX_EXTENSIONS_JOINT_LIMIT
00032 #define PX_EXTENSIONS_JOINT_LIMIT
00033 
00037 #include "foundation/PxMath.h"
00038 #include "PxPhysXConfig.h"
00039 #include "common/PxTolerancesScale.h"
00040 #include "PxJoint.h"
00041 
00042 #if !PX_DOXYGEN
00043 namespace physx
00044 {
00045 #endif
00046 
00055 class PxJointLimitParameters
00056 {
00057 //= ATTENTION! =====================================================================================
00058 // Changing the data layout of this class breaks the binary serialization format.  See comments for 
00059 // PX_BINARY_SERIAL_VERSION.  If a modification is required, please adjust the getBinaryMetaData 
00060 // function.  If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
00061 // accordingly.
00062 //==================================================================================================
00063 public:
00083     PxReal restitution;
00084 
00085 
00090     PxReal bounceThreshold;
00097     PxReal stiffness;
00098 
00105     PxReal damping;
00106 
00123     PxReal contactDistance;
00124 
00125 
00126 
00127     PxJointLimitParameters()
00128     : restitution(0)
00129     , bounceThreshold(0)
00130     , stiffness(0)
00131     , damping(0)
00132     , contactDistance(0)
00133     {
00134     }   
00135 
00141     PX_INLINE bool isValid() const
00142     {
00143         return  PxIsFinite(restitution) && restitution >= 0 && restitution <= 1 && 
00144                 PxIsFinite(stiffness) && stiffness >= 0 && 
00145                 PxIsFinite(damping) && damping >= 0 &&
00146                 PxIsFinite(bounceThreshold) && bounceThreshold >= 0 &&
00147                 PxIsFinite(contactDistance) && contactDistance >= 0;
00148     }
00149 
00150     PX_INLINE bool isSoft() const
00151     {
00152         return damping>0 || stiffness>0;
00153     }
00154 
00155 protected:
00156     ~PxJointLimitParameters() {}
00157 };
00158 
00159 
00163 class PxJointLinearLimit : public PxJointLimitParameters
00164 {
00165 //= ATTENTION! =====================================================================================
00166 // Changing the data layout of this class breaks the binary serialization format.  See comments for 
00167 // PX_BINARY_SERIAL_VERSION.  If a modification is required, please adjust the getBinaryMetaData 
00168 // function.  If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
00169 // accordingly.
00170 //==================================================================================================
00171 public:
00178     PxReal value;
00179 
00190     PxJointLinearLimit(const PxTolerancesScale& scale, PxReal extent, PxReal contactDist = -1)
00191     : value(extent)
00192     {
00193         PxJointLimitParameters::contactDistance = contactDist == -1 ? 0.01f*scale.length : contactDist; 
00194     }
00195 
00196 
00206     PxJointLinearLimit(PxReal extent, const PxSpring& spring)
00207     : value(extent)
00208     {
00209         stiffness = spring.stiffness;
00210         damping = spring.damping;
00211     }
00212 
00213 
00214 
00220     PX_INLINE bool isValid() const
00221     {
00222         return PxJointLimitParameters::isValid() &&
00223                PxIsFinite(value) && 
00224                value > 0;
00225     }
00226 };
00227 
00228 
00233 class PxJointLinearLimitPair : public PxJointLimitParameters
00234 {
00235 //= ATTENTION! =====================================================================================
00236 // Changing the data layout of this class breaks the binary serialization format.  See comments for 
00237 // PX_BINARY_SERIAL_VERSION.  If a modification is required, please adjust the getBinaryMetaData 
00238 // function.  If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
00239 // accordingly.
00240 //==================================================================================================
00241 public:
00250     PxReal upper, lower;
00251 
00252 
00264     PxJointLinearLimitPair(const PxTolerancesScale& scale, PxReal lowerLimit, PxReal upperLimit, PxReal contactDist = -1)
00265     : upper(upperLimit)
00266     , lower(lowerLimit)
00267     {
00268         PxJointLimitParameters::contactDistance = contactDist == -1 ? PxMin(scale.length * 0.01f, (upperLimit*0.49f-lowerLimit*0.49f)) : contactDist; 
00269         bounceThreshold = 2*scale.length;
00270     }
00271 
00272 
00283     PxJointLinearLimitPair(PxReal lowerLimit, PxReal upperLimit, const PxSpring& spring)
00284     : upper(upperLimit)
00285     , lower(lowerLimit)
00286     {
00287         stiffness = spring.stiffness;
00288         damping = spring.damping;
00289     }
00290 
00291 
00297     PX_INLINE bool isValid() const
00298     {
00299         return PxJointLimitParameters::isValid() &&
00300                PxIsFinite(upper) && PxIsFinite(lower) && upper >= lower &&
00301                PxIsFinite(upper - lower) && 
00302                PxIsFinite(contactDistance) && contactDistance <= upper - lower;
00303     }
00304 };
00305 
00306 
00307 class PxJointAngularLimitPair : public PxJointLimitParameters
00308 {
00309 //= ATTENTION! =====================================================================================
00310 // Changing the data layout of this class breaks the binary serialization format.  See comments for 
00311 // PX_BINARY_SERIAL_VERSION.  If a modification is required, please adjust the getBinaryMetaData 
00312 // function.  If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
00313 // accordingly.
00314 //==================================================================================================
00315 public:
00323     PxReal upper, lower;
00324 
00325 
00338     PxJointAngularLimitPair(PxReal lowerLimit, PxReal upperLimit, PxReal contactDist = -1)
00339     : upper(upperLimit)
00340     , lower(lowerLimit)
00341     {
00342         PxJointLimitParameters::contactDistance = contactDist ==-1 ? PxMin(0.1f, 0.49f*(upperLimit-lowerLimit)) : contactDist;
00343         bounceThreshold = 0.5f;
00344     }
00345 
00346 
00359     PxJointAngularLimitPair(PxReal lowerLimit, PxReal upperLimit, const PxSpring& spring)
00360     : upper(upperLimit)
00361     , lower(lowerLimit)
00362     {
00363         stiffness = spring.stiffness;
00364         damping = spring.damping;
00365     }
00366 
00367 
00373     PX_INLINE bool isValid() const
00374     {
00375         return PxJointLimitParameters::isValid() &&
00376                PxIsFinite(upper) && PxIsFinite(lower) && upper >= lower &&
00377                PxIsFinite(contactDistance) && contactDistance <= upper - lower;
00378     }
00379 };
00380 
00381 
00382 
00390 class PxJointLimitCone : public PxJointLimitParameters
00391 {
00392 //= ATTENTION! =====================================================================================
00393 // Changing the data layout of this class breaks the binary serialization format.  See comments for 
00394 // PX_BINARY_SERIAL_VERSION.  If a modification is required, please adjust the getBinaryMetaData 
00395 // function.  If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
00396 // accordingly.
00397 //==================================================================================================
00398 public:
00406     PxReal yAngle;
00407 
00408 
00416     PxReal zAngle;
00417 
00428     PxJointLimitCone(PxReal yLimitAngle, PxReal zLimitAngle, PxReal contactDist = -1):
00429       yAngle(yLimitAngle),
00430       zAngle(zLimitAngle)
00431       {
00432             PxJointLimitParameters::contactDistance = contactDist == -1 ? PxMin(0.1f, PxMin(yLimitAngle, zLimitAngle)*0.49f) : contactDist;
00433             bounceThreshold = 0.5f;
00434       }
00435 
00436 
00437     
00448       PxJointLimitCone(PxReal yLimitAngle, PxReal zLimitAngle, const PxSpring& spring):
00449       yAngle(yLimitAngle),
00450       zAngle(zLimitAngle)
00451       {
00452           stiffness = spring.stiffness;
00453           damping = spring.damping;
00454       }
00455 
00456 
00462     PX_INLINE bool isValid() const
00463     {
00464         return PxJointLimitParameters::isValid() &&
00465                PxIsFinite(yAngle) && yAngle>0 && yAngle<PxPi && 
00466                PxIsFinite(zAngle) && zAngle>0 && zAngle<PxPi;
00467     }
00468 };
00469 
00470 #if !PX_DOXYGEN
00471 } // namespace physx
00472 #endif
00473 
00475 #endif


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