[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29789] trunk/blender/source/blender/ editors: Fix [#22355] Spin Tool crashes Blender on Click'n'Drag Steps

Matt Ebb matt at mke3.net
Tue Jun 29 14:33:25 CEST 2010


Revision: 29789
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29789
Author:   broken
Date:     2010-06-29 14:33:25 +0200 (Tue, 29 Jun 2010)

Log Message:
-----------
Fix [#22355] Spin Tool crashes Blender on Click'n'Drag Steps

Spin tool steps property had no softmin/softmax (set to INT_MAX), and without continuous grab on, the number field dragging code would jump up to ridiculously high numbers.

Added a reasonable soft max for spin, and also added some protection to the button dragging code to prevent the drag increments from getting too high.

Probably need to doublecheck other op property softmaxes as well.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface_handlers.c
    trunk/blender/source/blender/editors/mesh/editmesh_tools.c

Modified: trunk/blender/source/blender/editors/interface/interface_handlers.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_handlers.c	2010-06-29 12:14:03 UTC (rev 29788)
+++ trunk/blender/source/blender/editors/interface/interface_handlers.c	2010-06-29 12:33:25 UTC (rev 29789)
@@ -24,6 +24,7 @@
  */
 
 #include <float.h>
+#include <limits.h>
 #include <math.h>
 #include <stdlib.h>
 #include <string.h>
@@ -2223,7 +2224,6 @@
 	softmax= but->softmax;
 	softrange= softmax - softmin;
 
-
 	if(ui_is_a_warp_but(but)) {
 		/* Mouse location isn't screen clamped to the screen so use a linear mapping
 		 * 2px == 1-int, or 1px == 1-ClickStep */
@@ -2283,15 +2283,18 @@
 		/* Use a non-linear mapping of the mouse drag especially for large floats (normal behavior) */
 		deler= 500;
 		if(!ui_is_but_float(but)) {
-			if((softrange)<100) deler= 200.0;
-			if((softrange)<25) deler= 50.0;
+			/* prevent large ranges from getting too out of control */
+			if (softrange > 600) deler = powf(softrange, 0.75);
+			
+			if (softrange < 100) deler= 200.0;
+			if (softrange < 25) deler= 50.0;
 		}
 		deler /= fac;
 
-		if(ui_is_but_float(but) && softrange > 11) {
+		if(softrange > 11) {
 			/* non linear change in mouse input- good for high precicsion */
 			data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabs(data->dragstartx-mx)*0.002);
-		} else if (!ui_is_but_float(but) && softrange > 129) { /* only scale large int buttons */
+		} else if (softrange > 129) { /* only scale large int buttons */
 			/* non linear change in mouse input- good for high precicsionm ints need less fine tuning */
 			data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabs(data->dragstartx-mx)*0.004);
 		} else {
@@ -2299,8 +2302,7 @@
 			data->dragf+= ((float)(mx-data->draglastx))/deler ;
 		}
 	
-		if(data->dragf>1.0) data->dragf= 1.0;
-		if(data->dragf<0.0) data->dragf= 0.0;
+		CLAMP(data->dragf, 0.0, 1.0);
 		data->draglastx= mx;
 		tempf= (softmin + data->dragf*softrange);
 
@@ -2312,7 +2314,7 @@
 
 			CLAMP(temp, softmin, softmax);
 			lvalue= (int)data->value;
-
+			
 			if(temp != lvalue) {
 				data->dragchange= 1;
 				data->value= (double)temp;

Modified: trunk/blender/source/blender/editors/mesh/editmesh_tools.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_tools.c	2010-06-29 12:14:03 UTC (rev 29788)
+++ trunk/blender/source/blender/editors/mesh/editmesh_tools.c	2010-06-29 12:33:25 UTC (rev 29789)
@@ -1030,7 +1030,7 @@
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 
 	/* props */
-	RNA_def_int(ot->srna, "steps", 9, 0, INT_MAX, "Steps", "Steps", 0, INT_MAX);
+	RNA_def_int(ot->srna, "steps", 9, 0, INT_MAX, "Steps", "Steps", 0, 128);
 	RNA_def_boolean(ot->srna, "dupli", 0, "Dupli", "Make Duplicates");
 	RNA_def_float(ot->srna, "degrees", 90.0f, -FLT_MAX, FLT_MAX, "Degrees", "Degrees", -360.0f, 360.0f);
 





More information about the Bf-blender-cvs mailing list