Blender V4.5
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
8
9#include "BLI_assert.h"
11#include "BLI_math_matrix.hh"
12
13#include "UI_interface.hh"
14#include "UI_resources.hh"
15
16#include "COM_node_operation.hh"
17
19
20/* **************** Rotate ******************** */
21
23
25{
26 b.add_input<decl::Color>("Image")
27 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
28 .compositor_realization_mode(CompositorInputRealizationMode::None)
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{
42}
43
45{
46 layout->prop(ptr, "filter_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
47}
48
49using namespace blender::compositor;
50
52 public:
54
55 void execute() override
56 {
57 const math::AngleRadian rotation = this->get_input("Degr").get_single_value_default(0.0f);
58 const float3x3 transformation = math::from_rotation<float3x3>(rotation);
59
60 const Result &input = this->get_input("Image");
61 Result &output = this->get_result("Image");
62 output.share_data(input);
63 output.transform(transformation);
64 output.get_realization_options().interpolation = this->get_interpolation();
65 }
66
81};
82
84{
85 return new RotateOperation(context, node);
86}
87
88} // namespace blender::nodes::node_composite_rotate_cc
89
91{
93
94 static blender::bke::bNodeType ntype;
95
96 cmp_node_type_base(&ntype, "CompositorNodeRotate", CMP_NODE_ROTATE);
97 ntype.ui_name = "Rotate";
98 ntype.ui_description = "Rotate image by specified angle";
99 ntype.enum_name_legacy = "ROTATE";
101 ntype.declare = file_ns::cmp_node_rotate_declare;
102 ntype.draw_buttons = file_ns::node_composit_buts_rotate;
103 ntype.initfunc = file_ns::node_composit_init_rotate;
104 ntype.get_compositor_operation = file_ns::get_compositor_operation;
105
107}
#define NODE_CLASS_DISTORT
Definition BKE_node.hh:441
#define CMP_NODE_ROTATE
#define BLI_assert_unreachable()
Definition BLI_assert.h:93
CMPNodeInterpolation
@ CMP_NODE_INTERPOLATION_NEAREST
@ CMP_NODE_INTERPOLATION_BILINEAR
@ CMP_NODE_INTERPOLATION_BICUBIC
#define NOD_REGISTER_NODE(REGISTER_FUNC)
@ PROP_ANGLE
Definition RNA_types.hh:240
@ UI_ITEM_R_SPLIT_EMPTY_NAME
NodeOperation(Context &context, DNode node)
Result & get_result(StringRef identifier)
Definition operation.cc:39
Result & get_input(StringRef identifier) const
Definition operation.cc:138
void share_data(const Result &source)
Definition result.cc:401
T get_single_value_default(const T &default_value) const
#define input
#define output
void node_register_type(bNodeType &ntype)
Definition node.cc:2748
AngleRadianBase< float > AngleRadian
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)
MatBase< float, 3, 3 > float3x3
static void register_node_type_cmp_rotate()
void cmp_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
int16_t custom1
Defines a node type.
Definition BKE_node.hh:226
std::string ui_description
Definition BKE_node.hh:232
NodeGetCompositorOperationFunction get_compositor_operation
Definition BKE_node.hh:336
void(* initfunc)(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:277
const char * enum_name_legacy
Definition BKE_node.hh:235
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:247
NodeDeclareFunction declare
Definition BKE_node.hh:355
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)
PointerRNA * ptr
Definition wm_files.cc:4227