Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2020-09-09 16:41:15 +0300
committerHans Goudey <h.goudey@me.com>2020-09-09 16:41:15 +0300
commit842f52d418aaccae45c8e400eb0a8bddef0dbb51 (patch)
tree800dc6f6db8b2dbf4d2c4c78713e79bdce6d025c
parent6dc7266cf1f4ee4e6e6eaa7e4949fcff11372479 (diff)
Cleanup: Rename public "bUnit" functions
This commit renames the functions in "BKE_unit.h` to be consistent with the naming in the rest of blenkernel. bUnit_AsString -> BKE_unit_value_as_string_adaptive bUnit_AsString2 -> BKE_unit_value_as_string bUnit_ReplaceString -> BKE_unit_replace_string bUnit_ApplyPreferredUnit -> BKE_unit_apply_preferred_unit bUnit_ToUnitAltName -> BKE_unit_name_to_alt bUnit_ClosestScalar -> BKE_unit_closest_scalar bUnit_BaseScalar -> BKE_unit_base_scalar bUnit_IsValid -> BKE_unit_is_valid bUnit_GetSystem -> BKE_unit_system_get bUnit_GetBaseUnit -> BKE_unit_base_get bUnit_GetBaseUnitOfType -> BKE_unit_base_of_type_get bUnit_GetName -> BKE_unit_name_get bUnit_GetNameDisplay -> BKE_unit_display_name_get bUnit_GetIdentifier -> BKE_unit_identifier_get bUnit_GetScaler -> BKE_unit_scalar_get bUnit_IsSuppressed -> BKE_unit_is_suppressed Differential Revision: https://developer.blender.org/D8828
-rw-r--r--source/blender/blenkernel/BKE_unit.h46
-rw-r--r--source/blender/blenkernel/intern/scene.c10
-rw-r--r--source/blender/blenkernel/intern/unit.c50
-rw-r--r--source/blender/blenloader/intern/versioning_280.c6
-rw-r--r--source/blender/draw/intern/draw_manager_text.c29
-rw-r--r--source/blender/editors/interface/interface.c21
-rw-r--r--source/blender/editors/interface/interface_eyedropper_depth.c14
-rw-r--r--source/blender/editors/interface/interface_handlers.c4
-rw-r--r--source/blender/editors/mesh/editmesh_bevel.c14
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c18
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_ruler.c16
-rw-r--r--source/blender/editors/transform/transform_mode_translate.c28
-rw-r--r--source/blender/editors/util/numinput.c40
-rw-r--r--source/blender/makesrna/intern/rna_scene.c12
-rw-r--r--source/blender/python/intern/bpy_utils_units.c9
15 files changed, 160 insertions, 157 deletions
diff --git a/source/blender/blenkernel/BKE_unit.h b/source/blender/blenkernel/BKE_unit.h
index d47cebb5dc8..c4af9ab40e2 100644
--- a/source/blender/blenkernel/BKE_unit.h
+++ b/source/blender/blenkernel/BKE_unit.h
@@ -29,49 +29,49 @@ struct UnitSettings;
/* in all cases the value is assumed to be scaled by the user preference */
/* humanly readable representation of a value in units (used for button drawing) */
-size_t bUnit_AsString(
+size_t BKE_unit_value_as_string_adaptive(
char *str, int len_max, double value, int prec, int system, int type, bool split, bool pad);
-size_t bUnit_AsString2(char *str,
- int len_max,
- double value,
- int prec,
- int type,
- const struct UnitSettings *settings,
- bool pad);
+size_t BKE_unit_value_as_string(char *str,
+ int len_max,
+ double value,
+ int prec,
+ int type,
+ const struct UnitSettings *settings,
+ bool pad);
/* replace units with values, used before python button evaluation */
-bool bUnit_ReplaceString(
+bool BKE_unit_replace_string(
char *str, int len_max, const char *str_prev, double scale_pref, int system, int type);
/* return true if the string contains any valid unit for the given type */
-bool bUnit_ContainsUnit(const char *str, int type);
+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 bUnit_ApplyPreferredUnit(const struct UnitSettings *settings, int type, double value);
+double BKE_unit_apply_preferred_unit(const struct UnitSettings *settings, int type, double value);
/* make string keyboard-friendly: 10µm --> 10um */
-void bUnit_ToUnitAltName(char *str, int len_max, const char *orig_str, int system, int type);
+void BKE_unit_name_to_alt(char *str, int len_max, const char *orig_str, int system, int type);
/* the size of the unit used for this value (used for calculating the ckickstep) */
-double bUnit_ClosestScalar(double value, int system, int type);
+double BKE_unit_closest_scalar(double value, int system, int type);
/* base scale for these units */
-double bUnit_BaseScalar(int system, int type);
+double BKE_unit_base_scalar(int system, int type);
/* return true is the unit system exists */
-bool bUnit_IsValid(int system, int type);
+bool BKE_unit_is_valid(int system, int type);
/* loop over scales, could add names later */
// double bUnit_Iter(void **unit, char **name, int system, int type);
-void bUnit_GetSystem(int system, int type, void const **r_usys_pt, int *r_len);
-int bUnit_GetBaseUnit(const void *usys_pt);
-int bUnit_GetBaseUnitOfType(int system, int type);
-const char *bUnit_GetName(const void *usys_pt, int index);
-const char *bUnit_GetNameDisplay(const void *usys_pt, int index);
-const char *bUnit_GetIdentifier(const void *usys_pt, int index);
-double bUnit_GetScaler(const void *usys_pt, int index);
-bool bUnit_IsSuppressed(const void *usys_pt, int index);
+void BKE_unit_system_get(int system, int type, const void **r_usys_pt, int *r_len);
+int BKE_unit_base_get(const void *usys_pt);
+int BKE_unit_base_of_type_get(int system, int type);
+const char *BKE_unit_name_get(const void *usys_pt, int index);
+const char *BKE_unit_display_name_get(const void *usys_pt, int index);
+const char *BKE_unit_identifier_get(const void *usys_pt, int index);
+double BKE_unit_scalar_get(const void *usys_pt, int index);
+bool BKE_unit_is_suppressed(const void *usys_pt, int index);
/* aligned with PropertyUnit */
enum {
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index a1f74dddbad..34af226ef72 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -154,11 +154,11 @@ static void scene_init_data(ID *id)
scene->unit.system = USER_UNIT_METRIC;
scene->unit.scale_length = 1.0f;
- scene->unit.length_unit = (uchar)bUnit_GetBaseUnitOfType(USER_UNIT_METRIC, B_UNIT_LENGTH);
- scene->unit.mass_unit = (uchar)bUnit_GetBaseUnitOfType(USER_UNIT_METRIC, B_UNIT_MASS);
- scene->unit.time_unit = (uchar)bUnit_GetBaseUnitOfType(USER_UNIT_METRIC, B_UNIT_TIME);
- scene->unit.temperature_unit = (uchar)bUnit_GetBaseUnitOfType(USER_UNIT_METRIC,
- B_UNIT_TEMPERATURE);
+ scene->unit.length_unit = (uchar)BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_LENGTH);
+ scene->unit.mass_unit = (uchar)BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_MASS);
+ scene->unit.time_unit = (uchar)BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_TIME);
+ scene->unit.temperature_unit = (uchar)BKE_unit_base_of_type_get(USER_UNIT_METRIC,
+ B_UNIT_TEMPERATURE);
/* Anti-Aliasing threshold. */
scene->grease_pencil_settings.smaa_threshold = 1.0f;
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index f4a280581f3..bfa031f0d64 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -662,7 +662,7 @@ static size_t unit_as_string_main(char *str,
return unit_as_string(str, len_max, value, prec, usys, main_unit, pad ? ' ' : '\0');
}
-size_t bUnit_AsString(
+size_t BKE_unit_value_as_string_adaptive(
char *str, int len_max, double value, int prec, int system, int type, bool split, bool pad)
{
PreferredUnits units;
@@ -675,13 +675,13 @@ size_t bUnit_AsString(
return unit_as_string_main(str, len_max, value, prec, type, split, pad, units);
}
-size_t bUnit_AsString2(char *str,
- int len_max,
- double value,
- int prec,
- int type,
- const UnitSettings *settings,
- bool pad)
+size_t BKE_unit_value_as_string(char *str,
+ int len_max,
+ double value,
+ int prec,
+ int type,
+ const UnitSettings *settings,
+ bool pad)
{
bool do_split = (settings->flag & USER_UNIT_OPT_SPLIT) != 0;
PreferredUnits units = preferred_units_from_UnitSettings(settings);
@@ -1059,7 +1059,7 @@ static const bUnitDef *unit_detect_from_str(const bUnitCollection *usys,
return unit;
}
-bool bUnit_ContainsUnit(const char *str, int type)
+bool BKE_unit_string_contains_unit(const char *str, int type)
{
for (int system = 0; system < UNIT_SYSTEM_TOT; system++) {
const bUnitCollection *usys = unit_get_system(system, type);
@@ -1076,12 +1076,12 @@ bool bUnit_ContainsUnit(const char *str, int type)
return false;
}
-double bUnit_ApplyPreferredUnit(const struct UnitSettings *settings, int type, double value)
+double BKE_unit_apply_preferred_unit(const struct UnitSettings *settings, int type, double value)
{
PreferredUnits units = preferred_units_from_UnitSettings(settings);
const bUnitDef *unit = get_preferred_display_unit_if_used(type, units);
- const double scalar = (unit == NULL) ? bUnit_BaseScalar(units.system, type) : unit->scalar;
+ const double scalar = (unit == NULL) ? BKE_unit_base_scalar(units.system, type) : unit->scalar;
const double bias = (unit == NULL) ? 0.0 : unit->bias; /* Base unit shouldn't have a bias. */
return value * scalar + bias;
@@ -1103,7 +1103,7 @@ double bUnit_ApplyPreferredUnit(const struct UnitSettings *settings, int type, d
*
* \return True of a change was made.
*/
-bool bUnit_ReplaceString(
+bool BKE_unit_replace_string(
char *str, int len_max, const char *str_prev, double scale_pref, int system, int type)
{
const bUnitCollection *usys = unit_get_system(system, type);
@@ -1133,7 +1133,7 @@ bool bUnit_ReplaceString(
}
else {
/* BLI_snprintf would not fit into str_tmp, cant do much in this case.
- * Check for this because otherwise bUnit_ReplaceString could call its self forever. */
+ * Check for this because otherwise BKE_unit_replace_string could call its self forever. */
return changed;
}
@@ -1194,7 +1194,7 @@ bool bUnit_ReplaceString(
}
/* 45µm --> 45um */
-void bUnit_ToUnitAltName(char *str, int len_max, const char *orig_str, int system, int type)
+void BKE_unit_name_to_alt(char *str, int len_max, const char *orig_str, int system, int type)
{
const bUnitCollection *usys = unit_get_system(system, type);
@@ -1234,7 +1234,7 @@ void bUnit_ToUnitAltName(char *str, int len_max, const char *orig_str, int syste
strncpy(str, orig_str, len_max);
}
-double bUnit_ClosestScalar(double value, int system, int type)
+double BKE_unit_closest_scalar(double value, int system, int type)
{
const bUnitCollection *usys = unit_get_system(system, type);
@@ -1250,7 +1250,7 @@ double bUnit_ClosestScalar(double value, int system, int type)
return unit->scalar;
}
-double bUnit_BaseScalar(int system, int type)
+double BKE_unit_base_scalar(int system, int type)
{
const bUnitCollection *usys = unit_get_system(system, type);
if (usys) {
@@ -1260,12 +1260,12 @@ double bUnit_BaseScalar(int system, int type)
return 1.0;
}
-bool bUnit_IsValid(int system, int type)
+bool BKE_unit_is_valid(int system, int type)
{
return !(system < 0 || system > UNIT_SYSTEM_TOT || type < 0 || type > B_UNIT_TYPE_TOT);
}
-void bUnit_GetSystem(int system, int type, void const **r_usys_pt, int *r_len)
+void BKE_unit_system_get(int system, int type, void const **r_usys_pt, int *r_len)
{
const bUnitCollection *usys = unit_get_system(system, type);
*r_usys_pt = usys;
@@ -1278,25 +1278,25 @@ void bUnit_GetSystem(int system, int type, void const **r_usys_pt, int *r_len)
*r_len = usys->length;
}
-int bUnit_GetBaseUnit(const void *usys_pt)
+int BKE_unit_base_get(const void *usys_pt)
{
return ((bUnitCollection *)usys_pt)->base_unit;
}
-int bUnit_GetBaseUnitOfType(int system, int type)
+int BKE_unit_base_of_type_get(int system, int type)
{
return unit_get_system(system, type)->base_unit;
}
-const char *bUnit_GetName(const void *usys_pt, int index)
+const char *BKE_unit_name_get(const void *usys_pt, int index)
{
return ((bUnitCollection *)usys_pt)->units[index].name;
}
-const char *bUnit_GetNameDisplay(const void *usys_pt, int index)
+const char *BKE_unit_display_name_get(const void *usys_pt, int index)
{
return ((bUnitCollection *)usys_pt)->units[index].name_display;
}
-const char *bUnit_GetIdentifier(const void *usys_pt, int index)
+const char *BKE_unit_identifier_get(const void *usys_pt, int index)
{
const bUnitDef *unit = ((const bUnitCollection *)usys_pt)->units + index;
if (unit->identifier == NULL) {
@@ -1305,12 +1305,12 @@ const char *bUnit_GetIdentifier(const void *usys_pt, int index)
return unit->identifier;
}
-double bUnit_GetScaler(const void *usys_pt, int index)
+double BKE_unit_scalar_get(const void *usys_pt, int index)
{
return ((bUnitCollection *)usys_pt)->units[index].scalar;
}
-bool bUnit_IsSuppressed(const void *usys_pt, int index)
+bool BKE_unit_is_suppressed(const void *usys_pt, int index)
{
return (((bUnitCollection *)usys_pt)->units[index].flag & B_UNIT_DEF_SUPPRESS) != 0;
}
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index e07ee7ee2b9..213fbe0bde0 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -2975,10 +2975,10 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
UnitSettings *unit = &scene->unit;
if (unit->system != USER_UNIT_NONE) {
- unit->length_unit = bUnit_GetBaseUnitOfType(scene->unit.system, B_UNIT_LENGTH);
- unit->mass_unit = bUnit_GetBaseUnitOfType(scene->unit.system, B_UNIT_MASS);
+ unit->length_unit = BKE_unit_base_of_type_get(scene->unit.system, B_UNIT_LENGTH);
+ unit->mass_unit = BKE_unit_base_of_type_get(scene->unit.system, B_UNIT_MASS);
}
- unit->time_unit = bUnit_GetBaseUnitOfType(USER_UNIT_NONE, B_UNIT_TIME);
+ unit->time_unit = BKE_unit_base_of_type_get(USER_UNIT_NONE, B_UNIT_TIME);
}
/* gpencil grid settings */
diff --git a/source/blender/draw/intern/draw_manager_text.c b/source/blender/draw/intern/draw_manager_text.c
index b3c4c97715e..adcac15ab85 100644
--- a/source/blender/draw/intern/draw_manager_text.c
+++ b/source/blender/draw/intern/draw_manager_text.c
@@ -298,13 +298,13 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region,
}
if (unit->system) {
- numstr_len = bUnit_AsString2(numstr,
- sizeof(numstr),
- len_v3v3(v1, v2) * unit->scale_length,
- 3,
- B_UNIT_LENGTH,
- unit,
- false);
+ numstr_len = BKE_unit_value_as_string(numstr,
+ sizeof(numstr),
+ len_v3v3(v1, v2) * unit->scale_length,
+ 3,
+ B_UNIT_LENGTH,
+ unit,
+ false);
}
else {
numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), conv_float, len_v3v3(v1, v2));
@@ -440,13 +440,14 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region,
mul_m4_v3(ob->obmat, vmid);
if (unit->system) {
- numstr_len = bUnit_AsString2(numstr,
- sizeof(numstr),
- (double)(area * unit->scale_length * unit->scale_length),
- 3,
- B_UNIT_AREA,
- unit,
- false);
+ numstr_len = BKE_unit_value_as_string(
+ numstr,
+ sizeof(numstr),
+ (double)(area * unit->scale_length * unit->scale_length),
+ 3,
+ B_UNIT_AREA,
+ unit,
+ false);
}
else {
numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), conv_float, area);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index ce9db09e340..0bd4934dd0f 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -2571,7 +2571,7 @@ void ui_but_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen)
orig_str = BLI_strdup(str);
- bUnit_ToUnitAltName(str, maxlen, orig_str, unit->system, RNA_SUBTYPE_UNIT_VALUE(unit_type));
+ BKE_unit_name_to_alt(str, maxlen, orig_str, unit->system, RNA_SUBTYPE_UNIT_VALUE(unit_type));
MEM_freeN(orig_str);
}
@@ -2606,13 +2606,13 @@ static void ui_get_but_string_unit(
precision = float_precision;
}
- bUnit_AsString2(str,
- len_max,
- ui_get_but_scale_unit(but, value),
- precision,
- RNA_SUBTYPE_UNIT_VALUE(unit_type),
- unit,
- pad);
+ BKE_unit_value_as_string(str,
+ len_max,
+ ui_get_but_scale_unit(but, value),
+ precision,
+ RNA_SUBTYPE_UNIT_VALUE(unit_type),
+ unit,
+ pad);
}
static float ui_get_but_step_unit(uiBut *but, float step_default)
@@ -2622,12 +2622,13 @@ static float ui_get_but_step_unit(uiBut *but, float step_default)
/* Scaling up 'step_origg ' here is a bit arbitrary,
* its just giving better scales from user POV */
const double scale_step = ui_get_but_scale_unit(but, step_orig * 10);
- const double step = bUnit_ClosestScalar(scale_step, but->block->unit->system, unit_type);
+ const double step = BKE_unit_closest_scalar(scale_step, but->block->unit->system, unit_type);
/* -1 is an error value */
if (step != -1.0) {
const double scale_unit = ui_get_but_scale_unit(but, 1.0);
- const double step_unit = bUnit_ClosestScalar(scale_unit, but->block->unit->system, unit_type);
+ const double step_unit = BKE_unit_closest_scalar(
+ scale_unit, but->block->unit->system, unit_type);
double step_final;
BLI_assert(step > 0.0);
diff --git a/source/blender/editors/interface/interface_eyedropper_depth.c b/source/blender/editors/interface/interface_eyedropper_depth.c
index fbc0ed1fc1f..ead65a62226 100644
--- a/source/blender/editors/interface/interface_eyedropper_depth.c
+++ b/source/blender/editors/interface/interface_eyedropper_depth.c
@@ -193,13 +193,13 @@ static void depthdropper_depth_sample_pt(
*r_depth = len_v3v3(view_co, co_align);
- bUnit_AsString2(ddr->name,
- sizeof(ddr->name),
- (double)*r_depth,
- 4,
- B_UNIT_LENGTH,
- &scene->unit,
- false);
+ BKE_unit_value_as_string(ddr->name,
+ sizeof(ddr->name),
+ (double)*r_depth,
+ 4,
+ B_UNIT_LENGTH,
+ &scene->unit,
+ false);
}
else {
BLI_strncpy(ddr->name, "Nothing under cursor", sizeof(ddr->name));
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index a4042ab8265..6a6914daf47 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -4614,8 +4614,8 @@ static float ui_numedit_apply_snapf(
UnitSettings *unit = but->block->unit;
const int unit_type = RNA_SUBTYPE_UNIT_VALUE(UI_but_unit_type_get(but));
- if (bUnit_IsValid(unit->system, unit_type)) {
- fac = (float)bUnit_BaseScalar(unit->system, unit_type);
+ if (BKE_unit_is_valid(unit->system, unit_type)) {
+ fac = (float)BKE_unit_base_scalar(unit->system, unit_type);
if (ELEM(unit_type, B_UNIT_LENGTH, B_UNIT_AREA, B_UNIT_VOLUME)) {
fac /= unit->scale_length;
}
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
index dd4b8146154..a90d6530453 100644
--- a/source/blender/editors/mesh/editmesh_bevel.c
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -158,13 +158,13 @@ static void edbm_bevel_update_status_text(bContext *C, wmOperator *op)
}
else {
double offset_val = (double)RNA_float_get(op->ptr, "offset");
- bUnit_AsString2(offset_str,
- NUM_STR_REP_LEN,
- offset_val * sce->unit.scale_length,
- 3,
- B_UNIT_LENGTH,
- &sce->unit,
- true);
+ BKE_unit_value_as_string(offset_str,
+ NUM_STR_REP_LEN,
+ offset_val * sce->unit.scale_length,
+ 3,
+ B_UNIT_LENGTH,
+ &sce->unit,
+ true);
}
prop = RNA_struct_find_property(op->ptr, "offset_type");
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 6cd940244b4..da44815b31a 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -879,14 +879,14 @@ float ED_scene_grid_scale(const Scene *scene, const char **r_grid_unit)
const void *usys;
int len;
- bUnit_GetSystem(scene->unit.system, B_UNIT_LENGTH, &usys, &len);
+ BKE_unit_system_get(scene->unit.system, B_UNIT_LENGTH, &usys, &len);
if (usys) {
- int i = bUnit_GetBaseUnit(usys);
+ int i = BKE_unit_base_get(usys);
if (r_grid_unit) {
- *r_grid_unit = bUnit_GetNameDisplay(usys, i);
+ *r_grid_unit = BKE_unit_display_name_get(usys, i);
}
- return (float)bUnit_GetScaler(usys, i) / scene->unit.scale_length;
+ return (float)BKE_unit_scalar_get(usys, i) / scene->unit.scale_length;
}
}
@@ -906,20 +906,20 @@ void ED_view3d_grid_steps(const Scene *scene,
{
const void *usys;
int i, len;
- bUnit_GetSystem(scene->unit.system, B_UNIT_LENGTH, &usys, &len);
+ BKE_unit_system_get(scene->unit.system, B_UNIT_LENGTH, &usys, &len);
float grid_scale = v3d->grid;
BLI_assert(STEPS_LEN >= len);
if (usys) {
if (rv3d->view == RV3D_VIEW_USER) {
/* Skip steps */
- len = bUnit_GetBaseUnit(usys) + 1;
+ len = BKE_unit_base_get(usys) + 1;
}
grid_scale /= scene->unit.scale_length;
for (i = 0; i < len; i++) {
- r_grid_steps[i] = (float)bUnit_GetScaler(usys, len - 1 - i) * grid_scale;
+ r_grid_steps[i] = (float)BKE_unit_scalar_get(usys, len - 1 - i) * grid_scale;
}
for (; i < STEPS_LEN; i++) {
/* Fill last slots */
@@ -971,10 +971,10 @@ float ED_view3d_grid_view_scale(Scene *scene,
if (r_grid_unit) {
const void *usys;
int len;
- bUnit_GetSystem(scene->unit.system, B_UNIT_LENGTH, &usys, &len);
+ BKE_unit_system_get(scene->unit.system, B_UNIT_LENGTH, &usys, &len);
if (usys) {
- *r_grid_unit = bUnit_GetNameDisplay(usys, len - i - 1);
+ *r_grid_unit = BKE_unit_display_name_get(usys, len - i - 1);
}
}
}
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
index 5aba1fecc53..990b7952e39 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
@@ -179,7 +179,7 @@ static void ruler_item_as_string(
BLI_snprintf(numstr, numstr_size, "%.*f°", prec, RAD2DEGF(ruler_angle));
}
else {
- bUnit_AsString2(
+ BKE_unit_value_as_string(
numstr, numstr_size, (double)ruler_angle, prec, B_UNIT_ROTATION, unit, false);
}
}
@@ -190,13 +190,13 @@ static void ruler_item_as_string(
BLI_snprintf(numstr, numstr_size, "%.*f", prec, ruler_len);
}
else {
- bUnit_AsString2(numstr,
- numstr_size,
- (double)(ruler_len * unit->scale_length),
- prec,
- B_UNIT_LENGTH,
- unit,
- false);
+ BKE_unit_value_as_string(numstr,
+ numstr_size,
+ (double)(ruler_len * unit->scale_length),
+ prec,
+ B_UNIT_LENGTH,
+ unit,
+ false);
}
}
}
diff --git a/source/blender/editors/transform/transform_mode_translate.c b/source/blender/editors/transform/transform_mode_translate.c
index 36be26049d3..866b9d921c8 100644
--- a/source/blender/editors/transform/transform_mode_translate.c
+++ b/source/blender/editors/transform/transform_mode_translate.c
@@ -89,13 +89,13 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_
dist = len_v3(vec);
if (!(t->flag & T_2D_EDIT) && t->scene->unit.system) {
for (int i = 0; i < 3; i++) {
- bUnit_AsString2(&tvec[NUM_STR_REP_LEN * i],
- NUM_STR_REP_LEN,
- dvec[i] * t->scene->unit.scale_length,
- 4,
- B_UNIT_LENGTH,
- &t->scene->unit,
- true);
+ BKE_unit_value_as_string(&tvec[NUM_STR_REP_LEN * i],
+ NUM_STR_REP_LEN,
+ dvec[i] * t->scene->unit.scale_length,
+ 4,
+ B_UNIT_LENGTH,
+ &t->scene->unit,
+ true);
}
}
else {
@@ -106,13 +106,13 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_
}
if (!(t->flag & T_2D_EDIT) && t->scene->unit.system) {
- bUnit_AsString2(distvec,
- sizeof(distvec),
- dist * t->scene->unit.scale_length,
- 4,
- B_UNIT_LENGTH,
- &t->scene->unit,
- false);
+ BKE_unit_value_as_string(distvec,
+ sizeof(distvec),
+ dist * t->scene->unit.scale_length,
+ 4,
+ B_UNIT_LENGTH,
+ &t->scene->unit,
+ false);
}
else if (dist > 1e10f || dist < -1e10f) {
/* prevent string buffer overflow */
diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c
index f8e3dda0ed3..ba22bcca0e1 100644
--- a/source/blender/editors/util/numinput.c
+++ b/source/blender/editors/util/numinput.c
@@ -136,14 +136,14 @@ void outputNumInput(NumInput *n, char *str, UnitSettings *unit_settings)
BLI_strncpy(val, "Invalid", sizeof(val));
}
else {
- bUnit_AsString(val,
- sizeof(val),
- (double)(n->val[i] * fac),
- prec,
- n->unit_sys,
- n->unit_type[i],
- true,
- false);
+ BKE_unit_value_as_string_adaptive(val,
+ sizeof(val),
+ (double)(n->val[i] * fac),
+ prec,
+ n->unit_sys,
+ n->unit_type[i],
+ true,
+ false);
}
/* +1 because of trailing '\0' */
@@ -165,7 +165,7 @@ void outputNumInput(NumInput *n, char *str, UnitSettings *unit_settings)
}
else {
char tstr[NUM_STR_REP_LEN];
- bUnit_AsString(
+ BKE_unit_value_as_string_adaptive(
tstr, ln, (double)n->val[i], prec, n->unit_sys, n->unit_type[i], true, false);
BLI_snprintf(&str[j * ln], ln, "%s%s%s", cur, tstr, cur);
}
@@ -252,14 +252,14 @@ bool applyNumInput(NumInput *n, float *vec)
static void value_to_editstr(NumInput *n, int idx)
{
const int prec = 6; /* editing, higher precision needed. */
- n->str_cur = bUnit_AsString(n->str,
- NUM_STR_REP_LEN,
- (double)n->val[idx],
- prec,
- n->unit_sys,
- n->unit_type[idx],
- true,
- false);
+ n->str_cur = BKE_unit_value_as_string_adaptive(n->str,
+ NUM_STR_REP_LEN,
+ (double)n->val[idx],
+ prec,
+ n->unit_sys,
+ n->unit_type[idx],
+ true,
+ false);
}
static bool editstr_insert_at_cursor(NumInput *n, const char *buf, const int buf_len)
@@ -288,17 +288,17 @@ bool user_string_to_number(bContext *C,
{
#ifdef WITH_PYTHON
double unit_scale = BKE_scene_unit_scale(unit, type, 1.0);
- if (bUnit_ContainsUnit(str, type)) {
+ if (BKE_unit_string_contains_unit(str, type)) {
char str_unit_convert[256];
BLI_strncpy(str_unit_convert, str, sizeof(str_unit_convert));
- bUnit_ReplaceString(
+ BKE_unit_replace_string(
str_unit_convert, sizeof(str_unit_convert), str, unit_scale, unit->system, type);
return BPY_run_string_as_number(C, NULL, str_unit_convert, error_prefix, r_value);
}
int success = BPY_run_string_as_number(C, NULL, str, error_prefix, r_value);
- *r_value = bUnit_ApplyPreferredUnit(unit, type, *r_value);
+ *r_value = BKE_unit_apply_preferred_unit(unit, type, *r_value);
*r_value /= unit_scale;
return success;
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index ebec5e3bff8..bf97e4fcc0f 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2514,7 +2514,7 @@ static const EnumPropertyItem *rna_UnitSettings_itemf_wrapper(const int system,
{
const void *usys;
int len;
- bUnit_GetSystem(system, type, &usys, &len);
+ BKE_unit_system_get(system, type, &usys, &len);
EnumPropertyItem *items = NULL;
int totitem = 0;
@@ -2526,10 +2526,10 @@ static const EnumPropertyItem *rna_UnitSettings_itemf_wrapper(const int system,
RNA_enum_item_add(&items, &totitem, &adaptive);
for (int i = 0; i < len; i++) {
- if (!bUnit_IsSuppressed(usys, i)) {
+ if (!BKE_unit_is_suppressed(usys, i)) {
EnumPropertyItem tmp = {0};
- tmp.identifier = bUnit_GetIdentifier(usys, i);
- tmp.name = bUnit_GetNameDisplay(usys, i);
+ tmp.identifier = BKE_unit_identifier_get(usys, i);
+ tmp.name = BKE_unit_display_name_get(usys, i);
tmp.value = i;
RNA_enum_item_add(&items, &totitem, &tmp);
}
@@ -2587,8 +2587,8 @@ static void rna_UnitSettings_system_update(Main *UNUSED(bmain),
unit->mass_unit = USER_UNIT_ADAPTIVE;
}
else {
- unit->length_unit = bUnit_GetBaseUnitOfType(unit->system, B_UNIT_LENGTH);
- unit->mass_unit = bUnit_GetBaseUnitOfType(unit->system, B_UNIT_MASS);
+ unit->length_unit = BKE_unit_base_of_type_get(unit->system, B_UNIT_LENGTH);
+ unit->mass_unit = BKE_unit_base_of_type_get(unit->system, B_UNIT_MASS);
}
}
diff --git a/source/blender/python/intern/bpy_utils_units.c b/source/blender/python/intern/bpy_utils_units.c
index 4433f5d0f88..a58e2bcb975 100644
--- a/source/blender/python/intern/bpy_utils_units.c
+++ b/source/blender/python/intern/bpy_utils_units.c
@@ -134,7 +134,7 @@ static bool bpyunits_validate(const char *usys_str, const char *ucat_str, int *r
return false;
}
- if (!bUnit_IsValid(*r_usys, *r_ucat)) {
+ if (!BKE_unit_is_valid(*r_usys, *r_ucat)) {
PyErr_Format(PyExc_ValueError,
"%.200s / %.200s unit system/category combination is not valid.",
usys_str,
@@ -197,7 +197,7 @@ static PyObject *bpyunits_to_value(PyObject *UNUSED(self), PyObject *args, PyObj
str = PyMem_MALLOC(sizeof(*str) * (size_t)str_len);
BLI_strncpy(str, inpt, (size_t)str_len);
- bUnit_ReplaceString(str, (int)str_len, uref, scale, usys, ucat);
+ BKE_unit_replace_string(str, (int)str_len, uref, scale, usys, ucat);
if (!PyC_RunString_AsNumber(NULL, str, "<bpy_units_api>", &result)) {
if (PyErr_Occurred()) {
@@ -291,10 +291,11 @@ static PyObject *bpyunits_to_string(PyObject *UNUSED(self), PyObject *args, PyOb
char buf1[64], buf2[64], *str;
PyObject *result;
- bUnit_AsString(buf1, sizeof(buf1), value, precision, usys, ucat, (bool)split_unit, false);
+ BKE_unit_value_as_string_adaptive(
+ buf1, sizeof(buf1), value, precision, usys, ucat, (bool)split_unit, false);
if (compatible_unit) {
- bUnit_ToUnitAltName(buf2, sizeof(buf2), buf1, usys, ucat);
+ BKE_unit_name_to_alt(buf2, sizeof(buf2), buf1, usys, ucat);
str = buf2;
}
else {