diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-06-15 22:42:03 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-06-15 22:42:03 +0400 |
commit | 570cc70772d78703053956ce57b20c6c4ed74c95 (patch) | |
tree | b4c5db0392384251f1b1ccefc17c959d3e742977 /source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp | |
parent | 8fd2267e56d3d0b6bb860800eb8059bcbfa0b501 (diff) |
style cleanup: compositor operations
Diffstat (limited to 'source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp')
-rw-r--r-- | source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp index 4442fd9075e..3299434a02e 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp @@ -27,7 +27,7 @@ extern "C" { #include "BLI_rand.h" } -ScreenLensDistortionOperation::ScreenLensDistortionOperation(): NodeOperation() +ScreenLensDistortionOperation::ScreenLensDistortionOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); @@ -39,19 +39,19 @@ void ScreenLensDistortionOperation::initExecution() this->inputProgram = this->getInputSocketReader(0); kg = MAX2(MIN2(this->distortion, 1.f), -0.999f); // smaller dispersion range for somewhat more control - const float d = 0.25f*MAX2(MIN2(this->dispersion, 1.f), 0.f); - kr = MAX2(MIN2((kg+d), 1.f), -0.999f); - kb = MAX2(MIN2((kg-d), 1.f), -0.999f); + const float d = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f); + kr = MAX2(MIN2((kg + d), 1.f), -0.999f); + kb = MAX2(MIN2((kg - d), 1.f), -0.999f); maxk = MAX3(kr, kg, kb); - sc = (this->data->fit && (maxk > 0.f)) ? (1.f/(1.f + 2.f*maxk)) : (1.f/(1.f + maxk)); - drg = 4.f*(kg - kr); - dgb = 4.f*(kb - kg); + sc = (this->data->fit && (maxk > 0.f)) ? (1.f / (1.f + 2.f * maxk)) : (1.f / (1.f + maxk)); + drg = 4.f * (kg - kr); + dgb = 4.f * (kb - kg); - kr4 = kr*4; - kg4 = kg*4.f; - kb4 *= kb*4.f; - cx = 0.5f*(float)getWidth(); - cy = 0.5f*(float)getHeight(); + kr4 = kr * 4; + kg4 = kg * 4.f; + kb4 *= kb * 4.f; + cx = 0.5f * (float)getWidth(); + cy = 0.5f * (float)getHeight(); } @@ -65,28 +65,28 @@ void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int { const float height = this->getHeight(); const float width = this->getWidth(); - MemoryBuffer *buffer = (MemoryBuffer*)data; + MemoryBuffer *buffer = (MemoryBuffer *)data; int dr = 0, dg = 0, db = 0; float d, t, ln[6] = {0, 0, 0, 0, 0, 0}; float tc[4] = {0, 0, 0, 0}; - const float v = sc*((y + 0.5f) - cy)/cy; - const float u = sc*((x + 0.5f) - cx)/cx; + const float v = sc * ((y + 0.5f) - cy) / cy; + const float u = sc * ((x + 0.5f) - cx) / cx; int sta = 0, mid = 0, end = 0; - if ((t = 1.f - kr4*(u*u + v*v)) >= 0.f) { - d = 1.f/(1.f + sqrtf(t)); - ln[0] = (u*d + 0.5f)*width - 0.5f, ln[1] = (v*d + 0.5f)*height - 0.5f; + if ((t = 1.f - kr4 * (u * u + v * v)) >= 0.f) { + d = 1.f / (1.f + sqrtf(t)); + ln[0] = (u * d + 0.5f) * width - 0.5f, ln[1] = (v * d + 0.5f) * height - 0.5f; sta = 1; } - if ((t = 1.f - kg4*(u*u + v*v)) >= 0.f) { - d = 1.f/(1.f + sqrtf(t)); - ln[2] = (u*d + 0.5f)*width - 0.5f, ln[3] = (v*d + 0.5f)*height - 0.5f; + if ((t = 1.f - kg4 * (u * u + v * v)) >= 0.f) { + d = 1.f / (1.f + sqrtf(t)); + ln[2] = (u * d + 0.5f) * width - 0.5f, ln[3] = (v * d + 0.5f) * height - 0.5f; mid = 1; } - if ((t = 1.f - kb4*(u*u + v*v)) >= 0.f) { - d = 1.f/(1.f + sqrtf(t)); - ln[4] = (u*d + 0.5f)*width - 0.5f, ln[5] = (v*d + 0.5f)*height - 0.5f; + if ((t = 1.f - kb4 * (u * u + v * v)) >= 0.f) { + d = 1.f / (1.f + sqrtf(t)); + ln[4] = (u * d + 0.5f) * width - 0.5f, ln[5] = (v * d + 0.5f) * height - 0.5f; end = 1; } @@ -97,43 +97,43 @@ void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int { // RG const int dx = ln[2] - ln[0], dy = ln[3] - ln[1]; - const float dsf = sqrtf((float)dx*dx + dy*dy) + 1.f; + const float dsf = sqrtf((float)dx * dx + dy * dy) + 1.f; const int ds = (int)(jit ? ((dsf < 4.f) ? 2.f : sqrtf(dsf)) : dsf); - const float sd = 1.f/(float)ds; + const float sd = 1.f / (float)ds; - for (z=0; z<ds; ++z) { - const float tz = ((float)z + (jit ? BLI_frand() : 0.5f))*sd; - t = 1.f - (kr4 + tz*drg)*(u*u + v*v); + for (z = 0; z < ds; ++z) { + const float tz = ((float)z + (jit ? BLI_frand() : 0.5f)) * sd; + t = 1.f - (kr4 + tz * drg) * (u * u + v * v); d = 1.f / (1.f + sqrtf(t)); - const float nx = (u*d + 0.5f)*getWidth() - 0.5f; - const float ny = (v*d + 0.5f)*getHeight() - 0.5f; + const float nx = (u * d + 0.5f) * getWidth() - 0.5f; + const float ny = (v * d + 0.5f) * getHeight() - 0.5f; buffer->readCubic(color, nx, ny); - tc[0] += (1.f-tz)*color[0], tc[1] += tz*color[1]; + tc[0] += (1.f - tz) * color[0], tc[1] += tz * color[1]; dr++, dg++; } } { // GB const int dx = ln[4] - ln[2], dy = ln[5] - ln[3]; - const float dsf = sqrtf((float)dx*dx + dy*dy) + 1.f; + const float dsf = sqrtf((float)dx * dx + dy * dy) + 1.f; const int ds = (int)(jit ? ((dsf < 4.f) ? 2.f : sqrtf(dsf)) : dsf); - const float sd = 1.f/(float)ds; + const float sd = 1.f / (float)ds; - for (z=0; z<ds; ++z) { - const float tz = ((float)z + (jit ? BLI_frand() : 0.5f))*sd; - t = 1.f - (kg4 + tz*dgb)*(u*u + v*v); + for (z = 0; z < ds; ++z) { + const float tz = ((float)z + (jit ? BLI_frand() : 0.5f)) * sd; + t = 1.f - (kg4 + tz * dgb) * (u * u + v * v); d = 1.f / (1.f + sqrtf(t)); - const float nx = (u*d + 0.5f)*getWidth() - 0.5f; - const float ny = (v*d + 0.5f)*getHeight() - 0.5f; + const float nx = (u * d + 0.5f) * getWidth() - 0.5f; + const float ny = (v * d + 0.5f) * getHeight() - 0.5f; buffer->readCubic(color, nx, ny); - tc[1] += (1.f-tz)*color[1], tc[2] += tz*color[2]; + tc[1] += (1.f - tz) * color[1], tc[2] += tz * color[2]; dg++, db++; } } - if (dr) outputColor[0] = 2.f*tc[0] / (float)dr; - if (dg) outputColor[1] = 2.f*tc[1] / (float)dg; - if (db) outputColor[2] = 2.f*tc[2] / (float)db; + if (dr) outputColor[0] = 2.f * tc[0] / (float)dr; + if (dg) outputColor[1] = 2.f * tc[1] / (float)dg; + if (db) outputColor[2] = 2.f * tc[2] / (float)db; /* set alpha */ outputColor[3] = 1.0f; @@ -153,12 +153,12 @@ void ScreenLensDistortionOperation::deinitExecution() void ScreenLensDistortionOperation::determineUV(float result[2], float x, float y) const { - const float v = sc*((y + 0.5f) - cy)/cy; - const float u = sc*((x + 0.5f) - cx)/cx; - const float t = ABS(MIN3(kr, kg, kb)*4); - float d = 1.f/(1.f + sqrtf(t)); - result[0] = (u*d + 0.5f)*getWidth() - 0.5f; - result[1] = (v*d + 0.5f)*getHeight() - 0.5f; + const float v = sc * ((y + 0.5f) - cy) / cy; + const float u = sc * ((x + 0.5f) - cx) / cx; + const float t = ABS(MIN3(kr, kg, kb) * 4); + float d = 1.f / (1.f + sqrtf(t)); + result[0] = (u * d + 0.5f) * getWidth() - 0.5f; + result[1] = (v * d + 0.5f) * getHeight() - 0.5f; } bool ScreenLensDistortionOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) |