diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-10-23 20:32:39 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-10-23 20:32:39 +0400 |
commit | e038a1c613009d81adda0662dbb1e4a38228909a (patch) | |
tree | be5851f67fda72085c51abd762fb81dd521f1e05 /source | |
parent | fec81d9b56075f46f6dde196ac85140872cff74e (diff) |
reduce float comparisons for keying operation and despill.
Diffstat (limited to 'source')
5 files changed, 34 insertions, 32 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index eb42ecd8b3a..49025ceaaa1 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2496,7 +2496,7 @@ void DM_add_tangent_layer(DerivedMesh *dm) MTFace *mtface; MFace *mface; float (*orco)[3] = NULL, (*tangent)[4]; - int totvert, totface; + int /* totvert, */ totface; float *nors; if (CustomData_get_layer_index(&dm->faceData, CD_TANGENT) != -1) @@ -2505,7 +2505,7 @@ void DM_add_tangent_layer(DerivedMesh *dm) nors = dm->getTessFaceDataArray(dm, CD_NORMAL); /* check we have all the needed layers */ - totvert = dm->getNumVerts(dm); + /* totvert = dm->getNumVerts(dm); */ /* UNUSED */ totface = dm->getNumTessFaces(dm); mvert = dm->getVertArray(dm); diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index f781714e935..5fbec6a3293 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -283,6 +283,8 @@ float form_factor_hemi_poly(float p[3], float n[3], void axis_dominant_v3(int *axis_a, int *axis_b, const float axis[3]); +MINLINE int axis_primary_v3(const float vec[3]); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c index 0d4c797cefb..bbf6dc9dfc2 100644 --- a/source/blender/blenlib/intern/math_geom_inline.c +++ b/source/blender/blenlib/intern/math_geom_inline.c @@ -137,4 +137,28 @@ MINLINE void madd_sh_shfl(float r[9], const float sh[9], const float f) add_sh_shsh(r, r, tmp); } +MINLINE int axis_primary_v3(const float vec[3]) +{ + const float x = vec[0]; + const float y = vec[1]; + const float z = vec[2]; + + if (x > y) { + if (x > z) { + return 0; + } + else { + return 2; + } + } + else { + if (y > z) { + return 1; + } + else { + return 2; + } + } +} + #endif /* __MATH_GEOM_INLINE_C__ */ diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp index f9f43025d29..73bc5fb2701 100644 --- a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp @@ -28,18 +28,6 @@ #include "BLI_listbase.h" #include "BLI_math.h" -static int get_pixel_primary_channel(float pixel[3]) -{ - float max_value = max(max(pixel[0], pixel[1]), pixel[2]); - - if (max_value == pixel[0]) - return 0; - else if (max_value == pixel[1]) - return 1; - - return 2; -} - KeyingDespillOperation::KeyingDespillOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); @@ -73,12 +61,12 @@ void KeyingDespillOperation::executePixel(float output[4], float x, float y, Pix this->m_pixelReader->read(pixelColor, x, y, sampler); this->m_screenReader->read(screenColor, x, y, sampler); - int screen_primary_channel = get_pixel_primary_channel(screenColor); - int other_1 = (screen_primary_channel + 1) % 3; - int other_2 = (screen_primary_channel + 2) % 3; + const int screen_primary_channel = axis_primary_v3(screenColor); + const int other_1 = (screen_primary_channel + 1) % 3; + const int other_2 = (screen_primary_channel + 2) % 3; - int min_channel = min(other_1, other_2); - int max_channel = max(other_1, other_2); + const int min_channel = min(other_1, other_2); + const int max_channel = max(other_1, other_2); float average_value, amount; diff --git a/source/blender/compositor/operations/COM_KeyingOperation.cpp b/source/blender/compositor/operations/COM_KeyingOperation.cpp index bc2d14d42b8..dcb15eda638 100644 --- a/source/blender/compositor/operations/COM_KeyingOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingOperation.cpp @@ -28,18 +28,6 @@ #include "BLI_listbase.h" #include "BLI_math.h" -static int get_pixel_primary_channel(float pixel[3]) -{ - float max_value = max(max(pixel[0], pixel[1]), pixel[2]); - - if (max_value == pixel[0]) - return 0; - else if (max_value == pixel[1]) - return 1; - - return 2; -} - static float get_pixel_saturation(float pixelColor[4], float screen_balance, int primary_channel) { int other_1 = (primary_channel + 1) % 3; @@ -85,7 +73,7 @@ void KeyingOperation::executePixel(float output[4], float x, float y, PixelSampl this->m_pixelReader->read(pixelColor, x, y, sampler); this->m_screenReader->read(screenColor, x, y, sampler); - int primary_channel = get_pixel_primary_channel(screenColor); + const int primary_channel = axis_primary_v3(screenColor); if (pixelColor[primary_channel] > 1.0f) { /* overexposure doesn't happen on screen itself and usually happens |