diff options
author | Monique Dewanchand <m.dewanchand@atmind.nl> | 2013-02-06 12:40:12 +0400 |
---|---|---|
committer | Monique Dewanchand <m.dewanchand@atmind.nl> | 2013-02-06 12:40:12 +0400 |
commit | 23bf087338204b45e5b72c1269bd013a88cf3f9d (patch) | |
tree | b90552717bd7c3af01697d33de29b3872d6d537a /source/blender/compositor/operations/COM_TranslateOperation.cpp | |
parent | a78cf854b4c811d5df24d10cf3b9a0d9d6679ca0 (diff) |
Code clean up translate node
added constants.
moved the code to a separate class. so it can be reused for other nodes
Diffstat (limited to 'source/blender/compositor/operations/COM_TranslateOperation.cpp')
-rw-r--r-- | source/blender/compositor/operations/COM_TranslateOperation.cpp | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/source/blender/compositor/operations/COM_TranslateOperation.cpp b/source/blender/compositor/operations/COM_TranslateOperation.cpp index 32b9398094d..9f6924eb428 100644 --- a/source/blender/compositor/operations/COM_TranslateOperation.cpp +++ b/source/blender/compositor/operations/COM_TranslateOperation.cpp @@ -44,11 +44,6 @@ void TranslateOperation::initExecution() this->m_inputYOperation = this->getInputSocketReader(2); ensureDelta(); - - //Calculate the relative offset once per execution, no need to do this per pixel - this->m_relativeOffsetX = fmodf(this->getDeltaX(), this->getWidth()); - this->m_relativeOffsetY = fmodf(this->getDeltaY(), this->getHeight()); - } void TranslateOperation::deinitExecution() @@ -66,27 +61,7 @@ void TranslateOperation::executePixel(float output[4], float x, float y, PixelSa float originalXPos = x - this->getDeltaX(); float originalYPos = y - this->getDeltaY(); - switch (m_wrappingType) { - case 0: - //Intentionally empty, originalXPos and originalYPos have been set before - break; - case 1: - // wrap only on the x-axis - originalXPos = this->getWrappedOriginalXPos(x); - break; - case 2: - // wrap only on the y-axis - originalYPos = this->getWrappedOriginalYPos(y); - break; - case 3: - // wrap on both - originalXPos = this->getWrappedOriginalXPos(x); - originalYPos = this->getWrappedOriginalYPos(y); - break; - } - this->m_inputOperation->read(output, originalXPos, originalYPos, sampler); - } bool TranslateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -100,89 +75,9 @@ bool TranslateOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe newInput.ymin = input->ymin - this->getDeltaY(); newInput.ymax = input->ymax - this->getDeltaY(); - if (m_wrappingType == 1 || m_wrappingType == 3) { - // wrap only on the x-axis if tile is wrapping - newInput.xmin = getWrappedOriginalXPos(input->xmin); - newInput.xmax = getWrappedOriginalXPos(input->xmax); - if (newInput.xmin > newInput.xmax) { - newInput.xmin = 0; - newInput.xmax = this->getWidth(); - } - } - if (m_wrappingType == 2 || m_wrappingType == 3) { - // wrap only on the y-axis if tile is wrapping - newInput.ymin = getWrappedOriginalYPos(input->ymin); - newInput.ymax = getWrappedOriginalYPos(input->ymax); - if (newInput.ymin > newInput.ymax) { - newInput.ymin = 0; - newInput.ymax = this->getHeight(); - } - } - - return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } -void TranslateOperation::setWrapping(char wrapping_type) -{ - m_wrappingType = wrapping_type; -} - -float TranslateOperation::getWrappedOriginalXPos(float x) -{ - float originalXPos = 0; - - // Positive offset: Append image data from the left - if (this->m_relativeOffsetX > 0) { - if (x < this->m_relativeOffsetX) { - originalXPos = this->getWidth() - this->m_relativeOffsetX + x; - } - else { - originalXPos = x - this->m_relativeOffsetX; - } - } - else { - // Negative offset: Append image data from the right - if (x < (this->getWidth() + this->m_relativeOffsetX)) { - originalXPos = x - this->m_relativeOffsetX; - } - else { - originalXPos = x - (this->getWidth() + this->m_relativeOffsetX); - } - } - - while (originalXPos < 0) originalXPos += this->m_width; - return fmodf(originalXPos, this->getWidth()); -} - - -float TranslateOperation::getWrappedOriginalYPos(float y) -{ - float originalYPos = 0; - - // Positive offset: Append image data from the bottom - if (this->m_relativeOffsetY > 0) { - if (y < this->m_relativeOffsetY) { - originalYPos = this->getHeight() - this->m_relativeOffsetY + y; - } - else { - originalYPos = y - this->m_relativeOffsetY; - } - } - else { - // Negative offset: Append image data from the top - if (y < (this->getHeight() + this->m_relativeOffsetY)) { - originalYPos = y - this->m_relativeOffsetY; - } - else { - originalYPos = y - (this->getHeight() + this->m_relativeOffsetY); - } - } - - while (originalYPos < 0) originalYPos += this->m_height; - return fmodf(originalYPos, this->getHeight()); -} - void TranslateOperation::setFactorXY(float factorX, float factorY) { m_factorX = factorX; |