Differential D12689 Diff 42663 source/blender/compositor/operations/COM_MovieClipAttributeOperation.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/operations/COM_MovieClipAttributeOperation.cc
| Show All 23 Lines | |||||
| namespace blender::compositor { | namespace blender::compositor { | ||||
| MovieClipAttributeOperation::MovieClipAttributeOperation() | MovieClipAttributeOperation::MovieClipAttributeOperation() | ||||
| { | { | ||||
| this->addOutputSocket(DataType::Value); | this->addOutputSocket(DataType::Value); | ||||
| this->m_framenumber = 0; | this->m_framenumber = 0; | ||||
| this->m_attribute = MCA_X; | this->m_attribute = MCA_X; | ||||
| this->m_invert = false; | this->m_invert = false; | ||||
| needs_resolution_to_get_constant_ = true; | needs_canvas_to_get_constant_ = true; | ||||
| is_value_calculated_ = false; | is_value_calculated_ = false; | ||||
| stabilization_resolution_socket_ = nullptr; | |||||
| } | } | ||||
| void MovieClipAttributeOperation::initExecution() | void MovieClipAttributeOperation::initExecution() | ||||
| { | { | ||||
| if (!is_value_calculated_) { | if (!is_value_calculated_) { | ||||
| calc_value(); | calc_value(); | ||||
| } | } | ||||
| } | } | ||||
| void MovieClipAttributeOperation::calc_value() | void MovieClipAttributeOperation::calc_value() | ||||
| { | { | ||||
| BLI_assert(this->get_flags().is_resolution_set); | BLI_assert(this->get_flags().is_canvas_set); | ||||
| is_value_calculated_ = true; | is_value_calculated_ = true; | ||||
| if (this->m_clip == nullptr) { | if (this->m_clip == nullptr) { | ||||
| return; | return; | ||||
| } | } | ||||
| float loc[2], scale, angle; | float loc[2], scale, angle; | ||||
| loc[0] = 0.0f; | loc[0] = 0.0f; | ||||
| loc[1] = 0.0f; | loc[1] = 0.0f; | ||||
| scale = 1.0f; | scale = 1.0f; | ||||
| angle = 0.0f; | angle = 0.0f; | ||||
| int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(this->m_clip, this->m_framenumber); | int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(this->m_clip, this->m_framenumber); | ||||
| BKE_tracking_stabilization_data_get( | NodeOperation &stabilization_operation = | ||||
| this->m_clip, clip_framenr, getWidth(), getHeight(), loc, &scale, &angle); | stabilization_resolution_socket_ ? | ||||
| stabilization_resolution_socket_->getLink()->getOperation() : | |||||
| *this; | |||||
| BKE_tracking_stabilization_data_get(this->m_clip, | |||||
| clip_framenr, | |||||
| stabilization_operation.getWidth(), | |||||
| stabilization_operation.getHeight(), | |||||
| loc, | |||||
| &scale, | |||||
| &angle); | |||||
| switch (this->m_attribute) { | switch (this->m_attribute) { | ||||
| case MCA_SCALE: | case MCA_SCALE: | ||||
| this->m_value = scale; | this->m_value = scale; | ||||
| break; | break; | ||||
| case MCA_ANGLE: | case MCA_ANGLE: | ||||
| this->m_value = angle; | this->m_value = angle; | ||||
| break; | break; | ||||
| case MCA_X: | case MCA_X: | ||||
| Show All 16 Lines | |||||
| void MovieClipAttributeOperation::executePixelSampled(float output[4], | void MovieClipAttributeOperation::executePixelSampled(float output[4], | ||||
| float /*x*/, | float /*x*/, | ||||
| float /*y*/, | float /*y*/, | ||||
| PixelSampler /*sampler*/) | PixelSampler /*sampler*/) | ||||
| { | { | ||||
| output[0] = this->m_value; | output[0] = this->m_value; | ||||
| } | } | ||||
| void MovieClipAttributeOperation::determineResolution(unsigned int resolution[2], | void MovieClipAttributeOperation::determine_canvas(const rcti &preferred_area, rcti &r_area) | ||||
| unsigned int preferredResolution[2]) | |||||
| { | { | ||||
| resolution[0] = preferredResolution[0]; | r_area = preferred_area; | ||||
| resolution[1] = preferredResolution[1]; | |||||
| } | } | ||||
| const float *MovieClipAttributeOperation::get_constant_elem() | const float *MovieClipAttributeOperation::get_constant_elem() | ||||
| { | { | ||||
| if (!is_value_calculated_) { | if (!is_value_calculated_) { | ||||
| calc_value(); | calc_value(); | ||||
| } | } | ||||
| return &m_value; | return &m_value; | ||||
| } | } | ||||
| } // namespace blender::compositor | } // namespace blender::compositor | ||||