Fix T74648: Do not relax with 0 neighbors or no vertex normal

The mesh provided in the report has 0 area faces and overlapping
vertices, causing the relax code to fail when calculating the plane to
constraint the vertex movement. Now it works fine both in the brush and
in the mesh filter.

Reviewed By: jbakker

Maniphest Tasks: T74648

Differential Revision: https://developer.blender.org/D7109
This commit is contained in:
Pablo Dobarro 2020-03-11 13:36:20 +01:00
parent 088b92b92c
commit 88fd2b1dd5
Notes: blender-bot 2024-01-16 18:05:25 +01:00
Referenced by issue #74648, Face Sets smooth operation causes mesh chunks to disappear
1 changed files with 10 additions and 0 deletions

View File

@ -3661,6 +3661,10 @@ void SCULPT_relax_vertex(SculptSession *ss,
if (count > 0) {
mul_v3_fl(smooth_pos, 1.0f / (float)count);
}
else {
copy_v3_v3(r_final_pos, vd->co);
return;
}
float plane[4];
float smooth_closest_plane[3];
@ -3671,6 +3675,12 @@ void SCULPT_relax_vertex(SculptSession *ss,
else {
copy_v3_v3(vno, vd->fno);
}
if (is_zero_v3(vno)) {
copy_v3_v3(r_final_pos, vd->co);
return;
}
plane_from_point_normal_v3(plane, vd->co, vno);
closest_to_plane_v3(smooth_closest_plane, plane, smooth_pos);
sub_v3_v3v3(final_disp, smooth_closest_plane, vd->co);