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:
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_unit.h3
-rw-r--r--source/blender/blenkernel/intern/unit.c16
2 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_unit.h b/source/blender/blenkernel/BKE_unit.h
index 6b72c01bf0a..91b1702ca82 100644
--- a/source/blender/blenkernel/BKE_unit.h
+++ b/source/blender/blenkernel/BKE_unit.h
@@ -36,6 +36,9 @@ void bUnit_AsString(char *str, double value, int prec, int system, int type, int
/* replace units with values, used before python button evaluation */
int bUnit_ReplaceString(char *str, char *str_orig, char *str_prev, double scale_pref, int system, int type);
+/* the size of the unit used for this value (used for calculating the ckickstep) */
+double bUnit_Size(double value, int system, int type);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index eaa90a87691..5ecc8ddf5b8 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -347,3 +347,19 @@ int bUnit_ReplaceString(char *str, char *str_orig, char *str_prev, double scale_
// printf("replace %s\n", str);
return change;
}
+
+
+double bUnit_Size(double value, int system, int type)
+{
+ bUnitCollection *usys = unit_get_system(system, type);
+ bUnitDef *unit;
+
+ if(usys==NULL)
+ return -1;
+
+ unit= unit_best_fit(value, usys, NULL);
+ if(unit==NULL)
+ return -1;
+
+ return unit->mul;
+}