From eccc57aa5c791009634ffe8a1e41472ce02317f5 Mon Sep 17 00:00:00 2001 From: Falk David Date: Sat, 6 Feb 2021 08:53:16 +0100 Subject: Fix T85378: Shrink/Fatten display number units Currently the displayed distance when using the shrink/fatten transform operator does not respect the scene units (they would always be in blender units). This changes makes sure the number is displayed in the correct unit. Reviewed By: mano-wii Maniphest Tasks: T85378 Differential Revision: https://developer.blender.org/D10325 --- .../editors/transform/transform_mode_shrink_fatten.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/transform/transform_mode_shrink_fatten.c b/source/blender/editors/transform/transform_mode_shrink_fatten.c index 2a5c631df41..ba5b1229f3e 100644 --- a/source/blender/editors/transform/transform_mode_shrink_fatten.c +++ b/source/blender/editors/transform/transform_mode_shrink_fatten.c @@ -64,6 +64,7 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) int i; char str[UI_MAX_DRAW_STR]; size_t ofs = 0; + UnitSettings *unit = &t->scene->unit; distance = t->values[0]; @@ -74,15 +75,21 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) t->values_final[0] = distance; /* header print for NumInput */ - ofs += BLI_strncpy_rlen(str + ofs, TIP_("Shrink/Fatten:"), sizeof(str) - ofs); + ofs += BLI_strncpy_rlen(str + ofs, TIP_("Shrink/Fatten: "), sizeof(str) - ofs); if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - outputNumInput(&(t->num), c, &t->scene->unit); - ofs += BLI_snprintf(str + ofs, sizeof(str) - ofs, " %s", c); + outputNumInput(&(t->num), c, unit); + ofs += BLI_snprintf(str + ofs, sizeof(str) - ofs, "%s", c); } else { /* default header print */ - ofs += BLI_snprintf(str + ofs, sizeof(str) - ofs, " %.4f", distance); + if (unit != NULL) { + ofs += BKE_unit_value_as_string( + str + ofs, sizeof(str) - ofs, distance * unit->scale_length, 4, B_UNIT_LENGTH, unit, true); + } + else { + ofs += BLI_snprintf(str + ofs, sizeof(str) - ofs, "%.4f", distance); + } } if (t->proptext[0]) { -- cgit v1.2.3