Motion Tracking: move keyframe settings to per-tracking object settings
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 9 Oct 2012 10:33:18 +0000 (10:33 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 9 Oct 2012 10:33:18 +0000 (10:33 +0000)
release/scripts/startup/bl_ui/space_clip.py
source/blender/blenkernel/BKE_blender.h
source/blender/blenkernel/intern/tracking.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/space_clip/clip_draw.c
source/blender/editors/space_clip/tracking_ops.c
source/blender/makesdna/DNA_tracking_types.h
source/blender/makesrna/intern/rna_tracking.c

index 7732a0c6400f3574ab022b2bbaa75586494f5b72..17dd1c9cdab4c02c4b15ebb6272a52e4f026455d 100644 (file)
@@ -311,8 +311,8 @@ class CLIP_PT_tools_solve(CLIP_PT_tracking_panel, Panel):
 
         col = layout.column(align=True)
         col.active = not settings.use_tripod_solver
-        col.prop(settings, "keyframe_a")
-        col.prop(settings, "keyframe_b")
+        col.prop(tracking_object, "keyframe_a")
+        col.prop(tracking_object, "keyframe_b")
 
         col = layout.column(align=True)
         col.active = (tracking_object.is_camera and
index 741a001142fe622f6f31be08639eabe9442a9ccd..e1c79f8d6c142df7cd216a5244c95e18771bc335 100644 (file)
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         264
-#define BLENDER_SUBVERSION      1
+#define BLENDER_SUBVERSION      2
 
 /* 262 was the last editmesh release but its has compatibility code for bmesh data,
  * so set the minversion to 2.61 */
index c9d7ec3964f634ba59b9dc70a3c6f16864997090..7d2fd520c37b2799c1b4b8f4e2046f63bdfc6d16 100644 (file)
@@ -169,8 +169,6 @@ void BKE_tracking_settings_init(MovieTracking *tracking)
        tracking->settings.default_minimum_correlation = 0.75;
        tracking->settings.default_pattern_size = 11;
        tracking->settings.default_search_size = 61;
-       tracking->settings.keyframe1 = 1;
-       tracking->settings.keyframe2 = 30;
        tracking->settings.dist = 1;
        tracking->settings.object_distance = 1;
 
@@ -1179,6 +1177,8 @@ MovieTrackingObject *BKE_tracking_object_add(MovieTracking *tracking, const char
        tracking->objectnr = BLI_countlist(&tracking->objects) - 1;
 
        object->scale = 1.0f;
+       object->keyframe1 = 1;
+       object->keyframe2 = 30;
 
        BKE_tracking_object_unique_name(tracking, object);
 
@@ -2755,10 +2755,11 @@ static int reconstruct_refine_intrinsics_get_flags(MovieTracking *tracking, Movi
        return flags;
 }
 
-static int reconstruct_count_tracks_on_both_keyframes(MovieTracking *tracking, ListBase *tracksbase)
+static int reconstruct_count_tracks_on_both_keyframes(MovieTracking *tracking, MovieTrackingObject *object)
 {
+       ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
        int tot = 0;
-       int frame1 = tracking->settings.keyframe1, frame2 = tracking->settings.keyframe2;
+       int frame1 = object->keyframe1, frame2 = object->keyframe2;
        MovieTrackingTrack *track;
 
        track = tracksbase->first;
@@ -2779,13 +2780,11 @@ static int reconstruct_count_tracks_on_both_keyframes(MovieTracking *tracking, L
 int BKE_tracking_reconstruction_check(MovieTracking *tracking, MovieTrackingObject *object, char *error_msg, int error_size)
 {
 #ifdef WITH_LIBMV
-       ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
-
        if (tracking->settings.motion_flag & TRACKING_MOTION_MODAL) {
                /* TODO: check for number of tracks? */
                return TRUE;
        }
-       else if (reconstruct_count_tracks_on_both_keyframes(tracking, tracksbase) < 8) {
+       else if (reconstruct_count_tracks_on_both_keyframes(tracking, object) < 8) {
                BLI_strncpy(error_msg, "At least 8 common tracks on both of keyframes are needed for reconstruction",
                            error_size);
 
index fdb68d4cc1757e048372abac4439e135403e2ffc..606fd48dc2b8de932c4af69b823d3cb8eaf3a591 100644 (file)
@@ -8016,6 +8016,25 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                do_version_ntree_tex_coord_from_dupli_264(NULL, NULL, ntree);
        }
 
+       if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 2)) {
+               MovieClip *clip;
+
+               for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+                       MovieTracking *tracking = &clip->tracking;
+                       MovieTrackingObject *tracking_object;
+
+                       for (tracking_object = tracking->objects.first;
+                            tracking_object;
+                            tracking_object = tracking_object->next)
+                       {
+                               if (tracking_object->keyframe1 == 0 && tracking_object->keyframe2 == 0) {
+                                       tracking_object->keyframe1 = tracking->settings.keyframe1;
+                                       tracking_object->keyframe2 = tracking->settings.keyframe2;
+                               }
+                       }
+               }
+       }
+
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
        /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
 
index 5e940df2a30e11812a099734de33385acb8e43ba..d7936c1e2e897d9c14d19e23afdd0ea47f1516a7 100644 (file)
@@ -117,6 +117,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
        int *points, totseg, i, a;
        float sfra = SFRA, efra = EFRA, framelen = ar->winx / (efra - sfra + 1);
        MovieTracking *tracking = &clip->tracking;
+       MovieTrackingObject *act_object = BKE_tracking_object_get_active(tracking);
        MovieTrackingTrack *act_track = BKE_tracking_track_get_active(&clip->tracking);
        MovieTrackingReconstruction *reconstruction = BKE_tracking_get_active_reconstruction(tracking);
 
@@ -218,8 +219,8 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
 
        /* solver keyframes */
        glColor4ub(175, 255, 0, 255);
-       draw_keyframe(tracking->settings.keyframe1 + clip->start_frame - 1, CFRA, sfra, framelen, 2);
-       draw_keyframe(tracking->settings.keyframe2 + clip->start_frame - 1, CFRA, sfra, framelen, 2);
+       draw_keyframe(act_object->keyframe1 + clip->start_frame - 1, CFRA, sfra, framelen, 2);
+       draw_keyframe(act_object->keyframe2 + clip->start_frame - 1, CFRA, sfra, framelen, 2);
 
        /* movie clip animation */
        if ((sc->mode == SC_MODE_MASKEDIT) && sc->mask_info.mask) {
index 97f7d7bf132e61e5b3e8e3e720d37bd332e04d2c..8dc28bbaee0f2379f50fbb645a9f0e21b98c7e46 100644 (file)
@@ -1343,7 +1343,6 @@ static int solve_camera_initjob(bContext *C, SolveCameraJob *scj, wmOperator *op
        MovieClip *clip = ED_space_clip_get_clip(sc);
        Scene *scene = CTX_data_scene(C);
        MovieTracking *tracking = &clip->tracking;
-       MovieTrackingSettings *settings = &clip->tracking.settings;
        MovieTrackingObject *object = BKE_tracking_object_get_active(tracking);
        int width, height;
 
@@ -1359,7 +1358,7 @@ static int solve_camera_initjob(bContext *C, SolveCameraJob *scj, wmOperator *op
        scj->user = sc->user;
 
        scj->context = BKE_tracking_reconstruction_context_new(tracking, object,
-                                                              settings->keyframe1, settings->keyframe2, width, height);
+                                                              object->keyframe1, object->keyframe2, width, height);
 
        tracking->stats = MEM_callocN(sizeof(MovieTrackingStats), "solve camera stats");
 
@@ -2859,14 +2858,14 @@ static int set_solver_keyframe_exec(bContext *C, wmOperator *op)
        SpaceClip *sc = CTX_wm_space_clip(C);
        MovieClip *clip = ED_space_clip_get_clip(sc);
        MovieTracking *tracking = &clip->tracking;
-       MovieTrackingSettings *settings = &tracking->settings;
+       MovieTrackingObject *object = BKE_tracking_object_get_active(tracking);
        int keyframe = RNA_enum_get(op->ptr, "keyframe");
        int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, sc->user.framenr);
 
        if (keyframe == 0)
-               settings->keyframe1 = framenr;
+               object->keyframe1 = framenr;
        else
-               settings->keyframe2 = framenr;
+               object->keyframe2 = framenr;
 
        WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip);
 
index 1ab64ed1cc15c1ecd1b227085c9e04c6a73366b1..c6cefce29948fbb419a12fea18ff768302b74953 100644 (file)
@@ -162,7 +162,10 @@ typedef struct MovieTrackingSettings {
        short speed;            /* speed of tracking */
 
        /* ** reconstruction settings ** */
-       int keyframe1, keyframe2;   /* two keyframes for reconstrution initialization */
+       int keyframe1 DNA_DEPRECATED,
+               keyframe2 DNA_DEPRECATED;   /* two keyframes for reconstrution initialization
+                                            * were moved to per-tracking object settings
+                                            */
 
        /* which camera intrinsics to refine. uses on the REFINE_* flags */
        short refine_camera_intrinsics, pad2;
@@ -220,6 +223,8 @@ typedef struct MovieTrackingObject {
 
        ListBase tracks;        /* list of tracks use to tracking this object */
        MovieTrackingReconstruction reconstruction; /* reconstruction data for this object */
+
+       int keyframe1, keyframe2;   /* two keyframes for reconstrution initialization */
 } MovieTrackingObject;
 
 typedef struct MovieTrackingStats {
index 0c62a280935233c3c54e8445d560168e2424b800..4b744b160fcab76abf0126cbf43a940f64bb0fd1 100644 (file)
@@ -567,18 +567,6 @@ static void rna_def_trackingSettings(BlenderRNA *brna)
                                 "Limit speed of tracking to make visual feedback easier "
                                 "(this does not affect the tracking quality)");
 
-       /* keyframe_a */
-       prop = RNA_def_property(srna, "keyframe_a", PROP_INT, PROP_NONE);
-       RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
-       RNA_def_property_int_sdna(prop, NULL, "keyframe1");
-       RNA_def_property_ui_text(prop, "Keyframe A", "First keyframe used for reconstruction initialization");
-
-       /* keyframe_b */
-       prop = RNA_def_property(srna, "keyframe_b", PROP_INT, PROP_NONE);
-       RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
-       RNA_def_property_int_sdna(prop, NULL, "keyframe2");
-       RNA_def_property_ui_text(prop, "Keyframe B", "Second keyframe used for reconstruction initialization");
-
        /* intrinsics refinement during bundle adjustment */
        prop = RNA_def_property(srna, "refine_intrinsics", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "refine_camera_intrinsics");
@@ -1393,6 +1381,18 @@ static void rna_def_trackingObject(BlenderRNA *brna)
        RNA_def_property_float_default(prop, 1.0f);
        RNA_def_property_ui_text(prop, "Scale", "Scale of object solution in camera space");
        RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_trackingObject_flushUpdate");
+
+       /* keyframe_a */
+       prop = RNA_def_property(srna, "keyframe_a", PROP_INT, PROP_NONE);
+       RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+       RNA_def_property_int_sdna(prop, NULL, "keyframe1");
+       RNA_def_property_ui_text(prop, "Keyframe A", "First keyframe used for reconstruction initialization");
+
+       /* keyframe_b */
+       prop = RNA_def_property(srna, "keyframe_b", PROP_INT, PROP_NONE);
+       RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+       RNA_def_property_int_sdna(prop, NULL, "keyframe2");
+       RNA_def_property_ui_text(prop, "Keyframe B", "Second keyframe used for reconstruction initialization");
 }
 
 static void rna_def_trackingObjects(BlenderRNA *brna, PropertyRNA *cprop)