NVIDIAGameWorks/PhysX

Collision resolution for convex mesh being recreated in each frame

amir90 opened this issue · 1 comments

Hello,

I have a convex mesh that needs to be deformed throughout the simulation. To achieve this, I recreate it in each frame. unfortunately, this results in clipping through the environment (a triangle mesh), even though the corresponding actor's simulation flag is set to true. I assume the deformation is subtle enough so that the difference in the center of mass and Inertia tensor is negligible between consecutive frames.

Currently, I am using my own OnContact callback that pushes the mesh in opposite direction of the intersection. This is very basic, and causes jittering behavior when the mesh is supposed to rest against a surface, and sometimes outright fails if the scene is complex enough.
Ideally, I would like for Physx to resolve the collisions as it does with rigid objects, which achieves much more stable behavior.
I am unsure about how exactly I can get the collision resolution pipeline to do this, or if it is even possible through the exposed API. Any help will be appreciated.
thanks.

In theory, this should work and there is a snippet in the SDK called "SnippetDeformableMesh", which shows a similar effect, although in this case it is showing a mesh deforming rather than a convex.

Are you achieving this by calling setGeometry on the shape, assigning a newly-cooked convex mesh representing the new geometry? Or are you just directly changing the vertices in PxConvexMesh by casting away the const on the vertex buffer?

If you are doing the first option, it should work. If you are taking the second option, it is highly likely not to work unless you were also updating all the information in the convex mesh (plane information, for example).

If you take a look at the snippet showing the deformable mesh, you will see this line immediately after the mesh was modified:

gScene->resetFiltering(*gActor);

This tells the simulation to re-generate the interactions involving this specific actor. Can you try calling this to see if it helps? That should discard all the cached information between the pair so it should generate a completely fresh set of contacts. You may still get some clipping that takes more than a frame to resolve.