Blender  V2.93
COM_MovieClipAttributeOperation.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * Copyright 2011, Blender Foundation.
17  */
18 
20 
21 #include "BKE_movieclip.h"
22 #include "BKE_tracking.h"
23 
24 namespace blender::compositor {
25 
27 {
29  this->m_framenumber = 0;
30  this->m_attribute = MCA_X;
31  this->m_invert = false;
32 }
33 
35 {
36  if (this->m_clip == nullptr) {
37  return;
38  }
39  float loc[2], scale, angle;
40  loc[0] = 0.0f;
41  loc[1] = 0.0f;
42  scale = 1.0f;
43  angle = 0.0f;
44  int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(this->m_clip, this->m_framenumber);
46  this->m_clip, clip_framenr, getWidth(), getHeight(), loc, &scale, &angle);
47  switch (this->m_attribute) {
48  case MCA_SCALE:
49  this->m_value = scale;
50  break;
51  case MCA_ANGLE:
52  this->m_value = angle;
53  break;
54  case MCA_X:
55  this->m_value = loc[0];
56  break;
57  case MCA_Y:
58  this->m_value = loc[1];
59  break;
60  }
61  if (this->m_invert) {
62  if (this->m_attribute != MCA_SCALE) {
63  this->m_value = -this->m_value;
64  }
65  else {
66  this->m_value = 1.0f / this->m_value;
67  }
68  }
69 }
70 
72  float /*x*/,
73  float /*y*/,
74  PixelSampler /*sampler*/)
75 {
76  output[0] = this->m_value;
77 }
78 
79 void MovieClipAttributeOperation::determineResolution(unsigned int resolution[2],
80  unsigned int preferredResolution[2])
81 {
82  resolution[0] = preferredResolution[0];
83  resolution[1] = preferredResolution[1];
84 }
85 
86 } // 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 output
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition: btVector3.h:356
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]) override
determine the resolution of this node
void addOutputSocket(DataType datatype)