From 312516d53e27f018bd9153e54f7afbb42a013de7 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 5 Mar 2025 21:18:45 +0100 Subject: [PATCH] Fix #135517: Geometry nodes convex hull imprecision The equivalent operation in edit mode reused existing vertices rather than taking the new positions from the convex hull output. This commit implements the same behavior for the geometry node. Pull Request: https://projects.blender.org/blender/blender/pulls/135536 --- .../geometry/nodes/node_geo_convex_hull.cc | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc b/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc index 50c95e23901..3005ce10cf5 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc @@ -52,20 +52,15 @@ static Mesh *hull_from_bullet(const Mesh *mesh, Span coords) /* Copy vertices. */ MutableSpan dst_positions = result->vert_positions_for_write(); for (const int i : IndexRange(verts_num)) { + float3 dummy_co; int original_index; - plConvexHullGetVertex(hull, i, dst_positions[i], &original_index); - - if (original_index >= 0 && original_index < coords.size()) { -# if 0 /* Disabled because it only works for meshes, not predictable enough. */ - /* Copy custom data on vertices, like vertex groups etc. */ - if (mesh && original_index < mesh->verts_num) { - CustomData_copy_data(&mesh->vert_data, &result->vert_data, int(original_index), int(i), 1); - } -# endif - } - else { - BLI_assert_msg(0, "Unexpected new vertex in hull output"); + plConvexHullGetVertex(hull, i, dummy_co, &original_index); + if (UNLIKELY(!coords.index_range().contains(original_index))) { + BLI_assert_unreachable(); + dst_positions[i] = float3(0); + continue; } + dst_positions[i] = coords[original_index]; } /* Copy edges and loops. */