[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54655] trunk/blender/source/blender/ editors/interface/interface_handlers.c: fix [#34295] Color picker brightness to infinity
Campbell Barton
ideasman42 at gmail.com
Tue Feb 19 10:41:49 CET 2013
Revision: 54655
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54655
Author: campbellbarton
Date: 2013-02-19 09:41:48 +0000 (Tue, 19 Feb 2013)
Log Message:
-----------
fix [#34295] Color picker brightness to infinity
simply clamp the color to the buttons softrange since color conversion can cause the value to scale outside the intended button limits.
Modified Paths:
--------------
trunk/blender/source/blender/editors/interface/interface_handlers.c
Modified: trunk/blender/source/blender/editors/interface/interface_handlers.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_handlers.c 2013-02-19 08:37:08 UTC (rev 54654)
+++ trunk/blender/source/blender/editors/interface/interface_handlers.c 2013-02-19 09:41:48 UTC (rev 54655)
@@ -3404,6 +3404,19 @@
return WM_UI_HANDLER_CONTINUE;
}
+/* scales a vector so no axis exceeds max
+ * (could become BLI_math func) */
+static void clamp_axis_max_v3(float v[3], const float max)
+{
+ const float v_max = max_fff(v[0], v[1], v[2]);
+ if (v_max > max) {
+ mul_v3_fl(v, max / v_max);
+ if (v[0] > max) v[0] = max;
+ if (v[1] > max) v[1] = max;
+ if (v[2] > max) v[2] = max;
+ }
+}
+
static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx, int my, const short shift)
{
float rgb[3];
@@ -3480,6 +3493,11 @@
if (color_profile && ((int)but->a1 != UI_GRAD_SV))
ui_block_to_scene_linear_v3(but->block, rgb);
+ /* clamp because with color conversion we can exceed range [#34295] */
+ if ((int)but->a1 == UI_GRAD_V_ALT) {
+ clamp_axis_max_v3(rgb, but->softmax);
+ }
+
copy_v3_v3(data->vec, rgb);
data->draglastx = mx;
More information about the Bf-blender-cvs
mailing list