Fix T89214: Smooth Vertices (Laplacian) produces NaN coordinates

Vertices with no connected faces would attempt to divide by the combined
face area causing a divide by zero.

Use the same weight for wire vertices as vertices connected
to zero area faces.
This commit is contained in:
Campbell Barton 2021-08-05 20:41:23 +10:00
parent 02e0c6f42e
commit ed9759349b
Notes: blender-bot 2023-02-14 00:20:19 +01:00
Referenced by issue #89214, Smooth Vertices (Laplacian) produces NaN coordinates for loose vertices and edges
1 changed files with 4 additions and 1 deletions

View File

@ -533,7 +533,10 @@ void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op)
EIG_linear_solver_right_hand_side_add(sys->context, 1, m_vertex_id, v->co[1]);
EIG_linear_solver_right_hand_side_add(sys->context, 2, m_vertex_id, v->co[2]);
i = m_vertex_id;
if (sys->zerola[i] == 0) {
if ((sys->zerola[i] == 0) &&
/* Non zero check is to account for vertices that aren't connected to a selected face.
* Without this wire edges become `nan`, see T89214. */
(sys->ring_areas[i] != 0.0f)) {
w = sys->vweights[i] * sys->ring_areas[i];
sys->vweights[i] = (w == 0.0f) ? 0.0f : -lambda_factor / (4.0f * w);
w = sys->vlengths[i];