From d718d6b4493429a1e688e874fd76963f98e3d034 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 31 Aug 2021 13:36:28 +1000 Subject: Cleanup: Use C style comments for descriptive text --- .../operations/COM_BilateralBlurOperation.cc | 12 ++-- .../operations/COM_ColorCorrectionOperation.cc | 2 +- .../COM_ConvertDepthToRadiusOperation.cc | 10 +-- .../operations/COM_GlareStreaksOperation.cc | 14 ++-- .../compositor/operations/COM_ScaleOperation.cc | 8 +-- .../COM_ScreenLensDistortionOperation.cc | 2 +- .../COM_VariableSizeBokehBlurOperation.cc | 76 +++++++++++----------- 7 files changed, 63 insertions(+), 61 deletions(-) (limited to 'source/blender/compositor/operations') diff --git a/source/blender/compositor/operations/COM_BilateralBlurOperation.cc b/source/blender/compositor/operations/COM_BilateralBlurOperation.cc index 0c1bb688d4e..44680c3acd1 100644 --- a/source/blender/compositor/operations/COM_BilateralBlurOperation.cc +++ b/source/blender/compositor/operations/COM_BilateralBlurOperation.cc @@ -43,8 +43,8 @@ void BilateralBlurOperation::initExecution() void BilateralBlurOperation::executePixel(float output[4], int x, int y, void *data) { - // read the determinator color at x, y, this will be used as the reference color for the - // determinator + /* Read the determinator color at x, y, + * this will be used as the reference color for the determinator. */ float determinatorReferenceColor[4]; float determinator[4]; float tempColor[4]; @@ -67,14 +67,14 @@ void BilateralBlurOperation::executePixel(float output[4], int x, int y, void *d */ for (int yi = miny; yi < maxy; yi += QualityStepHelper::getStep()) { for (int xi = minx; xi < maxx; xi += QualityStepHelper::getStep()) { - // read determinator + /* Read determinator. */ this->m_inputDeterminatorProgram->read(determinator, xi, yi, data); deltaColor = (fabsf(determinatorReferenceColor[0] - determinator[0]) + fabsf(determinatorReferenceColor[1] - determinator[1]) + - fabsf(determinatorReferenceColor[2] - - determinator[2])); // do not take the alpha channel into account + /* Do not take the alpha channel into account. */ + fabsf(determinatorReferenceColor[2] - determinator[2])); if (deltaColor < sigmacolor) { - // add this to the blur + /* Add this to the blur. */ this->m_inputColorProgram->read(tempColor, xi, yi, data); add_v4_v4(blurColor, tempColor); blurDivider += 1.0f; diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cc b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cc index b50145b106d..d3557e541c0 100644 --- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cc +++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cc @@ -132,7 +132,7 @@ void ColorCorrectionOperation::executePixelSampled(float output[4], g = color_correct_powf_safe(g * gain + lift, invgamma, g); b = color_correct_powf_safe(b * gain + lift, invgamma, b); - // mix with mask + /* Mix with mask. */ r = mvalue * inputImageColor[0] + value * r; g = mvalue * inputImageColor[1] + value * g; b = mvalue * inputImageColor[2] + value * b; diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cc b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cc index 57027c11949..a9c58b55d73 100644 --- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cc +++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cc @@ -58,7 +58,7 @@ void ConvertDepthToRadiusOperation::initExecution() this->m_inputOperation = this->getInputSocketReader(0); float focalDistance = determineFocalDistance(); if (focalDistance == 0.0f) { - focalDistance = 1e10f; /* if the dof is 0.0 then set it to be far away */ + focalDistance = 1e10f; /* If the DOF is 0.0 then set it to be far away. */ } this->m_inverseFocalDistance = 1.0f / focalDistance; this->m_aspect = (this->getWidth() > this->getHeight()) ? @@ -66,9 +66,9 @@ void ConvertDepthToRadiusOperation::initExecution() (this->getWidth() / (float)this->getHeight()); this->m_aperture = 0.5f * (this->m_cam_lens / (this->m_aspect * cam_sensor)) / this->m_fStop; const float minsz = MIN2(getWidth(), getHeight()); - this->m_dof_sp = minsz / - ((cam_sensor / 2.0f) / - this->m_cam_lens); // <- == aspect * MIN2(img->x, img->y) / tan(0.5f * fov); + this->m_dof_sp = + minsz / ((cam_sensor / 2.0f) / + this->m_cam_lens); /* <- == `aspect * MIN2(img->x, img->y) / tan(0.5f * fov)` */ if (this->m_blurPostOperation) { m_blurPostOperation->setSigma(MIN2(m_aperture * 128.0f, this->m_maxRadius)); @@ -91,7 +91,7 @@ void ConvertDepthToRadiusOperation::executePixelSampled(float output[4], /* bug T6656 part 2b, do not re-scale. */ #if 0 bcrad = 0.5f * fabs(aperture * (dof_sp * (cam_invfdist - iZ) - 1.0f)); - // scale crad back to original maximum and blend + /* Scale crad back to original maximum and blend. */ crad->rect[px] = bcrad + wts->rect[px] * (scf * crad->rect[px] - bcrad); #endif radius = 0.5f * fabsf(this->m_aperture * diff --git a/source/blender/compositor/operations/COM_GlareStreaksOperation.cc b/source/blender/compositor/operations/COM_GlareStreaksOperation.cc index 0af4eb43624..5ca64b02586 100644 --- a/source/blender/compositor/operations/COM_GlareStreaksOperation.cc +++ b/source/blender/compositor/operations/COM_GlareStreaksOperation.cc @@ -47,15 +47,15 @@ void GlareStreaksOperation::generateGlare(float *data, const float p4 = pow(4.0, (double)n); const float vxp = vx * p4, vyp = vy * p4; const float wt = pow((double)settings->fade, (double)p4); - const float cmo = 1.0f - - (float)pow((double)settings->colmod, - (double)n + - 1); // colormodulation amount relative to current pass + + /* Color-modulation amount relative to current pass. */ + const float cmo = 1.0f - (float)pow((double)settings->colmod, (double)n + 1); + float *tdstcol = tdst.getBuffer(); for (y = 0; y < tsrc.getHeight() && (!breaked); y++) { for (x = 0; x < tsrc.getWidth(); x++, tdstcol += 4) { - // first pass no offset, always same for every pass, exact copy, - // otherwise results in uneven brightness, only need once + /* First pass no offset, always same for every pass, exact copy, + * otherwise results in uneven brightness, only need once. */ if (n == 0) { tsrc.read(c1, x, y); } @@ -65,7 +65,7 @@ void GlareStreaksOperation::generateGlare(float *data, tsrc.readBilinear(c2, x + vxp, y + vyp); tsrc.readBilinear(c3, x + vxp * 2.0f, y + vyp * 2.0f); tsrc.readBilinear(c4, x + vxp * 3.0f, y + vyp * 3.0f); - // modulate color to look vaguely similar to a color spectrum + /* Modulate color to look vaguely similar to a color spectrum. */ c2[1] *= cmo; c2[2] *= cmo; diff --git a/source/blender/compositor/operations/COM_ScaleOperation.cc b/source/blender/compositor/operations/COM_ScaleOperation.cc index bbb6de2f39e..0161b837915 100644 --- a/source/blender/compositor/operations/COM_ScaleOperation.cc +++ b/source/blender/compositor/operations/COM_ScaleOperation.cc @@ -213,12 +213,12 @@ void ScaleAbsoluteOperation::executePixelSampled(float output[4], this->m_inputXOperation->readSampled(scaleX, x, y, effective_sampler); this->m_inputYOperation->readSampled(scaleY, x, y, effective_sampler); - const float scx = scaleX[0]; // target absolute scale - const float scy = scaleY[0]; // target absolute scale + const float scx = scaleX[0]; /* Target absolute scale. */ + const float scy = scaleY[0]; /* Target absolute scale. */ const float width = this->getWidth(); const float height = this->getHeight(); - // div + /* Divide. */ float relativeXScale = scx / width; float relativeYScale = scy / height; @@ -244,7 +244,7 @@ bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, const float scy = scaleY[0]; const float width = this->getWidth(); const float height = this->getHeight(); - // div + /* Divide. */ float relateveXScale = scx / width; float relateveYScale = scy / height; diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc index 1f503051349..628da686a42 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc @@ -369,7 +369,7 @@ bool ScreenLensDistortionOperation::determineDependingAreaOfInterest( void ScreenLensDistortionOperation::updateVariables(float distortion, float dispersion) { m_k[1] = max_ff(min_ff(distortion, 1.0f), -0.999f); - // smaller dispersion range for somewhat more control + /* Smaller dispersion range for somewhat more control. */ float d = 0.25f * max_ff(min_ff(dispersion, 1.0f), 0.0f); m_k[0] = max_ff(min_ff((m_k[1] + d), 1.0f), -0.999f); m_k[2] = max_ff(min_ff((m_k[1] - d), 1.0f), -0.999f); diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc index 6af6f5a6244..b8274576cb5 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc @@ -28,11 +28,11 @@ namespace blender::compositor { VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() { this->addInputSocket(DataType::Color); - this->addInputSocket(DataType::Color, ResizeMode::None); // do not resize the bokeh image. - this->addInputSocket(DataType::Value); // radius + this->addInputSocket(DataType::Color, ResizeMode::None); /* Do not resize the bokeh image. */ + this->addInputSocket(DataType::Value); /* Radius. */ #ifdef COM_DEFOCUS_SEARCH - this->addInputSocket(DataType::Color, - ResizeMode::None); // inverse search radius optimization structure. + /* Inverse search radius optimization structure. */ + this->addInputSocket(DataType::Color, ResizeMode::None); #endif this->addOutputSocket(DataType::Color); flags.complex = true; @@ -438,10 +438,10 @@ void VariableSizeBokehBlurOperation::update_memory_buffer_partial(MemoryBuffer * } #ifdef COM_DEFOCUS_SEARCH -// InverseSearchRadiusOperation +/* #InverseSearchRadiusOperation. */ InverseSearchRadiusOperation::InverseSearchRadiusOperation() { - this->addInputSocket(DataType::Value, ResizeMode::None); // radius + this->addInputSocket(DataType::Value, ResizeMode::None); /* Radius. */ this->addOutputSocket(DataType::Color); this->flags.complex = true; this->m_inputRadius = nullptr; @@ -472,37 +472,39 @@ void *InverseSearchRadiusOperation::initializeTileData(rcti *rect) offset += 4; } } - // for (x = rect->xmin; x < rect->xmax ; x++) { - // for (y = rect->ymin; y < rect->ymax ; y++) { - // int rx = x * DIVIDER; - // int ry = y * DIVIDER; - // float radius = 0.0f; - // float maxx = x; - // float maxy = y; - - // for (int x2 = 0 ; x2 < DIVIDER ; x2 ++) { - // for (int y2 = 0 ; y2 < DIVIDER ; y2 ++) { - // this->m_inputRadius->read(temp, rx+x2, ry+y2, PixelSampler::Nearest); - // if (radius < temp[0]) { - // radius = temp[0]; - // maxx = x2; - // maxy = y2; - // } - // } - // } - // int impactRadius = ceil(radius / DIVIDER); - // for (int x2 = x - impactRadius ; x2 < x + impactRadius ; x2 ++) { - // for (int y2 = y - impactRadius ; y2 < y + impactRadius ; y2 ++) { - // data->read(temp, x2, y2); - // temp[0] = MIN2(temp[0], maxx); - // temp[1] = MIN2(temp[1], maxy); - // temp[2] = MAX2(temp[2], maxx); - // temp[3] = MAX2(temp[3], maxy); - // data->writePixel(x2, y2, temp); - // } - // } - // } - // } +# if 0 + for (x = rect->xmin; x < rect->xmax; x++) { + for (y = rect->ymin; y < rect->ymax; y++) { + int rx = x * DIVIDER; + int ry = y * DIVIDER; + float radius = 0.0f; + float maxx = x; + float maxy = y; + + for (int x2 = 0; x2 < DIVIDER; x2++) { + for (int y2 = 0; y2 < DIVIDER; y2++) { + this->m_inputRadius->read(temp, rx + x2, ry + y2, PixelSampler::Nearest); + if (radius < temp[0]) { + radius = temp[0]; + maxx = x2; + maxy = y2; + } + } + } + int impactRadius = ceil(radius / DIVIDER); + for (int x2 = x - impactRadius; x2 < x + impactRadius; x2++) { + for (int y2 = y - impactRadius; y2 < y + impactRadius; y2++) { + data->read(temp, x2, y2); + temp[0] = MIN2(temp[0], maxx); + temp[1] = MIN2(temp[1], maxy); + temp[2] = MAX2(temp[2], maxx); + temp[3] = MAX2(temp[3], maxy); + data->writePixel(x2, y2, temp); + } + } + } + } +# endif return data; } -- cgit v1.2.3