Why the box will shake when it drop onto the surface with btConvexHullShape?

Post Reply
Winson
Posts: 5
Joined: Thu Apr 09, 2020 8:43 am

Why the box will shake when it drop onto the surface with btConvexHullShape?

Post by Winson » Tue Jun 30, 2020 1:05 pm

Hello everyone,

I'm trying to create a curve conveyor which is used for convey the box.
I adopt btConvexHullShape class to make the collision shape of conveyor suface.
but it has one problem: the Box will shake when it drop onto the suface.

It needs to be emphasized that the bottom of the box and the surface of the conveyor are parallel to the horizontal plane.

I think there are something wrong with btBoxShape collide with btConvexHullShape.
So, I make a example to show these wrong.
The result like the following GIF:

Image

The following is my code to create a triangular prism with btConvexHullShape class:

Code: Select all

btConvexHullShape* hull = new btConvexHullShape();
const btVector3 v1 = btVector3(0, 0, 2);
hull->addPoint(v1);
const btVector3 v2 = btVector3(0, 0.1, 2);
hull->addPoint(v2);
const btVector3 v3 = btVector3(0, 0, -2);
hull->addPoint(v3);
const btVector3 v4 = btVector3(0, 0.1, -2);
hull->addPoint(v4);
const btVector3 v5 = btVector3(-5, 0.1f, 0);
hull->addPoint(v5);
const btVector3 v6 = btVector3(-5, 0, 0);
hull->addPoint(v6);
hull->optimizeConvexHull();
hull->setMargin(0);
btTransform t;
t.setIdentity();
btRigidBody* hullBody = createRigidBody(0, t, hull);
I wonder how to solve this problem.
Is there any other way without this error to make the custom collision shape, such as sector surface and hollow cylinder?

Thanks!

User avatar
drleviathan
Posts: 629
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Why the box will shake when it drop onto the surface with btConvexHullShape?

Post by drleviathan » Tue Jun 30, 2020 3:11 pm

Don't set the margin of the convex hull to 0.0. Leave it at the default (which is 0.04m I think) and see if that makes your problem go away. My hypothesis is: you are allowing the box to actually penetrate the convex hull and the penetration resolution logic is kicking in. The penetration resolution algorithm is usually stable (doesn't pump too much energy into the system) but is ultimately non-physical and can introduce "unexpected artifacts" such as this.

If that doesn't solve your problem: make sure your substep is small. It should be at least 1/60 sec but try smaller steps to see if that helps.

Winson
Posts: 5
Joined: Thu Apr 09, 2020 8:43 am

Re: Why the box will shake when it drop onto the surface with btConvexHullShape?

Post by Winson » Tue Jul 07, 2020 7:28 am

drleviathan wrote:
Tue Jun 30, 2020 3:11 pm
Don't set the margin of the convex hull to 0.0. Leave it at the default (which is 0.04m I think) and see if that makes your problem go away. My hypothesis is: you are allowing the box to actually penetrate the convex hull and the penetration resolution logic is kicking in. The penetration resolution algorithm is usually stable (doesn't pump too much energy into the system) but is ultimately non-physical and can introduce "unexpected artifacts" such as this.

If that doesn't solve your problem: make sure your substep is small. It should be at least 1/60 sec but try smaller steps to see if that helps.
Thanks, drleviathan!
I had tried to set margin greater than 0.0 or set smaller steps, but also can not solve this problem.

I checked the source code and knew the process of collision detection. I found that btBoxShape collides with btConvexHullShape calls btConvexConvexAlgorithm class to get the closest points between two convex shapes. This is different from the case that btBoxShape collides with btBoxShape calls btBoxBoxAlgorithm class which without this problem.

I think the problem may be due to btConvexConvexAlgorithm class, but I couldn't undestand.

In addition, I used Demo3D, a physics simulation software which is based on PhysX or Bullet or ODE to test ConvexHullShape collides with BoxShape. When based on PhysX, it seems to be all right. When based on Bullet, this problem will occur but the extent is less than testing in Bullet.

I don't know what to do anymore!

Post Reply