From 25fab54e092fb453e418ed1c895c739f4c5d03c8 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Mon, 21 Jul 2014 12:33:49 +0200 Subject: Fix errors in hsv calculation from recent optimization patch. Code was different from original here, result was apparent in color picker wedge position. --- source/blender/blenlib/intern/math_color.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to '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 3dd8aab18d7..eb9e36bcbf4 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); -- cgit v1.2.3