Listing the "Blender Foundation" as copyright holder implied the Blender Foundation holds copyright to files which may include work from many developers. While keeping copyright on headers makes sense for isolated libraries, Blender's own code may be refactored or moved between files in a way that makes the per file copyright holders less meaningful. Copyright references to the "Blender Foundation" have been replaced with "Blender Authors", with the exception of `./extern/` since these this contains libraries which are more isolated, any changed to license headers there can be handled on a case-by-case basis. Some directories in `./intern/` have also been excluded: - `./intern/cycles/` it's own `AUTHORS` file is planned. - `./intern/opensubdiv/`. An "AUTHORS" file has been added, using the chromium projects authors file as a template. Design task: #110784 Ref !110783.
100 lines
2.5 KiB
C++
100 lines
2.5 KiB
C++
/* SPDX-FileCopyrightText: 2011 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#include "COM_MovieClipAttributeOperation.h"
|
|
|
|
#include "BKE_movieclip.h"
|
|
#include "BKE_tracking.h"
|
|
|
|
namespace blender::compositor {
|
|
|
|
MovieClipAttributeOperation::MovieClipAttributeOperation()
|
|
{
|
|
this->add_output_socket(DataType::Value);
|
|
framenumber_ = 0;
|
|
attribute_ = MCA_X;
|
|
invert_ = false;
|
|
needs_canvas_to_get_constant_ = true;
|
|
is_value_calculated_ = false;
|
|
stabilization_resolution_socket_ = nullptr;
|
|
}
|
|
|
|
void MovieClipAttributeOperation::init_execution()
|
|
{
|
|
if (!is_value_calculated_) {
|
|
calc_value();
|
|
}
|
|
}
|
|
|
|
void MovieClipAttributeOperation::calc_value()
|
|
{
|
|
BLI_assert(this->get_flags().is_canvas_set);
|
|
is_value_calculated_ = true;
|
|
if (clip_ == nullptr) {
|
|
return;
|
|
}
|
|
float loc[2], scale, angle;
|
|
loc[0] = 0.0f;
|
|
loc[1] = 0.0f;
|
|
scale = 1.0f;
|
|
angle = 0.0f;
|
|
int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip_, framenumber_);
|
|
NodeOperation &stabilization_operation =
|
|
stabilization_resolution_socket_ ?
|
|
stabilization_resolution_socket_->get_link()->get_operation() :
|
|
*this;
|
|
BKE_tracking_stabilization_data_get(clip_,
|
|
clip_framenr,
|
|
stabilization_operation.get_width(),
|
|
stabilization_operation.get_height(),
|
|
loc,
|
|
&scale,
|
|
&angle);
|
|
switch (attribute_) {
|
|
case MCA_SCALE:
|
|
value_ = scale;
|
|
break;
|
|
case MCA_ANGLE:
|
|
value_ = angle;
|
|
break;
|
|
case MCA_X:
|
|
value_ = loc[0];
|
|
break;
|
|
case MCA_Y:
|
|
value_ = loc[1];
|
|
break;
|
|
}
|
|
if (invert_) {
|
|
if (attribute_ != MCA_SCALE) {
|
|
value_ = -value_;
|
|
}
|
|
else {
|
|
value_ = 1.0f / value_;
|
|
}
|
|
}
|
|
}
|
|
|
|
void MovieClipAttributeOperation::execute_pixel_sampled(float output[4],
|
|
float /*x*/,
|
|
float /*y*/,
|
|
PixelSampler /*sampler*/)
|
|
{
|
|
output[0] = value_;
|
|
}
|
|
|
|
void MovieClipAttributeOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
|
{
|
|
r_area = preferred_area;
|
|
}
|
|
|
|
const float *MovieClipAttributeOperation::get_constant_elem()
|
|
{
|
|
if (!is_value_calculated_) {
|
|
calc_value();
|
|
}
|
|
return &value_;
|
|
}
|
|
|
|
} // namespace blender::compositor
|