Collision problems with btTriangleMesh

Post Reply
aFerreira
Posts: 9
Joined: Fri Dec 04, 2015 10:30 pm

Collision problems with btTriangleMesh

Post by aFerreira » Fri Dec 04, 2015 10:40 pm

Hello,
I am having problems with using triangles meshes as collision objects. In the triangles division my vehicle bump into the lines as if there was a bump there:
https://vimeo.com/147900906
My code:

Code: Select all

btTriangleMesh* trimesh = new btTriangleMesh();

//Get the object collision shape from the objVertices variable
staticObjectsVector[mainBodyIdx].convertVerticesToCollisionShape(trimesh);

bool useQuantizedBvhTree = true;
collisionShape  = new btBvhTriangleMeshShape(trimesh, useQuantizedBvhTree);

with

Code: Select all

void openglObject::convertVerticesToCollisionShape(btTriangleMesh* trimesh)
{
  for (unsigned int i=0;i<nVertices;i+=3)
trimesh->addTriangle( 
btVector3(objVertices[i].x - objectCenter.X, objVertices[i].y - objectCenter.Y, objVertices[i].z - objectCenter.Z), 
btVector3(objVertices[i+1].x - objectCenter.X, objVertices[i+1].y - objectCenter.Y, objVertices[i+1].z - objectCenter.Z), 
btVector3(objVertices[i+2].x - objectCenter.X, objVertices[i+2].y - objectCenter.Y, objVertices[i+2].z - objectCenter.Z));

}
Any suggestions? i already tried increasing the step size and frequency to no avail.

Silverlan
Posts: 27
Joined: Thu Oct 30, 2014 9:15 pm

Re: Collision problems with btTriangleMesh

Post by Silverlan » Sun Dec 06, 2015 10:04 am

Yeah, this looks very similar to the problem I'm having.
Collisions are fine with btConvexShape, but vehicles really don't like triangle meshes. The size of the triangles seems to make no difference, since they're much more dense in my case but the problem is still there.
Looks like it might be a bug?

aFerreira
Posts: 9
Joined: Fri Dec 04, 2015 10:30 pm

Re: Collision problems with btTriangleMesh

Post by aFerreira » Sun Dec 06, 2015 2:17 pm

Seems like it. If i use a convexShape the problem also get solved, however this is not a viable solution as many objects just arent convex. Also, if i remove the cylinder shape for the wheels, the problem also disappears but this not a viable solution either, as you lose collision with the wheels in all interactions.

xexuxjy
Posts: 225
Joined: Wed Jan 07, 2009 11:43 am
Location: London

Re: Collision problems with btTriangleMesh

Post by xexuxjy » Mon Dec 07, 2015 1:41 pm

Have you had a look at the InternalEdgeUtility and the InternalEdgeDemo ? It might help with the problem by 'smoothing' the normals between the triangles.

http://www.bulletphysics.org/Bullet/php ... 03&start=0

aFerreira
Posts: 9
Joined: Fri Dec 04, 2015 10:30 pm

Re: Collision problems with btTriangleMesh

Post by aFerreira » Tue Dec 08, 2015 11:42 pm

xexuxjy wrote:Have you had a look at the InternalEdgeUtility and the InternalEdgeDemo ? It might help with the problem by 'smoothing' the normals between the triangles.

http://www.bulletphysics.org/Bullet/php ... 03&start=0
Yep, this 4 year old "hack" works on small triangles. With larger triangles it works 90% of the time. Why is this not more tightly integrated with the bullet library?

Silverlan
Posts: 27
Joined: Thu Oct 30, 2014 9:15 pm

Re: Collision problems with btTriangleMesh

Post by Silverlan » Mon Jan 18, 2016 9:13 am

xexuxjy wrote:Have you had a look at the InternalEdgeUtility and the InternalEdgeDemo ? It might help with the problem by 'smoothing' the normals between the triangles.

http://www.bulletphysics.org/Bullet/php ... 03&start=0
This also worked for me, thanks.
However, the problem still occurs on the intersection between two meshes:
https://youtu.be/y9xwJRlZ6UM?t=16s

Is there anything that can be done about that, without having to combine the meshes into a single mesh?

gdlk
Posts: 62
Joined: Fri Oct 24, 2014 7:01 pm

Re: Collision problems with btTriangleMesh

Post by gdlk » Tue Jan 19, 2016 2:11 pm

The problem is seems like the sliding problem explained in the Game Physics Pearls book. Try making the final of the mesh like a ramp, and then intersect one mesh inside the another one (like in the attached image). I don't know if works (currently I don't have that problem, so I never have to use that solution), but maybe solve the issue.

Regards!
Attachments
sliding.png
sliding.png (3.98 KiB) Viewed 3357 times

kermado
Posts: 20
Joined: Tue Jan 12, 2016 11:20 am

Re: Collision problems with btTriangleMesh

Post by kermado » Fri Jan 22, 2016 5:01 pm

It's the edge catching problem.
There are a number of potential "solutions", although I don't believe that it is solvable in the general case. You could modify the persistent manifold point normal or set the depth to positive infinity when you encounter a manifold point with a strange normal. Note that the constraint solvers ignore manifold points with a positive depth.

Post Reply