diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp')
-rw-r--r-- | source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp | 170 |
1 files changed, 87 insertions, 83 deletions
diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp index e6edbfcf6e0..32eb5679d9d 100644 --- a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp +++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp @@ -22,106 +22,110 @@ DisplaceSimpleOperation::DisplaceSimpleOperation() : NodeOperation() { - this->addInputSocket(COM_DT_COLOR); - this->addInputSocket(COM_DT_VECTOR); - this->addInputSocket(COM_DT_VALUE); - this->addInputSocket(COM_DT_VALUE); - this->addOutputSocket(COM_DT_COLOR); - - this->m_inputColorProgram = NULL; - this->m_inputVectorProgram = NULL; - this->m_inputScaleXProgram = NULL; - this->m_inputScaleYProgram = NULL; + this->addInputSocket(COM_DT_COLOR); + this->addInputSocket(COM_DT_VECTOR); + this->addInputSocket(COM_DT_VALUE); + this->addInputSocket(COM_DT_VALUE); + this->addOutputSocket(COM_DT_COLOR); + + this->m_inputColorProgram = NULL; + this->m_inputVectorProgram = NULL; + this->m_inputScaleXProgram = NULL; + this->m_inputScaleYProgram = NULL; } void DisplaceSimpleOperation::initExecution() { - this->m_inputColorProgram = this->getInputSocketReader(0); - this->m_inputVectorProgram = this->getInputSocketReader(1); - this->m_inputScaleXProgram = this->getInputSocketReader(2); - this->m_inputScaleYProgram = this->getInputSocketReader(3); + this->m_inputColorProgram = this->getInputSocketReader(0); + this->m_inputVectorProgram = this->getInputSocketReader(1); + this->m_inputScaleXProgram = this->getInputSocketReader(2); + this->m_inputScaleYProgram = this->getInputSocketReader(3); - this->m_width_x4 = this->getWidth() * 4; - this->m_height_x4 = this->getHeight() * 4; + this->m_width_x4 = this->getWidth() * 4; + this->m_height_x4 = this->getHeight() * 4; } - /* minimum distance (in pixels) a pixel has to be displaced * in order to take effect */ // #define DISPLACE_EPSILON 0.01f -void DisplaceSimpleOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) +void DisplaceSimpleOperation::executePixelSampled(float output[4], + float x, + float y, + PixelSampler sampler) { - float inVector[4]; - float inScale[4]; - - float p_dx, p_dy; /* main displacement in pixel space */ - float u, v; - - this->m_inputScaleXProgram->readSampled(inScale, x, y, sampler); - float xs = inScale[0]; - this->m_inputScaleYProgram->readSampled(inScale, x, y, sampler); - float ys = inScale[0]; - - /* clamp x and y displacement to triple image resolution - - * to prevent hangs from huge values mistakenly plugged in eg. z buffers */ - CLAMP(xs, -this->m_width_x4, this->m_width_x4); - CLAMP(ys, -this->m_height_x4, this->m_height_x4); - - this->m_inputVectorProgram->readSampled(inVector, x, y, sampler); - p_dx = inVector[0] * xs; - p_dy = inVector[1] * ys; - - /* displaced pixel in uv coords, for image sampling */ - /* clamp nodes to avoid glitches */ - u = x - p_dx + 0.5f; - v = y - p_dy + 0.5f; - CLAMP(u, 0.0f, this->getWidth() - 1.0f); - CLAMP(v, 0.0f, this->getHeight() - 1.0f); - - this->m_inputColorProgram->readSampled(output, u, v, sampler); + float inVector[4]; + float inScale[4]; + + float p_dx, p_dy; /* main displacement in pixel space */ + float u, v; + + this->m_inputScaleXProgram->readSampled(inScale, x, y, sampler); + float xs = inScale[0]; + this->m_inputScaleYProgram->readSampled(inScale, x, y, sampler); + float ys = inScale[0]; + + /* clamp x and y displacement to triple image resolution - + * to prevent hangs from huge values mistakenly plugged in eg. z buffers */ + CLAMP(xs, -this->m_width_x4, this->m_width_x4); + CLAMP(ys, -this->m_height_x4, this->m_height_x4); + + this->m_inputVectorProgram->readSampled(inVector, x, y, sampler); + p_dx = inVector[0] * xs; + p_dy = inVector[1] * ys; + + /* displaced pixel in uv coords, for image sampling */ + /* clamp nodes to avoid glitches */ + u = x - p_dx + 0.5f; + v = y - p_dy + 0.5f; + CLAMP(u, 0.0f, this->getWidth() - 1.0f); + CLAMP(v, 0.0f, this->getHeight() - 1.0f); + + this->m_inputColorProgram->readSampled(output, u, v, sampler); } void DisplaceSimpleOperation::deinitExecution() { - this->m_inputColorProgram = NULL; - this->m_inputVectorProgram = NULL; - this->m_inputScaleXProgram = NULL; - this->m_inputScaleYProgram = NULL; + this->m_inputColorProgram = NULL; + this->m_inputVectorProgram = NULL; + this->m_inputScaleXProgram = NULL; + this->m_inputScaleYProgram = NULL; } -bool DisplaceSimpleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) +bool DisplaceSimpleOperation::determineDependingAreaOfInterest(rcti *input, + ReadBufferOperation *readOperation, + rcti *output) { - rcti colorInput; - NodeOperation *operation = NULL; - - /* the vector buffer only needs a 2x2 buffer. The image needs whole buffer */ - /* image */ - operation = getInputOperation(0); - colorInput.xmax = operation->getWidth(); - colorInput.xmin = 0; - colorInput.ymax = operation->getHeight(); - colorInput.ymin = 0; - if (operation->determineDependingAreaOfInterest(&colorInput, readOperation, output)) { - return true; - } - - /* vector */ - if (operation->determineDependingAreaOfInterest(input, readOperation, output)) { - return true; - } - - /* scale x */ - operation = getInputOperation(2); - if (operation->determineDependingAreaOfInterest(input, readOperation, output) ) { - return true; - } - - /* scale y */ - operation = getInputOperation(3); - if (operation->determineDependingAreaOfInterest(input, readOperation, output) ) { - return true; - } - - return false; + rcti colorInput; + NodeOperation *operation = NULL; + + /* the vector buffer only needs a 2x2 buffer. The image needs whole buffer */ + /* image */ + operation = getInputOperation(0); + colorInput.xmax = operation->getWidth(); + colorInput.xmin = 0; + colorInput.ymax = operation->getHeight(); + colorInput.ymin = 0; + if (operation->determineDependingAreaOfInterest(&colorInput, readOperation, output)) { + return true; + } + + /* vector */ + if (operation->determineDependingAreaOfInterest(input, readOperation, output)) { + return true; + } + + /* scale x */ + operation = getInputOperation(2); + if (operation->determineDependingAreaOfInterest(input, readOperation, output)) { + return true; + } + + /* scale y */ + operation = getInputOperation(3); + if (operation->determineDependingAreaOfInterest(input, readOperation, output)) { + return true; + } + + return false; } |