dimforge / nphysics

2 and 3-dimensional rigid body physics engine for Rust.
https://nphysics.org
Apache License 2.0
1.62k stars 121 forks source link

Jitters when approximating wheels with convex cylinders #156

Closed TheEdward162 closed 8 months ago

TheEdward162 commented 5 years ago

Hi, I've been trying to create a little racing game using nphysics for physics. I have a central piece and four wheels I attach to it using constraints. What I'm doing now is that I compute ConvexHull of the wheel model and use it as a shape. But this creates a lot of jitters when the car is moving, because the shape isn't smooth and the car is colliding with the ground very often and is getting bumped out of it.

I wanted to ask if there is any better way to simulate this. I would like to avoid having to create wheels out of multiple pieces, but right now that is the only solution to model elasticity I can think of.

sebcrozet commented 5 years ago

If you issues is due to the non-smoothness of the wheels, one solution is to increase the accuracy of the polyhedral approximation of their shapes.

A better solution would be to use a Capsule or a Cylinder as shapes for the wheel colliders, but those two primitives are currently not supported by nphysics. (Adding support of cylinders would be quite difficult, but adding capsule should be straightforward).

TheEdward162 commented 5 years ago

Yes, it's mostly about the non-smoothness. I'll look into the shapes if I have some time, but right now I'll probably just add more divisions to my cylinders and hope it's enough. Thanks.