PxContactModifyCallback.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_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-2018 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com