Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc
| Show All 17 Lines | |||||
| #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_set_curve_handles_cc { | namespace blender::nodes::node_geo_set_curve_handles_cc { | ||||
| static void geo_node_set_curve_handles_declare(NodeDeclarationBuilder &b) | static void node_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_input<decl::Geometry>(N_("Curve")).supported_type(GEO_COMPONENT_TYPE_CURVE); | b.add_input<decl::Geometry>(N_("Curve")).supported_type(GEO_COMPONENT_TYPE_CURVE); | ||||
| b.add_input<decl::Bool>(N_("Selection")).default_value(true).hide_value().supports_field(); | b.add_input<decl::Bool>(N_("Selection")).default_value(true).hide_value().supports_field(); | ||||
| b.add_input<decl::Vector>(N_("Position")).implicit_field(); | b.add_input<decl::Vector>(N_("Position")).implicit_field(); | ||||
| b.add_input<decl::Vector>(N_("Offset")).default_value(float3(0.0f, 0.0f, 0.0f)).supports_field(); | b.add_input<decl::Vector>(N_("Offset")).default_value(float3(0.0f, 0.0f, 0.0f)).supports_field(); | ||||
| b.add_output<decl::Geometry>(N_("Curve")); | b.add_output<decl::Geometry>(N_("Curve")); | ||||
| } | } | ||||
| static void geo_node_set_curve_handles_layout(uiLayout *layout, | static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | ||||
| 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 geo_node_set_curve_handles_init(bNodeTree *UNUSED(tree), bNode *node) | static void node_init(bNodeTree *UNUSED(tree), bNode *node) | ||||
| { | { | ||||
| NodeGeometrySetCurveHandlePositions *data = (NodeGeometrySetCurveHandlePositions *)MEM_callocN( | NodeGeometrySetCurveHandlePositions *data = (NodeGeometrySetCurveHandlePositions *)MEM_callocN( | ||||
| sizeof(NodeGeometrySetCurveHandlePositions), __func__); | sizeof(NodeGeometrySetCurveHandlePositions), __func__); | ||||
| data->mode = GEO_NODE_CURVE_HANDLE_LEFT; | data->mode = GEO_NODE_CURVE_HANDLE_LEFT; | ||||
| node->storage = data; | node->storage = data; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | static void set_position_in_component(const GeometryNodeCurveHandleMode mode, | ||||
| for (int i : selection) { | for (int i : selection) { | ||||
| position_mutable[i] = positions_input[i] + offsets_input[i]; | position_mutable[i] = positions_input[i] + offsets_input[i]; | ||||
| } | } | ||||
| positions.save(); | positions.save(); | ||||
| } | } | ||||
| static void geo_node_set_curve_handles_exec(GeoNodeExecParams params) | static void node_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| const NodeGeometrySetCurveHandlePositions *node_storage = | const NodeGeometrySetCurveHandlePositions *node_storage = | ||||
| (NodeGeometrySetCurveHandlePositions *)params.node().storage; | (NodeGeometrySetCurveHandlePositions *)params.node().storage; | ||||
| const GeometryNodeCurveHandleMode mode = (GeometryNodeCurveHandleMode)node_storage->mode; | const GeometryNodeCurveHandleMode mode = (GeometryNodeCurveHandleMode)node_storage->mode; | ||||
| GeometrySet geometry_set = params.extract_input<GeometrySet>("Curve"); | GeometrySet geometry_set = params.extract_input<GeometrySet>("Curve"); | ||||
| Field<bool> selection_field = params.extract_input<Field<bool>>("Selection"); | Field<bool> selection_field = params.extract_input<Field<bool>>("Selection"); | ||||
| Field<float3> position_field = params.extract_input<Field<float3>>("Position"); | Field<float3> position_field = params.extract_input<Field<float3>>("Position"); | ||||
| Show All 23 Lines | |||||
| void register_node_type_geo_set_curve_handles() | void register_node_type_geo_set_curve_handles() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_set_curve_handles_cc; | namespace file_ns = blender::nodes::node_geo_set_curve_handles_cc; | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| geo_node_type_base( | geo_node_type_base( | ||||
| &ntype, GEO_NODE_SET_CURVE_HANDLES, "Set Handle Positions", NODE_CLASS_GEOMETRY, 0); | &ntype, GEO_NODE_SET_CURVE_HANDLES, "Set Handle Positions", NODE_CLASS_GEOMETRY, 0); | ||||
| ntype.geometry_node_execute = file_ns::geo_node_set_curve_handles_exec; | ntype.geometry_node_execute = file_ns::node_exec; | ||||
| ntype.declare = file_ns::geo_node_set_curve_handles_declare; | ntype.declare = file_ns::node_declare; | ||||
| ntype.minwidth = 100.0f; | ntype.minwidth = 100.0f; | ||||
| node_type_init(&ntype, file_ns::geo_node_set_curve_handles_init); | node_type_init(&ntype, file_ns::node_init); | ||||
| node_type_storage(&ntype, | node_type_storage(&ntype, | ||||
| "NodeGeometrySetCurveHandlePositions", | "NodeGeometrySetCurveHandlePositions", | ||||
| node_free_standard_storage, | node_free_standard_storage, | ||||
| node_copy_standard_storage); | node_copy_standard_storage); | ||||
| ntype.draw_buttons = file_ns::geo_node_set_curve_handles_layout; | ntype.draw_buttons = file_ns::node_layout; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||