Page 1 of 1

Performance for ConvexHull

Posted: Thu Dec 13, 2012 1:57 am
by mazelin
I load my model and use ConvexHull to add to Space.
I find some model exe 'new ConvexHull' very slow. The model is not very complex.
So, I need help for how to let it fast.Thanks!
Code like:
TriangleMesh.AddMesh(model.Meshes, matrix, verticesList, indicesList);
ConvexHull hull = new ConvexHull(verticesList, 1); // this line run slow,can i fast?
I think the verticesList is to big, but i do not know how to decreases it.

Re: Performance for ConvexHull

Posted: Thu Dec 13, 2012 5:05 am
by Norbo
You can reduce the time the convex hull computation takes by using the ConvexHullHelper.RemoveRedundantPoints method on the pointset if there's a lot of redundant vertices. However, the best way to reduce the computation time is by simply not doing it. :)

You can create a ConvexHullShape at initialization and share it between multiple entities, avoiding the need for redundant convex hull operations. Examples of this can be found in the EntityConstructionDemo in the BEPUphysicsDemos.

If even the initialization takes too long, chances are the number of elements is huge or there are other problems (NaNs).

Note that the cost of collision detection for a convex hull is roughly linear with the number of points contained in the final processed point set. For runtime performance, it is a good idea to use simplified source models. A good target is less than 30 points (the lower, the better!).

Re: Performance for ConvexHull

Posted: Fri Dec 14, 2012 5:56 am
by mazelin
Thank you for your reply.
It's perfact and simple solution.
Thank you again.