24 auto enable_points = [](
bNode &node) {
27 auto enable_radius = [](
bNode &node) {
36 .description(
"The number of points on the arc");
40 .description(
"Position of the first control point")
41 .make_available(enable_points);
45 .description(
"Position of the middle control point")
46 .make_available(enable_points);
50 .description(
"Position of the last control point")
51 .make_available(enable_points);
56 .description(
"Distance of the points from the origin")
57 .make_available(enable_radius);
58 auto &start_angle =
b.add_input<
decl::Float>(
"Start Angle")
61 .description(
"Starting angle of the arc")
62 .make_available(enable_radius);
63 auto &sweep_angle =
b.add_input<
decl::Float>(
"Sweep Angle")
68 .description(
"Length of the arc")
69 .make_available(enable_radius);
70 auto &offset_angle =
b.add_input<
decl::Float>(
"Offset Angle")
73 .description(
"Offset angle of the arc")
74 .make_available(enable_points);
77 .description(
"Connect the arc at the center");
80 .description(
"Invert and draw opposite arc");
84 .
description(
"The center of the circle described by the three points")
85 .make_available(enable_points);
88 "The normal direction of the plane described by the three points, "
89 "pointing towards the positive Z axis")
90 .make_available(enable_points);
92 .
description(
"The radius of the circle described by the three points")
93 .make_available(enable_points);
95 const bNode *node =
b.node_or_null();
96 if (node !=
nullptr) {
103 start.available(points_mode);
104 middle.available(points_mode);
105 end.available(points_mode);
107 radius.available(radius_mode);
108 start_angle.available(radius_mode);
109 sweep_angle.available(radius_mode);
111 offset_angle.available(points_mode);
113 center_out.available(points_mode);
114 normal_out.available(points_mode);
115 radius_out.available(points_mode);
145 return ELEM(a,
b,
b * -1.0f);
153 const bool connect_center,
154 const bool invert_arc,
159 const int size = connect_center ? resolution + 1 : resolution;
163 const int stepcount = resolution - 1;
164 const int centerpoint = resolution;
175 if (is_colinear || a == c || a ==
b ||
b == c || resolution == 2) {
183 if (ab > ac && ab > bc) {
187 else if (bc > ab && bc > ac) {
196 const float step = 1.0f / stepcount;
198 const float factor =
step *
i;
217 float plane_1[4], plane_2[4], plane_3[4];
239 float angle = (angle_ac > angle_ab) ? angle_ac : angle_ab;
248 const float factor =
step *
i + angle_offset;
250 positions[
i] =
out * radius + center;
254 if (connect_center) {
256 positions[centerpoint] = center;
272 const float start_angle,
273 const float sweep_angle,
274 const bool connect_center,
275 const bool invert_arc)
277 const int size = connect_center ? resolution + 1 : resolution;
281 const int stepcount = resolution - 1;
282 const int centerpoint = resolution;
285 const float sweep = (invert_arc) ? -(2.0f *
M_PI - sweep_angle) : sweep_angle;
287 const float theta_step = sweep /
float(stepcount);
289 const float theta = theta_step *
i + start_angle;
290 const float x = radius *
cos(theta);
291 const float y = radius *
sin(theta);
295 if (connect_center) {
297 positions[centerpoint] =
float3(0.0f, 0.0f, 0.0f);
314 std::max(
params.extract_input<
int>(
"Resolution"), 2),
318 params.extract_input<
float>(
"Offset Angle"),
319 params.extract_input<
bool>(
"Connect Center"),
320 params.extract_input<
bool>(
"Invert Arc"),
325 params.set_output(
"Center", center);
326 params.set_output(
"Normal", normal);
327 params.set_output(
"Radius", radius);
332 std::max(
params.extract_input<
int>(
"Resolution"), 2),
333 params.extract_input<
float>(
"Radius"),
334 params.extract_input<
float>(
"Start Angle"),
335 params.extract_input<
float>(
"Sweep Angle"),
336 params.extract_input<
bool>(
"Connect Center"),
337 params.extract_input<
bool>(
"Invert Arc"));
352 "Define arc by 3 points on circle. Arc is calculated between start and end points"},
357 "Define radius with a float"},
358 {0,
nullptr, 0,
nullptr,
nullptr},
364 "Method used to determine radius and placement",
380 "NodeGeometryCurvePrimitiveArc",
Low-level operations for curves.
#define NODE_STORAGE_FUNCS(StorageT)
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_CURVE_PRIMITIVE_ARC
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
bool isect_plane_plane_plane_v3(const float plane_a[4], const float plane_b[4], const float plane_c[4], float r_isect_co[3]) ATTR_WARN_UNUSED_RESULT
float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
void mul_m3_v3(const float M[3][3], float r[3])
void axis_angle_to_mat3(float R[3][3], const float axis[3], float angle)
float angle_signed_on_axis_v3v3_v3(const float v1[3], const float v2[3], const float axis[3]) ATTR_WARN_UNUSED_RESULT
GeometryNodeCurvePrimitiveArcMode
@ GEO_NODE_CURVE_PRIMITIVE_ARC_TYPE_POINTS
@ GEO_NODE_CURVE_PRIMITIVE_ARC_TYPE_RADIUS
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_storage_enum_accessors(member)
BMesh const char void * data
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
constexpr T & first() const
MutableSpan< float3 > positions_for_write()
MutableSpan< bool > cyclic_for_write()
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
void * MEM_callocN(size_t len, const char *str)
void node_register_type(bNodeType &ntype)
Curves * curves_new_nomain_single(int points_num, CurveType type)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
T distance(const T &a, const T &b)
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
T midpoint(const T &a, const T &b)
AxisSigned cross(const AxisSigned a, const AxisSigned b)
T interpolate(const T &a, const T &b, const FactorT &t)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
T distance_squared(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
static Curves * create_arc_curve_from_points(const int resolution, const float3 a, const float3 b, const float3 c, float angle_offset, const bool connect_center, const bool invert_arc, float3 &r_center, float3 &r_normal, float &r_radius)
static void node_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_declare(NodeDeclarationBuilder &b)
static void node_rna(StructRNA *srna)
static Curves * create_arc_curve_from_radius(const int resolution, const float radius, const float start_angle, const float sweep_angle, const bool connect_center, const bool invert_arc)
static float3 rotate_vector_around_axis(const float3 vector, const float3 axis, const float angle)
static void node_init(bNodeTree *, bNode *node)
static void node_register()
static bool colinear_f3_f3_f3(const float3 p1, const float3 p2, const float3 p3)
static void node_geo_exec(GeoNodeExecParams params)
PropertyRNA * RNA_def_node_enum(StructRNA *srna, const char *identifier, const char *ui_name, const char *ui_description, const EnumPropertyItem *static_items, const EnumRNAAccessors accessors, std::optional< int > default_value, const EnumPropertyItemFunc item_func, const bool allow_animation)
VecBase< float, 3 > float3
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
void node_free_standard_storage(bNode *node)
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
std::string ui_description
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeGeometryExecFunction geometry_node_execute
const char * enum_name_legacy
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare
static GeometrySet from_curves(Curves *curves, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)