[Bf-blender-cvs] [bc41d25] master: NDOF: minor color picker improvements

Campbell Barton noreply at git.blender.org
Wed Feb 12 11:08:53 CET 2014


Commit: bc41d255cbe88875b1e5a6f32a135ba4dd89d3f7
Author: Campbell Barton
Date:   Wed Feb 12 17:22:41 2014 +1100
https://developer.blender.org/rBbc41d255cbe88875b1e5a6f32a135ba4dd89d3f7

NDOF: minor color picker improvements

- swap Z/Y axis so Z changes hue and X/Y change location.
  this way you can use ndof like a joystick and Z rotation like a dial
  for the hue.

- change sensitivity when shift is held to be 1/5th

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

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

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

diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 4665752..c3d8343 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -4626,7 +4626,7 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data,
 	float *hsv = ui_block_hsv_get(but->block);
 	float rgb[3];
 	float phi, r /*, sqr */ /* UNUSED */, v[2];
-	float sensitivity = (shift ? 0.15f : 0.3f) * ndof->dt;
+	float sensitivity = (shift ? 0.06f : 0.3f) * ndof->dt;
 	
 	ui_get_but_vectorf(but, rgb);
 	rgb_to_hsv_compat_v(rgb, hsv);
@@ -4641,20 +4641,18 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data,
 	v[1] = r * sinf(phi);
 	
 	/* Use ndof device y and x rotation to move the vector in 2d space */
-	v[0] += ndof->ry * sensitivity;
+	v[0] += ndof->rz * sensitivity;
 	v[1] += ndof->rx * sensitivity;
 
 	/* convert back to polar coords on circle */
 	phi = atan2f(v[0], v[1]) / (2.0f * (float)M_PI) + 0.5f;
 	
 	/* use ndof z rotation to additionally rotate hue */
-	phi -= ndof->rz * sensitivity * 0.5f;
-	
+	phi += ndof->ry * sensitivity * 0.5f;
 	r = len_v2(v);
-	CLAMP(r, 0.0f, 1.0f);
-	
+
 	/* convert back to hsv values, in range [0,1] */
-	hsv[0] = fmodf(phi, 1.0f);
+	hsv[0] = phi;
 	hsv[1] = r;
 
 	/* exception, when using color wheel in 'locked' value state:
@@ -4667,6 +4665,8 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data,
 		ui_color_snap_hue(snap, &hsv[0]);
 	}
 
+	hsv_clamp_v(hsv, FLT_MAX);
+
 	hsv_to_rgb_v(hsv, data->vec);
 	
 	if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (data->vec[0] || data->vec[1] || data->vec[2])) {




More information about the Bf-blender-cvs mailing list