diff --git a/source/blender/geometry/intern/mesh_merge_by_distance.cc b/source/blender/geometry/intern/mesh_merge_by_distance.cc index fbd06791bd8..f0f1e02ae1d 100644 --- a/source/blender/geometry/intern/mesh_merge_by_distance.cc +++ b/source/blender/geometry/intern/mesh_merge_by_distance.cc @@ -836,9 +836,9 @@ static void weld_poly_loop_ctx_alloc(Span mpoly, poly_map[i] = wpoly_len++; if (totloop > 5 && vert_ctx_len > 1) { - int max_new = (totloop / 3) - 1; - vert_ctx_len /= 2; - maybe_new_poly += MIN2(max_new, vert_ctx_len); + /* Each untouched vertex pair is a candidate for a new polygon. */ + int max_new = std::min(vert_ctx_len, (totloop - vert_ctx_len) / 2); + maybe_new_poly += max_new; CLAMP_MIN(max_ctx_poly_len, totloop); } }