Page MenuHome

Geometry Nodes: Curve Primitive Arc
AbandonedPublic

Authored by Johnny Matthews (guitargeek) on Jun 26 2021, 6:51 AM.
Subscribers
None
Tokens
"Love" token, awarded by monio."Love" token, awarded by duarteframos."Love" token, awarded by someuser."Love" token, awarded by 14AUDDIN.

Details

Summary

This node creates an arc defined by 2 modes:

mode 1 takes 3 points which define a circle. p1 and p3 become the endpoints of the arc. The arc does not need to be locked to the world coords
mode 2 takes a radius, start and end angle, creates the arc aligned to the world

both modes allow for setting resolution

"Include Center" option for changing arc into a circle sector.

Diff Detail

Repository
rB Blender

Event Timeline

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

Set default to radius mode
Set default radius to 1
set default points to (-1,0,0),(0,1,0),(1,0,0)
If the points are colinear, it will return a line with the proper resolution from point 1 to point 3.

Add Centerpoint Output

Since a fair amount of the more complicated logic is the same as the circle node, maybe it makes sense to reuse some of the code by splitting out part of the logic in the circle file and adding it to the node_geometry_util.hh header file.

Extracted a colinear function and a centerpoint function that may be useful from arc and circle.

Better name for circle center point function.

Hans Goudey (HooglyBoogly) requested changes to this revision.Jul 13 2021, 10:03 PM
Hans Goudey (HooglyBoogly) added inline comments.
source/blender/nodes/geometry/node_geometry_util.cc
58

If something like this is extracted, it should probably be in the float3 class. I did an attempt at that here: D11773: BLI: Add "is_parallel" function for float3

67

Exposing the function in node_geometry_util.hh doesn't necessarily mean moving it to node_geometry_util.cc. I think the implementation can stay in the circle primitive file.


If you want to return a float3, there are a couple things to know:

  • Pass the float3 by reference, (with &) then you can just assign it's value in the function and the caller will have the new value.
  • Return arguments should generally be last.
  • Return arguments should generally have an r_ prefix, like float3 &r_center
source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc
118

Looks like you don't have clang format set to run when you save the file. I strongly recommend doing that, it's a great time saver.

124–132

The reason I was questioning the abstraction of "circle centerpoint" earlier is that you have to repeat this work that was already done in it. Maybe there is a way to arrange things differently where that isn't possible, maybe not.

142–178

Hmm, it looks like most of this is dealing with reordering the points if necessary? Not sure. I think it's totally valid to assume that the first point is the beginning, the second the middle, and the last the end.

source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc
101–104

I wonder if these could get more descriptive names and they could also be returned from the circle calculation function. That way circle_centerpoint would be able to do most of the "hard thinking" for you.

This revision now requires changes to proceed.Jul 13 2021, 10:03 PM

Refactoring and Cleanup

Johnny Matthews (guitargeek) edited the summary of this revision. (Show Details)

Add "Include Center" mode for circle sector instead of arc

Hans Goudey (HooglyBoogly) requested changes to this revision.Aug 12 2021, 10:51 PM

I think circle_centerpoint_f3_f3_f3 could return a struct called something like CircleCenterResult Each item in the struct can have a brief description.
The nice thing about that is that the variables don't have to be declared separately in each user of the function.

I haven't taken the time to fully understand the math, but I'm still not quite thrilled with the amount of duplication between the circle and arc nodes.
Do you think the circle node could be implemented completely in terms of the arc node? It's a tempting idea, since moving around some empties as handles I can basically make it work in the viewport.
Theoretically the only different would need to be whether the output spline is cyclic. Hmm.

This revision now requires changes to proceed.Aug 12 2021, 10:51 PM