Volume of btConvexHullShape

Post Reply
Geometrian
Posts: 23
Joined: Sat Dec 03, 2011 8:37 pm
Contact:

Volume of btConvexHullShape

Post by Geometrian »

I need to calculate the volume of a "btConvexHullShape" (more accurately, I need to compute a mass, but I'll do this through a density).

Short of implementing my own convex hull algorithm, what should I do?

I considered making a temporary "btConvexTriangleMeshShape" and then using its "calculatePrincipalAxisTransform" method, but this seems semi-crufty. If there's no better option, I'll try it.
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Volume of btConvexHullShape

Post by Flix »

I'm probably not enough "geometry-expert" to answer this. Anyways:

What I'd do:
1) using btConvexHullComputer to compute vertices/triangle indices from the btConvexHullShape (*).
2) after that, you can use for example Stan Melax's code here http://www.melax.com/volint (I'm not sure, but I AFAIR it should work for every manifold mesh (convex or not)).

I don't know if there's a faster way of doing it, specialized for convex meshes (maybe operating on the convex plane equations directly). Are you doing it every frame?
Geometrian wrote:I considered making a temporary "btConvexTriangleMeshShape" and then using its "calculatePrincipalAxisTransform" method, but this seems semi-crufty. If there's no better option, I'll try it.
I don't understand that... btConvexHullComputer should be enough.

However, as I've aready told you, I'm not an expert of topology/geometry and maybe there's something I'm missing.

(*) You can probably use generatePolyhedralFeatures(), btConvexPolyhedron(), [or something like that] directly on your btConvexHullShape to get the convex faces.
c6burns
Posts: 149
Joined: Fri May 24, 2013 6:08 am

Re: Volume of btConvexHullShape

Post by c6burns »

There's an example of doing exactly what Flix has suggested in VoronoiFractureDemo::voronoiBBShatter
Post Reply