Page MenuHome

Geometry Nodes: Mesh Island Field Input Node
ClosedPublic

Authored by Johnny Matthews (guitargeek) on Dec 7 2021, 7:37 PM.
Subscribers
None
Tokens
"Love" token, awarded by mcurt09."Love" token, awarded by lopoIsaac."Love" token, awarded by HEYPictures."Love" token, awarded by mswf.

Details

Summary

This node is a field input that outputs a separate index for each mesh island. The indices are based on the order of the lowest-numbered vertex in each island.

For example: if the islands were defined as the following groups of vertex indices:

0,1,2,4,56,73

The indices of the 3 islands would be:

021

Example File by @Hans Goudey (HooglyBoogly)

Diff Detail

Repository
rB Blender
Branch
mesh_island (branched from master)
Build Status
Buildable 19281
Build 19281: arc lint + arc unit

Event Timeline

Johnny Matthews (guitargeek) requested review of this revision.Dec 7 2021, 7:37 PM
Johnny Matthews (guitargeek) created this revision.
Hans Goudey (HooglyBoogly) requested changes to this revision.EditedDec 7 2021, 10:31 PM

Great patch! Quite simple too!

It would be nice to have a test file and a screenshot in the patch description. (I'd like to start making that the responsibility of the patch author). That can later become a regression test. Here's a pretty stupid test file:


/home/hans/Blender-Git/blender/source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc: In member function ‘virtual blender::fn::GVArray blender::nodes::node_geo_input_mesh_island_cc::IslandFieldInput::get_varray_for_context(const GeometryComponent&, AttributeDomain, blender::IndexMask) const’:
/home/hans/Blender-Git/blender/source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc:74:3: error: control reaches end of non-void function [-Werror=return-type]
source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc
16

Newline here

36

"Field" is redundant here IMO, I think "Index" is more helpful.

45

We can avoid indenting the rest of the function:

if (component.type() != GEO_COMPONENT_TYPE_MESH) {
  return {};
}
const MeshComponent &mesh_component = static_cast<const MeshComponent &>(component);
57–69

I think I found a somewhat simpler way to write the ordering:

Array<int> output(mesh->totvert);
VectorSet<int> ordered_roots;
for (const int i : IndexRange(mesh->totvert)) {
  const int64_t root = islands.find_root(i);
  output[i] = ordered_roots.index_of_or_add(root);
}
This revision now requires changes to proceed.Dec 7 2021, 10:31 PM
Johnny Matthews (guitargeek) marked 4 inline comments as done.
  • Merge branch 'master' into mesh_island
  • Simplify the island numbering with a VectorSet
Jacques Lucke (JacquesLucke) added inline comments.
release/scripts/startup/nodeitems_builtins.py
157

Trailing whitespace.

source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc
32

Add a description about the ordering.

This revision is now accepted and ready to land.Dec 8 2021, 4:12 PM
This revision was automatically updated to reflect the committed changes.
Johnny Matthews (guitargeek) marked an inline comment as done.