Build a convex hull from a given mesh in Bullet

Post Reply
paprica
Posts: 2
Joined: Sun Jul 30, 2017 12:40 pm

Build a convex hull from a given mesh in Bullet

Post by paprica »

According to this tutorial: http://www.opengl-tutorial.org/miscella ... s-library/,
a convex hull is the most accurate shape one can build from a mesh? I have two questions regarding this:

1. How do I build a convex hull from a given, complex mesh in Bullet?
2. Should this be done offline? How do most people do this? (that is, create a collision shape from a mesh in games)
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Build a convex hull from a given mesh in Bullet

Post by drleviathan »

(1) No, the convex hull of a complex mesh is, in general, an approximation of the original mesh. For static meshes you can use a btBvhTriangleMeshShape for more accurate collision shape, but these have a few drawbacks/limitations: (a) objects that use such a shape can only be static, (b) dynamic small and/or thin things can sometimes tunnel through them, and (c) if your mesh has too many triangles in too tight of a volume (compared to the objects hat hit it) then they can cause spikes of poor performance.

(2) Whether you should generate the btConvexHullShape at run-time or as a preprocessed step depends on the CPU resources available for your game. If you're running it on a modern PC then run-time shouldn't cause any problem for most models. If you're running it on an embedded platform, a phone, or a console then preprocessing and optimizing shapes is probably a good idea.

BTW, using more than 42 points for a btConvexHullShape is probably a bad idea. If you need more points then maybe you should be using a btCompoundShape with multiple convex parts instead. If you go this path (convex decomposition) then you really should be doing it in a pre-processed step.
Post Reply