Revision: 23701
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23701
Author:   aligorith
Date:     2009-10-08 07:02:04 +0200 (Thu, 08 Oct 2009)

Log Message:
-----------
Fixed remaining bugs with animating rotation modes:

* Removed the hack-functions to set euler rotations from the values set in the 
other rotation representations, even when euler rotations weren't being used. I 
pressume that this was added for being able to represent quats in terms of 
eulers for the UI, but really it would break animation evaluation (i.e. euler 
curves after quaternion curves would always block the quaternion curves).

* Object rotation values in the transform properties panel now take into 
account rotation modes, so the appropriate rotations will get converted to 
quaternions before being drawn.

* Fixed a few bugs with some of the conversion code (minor stuff left out).

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/armature.c
    trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c
    trunk/blender/source/blender/makesrna/intern/rna_object.c
    trunk/blender/source/blender/makesrna/intern/rna_pose.c

Modified: trunk/blender/source/blender/blenkernel/intern/armature.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/armature.c   2009-10-08 
00:57:00 UTC (rev 23700)
+++ trunk/blender/source/blender/blenkernel/intern/armature.c   2009-10-08 
05:02:04 UTC (rev 23701)
@@ -1314,7 +1314,7 @@
        else if (newMode == ROT_MODE_AXISANGLE) { /* to axis-angle */
                if (oldMode > 0) {
                        /* euler to axis angle */
-                       EulOToAxisAngle(eul, oldMode, &quat[1], &quat[0]);
+                       EulOToAxisAngle(eul, oldMode, axis, angle);
                }
                else if (oldMode == ROT_MODE_QUAT) {
                        /* quat to axis angle */

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c  
2009-10-08 00:57:00 UTC (rev 23700)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c  
2009-10-08 05:02:04 UTC (rev 23701)
@@ -520,7 +520,7 @@
        if (pchan->rotmode == ROT_MODE_AXISANGLE) {
                float quat[4];
                /* convert to euler, passing through quats... */
-               AxisAngleToQuat(quat, &pchan->quat[1], pchan->quat[0]);
+               AxisAngleToQuat(quat, pchan->rotAxis, pchan->rotAngle);
                QuatToEul(quat, tfp->ob_eul);
        }
        else if (pchan->rotmode == ROT_MODE_QUAT)
@@ -689,10 +689,24 @@
                
        case B_OBJECTPANELROT:
                if(ob) {
-                       // TODO: need to support roation modes
-                       ob->rot[0]= M_PI*tfp->ob_eul[0]/180.0;
-                       ob->rot[1]= M_PI*tfp->ob_eul[1]/180.0;
-                       ob->rot[2]= M_PI*tfp->ob_eul[2]/180.0;
+                       float eul[3];
+                       
+                       /* make a copy to eul[3], to allow TAB on buttons to 
work */
+                       eul[0]= M_PI*tfp->ob_eul[0]/180.0;
+                       eul[1]= M_PI*tfp->ob_eul[1]/180.0;
+                       eul[2]= M_PI*tfp->ob_eul[2]/180.0;
+                       
+                       if (ob->rotmode == ROT_MODE_AXISANGLE) {
+                               float quat[4];
+                               /* convert to axis-angle, passing through quats 
 */
+                               EulToQuat(eul, quat);
+                               QuatToAxisAngle(quat, ob->rotAxis, 
&ob->rotAngle);
+                       }
+                       else if (ob->rotmode == ROT_MODE_QUAT)
+                               EulToQuat(eul, ob->quat);
+                       else
+                               VecCopyf(ob->rot, eul);
+                               
                        DAG_id_flush_update(&ob->id, OB_RECALC_OB);
                }
                break;
@@ -1130,9 +1144,19 @@
                uiDefIconButBitS(block, ICONTOG, OB_LOCK_LOCZ, B_REDR, 
ICON_UNLOCKED,           125, 240, 25, 19, &(ob->protectflag), 0, 0, 0, 0, 
"Protects Z Location value from being Transformed");
                uiBlockEndAlign(block);
                
-               tfp->ob_eul[0]= 180.0*ob->rot[0]/M_PI;
-               tfp->ob_eul[1]= 180.0*ob->rot[1]/M_PI;
-               tfp->ob_eul[2]= 180.0*ob->rot[2]/M_PI;
+               if (ob->rotmode == ROT_MODE_AXISANGLE) {
+                       float quat[4];
+                       /* convert to euler, passing through quats... */
+                       AxisAngleToQuat(quat, ob->rotAxis, ob->rotAngle);
+                       QuatToEul(quat, tfp->ob_eul);
+               }
+               else if (ob->rotmode == ROT_MODE_QUAT)
+                       QuatToEul(ob->quat, tfp->ob_eul);
+               else
+                       VecCopyf(tfp->ob_eul, ob->rot);
+               tfp->ob_eul[0]*= 180.0/M_PI;
+               tfp->ob_eul[1]*= 180.0/M_PI;
+               tfp->ob_eul[2]*= 180.0/M_PI;
                
                uiBlockBeginAlign(block);
                if ((ob->parent) && (ob->partype == PARBONE)) {

Modified: trunk/blender/source/blender/makesrna/intern/rna_object.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_object.c   2009-10-08 
00:57:00 UTC (rev 23700)
+++ trunk/blender/source/blender/makesrna/intern/rna_object.c   2009-10-08 
05:02:04 UTC (rev 23701)
@@ -458,32 +458,6 @@
        psys_set_current_num(ob, value);
 }
 
-/* rotation - euler angles */
-static void rna_Object_rotation_euler_get(PointerRNA *ptr, float *value)
-{
-       Object *ob= ptr->data;
-       
-       if(ob->rotmode == ROT_MODE_AXISANGLE) /* default XYZ eulers */
-               AxisAngleToEulO(&ob->quat[1], ob->quat[0], value, 
EULER_ORDER_DEFAULT);
-       else if(ob->rotmode == ROT_MODE_QUAT) /* default XYZ eulers  */
-               QuatToEul(ob->quat, value);
-       else
-               VECCOPY(value, ob->rot);
-}
-
-/* rotation - euler angles */
-static void rna_Object_rotation_euler_set(PointerRNA *ptr, const float *value)
-{
-       Object *ob= ptr->data;
-       
-       if(ob->rotmode == ROT_MODE_AXISANGLE) /* default XYZ eulers */
-               EulOToAxisAngle((float *)value, EULER_ORDER_DEFAULT, 
&ob->quat[1], &ob->quat[0]);
-       else if(ob->rotmode == ROT_MODE_QUAT) /* default XYZ eulers */
-               EulToQuat((float*)value, ob->quat);
-       else
-               VECCOPY(ob->rot, value);
-}
-
 /* rotation - axis-angle */
 static void rna_Object_rotation_axis_angle_get(PointerRNA *ptr, float *value)
 {
@@ -1271,7 +1245,6 @@
        
        prop= RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER);
        RNA_def_property_float_sdna(prop, NULL, "rot");
-       RNA_def_property_float_funcs(prop, "rna_Object_rotation_euler_get", 
"rna_Object_rotation_euler_set", NULL);
        RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers.");
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, 
"rna_Object_update");
        

Modified: trunk/blender/source/blender/makesrna/intern/rna_pose.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_pose.c     2009-10-08 
00:57:00 UTC (rev 23700)
+++ trunk/blender/source/blender/makesrna/intern/rna_pose.c     2009-10-08 
05:02:04 UTC (rev 23701)
@@ -156,32 +156,6 @@
        DAG_id_flush_update(&ob->id, OB_RECALC_DATA|OB_RECALC_OB);
 }
 
