Mask: Fix possible nan values in the weight interpolation

Noticed while looking into animation data being created as per
steps to reproduce bug in T76872.
This commit is contained in:
Sergey Sharybin 2021-03-29 15:46:48 +02:00
parent 10e05bb413
commit 51f8dbe081
1 changed files with 8 additions and 1 deletions

View File

@ -1893,10 +1893,17 @@ static void interp_weights_uv_v2_calc(float r_uv[2],
const float pt_a[2],
const float pt_b[2])
{
const float segment_len = len_v2v2(pt_a, pt_b);
if (segment_len == 0.0f) {
r_uv[0] = 1.0f;
r_uv[1] = 0.0f;
return;
}
float pt_on_line[2];
r_uv[0] = closest_to_line_v2(pt_on_line, pt, pt_a, pt_b);
r_uv[1] = (len_v2v2(pt_on_line, pt) / len_v2v2(pt_a, pt_b)) *
r_uv[1] = (len_v2v2(pt_on_line, pt) / segment_len) *
/* This line only sets the sign. */
((line_point_side_v2(pt_a, pt_b, pt) < 0.0f) ? -1.0f : 1.0f);
}