Jump to content

Advances in approximate convex decomposition, or how to get better physics models.


You are about to reply to a thread that has been inactive for 249 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Second Life has much trouble with bad physics models. The system for generating them automatically during mesh upload is not that great. It's a hard problem.

There's been recent research work on solving that. Google seems to be funding work in the field, partly because they need this for Google Earth.

New papers, both from 2022:

Looks like there's been considerable progress. The big advance is doing approximate convex decomposition, where it's OK if there's a little overlap between the parts. If you go for exact decomposition, as Havok does, the joints get complicated. For collision purposes, a little overlap is not a problem.

The second paper has some useful pictures.

convexdecomp1.thumb.jpg.a6a4db0badfb0a762423924ca756569a.jpg

The input is a single mesh, and the output is multiple convex (no inward dents) meshes, shown in different colors. Convex meshes are suitable for SL's collision system. (Convex hull intersections are fast to compute. See "GJK algorithm" for the theory. That's what everybody serious, including Havok, uses.)

This approach seems to get the classic hard cases right. The Havok decomposition has a hard time with simple cases such as a house with four walls, let alone one with a door and windows. This system seems to do better.

convexdecomp2.thumb.jpg.370226d3dd7d35d216e5a444c15babe8.jpg

Harder cases, with the accuracy turned down. This looks promising. If you turn the accuracy way down, something reasonable still comes out. That's what we need.

Of course, these are the author's test cases. Anyone want to build the code and run some models through it? The program takes .obj format, so if you have it in Blender, you can try it with this program.

SL viewers that upload content send this info as a "Physics Convex Block". Currently, Havok code in the viewer generates those, but a new approach could be substituted.

  • Like 3
  • Thanks 2
Link to comment
Share on other sites

escalatortest1.thumb.png.33e35e263af33881396340211f793202.png

First try of this convex decomposition program. This is the frame from one of my escalators. (No steps; those are a separate part.)

  • On the right, the original.
  • In the middle, the default reduction to convex hulls. This resulted in 24 hulls. Would be an OK physics model.
  • On the left, forced down to 8 hulls. Except for that bump at the top left, which would get avatars stuck on the escalator, it's fine. 8 was too small.

Looks OK so far. Its choices on where to cut are reasonable. Try it yourself. I used the Python 3 version, listed under PyPi here.

Creators, please try some of your own models and post the results. Thanks.

  • Thanks 1
Link to comment
Share on other sites

housetest1.thumb.png.f0e60c74c1d05a7e7c4c9104731d404f.png

We have a problem. Original model of simple building on right. Generated convex decomposition on left.

This isn't good. Three walls and the floor were already convex, and they were subdivided, for no good reason.

Bug report submitted.

Link to comment
Share on other sites

triangulatedtest.thumb.png.6b2e736fe2c9edf998329020346ba4a6.png

Some progress. Turns out that the input must be subdivided into triangles, not polygons, but the program doesn't check for that.

On the right, the original. Center, convex hulls with default settings. On the left, asked for more precision.

It tends to shrink holes unless the precision is turned up to max. Then it generates too many hulls. Adjacent hull merging does not seem to be working properly. Tends to round sharp edges and generate unnecessary triangles, which would run up the SL physics cost. The developer is looking into this.

It's promising, but it needs a better clean-up phase. Too early to say if this is a viable solution for SL.

Link to comment
Share on other sites

  • 2 weeks later...

A bit more progress.

goodhull1.thumb.png.07f2d14c066a2957a3b14a00535286f2.png

Finally, a good convex hull decomposition. 10 hulls. Even if the window is slightly off.

This was made by:

  • Create model in Blender.
  • Clean it up until it's a valid manifold. Watertight solid, all normals correct. Blender has a "Manifold" checker that can tell you if your model is watertight, but it doesn't fix it for you.
  • Triangulate. Must be triangles, not polygons.
  • Export to .obj format.
  • ./coacd -i work/house1atriang.obj -o house1atriangphy5b.obj -pm off -md 7 -t 0.02

Takes about 3 seconds.

  • Import new .obj file back into Blender.

The program is rather brittle academic software. If you don't triangulate the input, the output is terrible, but you don't get any error messages. The program is supposed to be able to cope with non-manifold geometry, but that feature rounds square corners and messes things up. "-pm off" turns that off.

So the theory is coming along, but the code needs some work. I'll try some harder cases soon. I've tried my escalator frame, and it's not bad except for parts that are not a valid manifold. Have to fix those and try again.

Probably the most useful form of this for now would be as a Blender plug-in to help make SL physics models. It's not ready to be part of the uploader. Nice to see advances in the technology, though.

Edited by animats
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 249 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...