diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index eea084b4750..c4fdacaa915 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -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)) {