Revision: 23126
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23126
Author:   aligorith
Date:     2009-09-11 14:44:09 +0200 (Fri, 11 Sep 2009)

Log Message:
-----------
2.5 - Rotation work (axis angle bugfixes + cleanups)

* Made transform work better with axis-angle
* Corrected the rotation-type handling code in a few places

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/armature/editarmature.c
    branches/blender2.5/blender/source/blender/editors/armature/poselib.c
    branches/blender2.5/blender/source/blender/editors/armature/poseobject.c
    
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_buttons.c
    branches/blender2.5/blender/source/blender/editors/transform/transform.c
    
branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c

Modified: 
branches/blender2.5/blender/source/blender/editors/armature/editarmature.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/editarmature.c  
2009-09-11 12:05:09 UTC (rev 23125)
+++ branches/blender2.5/blender/source/blender/editors/armature/editarmature.c  
2009-09-11 12:44:09 UTC (rev 23126)
@@ -4856,9 +4856,13 @@
                                QUATCOPY(quat1, pchan->quat);
                                QuatToEul(pchan->quat, oldeul);
                        }
+                       else if (pchan->rotmode == PCHAN_ROT_AXISANGLE) {
+                               continue; // XXX
+                       }
                        else {
                                VECCOPY(oldeul, pchan->eul);
                        }
+                       
                        eul[0]= eul[1]= eul[2]= 0.0f;
                        
                        if (pchan->protectflag & OB_LOCK_ROTX)
@@ -4875,6 +4879,9 @@
                                        QuatMulf(pchan->quat, -1.0f);
                                }
                        }
+                       else if (pchan->rotmode == PCHAN_ROT_AXISANGLE) {
+                               // TODO...
+                       }
                        else {
                                VECCOPY(pchan->eul, eul);
                        }
@@ -4884,6 +4891,11 @@
                                pchan->quat[1]=pchan->quat[2]=pchan->quat[3]= 
0.0f; 
                                pchan->quat[0]= 1.0f;
                        }
+                       else if (pchan->rotmode == PCHAN_ROT_AXISANGLE) {
+                               /* by default, make rotation of 0 radians 
around y-axis (roll) */
+                               pchan->quat[0]=pchan->quat[1]=pchan->quat[3]= 
0.0f;
+                               pchan->quat[2]= 1.0f;
+                       }
                        else {
                                pchan->eul[0]= pchan->eul[1]= pchan->eul[2]= 
0.0f;
                        }

Modified: branches/blender2.5/blender/source/blender/editors/armature/poselib.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/poselib.c       
2009-09-11 12:05:09 UTC (rev 23125)
+++ branches/blender2.5/blender/source/blender/editors/armature/poselib.c       
2009-09-11 12:44:09 UTC (rev 23126)
@@ -278,8 +278,7 @@
 /* ************************************************************* */
 
 /* Pointers to the builtin KeyingSets that we want to use */
-static KeyingSet *poselib_ks_locrotscale = NULL;               /* quaternion 
rotations */
-static KeyingSet *poselib_ks_locrotscale2 = NULL;              /* euler 
rotations */           // XXX FIXME...
+static KeyingSet *poselib_ks_locrotscale = NULL;               /* the only 
keyingset we'll need*/
 static short poselib_ks_need_init= 1;                                  /* have 
the above been obtained yet? */
 
 /* Make sure the builtin KeyingSets are initialised properly 
@@ -290,13 +289,9 @@
        /* only if we haven't got these yet */
        // FIXME: this assumes that we will always get the builtin sets... 
        if (poselib_ks_need_init) {
-               /* LocRotScale (quaternions) */
+               /* LocRotScale (quaternions or eulers depending on context) */
                poselib_ks_locrotscale= ANIM_builtin_keyingset_get_named(NULL, 
"LocRotScale");
                
-               /* LocRotScale (euler) */
-               //ks_locrotscale2= 
ANIM_builtin_keyingset_get_named(ks_locrotscale, "LocRotScale");
-               poselib_ks_locrotscale2= poselib_ks_locrotscale; // FIXME: for 
now, just use the same one...
-               
                /* clear flag requesting init */
                poselib_ks_need_init= 0;
        }
