diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-08-26 14:52:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-08-26 14:53:41 +0400 |
commit | b198500c027231709686ed600cfeff8dde70d8cd (patch) | |
tree | 8f90e2b71b99c777df8b1d6a107f653500561855 /source/blender/blenkernel/intern | |
parent | 3dd5adeed14518ff8b21343d6269732aa36e1cee (diff) |
Move bUnit_getScaleUnit -> BKE_scene_unit_scale
unit.c intentionally doesn't include DNA or BKE headers (except its own)
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 27 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/unit.c | 27 |
2 files changed, 29 insertions, 25 deletions
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 5b5e27d4c53..f912e3d45a6 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -82,6 +82,7 @@ #include "BKE_scene.h" #include "BKE_sequencer.h" #include "BKE_sound.h" +#include "BKE_unit.h" #include "BKE_world.h" #include "RE_engine.h" @@ -1970,3 +1971,29 @@ int BKE_scene_num_threads(const Scene *scene) { return BKE_render_num_threads(&scene->r); } + +/* Apply the needed correction factor to value, based on unit_type (only length-related are affected currently) + * and unit->scale_length. + */ +double BKE_scene_unit_scale(const UnitSettings *unit, const int unit_type, double value) +{ + if (unit->system == USER_UNIT_NONE) { + /* Never apply scale_length when not using a unit setting! */ + return value; + } + + switch (unit_type) { + case B_UNIT_LENGTH: + return value * (double)unit->scale_length; + case B_UNIT_CAMERA: + return value * (double)unit->scale_length; + case B_UNIT_AREA: + return value * pow(unit->scale_length, 2); + case B_UNIT_VOLUME: + return value * pow(unit->scale_length, 3); + case B_UNIT_MASS: + return value * pow(unit->scale_length, 3); + default: + return value; + } +} diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index cdaf72aa191..5a2c77b5619 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -37,12 +37,12 @@ #include "BKE_unit.h" /* own include */ -#include "DNA_scene_types.h" - #ifdef WIN32 # include "BLI_winstuff.h" #endif +/* no BKE or DNA includes! */ + #define TEMP_STR_SIZE 256 #define SEP_CHR '#' @@ -791,29 +791,6 @@ double bUnit_BaseScalar(int system, int type) return unit_default(usys)->scalar; } -double bUnit_getScaleUnit(UnitSettings *unit, const int unit_type, double value) -{ - if (unit->system == USER_UNIT_NONE) { - /* Never apply scale_length when not using a unit setting! */ - return value; - } - - switch (unit_type) { - case B_UNIT_LENGTH: - return value * (double)unit->scale_length; - case B_UNIT_CAMERA: - return value * (double)unit->scale_length; - case B_UNIT_AREA: - return value * pow(unit->scale_length, 2); - case B_UNIT_VOLUME: - return value * pow(unit->scale_length, 3); - case B_UNIT_MASS: - return value * pow(unit->scale_length, 3); - default: - return value; - } -} - /* external access */ bool bUnit_IsValid(int system, int type) { |