Blender  V3.3
node_geo_geometry_to_instance.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include "node_geometry_util.hh"
4 
6 
8 {
9  b.add_input<decl::Geometry>(N_("Geometry")).multi_input();
10  b.add_output<decl::Geometry>(N_("Instances"));
11 }
12 
14 {
15  Vector<GeometrySet> geometries = params.extract_multi_input<GeometrySet>("Geometry");
16  GeometrySet instances_geometry;
17  InstancesComponent &instances_component =
18  instances_geometry.get_component_for_write<InstancesComponent>();
19  for (GeometrySet &geometry : geometries) {
20  geometry.ensure_owns_direct_data();
21  const int handle = instances_component.add_reference(std::move(geometry));
22  instances_component.add_instance(handle, float4x4::identity());
23  }
24  params.set_output("Instances", std::move(instances_geometry));
25 }
26 
27 } // namespace blender::nodes::node_geo_geometry_to_instance_cc
28 
30 {
32 
33  static bNodeType ntype;
34 
36  &ntype, GEO_NODE_GEOMETRY_TO_INSTANCE, "Geometry to Instance", NODE_CLASS_GEOMETRY);
37  node_type_size(&ntype, 160, 100, 300);
40  nodeRegisterType(&ntype);
41 }
void node_type_size(struct bNodeType *ntype, int width, int minwidth, int maxwidth)
Definition: node.cc:4396
#define NODE_CLASS_GEOMETRY
Definition: BKE_node.h:359
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1357
#define GEO_NODE_GEOMETRY_TO_INSTANCE
Definition: BKE_node.h:1483
int add_reference(const InstanceReference &reference)
void add_instance(int instance_handle, const blender::float4x4 &transform)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void register_node_type_geo_geometry_to_instance()
void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
Defines a node type.
Definition: BKE_node.h:226
NodeGeometryExecFunction geometry_node_execute
Definition: BKE_node.h:316
NodeDeclareFunction declare
Definition: BKE_node.h:324
static float4x4 identity()
Definition: BLI_float4x4.hh:80
#define N_(msgid)