Blender V4.5
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
9#include "UI_interface.hh"
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 uiLayout &row = params.layout.row(true);
20 row.column(true).prop(
21 &params.node_ptr, "rotation_euler", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
23 row.prop(&params.socket_ptr, "pin_gizmo", UI_ITEM_NONE, "", ICON_GIZMO);
24 }
25 });
26}
27
29{
30 const bNode &bnode = builder.node();
31 const NodeInputRotation &node_storage = *static_cast<const NodeInputRotation *>(bnode.storage);
32 const math::EulerXYZ euler_rotation(node_storage.rotation_euler[0],
33 node_storage.rotation_euler[1],
34 node_storage.rotation_euler[2]);
35 builder.construct_and_set_matching_fn<mf::CustomMF_Constant<math::Quaternion>>(
36 math::to_quaternion(euler_rotation));
37}
38
39static void node_init(bNodeTree * /*tree*/, bNode *node)
40{
42 node->storage = data;
43}
44
45static void node_register()
46{
47 static blender::bke::bNodeType ntype;
48
49 fn_node_type_base(&ntype, "FunctionNodeInputRotation", FN_NODE_INPUT_ROTATION);
50 ntype.ui_name = "Rotation";
51 ntype.enum_name_legacy = "INPUT_ROTATION";
53 ntype.declare = node_declare;
54 ntype.initfunc = node_init;
56 ntype, "NodeInputRotation", node_free_standard_storage, node_copy_standard_storage);
59}
61
62} // namespace blender::nodes::node_fn_input_rotation_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:433
#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:2748
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:5603
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:226
void(* initfunc)(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:277
NodeMultiFunctionBuildFunction build_multi_function
Definition BKE_node.hh:344
const char * enum_name_legacy
Definition BKE_node.hh:235
NodeDeclareFunction declare
Definition BKE_node.hh:355
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)