-/* rotation - euler angles */
-static void rna_PoseChannel_rotation_euler_get(PointerRNA *ptr, float *value)
-{
-       bPoseChannel *pchan= ptr->data;
-       
-       if(pchan->rotmode == ROT_MODE_AXISANGLE) /* default XYZ eulers */
-               AxisAngleToEulO(pchan->rotAxis, pchan->rotAngle, value, 
EULER_ORDER_DEFAULT);
-       else if(pchan->rotmode == ROT_MODE_QUAT) /* default XYZ eulers  */
-               QuatToEul(pchan->quat, value);
-       else
-               VECCOPY(value, pchan->eul);
-}
-
-/* rotation - euler angles */
-static void rna_PoseChannel_rotation_euler_set(PointerRNA *ptr, const float 
*value)
-{
-       bPoseChannel *pchan= ptr->data;
-       
-       if(pchan->rotmode == ROT_MODE_AXISANGLE) /* default XYZ eulers */
-               EulOToAxisAngle((float *)value, EULER_ORDER_DEFAULT, 
pchan->rotAxis, &pchan->rotAngle);
-       else if(pchan->rotmode == ROT_MODE_QUAT) /* default XYZ eulers */
-               EulToQuat((float*)value, pchan->quat);
-       else
-               VECCOPY(pchan->eul, value);
-}
-
 /* rotation - axis-angle */
 static void rna_PoseChannel_rotation_axis_angle_get(PointerRNA *ptr, float 
*value)
 {
@@ -607,7 +581,6 @@
        
        prop= RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER);
        RNA_def_property_float_sdna(prop, NULL, "eul");
-       RNA_def_property_float_funcs(prop, 
"rna_PoseChannel_rotation_euler_get", "rna_PoseChannel_rotation_euler_set", 
NULL);
        RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers.");
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, 
"rna_Pose_update");
        
@@ -617,15 +590,14 @@
        RNA_def_property_enum_funcs(prop, NULL, 
"rna_PoseChannel_rotation_mode_set", NULL);
        RNA_def_property_ui_text(prop, "Rotation Mode", "");
        RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update");
-
-       /* These three matrix properties await an implementation of the 
PROP_MATRIX subtype, which currently doesn't exist. */
+       
+       /* transform matrices - should be read-only since these are set 
directly by AnimSys evaluation */
        prop= RNA_def_property(srna, "channel_matrix", PROP_FLOAT, PROP_MATRIX);
        RNA_def_property_float_sdna(prop, NULL, "chan_mat");
        RNA_def_property_array(prop, 16);
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_ui_text(prop, "Channel Matrix", "4x4 matrix, before 
constraints.");
-
-       /* kaito says this should be not user-editable; I disagree; power users 
should be able to force this in python; he's the boss. */
+       
        prop= RNA_def_property(srna, "pose_matrix", PROP_FLOAT, PROP_MATRIX);
        RNA_def_property_float_sdna(prop, NULL, "pose_mat");
        RNA_def_property_array(prop, 16);


_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to