Blender  V3.3
COM_TranslateOperation.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2011 Blender Foundation. */
3 
5 
6 namespace blender::compositor {
7 
9 {
10 }
12 {
13  this->add_input_socket(data_type, resize_mode);
16  this->add_output_socket(data_type);
17  this->set_canvas_input_index(0);
18  input_operation_ = nullptr;
19  input_xoperation_ = nullptr;
20  input_yoperation_ = nullptr;
21  is_delta_set_ = false;
22  factor_x_ = 1.0f;
23  factor_y_ = 1.0f;
26 }
27 
29 {
30  input_operation_ = this->get_input_socket_reader(0);
31  input_xoperation_ = this->get_input_socket_reader(1);
32  input_yoperation_ = this->get_input_socket_reader(2);
33 }
34 
36 {
37  input_operation_ = nullptr;
38  input_xoperation_ = nullptr;
39  input_yoperation_ = nullptr;
40 }
41 
43  float x,
44  float y,
45  PixelSampler /*sampler*/)
46 {
47  ensure_delta();
48 
49  float original_xpos = x - this->getDeltaX();
50  float original_ypos = y - this->getDeltaY();
51 
52  input_operation_->read_sampled(output, original_xpos, original_ypos, PixelSampler::Bilinear);
53 }
54 
56  ReadBufferOperation *read_operation,
57  rcti *output)
58 {
59  rcti new_input;
60 
61  ensure_delta();
62 
63  new_input.xmin = input->xmin - this->getDeltaX();
64  new_input.xmax = input->xmax - this->getDeltaX();
65  new_input.ymin = input->ymin - this->getDeltaY();
66  new_input.ymax = input->ymax - this->getDeltaY();
67 
68  return NodeOperation::determine_depending_area_of_interest(&new_input, read_operation, output);
69 }
70 
71 void TranslateOperation::setFactorXY(float factorX, float factorY)
72 {
73  factor_x_ = factorX;
74  factor_y_ = factorY;
75 }
76 
77 void TranslateOperation::set_wrapping(int wrapping_type)
78 {
79  switch (wrapping_type) {
80  case CMP_NODE_WRAP_X:
82  break;
83  case CMP_NODE_WRAP_Y:
85  break;
86  case CMP_NODE_WRAP_XY:
89  break;
90  default:
91  break;
92  }
93 }
94 
96  const rcti &output_area,
97  rcti &r_input_area)
98 {
99  if (input_idx == 0) {
100  ensure_delta();
101  r_input_area = output_area;
103  const int delta_x = this->getDeltaX();
104  BLI_rcti_translate(&r_input_area, -delta_x, 0);
105  }
107  const int delta_y = this->getDeltaY();
108  BLI_rcti_translate(&r_input_area, 0, -delta_y);
109  }
110  }
111  else {
112  r_input_area = output_area;
113  }
114 }
115 
117  const rcti &area,
119 {
120  MemoryBuffer *input = inputs[0];
121  const int delta_x = this->getDeltaX();
122  const int delta_y = this->getDeltaY();
123  for (int y = area.ymin; y < area.ymax; y++) {
124  float *out = output->get_elem(area.xmin, y);
125  for (int x = area.xmin; x < area.xmax; x++) {
126  const int input_x = x - delta_x;
127  const int input_y = y - delta_y;
128  input->read(out, input_x, input_y, x_extend_mode_, y_extend_mode_);
129  out += output->elem_stride;
130  }
131  }
132 }
133 
136 {
137 }
138 
139 void TranslateCanvasOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
140 {
141  const bool determined =
142  get_input_socket(IMAGE_INPUT_INDEX)->determine_canvas(preferred_area, r_area);
143  if (determined) {
146  rcti unused = COM_AREA_NONE;
147  x_socket->determine_canvas(r_area, unused);
148  y_socket->determine_canvas(r_area, unused);
149 
150  ensure_delta();
151  const float delta_x = x_extend_mode_ == MemoryBufferExtend::Clip ? getDeltaX() : 0.0f;
152  const float delta_y = y_extend_mode_ == MemoryBufferExtend::Clip ? getDeltaY() : 0.0f;
153  BLI_rcti_translate(&r_area, delta_x, delta_y);
154  }
155 }
156 
157 } // namespace blender::compositor
void BLI_rcti_translate(struct rcti *rect, int x, int y)
Definition: rct.c:559
#define CMP_NODE_WRAP_X
#define CMP_NODE_WRAP_XY
#define CMP_NODE_WRAP_Y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between and object coordinate space Combine Create a color from its and value channels Color Retrieve a color or the default fallback if none is specified Separate Split a vector into its and Z components Generates normals with round corners and may slow down renders Vector Displace the surface along an arbitrary direction White Return a random value or color based on an input seed Float Map an input float to a curve and outputs a float value Separate Color
a MemoryBuffer contains access to the data of a chunk
bool determine_canvas(const rcti &preferred_area, rcti &r_area)
void add_output_socket(DataType datatype)
SocketReader * get_input_socket_reader(unsigned int index)
NodeOperationInput * get_input_socket(unsigned int index)
virtual bool determine_depending_area_of_interest(rcti *input, ReadBufferOperation *read_operation, rcti *output)
void read_sampled(float result[4], float x, float y, PixelSampler sampler)
void add_input_socket(DataType datatype, ResizeMode resize_mode=ResizeMode::Center)
void set_canvas_input_index(unsigned int index)
set the index of the input socket that will determine the canvas of this operation
void determine_canvas(const rcti &preferred_area, rcti &r_area) override
void update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span< MemoryBuffer * > inputs) override
bool determine_depending_area_of_interest(rcti *input, ReadBufferOperation *read_operation, rcti *output) override
void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override
calculate a single pixel
void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override
Get input operation area being read by this operation on rendering given output area.
void setFactorXY(float factorX, float factorY)
DataType
possible data types for sockets
Definition: COM_defines.h:30
ResizeMode
Resize modes of inputsockets How are the input and working resolutions matched.
ccl_global KernelShaderEvalInput ccl_global float * output
ccl_global KernelShaderEvalInput * input
static void area(int d1, int d2, int e1, int e2, float weights[2])
constexpr rcti COM_AREA_NONE
Definition: COM_defines.h:112
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static bNodeSocketTemplate inputs[]
int ymin
Definition: DNA_vec_types.h:64
int ymax
Definition: DNA_vec_types.h:64
int xmin
Definition: DNA_vec_types.h:63
int xmax
Definition: DNA_vec_types.h:63