Differential D14283 Diff 49065 source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||||
| #include "BKE_curves.hh" | #include "BKE_curves.hh" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| namespace blender::nodes::node_geo_curve_primitive_circle_cc { | namespace blender::nodes::node_geo_curve_primitive_circle_cc { | ||||
| NODE_STORAGE_FUNCS(NodeGeometryCurvePrimitiveCircle) | NODE_STORAGE_FUNCS(NodeGeometryCurvePrimitiveCircle) | ||||
| static void node_declare(NodeDeclarationBuilder &b) | static void node_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| auto is_points_mode = [](bNode &node) { | |||||
| node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_POINTS; | |||||
| }; | |||||
| auto is_radius_mode = [](bNode &node) { | |||||
| node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_RADIUS; | |||||
| }; | |||||
| b.add_input<decl::Int>(N_("Resolution")) | b.add_input<decl::Int>(N_("Resolution")) | ||||
| .default_value(32) | .default_value(32) | ||||
| .min(3) | .min(3) | ||||
| .max(512) | .max(512) | ||||
| .description(N_("Number of points on the circle")); | .description(N_("Number of points on the circle")); | ||||
| b.add_input<decl::Vector>(N_("Point 1")) | b.add_input<decl::Vector>(N_("Point 1")) | ||||
| .default_value({-1.0f, 0.0f, 0.0f}) | .default_value({-1.0f, 0.0f, 0.0f}) | ||||
| .subtype(PROP_TRANSLATION) | .subtype(PROP_TRANSLATION) | ||||
| .description( | .description( | ||||
| N_("One of the three points on the circle. The point order determines the circle's " | N_("One of the three points on the circle. The point order determines the circle's " | ||||
| "direction")); | "direction")) | ||||
| .make_available(is_points_mode); | |||||
| b.add_input<decl::Vector>(N_("Point 2")) | b.add_input<decl::Vector>(N_("Point 2")) | ||||
| .default_value({0.0f, 1.0f, 0.0f}) | .default_value({0.0f, 1.0f, 0.0f}) | ||||
| .subtype(PROP_TRANSLATION) | .subtype(PROP_TRANSLATION) | ||||
| .description( | .description( | ||||
| N_("One of the three points on the circle. The point order determines the circle's " | N_("One of the three points on the circle. The point order determines the circle's " | ||||
| "direction")); | "direction")) | ||||
| .make_available(is_points_mode); | |||||
| b.add_input<decl::Vector>(N_("Point 3")) | b.add_input<decl::Vector>(N_("Point 3")) | ||||
| .default_value({1.0f, 0.0f, 0.0f}) | .default_value({1.0f, 0.0f, 0.0f}) | ||||
| .subtype(PROP_TRANSLATION) | .subtype(PROP_TRANSLATION) | ||||
| .description( | .description( | ||||
| N_("One of the three points on the circle. The point order determines the circle's " | N_("One of the three points on the circle. The point order determines the circle's " | ||||
| "direction")); | "direction")) | ||||
| .make_available(is_points_mode); | |||||
| 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(is_radius_mode); | |||||
| b.add_output<decl::Geometry>(N_("Curve")); | b.add_output<decl::Geometry>(N_("Curve")); | ||||
| b.add_output<decl::Vector>(N_("Center")).make_available([](bNode &node) { | b.add_output<decl::Vector>(N_("Center")).make_available(is_points_mode); | ||||
| node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_CIRCLE_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 166 Lines • Show Last 20 Lines | |||||