Commit: b198500c027231709686ed600cfeff8dde70d8cd
Author: Campbell Barton
Date:   Tue Aug 26 20:52:07 2014 +1000
Branches: master
https://developer.blender.org/rBb198500c027231709686ed600cfeff8dde70d8cd

Move bUnit_getScaleUnit -> BKE_scene_unit_scale

unit.c intentionally doesn't include DNA or BKE headers (except its own)

===================================================================

M       source/blender/blenkernel/BKE_scene.h
M       source/blender/blenkernel/BKE_unit.h
M       source/blender/blenkernel/intern/scene.c
M       source/blender/blenkernel/intern/unit.c
M       source/blender/editors/interface/interface.c
M       source/blender/editors/util/numinput.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_scene.h 
b/source/blender/blenkernel/BKE_scene.h
index 452e23b..dd46ffa 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -48,6 +48,7 @@ struct RenderData;
 struct SceneRenderLayer;
 struct Scene;
 struct Text;
+struct UnitSettings;
 struct Main;
 
 #define SCE_COPY_NEW        0
@@ -138,6 +139,8 @@ bool BKE_scene_check_rigidbody_active(const struct Scene 
*scene);
 int BKE_scene_num_threads(const struct Scene *scene);
 int BKE_render_num_threads(const struct RenderData *r);
 
+double BKE_scene_unit_scale(const struct UnitSettings *unit, const int 
unit_type, double value);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/blenkernel/BKE_unit.h 
b/source/blender/blenkernel/BKE_unit.h
index c784794..b351bc6 100644
--- a/source/blender/blenkernel/BKE_unit.h
+++ b/source/blender/blenkernel/BKE_unit.h
@@ -31,8 +31,6 @@
 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) */
@@ -41,11 +39,6 @@ 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);
 
diff --git a/source/blender/blenkernel/intern/scene.c 
b/source/blender/blenkernel/intern/scene.c
index 5b5e27d..f912e3d 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 cdaf72a..5a2c77b 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)
 {
diff --git a/source/blender/editors/interface/interface.c 
b/source/blender/editors/interface/interface.c
index 698d3f0..6981f90 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -51,6 +51,7 @@
 
 #include "BKE_context.h"
 #include "BKE_unit.h"
+#include "BKE_scene.h"
 #include "BKE_screen.h"
 #include "BKE_idprop.h"
 
@@ -1942,13 +1943,13 @@ static double ui_get_but_scale_unit(uiBut *but, double 
value)
        UnitSettings *unit = but->block->unit;
        int unit_type = uiButGetUnitType(but);
 
-       /* Time unit is a bit special, not handled by bUnit_getScaleUnit() for 
now. */
+       /* Time unit is a bit special, not handled by BKE_scene_unit_scale() 
for now. */
        if (unit_type == PROP_UNIT_TIME) { /* WARNING - using evil_C :| */
                Scene *scene = CTX_data_scene(but->block->evil_C);
                return FRA2TIME(value);
        }
        else {
-               return bUnit_getScaleUnit(unit, 
RNA_SUBTYPE_UNIT_VALUE(unit_type), value);
+               return BKE_scene_unit_scale(unit, 
RNA_SUBTYPE_UNIT_VALUE(unit_type), value);
        }
 }
 
diff --git a/source/blender/editors/util/numinput.c 
b/source/blender/editors/util/numinput.c
index 4e8f6df..a154f12 100644
--- a/source/blender/editors/util/numinput.c
+++ b/source/blender/editors/util/numinput.c
@@ -33,6 +33,7 @@
 #include "BLI_string_cursor_utf8.h"
 
 #include "BKE_context.h"
+#include "BKE_scene.h"
 #include "BKE_unit.h"
 
 #include "DNA_scene_types.h"
@@ -98,7 +99,7 @@ void outputNumInput(NumInput *n, char *str, UnitSettings 
*unit_settings)
                const short i = (n->flag & NUM_AFFECT_ALL && n->idx != j && 
!(n->val_flag[j] & NUM_EDITED)) ? 0 : j;
 
                /* Use scale_length if needed! */
-               const float fac = (float)bUnit_getScaleUnit(unit_settings, 
n->unit_type[j], 1.0);
+               const float fac = (float)BKE_scene_unit_scale(unit_settings, 
n->unit_type[j], 1.0);
 
                if (n->val_flag[i] & NUM_EDITED) {
                        /* Get the best precision, allows us to draw '10.0001' 
as '10' instead! */
@@ -482,7 +483,7 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent 
*event)
                const char *default_unit = NULL;
 
                /* Use scale_length if needed! */
-               const float fac = (float)bUnit_getScaleUnit(&sce->unit, 
n->unit_type[idx], 1.0);
+               const float fac = (float)BKE_scene_unit_scale(&sce->unit, 
n->unit_type[idx], 1.0);
 
                /* Make radian default unit when needed. */
                if (n->unit_use_radians && n->unit_type[idx] == B_UNIT_ROTATION)

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to