Page MenuHome

Geometry Nodes: Curve Primitive Bezier Segment
ClosedPublic

Authored by Johnny Matthews (guitargeek) on Jun 18 2021, 3:53 PM.
Subscribers
None
Tokens
"Love" token, awarded by duarteframos."Love" token, awarded by dulrich."Love" token, awarded by HEYPictures.

Details

Summary

Creates a Curve with 1 Bezier Spline from 4 positions (start, start handle, end handle, end) and a resolution. The handles are aligned and mirrored automatically.

The default settings recreate the default Bezier Curve

Diff Detail

Repository
rB Blender

Event Timeline

Johnny Matthews (guitargeek) requested review of this revision.Jun 18 2021, 3:53 PM
Johnny Matthews (guitargeek) created this revision.
Hans Goudey (HooglyBoogly) requested changes to this revision.Jun 19 2021, 2:53 AM

Looks good! Just a couple style notes:

  • By convention variables should be declared with camel_case
  • Values used as floats, like the radius input, etc. should have .0f on the end to show that.
source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc
23

I don't blame you for not knowing this, since there's no documentation, but it's PROP_TRANSLATION that gives the node socket units here.

Also, above, I don't think PROP_UNSIGNED will do anything, it's just the min and max that matter here.

67
/home/hans/Blender-Git/blender/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc: In function ‘std::unique_ptr<CurveEval> blender::nodes::create_bezier_segment_curve(blender::float3, blender::float3, blender::float3, blender::float3, int)’:
/home/hans/Blender-Git/blender/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc:66:19: warning: moving a local object in a return statement prevents copy elision [-Wpessimizing-move]
   66 |   return std::move(curve);
      |          ~~~~~~~~~^~~~~~~

Basically returning something is optimized by the compiler to just construct the object in the place it's returned to anyway, so std::move is only misleading.

72

The limits in the socket template are just soft limits actually, and you can end up with any value if it's plugged into a math node, etc. So a std::max(..., 0); is necessary here.

78

Just call this curve I think, that's what I've been calling it everywhere.

This revision now requires changes to proceed.Jun 19 2021, 2:53 AM
Hans Goudey (HooglyBoogly) requested changes to this revision.Jun 22 2021, 11:57 PM
Hans Goudey (HooglyBoogly) added inline comments.
source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc
45

Picky: Suggest start_handle_right to be more consistent with the names in the UI and elsewhere in bezier spline code.

79

The minimum resolution for a bezier curve is 1, for 0 there is an assert in set_resolution, so std::max(input, 1);

82

Typo (end_ccontrol). Maybe just pass them directly to the function like in the other patch.

This revision now requires changes to proceed.Jun 22 2021, 11:57 PM

Add "points" to input names

This revision was not accepted when it landed; it landed in state Needs Review.Jun 30 2021, 7:04 AM
This revision was automatically updated to reflect the committed changes.

I cleaned up the handle calculation a little bit when committing.