Index: source/gameengine/Converter/BL_BlenderDataConversion.cpp =================================================================== --- source/gameengine/Converter/BL_BlenderDataConversion.cpp (revision 26217) +++ source/gameengine/Converter/BL_BlenderDataConversion.cpp (working copy) @@ -2584,13 +2584,11 @@ if (gameobj->GetPhysicsController()) { - float radsPerDeg = 6.283185307179586232f / 360.f; - PHY_IPhysicsController* physctrl = (PHY_IPhysicsController*) gameobj->GetPhysicsController()->GetUserData(); //we need to pass a full constraint frame, not just axis //localConstraintFrameBasis - MT_Matrix3x3 localCFrame(MT_Vector3(radsPerDeg*dat->axX,radsPerDeg*dat->axY,radsPerDeg*dat->axZ)); + MT_Matrix3x3 localCFrame(MT_Vector3(dat->axX,dat->axY,dat->axZ)); MT_Vector3 axis0 = localCFrame.getColumn(0); MT_Vector3 axis1 = localCFrame.getColumn(1); MT_Vector3 axis2 = localCFrame.getColumn(2); Index: source/blender/blenkernel/intern/unit.c =================================================================== --- source/blender/blenkernel/intern/unit.c (revision 26217) +++ source/blender/blenkernel/intern/unit.c (working copy) @@ -119,11 +119,18 @@ }; static struct bUnitCollection buNaturalTimeCollecton = {buNaturalTimeDef, 3, 0, sizeof(buNaturalTimeDef)/sizeof(bUnitDef)}; + +static struct bUnitDef buNaturalRotDef[] = { + {"degree", "degrees", "°", NULL, "Degrees", M_PI/180.f, 0.0, B_UNIT_DEF_NONE}, + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} +}; +static struct bUnitCollection buNaturalRotCollection = {buNaturalRotDef, 0, 0, sizeof(buNaturalRotDef)/sizeof(bUnitDef)}; + #define UNIT_SYSTEM_MAX 3 static struct bUnitCollection *bUnitSystems[][8] = { - {0,0,0,0,0,0,0,0}, - {0,&buMetricLenCollecton, 0,0,0,0, &buNaturalTimeCollecton,0}, /* metric */ - {0,&buImperialLenCollecton, 0,0,0,0, &buNaturalTimeCollecton,0}, /* imperial */ + {0,0,0,0,0,&buNaturalRotCollection,&buNaturalTimeCollecton,0}, + {0,&buMetricLenCollecton, 0,0,0, &buNaturalRotCollection, &buNaturalTimeCollecton,0}, /* metric */ + {0,&buImperialLenCollecton, 0,0,0,&buNaturalRotCollection, &buNaturalTimeCollecton,0}, /* imperial */ {0,0,0,0,0,0,0,0} }; @@ -451,23 +458,25 @@ bUnitCollection *usys_iter; int system_iter; - for(system_iter= 1; system_iterunits; unit->name; unit++) { + if (usys_iter) { + for(unit= usys_iter->units; unit->name; unit++) { - if((unit->flag & B_UNIT_DEF_SUPPRESS) == 0) { - int ofs = 0; - /* incase there are multiple instances */ - while((ofs=unit_replace(str+ofs, len_max-ofs, str_tmp, scale_pref, unit))) - change= 1; + if((unit->flag & B_UNIT_DEF_SUPPRESS) == 0) { + int ofs = 0; + /* incase there are multiple instances */ + while((ofs=unit_replace(str+ofs, len_max-ofs, str_tmp, scale_pref, unit))) + change= 1; + } } } } } } unit= NULL; - + if(change==0) { /* no units given so infer a unit from the previous string or default */ if(str_prev) { @@ -482,9 +491,10 @@ } } - if(unit==NULL) + if(unit==NULL || unit->name == NULL) unit= unit_default(usys); + /* add the unit prefix and re-run, use brackets incase there was an expression given */ if(snprintf(str_tmp, sizeof(str_tmp), "(%s)%s", str, unit->name) < sizeof(str_tmp)) { strncpy(str, str_tmp, len_max); @@ -530,7 +540,6 @@ } } - // printf("replace %s\n", str); return change; } Index: source/blender/blenkernel/intern/anim_sys.c =================================================================== --- source/blender/blenkernel/intern/anim_sys.c (revision 26217) +++ source/blender/blenkernel/intern/anim_sys.c (working copy) @@ -730,6 +730,11 @@ /* set value - only for animatable numerical values */ if (RNA_property_animateable(&new_ptr, prop)) { + /* convert to radians */ + if (RNA_SUBTYPE_UNIT(RNA_property_subtype(prop)) == PROP_UNIT_ROTATION) { + value *= M_PI/180.0; + } + switch (RNA_property_type(prop)) { case PROP_BOOLEAN: Index: source/blender/ikplugin/intern/iksolver_plugin.c =================================================================== --- source/blender/ikplugin/intern/iksolver_plugin.c (revision 26217) +++ source/blender/ikplugin/intern/iksolver_plugin.c (working copy) @@ -413,7 +413,7 @@ if(data->weight != 0.0) { if(poleconstrain) IK_SolverSetPoleVectorConstraint(solver, iktarget, goalpos, - polepos, data->poleangle*M_PI/180, (poleangledata == data)); + polepos, data->poleangle, (poleangledata == data)); IK_SolverAddGoal(solver, iktarget, goalpos, data->weight); } if((data->flag & CONSTRAINT_IK_ROT) && (data->orientweight != 0.0)) @@ -426,7 +426,7 @@ IK_Solve(solver, 0.0f, tree->iterations); if(poleangledata) - poleangledata->poleangle= IK_SolverGetPoleAngle(solver)*180/M_PI; + poleangledata->poleangle= IK_SolverGetPoleAngle(solver); IK_FreeSolver(solver); Index: source/blender/makesdna/DNA_anim_types.h =================================================================== --- source/blender/makesdna/DNA_anim_types.h (revision 26217) +++ source/blender/makesdna/DNA_anim_types.h (working copy) @@ -445,6 +445,9 @@ FCURVE_INT_VALUES = (1<<11), /* curve can only have certain discrete-number values (no interpolation at all, for enums/booleans) */ FCURVE_DISCRETE_VALUES = (1<<12), + /* curve represents a rotation value stored internally in the curve in degrees */ + FCURVE_ROTATION_DEGREES = (1<<13), + } eFCurve_Flags; /* extrapolation modes (only simple value 'extending') */ Index: source/blender/makesrna/intern/rna_constraint.c =================================================================== --- source/blender/makesrna/intern/rna_constraint.c (revision 26217) +++ source/blender/makesrna/intern/rna_constraint.c (working copy) @@ -29,6 +29,8 @@ #include "rna_internal.h" +#include "BLI_math.h" + #include "DNA_action_types.h" #include "DNA_constraint_types.h" #include "DNA_modifier_types.h" @@ -488,9 +490,9 @@ RNA_def_property_ui_text(prop, "Pole Sub-Target", ""); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); - prop= RNA_def_property(srna, "pole_angle", PROP_FLOAT, PROP_ANGLE); // XXX - todo, convert to rad + prop= RNA_def_property(srna, "pole_angle", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "poleangle"); - RNA_def_property_range(prop, -180.0f, 180.f); + RNA_def_property_range(prop, -M_PI, M_PI); RNA_def_property_ui_text(prop, "Pole Angle", "Pole rotation offset."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); @@ -1190,21 +1192,21 @@ RNA_def_property_ui_text(prop, "Pivot Z", "Offset pivot on Z."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "axis_x", PROP_FLOAT, PROP_ANGLE); // XXX - convert to radians + prop= RNA_def_property(srna, "axis_x", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "axX"); - RNA_def_property_range(prop, -360.0, 360.f); + RNA_def_property_range(prop, -M_PI*2, M_PI*2); RNA_def_property_ui_text(prop, "Axis X", "Rotate pivot on X axis in degrees."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "axis_y", PROP_FLOAT, PROP_ANGLE); // XXX - convert to radians + prop= RNA_def_property(srna, "axis_y", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "axY"); - RNA_def_property_range(prop, -360.0, 360.f); + RNA_def_property_range(prop, -M_PI*2, M_PI*2); RNA_def_property_ui_text(prop, "Axis Y", "Rotate pivot on Y axis in degrees."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "axis_z", PROP_FLOAT, PROP_ANGLE); // XXX - convert to radians + prop= RNA_def_property(srna, "axis_z", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "axZ"); - RNA_def_property_range(prop, -360.0, 360.f); + RNA_def_property_range(prop, -M_PI*2, M_PI*2); RNA_def_property_ui_text(prop, "Axis Z", "Rotate pivot on Z axis in degrees."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); Index: source/blender/makesrna/intern/rna_curve.c =================================================================== --- source/blender/makesrna/intern/rna_curve.c (revision 26217) +++ source/blender/makesrna/intern/rna_curve.c (working copy) @@ -50,12 +50,6 @@ {BEZT_IPO_LIN, "LINEAR", 0, "Linear", ""}, {BEZT_IPO_BEZ, "BEZIER", 0, "Bezier", ""}, {0, NULL, 0, NULL, NULL}}; - -EnumPropertyItem beztriple_keyframe_type_items[] = { - {BEZT_KEYTYPE_KEYFRAME, "KEYFRAME", 0, "Keyframe", ""}, - {BEZT_KEYTYPE_BREAKDOWN, "BREAKDOWN", 0, "Breakdown", ""}, - {BEZT_KEYTYPE_EXTREME, "EXTREME", 0, "Extreme", ""}, - {0, NULL, 0, NULL, NULL}}; #ifdef RNA_RUNTIME @@ -427,12 +421,6 @@ RNA_def_property_ui_text(prop, "Interpolation", "(For F-Curves Only) Interpolation to use for segment of curve starting from current BezTriple."); //RNA_def_property_update(prop, 0, "rna_Curve_update_data"); // this should be an F-Curve update call instead... - prop= RNA_def_property(srna, "keyframe_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "hide"); - RNA_def_property_enum_items(prop, beztriple_keyframe_type_items); - RNA_def_property_ui_text(prop, "Keyframe Type", "(For F-Curves only) The type of keyframe this control point defines."); - //RNA_def_property_update(prop, 0, "rna_Curve_update_data"); // this should be an F-Curve update call instead... - /* Vector values */ prop= RNA_def_property(srna, "handle1", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); Index: source/blender/makesrna/intern/rna_fcurve.c =================================================================== --- source/blender/makesrna/intern/rna_fcurve.c (revision 26217) +++ source/blender/makesrna/intern/rna_fcurve.c (working copy) @@ -23,6 +23,7 @@ */ #include +#include #include "RNA_access.h" #include "RNA_define.h" @@ -51,6 +52,12 @@ {FMODIFIER_TYPE_LIMITS, "LIMITS", 0, "Limits", ""}, {0, NULL, 0, NULL, NULL}}; +EnumPropertyItem beztriple_keyframe_type_items[] = { + {BEZT_KEYTYPE_KEYFRAME, "KEYFRAME", 0, "Keyframe", ""}, + {BEZT_KEYTYPE_BREAKDOWN, "BREAKDOWN", 0, "Breakdown", ""}, + {BEZT_KEYTYPE_EXTREME, "EXTREME", 0, "Extreme", ""}, + {0, NULL, 0, NULL, NULL}}; + #ifdef RNA_RUNTIME #include "WM_api.h" @@ -206,6 +213,95 @@ /* ****************************** */ +static int rna_beztriple_is_rotation(ID *id, BezTriple *bt) +{ + bAction *act = (bAction *)id; + FCurve *fcu; + unsigned int i; + int found=0; + + /* find the driver this belongs to and update it */ + for (fcu=act->curves.first; fcu; fcu=fcu->next) { + for (i=0; i< fcu->totvert; i++) { + if (fcu->bezt+i == bt) { + found=1; + break; + } + } + if (found) break; + } + + if (!found) + return 0; + + return (fcu->flag & FCURVE_ROTATION_DEGREES); +} + +static void rna_BezTriple_handle1_get(PointerRNA *ptr, float *values) +{ + ID *id = (ID *)ptr->id.data; + BezTriple *bt= (BezTriple*)ptr->data; + + values[0]= bt->vec[0][0]; + + if (rna_beztriple_is_rotation(id, bt)) + values[1]= bt->vec[0][1] * M_PI/180.0; + else + values[1]= bt->vec[0][1]; +} + +static void rna_BezTriple_handle1_set(PointerRNA *ptr, const float *values) +{ + BezTriple *bt= (BezTriple*)ptr->data; + + bt->vec[0][0]= values[0]; + bt->vec[0][1]= values[1]; +} + +static void rna_BezTriple_handle2_get(PointerRNA *ptr, float *values) +{ + ID *id = (ID *)ptr->id.data; + BezTriple *bt= (BezTriple*)ptr->data; + + values[0]= bt->vec[2][0]; + + if (rna_beztriple_is_rotation(id, bt)) + values[1]= bt->vec[2][1] * M_PI/180.0; + else + values[1]= bt->vec[2][1]; +} + +static void rna_BezTriple_handle2_set(PointerRNA *ptr, const float *values) +{ + BezTriple *bt= (BezTriple*)ptr->data; + + bt->vec[2][0]= values[0]; + bt->vec[2][1]= values[1]; +} + +static void rna_BezTriple_ctrlpoint_get(PointerRNA *ptr, float *values) +{ + ID *id = (ID *)ptr->id.data; + BezTriple *bt= (BezTriple*)ptr->data; + + values[0]= bt->vec[1][0]; + + if (rna_beztriple_is_rotation(id, bt)) + values[1]= bt->vec[1][1] * M_PI/180.0; + else + values[1]= bt->vec[1][1]; +} + +static void rna_BezTriple_ctrlpoint_set(PointerRNA *ptr, const float *values) +{ + BezTriple *bt= (BezTriple*)ptr->data; + + bt->vec[1][0]= values[0]; + bt->vec[1][1]= values[1]; +} + +/* ****************************** */ + static void rna_FCurve_RnaPath_get(PointerRNA *ptr, char *value) { FCurve *fcu= (FCurve *)ptr->data; @@ -888,6 +984,101 @@ RNA_def_property_ui_text(prop, "Point", "Point coordinates"); } + +/* duplicate of BezTriple in rna_curve.c + * but with F-Curve specific options updates/functionality */ +static void rna_def_fcurvebeztriple(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem beztriple_handle_type_items[] = { + {HD_FREE, "FREE", 0, "Free", ""}, + {HD_AUTO, "AUTO", 0, "Auto", ""}, + {HD_VECT, "VECTOR", 0, "Vector", ""}, + {HD_ALIGN, "ALIGNED", 0, "Aligned", ""}, + {HD_AUTO_ANIM, "AUTO_CLAMPED", 0, "Auto Clamped", ""}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem beztriple_interpolation_mode_items[] = { + {BEZT_IPO_CONST, "CONSTANT", 0, "Constant", ""}, + {BEZT_IPO_LIN, "LINEAR", 0, "Linear", ""}, + {BEZT_IPO_BEZ, "BEZIER", 0, "Bezier", ""}, + {0, NULL, 0, NULL, NULL}}; + + srna= RNA_def_struct(brna, "FCurveBezierSplinePoint", NULL); + RNA_def_struct_sdna(srna, "BezTriple"); + RNA_def_struct_ui_text(srna, "FCurve Bezier Curve Point", "Bezier curve point with two handles, used in F-Curves."); + + /* Boolean values */ + prop= RNA_def_property(srna, "selected_handle1", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "f1", 0); + RNA_def_property_ui_text(prop, "Handle 1 selected", "Handle 1 selection status"); + RNA_def_property_update(prop, 0, NULL); + + prop= RNA_def_property(srna, "selected_handle2", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "f3", 0); + RNA_def_property_ui_text(prop, "Handle 2 selected", "Handle 2 selection status"); + RNA_def_property_update(prop, 0, NULL); + + prop= RNA_def_property(srna, "selected_control_point", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "f2", 0); + RNA_def_property_ui_text(prop, "Control Point selected", "Control point selection status"); + RNA_def_property_update(prop, 0, NULL); + + prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "hide", 0); + RNA_def_property_ui_text(prop, "Hidden", "Visibility status"); + RNA_def_property_update(prop, 0, NULL); + + /* Enums */ + prop= RNA_def_property(srna, "handle1_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "h1"); + RNA_def_property_enum_items(prop, beztriple_handle_type_items); + RNA_def_property_ui_text(prop, "Handle 1 Type", "Handle types"); + RNA_def_property_update(prop, 0, NULL); + + prop= RNA_def_property(srna, "handle2_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "h2"); + RNA_def_property_enum_items(prop, beztriple_handle_type_items); + RNA_def_property_ui_text(prop, "Handle 2 Type", "Handle types"); + RNA_def_property_update(prop, 0, NULL); + + prop= RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "ipo"); + RNA_def_property_enum_items(prop, beztriple_interpolation_mode_items); + RNA_def_property_ui_text(prop, "Interpolation", "(For F-Curves Only) Interpolation to use for segment of curve starting from current BezTriple."); + //RNA_def_property_update(prop, 0, "rna_Curve_update_data"); // this should be an F-Curve update call instead... + + prop= RNA_def_property(srna, "keyframe_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "hide"); + RNA_def_property_enum_items(prop, beztriple_keyframe_type_items); + RNA_def_property_ui_text(prop, "Keyframe Type", "(For F-Curves only) The type of keyframe this control point defines."); + //RNA_def_property_update(prop, 0, "rna_Curve_update_data"); // this should be an F-Curve update call instead... + + /* Vector values */ + prop= RNA_def_property(srna, "handle1", PROP_FLOAT, PROP_TRANSLATION); + RNA_def_property_array(prop, 2); + RNA_def_property_float_funcs(prop, "rna_BezTriple_handle1_get", "rna_BezTriple_handle1_set", NULL); + RNA_def_property_ui_text(prop, "Handle 1", "Coordinates of the first handle"); + RNA_def_property_update(prop, 0, NULL); + + prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION); + RNA_def_property_array(prop, 2); + RNA_def_property_float_funcs(prop, "rna_BezTriple_ctrlpoint_get", "rna_BezTriple_ctrlpoint_set", NULL); + RNA_def_property_ui_text(prop, "Control Point", "Coordinates of the control point"); + RNA_def_property_update(prop, 0, NULL); + + prop= RNA_def_property(srna, "handle2", PROP_FLOAT, PROP_TRANSLATION); + RNA_def_property_array(prop, 2); + RNA_def_property_float_funcs(prop, "rna_BezTriple_handle2_get", "rna_BezTriple_handle2_set", NULL); + RNA_def_property_ui_text(prop, "Handle 2", "Coordinates of the second handle"); + RNA_def_property_update(prop, 0, NULL); + + /* Number values */ +} + + static void rna_def_fcurve_modifiers(BlenderRNA *brna, PropertyRNA *cprop) { /* add modifiers */ @@ -997,7 +1188,7 @@ prop= RNA_def_property(srna, "keyframe_points", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "bezt", "totvert"); - RNA_def_property_struct_type(prop, "BezierSplinePoint"); + RNA_def_property_struct_type(prop, "FCurveBezierSplinePoint"); RNA_def_property_ui_text(prop, "Keyframes", "User-editable keyframes"); prop= RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE); @@ -1011,6 +1202,7 @@ void RNA_def_fcurve(BlenderRNA *brna) { + rna_def_fcurvebeztriple(brna); rna_def_fcurve(brna); rna_def_fpoint(brna); Index: source/blender/blenloader/intern/readfile.c =================================================================== --- source/blender/blenloader/intern/readfile.c (revision 26217) +++ source/blender/blenloader/intern/readfile.c (working copy) @@ -6439,6 +6439,21 @@ } } +static void do_version_fcurve_radians_degrees_250(FCurve *fcu) +{ + int i; + + for (i=0; itotvert; i++) { + BezTriple *bt = fcu->bezt+i; + + bt->vec[0][1] *= 180.0/M_PI; + bt->vec[1][1] *= 180.0/M_PI; + bt->vec[2][1] *= 180.0/M_PI; + } + + fcu->flag |= FCURVE_ROTATION_DEGREES; +} + static void do_versions(FileData *fd, Library *lib, Main *main) { /* WATCH IT!!!: pointers from libdata have not been converted */ @@ -10493,7 +10508,51 @@ /* put 2.50 compatibility code here until next subversion bump */ if (1) { - ; + { + /* still missing: + - Rotation limit constraint (min x/y/z, max x/y/z) + - Pose channel IK (min x/y/z, max x/y/z) + - Brush texture rotation angle + */ + bAction *act; + Object *ob; + + float rads_per_deg = M_PI / 180.0; + + /* convert degrees to radians for internal use */ + for (ob=main->object.first; ob; ob=ob->id.next) { + bConstraint *con; + + for (con=ob->constraints.first; con; con=con->next) { + if(con->type==CONSTRAINT_TYPE_RIGIDBODYJOINT) { + bRigidBodyJointConstraint *data = con->data; + data->axX *= rads_per_deg; + data->axY *= rads_per_deg; + data->axZ *= rads_per_deg; + } + if(con->type==CONSTRAINT_TYPE_KINEMATIC) { + bKinematicConstraint *data = con->data; + data->poleangle *= rads_per_deg; + } + } + } + + + /* convert fcurve values to be stored in degrees */ + for (act = main->action.first; act; act=act->id.next) { + FCurve *fcu; + + /* convert over named properties with PROP_UNIT_ROTATION time of this change */ + for (fcu=act->curves.first; fcu; fcu=fcu->next) { + if (strcmp(fcu->rna_path, "rotation_euler")==0) + do_version_fcurve_radians_degrees_250(fcu); + else if (strcmp(fcu->rna_path, "delta_rotation_euler")==0) + do_version_fcurve_radians_degrees_250(fcu); + else if (strcmp(fcu->rna_path, "pole_angle")==0) + do_version_fcurve_radians_degrees_250(fcu); + } + } + } } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ Index: source/blender/editors/animation/keyframing.c =================================================================== --- source/blender/editors/animation/keyframing.c (revision 26217) +++ source/blender/editors/animation/keyframing.c (working copy) @@ -783,6 +783,11 @@ curval= setting_get_rna_value(&ptr, prop, fcu->array_index); } + /* convert to degrees */ + if (RNA_SUBTYPE_UNIT(RNA_property_subtype(prop)) == PROP_UNIT_ROTATION) { + curval *= 180.0/M_PI; + } + /* only insert keyframes where they are needed */ if (flag & INSERTKEY_NEEDED) { short insert_mode; @@ -895,6 +900,10 @@ } } + /* mark the curve if it's a new rotation curve */ + if ((fcu->totvert == 0) && (RNA_SUBTYPE_UNIT(RNA_property_subtype(prop)) == PROP_UNIT_ROTATION)) + fcu->flag |= FCURVE_ROTATION_DEGREES; + /* insert keyframe */ ret += insert_keyframe_direct(ptr, prop, fcu, cfra, flag); } Index: source/blender/editors/interface/interface.c =================================================================== --- source/blender/editors/interface/interface.c (revision 26217) +++ source/blender/editors/interface/interface.c (working copy) @@ -1225,13 +1225,19 @@ 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 @@ 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 @@ 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); } Index: source/blender/editors/interface/interface_regions.c =================================================================== --- source/blender/editors/interface/interface_regions.c (revision 26217) +++ source/blender/editors/interface/interface_regions.c (working copy) @@ -390,6 +390,16 @@ } if(but->rnaprop) { + int unit_type = RNA_SUBTYPE_UNIT(RNA_property_subtype(but->rnaprop)); + + if (unit_type == PROP_UNIT_ROTATION) { + if (RNA_property_type(but->rnaprop) == PROP_FLOAT) { + BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Radians: %f", RNA_property_float_get_index(&but->rnapoin, but->rnaprop, but->rnaindex)); + data->linedark[data->totline]= 1; + data->totline++; + } + } + if(but->flag & UI_BUT_DRIVEN) { if(ui_but_anim_expression_get(but, buf, sizeof(buf))) { /* expression */