[Bf-blender-cvs] [8de98d68c24] blender-v2.91-release: Fix T83352: Move with constraint showing an incorrect value in the header

Germano Cavalcante noreply at git.blender.org
Wed Jan 13 15:08:45 CET 2021


Commit: 8de98d68c2436d27463b32259f8bb5c415b981c9
Author: Germano Cavalcante
Date:   Thu Dec 3 15:29:23 2020 -0300
Branches: blender-v2.91-release
https://developer.blender.org/rB8de98d68c2436d27463b32259f8bb5c415b981c9

Fix T83352: Move with constraint showing an incorrect value in the header

The displayed value was always that of the x axis.

===================================================================

M	source/blender/editors/transform/transform_mode_translate.c

===================================================================

diff --git a/source/blender/editors/transform/transform_mode_translate.c b/source/blender/editors/transform/transform_mode_translate.c
index 48544eee7ec..ceb8c130c20 100644
--- a/source/blender/editors/transform/transform_mode_translate.c
+++ b/source/blender/editors/transform/transform_mode_translate.c
@@ -62,13 +62,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) {
@@ -83,18 +88,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);
       }
     }
@@ -105,14 +114,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 */



More information about the Bf-blender-cvs mailing list