Blender V4.3
node_composite_rotate.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2006 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "BLI_assert.h"
11#include "BLI_math_matrix.hh"
12
13#include "UI_interface.hh"
14#include "UI_resources.hh"
15
17#include "COM_node_operation.hh"
18
20
21/* **************** Rotate ******************** */
22
24
26{
27 b.add_input<decl::Color>("Image")
28 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
29 .compositor_domain_priority(0);
30 b.add_input<decl::Float>("Degr")
31 .default_value(0.0f)
32 .min(-10000.0f)
33 .max(10000.0f)
35 .compositor_expects_single_value();
36 b.add_output<decl::Color>("Image");
37}
38
39static void node_composit_init_rotate(bNodeTree * /*ntree*/, bNode *node)
40{
41 node->custom1 = 1; /* Bilinear Filter. */
42}
43
45{
46 uiItemR(layout, ptr, "filter_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
47}
48
49using namespace blender::realtime_compositor;
50
52 public:
54
55 void execute() override
56 {
57 Result &input = get_input("Image");
58 Result &output = get_result("Image");
59
60 const math::AngleRadian rotation = get_input("Degr").get_float_value_default(0.0f);
61 const float3x3 transformation = math::from_rotation<float3x3>(rotation);
62
63 RealizationOptions realization_options = input.get_realization_options();
64 realization_options.interpolation = get_interpolation();
65
66 transform(context(), input, output, transformation, realization_options);
67 }
68
70 {
71 switch (bnode().custom1) {
72 case 0:
73 return Interpolation::Nearest;
74 case 1:
75 return Interpolation::Bilinear;
76 case 2:
77 return Interpolation::Bicubic;
78 }
79
81 return Interpolation::Nearest;
82 }
83};
84
86{
87 return new RotateOperation(context, node);
88}
89
90} // namespace blender::nodes::node_composite_rotate_cc
91
93{
95
96 static blender::bke::bNodeType ntype;
97
98 cmp_node_type_base(&ntype, CMP_NODE_ROTATE, "Rotate", NODE_CLASS_DISTORT);
99 ntype.declare = file_ns::cmp_node_rotate_declare;
100 ntype.draw_buttons = file_ns::node_composit_buts_rotate;
101 ntype.initfunc = file_ns::node_composit_init_rotate;
102 ntype.get_compositor_operation = file_ns::get_compositor_operation;
103
105}
#define NODE_CLASS_DISTORT
Definition BKE_node.hh:412
#define BLI_assert_unreachable()
Definition BLI_assert.h:97
@ PROP_ANGLE
Definition RNA_types.hh:155
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
NodeOperation(Context &context, DNode node)
Result & get_input(StringRef identifier) const
Definition operation.cc:144
Result & get_result(StringRef identifier)
Definition operation.cc:46
float get_float_value_default(float default_value) const
Definition result.cc:413
local_group_size(16, 16) .push_constant(Type b
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
MatT from_rotation(const RotationT &rotation)
static void node_composit_buts_rotate(uiLayout *layout, bContext *, PointerRNA *ptr)
static void cmp_node_rotate_declare(NodeDeclarationBuilder &b)
static void node_composit_init_rotate(bNodeTree *, bNode *node)
static NodeOperation * get_compositor_operation(Context &context, DNode node)
void transform(Context &context, Result &input, Result &output, const float3x3 &transformation, RealizationOptions realization_options)
void register_node_type_cmp_rotate()
void cmp_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
Defines a node type.
Definition BKE_node.hh:218
NodeGetCompositorOperationFunction get_compositor_operation
Definition BKE_node.hh:324
void(* initfunc)(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:267
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