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:
authorBastien Montagne <montagne29@wanadoo.fr>2014-08-26 14:04:24 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2014-08-26 14:31:08 +0400
commit0e3fa0b7618fa86e97c5f46ae7208c082fd26eb7 (patch)
tree447fcae65fe6bf4086a79e03a82abb7a4138897b /source/blender/blenkernel/BKE_unit.h
parent600248783b50ddef9b809b0d4c7abd9a9b20fda3 (diff)
Fix T41590: When scene scale is not 1.0, and units are "None," Blender assumes translations are in meters.
Turned out there were several issues in handling of scale parameter by numinput. Fixed that by factorizing more some code in common with 'usual' numbuttons eval code (new `bUnit_getScaleUnit()` helper will return valid scaled value, depending on given system and type). Now, numinput behaves as expected - using default unit amended by scale in case no unit is given (i.e. entering '20' with a scale of 0.01 will give you 20cm, and '20cm' as well!).
Diffstat (limited to 'source/blender/blenkernel/BKE_unit.h')
-rw-r--r--source/blender/blenkernel/BKE_unit.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_unit.h b/source/blender/blenkernel/BKE_unit.h
index b351bc6fe3e..c7847947d33 100644
--- a/source/blender/blenkernel/BKE_unit.h
+++ b/source/blender/blenkernel/BKE_unit.h
@@ -31,6 +31,8 @@
extern "C" {
#endif
+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) */
@@ -39,6 +41,11 @@ size_t bUnit_AsString(char *str, int len_max, double value, int prec, int syste
/* replace units with values, used before python button evaluation */
bool bUnit_ReplaceString(char *str, int len_max, const char *str_prev, double scale_pref, 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 bUnit_getScaleUnit(struct UnitSettings *unit, const int unit_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);