Page MenuHome

Implement T89215 Curve Endpoints
ClosedPublic

Authored by Angus Stanton (abstanton) on Jun 27 2021, 4:07 PM.

Details

Summary

Implements the Curve Endpoints node.
Copies lots of code from the Curve to Points node.

Diff Detail

Repository
rB Blender
Branch
T89215-curve-endpoints (branched from master)
Build Status
Buildable 15447
Build 15447: arc lint + arc unit

Event Timeline

Angus Stanton (abstanton) requested review of this revision.Jun 27 2021, 4:07 PM
Angus Stanton (abstanton) created this revision.
Angus Stanton (abstanton) retitled this revision from initial work on curve endpoints, mainly copying curve to points code for now to Implement T89215 Curve Endpoints.Jun 27 2021, 4:09 PM
Angus Stanton (abstanton) edited the summary of this revision. (Show Details)
Angus Stanton (abstanton) edited the summary of this revision. (Show Details)
  • Remove unnecessary declaration in rna_nodetree.c
Hans Goudey (HooglyBoogly) requested changes to this revision.Jun 30 2021, 12:40 AM

Works well, nice job!

I may have found an issue with the "create_default_rotation_attribute" function in my test. Someone can work on solving that separately though, since it's shared with curve to points.
(I didn't expect to need the align rotation to vector node).

I think we can include something like this as an example in the manual.

source/blender/nodes/geometry/nodes/node_geo_curve_endpoints.cc
94

Since this is the same between the two nodes, I think we can use the version in node_geo_curve_to_points.cc.

  • create_point_attributes -> curve_to_points_create_result_attributes
  • ResultAttributes -> CurveToPointResults
155

You can avoid looping over the splines twice and allocating the temporary bool array if you use a Vector as a return type instead. You can use reserve with the length of the input spline span to avoid the need for the vector to reallocate as it grows

191–195

I think it's safe to assume that the first tilt value and the first radius value will be the same in the interpolated array.

Therefore you shouldn't need to do the interpolation at all, you can just use start_data.radii[i] = spline.radii().first();

It is an assumption for sure, but I can't see why it would change.

197–200

I don't really understand this comment. Sure, duplication isn't great, but this is not very complicated code anyway.
And for "limited to just the start and end points," isn't that the point of the node?

214

Comments should start with /* , and end with a period. More info: https://wiki.blender.org/wiki/Style_Guide/C_Cpp

220–222

You can make the same assumption I mentioned for the radii above.

238

Since this function is exactly the same, I think we can generalize it slightly in the original node_geo_curve_to_points.cc file, add it to node_geometry_util.hh, and then use it here.

Here's the signature I'd suggest: void curve_create_default_rotation_attribute(Span<float3> tangents, Span<float3> normals, MutableSpan<float3> rotations)

268

Can be const Array<int> offsets

This revision now requires changes to proceed.Jun 30 2021, 12:40 AM
  • Updated D11719 based on comments
Angus Stanton (abstanton) marked 8 inline comments as done.Jul 1 2021, 1:58 PM
Angus Stanton (abstanton) added inline comments.
source/blender/makesrna/intern/rna_nodetree.c
9906 ↗(On Diff #38805)

Did not mean to include this in the diff

Hans Goudey (HooglyBoogly) requested changes to this revision.Jul 2 2021, 8:41 PM

This is quite close now, just some cleanup necessary.

source/blender/nodes/geometry/nodes/node_geo_curve_endpoints.cc
57–74

These are unused now.

91

Unused variable

source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc
141 ↗(On Diff #39006)

Needs clang format. I suggest setting up your editor to do that when you save a file.

This revision now requires changes to proceed.Jul 2 2021, 8:41 PM
Angus Stanton (abstanton) marked 3 inline comments as done.
  • Responded to formatting/cleanup comments
Hans Goudey (HooglyBoogly) accepted this revision.EditedJul 7 2021, 5:17 AM

Looks good, pretty simple really! There's a chance the attribute access to curves could be refactored in the future, but since this is so similar to the curve to points node, that should be easy.

I marked the places I changed when committing this in comments, just to leave a good record.

source/blender/nodes/geometry/node_geometry_util.hh
45 ↗(On Diff #39064)

I moved this down to be closer to the other functions at the bottom of this file.

source/blender/nodes/geometry/nodes/node_geo_curve_endpoints.cc
86

I changed the wording a little bit here, and used the /** format for the comment.

114

I fixed the missing spaces in this comment.

170

I removed this newline.

204

And removed the newline here.

This revision is now accepted and ready to land.Jul 7 2021, 5:17 AM
This revision was automatically updated to reflect the committed changes.