Revision: 60823
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60823
Author:   aligorith
Date:     2013-10-17 14:19:03 +0000 (Thu, 17 Oct 2013)
Log Message:
-----------
Project Pampa Request: Selecting groups in animation editors selects
corresponding bones

Modified Paths:
--------------
    trunk/blender/source/blender/editors/animation/anim_channels_edit.c
    trunk/blender/source/blender/editors/armature/pose_select.c
    trunk/blender/source/blender/editors/include/ED_armature.h

Modified: trunk/blender/source/blender/editors/animation/anim_channels_edit.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_channels_edit.c 
2013-10-17 14:10:03 UTC (rev 60822)
+++ trunk/blender/source/blender/editors/animation/anim_channels_edit.c 
2013-10-17 14:19:03 UTC (rev 60823)
@@ -58,6 +58,7 @@
 #include "UI_view2d.h"
 
 #include "ED_anim_api.h"
+#include "ED_armature.h"
 #include "ED_keyframes_edit.h" // XXX move the select modes out of there!
 #include "ED_screen.h"
 
@@ -2441,6 +2442,30 @@
                {
                        bActionGroup *agrp = (bActionGroup *)ale->data;
                        
+                       Object *ob = NULL;
+                       bPoseChannel *pchan = NULL;
+                       
+                       
+                       /* Armatures-Specific Feature:
+                        * Since groups are used to collect F-Curves of the 
same Bone by default
+                        * (via Keying Sets) so that they can be managed 
better, we try to make
+                        * things here easier for animators by mapping group 
selection to bone
+                        * selection 
+                        */
+                       if ((ale->id) && (GS(ale->id->name) == ID_OB)) {
+                                ob = (ID *)ale->id;
+                               
+                               if (ob->type == OB_ARMATURE) {
+                                       /* Assume for now that any group with 
corresponding name is what we want
+                                        * (i.e. for an armature whose location 
is animated, things would break
+                                        * if the user were to add a bone named 
"Location").
+                                        *
+                                        * TODO: check the first F-Curve or so 
to be sure...
+                                        */
+                                       pchan = 
BKE_pose_channel_find_name(ob->pose, agrp->name);
+                               }       
+                       }
+                       
                        /* select/deselect group */
                        if (selectmode == SELECT_INVERT) {
                                /* inverse selection status of this group only 
*/
@@ -2452,6 +2477,7 @@
                                
                                /* deselect all other channels */
                                ANIM_deselect_anim_channels(ac, ac->data, 
ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
+                               if (pchan) ED_pose_deselectall(ob, 0);
                                
                                /* only select channels in group and group 
itself */
                                for (fcu = agrp->channels.first; fcu && 
fcu->grp == agrp; fcu = fcu->next)
@@ -2461,14 +2487,20 @@
                        else {
                                /* select group by itself */
                                ANIM_deselect_anim_channels(ac, ac->data, 
ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
+                               if (pchan) ED_pose_deselctall(ob, 0);
+                               
                                agrp->flag |= AGRP_SELECTED;
                        }
                        
                        /* if group is selected now, make group the 'active' 
one in the visible list */
-                       if (agrp->flag & AGRP_SELECTED)
+                       if (agrp->flag & AGRP_SELECTED) {
                                ANIM_set_active_channel(ac, ac->data, 
ac->datatype, filter, agrp, ANIMTYPE_GROUP);
-                       else
+                               if (pchan) ED_pose_bone_select(ob, pchan, true);
+                       }
+                       else {
                                ANIM_set_active_channel(ac, ac->data, 
ac->datatype, filter, NULL, ANIMTYPE_GROUP);
+                               if (pchan) ED_pose_bone_select(ob, pchan, 
false);
+                       }
                                
                        notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
                        break;

Modified: trunk/blender/source/blender/editors/armature/pose_select.c
===================================================================
--- trunk/blender/source/blender/editors/armature/pose_select.c 2013-10-17 
14:10:03 UTC (rev 60822)
+++ trunk/blender/source/blender/editors/armature/pose_select.c 2013-10-17 
14:19:03 UTC (rev 60823)
@@ -64,6 +64,35 @@
 
 /* ***************** Pose Select Utilities ********************* */
 
+/* Utility method for changing the selection status of a bone */
+ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select)
+ {
+       /* sanity checks */
+       // XXX: actually, we can probably still get away with no object - at 
most we have no updates
+       if (ELEM4(NULL, ob, ob->pose, pchan, pchan->bone))
+               return; 
+       
+       /* can only change selection state if bone can be modified */   
+       if (PBONE_SELECTABLE(ob, pchan->bone)) {
+               bArmature *arm = ob->data;
+               
+               /* change selection state */
+               if (select)
+                       pchan->bone->flag |= BONE_SELECTED;
+               else
+                       pchan->bone->flag &= ~BONE_SELECTED;
+               
+               // TODO: select and activate corresponding vgroup?
+               
+               /* tag necessary depsgraph updates 
+                * (see rna_Bone_select_update() in rna_armature.c for details)
+                */
+               if (arm->flag & ARM_HAS_VIZ_DEPS) {
+                       DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+               }
+       }
+ }
+
 /* called from editview.c, for mode-less pose selection */
 /* assumes scene obact and basact is still on old situation */
 int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, 
short hits,

Modified: trunk/blender/source/blender/editors/include/ED_armature.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_armature.h  2013-10-17 
14:10:03 UTC (rev 60822)
+++ trunk/blender/source/blender/editors/include/ED_armature.h  2013-10-17 
14:19:03 UTC (rev 60823)
@@ -168,6 +168,7 @@
 void ED_armature_exit_posemode(struct bContext *C, struct Base *base);
 void ED_armature_enter_posemode(struct bContext *C, struct Base *base);
 void ED_pose_deselectall(struct Object *ob, int test);
+void ED_pose_bone_select(struct Object *ob, struct bPoseChannel *pchan, bool 
select);
 void ED_pose_recalculate_paths(struct Scene *scene, struct Object *ob);
 struct Object *ED_pose_object_from_context(struct bContext *C);
 

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

Reply via email to