Blender V4.3
node_composite_transform.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011 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#include "BLI_math_vector.h"
13
14#include "UI_interface.hh"
15#include "UI_resources.hh"
16
18#include "COM_node_operation.hh"
19
21
22/* **************** Transform ******************** */
23
25
27{
28 b.add_input<decl::Color>("Image")
29 .default_value({0.8f, 0.8f, 0.8f, 1.0f})
30 .compositor_domain_priority(0);
31 b.add_input<decl::Float>("X")
32 .default_value(0.0f)
33 .min(-10000.0f)
34 .max(10000.0f)
36 b.add_input<decl::Float>("Y")
37 .default_value(0.0f)
38 .min(-10000.0f)
39 .max(10000.0f)
41 b.add_input<decl::Float>("Angle")
42 .default_value(0.0f)
43 .min(-10000.0f)
44 .max(10000.0f)
46 .compositor_expects_single_value();
47 b.add_input<decl::Float>("Scale")
48 .default_value(1.0f)
49 .min(0.0001f)
50 .max(CMP_SCALE_MAX)
52 b.add_output<decl::Color>("Image");
53}
54
56{
57 uiItemR(layout, ptr, "filter_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
58}
59
60using namespace blender::realtime_compositor;
61
63 public:
65
66 void execute() override
67 {
68 Result &input = get_input("Image");
69 Result &output = get_result("Image");
70
71 const float2 translation = float2(get_input("X").get_float_value_default(0.0f),
72 get_input("Y").get_float_value_default(0.0f));
73 const math::AngleRadian rotation = get_input("Angle").get_float_value_default(0.0f);
74 const float2 scale = float2(get_input("Scale").get_float_value_default(1.0f));
75 const float3x3 transformation = math::from_loc_rot_scale<float3x3>(
76 translation, rotation, scale);
77
78 RealizationOptions realization_options = input.get_realization_options();
79 realization_options.interpolation = get_interpolation();
80
81 transform(context(), input, output, transformation, realization_options);
82 }
83
85 {
86 switch (bnode().custom1) {
87 case 0:
88 return Interpolation::Nearest;
89 case 1:
90 return Interpolation::Bilinear;
91 case 2:
92 return Interpolation::Bicubic;
93 }
94
96 return Interpolation::Nearest;
97 }
98};
99
101{
102 return new TransformOperation(context, node);
103}
104
105} // namespace blender::nodes::node_composite_transform_cc
106
108{
110
111 static blender::bke::bNodeType ntype;
112
113 cmp_node_type_base(&ntype, CMP_NODE_TRANSFORM, "Transform", NODE_CLASS_DISTORT);
114 ntype.declare = file_ns::cmp_node_transform_declare;
115 ntype.draw_buttons = file_ns::node_composit_buts_transform;
116 ntype.get_compositor_operation = file_ns::get_compositor_operation;
117
119}
#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_loc_rot_scale(const typename MatT::loc_type &location, const RotationT &rotation, const VecBase< typename MatT::base_type, ScaleDim > &scale)
static NodeOperation * get_compositor_operation(Context &context, DNode node)
static void cmp_node_transform_declare(NodeDeclarationBuilder &b)
static void node_composit_buts_transform(uiLayout *layout, bContext *, PointerRNA *ptr)
void transform(Context &context, Result &input, Result &output, const float3x3 &transformation, RealizationOptions realization_options)
VecBase< float, 2 > float2
void register_node_type_cmp_transform()
void cmp_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
#define CMP_SCALE_MAX
Defines a node type.
Definition BKE_node.hh:218
NodeGetCompositorOperationFunction get_compositor_operation
Definition BKE_node.hh:324
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