Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc
| Show All 29 Lines | public: | ||||
| } | } | ||||
| GVArray get_varray_for_context(const Mesh &mesh, | GVArray get_varray_for_context(const Mesh &mesh, | ||||
| const eAttrDomain domain, | const eAttrDomain domain, | ||||
| const IndexMask /*mask*/) const final | const IndexMask /*mask*/) const final | ||||
| { | { | ||||
| const Span<MEdge> edges = mesh.edges(); | const Span<MEdge> edges = mesh.edges(); | ||||
| DisjointSet islands(mesh.totvert); | DisjointSet<int> islands(mesh.totvert); | ||||
| for (const int i : edges.index_range()) { | for (const int i : edges.index_range()) { | ||||
| islands.join(edges[i].v1, edges[i].v2); | islands.join(edges[i].v1, edges[i].v2); | ||||
| } | } | ||||
| Array<int> output(mesh.totvert); | Array<int> output(mesh.totvert); | ||||
| VectorSet<int> ordered_roots; | VectorSet<int> ordered_roots; | ||||
| for (const int i : IndexRange(mesh.totvert)) { | for (const int i : IndexRange(mesh.totvert)) { | ||||
| const int64_t root = islands.find_root(i); | const int root = islands.find_root(i); | ||||
| output[i] = ordered_roots.index_of_or_add(root); | output[i] = ordered_roots.index_of_or_add(root); | ||||
| } | } | ||||
| return mesh.attributes().adapt_domain<int>( | return mesh.attributes().adapt_domain<int>( | ||||
| VArray<int>::ForContainer(std::move(output)), ATTR_DOMAIN_POINT, domain); | VArray<int>::ForContainer(std::move(output)), ATTR_DOMAIN_POINT, domain); | ||||
| } | } | ||||
| uint64_t hash() const override | uint64_t hash() const override | ||||
| Show All 21 Lines | public: | ||||
| } | } | ||||
| GVArray get_varray_for_context(const Mesh &mesh, | GVArray get_varray_for_context(const Mesh &mesh, | ||||
| const eAttrDomain domain, | const eAttrDomain domain, | ||||
| const IndexMask /*mask*/) const final | const IndexMask /*mask*/) const final | ||||
| { | { | ||||
| const Span<MEdge> edges = mesh.edges(); | const Span<MEdge> edges = mesh.edges(); | ||||
| DisjointSet islands(mesh.totvert); | DisjointSet<int> islands(mesh.totvert); | ||||
| for (const int i : edges.index_range()) { | for (const int i : edges.index_range()) { | ||||
| islands.join(edges[i].v1, edges[i].v2); | islands.join(edges[i].v1, edges[i].v2); | ||||
| } | } | ||||
| Set<int> island_list; | Set<int> island_list; | ||||
| for (const int i_vert : IndexRange(mesh.totvert)) { | for (const int i_vert : IndexRange(mesh.totvert)) { | ||||
| const int64_t root = islands.find_root(i_vert); | const int root = islands.find_root(i_vert); | ||||
| island_list.add(root); | island_list.add(root); | ||||
| } | } | ||||
| return VArray<int>::ForSingle(island_list.size(), mesh.attributes().domain_size(domain)); | return VArray<int>::ForSingle(island_list.size(), mesh.attributes().domain_size(domain)); | ||||
| } | } | ||||
| uint64_t hash() const override | uint64_t hash() const override | ||||
| { | { | ||||
| Show All 39 Lines | |||||