diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc index d658b14092a..a99d0ac5ef9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc @@ -5,6 +5,7 @@ #include "BKE_mesh.h" +#include "BLI_timeit.hh" #include "BLI_disjoint_set.hh" #include "node_geometry_util.hh" @@ -36,15 +37,22 @@ class IslandFieldInput final : public bke::MeshFieldInput { const Span edges = mesh.edges(); DisjointSet islands(mesh.totvert); - for (const int i : edges.index_range()) { - islands.join(edges[i].v1, edges[i].v2); + SCOPED_TIMER_TABLE(islands_bench); + { + islands_bench_add("joins"); + for (const int i : edges.index_range()) { + islands.join(edges[i].v1, edges[i].v2); + } } Array output(mesh.totvert); VectorSet ordered_roots; - for (const int i : IndexRange(mesh.totvert)) { - const int root = islands.find_root(i); - output[i] = ordered_roots.index_of_or_add(root); + { + islands_bench_add("finding"); + for (const int i : IndexRange(mesh.totvert)) { + const int root = islands.find_root(i); + output[i] = ordered_roots.index_of_or_add(root); + } } return mesh.attributes().adapt_domain( @@ -80,16 +88,22 @@ class IslandCountFieldInput final : public bke::MeshFieldInput { const IndexMask /*mask*/) const final { const Span edges = mesh.edges(); - DisjointSet islands(mesh.totvert); - for (const int i : edges.index_range()) { - islands.join(edges[i].v1, edges[i].v2); + SCOPED_TIMER_TABLE(islands_bench_counting); + { + islands_bench_counting_add("joins"); + for (const int i : edges.index_range()) { + islands.join(edges[i].v1, edges[i].v2); + } } Set island_list; - for (const int i_vert : IndexRange(mesh.totvert)) { - const int root = islands.find_root(i_vert); - island_list.add(root); + { + islands_bench_counting_add("counting"); + for (const int i_vert : IndexRange(mesh.totvert)) { + const int root = islands.find_root(i_vert); + island_list.add(root); + } } return VArray::ForSingle(island_list.size(), mesh.attributes().domain_size(domain));