diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-09-16 08:19:22 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-09-16 08:19:22 +0400 |
commit | 36c273b1f7c65a759f77c8ed42b65b878dbb09da (patch) | |
tree | 8b75b606f4745c980c21790ff641b38fdb87d9ae /source/blender/blenkernel | |
parent | d6baea457e51c1443d68eb4ca5393e7de9981c02 (diff) |
- bone roll now in degrees not radians.
- rna buttons with units set now use the units base value for snapping.
- bone head/tail radius could be set negative.
matt: removed a check in ui_is_but_unit() which made angle buttons return false, what was this for?
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_unit.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/unit.c | 16 |
2 files changed, 18 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_unit.h b/source/blender/blenkernel/BKE_unit.h index 65bdea8095a..7461d43e721 100644 --- a/source/blender/blenkernel/BKE_unit.h +++ b/source/blender/blenkernel/BKE_unit.h @@ -45,6 +45,9 @@ double bUnit_ClosestScalar(double value, int system, int type); /* base scale for these units */ double bUnit_BaseScalar(int system, int type); +/* return true is the unit system exists */ +int bUnit_IsValid(int system, int type); + /* loop over scales, coudl add names later */ //double bUnit_Iter(void **unit, char **name, int system, int type); @@ -63,6 +66,7 @@ double bUnit_GetScaler(void *usys_pt, int index); #define B_UNIT_TIME 6 #define B_UNIT_VELOCITY 7 #define B_UNIT_ACCELERATION 8 +#define B_UNIT_MAXDEF 9 #ifdef __cplusplus } diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 963cfdbea1b..36a4cfea7a0 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -24,6 +24,8 @@ #include <stdio.h> #include <ctype.h> #include <string.h> +#include "BKE_unit.h" + #ifdef WIN32 #define _USE_MATH_DEFINES #endif @@ -31,6 +33,7 @@ #include "BLI_winstuff.h" + #define TEMP_STR_SIZE 256 #define SEP_CHR '#' @@ -127,7 +130,8 @@ static struct bUnitDef buNaturalRotDef[] = { }; static struct bUnitCollection buNaturalRotCollection = {buNaturalRotDef, 0, 0, sizeof(buNaturalRotDef)/sizeof(bUnitDef)}; -#define UNIT_SYSTEM_MAX 3 +#define UNIT_SYSTEM_TOT (((sizeof(bUnitSystems) / 8) / sizeof(void *)) - 1) + static struct bUnitCollection *bUnitSystems[][8] = { {0,0,0,0,0,&buNaturalRotCollection,&buNaturalTimeCollecton,0}, {0,&buMetricLenCollecton, 0,0,0, &buNaturalRotCollection, &buNaturalTimeCollecton,0}, /* metric */ @@ -135,6 +139,8 @@ static struct bUnitCollection *bUnitSystems[][8] = { {0,0,0,0,0,0,0,0} }; + + /* internal, has some option not exposed */ static bUnitCollection *unit_get_system(int system, int type) { @@ -459,7 +465,7 @@ int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pre bUnitCollection *usys_iter; int system_iter; - for(system_iter= 0; system_iter<UNIT_SYSTEM_MAX; system_iter++) { + for(system_iter= 0; system_iter<UNIT_SYSTEM_TOT; system_iter++) { if (system_iter != system) { usys_iter= unit_get_system(system_iter, type); if (usys_iter) { @@ -610,6 +616,12 @@ double bUnit_BaseScalar(int system, int type) } /* external access */ +int bUnit_IsValid(int system, int type) +{ + return !(type < 0 || type >= B_UNIT_MAXDEF || system < 0 || system > UNIT_SYSTEM_TOT); +} + + void bUnit_GetSystem(void **usys_pt, int *len, int system, int type) { bUnitCollection *usys = unit_get_system(system, type); |