diff options
author | Hans Goudey <h.goudey@me.com> | 2022-09-28 06:00:34 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-09-28 06:00:34 +0300 |
commit | 391462f69244be056a59fee6f0213f4a60577d30 (patch) | |
tree | bb45b05273108fa9be1c1a804999bc49831e9f58 | |
parent | a5b0030862a0be1bbd4a24d7bcf37ca2973b8285 (diff) |
Use std::array for MeshPrimitive edges
-rw-r--r-- | source/blender/blenkernel/intern/pbvh_uv_islands.cc | 11 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pbvh_uv_islands.hh | 4 |
2 files changed, 7 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/pbvh_uv_islands.cc b/source/blender/blenkernel/intern/pbvh_uv_islands.cc index 758d96bf1d3..7eedf7a5843 100644 --- a/source/blender/blenkernel/intern/pbvh_uv_islands.cc +++ b/source/blender/blenkernel/intern/pbvh_uv_islands.cc @@ -107,10 +107,7 @@ static void mesh_data_init_primitives(MeshData &mesh_data) const MLoopTri &tri = mesh_data.looptris[i]; MeshPrimitive primitive; primitive.poly = tri.poly; - - for (int j = 0; j < 3; j++) { - primitive.loops.append(tri.tri[j]); - } + std::copy(std::begin(tri.tri), std::end(tri.tri), std::begin(primitive.loops)); mesh_data.primitives.append(primitive); } } @@ -122,6 +119,7 @@ static void mesh_data_init_edges(MeshData &mesh_data) for (int64_t i = 0; i < mesh_data.looptris.size(); i++) { const MLoopTri &tri = mesh_data.looptris[i]; MeshPrimitive &primitive = mesh_data.primitives[i]; + Vector<int, 3> edges; for (int j = 0; j < 3; j++) { int v1 = mesh_data.loops[tri.tri[j]].v; int v2 = mesh_data.loops[tri.tri[(j + 1) % 3]].v; @@ -142,8 +140,9 @@ static void mesh_data_init_edges(MeshData &mesh_data) mesh_data.vert_to_edge_map.add(edge_index, v1, v2); } - primitive.edges.append(edge_index); + edges.append(edge_index); } + std::copy(std::begin(edges), std::end(edges), std::begin(primitive.edges)); } /* Build edge to neighboring triangle map. */ mesh_data.edge_to_primitive_map = EdgeToPrimitiveMap(mesh_data.edges.size()); @@ -1136,7 +1135,7 @@ bool UVPrimitive::has_shared_edge(const UVPrimitive &other) const bool UVPrimitive::has_shared_edge(const Span<float2> uv_map, const MeshPrimitive &primitive) const { for (const UVEdge *uv_edge : edges) { - int loop_1 = primitive.loops.last(); + int loop_1 = primitive.loops[2]; for (int i = 0; i < primitive.loops.size(); i++) { int loop_2 = primitive.loops[i]; if (uv_edge->has_shared_edge(uv_map, loop_1, loop_2)) { diff --git a/source/blender/blenkernel/intern/pbvh_uv_islands.hh b/source/blender/blenkernel/intern/pbvh_uv_islands.hh index 953af33bb19..39737fec884 100644 --- a/source/blender/blenkernel/intern/pbvh_uv_islands.hh +++ b/source/blender/blenkernel/intern/pbvh_uv_islands.hh @@ -97,8 +97,8 @@ class EdgeToPrimitiveMap { /** Represents a triangle in 3d space (MLoopTri). */ struct MeshPrimitive { int64_t poly; - Vector<int, 3> edges; - Vector<int, 3> loops; + std::array<int, 3> edges; + std::array<int, 3> loops; /** Get the vertex that is not given. Both given vertices must be part of the MeshPrimitive. */ int get_other_uv_vertex(const MeshData &mesh_data, const int v1, const int v2) const; |