Page MenuHome

Geometry Nodes: Change Curve Parameter to Spline Parameter & add Index
ClosedPublic

Authored by Johnny Matthews (guitargeek) on Nov 18 2021, 11:54 PM.

Details

Summary

Change the Curve Parameter Node to Spline Parameter and add an Index output that contains the index of each control point on the given spline.

Diff Detail

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

Event Timeline

Johnny Matthews (guitargeek) requested review of this revision.Nov 18 2021, 11:54 PM
Johnny Matthews (guitargeek) created this revision.
  • Merge branch 'master' into indexonspline
Hans Goudey (HooglyBoogly) requested changes to this revision.Nov 22 2021, 5:28 PM

I like this idea! Even though it doesn't exactly fit with the idea of parameterization, the concept is similar enough in a way that makes it fit well enough, at least compared to adding a separate node for it.

Small thing, personally I'd go with "Index In Spline", it just feels more correct that way somehow.

source/blender/nodes/geometry/nodes/node_geo_curve_parameter.cc
40

it's -> its

Could be simplified a bit maybe, since this only has a definition for points. Something like this maybe? Each control point's index on its spline

197–205

I'd suggest using the offsets from control_point_offsets to our advantage and structure the loop as a loop over all splines: for (const int i : IndexRange(curve.splines.size())) {. That should simplify it a lot.

209–211

This function has no return when the domain is not either of these values. You could just skip the if statement.

This revision now requires changes to proceed.Nov 22 2021, 5:28 PM
Johnny Matthews (guitargeek) marked 3 inline comments as done.
  • Merge branch 'master' into indexonspline
  • Use total_control_point_size()
  • small cleanup
  • Merge branch 'master' into indexonspline
  • Change Node Name
Johnny Matthews (guitargeek) retitled this revision from Geometry Nodes: Add Index on Spline to Curve Parameter Node to Geometry Nodes: Change Curve Parameter to Spline Parameter & add Index.Nov 24 2021, 8:47 PM
Johnny Matthews (guitargeek) edited the summary of this revision. (Show Details)

Looks good to me. I haven't tested it but the concept is simple and I'm trusting that Johnny has :)

Want to make sure Jacques sees this though.

This is missing a change in nodeitems_builtins.py.

We have a new policy regarding versioning that would be easy to test with this patch (more info about that still needs to be written down (T93409)). The new socket should be added in versioning code as well. Otherwise future versioning code will have to deal with both versions of the code (which will become very messy over time).

  • Merge branch 'master' into indexonspline
Hans Goudey (HooglyBoogly) requested changes to this revision.Nov 29 2021, 8:45 PM

Like @Jacques Lucke (JacquesLucke) mentioned above, the versioning code should still add the new socket. Other than that this looks good to me.

This revision now requires changes to proceed.Nov 29 2021, 8:45 PM
  • Change id
  • Add socket in versioning code
Hans Goudey (HooglyBoogly) added inline comments.
source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc
23

I think I'd go with node_geo_spline_parameter_cc (without the "curve_", just because it's shorter and matches up exactly with the name we use in the UI). I don't feel that strongly though.

Jacques Lucke (JacquesLucke) requested changes to this revision.Nov 29 2021, 10:02 PM
Jacques Lucke (JacquesLucke) added inline comments.
source/blender/blenloader/intern/versioning_300.c
2415

Either increase the subversion or check if the socket exists already (making the versioning code idempotent). I prefer the second option. Feel free to add an utility method.
(btw, you don't see the socket in Blender, because it will be removed automatically again based on the declaration, but we don't want to depend on that)

You can use nodeAddStaticSocket instead of calling nodeStaticSocketType manually.

source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc
194

Can just use output directly. No need to create a span.

195

Rename index variables to output_index, spline_index and point_index. That should make it more clear I think.

This revision now requires changes to proceed.Nov 29 2021, 10:02 PM

I'm fine with the naming as it is.

Johnny Matthews (guitargeek) marked 4 inline comments as done.
  • Minor cleanup and versioning.
  • formatting
  • Merge branch 'master' into indexonspline
  • Move versioning function to versioning_common

I was just wondering, how does one access the spline index when processing individual points currently?

This revision is now accepted and ready to land.Nov 30 2021, 12:11 PM

I was just wondering, how does one access the spline index when processing individual points currently?

I'm not sure how you would in a procedural way.