diff options
Diffstat (limited to 'source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc')
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc index 0062abba909..9bb824dbf7f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc @@ -230,7 +230,7 @@ static void extrude_mesh_vertices(Mesh &mesh, const IndexRange new_vert_range{orig_vert_size, selection.size()}; const IndexRange new_edge_range{orig_edge_size, selection.size()}; - MutableSpan<MVert> new_verts = mesh.verts_for_write().slice(new_vert_range); + MutableSpan<float3> new_positions = mesh.positions_for_write().slice(new_vert_range); MutableSpan<MEdge> new_edges = mesh.edges_for_write().slice(new_edge_range); for (const int i_selection : selection.index_range()) { @@ -274,8 +274,7 @@ static void extrude_mesh_vertices(Mesh &mesh, devirtualize_varray(offsets, [&](const auto offsets) { threading::parallel_for(selection.index_range(), 1024, [&](const IndexRange range) { for (const int i : range) { - const float3 offset = offsets[selection[i]]; - add_v3_v3(new_verts[i].co, offset); + new_positions[i] += offsets[selection[i]]; } }); }); @@ -599,19 +598,19 @@ static void extrude_mesh_edges(Mesh &mesh, return true; }); - MutableSpan<MVert> new_verts = mesh.verts_for_write().slice(new_vert_range); + MutableSpan<float3> new_positions = mesh.positions_for_write().slice(new_vert_range); if (edge_offsets.is_single()) { const float3 offset = edge_offsets.get_internal_single(); - threading::parallel_for(new_verts.index_range(), 1024, [&](const IndexRange range) { + threading::parallel_for(new_positions.index_range(), 1024, [&](const IndexRange range) { for (const int i : range) { - add_v3_v3(new_verts[i].co, offset); + new_positions[i] += offset; } }); } else { - threading::parallel_for(new_verts.index_range(), 1024, [&](const IndexRange range) { + threading::parallel_for(new_positions.index_range(), 1024, [&](const IndexRange range) { for (const int i : range) { - add_v3_v3(new_verts[i].co, vert_offsets[new_vert_indices[i]]); + new_positions[i] += vert_offsets[new_vert_indices[i]]; } }); } @@ -976,15 +975,19 @@ static void extrude_mesh_face_regions(Mesh &mesh, /* Translate vertices based on the offset. If the vertex is used by a selected edge, it will * have been duplicated and only the new vertex should use the offset. Otherwise the vertex might * still need an offset, but it was reused on the inside of a region of extruded faces. */ - MutableSpan<MVert> verts = mesh.verts_for_write(); + MutableSpan<float3> positions = mesh.positions_for_write(); if (poly_offsets.is_single()) { const float3 offset = poly_offsets.get_internal_single(); threading::parallel_for( IndexRange(all_selected_verts.size()), 1024, [&](const IndexRange range) { for (const int i_orig : all_selected_verts.as_span().slice(range)) { const int i_new = new_vert_indices.index_of_try(i_orig); - MVert &vert = verts[(i_new == -1) ? i_orig : new_vert_range[i_new]]; - add_v3_v3(vert.co, offset); + if (i_new == -1) { + positions[i_orig] += offset; + } + else { + positions[new_vert_range[i_new]] += offset; + } } }); } @@ -994,8 +997,12 @@ static void extrude_mesh_face_regions(Mesh &mesh, for (const int i_orig : all_selected_verts.as_span().slice(range)) { const int i_new = new_vert_indices.index_of_try(i_orig); const float3 offset = vert_offsets[i_orig]; - MVert &vert = verts[(i_new == -1) ? i_orig : new_vert_range[i_new]]; - add_v3_v3(vert.co, offset); + if (i_new == -1) { + positions[i_orig] += offset; + } + else { + positions[new_vert_range[i_new]] += offset; + } } }); } @@ -1078,7 +1085,7 @@ static void extrude_individual_mesh_faces(Mesh &mesh, side_poly_range.size(), side_loop_range.size()); - MutableSpan<MVert> new_verts = mesh.verts_for_write().slice(new_vert_range); + MutableSpan<float3> new_positions = mesh.positions_for_write().slice(new_vert_range); MutableSpan<MEdge> edges = mesh.edges_for_write(); MutableSpan<MEdge> connect_edges = edges.slice(connect_edge_range); MutableSpan<MEdge> duplicate_edges = edges.slice(duplicate_edge_range); @@ -1258,8 +1265,8 @@ static void extrude_individual_mesh_faces(Mesh &mesh, threading::parallel_for(poly_selection.index_range(), 1024, [&](const IndexRange range) { for (const int i_selection : range) { const IndexRange poly_corner_range = selected_corner_range(index_offsets, i_selection); - for (MVert &vert : new_verts.slice(poly_corner_range)) { - add_v3_v3(vert.co, poly_offset[poly_selection[i_selection]]); + for (float3 &position : new_positions.slice(poly_corner_range)) { + position += poly_offset[poly_selection[i_selection]]; } } }); |