blob: 8c5a92904ab167c04af8c659a9b5654a155673e8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include "node_geometry_util.hh"
namespace blender::nodes::node_geo_input_instance_rotation_cc {
static void node_declare(NodeDeclarationBuilder &b)
{
b.add_output<decl::Vector>(N_("Rotation")).field_source();
}
class InstanceRotationFieldInput final : public bke::InstancesFieldInput {
public:
InstanceRotationFieldInput() : bke::InstancesFieldInput(CPPType::get<float3>(), "Rotation")
{
}
GVArray get_varray_for_context(const InstancesComponent &instances,
IndexMask UNUSED(mask)) const final
{
auto rotation_fn = [&](const int i) -> float3 {
return instances.instance_transforms()[i].to_euler();
};
return VArray<float3>::ForFunc(instances.instances_num(), rotation_fn);
}
uint64_t hash() const override
{
return 22374372;
}
bool is_equal_to(const fn::FieldNode &other) const override
{
return dynamic_cast<const InstanceRotationFieldInput *>(&other) != nullptr;
}
};
static void node_geo_exec(GeoNodeExecParams params)
{
Field<float3> rotation{std::make_shared<InstanceRotationFieldInput>()};
params.set_output("Rotation", std::move(rotation));
}
} // namespace blender::nodes::node_geo_input_instance_rotation_cc
void register_node_type_geo_input_instance_rotation()
{
namespace file_ns = blender::nodes::node_geo_input_instance_rotation_cc;
static bNodeType ntype;
geo_node_type_base(
&ntype, GEO_NODE_INPUT_INSTANCE_ROTATION, "Instance Rotation", NODE_CLASS_INPUT);
ntype.geometry_node_execute = file_ns::node_geo_exec;
ntype.declare = file_ns::node_declare;
nodeRegisterType(&ntype);
}
|