Page MenuHome

Geometry Nodes: Curve Endpoint Selection
ClosedPublic

Authored by Johnny Matthews (guitargeek) on Oct 13 2021, 3:08 AM.

Details

Summary

An endpoint selection input node to replace the curve endpoint node. Start and End size determine how much of the end of the curve is
selected.

Diff Detail

Repository
rB Blender

Event Timeline

Johnny Matthews (guitargeek) requested review of this revision.Oct 13 2021, 3:08 AM
Johnny Matthews (guitargeek) created this revision.
Hans Goudey (HooglyBoogly) requested changes to this revision.Oct 13 2021, 5:26 AM

Just a couple basic comments inline, I think the idea is great though.

source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc
41–46

I know the cost is probably very minimal, but I'd suggest using two loops instead of checking start for each iteration.

43

It's important to only control control_point_offsets once, since the return value is an array. In other words, it has to allocate an array the size of the number of splines every time it's called.

This revision now requires changes to proceed.Oct 13 2021, 5:26 AM
Johnny Matthews (guitargeek) marked 2 inline comments as done.
  • A couple small optimizations from Hans Goudey

Other than the comment inline, this looks great to me.

source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc
83–88

control_point_offsets is called down here too, it's probably best to pass it to select_by_point

  • Merge branch 'master' into endpoints
  • Only eval control_point_offsets() once
Johnny Matthews (guitargeek) marked an inline comment as done.Oct 13 2021, 11:07 PM
Jacques Lucke (JacquesLucke) requested changes to this revision.Oct 14 2021, 2:38 PM

I'm not quite convinced by the general usefulness of this node. Feels like something we could easily ship as a node group at some point. Until then it does not seem to have enough use-cases to justify adding a built-in node for it. Maybe you can convince me otherwise with some better examples.

This revision now requires changes to proceed.Oct 14 2021, 2:38 PM

Combined with the selection input to the instance on points node, this node is meant to replace the curve endpoints node. The use case there was instancing something else at the beginning and end of each spline, which is actually a very use case.
This node generalizes that idea a bit, and works well with the rest of the fields system for curves. You can instance directly on them with the same method as the "interior" points as well.

Ok, I'd like to have one of the following two changes:

  • Add a Both output that contains the start and end endpoints.
  • Give the node an enum to change between start/end.

It's fine for now, but it feels like an unnecessary limitation that the inputs are not fields that can be changed per spline.

  • Merge branch 'master' into endpoints
  • Make the start and end lengths into fields
  • Add 'both' output
  • Wrap the outputs in output_is_required()
Johnny Matthews (guitargeek) edited the summary of this revision. (Show Details)
Johnny Matthews (guitargeek) edited the summary of this revision. (Show Details)
  • Name changes
  • Merge branch 'master' into endpoints

Looking at this again, it feels like the "Start" and "End" output should be removed and the "Both" output should be renamed to "Selection".
If someone wants to have a separate selection for start and end, two seperate nodes can be used.
What do you think?

  • Merge branch 'master' into endpoints
  • Remove extra outputs, now only selection
Hans Goudey (HooglyBoogly) requested changes to this revision.Oct 18 2021, 5:17 AM

Looks pretty good, it's definitely simpler now. Just a few changes inline.

source/blender/blenkernel/BKE_node.h
1542

Small thing, but it's best to just add a new line here instead of replacing the old one, so whitespace remains at the end of the list.

source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc
33

How about the splines -> each spline? I think that's a bit clearer.

42

Might as well use the same word-- sizes

95

This can return early a bit above, like the other early returns. That avoids the need to indent the rest of the function, which is an improvement IMO.

97–98

These two lines can be combined: Array<bool> selection(point_size, false);

122

Since Field has a hash function, it doesn't need to be cast here.

This revision now requires changes to proceed.Oct 18 2021, 5:17 AM
Johnny Matthews (guitargeek) marked 3 inline comments as done.
  • Small cleanups
Johnny Matthews (guitargeek) marked 3 inline comments as done.Oct 18 2021, 6:26 AM
This revision is now accepted and ready to land.Oct 18 2021, 10:42 AM
Johnny Matthews (guitargeek) edited the summary of this revision. (Show Details)