Blender V4.3
node_fn_rotate_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 "UI_interface.hh"
8#include "UI_resources.hh"
9
10#include "NOD_rna_define.hh"
11
12#include "node_function_util.hh"
13
15
16enum class RotationSpace {
17 Global = 0,
18 Local = 1,
19};
20
22{
23 b.is_function_node();
24 b.add_input<decl::Rotation>("Rotation");
25 b.add_input<decl::Rotation>("Rotate By");
26 b.add_output<decl::Rotation>("Rotation");
27};
28
29static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
30{
31 uiItemR(layout, ptr, "rotation_space", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
32}
33
35{
36 switch (RotationSpace(builder.node().custom1)) {
38 static auto fn = mf::build::SI2_SO<math::Quaternion, math::Quaternion, math::Quaternion>(
39 "Rotate Rotation Global", [](math::Quaternion a, math::Quaternion b) { return b * a; });
40 builder.set_matching_fn(fn);
41 break;
42 }
44 static auto fn = mf::build::SI2_SO<math::Quaternion, math::Quaternion, math::Quaternion>(
45 "Rotate Rotation Local", [](math::Quaternion a, math::Quaternion b) { return a * b; });
46 builder.set_matching_fn(fn);
47 break;
48 }
49 }
50}
51
52static void node_rna(StructRNA *srna)
53{
54 static const EnumPropertyItem space_items[] = {
56 "GLOBAL",
57 ICON_NONE,
58 "Global",
59 "Rotate the input rotation in global space"},
61 "LOCAL",
62 ICON_NONE,
63 "Local",
64 "Rotate the input rotation in its local space"},
65 {0, nullptr, 0, nullptr, nullptr},
66 };
67
69 "rotation_space",
70 "Space",
71 "Base orientation for the rotation",
74}
75
76static void node_register()
77{
78 static blender::bke::bNodeType ntype;
79 fn_node_type_base(&ntype, FN_NODE_ROTATE_ROTATION, "Rotate Rotation", NODE_CLASS_CONVERTER);
80 ntype.declare = node_declare;
84
85 node_rna(ntype.rna_ext.srna);
86}
88
89} // namespace blender::nodes::node_fn_rotate_rotation_cc
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:410
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_inline_enum_accessors(member)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
@ UI_ITEM_R_EXPAND
void set_matching_fn(const mf::MultiFunction *fn)
local_group_size(16, 16) .push_constant(Type b
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
static void node_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_declare(NodeDeclarationBuilder &b)
PropertyRNA * RNA_def_node_enum(StructRNA *srna, const char *identifier, const char *ui_name, const char *ui_description, const EnumPropertyItem *static_items, const EnumRNAAccessors accessors, std::optional< int > default_value, const EnumPropertyItemFunc item_func, const bool allow_animation)
void fn_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
static const EnumPropertyItem space_items[]
StructRNA * srna
Definition RNA_types.hh:780
int16_t custom1
Defines a node type.
Definition BKE_node.hh:218
NodeMultiFunctionBuildFunction build_multi_function
Definition BKE_node.hh:336
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:238
NodeDeclareFunction declare
Definition BKE_node.hh:347
PointerRNA * ptr
Definition wm_files.cc:4126