PhysX SDK 3.2 API Reference: PxConstraintDesc.h Source File

PhysX SDK 3.2 API

PxConstraintDesc.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-2012 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_PHYSICS_NX_CONSTRAINTDESC
00032 #define PX_PHYSICS_NX_CONSTRAINTDESC
00033 
00038 #include "PxPhysX.h"
00039 #include "foundation/PxFlags.h"
00040 #include "foundation/PxMath.h"
00041 #include "foundation/PxVec3.h"
00042 #include "common/PxSerialFramework.h"
00043 
00044 namespace physx { namespace debugger { namespace comm {
00045     class PvdDataStream;
00046 }}}
00047 
00048 #ifndef PX_DOXYGEN
00049 namespace physx
00050 {
00051 #endif
00052 
00053 class PxConstraintConnector;
00054 class PxRigidActor;
00055 class PxScene;
00056 class PxConstraintConnector;
00057 class PxRenderBuffer;
00058 
00065 struct PxConstraintFlag
00066 {
00067     enum Type
00068     {
00069         eBROKEN                 = 1<<0,         //< whether the constraint is broken
00070         ePROJECTION             = 1<<1,         //< whether projection is enabled for this constraint
00071         eCOLLISION_ENABLED      = 1<<2,         //< whether contacts should be generated between the objects this constraint constrains
00072         eREPORTING              = 1<<3,         //< whether this constraint should generate force reports
00073         eVISUALIZATION          = 1<<4,         //< whether this constraint should be visualized, if constraint visualization is turned on
00074     };
00075 };
00076 
00082 typedef PxFlags<PxConstraintFlag::Type, PxU16> PxConstraintFlags;
00083 PX_FLAGS_OPERATORS(PxConstraintFlag::Type, PxU16);
00084 
00085 
00092 struct Px1DConstraintFlag
00093 {
00094     enum Type
00095     {
00096         eSPRING                 = 1<<0,     //< whether the constraint is a spring
00097         eACCELERATION_SPRING    = 1<<1,     //< whether the constraint is a force or acceleration spring
00098         eRESTITUTION            = 1<<2,     //< whether the restitution model should be applied to generate the target velocity
00099         eKEEPBIAS               = 1<<3,     //< for hard constraints, whether to keep the error term when solving the error-free velocity equation
00100         eOUTPUT_FORCE           = 1<<4      //< whether to accumulate the force value from this constraint for the reported constraint force.
00101     };
00102 };
00103 
00104 typedef PxFlags<Px1DConstraintFlag::Type, PxU16> Px1DConstraintFlags;
00105 PX_FLAGS_OPERATORS(Px1DConstraintFlag::Type, PxU16);
00106 
00128 PX_ALIGN_PREFIX(16)
00129 struct Px1DConstraint
00130 {
00131     PxVec3              linear0;                //< linear component of velocity jacobian in world space
00132     PxReal              geometricError;         //< geometric error of the constraint along this axis
00133     PxVec3              angular0;               //< angular component of velocity jacobian in world space
00134     PxReal              velocityTarget;         //< velocity target for the constraint along this axis
00135 
00136     PxVec3              linear1;                //< linear component of velocity jacobian in world space
00137     PxReal              minImpulse;             //< minimum impulse the solver may apply to enforce this constraint
00138     PxVec3              angular1;               //< angular component of velocity jacobian in world space
00139     PxReal              maxImpulse;             //< maximum impulse the solver may apply to enforce this constraint
00140 
00141     PxReal              spring;                 //< spring parameter, for spring constraints
00142     PxReal              damping;                //< damping parameter, for spring constraints
00143 
00144     PxReal              restitution;            //< restitution parameter for determining additional "bounce"
00145 
00146     Px1DConstraintFlags flags;                  //< a set of Px1DConstraintFlags
00147     PxU16               solveGroup;             //< constraint optimization hint: make this 256 for hard constraints with unbounded force limits, 257 for hard unilateral constraints with [0, inf) force limits, and 0 otherwise
00148 } 
00149 PX_ALIGN_SUFFIX(16);
00150 
00151 
00155 struct PxConstraintVisualizationFlag
00156 {
00157     enum Enum
00158     {
00159         eLOCAL_FRAMES   = 1,    //< visualize constraint frames
00160         eLIMITS         = 2     //< visualize constraint limits
00161     };
00162 };
00163 
00164 
00183 typedef PxU32 (*PxConstraintSolverPrep)(Px1DConstraint* constraints,
00184                                         PxVec3& body0WorldOffset,
00185                                         PxU32 maxConstraints,
00186                                         const void* constantBlock,
00187                                         const PxTransform& bodyAToWorld,
00188                                         const PxTransform& bodyBToWorld);
00189 
00201 typedef void (*PxConstraintProject)(const void* constantBlock,
00202                                     PxTransform& bodyAToWorld,
00203                                     PxTransform& bodyBToWorld,
00204                                     bool projectToA);
00205 
00209 class PxConstraintVisualizer
00210 {
00211 protected:
00212     virtual ~PxConstraintVisualizer(){}
00213 public:
00214     virtual void visualizeJointFrames( const PxTransform& parent, const PxTransform& child ) = 0;
00215 
00216     virtual void visualizeLinearLimit( const PxTransform& t0, const PxTransform& t1, PxReal value, bool active ) = 0;
00217 
00218     virtual void visualizeAngularLimit( const PxTransform& t0, PxReal lower, PxReal upper, bool active) = 0;
00219 
00220     virtual void visualizeLimitCone( const PxTransform& t, PxReal ySwing, PxReal zSwing, bool active) = 0;
00221 
00222     virtual void visualizeDoubleCone( const PxTransform& t, PxReal angle, bool active) = 0;
00223 };
00224 
00239 typedef void (*PxConstraintVisualize)( PxConstraintVisualizer& visualizer,
00240                                       const void* constantBlock,
00241                                       const PxTransform& body0Transform,
00242                                       const PxTransform& body1Transform,
00243                                       PxU32 flags );
00244 
00245 
00246 struct PxPvdUpdateType
00247 {
00248     enum Enum
00249     {
00250         CREATE_INSTANCE,
00251         RELEASE_INSTANCE,
00252         UPDATE_ALL_PROPERTIES,
00253         UPDATE_SIM_PROPERTIES,
00254     };
00255 };
00256 
00267 class PxConstraintConnector
00268 {
00269 public:
00275     virtual void*           prepareData()                                                   = 0;
00276 
00281     virtual bool            updatePvdProperties(physx::debugger::comm::PvdDataStream& pvdConnection,
00282                                                 const PxConstraint* c,
00283                                                 PxPvdUpdateType::Enum updateType) const     = 0;
00284 
00296     virtual void            onConstraintRelease()                                           = 0;
00297 
00305     virtual void            onComShift(PxU32 actor)                                         = 0;
00306 
00319     virtual void*           getExternalReference(PxU32& typeID)                             = 0;
00320 
00324     virtual ~PxConstraintConnector() {};
00325 };
00326 
00327 #ifndef PX_DOXYGEN
00328 } // namespace physx
00329 #endif
00330 
00332 #endif


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