Blender V4.3
node_fn_euler_to_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
5#include "BLI_math_euler.hh"
6
9
10#include "node_function_util.hh"
11
13
15{
16 b.is_function_node();
17 b.add_input<decl::Vector>("Euler").subtype(PROP_EULER);
18 b.add_output<decl::Rotation>("Rotation");
19};
20
22{
23 static auto fn = mf::build::SI1_SO<float3, math::Quaternion>(
24 "Euler XYZ to Quaternion",
25 [](float3 euler) { return math::to_quaternion(math::EulerXYZ(euler)); });
26 builder.set_matching_fn(fn);
27}
28
30{
31 using namespace value_elem;
32 RotationElem rotation_elem;
33 rotation_elem.euler = params.get_input_elem<VectorElem>("Euler");
34 if (rotation_elem) {
35 rotation_elem.axis = VectorElem::all();
36 rotation_elem.angle = FloatElem::all();
37 }
38 params.set_output_elem("Rotation", rotation_elem);
39}
40
42{
43 using namespace value_elem;
44 const RotationElem rotation_elem = params.get_output_elem<RotationElem>("Rotation");
45 VectorElem vector_elem = rotation_elem.euler;
46 params.set_input_elem("Euler", vector_elem);
47}
48
50{
51 const math::Quaternion rotation = params.get_output<math::Quaternion>("Rotation");
52 params.set_input("Euler", float3(math::to_euler(rotation)));
53}
54
55static void node_register()
56{
57 static blender::bke::bNodeType ntype;
58 fn_node_type_base(&ntype, FN_NODE_EULER_TO_ROTATION, "Euler to Rotation", NODE_CLASS_CONVERTER);
59 ntype.declare = node_declare;
65}
67
68} // namespace blender::nodes::node_fn_euler_to_rotation_cc
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:410
#define NOD_REGISTER_NODE(REGISTER_FUNC)
@ PROP_EULER
Definition RNA_types.hh:169
void set_matching_fn(const mf::MultiFunction *fn)
local_group_size(16, 16) .push_constant(Type b
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
QuaternionBase< T > to_quaternion(const AxisAngleBase< T, AngleT > &axis_angle)
Euler3Base< T > to_euler(const AxisAngleBase< T, AngleT > &axis_angle, EulerOrder order)
static void node_declare(NodeDeclarationBuilder &b)
static void node_eval_inverse(inverse_eval::InverseEvalParams &params)
static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
static void node_eval_inverse_elem(value_elem::InverseElemEvalParams &params)
static void node_eval_elem(value_elem::ElemEvalParams &params)
VecBase< float, 3 > float3
void fn_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
Defines a node type.
Definition BKE_node.hh:218
NodeInverseElemEvalFunction eval_inverse_elem
Definition BKE_node.hh:378
NodeInverseEvalFunction eval_inverse
Definition BKE_node.hh:385
NodeElemEvalFunction eval_elem
Definition BKE_node.hh:372
NodeMultiFunctionBuildFunction build_multi_function
Definition BKE_node.hh:336
NodeDeclareFunction declare
Definition BKE_node.hh:347