Performance for ConvexHull

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
mazelin
Posts: 6
Joined: Thu Dec 13, 2012 1:50 am

Performance for ConvexHull

Post 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.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Performance for ConvexHull

Post 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!).
mazelin
Posts: 6
Joined: Thu Dec 13, 2012 1:50 am

Re: Performance for ConvexHull

Post by mazelin »

Thank you for your reply.
It's perfact and simple solution.
Thank you again.
Post Reply