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

Objects fall through TriMesh terrain very easily #524

Open
LPGhatguy opened this issue Sep 20, 2023 · 5 comments
Open

Objects fall through TriMesh terrain very easily #524

LPGhatguy opened this issue Sep 20, 2023 · 5 comments

Comments

@LPGhatguy
Copy link

Hello!

We're working on a game that has terrain and physics objects. We're using TriMesh for representing that terrain currently. We have been having issues with objects falling through the terrain even without large velocities or forces being applied.

2023-09-20.17-02-55.mp4

Here is a video of one of the parts we've been experiencing this issue with. The rapier debug visualization is enabled.

The ground here is a trimesh with four vertices. The slab is a convex hull that is 2x0.03x2. Gravity is -9.81.

We've noticed this issue with slabs as thick as 10cm, but the issue happens very frequently with objects like this one.

The dragger used in the video moves the object slightly above the plane and rotates it before dropping it again. We can see from the debug visualization that there are correct contacts being computed on the corners, but that doesn't stop the entire object from falling through the terrain as it rotates.

@sebcrozet
Copy link
Member

Sorry it took me so much time to start looking into this issue. I think two things need to happen to fix this:

  1. The internal-edges handler is not being conservative enough and is eliminating some contact that are essential to keep the rectangle above the floor. (I’m currently working on improving this).
  2. The prediction distance, that is currently a fixed value, needs to take into account the angular movement of the rigid-body. The point that is furthest from the existing collision with the floor ends up having at velocity that is large enough for it to tunnel through the ground.

@LPGhatguy
Copy link
Author

Thank you for looking into this! We're still working on this project and still using rapier, so I'm very excited to test any changes that you come up with.

@sebcrozet
Copy link
Member

sebcrozet commented Apr 28, 2024

Hey @LPGhatguy! I’ve got some news. Would you like to give #625 a try?
My recommendations are to:

  • Set the contact skin of your terrain collider (or the metal slab, or both) to the largest value you are visually comfortable with (it will create a gap between the terrain and the objects lying on it). This is done with ColliderBuilder::trimesh(...).contact_skin(your_contact_skin_value).
  • Enable soft-ccd on your metal slab rigid-body with RigidBodyBuilder::dynamic().soft_ccd_prediction(5.0). (I picked 5.0 arbitrarily here.)

Please let me know if that works or doesn’t. The work on improving triangle mesh behaviors has progressed quite a bit here, but there are still a few open questions. The thin-object on thin-terrain problem is generally quite challenging.

Thank you again for your patience!

@raycar5
Copy link

raycar5 commented May 1, 2024

Hi @sebcrozet I've been struggling with stability in collisions for my racing game where the track is a big trimesh and cars are convex decompositions, tried tuning a bunch of rapier parameters to no avail, sometimes after a collision the car would seemingly gain energy out of nowhere and go flying, I'm happy to report that after trying contact skin on the track and soft ccd on the car and playing with it for 15 minutes, the collisions seem a lot more realistic and I haven't had my car go flying yet, I'm cautiously optimistic since this seems to occur randomly but if it works, this is fantastic! I was starting to worry I'd have to drop rapier and move to a wrapped c++ physics engine, great job!

@sebcrozet
Copy link
Member

@raycar5 Glad to hear that! Let me know if you still encounter a similar issue.

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

3 participants