diff options
author | Ramil Roosileht <Limarest> | 2022-04-22 09:08:15 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2022-04-22 09:09:18 +0300 |
commit | b226236b017f5f84c5ce029689b0707f639299dc (patch) | |
tree | cbe2f96dbe61d175def3f4f303437ee7324296c4 | |
parent | d724d3ae58027eb3fae11bb2b4a9f9e827739baf (diff) |
Fix - Display correct units in "Edit voxel size" widget
Fix for T84962
Before the patch, edit voxel size always displayed voxel size without units, just as a number in meters.
Now it changes like in the voxel remesh panel and shows correct units
Video:
{F13009428}
In adaptive mode:
{F13009435}
Reviewed By: JulienKaspar
Maniphest Tasks: T84962
Differential Revision: https://developer.blender.org/D14682
-rw-r--r-- | source/blender/editors/object/object_remesh.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/source/blender/editors/object/object_remesh.cc b/source/blender/editors/object/object_remesh.cc index 39416a5fbe3..b65e76a5031 100644 --- a/source/blender/editors/object/object_remesh.cc +++ b/source/blender/editors/object/object_remesh.cc @@ -40,6 +40,7 @@ #include "BKE_report.h" #include "BKE_scene.h" #include "BKE_shrinkwrap.h" +#include "BKE_unit.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" @@ -282,7 +283,7 @@ static void voxel_size_parallel_lines_draw(uint pos3d, immEnd(); } -static void voxel_size_edit_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *arg) +static void voxel_size_edit_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) { VoxelSizeEditCustomData *cd = static_cast<VoxelSizeEditCustomData *>(arg); @@ -338,8 +339,9 @@ static void voxel_size_edit_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), short fstyle_points = fstyle->points; char str[VOXEL_SIZE_EDIT_MAX_STR_LEN]; short strdrawlen = 0; - - BLI_snprintf(str, VOXEL_SIZE_EDIT_MAX_STR_LEN, "%.4f", cd->voxel_size); + Scene *scene = CTX_data_scene(C); + UnitSettings *unit = &scene->unit; + BKE_unit_value_as_string(str, VOXEL_SIZE_EDIT_MAX_STR_LEN, (double)(cd->voxel_size * unit->scale_length), 4, B_UNIT_LENGTH, unit, true); strdrawlen = BLI_strlen_utf8(str); immUnbindProgram(); |