Page MenuHome

Geometry Nodes: Curve Primitive Circle
ClosedPublic

Authored by Johnny Matthews (guitargeek) on Jun 19 2021, 6:20 AM.
Tokens
"Love" token, awarded by duarteframos."Love" token, awarded by someuser."Love" token, awarded by 14AUDDIN."Love" token, awarded by HEYPictures.

Details

Summary

This node has 2 modes: the first mode computes a circle from 3 locations and a resolution. The second mode takes radius and resolution.

Diff Detail

Event Timeline

Johnny Matthews (guitargeek) requested review of this revision.Jun 19 2021, 6:20 AM
Johnny Matthews (guitargeek) created this revision.

Some Style and cleanup

Can this have two outputs? One for the cirlcle but another for the arc from point 1, through 2, ending at 3?
I think people needing it for an arc will be more common than actually creating the whole circle

Can this have two outputs? One for the cirlcle but another for the arc from point 1, through 2, ending at 3?
I think people needing it for an arc will be more common than actually creating the whole circle

I'd have to experiment. I was happy just to get the math to work for the whole circle! :D

Johnny Matthews (guitargeek) retitled this revision from Geometry Nodes: Curve Primitive Circle from 3 Points to Geometry Nodes: Curve Primitive Circle / Arc from 3 Points.

Added Circle/Arc toggle option

Johnny Matthews (guitargeek) set the repository for this revision to rB Blender.Jun 22 2021, 5:10 PM
Hans Goudey (HooglyBoogly) requested changes to this revision.Jun 23 2021, 6:44 AM
  • This is great! It's really satisfying when you plug in three empties to it and it works well!
  • It would be nice to give the node an error message in its failure cases (the points are collinear, etc).
  • The inline comments are just an initial review, I'd like to come back and understand this better in another pass.
  • Better input names would probably be "Start", "Rim" / "Middle", and "End"
  • I'm not sure about combining "Arc" and "Circle" in a single node, here's an alternate proposal below, I'm curious what you think about that.
    • Another benefit of the mockup below is that we wouldn't need the "Polygon" node.

source/blender/nodes/geometry/nodes/node_geo_curve_primitive_points_circle.cc
43–44

Where possible, it's preferred to use float3 methods instead. Also, don't forget the f at the end of 0.5 here.

53

I think calling a static method on an instance of the class is a bit confusing. You can use float3::cross instead.

57–58

You can declare these const like const float v4 = float3::cross(v3, v1).normalized();

68

Same here, float3::distance

90

This can be declared inside each loop, lower scope is nicer than reusing variables.

This revision now requires changes to proceed.Jun 23 2021, 6:44 AM

I like the idea of two nodes. This will take some time to rework into 2 nodes.

Awesome, thanks! I just remembered that for the arc in radius mode it would need to have a start and end angle, oops.

Awesome, thanks! I just remembered that for the arc in radius mode it would need to have a start and end angle, oops.

Makes sense. I need to wire up a toggle button for the circle node and it will be ready, but at the moment with an int to choose the mode, it works perfectly. Then I can start on the arc node from that code.

Johnny Matthews (guitargeek) retitled this revision from Geometry Nodes: Curve Primitive Circle / Arc from 3 Points to Geometry Nodes: Curve Primitive Circle.
Johnny Matthews (guitargeek) edited the summary of this revision. (Show Details)

Updated to Curve Primitive Circle with 2 modes.

Had to add the fill tilts because of some randomness happening with them.

Hans Goudey (HooglyBoogly) requested changes to this revision.Jun 24 2021, 5:42 AM
Hans Goudey (HooglyBoogly) added inline comments.
source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc
28 ↗(On Diff #38672)

Soft max of 0 for the radius maybe?

41–43 ↗(On Diff #38672)

Unused variable

45–47 ↗(On Diff #38672)

These three lines don't do anything.

110 ↗(On Diff #38672)
/home/hans/Blender-Git/blender/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc:110:29: warning: ignoring return value of ‘bool isect_plane_plane_plane_v3(const float*, const float*, const float*, float*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  110 |   isect_plane_plane_plane_v3(plane_1, plane_2, plane_3, center);
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You could return early if this fails? Maybe allow creating an empty geometry set.

121 ↗(On Diff #38672)

You could pull out theta_step here like below.

122–125 ↗(On Diff #38672)

In C++ we can overload the + and * operators, making this much simpler:
positions[i] = center + r * cos(theta) * v1 + r * sin(theta) * v4;

128 ↗(On Diff #38672)

This is done by spline->resize

This revision now requires changes to proceed.Jun 24 2021, 5:42 AM
Johnny Matthews (guitargeek) marked 7 inline comments as done.

Requested Revisions - Sorry I was copying what I thought was boilerplate code for the UI button and apparently had copied more than I needed. Also, I forget that float3's are so heavily operator overloaded.

Requested Revisions and add centerpoint output

Looks good. I changed a few things when committing (small cleanup):

  • Declare a few more variables const
  • Change whitespace slightly (remove extra newlines, add period at end of comment, etc.
  • Used unique_ptr implicit boolean conversion instead of == nullptr
  • Switch order of if (curve != nullptr) { test to remove double negative
This revision is now accepted and ready to land.Jul 1 2021, 2:22 AM

@Johnny Matthews (guitargeek)
Here we have confusing situation, when there are two identical options in the node search. One for mesh circle and one for curve circle.
Can you fix naming?