[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [61208] trunk/blender/source/blender/ editors/space_view3d/view3d_buttons.c: More fix for [#37327] Inconsistent numeric input conversion.

Bastien Montagne montagne29 at wanadoo.fr
Sat Nov 9 11:35:32 CET 2013


Revision: 61208
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=61208
Author:   mont29
Date:     2013-11-09 10:35:32 +0000 (Sat, 09 Nov 2013)
Log Message:
-----------
More fix for [#37327] Inconsistent numeric input conversion.

When a single element is involved, apply directly the values instead of using the diff from init values. This avoids glitches when going from huge values to very small ones (due to float precision).

Note we should probably switch to doubles here, ultimately, but would leave that for later.

Manys thanks to Armin Zingler, who did all the investigation work on this point!

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c	2013-11-08 22:02:46 UTC (rev 61207)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c	2013-11-09 10:35:32 UTC (rev 61208)
@@ -482,7 +482,15 @@
 
 				BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
 					if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
-						add_v3_v3(eve->co, &median[LOC_X]);
+						if (tot == 1) {
+							/* In case we only have one element selected, copy directly the value instead of applying
+							 * the diff. Avoids some glitches when going e.g. from 3 to 0.0001 (see [#37327]).
+							 */
+							copy_v3_v3(eve->co, &ve_median[LOC_X]);
+						}
+						else {
+							add_v3_v3(eve->co, &median[LOC_X]);
+						}
 					}
 				}
 
@@ -623,10 +631,12 @@
 			nu = nurbs->first;
 			while (nu) {
 				if (nu->type == CU_BEZIER) {
-					bezt = nu->bezt;
-					a = nu->pntsu;
-					while (a--) {
+					for (a = nu->pntsu, bezt = nu->bezt; a--; bezt++) {
 						if (bezt->f2 & SELECT) {
+							/* Here we always have to use the diff... :/
+							 * Cannot avoid some glitches when going e.g. from 3 to 0.0001 (see [#37327]),
+							 * unless we use doubles.
+							 */
 							add_v3_v3(bezt->vec[0], &median[LOC_X]);
 							add_v3_v3(bezt->vec[1], &median[LOC_X]);
 							add_v3_v3(bezt->vec[2], &median[LOC_X]);
@@ -647,22 +657,39 @@
 						}
 						else {
 							if (bezt->f1 & SELECT) {
-								add_v3_v3(bezt->vec[0], &median[LOC_X]);
+								if (tot == 1) {
+									copy_v3_v3(bezt->vec[0], &ve_median[LOC_X]);
+								}
+								else {
+									add_v3_v3(bezt->vec[0], &median[LOC_X]);
+								}
 							}
 							if (bezt->f3 & SELECT) {
-								add_v3_v3(bezt->vec[2], &median[LOC_X]);
+								if (tot == 1) {
+									copy_v3_v3(bezt->vec[2], &ve_median[LOC_X]);
+								}
+								else {
+									add_v3_v3(bezt->vec[2], &median[LOC_X]);
+								}
 							}
 						}
-						bezt++;
 					}
 				}
 				else {
-					bp = nu->bp;
-					a = nu->pntsu * nu->pntsv;
-					while (a--) {
+					for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a--; bp++) {
 						if (bp->f1 & SELECT) {
-							add_v3_v3(bp->vec, &median[LOC_X]);
-							bp->vec[3] += median[C_BWEIGHT];
+							if (tot == 1) {
+								copy_v3_v3(bp->vec, &ve_median[LOC_X]);
+								bp->vec[3] = ve_median[C_BWEIGHT];
+								bp->radius = ve_median[C_RADIUS];
+								bp->alfa = ve_median[C_TILT];
+							}
+							else {
+								add_v3_v3(bp->vec, &median[LOC_X]);
+								bp->vec[3] += median[C_BWEIGHT];
+								bp->radius += median[C_RADIUS];
+								bp->alfa += median[C_TILT];
+							}
 
 							if (median[C_WEIGHT] != 0.0f) {
 								if (ELEM(scale_w, 0.0f, 1.0f)) {
@@ -674,11 +701,7 @@
 									CLAMP(bp->weight, 0.0f, 1.0f);
 								}
 							}
-
-							bp->radius += median[C_RADIUS];
-							bp->alfa += median[C_TILT];
 						}
-						bp++;
 					}
 				}
 				BKE_nurb_test2D(nu);
@@ -697,7 +720,12 @@
 			bp = lt->editlatt->latt->def;
 			while (a--) {
 				if (bp->f1 & SELECT) {
-					add_v3_v3(bp->vec, &median[LOC_X]);
+					if (tot == 1) {
+						copy_v3_v3(bp->vec, &ve_median[LOC_X]);
+					}
+					else {
+						add_v3_v3(bp->vec, &median[LOC_X]);
+					}
 
 					if (median[L_WEIGHT] != 0.0f) {
 						if (ELEM(scale_w, 0.0f, 1.0f)) {




More information about the Bf-blender-cvs mailing list