Tracking: Cleanup, de-duplicate some code
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 27 Jan 2016 13:06:55 +0000 (14:06 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 27 Jan 2016 13:06:55 +0000 (14:06 +0100)
source/blender/editors/space_clip/tracking_ops_detect.c
source/blender/editors/space_clip/tracking_ops_intern.h
source/blender/editors/space_clip/tracking_select.c

index 1af6bbef0bc7fdc0ce22fd920c7a53855b5cbd04..992c347a6303517a2170cb6678ce1262184ec953 100644 (file)
@@ -54,6 +54,7 @@
 #include "RNA_define.h"
 
 #include "clip_intern.h"
+#include "tracking_ops_intern.h"
 
 /********************** detect features operator *********************/
 
@@ -105,16 +106,8 @@ static int detect_features_exec(bContext *C, wmOperator *op)
        }
 
        /* Deselect existing tracks. */
-       /* TODO(sergey): Could use deselect oeprator function for this. */
-       for (MovieTrackingTrack *track = tracksbase->first;
-            track != NULL;
-            track = track->next)
-       {
-               track->flag &= ~SELECT;
-               track->pat_flag &= ~SELECT;
-               track->search_flag &= ~SELECT;
-       }
-
+       ed_tracking_delect_all_tracks(tracksbase);
+       /* Run detector. */
        BKE_tracking_detect_harris(tracking,
                                   tracksbase,
                                   ibuf,
index 36af428b31feb8e0ac87c4c486297db545e4e3e7..6ac9287c914e8d93cb2b1b42d550f3316df3e220 100644 (file)
 #define __TRACKING_OPS_INTERN_H__
 
 struct bContext;
-struct SpaceClip;
+struct ListBase;
 struct MovieClip;
+struct SpaceClip;
+
+/* tracking_utils.c */
 
 void clip_tracking_clear_invisible_track_selection(struct SpaceClip *sc,
                                                    struct MovieClip *clip);
@@ -42,4 +45,9 @@ void clip_tracking_clear_invisible_track_selection(struct SpaceClip *sc,
 void clip_tracking_show_cursor(struct bContext *C);
 void clip_tracking_hide_cursor(struct bContext *C);
 
+/* tracking_select.h */
+
+void ed_tracking_delect_all_tracks(struct ListBase *tracks_base);
+void ed_tracking_delect_all_plane_tracks(struct ListBase *plane_tracks_base);
+
 #endif /* __TRACKING_OPS_INTERN_H__ */
\ No newline at end of file
index 8a2bf17c6676423811d403227a27ee3b9bbcc60f..b9b53a55fcee9024ac2f529c2bbc1bb786c6394f 100644 (file)
@@ -244,22 +244,22 @@ static MovieTrackingPlaneTrack *find_nearest_plane_track(SpaceClip *sc, ListBase
        return plane_track;
 }
 
-static void delect_all_tracks(ListBase *tracks_base)
+void ed_tracking_delect_all_tracks(ListBase *tracks_base)
 {
        MovieTrackingTrack *track;
        for (track = tracks_base->first;
-            track;
+            track != NULL;
             track = track->next)
        {
                BKE_tracking_track_flag_clear(track, TRACK_AREA_ALL, SELECT);
        }
 }
 
-static void delect_all_plane_tracks(ListBase *plane_tracks_base)
+void ed_tracking_delect_all_plane_tracks(ListBase *plane_tracks_base)
 {
        MovieTrackingPlaneTrack *plane_track;
        for (plane_track = plane_tracks_base->first;
-            plane_track;
+            plane_track != NULL;
             plane_track = plane_track->next)
        {
                plane_track->flag &= ~SELECT;
@@ -292,7 +292,7 @@ static int mouse_select(bContext *C, float co[2], int extend)
        }
 
        if (!extend) {
-               delect_all_plane_tracks(plane_tracks_base);
+               ed_tracking_delect_all_plane_tracks(plane_tracks_base);
        }
 
        if (track) {
@@ -321,7 +321,7 @@ static int mouse_select(bContext *C, float co[2], int extend)
        }
        else if (plane_track) {
                if (!extend) {
-                       delect_all_tracks(tracksbase);
+                       ed_tracking_delect_all_tracks(tracksbase);
                }
 
                if (PLANE_TRACK_VIEW_SELECTED(plane_track)) {