[Bf-blender-cvs] [eccc57aa5c7] blender-v2.92-release: Fix T85378: Shrink/Fatten display number units
Falk David
noreply at git.blender.org
Sat Feb 6 09:08:25 CET 2021
Commit: eccc57aa5c791009634ffe8a1e41472ce02317f5
Author: Falk David
Date: Sat Feb 6 08:53:16 2021 +0100
Branches: blender-v2.92-release
https://developer.blender.org/rBeccc57aa5c791009634ffe8a1e41472ce02317f5
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
===================================================================
M source/blender/editors/transform/transform_mode_shrink_fatten.c
===================================================================
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]) {
More information about the Bf-blender-cvs
mailing list