PxConstraintDesc.h

Go to the documentation of this file.
00001 //
00002 // Redistribution and use in source and binary forms, with or without
00003 // modification, are permitted provided that the following conditions
00004 // are met:
00005 //  * Redistributions of source code must retain the above copyright
00006 //    notice, this list of conditions and the following disclaimer.
00007 //  * Redistributions in binary form must reproduce the above copyright
00008 //    notice, this list of conditions and the following disclaimer in the
00009 //    documentation and/or other materials provided with the distribution.
00010 //  * Neither the name of NVIDIA CORPORATION nor the names of its
00011 //    contributors may be used to endorse or promote products derived
00012 //    from this software without specific prior written permission.
00013 //
00014 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
00015 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00017 // PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00018 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00019 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00020 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00021 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00022 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00023 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00024 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 
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     virtual void visualizeLine(const PxVec3& p0, const PxVec3& p1, PxU32 color) = 0;
00270 };
00271 
00284 typedef void (*PxConstraintVisualize)( PxConstraintVisualizer& visualizer,
00285                                       const void* constantBlock,
00286                                       const PxTransform& body0Transform,
00287                                       const PxTransform& body1Transform,
00288                                       PxU32 flags );
00289 
00290 
00291 struct PxPvdUpdateType
00292 {
00293     enum Enum
00294     {
00295         CREATE_INSTANCE,
00296         RELEASE_INSTANCE,
00297         UPDATE_ALL_PROPERTIES,
00298         UPDATE_SIM_PROPERTIES
00299     };
00300 };
00301 
00312 class PxConstraintConnector
00313 {
00314 public:
00320     virtual void*           prepareData()                                                   = 0;
00321 
00326     virtual bool            updatePvdProperties(physx::pvdsdk::PvdDataStream& pvdConnection,
00327                                                 const PxConstraint* c,
00328                                                 PxPvdUpdateType::Enum updateType) const     = 0;
00329 
00342     virtual void            onConstraintRelease()                                           = 0;
00343 
00351     virtual void            onComShift(PxU32 actor)                                         = 0;
00352 
00365     virtual void            onOriginShift(const PxVec3& shift)                              = 0;
00366 
00379     virtual void*           getExternalReference(PxU32& typeID)                             = 0;
00380 
00381 
00388     virtual PxBase* getSerializable()                                               = 0;
00389 
00393     virtual PxConstraintSolverPrep getPrep() const                                  = 0;
00394 
00398     virtual const void* getConstantBlock() const                                    = 0;
00399 
00400 
00404     virtual ~PxConstraintConnector() {}
00405 };
00406 
00407 #if !PX_DOXYGEN
00408 } // namespace physx
00409 #endif
00410 
00412 #endif


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