Tracking: Add missing animation fix when deleting plane track
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 19 Dec 2017 11:58:42 +0000 (12:58 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 19 Dec 2017 11:58:42 +0000 (12:58 +0100)
source/blender/editors/space_clip/clip_intern.h
source/blender/editors/space_clip/clip_utils.c
source/blender/editors/space_clip/tracking_ops.c

index 14393c6968b8461157616c92a846cebd8bd7f8e2..ae15834a1d9be5806db4e23029bd7f03d8de65fa 100644 (file)
@@ -139,6 +139,8 @@ void clip_graph_tracking_iterate(struct SpaceClip *sc, bool selected_only, bool
 void clip_delete_track(struct bContext *C, struct MovieClip *clip, struct MovieTrackingTrack *track);
 void clip_delete_marker(struct bContext *C, struct MovieClip *clip, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker);
 
+void clip_delete_plane_track(struct bContext *C, struct MovieClip *clip, struct MovieTrackingPlaneTrack *plane_track);
+
 void clip_view_center_to_point(SpaceClip *sc, float x, float y);
 
 void clip_draw_cfra(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene);
index ba04fa82a739c360107cd93df79d46ad8bbb8f40..e7853cb2a0cf0f9df2d661440b9d1348c410bd4e 100644 (file)
@@ -196,7 +196,7 @@ void clip_delete_track(bContext *C, MovieClip *clip, MovieTrackingTrack *track)
                                            track,
                                            rna_path, sizeof(rna_path));
        BKE_animdata_fix_paths_remove(&clip->id, rna_path);
-
+       /* Delete track itself. */
        BKE_tracking_track_free(track);
        BLI_freelinkN(tracksbase, track);
        /* Send notifiers. */
@@ -224,6 +224,28 @@ void clip_delete_marker(bContext *C, MovieClip *clip, MovieTrackingTrack *track,
        }
 }
 
+void clip_delete_plane_track(bContext *C,
+                             MovieClip *clip,
+                             MovieTrackingPlaneTrack *plane_track)
+{
+       MovieTracking *tracking = &clip->tracking;
+       ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
+       /* Delete f-curves associated with the track (such as weight, i.e.) */
+       /* Escaped object name, escaped track name, rest of the path. */
+       char rna_path[MAX_NAME * 4 + 64];
+       BKE_tracking_get_rna_path_for_plane_track(tracking,
+                                                 plane_track,
+                                                 rna_path, sizeof(rna_path));
+       BKE_animdata_fix_paths_remove(&clip->id, rna_path);
+       /* Delete the plane track itself. */
+       BKE_tracking_plane_track_free(plane_track);
+       BLI_freelinkN(plane_tracks_base, plane_track);
+       /* TODO(sergey): Any notifiers to be sent here? */
+       (void) C;
+       /* Inform dependency graph. */
+       DAG_id_tag_update(&clip->id, 0);
+}
+
 void clip_view_center_to_point(SpaceClip *sc, float x, float y)
 {
        int width, height;
index f32071b81dc4e3bd0355e139e81a7eb7e9ae2012..db891dba29408522d6536c3a042d56a4b7007f7b 100644 (file)
@@ -226,7 +226,6 @@ static int delete_track_exec(bContext *C, wmOperator *UNUSED(op))
        MovieClip *clip = ED_space_clip_get_clip(sc);
        MovieTracking *tracking = &clip->tracking;
        bool changed = false;
-
        /* Delete selected plane tracks. */
        ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
        for (MovieTrackingPlaneTrack *plane_track = plane_tracks_base->first,
@@ -235,14 +234,11 @@ static int delete_track_exec(bContext *C, wmOperator *UNUSED(op))
             plane_track = next_plane_track)
        {
                next_plane_track = plane_track->next;
-
                if (PLANE_TRACK_VIEW_SELECTED(plane_track)) {
-                       BKE_tracking_plane_track_free(plane_track);
-                       BLI_freelinkN(plane_tracks_base, plane_track);
+                       clip_delete_plane_track(C, clip, plane_track);
                        changed = true;
                }
        }
-
        /* Remove selected point tracks (they'll also be removed from planes which
         * uses them).
         */
@@ -257,14 +253,11 @@ static int delete_track_exec(bContext *C, wmOperator *UNUSED(op))
                        changed = true;
                }
        }
-
        /* Nothing selected now, unlock view so it can be scrolled nice again. */
        sc->flag &= ~SC_LOCK_SELECTION;
-
        if (changed) {
                WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
        }
-
        return OPERATOR_FINISHED;
 }