Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc
| Show All 11 Lines | |||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| namespace blender::nodes::node_geo_curve_primitive_arc_cc { | namespace blender::nodes::node_geo_curve_primitive_arc_cc { | ||||
| NODE_STORAGE_FUNCS(NodeGeometryCurvePrimitiveArc) | NODE_STORAGE_FUNCS(NodeGeometryCurvePrimitiveArc) | ||||
| static void node_declare(NodeDeclarationBuilder &b) | static void node_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| auto enable_points = [](bNode &node) { | |||||
| node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_ARC_TYPE_POINTS; | |||||
| }; | |||||
| auto enable_radius = [](bNode &node) { | |||||
| node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_ARC_TYPE_RADIUS; | |||||
| }; | |||||
| b.add_input<decl::Int>(N_("Resolution")) | b.add_input<decl::Int>(N_("Resolution")) | ||||
| .default_value(16) | .default_value(16) | ||||
| .min(2) | .min(2) | ||||
| .max(256) | .max(256) | ||||
| .subtype(PROP_UNSIGNED) | .subtype(PROP_UNSIGNED) | ||||
| .description(N_("The number of points on the arc")); | .description(N_("The number of points on the arc")); | ||||
| b.add_input<decl::Vector>(N_("Start")) | b.add_input<decl::Vector>(N_("Start")) | ||||
| .default_value({-1.0f, 0.0f, 0.0f}) | .default_value({-1.0f, 0.0f, 0.0f}) | ||||
| .subtype(PROP_TRANSLATION) | .subtype(PROP_TRANSLATION) | ||||
| .description(N_("Position of the first control point")); | .description(N_("Position of the first control point")) | ||||
| .make_available(enable_points); | |||||
| b.add_input<decl::Vector>(N_("Middle")) | b.add_input<decl::Vector>(N_("Middle")) | ||||
| .default_value({0.0f, 2.0f, 0.0f}) | .default_value({0.0f, 2.0f, 0.0f}) | ||||
| .subtype(PROP_TRANSLATION) | .subtype(PROP_TRANSLATION) | ||||
| .description(N_("Position of the middle control point")); | .description(N_("Position of the middle control point")) | ||||
| .make_available(enable_points); | |||||
| b.add_input<decl::Vector>(N_("End")) | b.add_input<decl::Vector>(N_("End")) | ||||
| .default_value({1.0f, 0.0f, 0.0f}) | .default_value({1.0f, 0.0f, 0.0f}) | ||||
| .subtype(PROP_TRANSLATION) | .subtype(PROP_TRANSLATION) | ||||
| .description(N_("Position of the last control point")); | .description(N_("Position of the last control point")) | ||||
| .make_available(enable_points); | |||||
| b.add_input<decl::Float>(N_("Radius")) | b.add_input<decl::Float>(N_("Radius")) | ||||
| .default_value(1.0f) | .default_value(1.0f) | ||||
| .min(0.0f) | .min(0.0f) | ||||
| .subtype(PROP_DISTANCE) | .subtype(PROP_DISTANCE) | ||||
| .description(N_("Distance of the points from the origin")); | .description(N_("Distance of the points from the origin")) | ||||
| .make_available(enable_radius); | |||||
| b.add_input<decl::Float>(N_("Start Angle")) | b.add_input<decl::Float>(N_("Start Angle")) | ||||
| .default_value(0.0f) | .default_value(0.0f) | ||||
| .subtype(PROP_ANGLE) | .subtype(PROP_ANGLE) | ||||
| .description(N_("Starting angle of the arc")); | .description(N_("Starting angle of the arc")) | ||||
| .make_available(enable_radius); | |||||
| b.add_input<decl::Float>(N_("Sweep Angle")) | b.add_input<decl::Float>(N_("Sweep Angle")) | ||||
| .default_value(1.75f * M_PI) | .default_value(1.75f * M_PI) | ||||
| .min(-2 * M_PI) | .min(-2 * M_PI) | ||||
| .max(2 * M_PI) | .max(2 * M_PI) | ||||
| .subtype(PROP_ANGLE) | .subtype(PROP_ANGLE) | ||||
| .description(N_("Length of the arc")); | .description(N_("Length of the arc")) | ||||
| .make_available(enable_radius); | |||||
| b.add_input<decl::Float>(N_("Offset Angle")) | b.add_input<decl::Float>(N_("Offset Angle")) | ||||
| .default_value(0.0f) | .default_value(0.0f) | ||||
| .subtype(PROP_ANGLE) | .subtype(PROP_ANGLE) | ||||
| .description(N_("Offset angle of the arc")); | .description(N_("Offset angle of the arc")) | ||||
| .make_available(enable_points); | |||||
| b.add_input<decl::Bool>(N_("Connect Center")) | b.add_input<decl::Bool>(N_("Connect Center")) | ||||
| .default_value(false) | .default_value(false) | ||||
| .description(N_("Connect the arc at the center")); | .description(N_("Connect the arc at the center")); | ||||
| b.add_input<decl::Bool>(N_("Invert Arc")) | b.add_input<decl::Bool>(N_("Invert Arc")) | ||||
| .default_value(false) | .default_value(false) | ||||
| .description(N_("Invert and draw opposite arc")); | .description(N_("Invert and draw opposite arc")); | ||||
| b.add_output<decl::Geometry>(N_("Curve")); | b.add_output<decl::Geometry>(N_("Curve")); | ||||
| b.add_output<decl::Vector>(N_("Center")) | b.add_output<decl::Vector>(N_("Center")) | ||||
| .description(N_("The center of the circle described by the three points")) | .description(N_("The center of the circle described by the three points")) | ||||
| .make_available( | .make_available(enable_points); | ||||
| [](bNode &node) { node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_ARC_TYPE_POINTS; }); | |||||
| b.add_output<decl::Vector>(N_("Normal")) | b.add_output<decl::Vector>(N_("Normal")) | ||||
| .description(N_("The normal direction of the plane described by the three points, pointing " | .description(N_("The normal direction of the plane described by the three points, pointing " | ||||
| "towards the positive Z axis")) | "towards the positive Z axis")) | ||||
| .make_available( | .make_available(enable_points); | ||||
| [](bNode &node) { node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_ARC_TYPE_POINTS; }); | |||||
| b.add_output<decl::Float>(N_("Radius")) | b.add_output<decl::Float>(N_("Radius")) | ||||
| .description(N_("The radius of the circle described by the three points")) | .description(N_("The radius of the circle described by the three points")) | ||||
| .make_available( | .make_available(enable_points); | ||||
| [](bNode &node) { node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_ARC_TYPE_POINTS; }); | |||||
| } | } | ||||
| static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | ||||
| { | { | ||||
| uiItemR(layout, ptr, "mode", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); | uiItemR(layout, ptr, "mode", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); | ||||
| } | } | ||||
| static void node_init(bNodeTree *UNUSED(tree), bNode *node) | static void node_init(bNodeTree *UNUSED(tree), bNode *node) | ||||
| ▲ Show 20 Lines • Show All 276 Lines • Show Last 20 Lines | |||||