Convex Hull impact of duplicate vertices

User avatar
SynapticBytes
Posts: 74
Joined: Thu Feb 10, 2011 8:27 pm

Convex Hull impact of duplicate vertices

Post by SynapticBytes »

In creating my Bullet Plugin for Shiva3D, I've come across a slight issue in the way Shiva reports model vertices.

My simple ConvexHull creation helper passes all of the Shiva model vertices from the vertex buffer to a btConvexHullShape. I know this is not optimal from the start (I assume Bullet isn't doing optimisation of the hull shape from the vertex array passed in?), but what makes it even worse is that Shiva creates vertices based on coordinates + UV + normal uniqueness. However, what returns from the vertex buffer is simply the x,y,z components. This means that there appear to be duplicate vertices in the buffer.

So my question is, when a btConvexHullShape is passed a vertex cloud that includes duplicate vertices, does that complicate the convex hull further, or is it smart enough to reject these duplicate model vertices when creating the convex hull shape? If not, I guess I'll have to at least do my own optimisation and create a new vertex array as input which removes duplicates before creating the hull shape.

Thanks.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Convex Hull impact of duplicate vertices

Post by Erwin Coumans »

Bullet will use the vertices as-is, so it becomes much slower.

There is a convex hull computer, it might remove duplicate vertices:
bullet2\LinearMath\btConvexHullComputer.h

Otherwise, it is best to filter them before feeding them to Bullet.
User avatar
SynapticBytes
Posts: 74
Joined: Thu Feb 10, 2011 8:27 pm

Re: Convex Hull impact of duplicate vertices

Post by SynapticBytes »

OK thanks Erwin.

I'll look at the computer, but I assumed I'd probably have to at least remove the duplicates myself. I still need to look into optimisation either way, as even without the duplicates, generating from the model vertex buffer will be inefficient, but it makes it simpler for inexperienced developers to interface with my plugin.