Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/compositor/operations/COM_SunBeamsOperation.cc')
-rw-r--r--source/blender/compositor/operations/COM_SunBeamsOperation.cc77
1 files changed, 29 insertions, 48 deletions
diff --git a/source/blender/compositor/operations/COM_SunBeamsOperation.cc b/source/blender/compositor/operations/COM_SunBeamsOperation.cc
index 494506389c5..ba1363d1193 100644
--- a/source/blender/compositor/operations/COM_SunBeamsOperation.cc
+++ b/source/blender/compositor/operations/COM_SunBeamsOperation.cc
@@ -23,22 +23,22 @@ namespace blender::compositor {
SunBeamsOperation::SunBeamsOperation()
{
- this->addInputSocket(DataType::Color);
- this->addOutputSocket(DataType::Color);
+ this->add_input_socket(DataType::Color);
+ this->add_output_socket(DataType::Color);
this->set_canvas_input_index(0);
- this->flags.complex = true;
+ flags_.complex = true;
}
void SunBeamsOperation::calc_rays_common_data()
{
/* convert to pixels */
- this->m_source_px[0] = this->m_data.source[0] * this->getWidth();
- this->m_source_px[1] = this->m_data.source[1] * this->getHeight();
- this->m_ray_length_px = this->m_data.ray_length * MAX2(this->getWidth(), this->getHeight());
+ source_px_[0] = data_.source[0] * this->get_width();
+ source_px_[1] = data_.source[1] * this->get_height();
+ ray_length_px_ = data_.ray_length * MAX2(this->get_width(), this->get_height());
}
-void SunBeamsOperation::initExecution()
+void SunBeamsOperation::init_execution()
{
calc_rays_common_data();
}
@@ -64,16 +64,6 @@ template<int fxu, int fxv, int fyu, int fyv> struct BufferLineAccumulator {
/* utility functions implementing the matrix transform to/from sector space */
- static inline void buffer_to_sector(const float source[2], int x, int y, int &u, int &v)
- {
- int x0 = (int)source[0];
- int y0 = (int)source[1];
- x -= x0;
- y -= y0;
- u = x * fxu + y * fyu;
- v = x * fxv + y * fyv;
- }
-
static inline void buffer_to_sector(const float source[2], float x, float y, float &u, float &v)
{
int x0 = (int)source[0];
@@ -92,14 +82,6 @@ template<int fxu, int fxv, int fyu, int fyv> struct BufferLineAccumulator {
y = y0 + u * fyu + v * fyv;
}
- static inline void sector_to_buffer(const float source[2], float u, float v, float &x, float &y)
- {
- int x0 = (int)source[0];
- int y0 = (int)source[1];
- x = (float)x0 + u * fxu + v * fxv;
- y = (float)y0 + u * fyu + v * fyv;
- }
-
/**
* Set up the initial buffer pointer and calculate necessary variables for looping.
*
@@ -127,9 +109,9 @@ template<int fxu, int fxv, int fyu, int fyv> struct BufferLineAccumulator {
buffer_to_sector(source, co[0], co[1], pu, pv);
/* line angle */
- float tan_phi = pv / pu;
- float dr = sqrtf(tan_phi * tan_phi + 1.0f);
- float cos_phi = 1.0f / dr;
+ double tan_phi = pv / (double)pu;
+ double dr = sqrt(tan_phi * tan_phi + 1.0);
+ double cos_phi = 1.0 / dr;
/* clamp u range to avoid influence of pixels "behind" the source */
float umin = max_ff(pu - cos_phi * dist_min, 0.0f);
@@ -143,9 +125,9 @@ template<int fxu, int fxv, int fyu, int fyv> struct BufferLineAccumulator {
sector_to_buffer(source, end, (int)ceilf(v), x, y);
- falloff_factor = dist_max > dist_min ? dr / (float)(dist_max - dist_min) : 0.0f;
+ falloff_factor = dist_max > dist_min ? dr / (double)(dist_max - dist_min) : 0.0f;
- float *iter = input->getBuffer() + input->get_coords_offset(x, y);
+ float *iter = input->get_buffer() + input->get_coords_offset(x, y);
return iter;
}
@@ -312,18 +294,17 @@ static void accumulate_line(MemoryBuffer *input,
}
}
-void *SunBeamsOperation::initializeTileData(rcti * /*rect*/)
+void *SunBeamsOperation::initialize_tile_data(rcti * /*rect*/)
{
- void *buffer = getInputOperation(0)->initializeTileData(nullptr);
+ void *buffer = get_input_operation(0)->initialize_tile_data(nullptr);
return buffer;
}
-void SunBeamsOperation::executePixel(float output[4], int x, int y, void *data)
+void SunBeamsOperation::execute_pixel(float output[4], int x, int y, void *data)
{
const float co[2] = {(float)x, (float)y};
- accumulate_line(
- (MemoryBuffer *)data, output, co, this->m_source_px, 0.0f, this->m_ray_length_px);
+ accumulate_line((MemoryBuffer *)data, output, co, source_px_, 0.0f, ray_length_px_);
}
static void calc_ray_shift(rcti *rect, float x, float y, const float source[2], float ray_length)
@@ -341,21 +322,21 @@ static void calc_ray_shift(rcti *rect, float x, float y, const float source[2],
BLI_rcti_do_minmax_v(rect, ico);
}
-bool SunBeamsOperation::determineDependingAreaOfInterest(rcti *input,
- ReadBufferOperation *readOperation,
- rcti *output)
+bool SunBeamsOperation::determine_depending_area_of_interest(rcti *input,
+ ReadBufferOperation *read_operation,
+ rcti *output)
{
/* Enlarges the rect by moving each corner toward the source.
* This is the maximum distance that pixels can influence each other
* and gives a rect that contains all possible accumulated pixels.
*/
rcti rect = *input;
- calc_ray_shift(&rect, input->xmin, input->ymin, this->m_source_px, this->m_ray_length_px);
- calc_ray_shift(&rect, input->xmin, input->ymax, this->m_source_px, this->m_ray_length_px);
- calc_ray_shift(&rect, input->xmax, input->ymin, this->m_source_px, this->m_ray_length_px);
- calc_ray_shift(&rect, input->xmax, input->ymax, this->m_source_px, this->m_ray_length_px);
+ calc_ray_shift(&rect, input->xmin, input->ymin, source_px_, ray_length_px_);
+ calc_ray_shift(&rect, input->xmin, input->ymax, source_px_, ray_length_px_);
+ calc_ray_shift(&rect, input->xmax, input->ymin, source_px_, ray_length_px_);
+ calc_ray_shift(&rect, input->xmax, input->ymax, source_px_, ray_length_px_);
- return NodeOperation::determineDependingAreaOfInterest(&rect, readOperation, output);
+ return NodeOperation::determine_depending_area_of_interest(&rect, read_operation, output);
}
void SunBeamsOperation::get_area_of_interest(const int input_idx,
@@ -370,10 +351,10 @@ void SunBeamsOperation::get_area_of_interest(const int input_idx,
/* Enlarges the rect by moving each corner toward the source.
* This is the maximum distance that pixels can influence each other
* and gives a rect that contains all possible accumulated pixels. */
- calc_ray_shift(&r_input_area, output_area.xmin, output_area.ymin, m_source_px, m_ray_length_px);
- calc_ray_shift(&r_input_area, output_area.xmin, output_area.ymax, m_source_px, m_ray_length_px);
- calc_ray_shift(&r_input_area, output_area.xmax, output_area.ymin, m_source_px, m_ray_length_px);
- calc_ray_shift(&r_input_area, output_area.xmax, output_area.ymax, m_source_px, m_ray_length_px);
+ calc_ray_shift(&r_input_area, output_area.xmin, output_area.ymin, source_px_, ray_length_px_);
+ calc_ray_shift(&r_input_area, output_area.xmin, output_area.ymax, source_px_, ray_length_px_);
+ calc_ray_shift(&r_input_area, output_area.xmax, output_area.ymin, source_px_, ray_length_px_);
+ calc_ray_shift(&r_input_area, output_area.xmax, output_area.ymax, source_px_, ray_length_px_);
}
void SunBeamsOperation::update_memory_buffer_partial(MemoryBuffer *output,
@@ -387,7 +368,7 @@ void SunBeamsOperation::update_memory_buffer_partial(MemoryBuffer *output,
float *out_elem = output->get_elem(area.xmin, y);
for (int x = area.xmin; x < area.xmax; x++) {
coords[0] = x;
- accumulate_line(input, out_elem, coords, m_source_px, 0.0f, m_ray_length_px);
+ accumulate_line(input, out_elem, coords, source_px_, 0.0f, ray_length_px_);
out_elem += output->elem_stride;
}
}