Blender V5.3
node_geo_edge_split.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "DNA_mesh_types.h"
6
9
10#include "node_geometry_util.hh"
11
13
15{
16 b.use_custom_socket_order();
17 b.allow_any_socket_order();
18 b.add_input<decl::Geometry>("Mesh"_ustr)
19 .supported_type(GeometryComponent::Type::Mesh)
20 .description("Mesh whose edges to split");
21 b.add_output<decl::Geometry>("Mesh"_ustr).propagate_all_geometry().align_with_previous();
22 b.add_input<decl::Bool>("Selection"_ustr)
23 .default_value(true)
24 .hide_value()
25 .evaluated_geometry_field();
26}
27
29{
30 GeometrySet geometry_set = params.extract_input<GeometrySet>("Mesh"_ustr);
31
32 const Field<bool> selection_field = params.extract_input<Field<bool>>("Selection"_ustr);
33
34 geometry::foreach_real_geometry(geometry_set, [&](GeometrySet &geometry_set) {
35 if (const Mesh *mesh = geometry_set.get_mesh()) {
36 const bke::MeshFieldContext field_context{*mesh, AttrDomain::Edge};
37 fn::FieldEvaluator selection_evaluator{field_context, mesh->edges_num};
38 selection_evaluator.set_selection(selection_field);
39 selection_evaluator.evaluate();
40 const IndexMask mask = selection_evaluator.get_evaluated_selection_as_mask();
41 if (mask.is_empty()) {
42 return;
43 }
44
46 *geometry_set.get_mesh_for_write(), mask, params.get_attribute_filter("Mesh"_ustr));
47 }
48 });
49
50 params.set_output("Mesh"_ustr, std::move(geometry_set));
51}
52
53static void node_register()
54{
55 static bke::bNodeType ntype;
56
57 geo_node_type_base(&ntype, "GeometryNodeSplitEdges"_ustr, GEO_NODE_SPLIT_EDGES);
58 ntype.ui_name = "Split Edges";
59 ntype.ui_description = "Duplicate mesh edges and break connections with the surrounding faces";
60 ntype.enum_name_legacy = "SPLIT_EDGES";
63 ntype.declare = node_declare;
65}
67
68} // namespace blender::nodes::node_geo_edge_split_cc
#define NODE_CLASS_GEOMETRY
Definition BKE_node.hh:492
#define GEO_NODE_SPLIT_EDGES
#define NOD_REGISTER_NODE(REGISTER_FUNC)
void set_selection(Field< bool > selection)
IndexMask get_evaluated_selection_as_mask() const
NodeAttributeFilter get_attribute_filter(const UString output_identifier) const
T extract_input(const UString identifier)
void set_output(const UString identifier, T &&value)
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
void foreach_real_geometry(bke::GeometrySet &geometry, FunctionRef< void(bke::GeometrySet &geometry_set)> fn)
void split_edges(Mesh &mesh, const IndexMask &selected_edges, const bke::AttributeFilter &attribute_filter={})
static void node_geo_exec(GeoNodeExecParams params)
static void node_declare(NodeDeclarationBuilder &b)
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
const Mesh * get_mesh() const
Defines a node type.
Definition BKE_node.hh:265
std::string ui_description
Definition BKE_node.hh:271
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:385
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeDeclareFunction declare
Definition BKE_node.hh:393