Blender V4.3
COM_MovieClipAttributeOperation.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
6
7#include "BKE_movieclip.h"
8#include "BKE_tracking.h"
9
10namespace blender::compositor {
11
13{
15 framenumber_ = 0;
16 attribute_ = MCA_X;
17 invert_ = false;
19 is_value_calculated_ = false;
20 stabilization_resolution_socket_ = nullptr;
21}
22
24{
25 if (!is_value_calculated_) {
26 calc_value();
27 }
28}
29
30void MovieClipAttributeOperation::calc_value()
31{
32 BLI_assert(this->get_flags().is_canvas_set);
33 is_value_calculated_ = true;
34 if (clip_ == nullptr) {
35 return;
36 }
37 float loc[2], scale, angle;
38 loc[0] = 0.0f;
39 loc[1] = 0.0f;
40 scale = 1.0f;
41 angle = 0.0f;
42 int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip_, framenumber_);
43 NodeOperation &stabilization_operation =
44 stabilization_resolution_socket_ ?
45 stabilization_resolution_socket_->get_link()->get_operation() :
46 *this;
48 clip_framenr,
49 stabilization_operation.get_width(),
50 stabilization_operation.get_height(),
51 loc,
52 &scale,
53 &angle);
54 switch (attribute_) {
55 case MCA_SCALE:
56 value_ = scale;
57 break;
58 case MCA_ANGLE:
59 value_ = angle;
60 break;
61 case MCA_X:
62 value_ = loc[0];
63 break;
64 case MCA_Y:
65 value_ = loc[1];
66 break;
67 }
68 if (invert_) {
69 if (attribute_ != MCA_SCALE) {
70 value_ = -value_;
71 }
72 else {
73 value_ = 1.0f / value_;
74 }
75 }
76}
77
78void MovieClipAttributeOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
79{
80 r_area = preferred_area;
81}
82
84{
85 if (!is_value_calculated_) {
86 calc_value();
87 }
88 return &value_;
89}
90
91} // namespace blender::compositor
float BKE_movieclip_remap_scene_to_clip_frame(const struct MovieClip *clip, float framenr)
void BKE_tracking_stabilization_data_get(struct MovieClip *clip, int framenr, int width, int height, float translation[2], float *scale, float *angle)
#define BLI_assert(a)
Definition BLI_assert.h:50
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
Definition IK_Math.h:125
void determine_canvas(const rcti &preferred_area, rcti &r_area) override
NodeOperationOutput * get_link() const
void add_output_socket(DataType datatype)
const NodeOperationFlags get_flags() const