btBvhTriangleMeshShape and Bullet limitations

Post Reply
erbisme4@yahoo.com
Posts: 41
Joined: Fri Apr 29, 2016 2:41 pm

btBvhTriangleMeshShape and Bullet limitations

Post by erbisme4@yahoo.com »

I have been using Bullet for complex model collision detection and have come across serious performance degradation using btBvhTriangleMeshShape. I have Convex primitives colliding with this static mesh and at times the performance is bad. To give an example, the static mesh has a bbox of 0.1mx0.07mx0.07m, and geometry contains 10,620 triangles. I move the convex rigidbody close to the static mesh, not touching it, but inside its aabb and the performance dips. Is this a problem with the triangleMesh being too dense, or am I missing something?

Any hints would be appreciated.
ktfh
Posts: 44
Joined: Thu Apr 14, 2016 3:44 pm

Re: btBvhTriangleMeshShape and Bullet limitations

Post by ktfh »

I would guess your convex primitives aabb overlaps all or most of the btBvhTriangleMeshShape even when not colliding, so all 10k triangles in overlapping volumes are being tested for collision against the primitive. A bvh would accelerate collision detection for something this complex if its scale was significantly larger than the primitive colliding with it. eg 100m btBvhTriangleMeshShape vs a 1m btSphereShape.

There are probably a few hack/solutions possible depending on what your trying to achieve. More details about what your trying to do would help with giving good advice.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: btBvhTriangleMeshShape and Bullet limitations

Post by Erwin Coumans »

Indeed, there are some default margins/tolerances that make the axis aligned bounding box much bigger, so the convex object is likely overlapping with all triangles. We are improving support for smaller shapes at the moment, especially since collision detection and physics simulation for robotics and VR needs it.

One of those thresholds is the contactBreakingThreshold (gContactBreakingThreshold), each AABB is increased by this threshold. Set it to a much smaller value.

An easier way is to use mm scale units (instead of meter units). That avoids hitting the threshold.
erbisme4@yahoo.com
Posts: 41
Joined: Fri Apr 29, 2016 2:41 pm

Re: btBvhTriangleMeshShape and Bullet limitations

Post by erbisme4@yahoo.com »

So I am curious as to what is going on when I serialize and deserialize the btBvhTriangleMeshShape structure through a static rigid body? I serialize from my application and deserialize into the Bullet Example browser, and I get much better performance in the sample browser. Do you know why this could be? Does serializing and deserializing change the scale of the btBvhTriangleMeshShape? I've spent days digging on why I can't achieve the same performance as the Example browser using Bvh static mesh.
erbisme4@yahoo.com
Posts: 41
Joined: Fri Apr 29, 2016 2:41 pm

Re: btBvhTriangleMeshShape and Bullet limitations

Post by erbisme4@yahoo.com »

Furthermore, what I'm getting at, is that there is a discrepancy between CollisionObject/CollisionShape data before and after Serializing/Deserializing the world and retrieving the same objects. Let's say I have two Collision Shapes, btBvhTriangleMeshShape bvhShape and btCompoundShape cShape. Collision between these two bodies at times has significant performance dips. Now I serialize the world to "world.txt". I instantiate btBulletWorldImporter *importer = new btBulletWorldImporter() and don't load this file into my existing world. I then call compoundRigidBody = (btRigidBody*)importer->getRigidBodyByIndex(0) as well as bvhRigidBody = (btRigidBody*)importer->getRigidBodyByIndex(1). Upon doing this, all performance issues have been resolved simply through De/Serialization.
Post Reply