Blender V5.3
node_geo_set_instance_transform.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
6
8
10{
11 b.use_custom_socket_order();
12 b.allow_any_socket_order();
13 b.add_input<decl::Geometry>("Instances"_ustr)
14 .only_instances()
15 .description("Instances to transform individually");
16 b.add_output<decl::Geometry>("Instances"_ustr).propagate_all_geometry().align_with_previous();
17 b.add_input<decl::Bool>("Selection"_ustr)
18 .default_value(true)
19 .hide_value()
20 .evaluated_geometry_field();
21 b.add_input<decl::Matrix>("Transform"_ustr)
22 .evaluated_geometry_field()
24 .structure_type(StructureType::Field);
25}
26
28{
29 GeometrySet geometry_set = params.extract_input<GeometrySet>("Instances"_ustr);
30 Field<bool> selection_field = params.extract_input<Field<bool>>("Selection"_ustr);
31 Field<float4x4> transform_field = params.extract_input<Field<float4x4>>("Transform"_ustr);
32
33 if (geometry_set.has_instances()) {
36 instances, "instance_transform", AttrDomain::Instance, selection_field, transform_field);
37 }
38
39 params.set_output("Instances"_ustr, std::move(geometry_set));
40}
41
42static void node_register()
43{
44 static bke::bNodeType ntype;
45
47 &ntype, "GeometryNodeSetInstanceTransform"_ustr, GEO_NODE_SET_INSTANCE_TRANSFORM);
48 ntype.ui_name = "Set Instance Transform";
49 ntype.ui_description = "Set the transformation matrix of every instance";
50 ntype.enum_name_legacy = "SET_INSTANCE_TRANSFORM";
53 ntype.declare = node_declare;
55 node_register_type(ntype);
56}
58
59} // namespace blender::nodes::node_geo_set_instance_transform_cc
#define NODE_CLASS_GEOMETRY
Definition BKE_node.hh:492
#define GEO_NODE_SET_INSTANCE_TRANSFORM
#define NOD_REGISTER_NODE(REGISTER_FUNC)
T extract_input(const UString identifier)
void set_output(const UString identifier, T &&value)
bool try_capture_field_on_geometry(MutableAttributeAccessor attributes, const fn::FieldContext &field_context, const StringRef name, AttrDomain domain, const fn::Field< bool > &selection, const fn::GField &field)
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
GeometryComponent & get_component_for_write(GeometryComponent::Type component_type)
static constexpr int _160
Definition BKE_node.hh:246
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