diff options
Diffstat (limited to 'source/blender/compositor/operations/COM_BokehImageOperation.cc')
-rw-r--r-- | source/blender/compositor/operations/COM_BokehImageOperation.cc | 133 |
1 files changed, 67 insertions, 66 deletions
diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.cc b/source/blender/compositor/operations/COM_BokehImageOperation.cc index 5389fa633b0..9e7c1162052 100644 --- a/source/blender/compositor/operations/COM_BokehImageOperation.cc +++ b/source/blender/compositor/operations/COM_BokehImageOperation.cc @@ -22,91 +22,91 @@ namespace blender::compositor { BokehImageOperation::BokehImageOperation() { - this->addOutputSocket(DataType::Color); - deleteData_ = false; + this->add_output_socket(DataType::Color); + delete_data_ = false; } -void BokehImageOperation::initExecution() +void BokehImageOperation::init_execution() { - center_[0] = getWidth() / 2; - center_[1] = getHeight() / 2; - inverseRounding_ = 1.0f - data_->rounding; - circularDistance_ = getWidth() / 2; - flapRad_ = (float)(M_PI * 2) / data_->flaps; - flapRadAdd_ = data_->angle; - while (flapRadAdd_ < 0.0f) { - flapRadAdd_ += (float)(M_PI * 2.0); + center_[0] = get_width() / 2; + center_[1] = get_height() / 2; + inverse_rounding_ = 1.0f - data_->rounding; + circular_distance_ = get_width() / 2; + flap_rad_ = (float)(M_PI * 2) / data_->flaps; + flap_rad_add_ = data_->angle; + while (flap_rad_add_ < 0.0f) { + flap_rad_add_ += (float)(M_PI * 2.0); } - while (flapRadAdd_ > (float)M_PI) { - flapRadAdd_ -= (float)(M_PI * 2.0); + while (flap_rad_add_ > (float)M_PI) { + flap_rad_add_ -= (float)(M_PI * 2.0); } } -void BokehImageOperation::detemineStartPointOfFlap(float r[2], int flapNumber, float distance) +void BokehImageOperation::detemine_start_point_of_flap(float r[2], int flap_number, float distance) { - r[0] = sinf(flapRad_ * flapNumber + flapRadAdd_) * distance + center_[0]; - r[1] = cosf(flapRad_ * flapNumber + flapRadAdd_) * distance + center_[1]; + r[0] = sinf(flap_rad_ * flap_number + flap_rad_add_) * distance + center_[0]; + r[1] = cosf(flap_rad_ * flap_number + flap_rad_add_) * distance + center_[1]; } -float BokehImageOperation::isInsideBokeh(float distance, float x, float y) +float BokehImageOperation::is_inside_bokeh(float distance, float x, float y) { - float insideBokeh = 0.0f; + float inside_bokeh = 0.0f; const float deltaX = x - center_[0]; const float deltaY = y - center_[1]; - float closestPoint[2]; - float lineP1[2]; - float lineP2[2]; + float closest_point[2]; + float line_p1[2]; + float line_p2[2]; float point[2]; point[0] = x; point[1] = y; - const float distanceToCenter = len_v2v2(point, center_); + const float distance_to_center = len_v2v2(point, center_); const float bearing = (atan2f(deltaX, deltaY) + (float)(M_PI * 2.0)); - int flapNumber = (int)((bearing - flapRadAdd_) / flapRad_); + int flap_number = (int)((bearing - flap_rad_add_) / flap_rad_); - detemineStartPointOfFlap(lineP1, flapNumber, distance); - detemineStartPointOfFlap(lineP2, flapNumber + 1, distance); - closest_to_line_v2(closestPoint, point, lineP1, lineP2); + detemine_start_point_of_flap(line_p1, flap_number, distance); + detemine_start_point_of_flap(line_p2, flap_number + 1, distance); + closest_to_line_v2(closest_point, point, line_p1, line_p2); - const float distanceLineToCenter = len_v2v2(center_, closestPoint); - const float distanceRoundingToCenter = inverseRounding_ * distanceLineToCenter + - data_->rounding * distance; + const float distance_line_to_center = len_v2v2(center_, closest_point); + const float distance_rounding_to_center = inverse_rounding_ * distance_line_to_center + + data_->rounding * distance; - const float catadioptricDistanceToCenter = distanceRoundingToCenter * data_->catadioptric; - if (distanceRoundingToCenter >= distanceToCenter && - catadioptricDistanceToCenter <= distanceToCenter) { - if (distanceRoundingToCenter - distanceToCenter < 1.0f) { - insideBokeh = (distanceRoundingToCenter - distanceToCenter); + const float catadioptric_distance_to_center = distance_rounding_to_center * data_->catadioptric; + if (distance_rounding_to_center >= distance_to_center && + catadioptric_distance_to_center <= distance_to_center) { + if (distance_rounding_to_center - distance_to_center < 1.0f) { + inside_bokeh = (distance_rounding_to_center - distance_to_center); } else if (data_->catadioptric != 0.0f && - distanceToCenter - catadioptricDistanceToCenter < 1.0f) { - insideBokeh = (distanceToCenter - catadioptricDistanceToCenter); + distance_to_center - catadioptric_distance_to_center < 1.0f) { + inside_bokeh = (distance_to_center - catadioptric_distance_to_center); } else { - insideBokeh = 1.0f; + inside_bokeh = 1.0f; } } - return insideBokeh; + return inside_bokeh; } -void BokehImageOperation::executePixelSampled(float output[4], - float x, - float y, - PixelSampler /*sampler*/) +void BokehImageOperation::execute_pixel_sampled(float output[4], + float x, + float y, + PixelSampler /*sampler*/) { float shift = data_->lensshift; float shift2 = shift / 2.0f; - float distance = circularDistance_; - float insideBokehMax = isInsideBokeh(distance, x, y); - float insideBokehMed = isInsideBokeh(distance - fabsf(shift2 * distance), x, y); - float insideBokehMin = isInsideBokeh(distance - fabsf(shift * distance), x, y); + float distance = circular_distance_; + float inside_bokeh_max = is_inside_bokeh(distance, x, y); + float inside_bokeh_med = is_inside_bokeh(distance - fabsf(shift2 * distance), x, y); + float inside_bokeh_min = is_inside_bokeh(distance - fabsf(shift * distance), x, y); if (shift < 0) { - output[0] = insideBokehMax; - output[1] = insideBokehMed; - output[2] = insideBokehMin; + output[0] = inside_bokeh_max; + output[1] = inside_bokeh_med; + output[2] = inside_bokeh_min; } else { - output[0] = insideBokehMin; - output[1] = insideBokehMed; - output[2] = insideBokehMax; + output[0] = inside_bokeh_min; + output[1] = inside_bokeh_med; + output[2] = inside_bokeh_max; } - output[3] = (insideBokehMax + insideBokehMed + insideBokehMin) / 3.0f; + output[3] = (inside_bokeh_max + inside_bokeh_med + inside_bokeh_min) / 3.0f; } void BokehImageOperation::update_memory_buffer_partial(MemoryBuffer *output, @@ -115,28 +115,29 @@ void BokehImageOperation::update_memory_buffer_partial(MemoryBuffer *output, { const float shift = data_->lensshift; const float shift2 = shift / 2.0f; - const float distance = circularDistance_; + const float distance = circular_distance_; for (BuffersIterator<float> it = output->iterate_with({}, area); !it.is_end(); ++it) { - const float insideBokehMax = isInsideBokeh(distance, it.x, it.y); - const float insideBokehMed = isInsideBokeh(distance - fabsf(shift2 * distance), it.x, it.y); - const float insideBokehMin = isInsideBokeh(distance - fabsf(shift * distance), it.x, it.y); + const float inside_bokeh_max = is_inside_bokeh(distance, it.x, it.y); + const float inside_bokeh_med = is_inside_bokeh( + distance - fabsf(shift2 * distance), it.x, it.y); + const float inside_bokeh_min = is_inside_bokeh(distance - fabsf(shift * distance), it.x, it.y); if (shift < 0) { - it.out[0] = insideBokehMax; - it.out[1] = insideBokehMed; - it.out[2] = insideBokehMin; + it.out[0] = inside_bokeh_max; + it.out[1] = inside_bokeh_med; + it.out[2] = inside_bokeh_min; } else { - it.out[0] = insideBokehMin; - it.out[1] = insideBokehMed; - it.out[2] = insideBokehMax; + it.out[0] = inside_bokeh_min; + it.out[1] = inside_bokeh_med; + it.out[2] = inside_bokeh_max; } - it.out[3] = (insideBokehMax + insideBokehMed + insideBokehMin) / 3.0f; + it.out[3] = (inside_bokeh_max + inside_bokeh_med + inside_bokeh_min) / 3.0f; } } -void BokehImageOperation::deinitExecution() +void BokehImageOperation::deinit_execution() { - if (deleteData_) { + if (delete_data_) { if (data_) { delete data_; data_ = nullptr; |