diff --git a/source/blender/blenkernel/BKE_unit.hh b/source/blender/blenkernel/BKE_unit.hh index 06b04ef4edd..3d2e59a643d 100644 --- a/source/blender/blenkernel/BKE_unit.hh +++ b/source/blender/blenkernel/BKE_unit.hh @@ -34,7 +34,7 @@ size_t BKE_unit_value_as_string(char *str, double value, int prec, int type, - const UnitSettings *settings, + const UnitSettings &settings, bool pad); /** @@ -45,7 +45,7 @@ size_t BKE_unit_value_as_string_scaled(char *str, double value, int prec, int type, - const UnitSettings *settings, + const UnitSettings &settings, bool pad); /** @@ -76,7 +76,7 @@ bool BKE_unit_string_contains_unit(const char *str, int type); /** * If user does not specify a unit, this converts it to the unit from the settings. */ -double BKE_unit_apply_preferred_unit(const UnitSettings *settings, int type, double value); +double BKE_unit_apply_preferred_unit(const UnitSettings &settings, int type, double value); /** * Make string keyboard-friendly, e.g: `10µm -> 10um`. @@ -102,7 +102,7 @@ bool BKE_unit_is_valid(int system, int type); * Apply the needed correction factor to value, based on unit_type * (only length-related are affected currently) and `unit->scale_length`. */ -double BKE_unit_value_scale(const UnitSettings *unit, int unit_type, double value); +double BKE_unit_value_scale(const UnitSettings &settings, int unit_type, double value); /** * Loop over scales, could add names later. diff --git a/source/blender/blenkernel/intern/unit.cc b/source/blender/blenkernel/intern/unit.cc index 29efe9e54a4..cc04674ac67 100644 --- a/source/blender/blenkernel/intern/unit.cc +++ b/source/blender/blenkernel/intern/unit.cc @@ -1734,15 +1734,15 @@ struct PreferredUnits { int temperature; }; -static PreferredUnits preferred_units_from_UnitSettings(const UnitSettings *settings) +static PreferredUnits preferred_units_from_UnitSettings(const UnitSettings &settings) { PreferredUnits units = {0}; - units.system = settings->system; - units.rotation = settings->system_rotation; - units.length = settings->length_unit; - units.mass = settings->mass_unit; - units.time = settings->time_unit; - units.temperature = settings->temperature_unit; + units.system = settings.system; + units.rotation = settings.system_rotation; + units.length = settings.length_unit; + units.mass = settings.mass_unit; + units.time = settings.time_unit; + units.temperature = settings.temperature_unit; return units; } @@ -1878,10 +1878,10 @@ size_t BKE_unit_value_as_string(char *str, double value, int prec, int type, - const UnitSettings *settings, + const UnitSettings &settings, bool pad) { - bool do_split = (settings->flag & USER_UNIT_OPT_SPLIT) != 0; + bool do_split = (settings.flag & USER_UNIT_OPT_SPLIT) != 0; PreferredUnits units = preferred_units_from_UnitSettings(settings); return unit_as_string_main(str, str_maxncpy, value, prec, type, do_split, pad, units); } @@ -1891,16 +1891,16 @@ size_t BKE_unit_value_as_string_scaled(char *str, double value, int prec, int type, - const UnitSettings *settings, + const UnitSettings &settings, bool pad) { return BKE_unit_value_as_string( str, str_maxncpy, BKE_unit_value_scale(settings, type, value), prec, type, settings, pad); } -double BKE_unit_value_scale(const UnitSettings *unit, const int unit_type, double value) +double BKE_unit_value_scale(const UnitSettings &settings, const int unit_type, double value) { - if (unit->system == USER_UNIT_NONE) { + if (settings.system == USER_UNIT_NONE) { /* Never apply scale_length when not using a unit setting! */ return value; } @@ -1909,14 +1909,14 @@ double BKE_unit_value_scale(const UnitSettings *unit, const int unit_type, doubl case B_UNIT_LENGTH: case B_UNIT_VELOCITY: case B_UNIT_ACCELERATION: - return value * double(unit->scale_length); + return value * double(settings.scale_length); case B_UNIT_AREA: case B_UNIT_POWER: - return value * pow(unit->scale_length, 2); + return value * pow(settings.scale_length, 2); case B_UNIT_VOLUME: - return value * pow(unit->scale_length, 3); + return value * pow(settings.scale_length, 3); case B_UNIT_MASS: - return value * pow(unit->scale_length, 3); + return value * pow(settings.scale_length, 3); case B_UNIT_CAMERA: /* *Do not* use scene's unit scale for camera focal lens! See #42026. */ case B_UNIT_WAVELENGTH: /* Wavelength values are independent of the scene scale. */ default: @@ -2338,7 +2338,7 @@ bool BKE_unit_string_contains_unit(const char *str, int type) return false; } -double BKE_unit_apply_preferred_unit(const UnitSettings *settings, int type, double value) +double BKE_unit_apply_preferred_unit(const UnitSettings &settings, int type, double value) { PreferredUnits units = preferred_units_from_UnitSettings(settings); const bUnitDef *unit = get_preferred_display_unit_if_used(type, units); diff --git a/source/blender/draw/engines/overlay/overlay_next_mesh.hh b/source/blender/draw/engines/overlay/overlay_next_mesh.hh index 246f410ce9a..e264bbabe6b 100644 --- a/source/blender/draw/engines/overlay/overlay_next_mesh.hh +++ b/source/blender/draw/engines/overlay/overlay_next_mesh.hh @@ -349,7 +349,7 @@ class Meshes : Overlay { edit_mesh_skin_roots_ps_.draw_expand(geom, GPU_PRIM_LINES, 32, 1, res_handle); } if (state.show_text && (state.overlay.edit_flag & overlay_edit_text)) { - DRW_text_edit_mesh_measure_stats(state.region, state.v3d, ob, &state.scene->unit, state.dt); + DRW_text_edit_mesh_measure_stats(state.region, state.v3d, ob, state.scene->unit, state.dt); } } diff --git a/source/blender/draw/intern/draw_manager_text.cc b/source/blender/draw/intern/draw_manager_text.cc index 589c7c319d6..286615dcbfa 100644 --- a/source/blender/draw/intern/draw_manager_text.cc +++ b/source/blender/draw/intern/draw_manager_text.cc @@ -259,7 +259,7 @@ void DRW_text_cache_draw(DRWTextStore *dt, ARegion *region, View3D *v3d) void DRW_text_edit_mesh_measure_stats(const ARegion *region, const View3D *v3d, const Object *ob, - const UnitSettings *unit, + const UnitSettings &unit, DRWTextStore *dt) { /* Do not use ascii when using non-default unit system, some unit chars are utf8 (micro, square, @@ -277,7 +277,7 @@ void DRW_text_edit_mesh_measure_stats(const ARegion *region, char numstr[32]; /* Stores the measurement display text here */ const char *conv_float; /* Use a float conversion matching the grid size */ blender::uchar4 col = {0, 0, 0, 255}; /* color of the text to draw */ - const float grid = unit->system ? unit->scale_length : v3d->grid; + const float grid = unit.system ? unit.scale_length : v3d->grid; const bool do_global = (v3d->flag & V3D_GLOBAL_STATS) != 0; const bool do_moving = (G.moving & G_TRANSFORM_EDIT) != 0; blender::float4x4 clip_planes; @@ -363,7 +363,7 @@ void DRW_text_edit_mesh_measure_stats(const ARegion *region, } const size_t numstr_len = - unit->system ? + unit.system ? BKE_unit_value_as_string_scaled( numstr, sizeof(numstr), len_v3v3(v1, v2), 3, B_UNIT_LENGTH, unit, false) : SNPRINTF_RLEN(numstr, conv_float, len_v3v3(v1, v2)); @@ -375,7 +375,7 @@ void DRW_text_edit_mesh_measure_stats(const ARegion *region, } if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_ANG) { - const bool is_rad = (unit->system_rotation == USER_UNIT_ROT_RADIANS); + const bool is_rad = (unit.system_rotation == USER_UNIT_ROT_RADIANS); BMEdge *eed; UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGEANG, col); @@ -498,9 +498,9 @@ void DRW_text_edit_mesh_measure_stats(const ARegion *region, vmid = blender::math::transform_point(ob->object_to_world(), vmid); const size_t numstr_len = - unit->system ? BKE_unit_value_as_string_scaled( - numstr, sizeof(numstr), area, 3, B_UNIT_AREA, unit, false) : - SNPRINTF_RLEN(numstr, conv_float, area); + unit.system ? BKE_unit_value_as_string_scaled( + numstr, sizeof(numstr), area, 3, B_UNIT_AREA, unit, false) : + SNPRINTF_RLEN(numstr, conv_float, area); DRW_text_cache_add(dt, vmid, numstr, numstr_len, 0, 0, txt_flag, col); } @@ -510,7 +510,7 @@ void DRW_text_edit_mesh_measure_stats(const ARegion *region, if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_FACE_ANG) { BMFace *efa; - const bool is_rad = (unit->system_rotation == USER_UNIT_ROT_RADIANS); + const bool is_rad = (unit.system_rotation == USER_UNIT_ROT_RADIANS); UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col); diff --git a/source/blender/draw/intern/draw_manager_text.hh b/source/blender/draw/intern/draw_manager_text.hh index d58faf57335..73838b82cbe 100644 --- a/source/blender/draw/intern/draw_manager_text.hh +++ b/source/blender/draw/intern/draw_manager_text.hh @@ -38,7 +38,7 @@ void DRW_text_cache_draw(DRWTextStore *dt, ARegion *region, View3D *v3d); void DRW_text_edit_mesh_measure_stats(const ARegion *region, const View3D *v3d, const Object *ob, - const UnitSettings *unit, + const UnitSettings &unit, DRWTextStore *dt = DRW_text_cache_ensure()); enum { diff --git a/source/blender/editors/animation/anim_markers.cc b/source/blender/editors/animation/anim_markers.cc index ff430ef6855..81e98bcc063 100644 --- a/source/blender/editors/animation/anim_markers.cc +++ b/source/blender/editors/animation/anim_markers.cc @@ -857,7 +857,7 @@ static void ed_marker_move_update_header(bContext *C, wmOperator *op) } if (hasNumInput(&mm->num)) { - outputNumInput(&mm->num, str_ofs, &scene->unit); + outputNumInput(&mm->num, str_ofs, scene->unit); } else if (use_time) { SNPRINTF(str_ofs, "%.2f", FRA2TIME(ofs)); diff --git a/source/blender/editors/armature/pose_slide.cc b/source/blender/editors/armature/pose_slide.cc index e245578736b..cc08b23f767 100644 --- a/source/blender/editors/armature/pose_slide.cc +++ b/source/blender/editors/armature/pose_slide.cc @@ -967,7 +967,7 @@ static void pose_slide_draw_status(bContext *C, tPoseSlideOp *pso) Scene *scene = pso->scene; char str_offs[NUM_STR_REP_LEN]; - outputNumInput(&pso->num, str_offs, &scene->unit); + outputNumInput(&pso->num, str_offs, scene->unit); SNPRINTF(status_str, "%s: %s | %s", mode_str, str_offs, limits_str); } diff --git a/source/blender/editors/include/ED_numinput.hh b/source/blender/editors/include/ED_numinput.hh index c5842f6313e..f66267f7aa3 100644 --- a/source/blender/editors/include/ED_numinput.hh +++ b/source/blender/editors/include/ED_numinput.hh @@ -81,7 +81,7 @@ void initNumInput(NumInput *n); /** * \param str: Must be NUM_STR_REP_LEN * (idx_max + 1) length. */ -void outputNumInput(NumInput *n, char *str, const UnitSettings *unit_settings); +void outputNumInput(NumInput *n, char *str, const UnitSettings &unit_settings); bool hasNumInput(const NumInput *n); /** * \warning \a vec must be set beforehand otherwise we risk uninitialized vars. @@ -95,7 +95,7 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event); bool user_string_to_number(bContext *C, const char *str, - const UnitSettings *unit, + const UnitSettings &unit, int type, double *r_value, bool use_single_line_error, diff --git a/source/blender/editors/interface/eyedroppers/eyedropper_depth.cc b/source/blender/editors/interface/eyedroppers/eyedropper_depth.cc index 3e430eb1289..17a46fabb01 100644 --- a/source/blender/editors/interface/eyedroppers/eyedropper_depth.cc +++ b/source/blender/editors/interface/eyedroppers/eyedropper_depth.cc @@ -285,7 +285,7 @@ static void depthdropper_depth_sample_pt(bContext *C, double(*r_depth), 4, B_UNIT_LENGTH, - &scene->unit, + scene->unit, false); } else { diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc index 5f6f83f686b..4e99aad7764 100644 --- a/source/blender/editors/interface/interface.cc +++ b/source/blender/editors/interface/interface.cc @@ -2837,7 +2837,7 @@ static double ui_get_but_scale_unit(uiBut *but, double value) Scene *scene = CTX_data_scene(static_cast(but->block->evil_C)); return FRA2TIME(value); } - return BKE_unit_value_scale(unit, RNA_SUBTYPE_UNIT_VALUE(unit_type), value); + return BKE_unit_value_scale(*unit, RNA_SUBTYPE_UNIT_VALUE(unit_type), value); } void ui_but_convert_to_unit_alt_name(uiBut *but, char *str, size_t str_maxncpy) @@ -2890,7 +2890,7 @@ static void ui_get_but_string_unit( ui_get_but_scale_unit(but, value), precision, RNA_SUBTYPE_UNIT_VALUE(unit_type), - unit, + *unit, pad); } @@ -3128,7 +3128,7 @@ static bool ui_number_from_string_units( bContext *C, const char *str, const int unit_type, const UnitSettings *unit, double *r_value) { char *error = nullptr; - const bool ok = user_string_to_number(C, str, unit, unit_type, r_value, true, &error); + const bool ok = user_string_to_number(C, str, *unit, unit_type, r_value, true, &error); if (error) { ReportList *reports = CTX_wm_reports(C); BKE_reportf(reports, RPT_ERROR, "%s: %s", UI_NUMBER_EVAL_ERROR_PREFIX, error); diff --git a/source/blender/editors/mesh/editmesh_bevel.cc b/source/blender/editors/mesh/editmesh_bevel.cc index 8b6b09c6f78..f7d83c1ca7b 100644 --- a/source/blender/editors/mesh/editmesh_bevel.cc +++ b/source/blender/editors/mesh/editmesh_bevel.cc @@ -134,7 +134,7 @@ static void edbm_bevel_update_status_text(bContext *C, wmOperator *op) else { double offset_val = double(RNA_float_get(op->ptr, "offset")); BKE_unit_value_as_string_scaled( - offset_str, NUM_STR_REP_LEN, offset_val, 3, B_UNIT_LENGTH, &sce->unit, true); + offset_str, NUM_STR_REP_LEN, offset_val, 3, B_UNIT_LENGTH, sce->unit, true); } PropertyRNA *prop; diff --git a/source/blender/editors/mesh/editmesh_inset.cc b/source/blender/editors/mesh/editmesh_inset.cc index e16c77db4be..330d7f5d72b 100644 --- a/source/blender/editors/mesh/editmesh_inset.cc +++ b/source/blender/editors/mesh/editmesh_inset.cc @@ -80,7 +80,7 @@ static void edbm_inset_update_header(wmOperator *op, bContext *C) char msg[UI_MAX_DRAW_STR]; char flts_str[NUM_STR_REP_LEN * 2]; if (hasNumInput(&opdata->num_input)) { - outputNumInput(&opdata->num_input, flts_str, &sce->unit); + outputNumInput(&opdata->num_input, flts_str, sce->unit); } else { BKE_unit_value_as_string(flts_str, @@ -88,14 +88,14 @@ static void edbm_inset_update_header(wmOperator *op, bContext *C) RNA_float_get(op->ptr, "thickness"), 4, B_UNIT_LENGTH, - &sce->unit, + sce->unit, true); BKE_unit_value_as_string(flts_str + NUM_STR_REP_LEN, NUM_STR_REP_LEN, RNA_float_get(op->ptr, "depth"), 4, B_UNIT_LENGTH, - &sce->unit, + sce->unit, true); } SNPRINTF(msg, IFACE_("Thickness: %s, Depth: %s"), flts_str, flts_str + NUM_STR_REP_LEN); diff --git a/source/blender/editors/mesh/editmesh_knife.cc b/source/blender/editors/mesh/editmesh_knife.cc index df90e649434..7dfbe41cc10 100644 --- a/source/blender/editors/mesh/editmesh_knife.cc +++ b/source/blender/editors/mesh/editmesh_knife.cc @@ -509,8 +509,8 @@ static void knifetool_draw_visible_distances(const KnifeTool_OpData *kcd) /* Calculate distance and convert to string. */ const float cut_len = len_v3v3(kcd->prev.cage, kcd->curr.cage); - const UnitSettings *unit = &kcd->scene->unit; - if (unit->system == USER_UNIT_NONE) { + const UnitSettings &unit = kcd->scene->unit; + if (unit.system == USER_UNIT_NONE) { SNPRINTF(numstr, "%.*f", distance_precision, cut_len); } else { @@ -640,8 +640,8 @@ static void knifetool_draw_angle(const KnifeTool_OpData *kcd, float numstr_size[2]; float posit[2]; - const UnitSettings *unit = &kcd->scene->unit; - if (unit->system == USER_UNIT_NONE) { + const UnitSettings &unit = kcd->scene->unit; + if (unit.system == USER_UNIT_NONE) { SNPRINTF(numstr, "%.*f" BLI_STR_UTF8_DEGREE_SIGN, angle_precision, RAD2DEGF(angle)); } else { diff --git a/source/blender/editors/mesh/editmesh_loopcut.cc b/source/blender/editors/mesh/editmesh_loopcut.cc index 7b5fd4c5692..eb4fe446da3 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.cc +++ b/source/blender/editors/mesh/editmesh_loopcut.cc @@ -460,7 +460,7 @@ static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event) char buf[UI_MAX_DRAW_STR]; char str_rep[NUM_STR_REP_LEN * 2]; if (hasNumInput(&lcd->num)) { - outputNumInput(&lcd->num, str_rep, &scene->unit); + outputNumInput(&lcd->num, str_rep, scene->unit); } else { BLI_snprintf(str_rep, NUM_STR_REP_LEN, "%d", int(lcd->cuts)); @@ -692,7 +692,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) char buf[UI_MAX_DRAW_STR]; char str_rep[NUM_STR_REP_LEN * 2]; if (hasNumInput(&lcd->num)) { - outputNumInput(&lcd->num, str_rep, &sce->unit); + outputNumInput(&lcd->num, str_rep, sce->unit); } else { BLI_snprintf(str_rep, NUM_STR_REP_LEN, "%d", int(lcd->cuts)); diff --git a/source/blender/editors/object/object_remesh.cc b/source/blender/editors/object/object_remesh.cc index 33a8da88448..db682695ba1 100644 --- a/source/blender/editors/object/object_remesh.cc +++ b/source/blender/editors/object/object_remesh.cc @@ -319,7 +319,7 @@ static void voxel_size_edit_draw(const bContext *C, ARegion * /*region*/, void * char str[VOXEL_SIZE_EDIT_MAX_STR_LEN]; short strdrawlen = 0; Scene *scene = CTX_data_scene(C); - const UnitSettings *unit = &scene->unit; + const UnitSettings &unit = scene->unit; BKE_unit_value_as_string_scaled(str, sizeof(str), cd->voxel_size, -3, B_UNIT_LENGTH, unit, true); strdrawlen = BLI_strlen_utf8(str); diff --git a/source/blender/editors/sculpt_paint/grease_pencil_interpolate.cc b/source/blender/editors/sculpt_paint/grease_pencil_interpolate.cc index c4852ba1410..79e143d74dd 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_interpolate.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_interpolate.cc @@ -584,7 +584,7 @@ static void grease_pencil_interpolate_status_indicators(bContext &C, std::string status; if (hasNumInput(&opdata.numeric_input)) { char str_ofs[NUM_STR_REP_LEN]; - outputNumInput(&const_cast(opdata.numeric_input), str_ofs, &scene.unit); + outputNumInput(&const_cast(opdata.numeric_input), str_ofs, scene.unit); status = msg + std::string(str_ofs); } else { diff --git a/source/blender/editors/space_graph/graph_slider_ops.cc b/source/blender/editors/space_graph/graph_slider_ops.cc index 32a3235ed7f..1d71a3a6fb6 100644 --- a/source/blender/editors/space_graph/graph_slider_ops.cc +++ b/source/blender/editors/space_graph/graph_slider_ops.cc @@ -134,7 +134,7 @@ static void common_draw_status_header(bContext *C, tGraphSliderOp *gso, const ch if (hasNumInput(&gso->num)) { char str_ofs[NUM_STR_REP_LEN]; - outputNumInput(&gso->num, str_ofs, &gso->scene->unit); + outputNumInput(&gso->num, str_ofs, gso->scene->unit); SNPRINTF(status_str, "%s: %s", mode_str, str_ofs); } @@ -464,7 +464,7 @@ static void decimate_draw_status(bContext *C, tGraphSliderOp *gso) if (hasNumInput(&gso->num)) { char str_ofs[NUM_STR_REP_LEN]; - outputNumInput(&gso->num, str_ofs, &gso->scene->unit); + outputNumInput(&gso->num, str_ofs, gso->scene->unit); SNPRINTF(status_str, "%s: %s", mode_str, str_ofs); } @@ -973,7 +973,7 @@ static void ease_draw_status_header(bContext *C, wmOperator *op) if (hasNumInput(&gso->num)) { char str_ofs[NUM_STR_REP_LEN]; - outputNumInput(&gso->num, str_ofs, &gso->scene->unit); + outputNumInput(&gso->num, str_ofs, gso->scene->unit); SNPRINTF(status_str, "%s: %s", mode_str, str_ofs); } @@ -1577,7 +1577,7 @@ static void shear_draw_status_header(bContext *C, tGraphSliderOp *gso) if (hasNumInput(&gso->num)) { char str_ofs[NUM_STR_REP_LEN]; - outputNumInput(&gso->num, str_ofs, &gso->scene->unit); + outputNumInput(&gso->num, str_ofs, gso->scene->unit); SNPRINTF(status_str, "%s: %s", mode_str, str_ofs); } @@ -2467,7 +2467,7 @@ static void scale_from_neighbor_draw_status_header(bContext *C, wmOperator *op) if (hasNumInput(&gso->num)) { char str_ofs[NUM_STR_REP_LEN]; - outputNumInput(&gso->num, str_ofs, &gso->scene->unit); + outputNumInput(&gso->num, str_ofs, gso->scene->unit); SNPRINTF(status_str, "%s: %s", mode_str, str_ofs); } diff --git a/source/blender/editors/space_sequencer/sequencer_edit.cc b/source/blender/editors/space_sequencer/sequencer_edit.cc index 5dc02352a93..0f8639ab1f7 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.cc +++ b/source/blender/editors/space_sequencer/sequencer_edit.cc @@ -637,7 +637,7 @@ static void sequencer_slip_update_header(Scene *scene, ScrArea *area, SlipData * char msg[UI_MAX_DRAW_STR]; if (hasNumInput(&data->num_input)) { char num_str[NUM_STR_REP_LEN]; - outputNumInput(&data->num_input, num_str, &scene->unit); + outputNumInput(&data->num_input, num_str, scene->unit); SNPRINTF(msg, IFACE_("Slip offset: %s"), num_str); } else { diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.cc b/source/blender/editors/space_view3d/view3d_gizmo_ruler.cc index 463fb2a1885..adb8038d7a3 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.cc @@ -193,13 +193,13 @@ static void ruler_item_remove(bContext *C, wmGizmoGroup *gzgroup, RulerItem *rul } static void ruler_item_as_string( - RulerItem *ruler_item, UnitSettings *unit, char *numstr, size_t numstr_size, int prec) + RulerItem *ruler_item, const UnitSettings &unit, char *numstr, size_t numstr_size, int prec) { if (ruler_item->flag & RULERITEM_USE_ANGLE) { const float ruler_angle = angle_v3v3v3( ruler_item->co[0], ruler_item->co[1], ruler_item->co[2]); - if (unit->system == USER_UNIT_NONE) { + if (unit.system == USER_UNIT_NONE) { BLI_snprintf( numstr, numstr_size, "%.*f" BLI_STR_UTF8_DEGREE_SIGN, prec, RAD2DEGF(ruler_angle)); } @@ -211,7 +211,7 @@ static void ruler_item_as_string( else { const float ruler_len = len_v3v3(ruler_item->co[0], ruler_item->co[2]); - if (unit->system == USER_UNIT_NONE) { + if (unit.system == USER_UNIT_NONE) { BLI_snprintf(numstr, numstr_size, "%.*f", prec, ruler_len); } else { @@ -639,7 +639,7 @@ static bool view3d_ruler_from_gpencil(const bContext *C, wmGizmoGroup *gzgroup) static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) { Scene *scene = CTX_data_scene(C); - UnitSettings *unit = &scene->unit; + const UnitSettings &unit = scene->unit; RulerInfo *ruler_info = static_cast(gz->parent_gzgroup->customdata); RulerItem *ruler_item = (RulerItem *)gz; ARegion *region = ruler_info->region; diff --git a/source/blender/editors/transform/transform_mode.cc b/source/blender/editors/transform/transform_mode.cc index 300b9d4a0c7..fbd7cb7c441 100644 --- a/source/blender/editors/transform/transform_mode.cc +++ b/source/blender/editors/transform/transform_mode.cc @@ -540,7 +540,7 @@ void headerRotation(TransInfo *t, char *str, const int str_size, float final) if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - outputNumInput(&(t->num), c, &t->scene->unit); + outputNumInput(&(t->num), c, t->scene->unit); ofs += BLI_snprintf_rlen( str + ofs, str_size - ofs, IFACE_("Rotation: %s %s %s"), &c[0], t->con.text, t->proptext); @@ -841,7 +841,7 @@ void headerResize(TransInfo *t, const float vec[3], char *str, const int str_siz char tvec[NUM_STR_REP_LEN * 3]; size_t ofs = 0; if (hasNumInput(&t->num)) { - outputNumInput(&(t->num), tvec, &t->scene->unit); + outputNumInput(&(t->num), tvec, t->scene->unit); } else { BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", vec[0]); diff --git a/source/blender/editors/transform/transform_mode_baketime.cc b/source/blender/editors/transform/transform_mode_baketime.cc index 72d58b58362..44c513fdf10 100644 --- a/source/blender/editors/transform/transform_mode_baketime.cc +++ b/source/blender/editors/transform/transform_mode_baketime.cc @@ -59,7 +59,7 @@ static void applyBakeTime(TransInfo *t) if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - outputNumInput(&(t->num), c, &t->scene->unit); + outputNumInput(&(t->num), c, t->scene->unit); if (time >= 0.0f) { SNPRINTF(str, IFACE_("Time: +%s %s"), c, t->proptext); diff --git a/source/blender/editors/transform/transform_mode_bbone_resize.cc b/source/blender/editors/transform/transform_mode_bbone_resize.cc index 2eac2750c5b..9ad0bbce7a6 100644 --- a/source/blender/editors/transform/transform_mode_bbone_resize.cc +++ b/source/blender/editors/transform/transform_mode_bbone_resize.cc @@ -35,7 +35,7 @@ static void headerBoneSize(TransInfo *t, const float vec[3], char str[UI_MAX_DRA { char tvec[NUM_STR_REP_LEN * 3]; if (hasNumInput(&t->num)) { - outputNumInput(&(t->num), tvec, &t->scene->unit); + outputNumInput(&(t->num), tvec, t->scene->unit); } else { BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", vec[0]); diff --git a/source/blender/editors/transform/transform_mode_bend.cc b/source/blender/editors/transform/transform_mode_bend.cc index 10fa783cd5f..923ceb0270d 100644 --- a/source/blender/editors/transform/transform_mode_bend.cc +++ b/source/blender/editors/transform/transform_mode_bend.cc @@ -225,7 +225,7 @@ static void Bend(TransInfo *t) if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN * 2]; - outputNumInput(&(t->num), c, &t->scene->unit); + outputNumInput(&(t->num), c, t->scene->unit); SNPRINTF(str, IFACE_("Bend Angle: %s, Radius: %s, Alt: Clamp %s"), diff --git a/source/blender/editors/transform/transform_mode_boneenvelope.cc b/source/blender/editors/transform/transform_mode_boneenvelope.cc index 02ed24540d7..0b245cb7911 100644 --- a/source/blender/editors/transform/transform_mode_boneenvelope.cc +++ b/source/blender/editors/transform/transform_mode_boneenvelope.cc @@ -47,7 +47,7 @@ static void applyBoneEnvelope(TransInfo *t) if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - outputNumInput(&(t->num), c, &t->scene->unit); + outputNumInput(&(t->num), c, t->scene->unit); SNPRINTF(str, IFACE_("Envelope: %s"), c); } else { diff --git a/source/blender/editors/transform/transform_mode_boneroll.cc b/source/blender/editors/transform/transform_mode_boneroll.cc index 554c80a42e6..10787650af3 100644 --- a/source/blender/editors/transform/transform_mode_boneroll.cc +++ b/source/blender/editors/transform/transform_mode_boneroll.cc @@ -48,7 +48,7 @@ static void applyBoneRoll(TransInfo *t) if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - outputNumInput(&(t->num), c, &t->scene->unit); + outputNumInput(&(t->num), c, t->scene->unit); SNPRINTF(str, IFACE_("Roll: %s"), &c[0]); } diff --git a/source/blender/editors/transform/transform_mode_curveshrinkfatten.cc b/source/blender/editors/transform/transform_mode_curveshrinkfatten.cc index 65e88ee5d8b..7cda07aef97 100644 --- a/source/blender/editors/transform/transform_mode_curveshrinkfatten.cc +++ b/source/blender/editors/transform/transform_mode_curveshrinkfatten.cc @@ -48,7 +48,7 @@ static void applyCurveShrinkFatten(TransInfo *t) if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - outputNumInput(&(t->num), c, &t->scene->unit); + outputNumInput(&(t->num), c, t->scene->unit); SNPRINTF(str, IFACE_("Shrink/Fatten: %s"), c); } else { diff --git a/source/blender/editors/transform/transform_mode_customdata.cc b/source/blender/editors/transform/transform_mode_customdata.cc index 2757e46a703..f339a179c87 100644 --- a/source/blender/editors/transform/transform_mode_customdata.cc +++ b/source/blender/editors/transform/transform_mode_customdata.cc @@ -90,7 +90,7 @@ static void apply_value_impl(TransInfo *t, const char *value_name) if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - outputNumInput(&(t->num), c, &t->scene->unit); + outputNumInput(&(t->num), c, t->scene->unit); if (value >= 0.0f) { SNPRINTF(str, "%s: +%s %s", value_name, c, t->proptext); diff --git a/source/blender/editors/transform/transform_mode_edge_seq_slide.cc b/source/blender/editors/transform/transform_mode_edge_seq_slide.cc index 8beb093024c..21b9415d0fd 100644 --- a/source/blender/editors/transform/transform_mode_edge_seq_slide.cc +++ b/source/blender/editors/transform/transform_mode_edge_seq_slide.cc @@ -43,7 +43,7 @@ static void headerSeqSlide(TransInfo *t, const float val[2], char str[UI_MAX_DRA size_t ofs = 0; if (hasNumInput(&t->num)) { - outputNumInput(&(t->num), tvec, &t->scene->unit); + outputNumInput(&(t->num), tvec, t->scene->unit); } else { BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.0f, %.0f", val[0], val[1]); diff --git a/source/blender/editors/transform/transform_mode_edge_slide.cc b/source/blender/editors/transform/transform_mode_edge_slide.cc index af0dac6c00b..544e37208f2 100644 --- a/source/blender/editors/transform/transform_mode_edge_slide.cc +++ b/source/blender/editors/transform/transform_mode_edge_slide.cc @@ -793,7 +793,7 @@ static void applyEdgeSlide(TransInfo *t) ofs += BLI_strncpy_rlen(str + ofs, RPT_("Edge Slide: "), sizeof(str) - ofs); if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - outputNumInput(&(t->num), c, &t->scene->unit); + outputNumInput(&(t->num), c, t->scene->unit); ofs += BLI_strncpy_rlen(str + ofs, &c[0], sizeof(str) - ofs); } else { diff --git a/source/blender/editors/transform/transform_mode_gpopacity.cc b/source/blender/editors/transform/transform_mode_gpopacity.cc index 2c3c8559422..a3eb4dce164 100644 --- a/source/blender/editors/transform/transform_mode_gpopacity.cc +++ b/source/blender/editors/transform/transform_mode_gpopacity.cc @@ -49,7 +49,7 @@ static void applyGPOpacity(TransInfo *t) if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - outputNumInput(&(t->num), c, &t->scene->unit); + outputNumInput(&(t->num), c, t->scene->unit); SNPRINTF(str, IFACE_("Opacity: %s"), c); } else { diff --git a/source/blender/editors/transform/transform_mode_maskshrinkfatten.cc b/source/blender/editors/transform/transform_mode_maskshrinkfatten.cc index 616bfb5d765..9790bbf2f66 100644 --- a/source/blender/editors/transform/transform_mode_maskshrinkfatten.cc +++ b/source/blender/editors/transform/transform_mode_maskshrinkfatten.cc @@ -48,7 +48,7 @@ static void applyMaskShrinkFatten(TransInfo *t) if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - outputNumInput(&(t->num), c, &t->scene->unit); + outputNumInput(&(t->num), c, t->scene->unit); SNPRINTF(str, IFACE_("Feather Shrink/Fatten: %s"), c); } else { diff --git a/source/blender/editors/transform/transform_mode_push_pull.cc b/source/blender/editors/transform/transform_mode_push_pull.cc index b4ee87c5fd2..e4e635a84b6 100644 --- a/source/blender/editors/transform/transform_mode_push_pull.cc +++ b/source/blender/editors/transform/transform_mode_push_pull.cc @@ -121,7 +121,7 @@ static void applyPushPull(TransInfo *t) if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - outputNumInput(&(t->num), c, &t->scene->unit); + outputNumInput(&(t->num), c, t->scene->unit); SNPRINTF(str, IFACE_("Push/Pull: %s%s %s"), c, t->con.text, t->proptext); } diff --git a/source/blender/editors/transform/transform_mode_shear.cc b/source/blender/editors/transform/transform_mode_shear.cc index 16e0506abb6..034ad438abf 100644 --- a/source/blender/editors/transform/transform_mode_shear.cc +++ b/source/blender/editors/transform/transform_mode_shear.cc @@ -304,7 +304,7 @@ static void apply_shear(TransInfo *t) /* Header print for NumInput. */ if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - outputNumInput(&(t->num), c, &t->scene->unit); + outputNumInput(&(t->num), c, t->scene->unit); SNPRINTF(str, IFACE_("Shear: %s %s"), c, t->proptext); } else { diff --git a/source/blender/editors/transform/transform_mode_shrink_fatten.cc b/source/blender/editors/transform/transform_mode_shrink_fatten.cc index 1afd4e12520..af33d9a0643 100644 --- a/source/blender/editors/transform/transform_mode_shrink_fatten.cc +++ b/source/blender/editors/transform/transform_mode_shrink_fatten.cc @@ -95,7 +95,7 @@ static void applyShrinkFatten(TransInfo *t) float distance; int i; fmt::memory_buffer str; - UnitSettings *unit = &t->scene->unit; + const UnitSettings &unit = t->scene->unit; distance = t->values[0] + t->values_modal_offset[0]; @@ -114,7 +114,7 @@ static void applyShrinkFatten(TransInfo *t) } else { /* Default header print. */ - if (unit->system != USER_UNIT_NONE) { + if (unit.system != USER_UNIT_NONE) { char unit_str[64]; BKE_unit_value_as_string_scaled( unit_str, sizeof(unit_str), distance, 4, B_UNIT_LENGTH, unit, true); diff --git a/source/blender/editors/transform/transform_mode_tilt.cc b/source/blender/editors/transform/transform_mode_tilt.cc index 6002108056f..37ef8459285 100644 --- a/source/blender/editors/transform/transform_mode_tilt.cc +++ b/source/blender/editors/transform/transform_mode_tilt.cc @@ -48,7 +48,7 @@ static void applyTilt(TransInfo *t) if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - outputNumInput(&(t->num), c, &t->scene->unit); + outputNumInput(&(t->num), c, t->scene->unit); SNPRINTF(str, "%s %s" BLI_STR_UTF8_DEGREE_SIGN " %s", IFACE_("Tilt:"), &c[0], t->proptext); diff --git a/source/blender/editors/transform/transform_mode_timescale.cc b/source/blender/editors/transform/transform_mode_timescale.cc index e63f13640af..4d740500aec 100644 --- a/source/blender/editors/transform/transform_mode_timescale.cc +++ b/source/blender/editors/transform/transform_mode_timescale.cc @@ -44,7 +44,7 @@ static void headerTimeScale(TransInfo *t, char str[UI_MAX_DRAW_STR]) char tvec[NUM_STR_REP_LEN * 3]; if (hasNumInput(&t->num)) { - outputNumInput(&(t->num), tvec, &t->scene->unit); + outputNumInput(&(t->num), tvec, t->scene->unit); } else { BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", t->values_final[0]); diff --git a/source/blender/editors/transform/transform_mode_timeslide.cc b/source/blender/editors/transform/transform_mode_timeslide.cc index e61417aa556..47300934d97 100644 --- a/source/blender/editors/transform/transform_mode_timeslide.cc +++ b/source/blender/editors/transform/transform_mode_timeslide.cc @@ -38,7 +38,7 @@ static void headerTimeSlide(TransInfo *t, const float sval, char str[UI_MAX_DRAW char tvec[NUM_STR_REP_LEN * 3]; if (hasNumInput(&t->num)) { - outputNumInput(&(t->num), tvec, &t->scene->unit); + outputNumInput(&(t->num), tvec, t->scene->unit); } else { const float *range = static_cast(t->custom.mode.data); diff --git a/source/blender/editors/transform/transform_mode_timetranslate.cc b/source/blender/editors/transform/transform_mode_timetranslate.cc index 2820922237a..9e490d217ef 100644 --- a/source/blender/editors/transform/transform_mode_timetranslate.cc +++ b/source/blender/editors/transform/transform_mode_timetranslate.cc @@ -37,7 +37,7 @@ static void headerTimeTranslate(TransInfo *t, char str[UI_MAX_DRAW_STR]) /* If numeric input is active, use results from that, otherwise apply snapping to result. */ if (hasNumInput(&t->num)) { - outputNumInput(&(t->num), tvec, &t->scene->unit); + outputNumInput(&(t->num), tvec, t->scene->unit); } else { eSnapMode snap_mode = t->tsnap.mode; diff --git a/source/blender/editors/transform/transform_mode_tosphere.cc b/source/blender/editors/transform/transform_mode_tosphere.cc index a104d4e4998..b57dad2d2c4 100644 --- a/source/blender/editors/transform/transform_mode_tosphere.cc +++ b/source/blender/editors/transform/transform_mode_tosphere.cc @@ -193,7 +193,7 @@ static void applyToSphere(TransInfo *t) if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - outputNumInput(&(t->num), c, &t->scene->unit); + outputNumInput(&(t->num), c, t->scene->unit); SNPRINTF(str, IFACE_("To Sphere: %s %s"), c, t->proptext); } diff --git a/source/blender/editors/transform/transform_mode_trackball.cc b/source/blender/editors/transform/transform_mode_trackball.cc index 7550b2e5e38..491d639a8db 100644 --- a/source/blender/editors/transform/transform_mode_trackball.cc +++ b/source/blender/editors/transform/transform_mode_trackball.cc @@ -140,7 +140,7 @@ static void applyTrackball(TransInfo *t) if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN * 2]; - outputNumInput(&(t->num), c, &t->scene->unit); + outputNumInput(&(t->num), c, t->scene->unit); ofs += BLI_snprintf_rlen(str + ofs, sizeof(str) - ofs, diff --git a/source/blender/editors/transform/transform_mode_translate.cc b/source/blender/editors/transform/transform_mode_translate.cc index 8218f9fc801..f5e90fcfadb 100644 --- a/source/blender/editors/transform/transform_mode_translate.cc +++ b/source/blender/editors/transform/transform_mode_translate.cc @@ -188,7 +188,7 @@ static void translate_dist_to_str(char *r_str, const UnitSettings *unit) { if (unit && (unit->system != USER_UNIT_NONE)) { - BKE_unit_value_as_string_scaled(r_str, r_str_maxncpy, val, 4, B_UNIT_LENGTH, unit, false); + BKE_unit_value_as_string_scaled(r_str, r_str_maxncpy, val, 4, B_UNIT_LENGTH, *unit, false); } else { /* Check range to prevent string buffer overflow. */ @@ -209,7 +209,7 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_ } if (hasNumInput(&t->num)) { - outputNumInput(&(t->num), dvec_str[0], &t->scene->unit); + outputNumInput(&(t->num), dvec_str[0], t->scene->unit); dist = len_v3(t->num.val); } else { diff --git a/source/blender/editors/transform/transform_mode_vert_slide.cc b/source/blender/editors/transform/transform_mode_vert_slide.cc index 8ea60def06f..a4c2db33289 100644 --- a/source/blender/editors/transform/transform_mode_vert_slide.cc +++ b/source/blender/editors/transform/transform_mode_vert_slide.cc @@ -507,7 +507,7 @@ static void applyVertSlide(TransInfo *t) ofs += BLI_strncpy_rlen(str + ofs, IFACE_("Vertex Slide: "), sizeof(str) - ofs); if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - outputNumInput(&(t->num), c, &t->scene->unit); + outputNumInput(&(t->num), c, t->scene->unit); ofs += BLI_strncpy_rlen(str + ofs, &c[0], sizeof(str) - ofs); } else { diff --git a/source/blender/editors/util/numinput.cc b/source/blender/editors/util/numinput.cc index def66f16913..df2efe615a4 100644 --- a/source/blender/editors/util/numinput.cc +++ b/source/blender/editors/util/numinput.cc @@ -85,7 +85,7 @@ void initNumInput(NumInput *n) n->str_cur = 0; } -void outputNumInput(NumInput *n, char *str, const UnitSettings *unit_settings) +void outputNumInput(NumInput *n, char *str, const UnitSettings &unit_settings) { short j; const int ln = NUM_STR_REP_LEN; @@ -265,7 +265,7 @@ static bool editstr_insert_at_cursor(NumInput *n, const char *buf, const int buf bool user_string_to_number(bContext *C, const char *str, - const UnitSettings *unit, + const UnitSettings &unit, int type, double *r_value, const bool use_single_line_error, @@ -281,7 +281,7 @@ bool user_string_to_number(bContext *C, char str_unit_convert[256]; STRNCPY(str_unit_convert, str); BKE_unit_replace_string( - str_unit_convert, sizeof(str_unit_convert), str, unit_scale, unit->system, type); + str_unit_convert, sizeof(str_unit_convert), str, unit_scale, unit.system, type); return BPY_run_string_as_number(C, nullptr, str_unit_convert, &err_info, r_value); } @@ -583,7 +583,7 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event) double val; int success = user_string_to_number( - C, n->str, &sce->unit, n->unit_type[idx], &val, false, &error); + C, n->str, sce->unit, n->unit_type[idx], &val, false, &error); if (error) { ReportList *reports = CTX_wm_reports(C); diff --git a/source/blender/windowmanager/intern/wm_operators.cc b/source/blender/windowmanager/intern/wm_operators.cc index 1e491b94bbf..05115467270 100644 --- a/source/blender/windowmanager/intern/wm_operators.cc +++ b/source/blender/windowmanager/intern/wm_operators.cc @@ -2539,7 +2539,7 @@ static void radial_control_update_header(wmOperator *op, bContext *C) if (hasNumInput(&rc->num_input)) { char num_str[NUM_STR_REP_LEN]; - outputNumInput(&rc->num_input, num_str, &scene->unit); + outputNumInput(&rc->num_input, num_str, scene->unit); SNPRINTF(msg, "%s: %s", RNA_property_ui_name(rc->prop), num_str); } else {