Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| for (const int i : IndexRange(tot_loop)) { | for (const int i : IndexRange(tot_loop)) { | ||||
| indices.append_unchecked(src_loop_start + i); | indices.append_unchecked(src_loop_start + i); | ||||
| } | } | ||||
| } | } | ||||
| copy_attributes_based_on_mask( | copy_attributes_based_on_mask( | ||||
| attributes, src_attributes, dst_attributes, ATTR_DOMAIN_CORNER, IndexMask(indices)); | attributes, src_attributes, dst_attributes, ATTR_DOMAIN_CORNER, IndexMask(indices)); | ||||
| } | } | ||||
| static void copy_masked_verts_to_new_mesh(const Mesh &src_mesh, | |||||
| Mesh &dst_mesh, | |||||
| Span<int> vertex_map) | |||||
| { | |||||
| BLI_assert(src_mesh.totvert == vertex_map.size()); | |||||
| const Span<MVert> src_verts = src_mesh.verts(); | |||||
| MutableSpan<MVert> dst_verts = dst_mesh.verts_for_write(); | |||||
| for (const int i_src : vertex_map.index_range()) { | |||||
| const int i_dst = vertex_map[i_src]; | |||||
| if (i_dst == -1) { | |||||
| continue; | |||||
| } | |||||
| dst_verts[i_dst] = src_verts[i_src]; | |||||
| } | |||||
| } | |||||
| static void copy_masked_edges_to_new_mesh(const Mesh &src_mesh, Mesh &dst_mesh, Span<int> edge_map) | static void copy_masked_edges_to_new_mesh(const Mesh &src_mesh, Mesh &dst_mesh, Span<int> edge_map) | ||||
| { | { | ||||
| BLI_assert(src_mesh.totedge == edge_map.size()); | BLI_assert(src_mesh.totedge == edge_map.size()); | ||||
| const Span<MEdge> src_edges = src_mesh.edges(); | const Span<MEdge> src_edges = src_mesh.edges(); | ||||
| MutableSpan<MEdge> dst_edges = dst_mesh.edges_for_write(); | MutableSpan<MEdge> dst_edges = dst_mesh.edges_for_write(); | ||||
| for (const int i_src : IndexRange(src_mesh.totedge)) { | for (const int i_src : IndexRange(src_mesh.totedge)) { | ||||
| const int i_dst = edge_map[i_src]; | const int i_dst = edge_map[i_src]; | ||||
| ▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | |||||
| mesh_out = BKE_mesh_new_nomain_from_template(&mesh_in, | mesh_out = BKE_mesh_new_nomain_from_template(&mesh_in, | ||||
| selected_verts_num, | selected_verts_num, | ||||
| selected_edges_num, | selected_edges_num, | ||||
| 0, | 0, | ||||
| selected_loops_num, | selected_loops_num, | ||||
| selected_polys_num); | selected_polys_num); | ||||
| /* Copy the selected parts of the mesh over to the new mesh. */ | /* Copy the selected parts of the mesh over to the new mesh. */ | ||||
| copy_masked_verts_to_new_mesh(mesh_in, *mesh_out, vertex_map); | |||||
| copy_masked_edges_to_new_mesh(mesh_in, *mesh_out, vertex_map, edge_map); | copy_masked_edges_to_new_mesh(mesh_in, *mesh_out, vertex_map, edge_map); | ||||
| copy_masked_polys_to_new_mesh( | copy_masked_polys_to_new_mesh( | ||||
| mesh_in, *mesh_out, vertex_map, edge_map, selected_poly_indices, new_loop_starts); | mesh_in, *mesh_out, vertex_map, edge_map, selected_poly_indices, new_loop_starts); | ||||
| /* Copy attributes. */ | /* Copy attributes. */ | ||||
| copy_attributes_based_on_map(attributes, | copy_attributes_based_on_map(attributes, | ||||
| mesh_in.attributes(), | mesh_in.attributes(), | ||||
| mesh_out->attributes_for_write(), | mesh_out->attributes_for_write(), | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | |||||
| mesh_out = BKE_mesh_new_nomain_from_template(&mesh_in, | mesh_out = BKE_mesh_new_nomain_from_template(&mesh_in, | ||||
| mesh_in.totvert, | mesh_in.totvert, | ||||
| selected_edges_num, | selected_edges_num, | ||||
| 0, | 0, | ||||
| selected_loops_num, | selected_loops_num, | ||||
| selected_polys_num); | selected_polys_num); | ||||
| /* Copy the selected parts of the mesh over to the new mesh. */ | /* Copy the selected parts of the mesh over to the new mesh. */ | ||||
| mesh_out->verts_for_write().copy_from(mesh_in.verts()); | mesh_out->vert_positions_for_write().copy_from(mesh_in.vert_positions()); | ||||
| copy_masked_edges_to_new_mesh(mesh_in, *mesh_out, edge_map); | copy_masked_edges_to_new_mesh(mesh_in, *mesh_out, edge_map); | ||||
| copy_masked_polys_to_new_mesh( | copy_masked_polys_to_new_mesh( | ||||
| mesh_in, *mesh_out, edge_map, selected_poly_indices, new_loop_starts); | mesh_in, *mesh_out, edge_map, selected_poly_indices, new_loop_starts); | ||||
| /* Copy attributes. */ | /* Copy attributes. */ | ||||
| copy_attributes( | copy_attributes( | ||||
| attributes, mesh_in.attributes(), mesh_out->attributes_for_write(), {ATTR_DOMAIN_POINT}); | attributes, mesh_in.attributes(), mesh_out->attributes_for_write(), {ATTR_DOMAIN_POINT}); | ||||
| copy_attributes_based_on_map(attributes, | copy_attributes_based_on_map(attributes, | ||||
| ▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
| default: | default: | ||||
| BLI_assert_unreachable(); | BLI_assert_unreachable(); | ||||
| break; | break; | ||||
| } | } | ||||
| mesh_out = BKE_mesh_new_nomain_from_template( | mesh_out = BKE_mesh_new_nomain_from_template( | ||||
| &mesh_in, mesh_in.totvert, mesh_in.totedge, 0, selected_loops_num, selected_polys_num); | &mesh_in, mesh_in.totvert, mesh_in.totedge, 0, selected_loops_num, selected_polys_num); | ||||
| /* Copy the selected parts of the mesh over to the new mesh. */ | /* Copy the selected parts of the mesh over to the new mesh. */ | ||||
| mesh_out->verts_for_write().copy_from(mesh_in.verts()); | mesh_out->vert_positions_for_write().copy_from(mesh_in.vert_positions()); | ||||
| mesh_out->edges_for_write().copy_from(mesh_in.edges()); | mesh_out->edges_for_write().copy_from(mesh_in.edges()); | ||||
| copy_masked_polys_to_new_mesh(mesh_in, *mesh_out, selected_poly_indices, new_loop_starts); | copy_masked_polys_to_new_mesh(mesh_in, *mesh_out, selected_poly_indices, new_loop_starts); | ||||
| /* Copy attributes. */ | /* Copy attributes. */ | ||||
| copy_attributes(attributes, | copy_attributes(attributes, | ||||
| mesh_in.attributes(), | mesh_in.attributes(), | ||||
| mesh_out->attributes_for_write(), | mesh_out->attributes_for_write(), | ||||
| {ATTR_DOMAIN_POINT, ATTR_DOMAIN_EDGE}); | {ATTR_DOMAIN_POINT, ATTR_DOMAIN_EDGE}); | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||