From b226236b017f5f84c5ce029689b0707f639299dc Mon Sep 17 00:00:00 2001 From: Ramil Roosileht Date: Fri, 22 Apr 2022 08:08:15 +0200 Subject: 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 --- source/blender/editors/object/object_remesh.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source/blender/editors') 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(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(); -- cgit v1.2.3