forked from bartvdbraak/blender
Fix some loss of precision in BKE's unit code.
When converting text to value, units' "value" had only 6 digits of precision, leading to annoying loss of precision esp. when mixing big and small units (like e.g. miles and inches).
This commit is contained in:
parent
94b574ee02
commit
fa257adf96
@ -61,17 +61,19 @@ const char *bUnit_GetNameDisplay(void *usys_pt, int index);
|
|||||||
double bUnit_GetScaler(void *usys_pt, int index);
|
double bUnit_GetScaler(void *usys_pt, int index);
|
||||||
|
|
||||||
/* aligned with PropertyUnit */
|
/* aligned with PropertyUnit */
|
||||||
#define B_UNIT_NONE 0
|
enum {
|
||||||
#define B_UNIT_LENGTH 1
|
B_UNIT_NONE = 0,
|
||||||
#define B_UNIT_AREA 2
|
B_UNIT_LENGTH = 1,
|
||||||
#define B_UNIT_VOLUME 3
|
B_UNIT_AREA = 2,
|
||||||
#define B_UNIT_MASS 4
|
B_UNIT_VOLUME = 3,
|
||||||
#define B_UNIT_ROTATION 5
|
B_UNIT_MASS = 4,
|
||||||
#define B_UNIT_TIME 6
|
B_UNIT_ROTATION = 5,
|
||||||
#define B_UNIT_VELOCITY 7
|
B_UNIT_TIME = 6,
|
||||||
#define B_UNIT_ACCELERATION 8
|
B_UNIT_VELOCITY = 7,
|
||||||
#define B_UNIT_CAMERA 9
|
B_UNIT_ACCELERATION = 8,
|
||||||
#define B_UNIT_TYPE_TOT 10
|
B_UNIT_CAMERA = 9,
|
||||||
|
B_UNIT_TYPE_TOT = 10,
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -536,7 +536,7 @@ static int unit_scale_str(char *str, int len_max, char *str_tmp, double scale_pr
|
|||||||
|
|
||||||
len_name = strlen(replace_str);
|
len_name = strlen(replace_str);
|
||||||
len_move = (len - (found_ofs + len_name)) + 1; /* 1+ to copy the string terminator */
|
len_move = (len - (found_ofs + len_name)) + 1; /* 1+ to copy the string terminator */
|
||||||
len_num = BLI_snprintf(str_tmp, TEMP_STR_SIZE, "*%g"SEP_STR, unit->scalar / scale_pref); /* # removed later */
|
len_num = BLI_snprintf(str_tmp, TEMP_STR_SIZE, "*%.9g"SEP_STR, unit->scalar / scale_pref); /* # removed later */
|
||||||
|
|
||||||
if (len_num > len_max)
|
if (len_num > len_max)
|
||||||
len_num = len_max;
|
len_num = len_max;
|
||||||
@ -598,7 +598,7 @@ static int unit_find(const char *str, bUnitDef *unit)
|
|||||||
* ...will be resolved by python.
|
* ...will be resolved by python.
|
||||||
*
|
*
|
||||||
* values will be split by a comma's
|
* values will be split by a comma's
|
||||||
* 5'2" -> 5'0.0254, 2*0.3048
|
* 5'2" -> 5*0.3048, 2*0.0254
|
||||||
*
|
*
|
||||||
* str_prev is optional, when valid it is used to get a base unit when none is set.
|
* str_prev is optional, when valid it is used to get a base unit when none is set.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user