Page 1 of 1

Collision problems with btTriangleMesh

Posted: Fri Dec 04, 2015 10:40 pm
by aFerreira
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.

Re: Collision problems with btTriangleMesh

Posted: Sun Dec 06, 2015 10:04 am
by Silverlan
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?

Re: Collision problems with btTriangleMesh

Posted: Sun Dec 06, 2015 2:17 pm
by aFerreira
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.

Re: Collision problems with btTriangleMesh

Posted: Mon Dec 07, 2015 1:41 pm
by xexuxjy
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

Re: Collision problems with btTriangleMesh

Posted: Tue Dec 08, 2015 11:42 pm
by aFerreira
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?

Re: Collision problems with btTriangleMesh

Posted: Mon Jan 18, 2016 9:13 am
by Silverlan
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?

Re: Collision problems with btTriangleMesh

Posted: Tue Jan 19, 2016 2:11 pm
by gdlk
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!

Re: Collision problems with btTriangleMesh

Posted: Fri Jan 22, 2016 5:01 pm
by kermado
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.