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!
This commit is contained in:
Bastien Montagne 2013-11-09 10:35:32 +00:00
parent ac6d91b939
commit 396fb315c5
1 changed files with 45 additions and 17 deletions

View File

@ -482,7 +482,15 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
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 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
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 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
}
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 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
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 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
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)) {