diff options
Diffstat (limited to 'source/blender/nodes/geometry/nodes')
23 files changed, 135 insertions, 178 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 278d7c4bd24..2e0556024ea 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc @@ -46,11 +46,10 @@ static Mesh *hull_from_bullet(const Mesh *mesh, Span<float3> coords) } /* Copy vertices. */ - MutableSpan<MVert> dst_verts = result->verts_for_write(); + MutableSpan<float3> dst_positions = result->positions_for_write(); for (const int i : IndexRange(verts_num)) { - float co[3]; 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 0 /* Disabled because it only works for meshes, not predictable enough. */ @@ -59,8 +58,6 @@ static Mesh *hull_from_bullet(const Mesh *mesh, Span<float3> coords) CustomData_copy_data(&mesh->vdata, &result->vdata, int(original_index), int(i), 1); } # endif - /* Copy the position of the original point. */ - copy_v3_v3(dst_verts[i].co, co); } else { BLI_assert_msg(0, "Unexpected new vertex in hull output"); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc index a14661b4a50..9a45466be19 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc @@ -79,13 +79,13 @@ static Mesh *cdt_to_mesh(const meshintersect::CDT_result<double> &result) } Mesh *mesh = BKE_mesh_new_nomain(vert_len, edge_len, 0, loop_len, poly_len); - MutableSpan<MVert> verts = mesh->verts_for_write(); + MutableSpan<float3> positions = mesh->positions_for_write(); MutableSpan<MEdge> edges = mesh->edges_for_write(); MutableSpan<MPoly> polys = mesh->polys_for_write(); MutableSpan<MLoop> loops = mesh->loops_for_write(); for (const int i : IndexRange(result.vert.size())) { - copy_v3_v3(verts[i].co, float3(float(result.vert[i].x), float(result.vert[i].y), 0.0f)); + positions[i] = float3(float(result.vert[i].x), float(result.vert[i].y), 0.0f); } for (const int i : IndexRange(result.edge.size())) { edges[i].v1 = result.edge[i].first; diff --git a/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc b/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc index dabd2a1a9f2..7a63aa59509 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc @@ -66,10 +66,10 @@ static void deform_curves(const CurvesGeometry &curves, const float4x4 curves_to_surface = surface_to_curves.inverted(); - const Span<MVert> surface_verts_old = surface_mesh_old.verts(); + const Span<float3> surface_positions_old = surface_mesh_old.positions(); const Span<MLoop> surface_loops_old = surface_mesh_old.loops(); - const Span<MVert> surface_verts_new = surface_mesh_new.verts(); + const Span<float3> surface_positions_new = surface_mesh_new.positions(); const Span<MLoop> surface_loops_new = surface_mesh_new.loops(); threading::parallel_for(curves.curves_range(), 256, [&](const IndexRange range) { @@ -118,14 +118,14 @@ static void deform_curves(const CurvesGeometry &curves, const float3 normal_new = math::normalize( mix3(bary_weights_new, normal_0_new, normal_1_new, normal_2_new)); - const float3 &pos_0_old = surface_verts_old[vert_0_old].co; - const float3 &pos_1_old = surface_verts_old[vert_1_old].co; - const float3 &pos_2_old = surface_verts_old[vert_2_old].co; + const float3 &pos_0_old = surface_positions_old[vert_0_old]; + const float3 &pos_1_old = surface_positions_old[vert_1_old]; + const float3 &pos_2_old = surface_positions_old[vert_2_old]; const float3 pos_old = mix3(bary_weights_old, pos_0_old, pos_1_old, pos_2_old); - const float3 &pos_0_new = surface_verts_new[vert_0_new].co; - const float3 &pos_1_new = surface_verts_new[vert_1_new].co; - const float3 &pos_2_new = surface_verts_new[vert_2_new].co; + const float3 &pos_0_new = surface_positions_new[vert_0_new]; + const float3 &pos_1_new = surface_positions_new[vert_1_new]; + const float3 &pos_2_new = surface_positions_new[vert_2_new]; const float3 pos_new = mix3(bary_weights_new, pos_0_new, pos_1_new, pos_2_new); /* The translation is just the difference between the old and new position on the surface. */ diff --git a/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc index 8ed97f2019f..bccf0cd46ce 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc @@ -153,23 +153,6 @@ static void copy_face_corner_attributes(const Map<AttributeIDRef, AttributeKind> 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) { BLI_assert(src_mesh.totedge == edge_map.size()); @@ -891,7 +874,6 @@ static void do_mesh_separation(GeometrySet &geometry_set, selected_polys_num); /* 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_polys_to_new_mesh( mesh_in, *mesh_out, vertex_map, edge_map, selected_poly_indices, new_loop_starts); @@ -968,7 +950,7 @@ static void do_mesh_separation(GeometrySet &geometry_set, selected_polys_num); /* Copy the selected parts of the mesh over to the new mesh. */ - mesh_out->verts_for_write().copy_from(mesh_in.verts()); + mesh_out->positions_for_write().copy_from(mesh_in.positions()); copy_masked_edges_to_new_mesh(mesh_in, *mesh_out, edge_map); copy_masked_polys_to_new_mesh( mesh_in, *mesh_out, edge_map, selected_poly_indices, new_loop_starts); @@ -1029,7 +1011,7 @@ static void do_mesh_separation(GeometrySet &geometry_set, &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. */ - mesh_out->verts_for_write().copy_from(mesh_in.verts()); + mesh_out->positions_for_write().copy_from(mesh_in.positions()); 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); diff --git a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc index 7c9501608a3..8d23be28928 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc @@ -105,7 +105,7 @@ static void sample_mesh_surface(const Mesh &mesh, Vector<float3> &r_bary_coords, Vector<int> &r_looptri_indices) { - const Span<MVert> verts = mesh.verts(); + const Span<float3> positions = mesh.positions(); const Span<MLoop> loops = mesh.loops(); const Span<MLoopTri> looptris = mesh.looptris(); @@ -117,9 +117,9 @@ static void sample_mesh_surface(const Mesh &mesh, const int v0_index = loops[v0_loop].v; const int v1_index = loops[v1_loop].v; const int v2_index = loops[v2_loop].v; - const float3 v0_pos = verts[v0_index].co; - const float3 v1_pos = verts[v1_index].co; - const float3 v2_pos = verts[v2_index].co; + const float3 v0_pos = positions[v0_index]; + const float3 v1_pos = positions[v1_index]; + const float3 v2_pos = positions[v2_index]; float looptri_density_factor = 1.0f; if (!density_factors.is_empty()) { @@ -348,7 +348,7 @@ BLI_NOINLINE static void compute_attribute_outputs(const Mesh &mesh, attribute_outputs.rotation_id.get(), ATTR_DOMAIN_POINT); } - const Span<MVert> verts = mesh.verts(); + const Span<float3> positions = mesh.positions(); const Span<MLoop> loops = mesh.loops(); const Span<MLoopTri> looptris = mesh.looptris(); @@ -360,9 +360,9 @@ BLI_NOINLINE static void compute_attribute_outputs(const Mesh &mesh, const int v0_index = loops[looptri.tri[0]].v; const int v1_index = loops[looptri.tri[1]].v; const int v2_index = loops[looptri.tri[2]].v; - const float3 v0_pos = verts[v0_index].co; - const float3 v1_pos = verts[v1_index].co; - const float3 v2_pos = verts[v2_index].co; + const float3 v0_pos = positions[v0_index]; + const float3 v1_pos = positions[v1_index]; + const float3 v2_pos = positions[v2_index]; ids.span[i] = noise::hash(noise::hash_float(bary_coord), looptri_index); diff --git a/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc index 9b1c13bf563..bf018e1e04f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc @@ -627,7 +627,7 @@ static void calc_dual_mesh(GeometrySet &geometry_set, const bool keep_boundaries) { const Mesh &mesh_in = *in_component.get_for_read(); - const Span<MVert> src_verts = mesh_in.verts(); + const Span<float3> src_positions = mesh_in.positions(); const Span<MEdge> src_edges = mesh_in.edges(); const Span<MPoly> src_polys = mesh_in.polys(); const Span<MLoop> src_loops = mesh_in.loops(); @@ -695,8 +695,10 @@ static void calc_dual_mesh(GeometrySet &geometry_set, Vector<float3> vertex_positions(mesh_in.totpoly); for (const int i : IndexRange(mesh_in.totpoly)) { const MPoly &poly = src_polys[i]; - BKE_mesh_calc_poly_center( - &poly, &src_loops[poly.loopstart], src_verts.data(), vertex_positions[i]); + BKE_mesh_calc_poly_center(&poly, + &src_loops[poly.loopstart], + reinterpret_cast<const float(*)[3]>(src_positions.data()), + vertex_positions[i]); } Array<int> boundary_edge_midpoint_index; @@ -706,9 +708,8 @@ static void calc_dual_mesh(GeometrySet &geometry_set, /* We need to add vertices at the centers of boundary edges. */ for (const int i : IndexRange(mesh_in.totedge)) { if (edge_types[i] == EdgeType::Boundary) { - float3 mid; const MEdge &edge = src_edges[i]; - mid_v3_v3v3(mid, src_verts[edge.v1].co, src_verts[edge.v2].co); + const float3 mid = math::midpoint(src_positions[edge.v1], src_positions[edge.v2]); boundary_edge_midpoint_index[i] = vertex_positions.size(); vertex_positions.append(mid); } @@ -859,7 +860,7 @@ static void calc_dual_mesh(GeometrySet &geometry_set, new_to_old_face_corners_map.append(sorted_corners.first()); boundary_vertex_to_relevant_face_map.append( std::pair(loop_indices.last(), last_face_center)); - vertex_positions.append(src_verts[i].co); + vertex_positions.append(src_positions[i]); const int boundary_vertex = loop_indices.last(); add_edge(src_edges, edge1, @@ -913,7 +914,7 @@ static void calc_dual_mesh(GeometrySet &geometry_set, mesh_in.attributes(), mesh_out->attributes_for_write()); - MutableSpan<MVert> dst_verts = mesh_out->verts_for_write(); + mesh_out->positions_for_write().copy_from(vertex_positions); MutableSpan<MEdge> dst_edges = mesh_out->edges_for_write(); MutableSpan<MPoly> dst_polys = mesh_out->polys_for_write(); MutableSpan<MLoop> dst_loops = mesh_out->loops_for_write(); @@ -928,9 +929,6 @@ static void calc_dual_mesh(GeometrySet &geometry_set, dst_loops[i].v = loops[i]; dst_loops[i].e = loop_edges[i]; } - for (const int i : IndexRange(mesh_out->totvert)) { - copy_v3_v3(dst_verts[i].co, vertex_positions[i]); - } dst_edges.copy_from(new_edges); geometry_set.replace_mesh(mesh_out); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc index f048ec11f77..891f50c6a2c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc @@ -514,7 +514,6 @@ static void duplicate_faces(GeometrySet &geometry_set, geometry_set.keep_only_during_modify({GEO_COMPONENT_TYPE_MESH}); const Mesh &mesh = *geometry_set.get_mesh_for_read(); - const Span<MVert> verts = mesh.verts(); const Span<MEdge> edges = mesh.edges(); const Span<MPoly> polys = mesh.polys(); const Span<MLoop> loops = mesh.loops(); @@ -539,12 +538,11 @@ static void duplicate_faces(GeometrySet &geometry_set, offsets[selection.size()] = total_polys; Mesh *new_mesh = BKE_mesh_new_nomain(total_loops, total_loops, 0, total_loops, total_polys); - MutableSpan<MVert> new_verts = new_mesh->verts_for_write(); MutableSpan<MEdge> new_edges = new_mesh->edges_for_write(); MutableSpan<MPoly> new_polys = new_mesh->polys_for_write(); MutableSpan<MLoop> new_loops = new_mesh->loops_for_write(); - Array<int> vert_mapping(new_verts.size()); + Array<int> vert_mapping(new_mesh->totvert); Array<int> edge_mapping(new_edges.size()); Array<int> loop_mapping(new_loops.size()); @@ -560,7 +558,6 @@ static void duplicate_faces(GeometrySet &geometry_set, for (const int i_loops : IndexRange(source.totloop)) { const MLoop ¤t_loop = loops[source.loopstart + i_loops]; loop_mapping[loop_index] = source.loopstart + i_loops; - new_verts[loop_index] = verts[current_loop.v]; vert_mapping[loop_index] = current_loop.v; new_edges[loop_index] = edges[current_loop.e]; edge_mapping[loop_index] = current_loop.e; @@ -886,10 +883,9 @@ static void duplicate_points_mesh(GeometrySet &geometry_set, const IndexAttributes &attribute_outputs) { const Mesh &mesh = *geometry_set.get_mesh_for_read(); - const Span<MVert> src_verts = mesh.verts(); bke::MeshFieldContext field_context{mesh, ATTR_DOMAIN_POINT}; - FieldEvaluator evaluator{field_context, src_verts.size()}; + FieldEvaluator evaluator{field_context, mesh.totvert}; evaluator.add(count_field); evaluator.set_selection(selection_field); evaluator.evaluate(); @@ -899,9 +895,6 @@ static void duplicate_points_mesh(GeometrySet &geometry_set, Array<int> offsets = accumulate_counts_to_offsets(selection, counts); Mesh *new_mesh = BKE_mesh_new_nomain(offsets.last(), 0, 0, 0, 0); - MutableSpan<MVert> dst_verts = new_mesh->verts_for_write(); - - threaded_slice_fill(offsets.as_span(), selection, src_verts, dst_verts); copy_attributes_without_id(geometry_set, GEO_COMPONENT_TYPE_MESH, 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]]; } } }); diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_angle.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_angle.cc index 29730ab8dc4..c0ccd2f2570 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_angle.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_angle.cc @@ -64,20 +64,27 @@ class AngleFieldInput final : public bke::MeshFieldInput { const eAttrDomain domain, const IndexMask /*mask*/) const final { - const Span<MVert> verts = mesh.verts(); + const Span<float3> positions = mesh.positions(); const Span<MPoly> polys = mesh.polys(); const Span<MLoop> loops = mesh.loops(); Array<EdgeMapEntry> edge_map = create_edge_map(polys, loops, mesh.totedge); - auto angle_fn = [edge_map = std::move(edge_map), verts, polys, loops](const int i) -> float { + auto angle_fn = + [edge_map = std::move(edge_map), positions, polys, loops](const int i) -> float { if (edge_map[i].face_count != 2) { return 0.0f; } const MPoly &mpoly_1 = polys[edge_map[i].face_index_1]; const MPoly &mpoly_2 = polys[edge_map[i].face_index_2]; float3 normal_1, normal_2; - BKE_mesh_calc_poly_normal(&mpoly_1, &loops[mpoly_1.loopstart], verts.data(), normal_1); - BKE_mesh_calc_poly_normal(&mpoly_2, &loops[mpoly_2.loopstart], verts.data(), normal_2); + BKE_mesh_calc_poly_normal(&mpoly_1, + &loops[mpoly_1.loopstart], + reinterpret_cast<const float(*)[3]>(positions.data()), + normal_1); + BKE_mesh_calc_poly_normal(&mpoly_2, + &loops[mpoly_2.loopstart], + reinterpret_cast<const float(*)[3]>(positions.data()), + normal_2); return angle_normalized_v3v3(normal_1, normal_2); }; @@ -113,14 +120,14 @@ class SignedAngleFieldInput final : public bke::MeshFieldInput { const eAttrDomain domain, const IndexMask /*mask*/) const final { - const Span<MVert> verts = mesh.verts(); + const Span<float3> positions = mesh.positions(); const Span<MEdge> edges = mesh.edges(); const Span<MPoly> polys = mesh.polys(); const Span<MLoop> loops = mesh.loops(); Array<EdgeMapEntry> edge_map = create_edge_map(polys, loops, mesh.totedge); auto angle_fn = - [edge_map = std::move(edge_map), verts, edges, polys, loops](const int i) -> float { + [edge_map = std::move(edge_map), positions, edges, polys, loops](const int i) -> float { if (edge_map[i].face_count != 2) { return 0.0f; } @@ -129,18 +136,25 @@ class SignedAngleFieldInput final : public bke::MeshFieldInput { /* Find the normals of the 2 polys. */ float3 poly_1_normal, poly_2_normal; - BKE_mesh_calc_poly_normal(&mpoly_1, &loops[mpoly_1.loopstart], verts.data(), poly_1_normal); - BKE_mesh_calc_poly_normal(&mpoly_2, &loops[mpoly_2.loopstart], verts.data(), poly_2_normal); + BKE_mesh_calc_poly_normal(&mpoly_1, + &loops[mpoly_1.loopstart], + reinterpret_cast<const float(*)[3]>(positions.data()), + poly_1_normal); + BKE_mesh_calc_poly_normal(&mpoly_2, + &loops[mpoly_2.loopstart], + reinterpret_cast<const float(*)[3]>(positions.data()), + poly_2_normal); /* Find the centerpoint of the axis edge */ - const float3 edge_centerpoint = (float3(verts[edges[i].v1].co) + - float3(verts[edges[i].v2].co)) * - 0.5f; + const float3 edge_centerpoint = (positions[edges[i].v1] + positions[edges[i].v2]) * 0.5f; /* Get the centerpoint of poly 2 and subtract the edge centerpoint to get a tangent * normal for poly 2. */ float3 poly_center_2; - BKE_mesh_calc_poly_center(&mpoly_2, &loops[mpoly_2.loopstart], verts.data(), poly_center_2); + BKE_mesh_calc_poly_center(&mpoly_2, + &loops[mpoly_2.loopstart], + reinterpret_cast<const float(*)[3]>(positions.data()), + poly_center_2); const float3 poly_2_tangent = math::normalize(poly_center_2 - edge_centerpoint); const float concavity = math::dot(poly_1_normal, poly_2_tangent); diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_vertices.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_vertices.cc index 513ddd76055..aaf9b1aedb0 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_vertices.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_vertices.cc @@ -83,19 +83,19 @@ static VArray<float3> construct_edge_positions_gvarray(const Mesh &mesh, const VertNumber vertex, const eAttrDomain domain) { - const Span<MVert> verts = mesh.verts(); + const Span<float3> positions = mesh.positions(); const Span<MEdge> edges = mesh.edges(); if (vertex == VertNumber::V1) { return mesh.attributes().adapt_domain<float3>( - VArray<float3>::ForFunc(edges.size(), - [verts, edges](const int i) { return verts[edges[i].v1].co; }), + VArray<float3>::ForFunc( + edges.size(), [positions, edges](const int i) { return positions[edges[i].v1]; }), ATTR_DOMAIN_EDGE, domain); } return mesh.attributes().adapt_domain<float3>( VArray<float3>::ForFunc(edges.size(), - [verts, edges](const int i) { return verts[edges[i].v2].co; }), + [positions, edges](const int i) { return positions[edges[i].v2]; }), ATTR_DOMAIN_EDGE, domain); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_area.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_area.cc index aec1c27a4fc..4e4bb3de17f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_area.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_area.cc @@ -18,13 +18,14 @@ static void node_declare(NodeDeclarationBuilder &b) static VArray<float> construct_face_area_varray(const Mesh &mesh, const eAttrDomain domain) { - const Span<MVert> verts = mesh.verts(); + const Span<float3> positions = mesh.positions(); const Span<MPoly> polys = mesh.polys(); const Span<MLoop> loops = mesh.loops(); - auto area_fn = [verts, polys, loops](const int i) -> float { + auto area_fn = [positions, polys, loops](const int i) -> float { const MPoly &poly = polys[i]; - return BKE_mesh_calc_poly_area(&poly, &loops[poly.loopstart], verts.data()); + return BKE_mesh_calc_poly_area( + &poly, &loops[poly.loopstart], reinterpret_cast<const float(*)[3]>(positions.data())); }; return mesh.attributes().adapt_domain<float>( diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc index 7b084995fc3..0bd1cf968df 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc @@ -37,7 +37,7 @@ class PlanarFieldInput final : public bke::MeshFieldInput { const eAttrDomain domain, IndexMask /*mask*/) const final { - const Span<MVert> verts = mesh.verts(); + const Span<float3> positions = mesh.positions(); const Span<MPoly> polys = mesh.polys(); const Span<MLoop> loops = mesh.loops(); const Span<float3> poly_normals{ @@ -49,7 +49,7 @@ class PlanarFieldInput final : public bke::MeshFieldInput { evaluator.evaluate(); const VArray<float> thresholds = evaluator.get_evaluated<float>(0); - auto planar_fn = [verts, polys, loops, thresholds, poly_normals](const int i) -> bool { + auto planar_fn = [positions, polys, loops, thresholds, poly_normals](const int i) -> bool { const MPoly &poly = polys[i]; if (poly.totloop <= 3) { return true; @@ -61,7 +61,7 @@ class PlanarFieldInput final : public bke::MeshFieldInput { float max = -FLT_MAX; for (const int i_loop : poly_loops.index_range()) { - const float3 vert = verts[poly_loops[i_loop].v].co; + const float3 &vert = positions[poly_loops[i_loop].v]; float dot = math::dot(reference_normal, vert); if (dot > max) { max = dot; diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc index 14f38efbd42..956da402dd3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc @@ -109,7 +109,7 @@ static Mesh *create_circle_mesh(const float radius, circle_corner_total(fill_type, verts_num), circle_face_total(fill_type, verts_num)); BKE_id_material_eval_ensure_default_slot(&mesh->id); - MutableSpan<MVert> verts = mesh->verts_for_write(); + MutableSpan<float3> positions = mesh->positions_for_write(); MutableSpan<MEdge> edges = mesh->edges_for_write(); MutableSpan<MPoly> polys = mesh->polys_for_write(); MutableSpan<MLoop> loops = mesh->loops_for_write(); @@ -118,10 +118,10 @@ static Mesh *create_circle_mesh(const float radius, const float angle_delta = 2.0f * (M_PI / float(verts_num)); for (const int i : IndexRange(verts_num)) { const float angle = i * angle_delta; - copy_v3_v3(verts[i].co, float3(std::cos(angle) * radius, std::sin(angle) * radius, 0.0f)); + positions[i] = float3(std::cos(angle) * radius, std::sin(angle) * radius, 0.0f); } if (fill_type == GEO_NODE_MESH_CIRCLE_FILL_TRIANGLE_FAN) { - copy_v3_v3(verts.last().co, float3(0)); + positions.last() = float3(0); } /* Create outer edges. */ diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc index dca91d2dc61..7653d57ee70 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc @@ -255,7 +255,7 @@ int ConeConfig::calculate_total_corners() return corner_total; } -static void calculate_cone_verts(const MutableSpan<MVert> &verts, const ConeConfig &config) +static void calculate_cone_verts(const MutableSpan<float3> positions, const ConeConfig &config) { Array<float2> circle(config.circle_segments); const float angle_delta = 2.0f * (M_PI / float(config.circle_segments)); @@ -270,7 +270,7 @@ static void calculate_cone_verts(const MutableSpan<MVert> &verts, const ConeConf /* Top cone tip or triangle fan center. */ if (config.top_has_center_vert) { - copy_v3_fl3(verts[vert_index++].co, 0.0f, 0.0f, config.height); + positions[vert_index++] = {0.0f, 0.0f, config.height}; } /* Top fill including the outer edge of the fill. */ @@ -281,7 +281,7 @@ static void calculate_cone_verts(const MutableSpan<MVert> &verts, const ConeConf for (const int j : IndexRange(config.circle_segments)) { const float x = circle[j].x * top_fill_radius; const float y = circle[j].y * top_fill_radius; - copy_v3_fl3(verts[vert_index++].co, x, y, config.height); + positions[vert_index++] = {x, y, config.height}; } } } @@ -296,7 +296,7 @@ static void calculate_cone_verts(const MutableSpan<MVert> &verts, const ConeConf for (const int j : IndexRange(config.circle_segments)) { const float x = circle[j].x * ring_radius; const float y = circle[j].y * ring_radius; - copy_v3_fl3(verts[vert_index++].co, x, y, ring_height); + positions[vert_index++] = {x, y, ring_height}; } } @@ -308,14 +308,14 @@ static void calculate_cone_verts(const MutableSpan<MVert> &verts, const ConeConf for (const int j : IndexRange(config.circle_segments)) { const float x = circle[j].x * bottom_fill_radius; const float y = circle[j].y * bottom_fill_radius; - copy_v3_fl3(verts[vert_index++].co, x, y, -config.height); + positions[vert_index++] = {x, y, -config.height}; } } } /* Bottom cone tip or triangle fan center. */ if (config.bottom_has_center_vert) { - copy_v3_fl3(verts[vert_index++].co, 0.0f, 0.0f, -config.height); + positions[vert_index++] = {0.0f, 0.0f, -config.height}; } } @@ -654,7 +654,7 @@ static Mesh *create_vertex_mesh() { /* Returns a mesh with a single vertex at the origin. */ Mesh *mesh = BKE_mesh_new_nomain(1, 0, 0, 0, 0); - copy_v3_fl3(mesh->verts_for_write().first().co, 0.0f, 0.0f, 0.0f); + mesh->positions_for_write().first() = float3(0); return mesh; } @@ -686,12 +686,12 @@ Mesh *create_cylinder_or_cone_mesh(const float radius_top, config.tot_verts, config.tot_edges, 0, config.tot_corners, config.tot_faces); BKE_id_material_eval_ensure_default_slot(&mesh->id); - MutableSpan<MVert> verts = mesh->verts_for_write(); + MutableSpan<float3> positions = mesh->positions_for_write(); MutableSpan<MEdge> edges = mesh->edges_for_write(); MutableSpan<MPoly> polys = mesh->polys_for_write(); MutableSpan<MLoop> loops = mesh->loops_for_write(); - calculate_cone_verts(verts, config); + calculate_cone_verts(positions, config); calculate_cone_edges(edges, config); calculate_cone_faces(loops, polys, config); calculate_cone_uvs(mesh, config); diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc index e8ee057ee5c..dd84ae0e8ad 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc @@ -16,7 +16,7 @@ namespace blender::nodes { static void calculate_uvs( - Mesh *mesh, Span<MVert> verts, Span<MLoop> loops, const float size_x, const float size_y) + Mesh *mesh, Span<float3> positions, Span<MLoop> loops, const float size_x, const float size_y) { MutableAttributeAccessor attributes = mesh->attributes_for_write(); @@ -27,7 +27,7 @@ static void calculate_uvs( const float dy = (size_y == 0.0f) ? 0.0f : 1.0f / size_y; threading::parallel_for(loops.index_range(), 1024, [&](IndexRange range) { for (const int i : range) { - const float3 &co = verts[loops[i].v].co; + const float3 &co = positions[loops[i].v]; uv_attribute.span[i].x = (co.x + size_x * 0.5f) * dx; uv_attribute.span[i].y = (co.y + size_y * 0.5f) * dy; } @@ -49,7 +49,7 @@ Mesh *create_grid_mesh(const int verts_x, 0, edges_x * edges_y * 4, edges_x * edges_y); - MutableSpan<MVert> verts = mesh->verts_for_write(); + MutableSpan<float3> positions = mesh->positions_for_write(); MutableSpan<MEdge> edges = mesh->edges_for_write(); MutableSpan<MPoly> polys = mesh->polys_for_write(); MutableSpan<MLoop> loops = mesh->loops_for_write(); @@ -65,9 +65,9 @@ Mesh *create_grid_mesh(const int verts_x, threading::parallel_for(IndexRange(verts_y), 512, [&](IndexRange y_range) { for (const int y : y_range) { const int vert_index = y_offset + y; - verts[vert_index].co[0] = (x - x_shift) * dx; - verts[vert_index].co[1] = (y - y_shift) * dy; - verts[vert_index].co[2] = 0.0f; + positions[vert_index].x = (x - x_shift) * dx; + positions[vert_index].y = (y - y_shift) * dy; + positions[vert_index].z = 0.0f; } }); } @@ -141,7 +141,7 @@ Mesh *create_grid_mesh(const int verts_x, }); if (mesh->totpoly != 0) { - calculate_uvs(mesh, verts, loops, size_x, size_y); + calculate_uvs(mesh, positions, loops, size_x, size_y); } return mesh; diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc index 51a4f36507e..79a98b67d9c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc @@ -179,15 +179,15 @@ Mesh *create_line_mesh(const float3 start, const float3 delta, const int count) Mesh *mesh = BKE_mesh_new_nomain(count, count - 1, 0, 0, 0); BKE_id_material_eval_ensure_default_slot(&mesh->id); - MutableSpan<MVert> verts = mesh->verts_for_write(); + MutableSpan<float3> positions = mesh->positions_for_write(); MutableSpan<MEdge> edges = mesh->edges_for_write(); threading::parallel_invoke( 1024 < count, [&]() { - threading::parallel_for(verts.index_range(), 4096, [&](IndexRange range) { + threading::parallel_for(positions.index_range(), 4096, [&](IndexRange range) { for (const int i : range) { - copy_v3_v3(verts[i].co, start + delta * i); + positions[i] = start + delta * i; } }); }, diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc index cfa1c477b28..f29e21436e0 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc @@ -63,7 +63,7 @@ static int sphere_face_total(const int segments, const int rings) * Also calculate vertex normals here, since the calculation is trivial, and it allows avoiding the * calculation later, if it's necessary. The vertex normals are just the normalized positions. */ -BLI_NOINLINE static void calculate_sphere_vertex_data(MutableSpan<MVert> verts, +BLI_NOINLINE static void calculate_sphere_vertex_data(MutableSpan<float3> positions, MutableSpan<float3> vert_normals, const float radius, const int segments, @@ -83,7 +83,7 @@ BLI_NOINLINE static void calculate_sphere_vertex_data(MutableSpan<MVert> verts, segment_sines[segment] = std::sin(phi); } - copy_v3_v3(verts[0].co, float3(0.0f, 0.0f, radius)); + positions[0] = float3(0.0f, 0.0f, radius); vert_normals.first() = float3(0.0f, 0.0f, 1.0f); int vert_index = 1; @@ -94,13 +94,13 @@ BLI_NOINLINE static void calculate_sphere_vertex_data(MutableSpan<MVert> verts, for (const int segment : IndexRange(1, segments)) { const float x = sin_theta * segment_cosines[segment]; const float y = sin_theta * segment_sines[segment]; - copy_v3_v3(verts[vert_index].co, float3(x, y, z) * radius); + positions[vert_index] = float3(x, y, z) * radius; vert_normals[vert_index] = float3(x, y, z); vert_index++; } } - copy_v3_v3(verts.last().co, float3(0.0f, 0.0f, -radius)); + positions.last() = float3(0.0f, 0.0f, -radius); vert_normals.last() = float3(0.0f, 0.0f, -1.0f); } @@ -301,7 +301,7 @@ static Mesh *create_uv_sphere_mesh(const float radius, const int segments, const sphere_corner_total(segments, rings), sphere_face_total(segments, rings)); BKE_id_material_eval_ensure_default_slot(&mesh->id); - MutableSpan<MVert> verts = mesh->verts_for_write(); + MutableSpan<float3> positions = mesh->positions_for_write(); MutableSpan<MEdge> edges = mesh->edges_for_write(); MutableSpan<MPoly> polys = mesh->polys_for_write(); MutableSpan<MLoop> loops = mesh->loops_for_write(); @@ -311,7 +311,7 @@ static Mesh *create_uv_sphere_mesh(const float radius, const int segments, const [&]() { MutableSpan vert_normals{ reinterpret_cast<float3 *>(BKE_mesh_vertex_normals_for_write(mesh)), mesh->totvert}; - calculate_sphere_vertex_data(verts, vert_normals, radius, segments, rings); + calculate_sphere_vertex_data(positions, vert_normals, radius, segments, rings); BKE_mesh_vertex_normals_clear_dirty(mesh); }, [&]() { calculate_sphere_edge_indices(edges, segments, rings); }, diff --git a/source/blender/nodes/geometry/nodes/node_geo_sample_nearest.cc b/source/blender/nodes/geometry/nodes/node_geo_sample_nearest.cc index 7028b013dc6..b7142bc8521 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_sample_nearest.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_sample_nearest.cc @@ -163,7 +163,7 @@ static void get_closest_mesh_corners(const Mesh &mesh, const MutableSpan<float> r_distances_sq, const MutableSpan<float3> r_positions) { - const Span<MVert> verts = mesh.verts(); + const Span<float3> mesh_positions = mesh.positions(); const Span<MPoly> polys = mesh.polys(); const Span<MLoop> loops = mesh.loops(); @@ -178,24 +178,23 @@ static void get_closest_mesh_corners(const Mesh &mesh, /* Find the closest vertex in the polygon. */ float min_distance_sq = FLT_MAX; - const MVert *closest_mvert; + int closest_vert_index = 0; int closest_loop_index = 0; for (const int loop_index : IndexRange(poly.loopstart, poly.totloop)) { const MLoop &loop = loops[loop_index]; const int vertex_index = loop.v; - const MVert &mvert = verts[vertex_index]; - const float distance_sq = math::distance_squared(position, float3(mvert.co)); + const float distance_sq = math::distance_squared(position, mesh_positions[vertex_index]); if (distance_sq < min_distance_sq) { min_distance_sq = distance_sq; closest_loop_index = loop_index; - closest_mvert = &mvert; + closest_vert_index = vertex_index; } } if (!r_corner_indices.is_empty()) { r_corner_indices[i] = closest_loop_index; } if (!r_positions.is_empty()) { - r_positions[i] = closest_mvert->co; + r_positions[i] = mesh_positions[closest_vert_index]; } if (!r_distances_sq.is_empty()) { r_distances_sq[i] = min_distance_sq; diff --git a/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc b/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc index 5f1baa23511..dbce3dfe2b0 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc @@ -157,7 +157,7 @@ static void scale_vertex_islands_uniformly(Mesh &mesh, const UniformScaleParams ¶ms, const GetVertexIndicesFn get_vertex_indices) { - MutableSpan<MVert> verts = mesh.verts_for_write(); + MutableSpan<float3> positions = mesh.positions_for_write(); const Span<MEdge> edges = mesh.edges(); const Span<MPoly> polys = mesh.polys(); const Span<MLoop> loops = mesh.loops(); @@ -182,10 +182,7 @@ static void scale_vertex_islands_uniformly(Mesh &mesh, center *= f; for (const int vert_index : vertex_indices) { - MVert &vert = verts[vert_index]; - const float3 old_position = vert.co; - const float3 new_position = transform_with_uniform_scale(old_position, center, scale); - copy_v3_v3(vert.co, new_position); + positions[vert_index] = transform_with_uniform_scale(positions[vert_index], center, scale); } } }); @@ -198,7 +195,7 @@ static void scale_vertex_islands_on_axis(Mesh &mesh, const AxisScaleParams ¶ms, const GetVertexIndicesFn get_vertex_indices) { - MutableSpan<MVert> verts = mesh.verts_for_write(); + MutableSpan<float3> positions = mesh.positions_for_write(); const Span<MEdge> edges = mesh.edges(); const Span<MPoly> polys = mesh.polys(); const Span<MLoop> loops = mesh.loops(); @@ -231,10 +228,7 @@ static void scale_vertex_islands_on_axis(Mesh &mesh, const float4x4 transform = create_single_axis_transform(center, axis, scale); for (const int vert_index : vertex_indices) { - MVert &vert = verts[vert_index]; - const float3 old_position = vert.co; - const float3 new_position = transform * old_position; - copy_v3_v3(vert.co, new_position); + positions[vert_index] = transform * positions[vert_index]; } } }); diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_position.cc b/source/blender/nodes/geometry/nodes/node_geo_set_position.cc index e243fe3614c..50739b83a61 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_position.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_position.cc @@ -34,34 +34,6 @@ static void set_computed_position_and_offset(GeometryComponent &component, const int grain_size = 10000; switch (component.type()) { - case GEO_COMPONENT_TYPE_MESH: { - Mesh *mesh = static_cast<MeshComponent &>(component).get_for_write(); - MutableSpan<MVert> verts = mesh->verts_for_write(); - if (in_positions.is_same(positions.varray)) { - devirtualize_varray(in_offsets, [&](const auto in_offsets) { - threading::parallel_for( - selection.index_range(), grain_size, [&](const IndexRange range) { - for (const int i : selection.slice(range)) { - const float3 offset = in_offsets[i]; - add_v3_v3(verts[i].co, offset); - } - }); - }); - } - else { - devirtualize_varray2( - in_positions, in_offsets, [&](const auto in_positions, const auto in_offsets) { - threading::parallel_for( - selection.index_range(), grain_size, [&](const IndexRange range) { - for (const int i : selection.slice(range)) { - const float3 new_position = in_positions[i] + in_offsets[i]; - copy_v3_v3(verts[i].co, new_position); - } - }); - }); - } - break; - } case GEO_COMPONENT_TYPE_CURVE: { CurveComponent &curve_component = static_cast<CurveComponent &>(component); Curves &curves_id = *curve_component.get_for_write(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_uv_pack_islands.cc b/source/blender/nodes/geometry/nodes/node_geo_uv_pack_islands.cc index c2d27cffa93..e02348e9c44 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_uv_pack_islands.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_uv_pack_islands.cc @@ -37,7 +37,7 @@ static VArray<float3> construct_uv_gvarray(const Mesh &mesh, const float margin, const eAttrDomain domain) { - const Span<MVert> verts = mesh.verts(); + const Span<float3> positions = mesh.positions(); const Span<MPoly> polys = mesh.polys(); const Span<MLoop> loops = mesh.loops(); @@ -67,7 +67,7 @@ static VArray<float3> construct_uv_gvarray(const Mesh &mesh, for (const int i : IndexRange(mp.totloop)) { const MLoop &ml = loops[mp.loopstart + i]; mp_vkeys[i] = ml.v; - mp_co[i] = verts[ml.v].co; + mp_co[i] = positions[ml.v]; mp_uv[i] = uv[mp.loopstart + i]; mp_pin[i] = false; mp_select[i] = false; diff --git a/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc b/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc index eff3b969250..4136c21e58d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc @@ -62,7 +62,7 @@ static VArray<float3> construct_uv_gvarray(const Mesh &mesh, const GeometryNodeUVUnwrapMethod method, const eAttrDomain domain) { - const Span<MVert> verts = mesh.verts(); + const Span<float3> positions = mesh.positions(); const Span<MEdge> edges = mesh.edges(); const Span<MPoly> polys = mesh.polys(); const Span<MLoop> loops = mesh.loops(); @@ -95,7 +95,7 @@ static VArray<float3> construct_uv_gvarray(const Mesh &mesh, for (const int i : IndexRange(mp.totloop)) { const MLoop &ml = loops[mp.loopstart + i]; mp_vkeys[i] = ml.v; - mp_co[i] = verts[ml.v].co; + mp_co[i] = positions[ml.v]; mp_uv[i] = uv[mp.loopstart + i]; mp_pin[i] = false; mp_select[i] = false; diff --git a/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc index c076a6c08f3..309b03a1d44 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc @@ -123,7 +123,7 @@ static Mesh *create_mesh_from_volume_grids(Span<openvdb::GridBase::ConstPtr> gri Mesh *mesh = BKE_mesh_new_nomain(vert_offset, 0, 0, loop_offset, poly_offset); BKE_id_material_eval_ensure_default_slot(&mesh->id); - MutableSpan<MVert> verts = mesh->verts_for_write(); + MutableSpan<float3> positions = mesh->positions_for_write(); MutableSpan<MPoly> polys = mesh->polys_for_write(); MutableSpan<MLoop> loops = mesh->loops_for_write(); @@ -135,7 +135,7 @@ static Mesh *create_mesh_from_volume_grids(Span<openvdb::GridBase::ConstPtr> gri vert_offsets[i], poly_offsets[i], loop_offsets[i], - verts, + positions, polys, loops); } |