Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/compositor/operations/COM_RotateOperation.cpp')
-rw-r--r--source/blender/compositor/operations/COM_RotateOperation.cpp119
1 files changed, 60 insertions, 59 deletions
diff --git a/source/blender/compositor/operations/COM_RotateOperation.cpp b/source/blender/compositor/operations/COM_RotateOperation.cpp
index bc9fd46e8d7..3ccf36cec2c 100644
--- a/source/blender/compositor/operations/COM_RotateOperation.cpp
+++ b/source/blender/compositor/operations/COM_RotateOperation.cpp
@@ -21,86 +21,87 @@
RotateOperation::RotateOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
- this->setResolutionInputSocketIndex(0);
- this->m_imageSocket = NULL;
- this->m_degreeSocket = NULL;
- this->m_doDegree2RadConversion = false;
- this->m_isDegreeSet = false;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->m_imageSocket = NULL;
+ this->m_degreeSocket = NULL;
+ this->m_doDegree2RadConversion = false;
+ this->m_isDegreeSet = false;
}
void RotateOperation::initExecution()
{
- this->m_imageSocket = this->getInputSocketReader(0);
- this->m_degreeSocket = this->getInputSocketReader(1);
- this->m_centerX = (getWidth() - 1) / 2.0;
- this->m_centerY = (getHeight() - 1) / 2.0;
+ this->m_imageSocket = this->getInputSocketReader(0);
+ this->m_degreeSocket = this->getInputSocketReader(1);
+ this->m_centerX = (getWidth() - 1) / 2.0;
+ this->m_centerY = (getHeight() - 1) / 2.0;
}
void RotateOperation::deinitExecution()
{
- this->m_imageSocket = NULL;
- this->m_degreeSocket = NULL;
+ this->m_imageSocket = NULL;
+ this->m_degreeSocket = NULL;
}
inline void RotateOperation::ensureDegree()
{
- if (!this->m_isDegreeSet) {
- float degree[4];
- this->m_degreeSocket->readSampled(degree, 0, 0, COM_PS_NEAREST);
- double rad;
- if (this->m_doDegree2RadConversion) {
- rad = DEG2RAD((double)degree[0]);
- }
- else {
- rad = degree[0];
- }
- this->m_cosine = cos(rad);
- this->m_sine = sin(rad);
+ if (!this->m_isDegreeSet) {
+ float degree[4];
+ this->m_degreeSocket->readSampled(degree, 0, 0, COM_PS_NEAREST);
+ double rad;
+ if (this->m_doDegree2RadConversion) {
+ rad = DEG2RAD((double)degree[0]);
+ }
+ else {
+ rad = degree[0];
+ }
+ this->m_cosine = cos(rad);
+ this->m_sine = sin(rad);
- this->m_isDegreeSet = true;
- }
+ this->m_isDegreeSet = true;
+ }
}
-
void RotateOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- ensureDegree();
- const float dy = y - this->m_centerY;
- const float dx = x - this->m_centerX;
- const float nx = this->m_centerX + (this->m_cosine * dx + this->m_sine * dy);
- const float ny = this->m_centerY + (-this->m_sine * dx + this->m_cosine * dy);
- this->m_imageSocket->readSampled(output, nx, ny, sampler);
+ ensureDegree();
+ const float dy = y - this->m_centerY;
+ const float dx = x - this->m_centerX;
+ const float nx = this->m_centerX + (this->m_cosine * dx + this->m_sine * dy);
+ const float ny = this->m_centerY + (-this->m_sine * dx + this->m_cosine * dy);
+ this->m_imageSocket->readSampled(output, nx, ny, sampler);
}
-bool RotateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool RotateOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- ensureDegree();
- rcti newInput;
+ ensureDegree();
+ rcti newInput;
- const float dxmin = input->xmin - this->m_centerX;
- const float dymin = input->ymin - this->m_centerY;
- const float dxmax = input->xmax - this->m_centerX;
- const float dymax = input->ymax - this->m_centerY;
+ const float dxmin = input->xmin - this->m_centerX;
+ const float dymin = input->ymin - this->m_centerY;
+ const float dxmax = input->xmax - this->m_centerX;
+ const float dymax = input->ymax - this->m_centerY;
- const float x1 = this->m_centerX + (this->m_cosine * dxmin + this->m_sine * dymin);
- const float x2 = this->m_centerX + (this->m_cosine * dxmax + this->m_sine * dymin);
- const float x3 = this->m_centerX + (this->m_cosine * dxmin + this->m_sine * dymax);
- const float x4 = this->m_centerX + (this->m_cosine * dxmax + this->m_sine * dymax);
- const float y1 = this->m_centerY + (-this->m_sine * dxmin + this->m_cosine * dymin);
- const float y2 = this->m_centerY + (-this->m_sine * dxmax + this->m_cosine * dymin);
- const float y3 = this->m_centerY + (-this->m_sine * dxmin + this->m_cosine * dymax);
- const float y4 = this->m_centerY + (-this->m_sine * dxmax + this->m_cosine * dymax);
- const float minx = min(x1, min(x2, min(x3, x4)));
- const float maxx = max(x1, max(x2, max(x3, x4)));
- const float miny = min(y1, min(y2, min(y3, y4)));
- const float maxy = max(y1, max(y2, max(y3, y4)));
+ const float x1 = this->m_centerX + (this->m_cosine * dxmin + this->m_sine * dymin);
+ const float x2 = this->m_centerX + (this->m_cosine * dxmax + this->m_sine * dymin);
+ const float x3 = this->m_centerX + (this->m_cosine * dxmin + this->m_sine * dymax);
+ const float x4 = this->m_centerX + (this->m_cosine * dxmax + this->m_sine * dymax);
+ const float y1 = this->m_centerY + (-this->m_sine * dxmin + this->m_cosine * dymin);
+ const float y2 = this->m_centerY + (-this->m_sine * dxmax + this->m_cosine * dymin);
+ const float y3 = this->m_centerY + (-this->m_sine * dxmin + this->m_cosine * dymax);
+ const float y4 = this->m_centerY + (-this->m_sine * dxmax + this->m_cosine * dymax);
+ const float minx = min(x1, min(x2, min(x3, x4)));
+ const float maxx = max(x1, max(x2, max(x3, x4)));
+ const float miny = min(y1, min(y2, min(y3, y4)));
+ const float maxy = max(y1, max(y2, max(y3, y4)));
- newInput.xmax = ceil(maxx) + 1;
- newInput.xmin = floor(minx) - 1;
- newInput.ymax = ceil(maxy) + 1;
- newInput.ymin = floor(miny) - 1;
+ newInput.xmax = ceil(maxx) + 1;
+ newInput.xmin = floor(minx) - 1;
+ newInput.ymax = ceil(maxy) + 1;
+ newInput.ymin = floor(miny) - 1;
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}