Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.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_line_cc { | namespace blender::nodes::node_geo_curve_primitive_line_cc { | ||||
| NODE_STORAGE_FUNCS(NodeGeometryCurvePrimitiveLine) | NODE_STORAGE_FUNCS(NodeGeometryCurvePrimitiveLine) | ||||
| static void node_declare(NodeDeclarationBuilder &b) | static void node_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| auto enable_direction = [](bNode &node) { | |||||
| node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_LINE_MODE_DIRECTION; | |||||
| }; | |||||
| b.add_input<decl::Vector>(N_("Start")) | b.add_input<decl::Vector>(N_("Start")) | ||||
| .subtype(PROP_TRANSLATION) | .subtype(PROP_TRANSLATION) | ||||
| .description(N_("Position of the first control point")); | .description(N_("Position of the first control point")); | ||||
| b.add_input<decl::Vector>(N_("End")) | b.add_input<decl::Vector>(N_("End")) | ||||
| .default_value({0.0f, 0.0f, 1.0f}) | .default_value({0.0f, 0.0f, 1.0f}) | ||||
| .subtype(PROP_TRANSLATION) | .subtype(PROP_TRANSLATION) | ||||
| .description(N_("Position of the second control point")); | .description(N_("Position of the second control point")) | ||||
| .make_available([](bNode &node) { | |||||
| node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_LINE_MODE_POINTS; | |||||
| }); | |||||
| b.add_input<decl::Vector>(N_("Direction")) | b.add_input<decl::Vector>(N_("Direction")) | ||||
| .default_value({0.0f, 0.0f, 1.0f}) | .default_value({0.0f, 0.0f, 1.0f}) | ||||
| .description( | .description(N_("Direction the line is going in. The length of this vector does not matter")) | ||||
| N_("Direction the line is going in. The length of this vector does not matter")); | .make_available(enable_direction); | ||||
| b.add_input<decl::Float>(N_("Length")) | b.add_input<decl::Float>(N_("Length")) | ||||
| .default_value(1.0f) | .default_value(1.0f) | ||||
| .subtype(PROP_DISTANCE) | .subtype(PROP_DISTANCE) | ||||
| .description(N_("Distance between the two points")); | .description(N_("Distance between the two points")) | ||||
| .make_available(enable_direction); | |||||
| b.add_output<decl::Geometry>(N_("Curve")); | b.add_output<decl::Geometry>(N_("Curve")); | ||||
| } | } | ||||
| 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); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines | |||||