@@ -410,11 +405,8 @@
                                /* init cks for this PoseChannel, then use the 
relative KeyingSets to keyframe it */
                                cks.pchan= pchan;
                                
-                               /* KeyingSet to use depends on rotation mode  */
-                               if (pchan->rotmode)
-                                       modify_keyframes(C, &dsources, act, 
poselib_ks_locrotscale2, MODIFYKEY_MODE_INSERT, (float)frame);
-                               else
-                                       modify_keyframes(C, &dsources, act, 
poselib_ks_locrotscale, MODIFYKEY_MODE_INSERT, (float)frame);
+                               /* KeyingSet to use depends on rotation mode 
(but that's handled by the templates code)  */
+                               modify_keyframes(C, &dsources, act, 
poselib_ks_locrotscale, MODIFYKEY_MODE_INSERT, (float)frame);
                        }
                }
        }

Modified: 
branches/blender2.5/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/poseobject.c    
2009-09-11 12:05:09 UTC (rev 23125)
+++ branches/blender2.5/blender/source/blender/editors/armature/poseobject.c    
2009-09-11 12:44:09 UTC (rev 23126)
@@ -812,10 +812,17 @@
                                                
                                                
armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat);
                                                
-                                               if (pchan->rotmode > 0) 
+                                               if (pchan->rotmode == 
PCHAN_ROT_AXISANGLE) {
+                                                       float tmp_quat[4];
+                                                       
+                                                       /* need to convert to 
quat first (in temp var)... */
+                                                       Mat4ToQuat(delta_mat, 
tmp_quat);
+                                                       
QuatToAxisAngle(tmp_quat, &pchan->quat[1], &pchan->quat[0]);
+                                               }
+                                               else if (pchan->rotmode == 
PCHAN_ROT_QUAT)
+                                                       Mat4ToQuat(delta_mat, 
pchan->quat);
+                                               else
                                                        Mat4ToEulO(delta_mat, 
pchan->eul, pchan->rotmode);
-                                               else
-                                                       Mat4ToQuat(delta_mat, 
pchan->quat);
                                        }
                                                break;
                                        case 11: /* Visual Size */
