Convex Decomposition and threads

ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway

Convex Decomposition and threads

Post by ola »

Hi all,

I recently tried out the convex decomposition code found in Bullet's Extra directory. Works really well! It's really an excellent addon.

Only problem is, it seems it is not thread safe. I'm using separate loader threads for loading objects into my game world on-demand, and running more than one instance of the convex builder at a time causes a crash. Has anyone of you have had any experience with this?

Best regards,
Ola
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: Convex Decomposition and threads

Post by Dirk Gregorius »

Strange, we tried the Ratcliff stuff with several models and it didn't work at all. We even tried one simple cube with two distored vertices (as you find them ususally for vertex deformed brushes) and the results were useless.

One bug we found is that Ratcliff used single precision floating points in his hull code, while the original StanHull code uses double precision. This is actually not a very clever idea for an offline computation in my opinion.

I mean if it works for you than you are lucky. We tried five models or so and all were useless including the trivial deformed cube shape.
ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway

Re: Convex Decomposition and threads

Post by ola »

Oh!

One thing I found was that you cannot simply use a mesh that just is a long list of vertices. By that I mean the kind of mesh you'd find if you pull it out of Bullet's own btMesh (vertices are stored for each triangle, the indices list would just be a ever increasing list of 0, 1, 2, 3, 4, 5, etc...). So, I made a rough algorithm that first transforms the 3d graphics model mesh into a single one, then sorts the vertices so that each is only defined once, with a proper indices list.

Before doing that the output was complete rubbish. After sorting the mesh out, it all worked like in the example demo with the small table. So it seems the algorithm fails if a vertex is defined more than once.

Hope that made sense what I just tried to explain, maybe it could be the cause why it didn't work for you?
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: Convex Decomposition and threads

Post by Dirk Gregorius »

Thanks for pointing this out. I just double checked and we used cleaned meshes (snapped close vertices together and all this stuff) and all meshes used a proper indexed triangle mesh.
Maybe you try a simple box and push two vertices such that it becomes concave. For this we got totally bogus results or our expectations are totally wrong.


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

Re: Convex Decomposition and threads

Post by Erwin Coumans »

The convex decomposition is mainly an offline tool, generally not fast enough for real-time. You could add some synchronization primitives so only one instance is executed at a time.

Works really well! It's really an excellent addon
It seems to work very well for a lot of input, but as usual it is easy to generate some input that fails, as Dirk mentions. That is why I recommend to use it as an artist tool, rather then run-time. Several companies are using this convex decomposition by John Ratcliff successfully.

If you are interested, ODO and Swift++ also include convex decompositions.
Thanks,
Erwin
ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway

Re: Convex Decomposition and threads

Post by ola »

Dirk, I'll try to test such a cube and see what happens here soon, I'll let you know how it went. Maybe also we have different views on how accurate it has to be, mostly I just need a rough shell around some 3d-model.

I've added it to our (offline) import tool now as well, it's better off there. :-)

Best regards,
Ola