Page MenuHome

Geometry Nodes: Add Domain Size Node
ClosedPublic

Authored by Johnny Matthews (guitargeek) on Nov 25 2021, 7:12 AM.

Details

Summary

The Domain Size node has a single geometry input and a selection for the component type. Based on the component chosen, outputs containing single values for the related domains are shown.

Mesh:

  • Point Count
  • Edge Count
  • Face Count
  • Face Corner Count

Curve:

  • Point Count
  • Spline Count

Point Cloud:

  • Point Count

Instances:

  • Instance Count

Diff Detail

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

Event Timeline

Johnny Matthews (guitargeek) requested review of this revision.Nov 25 2021, 7:12 AM
Johnny Matthews (guitargeek) created this revision.

I guess I had assumed that we would have an output for every domain that exists on a geometry type. Since the most domains we have in a single type is four, I don't think that would make the node too big. How does that sound to you?

Also, I think I'd make this an "Attribute" class node and put it in the attribute category, since it's dealing with attribute domain sizes.

Hans Goudey (HooglyBoogly) requested changes to this revision.Nov 26 2021, 3:04 PM
Hans Goudey (HooglyBoogly) added inline comments.
source/blender/makesrna/intern/rna_nodetree.c
9188–9212

I think we should avoid duplicating these. rna_enum_attribute_domain_items is already used elsewhere,

geometry_component_type_items could also be moved to RNA_enum_items.h so it could be reused elsewhere.

This revision now requires changes to proceed.Nov 26 2021, 3:04 PM
  • Merge branch 'master' into attrdomain
  • -remove domain selection
Hans Goudey (HooglyBoogly) requested changes to this revision.Nov 27 2021, 10:41 PM

Looking good!

source/blender/makesrna/intern/rna_nodetree.c
4716

There is still geometry_component_type_items in rna_space.c that should be de-duplicated.

source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc
53–65

I'm not totally sure if it's better, but this could use local variables for each component type anc call attribute_domain_supported. That way the logic wouldn't be duplicated.

83–86

You can use params.set_default_remaining_outputs() at the end of the function now.

129

This should use the attribute class.

This revision now requires changes to proceed.Nov 27 2021, 10:41 PM
Johnny Matthews (guitargeek) marked 4 inline comments as done.
  • Merge branch 'master' into attrdomain
  • Move component enum to .h file
  • Minor cleanup
  • Merge branch 'master' into attrdomain

A few minor comments inline, but otherwise this looks good.

source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc
72

Unused variable

74

Unused variable

75

This should be a switch so that it will warn when we add a new component type

Also, the patch description should be updated with a new screenshot, and it could contain a bit more information about what the node does for someone unfamiliar with the context.

Johnny Matthews (guitargeek) marked 3 inline comments as done.
  • Final Cleanup
Jacques Lucke (JacquesLucke) requested changes to this revision.Nov 29 2021, 7:09 PM

So should the name be "Attribute Domain Size" or just "Domain Size"? I'm fine with "Domain Size", but right now the title and the node name are inconsistent.

I get a compiler warning.

[1106/2286] Building CXX object source/blender/nodes/geometry/CMakeFiles/bf_nodes_geometry.dir/Unity/unity_4_cxx.cxx.o
In file included from /home/jacques/blender-git/build_linux/source/blender/nodes/geometry/CMakeFiles/bf_nodes_geometry.dir/Unity/unity_4_cxx.cxx:5:
/home/jacques/blender-git/blender/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc: In function ‘void blender::nodes::node_geo_attribute_domain_size_cc::node_geo_exec(blender::nodes::GeoNodeExecParams)’:
/home/jacques/blender-git/blender/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc:120:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
  120 |     }
      |     ^
/home/jacques/blender-git/blender/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc:121:5: note: here
  121 |     default:
      |     ^~~~~~~

Without fixing this, this crashes in a debug build and shows a warning in release builds.

This revision now requires changes to proceed.Nov 29 2021, 7:09 PM
Johnny Matthews (guitargeek) retitled this revision from Geometry Nodes: Add Attribute Domain Size Node to Geometry Nodes: Add Domain Size Node.Nov 29 2021, 7:44 PM
This revision is now accepted and ready to land.Nov 29 2021, 7:56 PM
This revision was automatically updated to reflect the committed changes.