Strange behaviour: sphere on a concave mesh

Post Reply
openeye
Posts: 10
Joined: Sun Apr 29, 2012 3:22 pm

Strange behaviour: sphere on a concave mesh

Post by openeye »

Hi!

I have a path with a concave triangle mesh collision shape (btBvhTriangleMeshShape), and a sphere (btSphereShape) on it. I call addForce on the rigid body of the sphere, in every tick, with a force vector paralell to the surface of the path. Now the path has a simple rectangular shape with many triangles of its top surface. In the future it will have concave shape. So now, the triangles of the surface of the path are coplanar, and are along the XZ plane. So I use addForce to my sphere, my sphere accelerates along the XZ plane (on the ground), and above a specific speed the sphere starts to bounce on the surface, along the vertical (Y) axis too. Small bounces first, but growing after, till I lower the speed. If I replace the btBvhTriangleMeshShape to btConvexHullShape temporarily then the bouncing disappear. If I change steptime from 1/60 to 1/200 the bouncing is less, but not disappear. The combined Friction and combined Restitution are zero both.

Can somebody say what I can do reaching not to start bouncing the sphere above a specific speed ?
openeye
Posts: 10
Joined: Sun Apr 29, 2012 3:22 pm

Re: Strange behaviour: sphere on a concave mesh

Post by openeye »

I tried another test:

I created a compound shape of many convex hull shapes from my concave path mesh. And the bouncing was there.

It seems, the only stable version of rolling a ball is when I use one convex shape for the path.

Probably the sphere gets vertical speed rolling at the triangle edges of coplanar triangles,
or the "edges" (borders) of convex hulls in the case of the compound shape of many convex hull shapes.

In both cases the parts of the surface are coplanar, and the adjacent vertex positions are the same. The only problem can be the precision of floats in the vertices, making triangles (or convex hull sides) of the surface of the path not exactly coplanar.

Can it be the problem ? And how can I eliminate it ?
Last edited by openeye on Tue May 01, 2012 12:41 pm, edited 2 times in total.
openeye
Posts: 10
Joined: Sun Apr 29, 2012 3:22 pm

Re: Strange behaviour: sphere on a concave mesh

Post by openeye »

I tried another test too:

I made my path with a btBvhTriangleMeshShape again, but I created it from a btTriangleIndexVertexArray istead of the former btTriangleMesh.

After this I call

btGenerateInternalEdgeInfo(pShape,pTriangleInfoMap);

with the btBvhTriangleMeshShape and a newly allocated btTriangleInfoMap.

After this I use

btAdjustInternalEdgeContacts(p_MP,p_pCollObj1,p_pCollObj0,p_PartID1,p_Idx1);

in my custom BtContactAddedCallBack.

I found this method in the InternalEdgeDemo sample application.

But unfortunately, the bouncing is the same. What can I do to eliminate that bouncing of my sphere ?

I would like my sphere to roll smoothly along the top surface of my path object without the bouncing in the vertical direction.
openeye
Posts: 10
Joined: Sun Apr 29, 2012 3:22 pm

Re: Strange behaviour: sphere on a concave mesh

Post by openeye »

I think that I found the "solution".

I hope there will be somebody who understand this and can explain why this is the situation:

So, the source of the bouncing is the internal edges of my concave mesh collision shape.

There is already a utility solution for this kind of problem in bullet, called "InternalEdgeUtility", and a demo sample called "InternalEdgeDemo".

I used this solution to my program, but this did not solve the bouncing in my situation.

This was because of the friction.

I use a big friction in my program, but the InternalEdgeDemo uses zero friction.

I configure the InternalEdgeDemo to a similar setup like my program. This setup is a bigger an longer, more dense grid, and a sphere collision shape on it, instead of those ones in the original InternalEdgeDemo.

If you download the modified InternalEdgeDemo from the attachment and compile and run it, press space to restart animation, press O for side view, and watch, that if you set zero friction in calculateCombinedFriction, then the sphere rolling smooth on the floor, and when you set for example .5 friction, then the sphere starts bouncing.

If you turn off "contact filtering" with key N, then the bouncing happens at zero friction, too. So the "internal-edge-anti-bouncing" solution works in bullet, but it seems, that it is accurate only at little friction values.

You can fire boxes with mouse, and with those bodies the situation is the same.

Now, the question is, that what is the connection between friction and "contact filtering", and why do I have to use small friction values ?
Last edited by openeye on Wed May 02, 2012 12:40 pm, edited 1 time in total.
openeye
Posts: 10
Joined: Sun Apr 29, 2012 3:22 pm

Re: Strange behaviour: sphere on a concave mesh

Post by openeye »

It is the modified version of InternalEdgeDemo in the attachment.
Attachments
InternalEdgeDemo.zip
It is the modified version of InternalEdgeDemo in the attachment.
(9.23 KiB) Downloaded 418 times
toxikman
Posts: 4
Joined: Tue Jul 10, 2012 10:38 pm

Re: Strange behaviour: sphere on a concave mesh

Post by toxikman »

I'm also seeing this problem with both the surface (btConvexHullShape) and the sphere (btSphereShape) created with m_restitution = 0.5 and m_friction = 1.0

Is the only solution to turn down the friction? The friction needs to be high in order for the ball to roll well. I'll try playing with the ball's mass to see if that helps.
toxikman
Posts: 4
Joined: Tue Jul 10, 2012 10:38 pm

Re: Strange behaviour: sphere on a concave mesh

Post by toxikman »

Perhaps Laurent Coulon's code improvements help this stability issue we are seeing?

http://bulletphysics.org/Bullet/phpBB3/ ... f=9&t=8146

I'll have to give them a try.
Post Reply