2.4x Bugfix - #18188: "Clear user transform" does not work as described
authorJoshua Leung <aligorith@gmail.com>
Mon, 6 Apr 2009 00:04:04 +0000 (00:04 +0000)
committerJoshua Leung <aligorith@gmail.com>
Mon, 6 Apr 2009 00:04:04 +0000 (00:04 +0000)
For the record, "Clear user transform" is supposed to restore selected bones to the transforms defined by Actions/NLA, not back to rest position.

source/blender/include/BIF_poseobject.h
source/blender/src/header_view3d.c
source/blender/src/poseobject.c

index ab96f7ec03e44981e9fa280aea0489cbb703c4da..ba7ad8c4e77d3ff57e9df2c4ba149d3f4430310b 100644 (file)
@@ -80,6 +80,7 @@ void pose_activate_flipped_bone(void);
 void pose_movetolayer(void);
 void pose_relax(void);
 void pose_flipquats(void);
+void pose_clear_user_transforms(void);
 
 #endif
 
index 8171fe2e527e1ad89691050115c1f95731036b1f..6d72e434e67fe691cd16b484a7316bff24e25e5b 100644 (file)
@@ -4123,8 +4123,6 @@ static uiBlock *view3d_edit_armaturemenu(void *arg_unused)
 
 static void do_view3d_pose_armature_transformmenu(void *arg, int event)
 {
-       Object *ob= OBACT;
-       
        switch(event) {
        case 0: /*      clear origin */
                clear_object('o');
@@ -4139,9 +4137,7 @@ static void do_view3d_pose_armature_transformmenu(void *arg, int event)
                clear_object('g');
                break;
        case 4: /* clear user transform */
-               rest_pose(ob->pose);
-               DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
-               BIF_undo_push("Pose, Clear User Transform");
+               pose_clear_user_transforms();
                break;
        }
        allqueue(REDRAWVIEW3D, 0);
index c2a2be80e89ce98e206207e394cf47e4f763975c..c081bcbcb450ba6ad6f0532e3ad98e5d0f88bd81 100644 (file)
@@ -568,9 +568,7 @@ void pose_special_editmenu(void)
                pose_clear_paths(ob);
        }
        else if(nr==5) {
-               rest_pose(ob->pose);
-               DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
-               BIF_undo_push("Clear User Transform Pose");
+               pose_clear_user_transforms();
        }
        else if(nr==6) {
                pose_relax();
@@ -1740,4 +1738,30 @@ void pose_flipquats(void)
        autokeyframe_pose_cb_func(ob, TFM_ROTATION, 0);
 }
 
+/* Restore selected pose-bones to 'action'-defined pose */
+void pose_clear_user_transforms (void) 
+{
+       Object *ob = OBACT;
+       bArmature *arm= ob->data;
+       bPoseChannel *pchan;
+       
+       if (ob->pose == NULL)
+               return;
+       
+       /* find selected bones */
+       for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+               if (pchan->bone && (pchan->bone->flag & BONE_SELECTED) && (pchan->bone->layer & arm->layer)) {
+                       /* just clear the BONE_UNKEYED flag, allowing this bone to get overwritten by actions again */
+                       pchan->bone->flag &= ~BONE_UNKEYED;
+               }
+       }
+       
+       /* clear pose locking flag 
+        *      - this will only clear the user-defined pose in the selected bones, where BONE_UNKEYED has been cleared
+        */
+       ob->pose->flag |= POSE_DO_UNLOCK;
+       
+       DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
+       BIF_undo_push("Clear User Transform");
+}