Blender V5.0
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")
14 .only_instances()
15 .description("Instances to transform individually");
16 b.add_output<decl::Geometry>("Instances").propagate_all().align_with_previous();
17 b.add_input<decl::Bool>("Selection").default_value(true).hide_value().field_on_all();
18 b.add_input<decl::Matrix>("Transform")
19 .field_on_all()
21 .structure_type(StructureType::Field);
22}
23
25{
26 GeometrySet geometry_set = params.extract_input<GeometrySet>("Instances");
27 Field<bool> selection_field = params.extract_input<Field<bool>>("Selection");
28 Field<float4x4> transform_field = params.extract_input<Field<float4x4>>("Transform");
29
30 if (geometry_set.has_instances()) {
33 instances, "instance_transform", AttrDomain::Instance, selection_field, transform_field);
34 }
35
36 params.set_output("Instances", std::move(geometry_set));
37}
38
39static void node_register()
40{
41 static bke::bNodeType ntype;
42
43 geo_node_type_base(&ntype, "GeometryNodeSetInstanceTransform", GEO_NODE_SET_INSTANCE_TRANSFORM);
44 ntype.ui_name = "Set Instance Transform";
45 ntype.ui_description = "Set the transformation matrix of every instance";
46 ntype.enum_name_legacy = "SET_INSTANCE_TRANSFORM";
49 ntype.declare = node_declare;
50 bke::node_type_size(ntype, 160, 100, 700);
51 node_register_type(ntype);
52}
54
55} // namespace blender::nodes::node_geo_set_instance_transform_cc
#define NODE_CLASS_GEOMETRY
Definition BKE_node.hh:461
#define GEO_NODE_SET_INSTANCE_TRANSFORM
@ NODE_DEFAULT_INPUT_INSTANCE_TRANSFORM_FIELD
#define NOD_REGISTER_NODE(REGISTER_FUNC)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_type_size(bNodeType &ntype, int width, int minwidth, int maxwidth)
Definition node.cc:5384
bool try_capture_field_on_geometry(MutableAttributeAccessor attributes, const fn::FieldContext &field_context, const StringRef attribute_id, AttrDomain domain, const fn::Field< bool > &selection, const fn::GField &field)
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
GeometryComponent & get_component_for_write(GeometryComponent::Type component_type)
Defines a node type.
Definition BKE_node.hh:238
std::string ui_description
Definition BKE_node.hh:244
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:354
const char * enum_name_legacy
Definition BKE_node.hh:247
NodeDeclareFunction declare
Definition BKE_node.hh:362