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 semicrufty. If there's no better option, I'll try it.
Volume of btConvexHullShape

 Posts: 23
 Joined: Sat Dec 03, 2011 8:37 pm
 Contact:
Re: Volume of btConvexHullShape
I'm probably not enough "geometryexpert" 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?
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.
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?
I don't understand that... btConvexHullComputer should be enough.Geometrian wrote:I considered making a temporary "btConvexTriangleMeshShape" and then using its "calculatePrincipalAxisTransform" method, but this seems semicrufty. If there's no better option, I'll try it.
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.
Re: Volume of btConvexHullShape
There's an example of doing exactly what Flix has suggested in VoronoiFractureDemo::voronoiBBShatter