Jump to content
  • entries
    943
  • comments
    5,899
  • views
    924,413

Convex Decomposition Made Useful


Josh

8,002 views

 Share

Physics simulations typically require physical geometry to be provided in a series of convex hulls that approximate the shape of the object. This is because the intersection of two convex objects can be calculated fast enough for use in real-time simulations.

 

One solution for creating this type of physical geometry is to create a low-detail model of the object in a modeling program. However, this process can be tedious and is often overlooked by artists. Auto-generating this type of geometry from the visual mesh itself would be ideal.

 

Convex decomposition is a technique that takes an artbitrary polygonal mesh and transforms it into a series of convex hulls. Unfortunately until recently such algorithms were unreliable and produced physics geometry that was far too high-detail for real-time physics, as shown in the image below:

 

blogentry-1-0-94984000-1418789193_thumb.png

 

One solution was to model a low-poly polygonal mesh and then run that through the convex decomposition routine. Although this relieved the artist from the requirement of modeling shapes as separate convex objects, it created a situation that was the worst of both worlds; physics geometry still had to be modeled by hand, but the unreliability of a convex decomposition algorithm also had to be accounted for. For this reason, I have chosen to avoid using this technique until now. However, physics geometry is our bottleneck right now in getting more content into Leadwerks, and this is a problem that has been on my mind.

 

VHACD is a new(er) convex decomposition library. Apparently it's been around for a while, but I've only heard of HACD until recently, which did not produce very usable results. VHACD works by converting polygonal geometry into voxel data and creating a series of convex shapes from this data. Integrating this into Leadwerks took just two days, as it was very similar to the old HACD code, which was integrated at one point, but never saw the light of day because I did not feel it was good enough to release. The results of the new algorithm are, in most cases, about as good as hand-modeled geometry. This is generated purely from the visual geometry, so there is no need to hand-model a low detail collision mesh:

 

blogentry-1-0-66361200-1418790672_thumb.jpg

 

blogentry-1-0-49524600-1418790678_thumb.jpg

 

blogentry-1-0-07864200-1418790687_thumb.jpg

 

blogentry-1-0-67944300-1418790691_thumb.jpg

 

blogentry-1-0-65131900-1418790696_thumb.jpg

 

You can try this feature out right now if you opt in to the beta branch on Steam, on Windows. Open a model in the editor and select the Tools > Convex Decomposition... menu item to open the convex decomposition dialog.

 

Thanks to Khaled Mamou and Julio Jerez for their work in this area.

  • Upvote 11
 Share

11 Comments


Recommended Comments

Haha, I feel that sometimes you just add things because they're cool. I'm not complaining though! This tool looks super useful, especially with the project I'm working on right now!

  • Upvote 1
Link to comment

This is actually really important because our bottleneck in getting new models into the engine is physics geometry. For some reason artists almost never create physics models, and don't seem to understand why it is necessary. So adding an auto-generated technique saves many hours of work so more content can make it into the Workshop faster. The sci-fi interior pack, for example, took about two days of tuning to make it game-ready.

  • Upvote 1
Link to comment

@nick This was actually a hot topic a few months ago and the workaround at the time was the CSG hints. This library was suggested then but I guess a new version is out now that's better than the last.

Link to comment

WELL DONE, Josh. Yes, building proper collision geo is one of those things that HAS to be done, and is actually somewhat of an art in itself to make these models both efficient AND representative of the visual model.

 

ANYTHING that helps the artist out in this area is a big plus!

Link to comment

@Rick Oh I was unaware of that!

Well, regardless, I still love these random cool little features that keep getting added since they really set this engine apart from others! I've never seen something like this before, but, like I said, it'll be really useful!

Link to comment

Is there a polygon limit? There are some situations where is almost covers the whole model properly, then it looks like it gives up.

Link to comment

Is there a polygon limit? There are some situations where is almost covers the whole model properly, then it looks like it gives up.

Not sure. There might be a max number of hulls set somewhere.

Link to comment

Sounds good, but it crashed the first time I tried it. Take the forklift model from the Vehicles pack. Run the decomposition, it will do a hard crash after a while.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...