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

NVIDIA PhysX SDK 3.4 API

PxContactModifyCallback.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_CONTACT_MODIFY_CALLBACK
00032 #define PX_CONTACT_MODIFY_CALLBACK
00033 
00037 #include "PxPhysXConfig.h"
00038 #include "PxShape.h"
00039 #include "PxContact.h"
00040 #include "foundation/PxTransform.h"
00041 
00042 #if !PX_DOXYGEN
00043 namespace physx
00044 {
00045 #endif
00046 
00047 class PxShape;
00048 
00061 class PxContactSet
00062 {
00063 public:
00069     PX_FORCE_INLINE     const PxVec3& getPoint(PxU32 i) const           { return mContacts[i].contact;      }
00070 
00076     PX_FORCE_INLINE     void setPoint(PxU32 i, const PxVec3& p)         { mContacts[i].contact = p; }
00077 
00083     PX_FORCE_INLINE     const PxVec3& getNormal(PxU32 i) const          { return mContacts[i].normal;   }
00084 
00092     PX_FORCE_INLINE     void setNormal(PxU32 i, const PxVec3& n)        
00093     { 
00094         PxContactPatch* patch = getPatch();
00095         patch->internalFlags |= PxContactPatch::eREGENERATE_PATCHES;
00096         mContacts[i].normal = n;
00097     }
00098 
00104     PX_FORCE_INLINE     PxReal getSeparation(PxU32 i) const             { return mContacts[i].separation;   }
00105 
00111     PX_FORCE_INLINE     void setSeparation(PxU32 i, PxReal s)           { mContacts[i].separation = s; }
00112 
00119     PX_FORCE_INLINE     const PxVec3& getTargetVelocity(PxU32 i) const  { return mContacts[i].targetVelocity;   }
00120 
00126     PX_FORCE_INLINE     void setTargetVelocity(PxU32 i, const PxVec3& v)
00127     { 
00128         PxContactPatch* patch = getPatch();
00129         patch->internalFlags |= PxContactPatch::eHAS_TARGET_VELOCITY;
00130         mContacts[i].targetVelocity = v;
00131     }
00132 
00138     PX_FORCE_INLINE     PxU32 getInternalFaceIndex0(PxU32 i)            { PX_UNUSED(i); return PXC_CONTACT_NO_FACE_INDEX; }
00139 
00145     PX_FORCE_INLINE     PxU32 getInternalFaceIndex1(PxU32 i)            
00146     {
00147         PxContactPatch* patch = getPatch();
00148         if (patch->internalFlags & PxContactPatch::eHAS_FACE_INDICES)
00149         {
00150             return reinterpret_cast<PxU32*>(mContacts + mCount)[mCount + i];
00151         }
00152         return PXC_CONTACT_NO_FACE_INDEX;
00153     }
00154 
00160     PX_FORCE_INLINE     PxReal getMaxImpulse(PxU32 i) const             { return mContacts[i].maxImpulse;   }
00161 
00169     PX_FORCE_INLINE     void setMaxImpulse(PxU32 i, PxReal s)           
00170     {
00171         PxContactPatch* patch = getPatch();
00172         patch->internalFlags |= PxContactPatch::eHAS_MAX_IMPULSE;
00173         mContacts[i].maxImpulse = s; 
00174     }
00175 
00181     PX_FORCE_INLINE     PxReal getRestitution(PxU32 i) const            { return mContacts[i].restitution; }
00182 
00190     PX_FORCE_INLINE     void setRestitution(PxU32 i, PxReal r)      
00191     {
00192         PxContactPatch* patch = getPatch();
00193         patch->internalFlags |= PxContactPatch::eREGENERATE_PATCHES;
00194         mContacts[i].restitution = r; 
00195     }
00196 
00202     PX_FORCE_INLINE     PxReal getStaticFriction(PxU32 i) const { return mContacts[i].staticFriction; }
00203 
00209     PX_FORCE_INLINE     void setStaticFriction(PxU32 i, PxReal f) 
00210     { 
00211         PxContactPatch* patch = getPatch();
00212         patch->internalFlags |= PxContactPatch::eREGENERATE_PATCHES;
00213         mContacts[i].staticFriction = f; 
00214     }
00215 
00221     PX_FORCE_INLINE     PxReal getDynamicFriction(PxU32 i) const { return mContacts[i].dynamicFriction; }
00222 
00228     PX_FORCE_INLINE     void setDynamicFriction(PxU32 i, PxReal f) 
00229     {
00230         PxContactPatch* patch = getPatch();
00231         patch->internalFlags |= PxContactPatch::eREGENERATE_PATCHES; 
00232         mContacts[i].dynamicFriction = f; 
00233     }
00234 
00240     PX_FORCE_INLINE     void ignore(PxU32 i)                            { mContacts[i].maxImpulse = 0.f; }
00241 
00245     PX_FORCE_INLINE     PxU32 size() const                              { return mCount; }
00246 
00253     PX_FORCE_INLINE     PxReal getInvMassScale0() const                 
00254     { 
00255         PxContactPatch* patch = getPatch();
00256         return patch->mMassModification.mInvMassScale0;
00257     }
00258 
00265     PX_FORCE_INLINE     PxReal getInvMassScale1() const                 
00266     { 
00267         PxContactPatch* patch = getPatch();
00268         return patch->mMassModification.mInvMassScale1;
00269     }
00270 
00277     PX_FORCE_INLINE     PxReal getInvInertiaScale0() const                  
00278     { 
00279         PxContactPatch* patch = getPatch();
00280         return patch->mMassModification.mInvInertiaScale0;
00281     }
00282 
00289     PX_FORCE_INLINE     PxReal getInvInertiaScale1() const                  
00290     { 
00291         PxContactPatch* patch = getPatch();
00292         return patch->mMassModification.mInvInertiaScale1;
00293     }
00294 
00301     PX_FORCE_INLINE     void setInvMassScale0(const PxReal scale)                   
00302     { 
00303         PxContactPatch* patch = getPatch();
00304         patch->mMassModification.mInvMassScale0 = scale;
00305         patch->internalFlags |= PxContactPatch::eHAS_MODIFIED_MASS_RATIOS;
00306     }
00307 
00314     PX_FORCE_INLINE     void setInvMassScale1(const PxReal scale)                   
00315     { 
00316         PxContactPatch* patch = getPatch();
00317         patch->mMassModification.mInvMassScale1 = scale;
00318         patch->internalFlags |= PxContactPatch::eHAS_MODIFIED_MASS_RATIOS;
00319     }
00320 
00327     PX_FORCE_INLINE     void setInvInertiaScale0(const PxReal scale)                    
00328     { 
00329         PxContactPatch* patch = getPatch();
00330         patch->mMassModification.mInvInertiaScale0 = scale;
00331         patch->internalFlags |= PxContactPatch::eHAS_MODIFIED_MASS_RATIOS;
00332     }
00333 
00340     PX_FORCE_INLINE     void setInvInertiaScale1(const PxReal scale)                    
00341     { 
00342         PxContactPatch* patch = getPatch();
00343         patch->mMassModification.mInvInertiaScale1 = scale;
00344         patch->internalFlags |= PxContactPatch::eHAS_MODIFIED_MASS_RATIOS;
00345     }
00346 
00347 protected:
00348 
00349     PX_FORCE_INLINE PxContactPatch* getPatch() const
00350     {
00351         const size_t headerOffset = sizeof(PxContactPatch)*mCount;
00352         return reinterpret_cast<PxContactPatch*>(reinterpret_cast<PxU8*>(mContacts) - headerOffset);
00353     }
00354 
00355     PxU32                   mCount;         
00356     PxModifiableContact*    mContacts;      
00357 };
00358 
00359 
00360 
00367 class PxContactModifyPair
00368 {
00369 public:
00370 
00377     const PxRigidActor*     actor[2];
00384     const PxShape*          shape[2];
00385 
00394     PxTransform             transform[2];
00395 
00400     PxContactSet            contacts;
00401 };
00402 
00403 
00422 class PxContactModifyCallback
00423 {
00424 public:
00425 
00436     virtual void onContactModify(PxContactModifyPair* const pairs, PxU32 count) = 0;
00437 
00438 protected:
00439     virtual ~PxContactModifyCallback(){}
00440 };
00441 
00460 class PxCCDContactModifyCallback
00461 {
00462 public:
00463 
00474     virtual void onCCDContactModify(PxContactModifyPair* const pairs, PxU32 count) = 0;
00475 
00476 protected:
00477     virtual ~PxCCDContactModifyCallback(){}
00478 };
00479 
00480 
00481 #if !PX_DOXYGEN
00482 } // namespace physx
00483 #endif
00484 
00486 #endif


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