Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc
| Show All 40 Lines | result = BKE_mesh_new_nomain_from_template( | ||||
| mesh, verts_num, edges_num, 0, loops_num, faces_num); | mesh, verts_num, edges_num, 0, loops_num, faces_num); | ||||
| } | } | ||||
| else { | else { | ||||
| result = BKE_mesh_new_nomain(verts_num, edges_num, 0, loops_num, faces_num); | result = BKE_mesh_new_nomain(verts_num, edges_num, 0, loops_num, faces_num); | ||||
| BKE_id_material_eval_ensure_default_slot(&result->id); | BKE_id_material_eval_ensure_default_slot(&result->id); | ||||
| } | } | ||||
| /* Copy vertices. */ | /* Copy vertices. */ | ||||
| MutableSpan<MVert> dst_verts = result->verts_for_write(); | MutableSpan<float3> dst_positions = result->vert_positions_for_write(); | ||||
| for (const int i : IndexRange(verts_num)) { | for (const int i : IndexRange(verts_num)) { | ||||
| float co[3]; | |||||
| int original_index; | int original_index; | ||||
| plConvexHullGetVertex(hull, i, co, &original_index); | plConvexHullGetVertex(hull, i, dst_positions[i], &original_index); | ||||
| if (original_index >= 0 && original_index < coords.size()) { | if (original_index >= 0 && original_index < coords.size()) { | ||||
| # if 0 /* Disabled because it only works for meshes, not predictable enough. */ | # if 0 /* Disabled because it only works for meshes, not predictable enough. */ | ||||
| /* Copy custom data on vertices, like vertex groups etc. */ | /* Copy custom data on vertices, like vertex groups etc. */ | ||||
| if (mesh && original_index < mesh->totvert) { | if (mesh && original_index < mesh->totvert) { | ||||
| CustomData_copy_data(&mesh->vdata, &result->vdata, int(original_index), int(i), 1); | CustomData_copy_data(&mesh->vdata, &result->vdata, int(original_index), int(i), 1); | ||||
| } | } | ||||
| # endif | # endif | ||||
| /* Copy the position of the original point. */ | |||||
| copy_v3_v3(dst_verts[i].co, co); | |||||
| } | } | ||||
| else { | else { | ||||
| BLI_assert_msg(0, "Unexpected new vertex in hull output"); | BLI_assert_msg(0, "Unexpected new vertex in hull output"); | ||||
| } | } | ||||
| } | } | ||||
| /* Copy edges and loops. */ | /* Copy edges and loops. */ | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||