Full frame compositor: Unify relative translate behavior with realtime compositor #115947
|
@ -30,14 +30,7 @@ void TranslateNode::convert_to_operations(NodeConverter &converter,
|
|||
new TranslateOperation() :
|
||||
new TranslateCanvasOperation();
|
||||
operation->set_wrapping(data->wrap_axis);
|
||||
if (data->relative) {
|
||||
const RenderData *rd = context.get_render_data();
|
||||
const float render_size_factor = context.get_render_percentage_as_factor();
|
||||
float fx = rd->xsch * render_size_factor;
|
||||
float fy = rd->ysch * render_size_factor;
|
||||
|
||||
operation->setFactorXY(fx, fy);
|
||||
}
|
||||
operation->set_is_relative(data->relative);
|
||||
|
||||
converter.add_operation(operation);
|
||||
converter.map_input_socket(input_xsocket, operation->get_input_socket(1));
|
||||
|
|
|
@ -18,8 +18,7 @@ TranslateOperation::TranslateOperation(DataType data_type, ResizeMode resize_mod
|
|||
input_xoperation_ = nullptr;
|
||||
input_yoperation_ = nullptr;
|
||||
is_delta_set_ = false;
|
||||
factor_x_ = 1.0f;
|
||||
factor_y_ = 1.0f;
|
||||
is_relative_ = false;
|
||||
this->x_extend_mode_ = MemoryBufferExtend::Clip;
|
||||
this->y_extend_mode_ = MemoryBufferExtend::Clip;
|
||||
|
||||
|
@ -47,8 +46,8 @@ void TranslateOperation::execute_pixel_sampled(float output[4],
|
|||
{
|
||||
ensure_delta();
|
||||
|
||||
float original_xpos = x - this->getDeltaX();
|
||||
float original_ypos = y - this->getDeltaY();
|
||||
float original_xpos = x - this->get_delta_x();
|
||||
float original_ypos = y - this->get_delta_y();
|
||||
|
||||
input_operation_->read_sampled(output, original_xpos, original_ypos, PixelSampler::Bilinear);
|
||||
}
|
||||
|
@ -61,20 +60,14 @@ bool TranslateOperation::determine_depending_area_of_interest(rcti *input,
|
|||
|
||||
ensure_delta();
|
||||
|
||||
new_input.xmin = input->xmin - this->getDeltaX();
|
||||
new_input.xmax = input->xmax - this->getDeltaX();
|
||||
new_input.ymin = input->ymin - this->getDeltaY();
|
||||
new_input.ymax = input->ymax - this->getDeltaY();
|
||||
new_input.xmin = input->xmin - this->get_delta_x();
|
||||
new_input.xmax = input->xmax - this->get_delta_x();
|
||||
new_input.ymin = input->ymin - this->get_delta_y();
|
||||
new_input.ymax = input->ymax - this->get_delta_y();
|
||||
|
||||
return NodeOperation::determine_depending_area_of_interest(&new_input, read_operation, output);
|
||||
}
|
||||
|
||||
void TranslateOperation::setFactorXY(float factorX, float factorY)
|
||||
{
|
||||
factor_x_ = factorX;
|
||||
factor_y_ = factorY;
|
||||
}
|
||||
|
||||
void TranslateOperation::set_wrapping(int wrapping_type)
|
||||
{
|
||||
switch (wrapping_type) {
|
||||
|
@ -101,11 +94,11 @@ void TranslateOperation::get_area_of_interest(const int input_idx,
|
|||
ensure_delta();
|
||||
r_input_area = output_area;
|
||||
if (x_extend_mode_ == MemoryBufferExtend::Clip) {
|
||||
const int delta_x = this->getDeltaX();
|
||||
const int delta_x = this->get_delta_x();
|
||||
BLI_rcti_translate(&r_input_area, -delta_x, 0);
|
||||
}
|
||||
if (y_extend_mode_ == MemoryBufferExtend::Clip) {
|
||||
const int delta_y = this->getDeltaY();
|
||||
const int delta_y = this->get_delta_y();
|
||||
BLI_rcti_translate(&r_input_area, 0, -delta_y);
|
||||
}
|
||||
}
|
||||
|
@ -119,8 +112,8 @@ void TranslateOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
|||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
MemoryBuffer *input = inputs[0];
|
||||
const int delta_x = this->getDeltaX();
|
||||
const int delta_y = this->getDeltaY();
|
||||
const int delta_x = this->get_delta_x();
|
||||
const int delta_y = this->get_delta_y();
|
||||
for (int y = area.ymin; y < area.ymax; y++) {
|
||||
float *out = output->get_elem(area.xmin, y);
|
||||
for (int x = area.xmin; x < area.xmax; x++) {
|
||||
|
@ -149,8 +142,8 @@ void TranslateCanvasOperation::determine_canvas(const rcti &preferred_area, rcti
|
|||
y_socket->determine_canvas(r_area, unused);
|
||||
|
||||
ensure_delta();
|
||||
const float delta_x = x_extend_mode_ == MemoryBufferExtend::Clip ? getDeltaX() : 0.0f;
|
||||
const float delta_y = y_extend_mode_ == MemoryBufferExtend::Clip ? getDeltaY() : 0.0f;
|
||||
const float delta_x = x_extend_mode_ == MemoryBufferExtend::Clip ? get_delta_x() : 0.0f;
|
||||
const float delta_y = y_extend_mode_ == MemoryBufferExtend::Clip ? get_delta_y() : 0.0f;
|
||||
BLI_rcti_translate(&r_area, delta_x, delta_y);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,7 @@ class TranslateOperation : public MultiThreadedOperation {
|
|||
float delta_x_;
|
||||
float delta_y_;
|
||||
bool is_delta_set_;
|
||||
float factor_x_;
|
||||
float factor_y_;
|
||||
bool is_relative_;
|
||||
|
||||
protected:
|
||||
MemoryBufferExtend x_extend_mode_;
|
||||
|
@ -40,13 +39,22 @@ class TranslateOperation : public MultiThreadedOperation {
|
|||
void init_execution() override;
|
||||
void deinit_execution() override;
|
||||
|
||||
float getDeltaX()
|
||||
float get_delta_x()
|
||||
{
|
||||
return delta_x_ * factor_x_;
|
||||
return delta_x_;
|
||||
}
|
||||
float getDeltaY()
|
||||
float get_delta_y()
|
||||
{
|
||||
return delta_y_ * factor_y_;
|
||||
return delta_y_;
|
||||
}
|
||||
|
||||
void set_is_relative(const bool is_relative)
|
||||
{
|
||||
is_relative_ = is_relative;
|
||||
}
|
||||
bool get_is_relative()
|
||||
{
|
||||
return is_relative_;
|
||||
}
|
||||
|
||||
inline void ensure_delta()
|
||||
|
@ -58,17 +66,27 @@ class TranslateOperation : public MultiThreadedOperation {
|
|||
delta_x_ = temp_delta[0];
|
||||
input_yoperation_->read_sampled(temp_delta, 0, 0, PixelSampler::Nearest);
|
||||
delta_y_ = temp_delta[0];
|
||||
if(get_is_relative()) {
|
||||
const int input_width = BLI_rcti_size_x(&input_operation_->get_canvas());
|
||||
const int input_height = BLI_rcti_size_y(&input_operation_->get_canvas());
|
||||
delta_x_ *= input_width;
|
||||
delta_y_ *= input_height;
|
||||
}
|
||||
}
|
||||
else {
|
||||
delta_x_ = get_input_operation(X_INPUT_INDEX)->get_constant_value_default(0.0f);
|
||||
delta_y_ = get_input_operation(Y_INPUT_INDEX)->get_constant_value_default(0.0f);
|
||||
if(get_is_relative()) {
|
||||
const int input_width = BLI_rcti_size_x(&get_input_operation(IMAGE_INPUT_INDEX)->get_canvas());
|
||||
const int input_height = BLI_rcti_size_y(&get_input_operation(IMAGE_INPUT_INDEX)->get_canvas());
|
||||
delta_x_ *= input_width;
|
||||
delta_y_ *= input_height;
|
||||
}
|
||||
}
|
||||
|
||||
is_delta_set_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void setFactorXY(float factorX, float factorY);
|
||||
void set_wrapping(int wrapping_type);
|
||||
|
||||
void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override;
|
||||
|
|
Loading…
Reference in New Issue