Fix T83352: Move with constraint showing an incorrect value in the header
The displayed value was always that of the x axis.
This commit is contained in:
parent
f637b47064
commit
f3b08af24c
Notes:
blender-bot
2023-02-14 05:50:03 +01:00
Referenced by commit 8d590e4b86
, Fix T83801: UVEditor translation ignores "Pixel Coordinates" and aspect
Referenced by issue #83352, In "UV Editor", the movement of UV objects in pixels of an open texture map stopped working when using the [g]+[x/y] keyboard shortcuts (Blender 2.91)
Referenced by issue #83216, Potential candidates for corrective releases
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue