use BLI math length functions for distance compositor operations.
authorCampbell Barton <ideasman42@gmail.com>
Sun, 19 Aug 2012 10:41:16 +0000 (10:41 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 19 Aug 2012 10:41:16 +0000 (10:41 +0000)
source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp
source/blender/compositor/operations/COM_DistanceYCCMatteOperation.cpp

index df3809ba129dcf5b5483bf9284be73375ff95158..d3309e0c97807855d9b020138fff05e50724e64d 100644 (file)
@@ -46,9 +46,7 @@ void DistanceRGBMatteOperation::deinitExecution()
 
 float DistanceRGBMatteOperation::calculateDistance(float key[4], float image[4])
 {
-       return sqrt(pow((key[0] - image[0]), 2) +
-                   pow((key[1] - image[1]), 2) +
-                   pow((key[2] - image[2]), 2));
+       return len_v3v3(key, image);
 }
 
 void DistanceRGBMatteOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
index 32ed7486f5b4b75f8851e5f7ef8b63bc89ebbcd7..0a6f1fdfd316a5b014ea5dc23ba75c35c769140e 100644 (file)
@@ -29,7 +29,7 @@ DistanceYCCMatteOperation::DistanceYCCMatteOperation() : DistanceRGBMatteOperati
 
 float DistanceYCCMatteOperation::calculateDistance(float key[4], float image[4])
 {
-       return sqrt(pow((key[1] - image[1]), 2) +
-                   pow((key[2] - image[2]), 2));
+       /* only measure the second 2 values */
+       return len_v2v2(key + 1, image + 1);
 }