PxSolverDefs.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-2018 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 #ifndef PX_SOLVER_DEFS_H
00031 #define PX_SOLVER_DEFS_H
00032 
00033 
00034 #include "PxPhysXConfig.h"
00035 #include "foundation/PxVec3.h"
00036 #include "foundation/PxMat33.h"
00037 #include "foundation/PxTransform.h"
00038 #include "PxConstraintDesc.h"
00039 #include "geomutils/GuContactPoint.h"
00040 
00041 #if PX_VC
00042 #pragma warning(push)
00043 #pragma warning(disable : 4324) // structure was padded due to alignment
00044 #endif
00045 
00046 #if !PX_DOXYGEN
00047 namespace physx
00048 {
00049 #endif
00050 
00051 namespace Dy
00052 {
00053     //struct FsData;
00054     class ArticulationV;
00055 }
00056 
00057 namespace Sc
00058 {
00059     class ShapeInteraction;
00060 }
00061 
00062 struct PxSolverBody
00063 {
00064     PX_ALIGN(16, PxVec3) linearVelocity;                    
00065     PxU16               maxSolverNormalProgress;        
00066     PxU16               maxSolverFrictionProgress;      
00067 
00068     PxVec3              angularState;                   
00069 
00070     PxU32               solverProgress;                 
00071 
00072     PxSolverBody() : linearVelocity(0.f), maxSolverNormalProgress(0), maxSolverFrictionProgress(0), angularState(0), solverProgress(0)
00073     {
00074     }
00075 };
00076 
00077 PX_COMPILE_TIME_ASSERT(sizeof(PxSolverBody) == 32);
00078 
00079 struct PxSolverBodyData
00080 {
00081     PX_ALIGN(16, PxVec3 linearVelocity);    
00082     PxReal          invMass;                
00083     PxVec3          angularVelocity;        
00084     PxReal          reportThreshold;        
00085     PxMat33         sqrtInvInertia;         
00086     PxReal          penBiasClamp;           
00087     PxU32           nodeIndex;              
00088     PxReal          maxContactImpulse;      
00089     PxTransform     body2World;             
00090     PxU16           lockFlags;              
00091     PxU16           hasSurfaceVelocity;     
00092 
00093     PX_FORCE_INLINE PxReal projectVelocity(const PxVec3& lin, const PxVec3& ang)    const
00094     {
00095         return linearVelocity.dot(lin) + angularVelocity.dot(ang);
00096     }
00097 };
00098 
00099 //----------------------------------
00100 /*
00101 * A header that defines the size of a specific batch of constraints (of same type and without dependencies)
00102 */
00103 struct PxConstraintBatchHeader
00104 {
00105     PxU32 mStartIndex;          
00106     PxU16 mStride;              
00107     PxU16 mConstraintType;      
00108 };
00109 
00110 
00111 struct PxSolverConstraintDesc
00112 {
00113     static const PxU16 NO_LINK = 0xffff;
00114 
00115     enum ConstraintType
00116     {
00117         eCONTACT_CONSTRAINT,                
00118         eJOINT_CONSTRAINT                   
00119     };
00120 
00121     union
00122     {
00123         PxSolverBody*               bodyA;          
00124         Dy::ArticulationV*          articulationA;  
00125     };
00126 
00127     union
00128     {
00129         PxSolverBody*               bodyB;          
00130         Dy::ArticulationV*          articulationB;  
00131     };
00132     PxU16               linkIndexA;         
00133     PxU16               linkIndexB;         
00134     union
00135     {
00136         PxU16               articulationALength;    
00137         PxU32               bodyADataIndex;         
00138     };
00139 
00140     union
00141     {
00142         PxU16               articulationBLength;    
00143         PxU32               bodyBDataIndex;         
00144     };
00145 
00146     PxU16                   writeBackLengthOver4;   
00147     PxU16                   constraintLengthOver16; 
00148 
00149     PxU8*                   constraint;             
00150     void*                   writeBack;              
00151 };
00152 
00153 struct PxSolverConstraintPrepDescBase
00154 {
00155     enum BodyState
00156     {
00157         eDYNAMIC_BODY = 1 << 0,
00158         eSTATIC_BODY = 1 << 1,
00159         eKINEMATIC_BODY = 1 << 2,
00160         eARTICULATION = 1 << 3
00161     };
00162 
00163     PxConstraintInvMassScale mInvMassScales;    
00164 
00165     PxSolverConstraintDesc* desc;               
00166 
00167     const PxSolverBody* body0;                  
00168     const PxSolverBody* body1;                  
00169 
00170     const PxSolverBodyData* data0;              
00171     const PxSolverBodyData* data1;              
00172 
00173     PxTransform bodyFrame0;                     
00174     PxTransform bodyFrame1;                     
00175 
00176     BodyState bodyState0;                       
00177     BodyState bodyState1;                       
00178 
00179 };
00180 
00181 struct PxSolverConstraintPrepDesc : public PxSolverConstraintPrepDescBase
00182 {
00183     PX_ALIGN(16, Px1DConstraint* rows);         
00184     PxU32 numRows;                              
00185 
00186     PxReal linBreakForce, angBreakForce;        
00187     PxReal minResponseThreshold;                
00188     void* writeback;                            
00189     bool disablePreprocessing;                  
00190     bool improvedSlerp;                         
00191     bool driveLimitsAreForces;                  
00192     bool extendedLimits;                        
00193 
00194     PxVec3 body0WorldOffset;                    
00195 };
00196 
00197 
00198 struct PxSolverContactDesc : public PxSolverConstraintPrepDescBase
00199 {
00200 
00201     PX_ALIGN(16, Sc::ShapeInteraction* shapeInteraction); 
00202     Gu::ContactPoint* contacts;             
00203     PxU32 numContacts;                      
00204 
00205     bool hasMaxImpulse;                     
00206     bool disableStrongFriction;             
00207     bool hasForceThresholds;                
00208 
00209     PxReal restDistance;                    
00210     PxReal maxCCDSeparation;                
00211 
00212     PxU8* frictionPtr;                      
00213     PxU8 frictionCount;                     
00214 
00215     PxReal* contactForces;                  
00216 
00217     PxU32 startFrictionPatchIndex;          
00218     PxU32 numFrictionPatches;               
00219 
00220     PxU32 startContactPatchIndex;           
00221     PxU16 numContactPatches;                
00222     PxU16 axisConstraintCount;              
00223 
00224     PxU8 pad[16 - sizeof(void*)];
00225 };
00226 
00227 class PxConstraintAllocator
00228 {
00229 public:
00235     virtual PxU8* reserveConstraintData(const PxU32 byteSize) = 0;
00242     virtual PxU8* reserveFrictionData(const PxU32 byteSize) = 0;
00243 
00244     virtual ~PxConstraintAllocator() {}
00245 };
00246 
00247 #if !PX_DOXYGEN
00248 }
00249 #endif
00250 
00251 #if PX_VC
00252 #pragma warning(pop)
00253 #endif
00254 
00255 #endif
00256 


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