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:
authorMatt Ebb <matt@mke3.net>2010-01-25 09:24:05 +0300
committerMatt Ebb <matt@mke3.net>2010-01-25 09:24:05 +0300
commit0c5998e7998cba70d1dceacc5ed8109a5bba9e23 (patch)
treef9e250055d9de1647b283e7c493902bc51f0a9a5 /source/blender/editors/interface/interface.c
parentc94f385fce14fa5beb8637590ad4d4662cd733c6 (diff)
Radians -> Degrees (in UI)
Rotations are now stored internally as radians, while exposing degrees in the UI - in the graph editor and UI controls. This is done in two areas: 1) Using the unit system to convert RNA data to display as degrees in the UI controls 2) FCurves now use degrees for rotation, so you can edit in the graph editor what you see in the UI. All rotation data is consistently accessible in DNA and RNA as radians, degrees are only used for the UI controls and graph editor. This commit includes conversions will convert old files (stored data and also fcurve data) to the new units, hopefully everything should go smoothly! Part of this also changes a few properties that were hard-coded as degrees before (such as IK pole angle and brush texture rotation) to also use the same consistent system of radians (dna/rna) and degrees (ui). Thanks to Joshua for hints and review here too.
Diffstat (limited to 'source/blender/editors/interface/interface.c')
-rw-r--r--source/blender/editors/interface/interface.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 8b59ff604b9..82b53840ed3 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1225,13 +1225,19 @@ int ui_is_but_float(uiBut *but)
int ui_is_but_unit(uiBut *but)
{
Scene *scene= CTX_data_scene((bContext *)but->block->evil_C);
- if(scene->unit.system == USER_UNIT_NONE)
- return 0;
-
+ int unit_type;
+
if(but->rnaprop==NULL)
return 0;
+
+ unit_type = RNA_SUBTYPE_UNIT(RNA_property_subtype(but->rnaprop));
+
+ if(scene->unit.system == USER_UNIT_NONE) {
+ if (unit_type != PROP_UNIT_ROTATION)
+ return 0;
+ }
- if(RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop))==0)
+ if(unit_type == PROP_UNIT_NONE)
return 0;
return 1;
@@ -1406,12 +1412,12 @@ int ui_get_but_string_max_length(uiBut *but)
static double ui_get_but_scale_unit(uiBut *but, double value)
{
Scene *scene= CTX_data_scene((bContext *)but->block->evil_C);
- int subtype= RNA_property_subtype(but->rnaprop);
+ int subtype= RNA_SUBTYPE_UNIT(RNA_property_subtype(but->rnaprop));
- if(subtype & PROP_UNIT_LENGTH) {
+ if(subtype == PROP_UNIT_LENGTH) {
return value * scene->unit.scale_length;
}
- else if(subtype & PROP_UNIT_TIME) { /* WARNING - using evil_C :| */
+ else if(subtype == PROP_UNIT_TIME) { /* WARNING - using evil_C :| */
return FRA2TIME(value);
}
else {
@@ -1596,7 +1602,7 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
BLI_strncpy(str_unit_convert, str, sizeof(str_unit_convert));
- if(scene->unit.system != USER_UNIT_NONE && unit_type) {
+ if(ui_is_but_unit(but)) {
/* ugly, use the draw string to get the value, this could cause problems if it includes some text which resolves to a unit */
bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), but->drawstr, ui_get_but_scale_unit(but, 1.0), scene->unit.system, unit_type);
}