Simplify btConvexHullShape?

SteveDeFacto
Posts: 31
Joined: Sat Jul 23, 2011 4:24 pm

Simplify btConvexHullShape?

Post by SteveDeFacto »

I have a point cloud with too many vertices and it's convex hull is too elaborate. I would like to simplify the convex shape that is generated by the constructor for btConvexHullShape but I have no idea how to do this?
User avatar
Pyritie
Posts: 25
Joined: Thu Aug 11, 2011 6:42 pm

Re: Simplify btConvexHullShape?

Post by Pyritie »

use a simpler model?

EDIT:
if you can't do that, maybe weld vertices that are close together within a certain threshold?
eagletree
Posts: 28
Joined: Sun Jul 31, 2011 11:20 pm

Re: Simplify btConvexHullShape?

Post by eagletree »

I had this in my notes. I think it came from the Wiki. Haven't tried it yet but eventually I was going to need it. Maybe this is what you mean? I'm just parroting, interested to know if it works.

reduces the number of vertices to a minimum before using convexhullshape. Example is in bullet/demos/convexdecompositiondemo

Code: Select all

//	btConvexShape* originalConvexShape; is the original convexHullShape

	//create a hull approximation
	btShapeHull* hull = new btShapeHull(originalConvexShape);
	btScalar margin = originalConvexShape->getMargin();
	hull->buildHull(margin);
	btConvexHullShape* simplifiedConvexShape = new btConvexHullShape(hull->getVertexPointer(),hull->numVertices());
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: Simplify btConvexHullShape?

Post by dphil »

Yes the btShapeHull is one way to go. It simplifies a convex hull using a 42-point sphere, resulting in a convex hull of 42 points, or sometimes less (based on my own experimentation). I looked into this when checking out the new HACD decomposition library in Bullet, to simplify produced convex hulls. However, after experimenting, it seemed to me that the HACD library's own hull simplification tools did a better job of hull conservation vs num vertices trade-off. But in general, btShapeHull should be decent.
SteveDeFacto
Posts: 31
Joined: Sat Jul 23, 2011 4:24 pm

Re: Simplify btConvexHullShape?

Post by SteveDeFacto »

eagletree wrote:I had this in my notes. I think it came from the Wiki. Haven't tried it yet but eventually I was going to need it. Maybe this is what you mean? I'm just parroting, interested to know if it works.

reduces the number of vertices to a minimum before using convexhullshape. Example is in bullet/demos/convexdecompositiondemo

Code: Select all

//	btConvexShape* originalConvexShape; is the original convexHullShape

	//create a hull approximation
	btShapeHull* hull = new btShapeHull(originalConvexShape);
	btScalar margin = originalConvexShape->getMargin();
	hull->buildHull(margin);
	btConvexHullShape* simplifiedConvexShape = new btConvexHullShape(hull->getVertexPointer(),hull->numVertices());
This idea does appear to have worked!
Last edited by SteveDeFacto on Thu Sep 01, 2011 3:55 pm, edited 1 time in total.
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Simplify btConvexHullShape?

Post by Flix »

eagletree wrote:[btShapeHull] reduces the number of vertices to a minimum before using convexhullshape. Example is in bullet/demos/convexdecompositiondemo
Good to know. Now I understand what dphil meant in another post :P .
I've added this feature to my HACD demo here http://bulletphysics.org/Bullet/phpBB3/ ... =17&t=7159, although I agree that HACD itself does a better job in most cases in reducing the number of hull vertices.
SteveDeFacto
Posts: 31
Joined: Sat Jul 23, 2011 4:24 pm

Re: Simplify btConvexHullShape?

Post by SteveDeFacto »

Flix wrote:
eagletree wrote:[btShapeHull] reduces the number of vertices to a minimum before using convexhullshape. Example is in bullet/demos/convexdecompositiondemo
Good to know. Now I understand what dphil meant in another post :P .
I've added this feature to my HACD demo here http://bulletphysics.org/Bullet/phpBB3/ ... =17&t=7159, although I agree that HACD itself does a better job in most cases in reducing the number of hull vertices.
Yeah, I ended up reverting back to my engine's reduction algorithm. It's just not quite good enough for my uses.