NVIDIAGameWorks / PhysX

NVIDIA PhysX SDK
Other
3.18k stars 807 forks source link

Kinematic to dynamic actor - Uncertain about how PhysX resolves collisions #491

Open amirbarda opened 2 years ago

amirbarda commented 2 years ago

Hello,

I have a scenario where I need a simple deformable convex mesh for simulation. As Physx does not allow changing the vertices of of a convex mesh, I recreate it each frame with the required geometry. To handle collisions with the environment, my attempted solution is to use the PxPairFlag::eNOTIFY_TOUCH_FOUND, and to turn on the shape's simulation flag and let PhysX resolve the collision. When the collision is resolved I would turn off the simulation flag and continue.

However, I am not sure what the "collision resolved" flag should be. Is there eNOTIFY_PENETRATION_FOUND flag? Initially, I assumed PhysX resolves the collision within 1 frame, but that does not seem to always be true, even if I set MaxPenetrationVelocityto be the maximum (see attached PVD capture, where the actor penetrates the environment after the update, and is turned to a simulation object, but the penetration is not resolved in the next frame).

PVD

I would appreciate your help. Thank you!

kstorey-nvidia commented 2 years ago

PhysX can't guarantee it will resolve all penetrations in a single frame, so you definitely can't guarantee that. What you could potentially do is use a force thresholds/examine the applied forces to determine when the solver stops applying forces. You could alternatively just examine the set of contacts to determine when separation becomes >= 0.

amirbarda commented 2 years ago

Ok, Thanks for the reply! examining the separation sounds promising, I will try.