diff options
Diffstat (limited to 'source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cc')
-rw-r--r-- | source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cc | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cc b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cc index ee2a62f6147..fcd9d26c3f0 100644 --- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cc +++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cc @@ -26,19 +26,19 @@ ConvertDepthToRadiusOperation::ConvertDepthToRadiusOperation() { this->addInputSocket(DataType::Value); this->addOutputSocket(DataType::Value); - m_inputOperation = nullptr; - m_fStop = 128.0f; - m_cameraObject = nullptr; - m_maxRadius = 32.0f; - m_blurPostOperation = nullptr; + inputOperation_ = nullptr; + fStop_ = 128.0f; + cameraObject_ = nullptr; + maxRadius_ = 32.0f; + blurPostOperation_ = nullptr; } float ConvertDepthToRadiusOperation::determineFocalDistance() { - if (m_cameraObject && m_cameraObject->type == OB_CAMERA) { - Camera *camera = (Camera *)m_cameraObject->data; - m_cam_lens = camera->lens; - return BKE_camera_object_dof_distance(m_cameraObject); + if (cameraObject_ && cameraObject_->type == OB_CAMERA) { + Camera *camera = (Camera *)cameraObject_->data; + cam_lens_ = camera->lens; + return BKE_camera_object_dof_distance(cameraObject_); } return 10.0f; @@ -49,27 +49,27 @@ void ConvertDepthToRadiusOperation::initExecution() float cam_sensor = DEFAULT_SENSOR_WIDTH; Camera *camera = nullptr; - if (m_cameraObject && m_cameraObject->type == OB_CAMERA) { - camera = (Camera *)m_cameraObject->data; + if (cameraObject_ && cameraObject_->type == OB_CAMERA) { + camera = (Camera *)cameraObject_->data; cam_sensor = BKE_camera_sensor_size(camera->sensor_fit, camera->sensor_x, camera->sensor_y); } - m_inputOperation = this->getInputSocketReader(0); + 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. */ } - m_inverseFocalDistance = 1.0f / focalDistance; - m_aspect = (this->getWidth() > this->getHeight()) ? - (this->getHeight() / (float)this->getWidth()) : - (this->getWidth() / (float)this->getHeight()); - m_aperture = 0.5f * (m_cam_lens / (m_aspect * cam_sensor)) / m_fStop; + inverseFocalDistance_ = 1.0f / focalDistance; + aspect_ = (this->getWidth() > this->getHeight()) ? + (this->getHeight() / (float)this->getWidth()) : + (this->getWidth() / (float)this->getHeight()); + aperture_ = 0.5f * (cam_lens_ / (aspect_ * cam_sensor)) / fStop_; const float minsz = MIN2(getWidth(), getHeight()); - m_dof_sp = minsz / ((cam_sensor / 2.0f) / - m_cam_lens); /* <- == `aspect * MIN2(img->x, img->y) / tan(0.5f * fov)` */ + dof_sp_ = minsz / ((cam_sensor / 2.0f) / + cam_lens_); /* <- == `aspect * MIN2(img->x, img->y) / tan(0.5f * fov)` */ - if (m_blurPostOperation) { - m_blurPostOperation->setSigma(MIN2(m_aperture * 128.0f, m_maxRadius)); + if (blurPostOperation_) { + blurPostOperation_->setSigma(MIN2(aperture_ * 128.0f, maxRadius_)); } } @@ -81,7 +81,7 @@ void ConvertDepthToRadiusOperation::executePixelSampled(float output[4], float inputValue[4]; float z; float radius; - m_inputOperation->readSampled(inputValue, x, y, sampler); + inputOperation_->readSampled(inputValue, x, y, sampler); z = inputValue[0]; if (z != 0.0f) { float iZ = (1.0f / z); @@ -92,14 +92,14 @@ void ConvertDepthToRadiusOperation::executePixelSampled(float output[4], /* 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(m_aperture * (m_dof_sp * (m_inverseFocalDistance - iZ) - 1.0f)); + radius = 0.5f * fabsf(aperture_ * (dof_sp_ * (inverseFocalDistance_ - iZ) - 1.0f)); /* 'bug' T6615, limit minimum radius to 1 pixel, * not really a solution, but somewhat mitigates the problem. */ if (radius < 0.0f) { radius = 0.0f; } - if (radius > m_maxRadius) { - radius = m_maxRadius; + if (radius > maxRadius_) { + radius = maxRadius_; } output[0] = radius; } @@ -110,7 +110,7 @@ void ConvertDepthToRadiusOperation::executePixelSampled(float output[4], void ConvertDepthToRadiusOperation::deinitExecution() { - m_inputOperation = nullptr; + inputOperation_ = nullptr; } void ConvertDepthToRadiusOperation::update_memory_buffer_partial(MemoryBuffer *output, @@ -133,10 +133,10 @@ void ConvertDepthToRadiusOperation::update_memory_buffer_partial(MemoryBuffer *o * `crad->rect[px] = bcrad + wts->rect[px] * (scf * crad->rect[px] - bcrad);` */ #endif const float radius = 0.5f * - fabsf(m_aperture * (m_dof_sp * (m_inverseFocalDistance - inv_z) - 1.0f)); + fabsf(aperture_ * (dof_sp_ * (inverseFocalDistance_ - inv_z) - 1.0f)); /* Bug T6615, limit minimum radius to 1 pixel, * not really a solution, but somewhat mitigates the problem. */ - *it.out = CLAMPIS(radius, 0.0f, m_maxRadius); + *it.out = CLAMPIS(radius, 0.0f, maxRadius_); } } |