[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51548] trunk/blender/source/blender: reduce float comparisons for keying operation and despill.
Campbell Barton
ideasman42 at gmail.com
Tue Oct 23 18:32:39 CEST 2012
Revision: 51548
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51548
Author: campbellbarton
Date: 2012-10-23 16:32:39 +0000 (Tue, 23 Oct 2012)
Log Message:
-----------
reduce float comparisons for keying operation and despill.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
trunk/blender/source/blender/blenlib/BLI_math_geom.h
trunk/blender/source/blender/blenlib/intern/math_geom_inline.c
trunk/blender/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_KeyingOperation.cpp
Modified: trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c 2012-10-23 16:21:55 UTC (rev 51547)
+++ trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c 2012-10-23 16:32:39 UTC (rev 51548)
@@ -2496,7 +2496,7 @@
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 @@
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);
Modified: trunk/blender/source/blender/blenlib/BLI_math_geom.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_geom.h 2012-10-23 16:21:55 UTC (rev 51547)
+++ trunk/blender/source/blender/blenlib/BLI_math_geom.h 2012-10-23 16:32:39 UTC (rev 51548)
@@ -283,6 +283,8 @@
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
Modified: trunk/blender/source/blender/blenlib/intern/math_geom_inline.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_geom_inline.c 2012-10-23 16:21:55 UTC (rev 51547)
+++ trunk/blender/source/blender/blenlib/intern/math_geom_inline.c 2012-10-23 16:32:39 UTC (rev 51548)
@@ -137,4 +137,28 @@
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__ */
Modified: trunk/blender/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp 2012-10-23 16:21:55 UTC (rev 51547)
+++ trunk/blender/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp 2012-10-23 16:32:39 UTC (rev 51548)
@@ -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 @@
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;
Modified: trunk/blender/source/blender/compositor/operations/COM_KeyingOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_KeyingOperation.cpp 2012-10-23 16:21:55 UTC (rev 51547)
+++ trunk/blender/source/blender/compositor/operations/COM_KeyingOperation.cpp 2012-10-23 16:32:39 UTC (rev 51548)
@@ -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 @@
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
More information about the Bf-blender-cvs
mailing list