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-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_PHYSICS_NX_CONSTRAINTDESC
00032 #define PX_PHYSICS_NX_CONSTRAINTDESC
00033 
00038 #include "PxPhysXConfig.h"
00039 #include "foundation/PxFlags.h"
00040 #include "foundation/PxVec3.h"
00041 #include "common/PxBase.h"
00042 
00043 #if !PX_DOXYGEN
00044 namespace physx { namespace pvdsdk {
00045 #endif
00046     class PvdDataStream;
00047 #if !PX_DOXYGEN
00048 }}
00049 #endif
00050 
00051 #if !PX_DOXYGEN
00052 namespace physx
00053 {
00054 #endif
00055 
00056 class PxConstraintConnector;
00057 class PxRigidActor;
00058 class PxScene;
00059 class PxConstraintConnector;
00060 class PxRenderBuffer;
00061 class PxDeletionListener;
00062 
00069 struct Px1DConstraintFlag
00070 {
00071     PX_CUDA_CALLABLE Px1DConstraintFlag(){}
00072 
00073     enum Type
00074     {
00075         eSPRING                     = 1<<0,     
00076         eACCELERATION_SPRING        = 1<<1,     
00077         eRESTITUTION                = 1<<2,     
00078         eKEEPBIAS                   = 1<<3,     
00079         eOUTPUT_FORCE               = 1<<4,     
00080         eHAS_DRIVE_LIMIT            = 1<<5      
00081     };
00082 };
00083 
00084 typedef PxFlags<Px1DConstraintFlag::Type, PxU16> Px1DConstraintFlags;
00085 PX_FLAGS_OPERATORS(Px1DConstraintFlag::Type, PxU16)
00086 
00087 
00091 struct PxConstraintSolveHint
00092 {
00093     enum Enum
00094     {
00095         eNONE               =   0,          
00096         eACCELERATION1      =   256,        
00097         eSLERP_SPRING       =   258,        
00098         eACCELERATION2      =   512,        
00099         eACCELERATION3      =   768,        
00100         eEQUALITY           =   1024,       
00101         eINEQUALITY         =   1025        
00102     };
00103 };
00104 
00141 PX_ALIGN_PREFIX(16)
00142 struct Px1DConstraint
00143 {
00144     PxVec3              linear0;                
00145     PxReal              geometricError;         
00146     PxVec3              angular0;               
00147     PxReal              velocityTarget;         
00148 
00149     PxVec3              linear1;                
00150     PxReal              minImpulse;             
00151     PxVec3              angular1;               
00152     PxReal              maxImpulse;             
00153 
00154     union
00155     {
00156         struct SpringModifiers
00157         {
00158             PxReal      stiffness;              
00159             PxReal      damping;                
00160         } spring;
00161         struct RestitutionModifiers
00162         {
00163             PxReal      restitution;            
00164             PxReal      velocityThreshold;      
00165         } bounce;
00166     } mods;
00167 
00168     PxReal              forInternalUse;         
00169     PxU16               flags;                  
00170     PxU16               solveHint;              
00171 } 
00172 PX_ALIGN_SUFFIX(16);
00173 
00174 
00180 struct PxConstraintVisualizationFlag
00181 {
00182     enum Enum
00183     {
00184         eLOCAL_FRAMES   = 1,    
00185         eLIMITS         = 2     
00186     };
00187 };
00188 
00189 PX_ALIGN_PREFIX(16)
00190 struct PxConstraintInvMassScale
00191 {
00192 //= ATTENTION! =====================================================================================
00193 // Changing the data layout of this class breaks the binary serialization format.  See comments for 
00194 // PX_BINARY_SERIAL_VERSION.  If a modification is required, please adjust the getBinaryMetaData 
00195 // function.  If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
00196 // accordingly.
00197 //==================================================================================================
00198 
00199     PxReal linear0;     
00200     PxReal angular0;    
00201     PxReal linear1;     
00202     PxReal angular1;    
00203 
00204     PxConstraintInvMassScale(){}
00205     PxConstraintInvMassScale(PxReal lin0, PxReal ang0, PxReal lin1, PxReal ang1) : linear0(lin0), angular0(ang0), linear1(lin1), angular1(ang1){}
00206 }
00207 PX_ALIGN_SUFFIX(16);
00208 
00227 typedef PxU32 (*PxConstraintSolverPrep)(Px1DConstraint* constraints,
00228                                         PxVec3& bodyAWorldOffset,
00229                                         PxU32 maxConstraints,
00230                                         PxConstraintInvMassScale& invMassScale,
00231                                         const void* constantBlock,
00232                                         const PxTransform& bodyAToWorld,
00233                                         const PxTransform& bodyBToWorld);
00234 
00246 typedef void (*PxConstraintProject)(const void* constantBlock,
00247                                     PxTransform& bodyAToWorld,
00248                                     PxTransform& bodyBToWorld,
00249                                     bool projectToA);
00250 
00254 class PxConstraintVisualizer
00255 {
00256 protected:
00257     virtual ~PxConstraintVisualizer(){}
00258 public:
00259     virtual void visualizeJointFrames( const PxTransform& parent, const PxTransform& child ) = 0;
00260 
00261     virtual void visualizeLinearLimit( const PxTransform& t0, const PxTransform& t1, PxReal value, bool active ) = 0;
00262 
00263     virtual void visualizeAngularLimit( const PxTransform& t0, PxReal lower, PxReal upper, bool active) = 0;
00264 
00265     virtual void visualizeLimitCone( const PxTransform& t, PxReal ySwing, PxReal zSwing, bool active) = 0;
00266 
00267     virtual void visualizeDoubleCone( const PxTransform& t, PxReal angle, bool active) = 0;
00268 };
00269 
00282 typedef void (*PxConstraintVisualize)( PxConstraintVisualizer& visualizer,
00283                                       const void* constantBlock,
00284                                       const PxTransform& body0Transform,
00285                                       const PxTransform& body1Transform,
00286                                       PxU32 flags );
00287 
00288 
00289 struct PxPvdUpdateType
00290 {
00291     enum Enum
00292     {
00293         CREATE_INSTANCE,
00294         RELEASE_INSTANCE,
00295         UPDATE_ALL_PROPERTIES,
00296         UPDATE_SIM_PROPERTIES
00297     };
00298 };
00299 
00310 class PxConstraintConnector
00311 {
00312 public:
00318     virtual void*           prepareData()                                                   = 0;
00319 
00324     virtual bool            updatePvdProperties(physx::pvdsdk::PvdDataStream& pvdConnection,
00325                                                 const PxConstraint* c,
00326                                                 PxPvdUpdateType::Enum updateType) const     = 0;
00327 
00340     virtual void            onConstraintRelease()                                           = 0;
00341 
00349     virtual void            onComShift(PxU32 actor)                                         = 0;
00350 
00363     virtual void            onOriginShift(const PxVec3& shift)                              = 0;
00364 
00377     virtual void*           getExternalReference(PxU32& typeID)                             = 0;
00378 
00379 
00386     virtual PxBase* getSerializable()                                               = 0;
00387 
00391     virtual PxConstraintSolverPrep getPrep() const                                  = 0;
00392 
00396     virtual const void* getConstantBlock() const                                    = 0;
00397 
00398 
00402     virtual ~PxConstraintConnector() {}
00403 };
00404 
00405 #if !PX_DOXYGEN
00406 } // namespace physx
00407 #endif
00408 
00410 #endif


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