@@ -991,6 +998,7 @@
                                pchan->flag= chan->flag;
                                
                                /* check if rotation modes are compatible (i.e. 
do they need any conversions) */
+                               // FIXME: add axis-angle here too...
                                if (pchan->rotmode == chan->rotmode) {
                                        /* copy the type of rotation in use */
                                        if (pchan->rotmode > 0) {

Modified: 
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_buttons.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_buttons.c
    2009-09-11 12:05:09 UTC (rev 23125)
+++ 
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_buttons.c
    2009-09-11 12:44:09 UTC (rev 23126)
@@ -511,8 +511,17 @@
                but= uiDefBut(block, TEX, B_NOP, "Bone:",                       
        160, 140, 140, 19, bone->name, 1, 31, 0, 0, "");
        uiButSetFunc(but, validate_bonebutton_cb, bone, NULL);
        uiButSetCompleteFunc(but, autocomplete_bone, (void *)ob);
-
-       QuatToEulO(pchan->quat, tfp->ob_eul, pchan->rotmode); // XXX?
+       
+       if (pchan->rotmode == PCHAN_ROT_AXISANGLE) {
+               float quat[4];
+               /* convert to euler, passing through quats... */
+               AxisAngleToQuat(quat, &pchan->quat[1], pchan->quat[0]);
+               QuatToEul(quat, tfp->ob_eul);
+       }
+       else if (pchan->rotmode == PCHAN_ROT_QUAT)
+               QuatToEul(pchan->quat, tfp->ob_eul);
+       else
+               VecCopyf(tfp->ob_eul, pchan->eul);
        tfp->ob_eul[0]*= 180.0/M_PI;
        tfp->ob_eul[1]*= 180.0/M_PI;
        tfp->ob_eul[2]*= 180.0/M_PI;
@@ -841,7 +850,18 @@
                        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;
-                       EulOToQuat(eul, pchan->rotmode, pchan->quat); // xxx?
+                       
+                       if (pchan->rotmode == PCHAN_ROT_AXISANGLE) {
+                               float quat[4];
+                               /* convert to axis-angle, passing through quats 
 */
+                               EulToQuat(eul, quat);
+                               QuatToAxisAngle(quat, &pchan->quat[1], 
&pchan->quat[0]);
+                       }
+                       else if (pchan->rotmode == PCHAN_ROT_QUAT)
+                               EulToQuat(eul, pchan->quat);
+                       else
+                               VecCopyf(pchan->eul, eul);
+                       
                }
                /* no break, pass on */
        case B_ARMATUREPANEL2:

Modified: 
branches/blender2.5/blender/source/blender/editors/transform/transform.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/transform/transform.c    
2009-09-11 12:05:09 UTC (rev 23125)
+++ branches/blender2.5/blender/source/blender/editors/transform/transform.c    
2009-09-11 12:44:09 UTC (rev 23126)
@@ -2673,15 +2673,26 @@
                                /* this function works on end result */
                                protectedQuaternionBits(td->protectflag, 
td->ext->quat, td->ext->iquat);
                                
-                               /* if axis-angle, we now convert the quat 
representation to axis-angle again
-                                *      - this means that the math above is not 
totally correct, but it works well enough so far...
-                                */
-                               if (td->rotOrder == PCHAN_ROT_AXISANGLE) {      
-                                       /* make temp copy (since stored in same 
place) */
-                                       QuatCopy(quat, td->ext->quat);
-                                       QuatToAxisAngle(quat, 
&td->ext->quat[1], &td->ext->quat[0]); 
-                               }
                        }
+                       else if (td->rotOrder == PCHAN_ROT_AXISANGLE) {
+                               /* calculate effect based on quats */
+                               float iquat[4];
+                               
+                               /* td->ext->(i)quat is in axis-angle form, not 
quats! */
+                               AxisAngleToQuat(iquat, &td->ext->iquat[1], 
td->ext->iquat[0]);
+                               
+                               Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 
0, 0, 0, 0);
+                               Mat3ToQuat(fmat, quat); // Actual transform
+                               
+                               QuatMul(td->ext->quat, quat, iquat);
+                               
+                               /* this function works on end result */
+                               protectedQuaternionBits(td->protectflag, 
td->ext->quat, td->ext->iquat);
+                               
+                               /* make temp copy (since stored in same place) 
*/
+                               QuatCopy(quat, td->ext->quat);
+                               QuatToAxisAngle(quat, &td->ext->quat[1], 
&td->ext->quat[0]); 
+                       }
                        else { 
                                float eulmat[3][3];
                                

Modified: 
branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
        2009-09-11 12:05:09 UTC (rev 23125)
+++ 
branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
        2009-09-11 12:44:09 UTC (rev 23126)
@@ -552,9 +552,8 @@
 
        td->ob = ob;
        td->flag = TD_SELECTED;
-       if ((pchan->rotmode == PCHAN_ROT_QUAT) || (pchan->rotmode == 
PCHAN_ROT_AXISANGLE)) 
+       if (pchan->rotmode == PCHAN_ROT_QUAT) 
        {
-               // XXX: for now, axis-angle will be treated like for quats (the 
only difference is the normalisation)
                td->flag |= TD_USEQUAT;
        }
        if (bone->flag & BONE_HINGE_CHILD_TRANSFORM)


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

Reply via email to