Blender V5.0
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").field_source();
16}
17
19 public:
21 : bke::InstancesFieldInput(CPPType::get<math::Quaternion>(), "Rotation")
22 {
23 }
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 uint64_t hash() const override
35 {
36 return 22374372;
37 }
38
39 bool is_equal_to(const fn::FieldNode &other) const override
40 {
41 return dynamic_cast<const InstanceRotationFieldInput *>(&other) != nullptr;
42 }
43};
44
46{
47 Field<math::Quaternion> rotation{std::make_shared<InstanceRotationFieldInput>()};
48 params.set_output("Rotation", std::move(rotation));
49}
50
51static void node_register()
52{
53 static blender::bke::bNodeType ntype;
55 &ntype, "GeometryNodeInputInstanceRotation", GEO_NODE_INPUT_INSTANCE_ROTATION);
56 ntype.ui_name = "Instance Rotation";
57 ntype.ui_description = "Retrieve the rotation of each instance in the geometry";
58 ntype.enum_name_legacy = "INPUT_INSTANCE_ROTATION";
61 ntype.declare = node_declare;
63}
65
66} // namespace blender::nodes::node_geo_input_instance_rotation_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:447
#define GEO_NODE_INPUT_INSTANCE_ROTATION
#define final(a, b, c)
Definition BLI_hash.h:19
#define NOD_REGISTER_NODE(REGISTER_FUNC)
unsigned long long int uint64_t
static VArray from_func(const int64_t size, GetFunc get_func)
GVArray get_varray_for_context(const bke::Instances &instances, const IndexMask &) const final
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_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
i
Definition text_draw.cc:230