PxContactModifyCallback.h
Go to the documentation of this file.
1 //
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions
4 // are met:
5 // * Redistributions of source code must retain the above copyright
6 // notice, this list of conditions and the following disclaimer.
7 // * Redistributions in binary form must reproduce the above copyright
8 // notice, this list of conditions and the following disclaimer in the
9 // documentation and/or other materials provided with the distribution.
10 // * Neither the name of NVIDIA CORPORATION nor the names of its
11 // contributors may be used to endorse or promote products derived
12 // from this software without specific prior written permission.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
15 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 //
26 // Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
27 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
28 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
29 
30 
31 #ifndef PX_CONTACT_MODIFY_CALLBACK
32 #define PX_CONTACT_MODIFY_CALLBACK
33 
37 #include "PxPhysXConfig.h"
38 #include "PxShape.h"
39 #include "PxContact.h"
40 #include "foundation/PxTransform.h"
41 
42 #if !PX_DOXYGEN
43 namespace physx
44 {
45 #endif
46 
47 class PxShape;
48 
62 {
63 public:
69  PX_FORCE_INLINE const PxVec3& getPoint(PxU32 i) const { return mContacts[i].contact; }
70 
76  PX_FORCE_INLINE void setPoint(PxU32 i, const PxVec3& p) { mContacts[i].contact = p; }
77 
83  PX_FORCE_INLINE const PxVec3& getNormal(PxU32 i) const { return mContacts[i].normal; }
84 
93  {
94  PxContactPatch* patch = getPatch();
96  mContacts[i].normal = n;
97  }
98 
104  PX_FORCE_INLINE PxReal getSeparation(PxU32 i) const { return mContacts[i].separation; }
105 
111  PX_FORCE_INLINE void setSeparation(PxU32 i, PxReal s) { mContacts[i].separation = s; }
112 
119  PX_FORCE_INLINE const PxVec3& getTargetVelocity(PxU32 i) const { return mContacts[i].targetVelocity; }
120 
127  {
128  PxContactPatch* patch = getPatch();
130  mContacts[i].targetVelocity = v;
131  }
132 
139 
146  {
147  PxContactPatch* patch = getPatch();
149  {
150  return reinterpret_cast<PxU32*>(mContacts + mCount)[mCount + i];
151  }
153  }
154 
160  PX_FORCE_INLINE PxReal getMaxImpulse(PxU32 i) const { return mContacts[i].maxImpulse; }
161 
170  {
171  PxContactPatch* patch = getPatch();
173  mContacts[i].maxImpulse = s;
174  }
175 
181  PX_FORCE_INLINE PxReal getRestitution(PxU32 i) const { return mContacts[i].restitution; }
182 
191  {
192  PxContactPatch* patch = getPatch();
194  mContacts[i].restitution = r;
195  }
196 
202  PX_FORCE_INLINE PxReal getStaticFriction(PxU32 i) const { return mContacts[i].staticFriction; }
203 
210  {
211  PxContactPatch* patch = getPatch();
213  mContacts[i].staticFriction = f;
214  }
215 
221  PX_FORCE_INLINE PxReal getDynamicFriction(PxU32 i) const { return mContacts[i].dynamicFriction; }
222 
229  {
230  PxContactPatch* patch = getPatch();
232  mContacts[i].dynamicFriction = f;
233  }
234 
240  PX_FORCE_INLINE void ignore(PxU32 i) { setMaxImpulse(i, 0.0f); }
241 
245  PX_FORCE_INLINE PxU32 size() const { return mCount; }
246 
254  {
255  PxContactPatch* patch = getPatch();
256  return patch->mMassModification.mInvMassScale0;
257  }
258 
266  {
267  PxContactPatch* patch = getPatch();
268  return patch->mMassModification.mInvMassScale1;
269  }
270 
278  {
279  PxContactPatch* patch = getPatch();
280  return patch->mMassModification.mInvInertiaScale0;
281  }
282 
290  {
291  PxContactPatch* patch = getPatch();
292  return patch->mMassModification.mInvInertiaScale1;
293  }
294 
302  {
303  PxContactPatch* patch = getPatch();
304  patch->mMassModification.mInvMassScale0 = scale;
306  }
307 
315  {
316  PxContactPatch* patch = getPatch();
317  patch->mMassModification.mInvMassScale1 = scale;
319  }
320 
328  {
329  PxContactPatch* patch = getPatch();
330  patch->mMassModification.mInvInertiaScale0 = scale;
332  }
333 
341  {
342  PxContactPatch* patch = getPatch();
343  patch->mMassModification.mInvInertiaScale1 = scale;
345  }
346 
347 protected:
348 
350  {
351  const size_t headerOffset = sizeof(PxContactPatch)*mCount;
352  return reinterpret_cast<PxContactPatch*>(reinterpret_cast<PxU8*>(mContacts) - headerOffset);
353  }
354 
357 };
358 
359 
360 
368 {
369 public:
370 
377  const PxRigidActor* actor[2];
384  const PxShape* shape[2];
385 
394  PxTransform transform[2];
395 
401 };
402 
403 
423 {
424 public:
425 
436  virtual void onContactModify(PxContactModifyPair* const pairs, PxU32 count) = 0;
437 
438 protected:
440 };
441 
461 {
462 public:
463 
474  virtual void onCCDContactModify(PxContactModifyPair* const pairs, PxU32 count) = 0;
475 
476 protected:
478 };
479 
480 
481 #if !PX_DOXYGEN
482 } // namespace physx
483 #endif
484 
486 #endif
Definition: GuContactBuffer.h:37
This is required if the application modified either the contact normal or the material properties...
Definition: PxContact.h:74
PX_FORCE_INLINE void setDynamicFriction(PxU32 i, PxReal f)
Alter the static dynamic coefficient for a specific contact point in the set.
Definition: PxContactModifyCallback.h:228
PX_FORCE_INLINE PxU32 getInternalFaceIndex1(PxU32 i) const
Get the face index with respect to the second shape of the pair for a specific contact point in the s...
Definition: PxContactModifyCallback.h:145
PxU32 mCount
Number of contact points in the set.
Definition: PxContactModifyCallback.h:355
An array of instances of this class is passed to PxContactModifyCallback::onContactModify().
Definition: PxContactModifyCallback.h:367
virtual ~PxContactModifyCallback()
Definition: PxContactModifyCallback.h:439
PxU8 internalFlags
Definition: PxContact.h:95
PX_FORCE_INLINE PxReal getInvMassScale0() const
Returns the invMassScale of body 0.
Definition: PxContactModifyCallback.h:253
PX_FORCE_INLINE PxReal getInvInertiaScale1() const
Returns the invInertiaScale of body 1.
Definition: PxContactModifyCallback.h:289
Abstract class for collision shapes.
Definition: PxShape.h:142
#define PX_FORCE_INLINE
Definition: PxPreprocessor.h:351
float PxReal
Definition: PxSimpleTypes.h:78
#define PXC_CONTACT_NO_FACE_INDEX
Definition: PxContact.h:47
An interface class that the user can implement in order to modify CCD contact constraints.
Definition: PxContactModifyCallback.h:460
PX_FORCE_INLINE PxReal getMaxImpulse(PxU32 i) const
Get the maximum impulse for a specific contact point in the set.
Definition: PxContactModifyCallback.h:160
PX_FORCE_INLINE PxReal getDynamicFriction(PxU32 i) const
Get the static friction coefficient for a specific contact point in the set.
Definition: PxContactModifyCallback.h:221
PX_FORCE_INLINE void setPoint(PxU32 i, const PxVec3 &p)
Alter the position of a specific contact point in the set.
Definition: PxContactModifyCallback.h:76
PX_FORCE_INLINE const PxVec3 & getTargetVelocity(PxU32 i) const
Get the target velocity of a specific contact point in the set.
Definition: PxContactModifyCallback.h:119
PX_FORCE_INLINE void setNormal(PxU32 i, const PxVec3 &n)
Alter the contact normal of a specific contact point in the set.
Definition: PxContactModifyCallback.h:92
Indicates this contact stream has modified mass ratios.
Definition: PxContact.h:71
PX_FORCE_INLINE PxU32 getInternalFaceIndex0(PxU32 i) const
Get the face index with respect to the first shape of the pair for a specific contact point in the se...
Definition: PxContactModifyCallback.h:138
PxModifiableContact * mContacts
The contact points of the set.
Definition: PxContactModifyCallback.h:356
An array of contact points, as passed to contact modification.
Definition: PxContactModifyCallback.h:61
PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SD...
Definition: PxRigidActor.h:58
Indicates this contact stream has face indices.
Definition: PxContact.h:68
PX_FORCE_INLINE void ignore(PxU32 i)
Ignore the contact point.
Definition: PxContactModifyCallback.h:240
PX_FORCE_INLINE PxReal getStaticFriction(PxU32 i) const
Get the static friction coefficient for a specific contact point in the set.
Definition: PxContactModifyCallback.h:202
Header for contact patch where all points share same material and normal.
Definition: PxContact.h:64
PX_FORCE_INLINE void setRestitution(PxU32 i, PxReal r)
Alter the restitution coefficient for a specific contact point in the set.
Definition: PxContactModifyCallback.h:190
An interface class that the user can implement in order to modify contact constraints.
Definition: PxContactModifyCallback.h:422
virtual ~PxCCDContactModifyCallback()
Definition: PxContactModifyCallback.h:477
PX_FORCE_INLINE void setInvMassScale0(const PxReal scale)
Sets the invMassScale of body 0.
Definition: PxContactModifyCallback.h:301
PX_FORCE_INLINE void setInvMassScale1(const PxReal scale)
Sets the invMassScale of body 1.
Definition: PxContactModifyCallback.h:314
PX_FORCE_INLINE PxContactPatch * getPatch() const
Definition: PxContactModifyCallback.h:349
Indicates this contact stream has max impulses set.
Definition: PxContact.h:73
PxContactSet contacts
An array of contact points between these two shapes.
Definition: PxContactModifyCallback.h:400
PX_FORCE_INLINE const PxVec3 & getNormal(PxU32 i) const
Get the contact normal of a specific contact point in the set.
Definition: PxContactModifyCallback.h:83
PX_FORCE_INLINE void setSeparation(PxU32 i, PxReal s)
Alter the separation of a specific contact point in the set.
Definition: PxContactModifyCallback.h:111
uint8_t PxU8
Definition: PxSimpleTypes.h:75
class representing a rigid euclidean transform as a quaternion and a vector
Definition: PxTransform.h:48
PX_FORCE_INLINE PxReal getInvMassScale1() const
Returns the invMassScale of body 1.
Definition: PxContactModifyCallback.h:265
PX_FORCE_INLINE void setInvInertiaScale1(const PxReal scale)
Sets the invInertiaScale of body 1.
Definition: PxContactModifyCallback.h:340
PX_FORCE_INLINE void setMaxImpulse(PxU32 i, PxReal s)
Alter the maximum impulse for a specific contact point in the set.
Definition: PxContactModifyCallback.h:169
PX_FORCE_INLINE PxU32 size() const
The number of contact points in the set.
Definition: PxContactModifyCallback.h:245
PX_FORCE_INLINE void setInvInertiaScale0(const PxReal scale)
Sets the invInertiaScale of body 0.
Definition: PxContactModifyCallback.h:327
PX_FORCE_INLINE void setStaticFriction(PxU32 i, PxReal f)
Alter the static friction coefficient for a specific contact point in the set.
Definition: PxContactModifyCallback.h:209
PX_FORCE_INLINE const PxVec3 & getPoint(PxU32 i) const
Get the position of a specific contact point in the set.
Definition: PxContactModifyCallback.h:69
PX_CUDA_CALLABLE PX_INLINE void PX_UNUSED(T const &)
Definition: PxPreprocessor.h:466
PX_FORCE_INLINE PxReal getInvInertiaScale0() const
Returns the invInertiaScale of body 0.
Definition: PxContactModifyCallback.h:277
PX_FORCE_INLINE PxReal getSeparation(PxU32 i) const
Get the separation of a specific contact point in the set.
Definition: PxContactModifyCallback.h:104
Indicates this contact stream has target velocities set.
Definition: PxContact.h:72
PX_FORCE_INLINE PxReal getRestitution(PxU32 i) const
Get the restitution coefficient for a specific contact point in the set.
Definition: PxContactModifyCallback.h:181
A modifiable contact point. This has additional fields per-contact to permit modification by user...
Definition: PxContact.h:140
uint32_t PxU32
Definition: Px.h:48
PX_FORCE_INLINE void setTargetVelocity(PxU32 i, const PxVec3 &v)
Alter the target velocity of a specific contact point in the set.
Definition: PxContactModifyCallback.h:126
3 Element vector class.
Definition: PxVec3.h:49