Blender V5.3
node_geo_input_instance_rotation.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
7#include "BLI_math_matrix.hh"
8
9#include "BKE_instances.hh"
10
12
14{
15 b.add_output<decl::Rotation>("Rotation"_ustr).structure_type(StructureType::Field);
16}
17
19 public:
24
26 const IndexMask & /*mask*/) const final
27 {
28 const Span<float4x4> transforms = instances.transforms();
30 instances.instances_num(),
31 [transforms](const int i) { return math::to_quaternion(math::normalize(transforms[i])); });
32 }
33
34 void hash_unique(UniqueHashBytes &hash, fn::FieldHashDeep & /*deep_hash_cache*/) const override
35 {
36 static constexpr int8_t id = 0;
37 hash.add(&id);
38 }
39};
40
46
47static void node_register()
48{
49 static bke::bNodeType ntype;
51 &ntype, "GeometryNodeInputInstanceRotation"_ustr, GEO_NODE_INPUT_INSTANCE_ROTATION);
52 ntype.ui_name = "Instance Rotation";
53 ntype.ui_description = "Retrieve the rotation of each instance in the geometry";
54 ntype.enum_name_legacy = "INPUT_INSTANCE_ROTATION";
57 ntype.declare = node_declare;
59}
61
62} // namespace blender::nodes::node_geo_input_instance_rotation_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:478
#define GEO_NODE_INPUT_INSTANCE_ROTATION
#define final(a, b, c)
Definition BLI_hash_c.hh:21
#define NOD_REGISTER_NODE(REGISTER_FUNC)
static VArray from_func(const int64_t size, GetFunc get_func)
uint64_t hash() const
Definition field.cc:185
static Field from_input(Args &&...args)
void set_output(const UString identifier, T &&value)
GVArray get_varray_for_context(const bke::Instances &instances, const IndexMask &) const final
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)
signed char int8_t
Definition BKE_text.h:76
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