[Bf-blender-cvs] [d4b3068f36] blender2.8: Use FTOCHAR rather than CLAMP of uchar output

Sergey Sharybin noreply at git.blender.org
Wed Mar 15 13:50:52 CET 2017


Commit: d4b3068f36bf86a36ee49592b7f17771c881869d
Author: Sergey Sharybin
Date:   Wed Mar 15 13:48:47 2017 +0100
Branches: blender2.8
https://developer.blender.org/rBd4b3068f36bf86a36ee49592b7f17771c881869d

Use FTOCHAR rather than CLAMP of uchar output

This makes no sense to clamp after value was assigned to uchar already.
Proper way to do so is to use FTOCHAR.

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

M	source/blender/editors/interface/resources.c

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

diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index a6235a8d26..89e7b60edb 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -1500,13 +1500,13 @@ void UI_GetThemeColorBlendShade3ubv(int colorid1, int colorid2, float fac, int o
 	cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
 
 	CLAMP(fac, 0.0f, 1.0f);
-	col[0] = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
-	col[1] = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
-	col[2] = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
 
-	CLAMP(col[0], 0, 255);
-	CLAMP(col[1], 0, 255);
-	CLAMP(col[2], 0, 255);
+	float blend[3];
+	blend[0] = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
+	blend[1] = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
+	blend[2] = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
+
+	F3TOCHAR3(blend, col);
 }
 
 void UI_GetThemeColorShade4ubv(int colorid, int offset, unsigned char col[4])




More information about the Bf-blender-cvs mailing list