Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collision resolution for convex mesh being recreated in each frame #525

Open
amirbarda opened this issue Jan 30, 2022 · 1 comment
Open

Comments

@amirbarda
Copy link

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.

@kstorey-nvidia
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants