Usage of BvhTriangleMeshShape for static collision shapes

Post Reply
thegeneralsolution
Posts: 16
Joined: Sun Jul 05, 2015 12:55 am

Usage of BvhTriangleMeshShape for static collision shapes

Post by thegeneralsolution »

So I found the following cheat sheet from the User Manual super helpful for choosing collision shapes:

Image

I have a couple questions bout it though. Assume for the sake of this discussion that the object in question falls into the 'BvhTriangleMeshShape' or 'BvhScaledTriangleMeshShape' categories.

1. If the object is composed of disjoint/disconnected meshes, would I still be able to represent them as a single BvhTriangleMeshShape or would I need to construct several BvhTriangleMeshShapes? For example, suppose I have a (static) object that is represented by a series of cube meshes. Can I make a single BvhTriangleMeshShape from this?

2. Is it ALWAYS better to use a BvhTriangleMeshShape for static shapes even if the geometry resembles a basic primitive (Sphere, box, cyllinder, etc)?

Thanks so much! :)
nictosi
Posts: 11
Joined: Mon Jul 06, 2015 9:25 am

Re: Usage of BvhTriangleMeshShape for static collision shape

Post by nictosi »

thegeneralsolution wrote: [...]

2. Is it ALWAYS better to use a BvhTriangleMeshShape for static shapes even if the geometry resembles a basic primitive (Sphere, box, cyllinder, etc)?

Thanks so much! :)
I suppose this depends on the level of accuracy you need on your collision detection. Be aware that the Broadphase collision detection algorithm rejects object pairs using bounding boxes. From the Bullet User Manual:
"The broadphase collision detection provides acceleration structure to quickly reject pairs of objects based on axis aligned bounding box (AABB) overlap. Several different broadphase acceleration structures are available"

Hence, if you plan to use basic primitives instead of meshes to speed up computation, I believe you should benchmark collision-detection performance and decide if you intend to trade off accuracy for performance.
thegeneralsolution
Posts: 16
Joined: Sun Jul 05, 2015 12:55 am

Re: Usage of BvhTriangleMeshShape for static collision shape

Post by thegeneralsolution »

Thank you for your response!

I am not sure I quite see your point though. You appear to be implicitly stating that using primitives could be faster but less accurate. Am I correct?

The user manual states that Bullet builds an acceleration structure for the BvhTriangleMesh too though...

"For static world environment, a very efficient way to represent static triangle meshes is to use a
btBvhTriangleMeshShape. This collision shape builds an internal acceleration structure from a
btTriangleMesh or btStridingMeshInterface."

this structure clearly takes advantage of the fact that the mesh is static - I just wonder if that advantage is faster than using a simple primitive, or compound primitive when that can represent certain elements of the terrain.
nictosi
Posts: 11
Joined: Mon Jul 06, 2015 9:25 am

Re: Usage of BvhTriangleMeshShape for static collision shape

Post by nictosi »

thegeneralsolution wrote:Thank you for your response!

I am not sure I quite see your point though. You appear to be implicitly stating that using primitives could be faster but less accurate. Am I correct?

The user manual states that Bullet builds an acceleration structure for the BvhTriangleMesh too though...

"For static world environment, a very efficient way to represent static triangle meshes is to use a
btBvhTriangleMeshShape. This collision shape builds an internal acceleration structure from a
btTriangleMesh or btStridingMeshInterface."

this structure clearly takes advantage of the fact that the mesh is static - I just wonder if that advantage is faster than using a simple primitive, or compound primitive when that can represent certain elements of the terrain.
Normally, a single analytic primitive (e.g. a bounding sphere or a bounding box) will always faster than a mesh shape. However, the internal acceleration structure reduces the gap between these two models in terms of collision-detection time. If you represent your object as a set of analytical primitives, then you have to check if this is faster of a unique btBvhTriangleMeshShape.
thegeneralsolution
Posts: 16
Joined: Sun Jul 05, 2015 12:55 am

Re: Usage of BvhTriangleMeshShape for static collision shape

Post by thegeneralsolution »

then you have to check if this is faster of a unique btBvhTriangleMeshShape
Okay, so its a calibration thing. Makes sense. For me it really just boils down to - is it common practice to just create a massive, single btTriangleMeshShape from the entire static environment?

And this relates to question [1]. I read this at the tail end of the user manual:
"Combine multiple static triangle meshes into one
Many small btBvhTriangleMeshShape pollute the broadphase. Better combine them"

I guess I'm not sure what they mean by "combine" in this context.
secondwtq
Posts: 4
Joined: Sat Jul 04, 2015 6:02 pm

Re: Usage of BvhTriangleMeshShape for static collision shape

Post by secondwtq »

thegeneralsolution wrote:
then you have to check if this is faster of a unique btBvhTriangleMeshShape
Okay, so its a calibration thing. Makes sense. For me it really just boils down to - is it common practice to just create a massive, single btTriangleMeshShape from the entire static environment?

And this relates to question [1]. I read this at the tail end of the user manual:
"Combine multiple static triangle meshes into one
Many small btBvhTriangleMeshShape pollute the broadphase. Better combine them"

I guess I'm not sure what they mean by "combine" in this context.
IIRC it means , for example, that if you have many static meshes scattered on the ground, you should use one btTriangleMeshShape for them, rather than create one for each.
thegeneralsolution
Posts: 16
Joined: Sun Jul 05, 2015 12:55 am

Re: Usage of BvhTriangleMeshShape for static collision shape

Post by thegeneralsolution »

IIRC it means , for example, that if you have many static meshes scattered on the ground, you should use one btTriangleMeshShape for them, rather than create one for each.
Okay. But what if there are shared scaled instances as the diagram mentions? I saw a thread where someone was using btScaledBvhTriangleMeshShape to represent duplicated trees of various sizes. Is this just a memory consumption vs. speed thing?
Post Reply