Blender V5.0
node_fn_input_rotation.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BLI_math_euler.hh"
6
8
10#include "UI_resources.hh"
11
12#include "node_function_util.hh"
13
15
17{
18 b.add_output<decl::Rotation>("Rotation").custom_draw([](CustomSocketDrawParams &params) {
19 params.layout.alignment_set(ui::LayoutAlign::Expand);
20 uiLayout &row = params.layout.row(true);
21 row.column(true).prop(
22 &params.node_ptr, "rotation_euler", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
24 row.prop(&params.socket_ptr, "pin_gizmo", UI_ITEM_NONE, "", ICON_GIZMO);
25 }
26 });
27}
28
30{
31 const bNode &bnode = builder.node();
32 const NodeInputRotation &node_storage = *static_cast<const NodeInputRotation *>(bnode.storage);
33 const math::EulerXYZ euler_rotation(node_storage.rotation_euler[0],
34 node_storage.rotation_euler[1],
35 node_storage.rotation_euler[2]);
36 builder.construct_and_set_matching_fn<mf::CustomMF_Constant<math::Quaternion>>(
37 math::to_quaternion(euler_rotation));
38}
39
40static void node_init(bNodeTree * /*tree*/, bNode *node)
41{
43 node->storage = data;
44}
45
46static void node_register()
47{
48 static blender::bke::bNodeType ntype;
49
50 fn_node_type_base(&ntype, "FunctionNodeInputRotation", FN_NODE_INPUT_ROTATION);
51 ntype.ui_name = "Rotation";
52 ntype.ui_description =
53 "Provide a rotation value that can be connected to other nodes in the tree";
54 ntype.enum_name_legacy = "INPUT_ROTATION";
56 ntype.declare = node_declare;
57 ntype.initfunc = node_init;
59 ntype, "NodeInputRotation", node_free_standard_storage, node_copy_standard_storage);
62}
64
65} // namespace blender::nodes::node_fn_input_rotation_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:447
#define FN_NODE_INPUT_ROTATION
#define NOD_REGISTER_NODE(REGISTER_FUNC)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
#define UI_ITEM_NONE
BMesh const char void * data
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
Definition node.cc:5414
QuaternionBase< T > to_quaternion(const AxisAngleBase< T, AngleT > &axis_angle)
EulerXYZBase< float > EulerXYZ
bool value_node_has_gizmo(const bNodeTree &tree, const bNode &node)
static void node_declare(NodeDeclarationBuilder &b)
static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
static void node_init(bNodeTree *, bNode *node)
void fn_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
void node_free_standard_storage(bNode *node)
Definition node_util.cc:42
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
Definition node_util.cc:54
void * storage
Defines a node type.
Definition BKE_node.hh:238
std::string ui_description
Definition BKE_node.hh:244
void(* initfunc)(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:289
NodeMultiFunctionBuildFunction build_multi_function
Definition BKE_node.hh:351
const char * enum_name_legacy
Definition BKE_node.hh:247
NodeDeclareFunction declare
Definition BKE_node.hh:362
uiLayout & column(bool align)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)