You can use BVH trees and ray_cast() and overlap() to solve clipping issues automatically like DAZ does

Issue #309 on hold
Xin created an issue

I attached a simple example .blend with a script that demonstrates such method. It’s a proof of concept, I haven’t tweaked parameters that much and the method can be refined more (for example, by painting based on distance to the hits of the ray casts). The good thing about this is that the clipping is solved locally depending on the pose. Other solutions so far require either tedious manual painting, or affect the whole mesh creating too much deformation from the original (like the shrinkwrap or push). Even Shrinkwrap with “outside” snap mode doesn’t give enough control over the result since it affects the whole mesh uniformly if you don’t do tedious manual painting to increase or decrease the effect on certain polygons for a more organic result or even a decent result.

Also, this method can be iterated to solve many clipping issues almost completely while achieving a more natural result. But I didn’t implement iterations here. Daz has similar functionality. Another alternative for this method would be to use a Shrinkwrap modifier instead of the Displace modifier I used.

Comments (9)

  1. Thomas Larsson repo owner

    This interesting food for thought, but I will not implement it right now. I hope to make a stable release soon, and don’t want to introduce anything as complex as this at this time. It is also not clear to me how the UI should look. For still shots one could imagine a button which recalculates the displace vertex groups, but how to do it for animations. A handler that is called automatically after frame change, perhaps.

  2. Xin reporter

    Yeah, I just wanted to point it out so you were aware in case you wanted to do something in that area in the future, but it’s not really a big issue. Also, it still requires quite some polishing and testing, like handling double sided clothing. Maybe use the “distance” parameter on ray_cast() so the side facing towards the character doesn’t mistakenly detect a hit on the other side of the character when inside the character? maybe also ray_cast() the clothing to itself to detect close polygons and propagate vertex weights across a small thickness (Blender’s vertex weight smoothing only propagates along close connected faces)? or try to infer which polygons are hidden by the result of overlap() alone? or maybe think of an iterative approach that relies on overlap() alone, like pulling overlapped faces and calling overlap() again, and so on?

    In any case, it still requires some thought and experimentation.

    I was also thinking about it being a button, I don’t like how daz recalculates constantly by default since it slows down the viewport too much, no reason to replicate that sluggish and intrusive behavior. As for animations, I think you are right, you would need something to handle frame change (and applying the fix to the finished frame) otherwise it would be too tedious to have to press the button each time.

  3. Log in to comment