Blender V4.3
node_geo_geometry_to_instance.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 "BKE_instances.hh"
6
8
10
12{
13 b.add_input<decl::Geometry>("Geometry").multi_input();
14 b.add_output<decl::Geometry>("Instances").propagate_all();
15}
16
18{
19 Vector<GeometrySet> geometries = params.extract_input<Vector<GeometrySet>>("Geometry");
20 std::unique_ptr<bke::Instances> instances = std::make_unique<bke::Instances>();
21
22 for (GeometrySet &geometry : geometries) {
23 geometry.ensure_owns_direct_data();
24 const int handle = instances->add_reference(std::move(geometry));
25 instances->add_instance(handle, float4x4::identity());
26 }
27
28 GeometrySet new_geometry = GeometrySet::from_instances(instances.release());
29 params.set_output("Instances", std::move(new_geometry));
30}
31
32static void node_register()
33{
34 static blender::bke::bNodeType ntype;
35
37 &ntype, GEO_NODE_GEOMETRY_TO_INSTANCE, "Geometry to Instance", NODE_CLASS_GEOMETRY);
38 blender::bke::node_type_size(&ntype, 160, 100, 300);
40 ntype.declare = node_declare;
42}
44
45} // namespace blender::nodes::node_geo_geometry_to_instance_cc
#define NODE_CLASS_GEOMETRY
Definition BKE_node.hh:418
#define NOD_REGISTER_NODE(REGISTER_FUNC)
local_group_size(16, 16) .push_constant(Type b
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_type_size(bNodeType *ntype, int width, int minwidth, int maxwidth)
Definition node.cc:4602
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)
static GeometrySet from_instances(Instances *instances, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
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