[Bf-blender-cvs] [25fab54] master: Fix errors in hsv calculation from recent optimization patch.

Antony Riakiotakis noreply at git.blender.org
Mon Jul 21 12:34:57 CEST 2014


Commit: 25fab54e092fb453e418ed1c895c739f4c5d03c8
Author: Antony Riakiotakis
Date:   Mon Jul 21 12:33:49 2014 +0200
Branches: master
https://developer.blender.org/rB25fab54e092fb453e418ed1c895c739f4c5d03c8

Fix errors in hsv calculation from recent optimization patch.

Code was different from original here, result was apparent in color
picker wedge position.

===================================================================

M	source/blender/blenlib/intern/math_color.c

===================================================================

diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index 3dd8aab..eb9e36b 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -212,17 +212,20 @@ void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv)
 {
 	float k = 0.0f;
 	float chroma;
+	float min_gb;
 
 	if (g < b) {
 		SWAP(float, g, b);
 		k = -1.0f;
 	}
+	min_gb = b;
 	if (r < g) {
 		SWAP(float, r, g);
-		k = -2.0f * 6e-1f - k;
+		k = -2.0f / 6.0f - k;
+		min_gb = min_ff(g, b);
 	}
 
-	chroma = r - min_ff(g, b);
+	chroma = r - min_gb;
 
 	*lh = fabsf(k + (g - b) / (6.0f * chroma + 1e-20f));
 	*ls = chroma / (r + 1e-20f);




More information about the Bf-blender-cvs mailing list