Updates for blender-mat-addon

Simple Degenerated Slab Detection

Assume a medial slab:

Case 1

In this case, the main geometric feature is that the length of edges are much smaller than the radius of spheres at it ends. If only 1 edge meets this condition, the slab will degenerate into a cone. If more than 1 edge meets the condition, the slab will degenerate into a single sphere.

A slab degenerates into a single sphere.

To detect this case, we can simply use the ratio between the radius to filter this situation:

here, the threshold is set to 5%. This detection strategy is very simple and the value of is hard coded. Although it works fine for me, but it still requires further improvements.

Case 2

This case is designed for a medial sphere is inside the cone formed by other two spheres. illustration.001 As the figure shows, the space can be divided two parts by the conical surface. If the third sphere falls in the inside region, then the slab should degenerated into a cone.

Detection

Assume .

illustration2

It's intuitive that if , will be inside the cone.

First, compute (detailed in this post). Then compute the distance :

where is the closest point on line to and is the linear interpolation parameter.

To compute , we need to move the point towards by :

Then, we can compute the real interpolation parameter and as

Finally, the distance from to the conical surface is .

To be mentioned, is not clamped in 0-1, so it can handle more general cases as shown in the figure below.