Blender V4.3
node_geo_separate_components.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
6
8
10{
11 b.add_input<decl::Geometry>("Geometry");
12 b.add_output<decl::Geometry>("Mesh").propagate_all();
13 b.add_output<decl::Geometry>("Curve").propagate_all();
14 b.add_output<decl::Geometry>("Grease Pencil").propagate_all();
15 b.add_output<decl::Geometry>("Point Cloud").propagate_all();
16 b.add_output<decl::Geometry>("Volume")
17 .translation_context(BLT_I18NCONTEXT_ID_ID)
18 .propagate_all();
19 b.add_output<decl::Geometry>("Instances").propagate_all();
20}
21
23{
24 GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry");
25
26 GeometrySet meshes;
27 GeometrySet curves;
28 GeometrySet grease_pencil;
29 GeometrySet point_clouds;
30 GeometrySet volumes;
31 GeometrySet instances;
32
33 const std::string &name = geometry_set.name;
34 meshes.name = name;
35 curves.name = name;
36 grease_pencil.name = name;
37 point_clouds.name = name;
38 volumes.name = name;
39 instances.name = name;
40
41 if (geometry_set.has<MeshComponent>()) {
42 meshes.add(*geometry_set.get_component<MeshComponent>());
43 }
44 if (geometry_set.has<CurveComponent>()) {
45 curves.add(*geometry_set.get_component<CurveComponent>());
46 }
47 if (geometry_set.has<GreasePencilComponent>()) {
48 grease_pencil.add(*geometry_set.get_component<GreasePencilComponent>());
49 }
50 if (geometry_set.has<PointCloudComponent>()) {
51 point_clouds.add(*geometry_set.get_component<PointCloudComponent>());
52 }
53 if (geometry_set.has<VolumeComponent>()) {
54 volumes.add(*geometry_set.get_component<VolumeComponent>());
55 }
56 if (geometry_set.has<InstancesComponent>()) {
57 instances.add(*geometry_set.get_component<InstancesComponent>());
58 }
59
60 params.set_output("Mesh", meshes);
61 params.set_output("Curve", curves);
62 params.set_output("Grease Pencil", grease_pencil);
63 params.set_output("Point Cloud", point_clouds);
64 params.set_output("Volume", volumes);
65 params.set_output("Instances", instances);
66}
67
68static void node_register()
69{
70 static blender::bke::bNodeType ntype;
71
73 &ntype, GEO_NODE_SEPARATE_COMPONENTS, "Separate Components", NODE_CLASS_GEOMETRY);
74 ntype.declare = node_declare;
77}
79
80} // namespace blender::nodes::node_geo_separate_components_cc
#define NODE_CLASS_GEOMETRY
Definition BKE_node.hh:418
#define BLT_I18NCONTEXT_ID_ID
#define NOD_REGISTER_NODE(REGISTER_FUNC)
local_group_size(16, 16) .push_constant(Type b
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
void geo_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
bool has(const GeometryComponent::Type component_type) const
const GeometryComponent * get_component(GeometryComponent::Type component_type) const
void add(const GeometryComponent &component)
Defines a node type.
Definition BKE_node.hh:218
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:339
NodeDeclareFunction declare
Definition BKE_node.hh:347