From f3b08af24c9f00f437e57e8fc762235c6cff9286 Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Thu, 3 Dec 2020 15:29:23 -0300 Subject: Fix T83352: Move with constraint showing an incorrect value in the header The displayed value was always that of the x axis. --- .../editors/transform/transform_mode_translate.c | 30 ++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'source') diff --git a/source/blender/editors/transform/transform_mode_translate.c b/source/blender/editors/transform/transform_mode_translate.c index a54de102966..90c1f241338 100644 --- a/source/blender/editors/transform/transform_mode_translate.c +++ b/source/blender/editors/transform/transform_mode_translate.c @@ -60,13 +60,18 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_ char autoik[NUM_STR_REP_LEN]; float dist; + UnitSettings *unit = NULL; + if (!(t->flag & T_2D_EDIT)) { + unit = &t->scene->unit; + } + if (hasNumInput(&t->num)) { outputNumInput(&(t->num), tvec, &t->scene->unit); dist = len_v3(t->num.val); } else { float dvec[3]; - if (!(t->flag & T_2D_EDIT) && t->con.mode & CON_APPLY) { + if (t->con.mode & CON_APPLY) { int i = 0; zero_v3(dvec); if (t->con.mode & CON_AXIS0) { @@ -81,18 +86,22 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_ } else { copy_v3_v3(dvec, vec); + } + + if (t->flag & T_2D_EDIT) { applyAspectRatio(t, dvec); } - dist = len_v3(vec); - if (!(t->flag & T_2D_EDIT) && t->scene->unit.system) { + dist = len_v3(dvec); + + if (unit) { for (int i = 0; i < 3; i++) { BKE_unit_value_as_string(&tvec[NUM_STR_REP_LEN * i], NUM_STR_REP_LEN, - dvec[i] * t->scene->unit.scale_length, + dvec[i] * unit->scale_length, 4, B_UNIT_LENGTH, - &t->scene->unit, + unit, true); } } @@ -103,14 +112,9 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_ } } - if (!(t->flag & T_2D_EDIT) && t->scene->unit.system) { - BKE_unit_value_as_string(distvec, - sizeof(distvec), - dist * t->scene->unit.scale_length, - 4, - B_UNIT_LENGTH, - &t->scene->unit, - false); + if (unit) { + BKE_unit_value_as_string( + distvec, sizeof(distvec), dist * unit->scale_length, 4, B_UNIT_LENGTH, unit, false); } else if (dist > 1e10f || dist < -1e10f) { /* prevent string buffer overflow */ -- cgit v1.2.3