Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/transform/transform_mode_translate.c')
-rw-r--r--source/blender/editors/transform/transform_mode_translate.c30
1 files changed, 17 insertions, 13 deletions
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 */