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) { PX_UNUSED(i); return PXC_CONTACT_NO_FACE_INDEX; } 00146 00152 PX_FORCE_INLINE PxReal getMaxImpulse(PxU32 i) const { return mContacts[i].maxImpulse; } 00153 00161 PX_FORCE_INLINE void setMaxImpulse(PxU32 i, PxReal s) 00162 { 00163 PxContactPatch* patch = getPatch(); 00164 patch->internalFlags |= PxContactPatch::eHAS_MAX_IMPULSE; 00165 mContacts[i].maxImpulse = s; 00166 } 00167 00173 PX_FORCE_INLINE void ignore(PxU32 i) { mContacts[i].maxImpulse = 0.f; } 00174 00178 PX_FORCE_INLINE PxU32 size() const { return mCount; } 00179 00186 PX_FORCE_INLINE PxReal getInvMassScale0() const 00187 { 00188 PxContactPatch* patch = getPatch(); 00189 return patch->mMassModification.mInvMassScale0; 00190 } 00191 00198 PX_FORCE_INLINE PxReal getInvMassScale1() const 00199 { 00200 PxContactPatch* patch = getPatch(); 00201 return patch->mMassModification.mInvMassScale1; 00202 } 00203 00210 PX_FORCE_INLINE PxReal getInvInertiaScale0() const 00211 { 00212 PxContactPatch* patch = getPatch(); 00213 return patch->mMassModification.mInvInertiaScale0; 00214 } 00215 00222 PX_FORCE_INLINE PxReal getInvInertiaScale1() const 00223 { 00224 PxContactPatch* patch = getPatch(); 00225 return patch->mMassModification.mInvInertiaScale1; 00226 } 00227 00234 PX_FORCE_INLINE void setInvMassScale0(const PxReal scale) 00235 { 00236 PxContactPatch* patch = getPatch(); 00237 patch->mMassModification.mInvMassScale0 = scale; 00238 patch->internalFlags |= PxContactPatch::eHAS_MODIFIED_MASS_RATIOS; 00239 } 00240 00247 PX_FORCE_INLINE void setInvMassScale1(const PxReal scale) 00248 { 00249 PxContactPatch* patch = getPatch(); 00250 patch->mMassModification.mInvMassScale1 = scale; 00251 patch->internalFlags |= PxContactPatch::eHAS_MODIFIED_MASS_RATIOS; 00252 } 00253 00260 PX_FORCE_INLINE void setInvInertiaScale0(const PxReal scale) 00261 { 00262 PxContactPatch* patch = getPatch(); 00263 patch->mMassModification.mInvInertiaScale0 = scale; 00264 patch->internalFlags |= PxContactPatch::eHAS_MODIFIED_MASS_RATIOS; 00265 } 00266 00273 PX_FORCE_INLINE void setInvInertiaScale1(const PxReal scale) 00274 { 00275 PxContactPatch* patch = getPatch(); 00276 patch->mMassModification.mInvInertiaScale1 = scale; 00277 patch->internalFlags |= PxContactPatch::eHAS_MODIFIED_MASS_RATIOS; 00278 } 00279 00280 protected: 00281 00282 PX_FORCE_INLINE PxContactPatch* getPatch() const 00283 { 00284 const size_t headerOffset = sizeof(PxContactPatch)*mCount; 00285 return reinterpret_cast<PxContactPatch*>(reinterpret_cast<PxU8*>(mContacts) - headerOffset); 00286 } 00287 00288 PxU32 mCount; 00289 PxModifiableContact* mContacts; 00290 }; 00291 00292 00293 00300 class PxContactModifyPair 00301 { 00302 public: 00303 00310 const PxRigidActor* actor[2]; 00317 const PxShape* shape[2]; 00318 00327 PxTransform transform[2]; 00328 00333 PxContactSet contacts; 00334 }; 00335 00336 00355 class PxContactModifyCallback 00356 { 00357 public: 00358 00369 virtual void onContactModify(PxContactModifyPair* const pairs, PxU32 count) = 0; 00370 00371 protected: 00372 virtual ~PxContactModifyCallback(){} 00373 }; 00374 00393 class PxCCDContactModifyCallback 00394 { 00395 public: 00396 00407 virtual void onCCDContactModify(PxContactModifyPair* const pairs, PxU32 count) = 0; 00408 00409 protected: 00410 virtual ~PxCCDContactModifyCallback(){} 00411 }; 00412 00413 00414 #if !PX_DOXYGEN 00415 } // namespace physx 00416 #endif 00417 00419 #endif