Merging r40265 through r40492 from trunk into soc-2011-tomato
[blender.git] / source / blender / editors / space_view3d / view3d_select.c
index 1c98397..3d2f353 100644 (file)
@@ -44,6 +44,7 @@
 #include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
+#include "DNA_tracking_types.h"
 
 #include "MEM_guardedalloc.h"
 
@@ -62,6 +63,8 @@
 #include "BKE_context.h"
 #include "BKE_paint.h"
 #include "BKE_armature.h"
+#include "BKE_movieclip.h"
+#include "BKE_tracking.h"
 
 
 #include "BIF_gl.h"
@@ -1375,6 +1378,7 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce
                if(hits>0) {
                        int has_bones= 0;
                        
+                       /* note: bundles are handling in the same way as bones */
                        for(a=0; a<hits; a++) if(buffer[4*a+3] & 0xFFFF0000) has_bones= 1;
 
                        /* note; shift+alt goes to group-flush-selecting */
@@ -1385,7 +1389,41 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce
                        }
                        
                        if(has_bones && basact) {
-                               if(ED_do_pose_selectbuffer(scene, basact, buffer, hits, extend) ) {     /* then bone is found */
+                               if(basact->object->type==OB_CAMERA) {
+                                       if(BASACT==basact) {
+                                               int i, hitresult;
+                                               MovieTrackingTrack *track;
+
+                                               for (i=0; i< hits; i++) {
+                                                       hitresult= buffer[3+(i*4)];
+
+                                                       /* if there's bundles in buffer select bundles first,
+                                                          so non-camera elements should be ignored in buffer */
+                                                       if(basact->selcol != (hitresult & 0xFFFF))
+                                                               continue;
+
+                                                       /* index of bundle is 1<<16-based. if there's no "bone" index
+                                                          in hight word, this buffer value belongs to camera,. not to bundle */
+                                                       if(buffer[4*i+3] & 0xFFFF0000) {
+                                                               track= BKE_tracking_indexed_bundle(&scene->clip->tracking, hitresult >> 16);
+
+                                                               if(TRACK_SELECTED(track) && extend) BKE_movieclip_deselect_track(scene->clip, track, TRACK_AREA_ALL);
+                                                               else BKE_movieclip_select_track(scene->clip, track, TRACK_AREA_ALL, extend);
+
+                                                               basact->flag|= SELECT;
+                                                               basact->object->flag= basact->flag;
+
+                                                               retval= 1;
+
+                                                               WM_event_add_notifier(C, NC_MOVIECLIP|ND_SELECT, track);
+                                                               WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
+
+                                                               break;
+                                                       }
+                                               }
+                                       }
+                               }
+                               else if(ED_do_pose_selectbuffer(scene, basact, buffer, hits, extend) ) {        /* then bone is found */
                                
                                        /* we make the armature selected: 
                                           not-selected active object in posemode won't work well for tools */