Merging r42896 through r42944 from trunk into soc-2911-tomato
[blender.git] / source / blender / blenloader / intern / readfile.c
index 8a14e9416df8a45a3ceb1cec67a3e12ec7f218f3..59a34a706eef327dee0d954721a12544996d81cb 100644 (file)
@@ -5969,10 +5969,29 @@ static void lib_link_group(FileData *fd, Main *main)
 
 /* ***************** READ MOVIECLIP *************** */
 
+static void direct_link_movieReconstruction(FileData *fd, MovieTrackingReconstruction *reconstruction)
+{
+       reconstruction->cameras= newdataadr(fd, reconstruction->cameras);
+}
+
+static void direct_link_movieTracks(FileData *fd, ListBase *tracksbase)
+{
+       MovieTrackingTrack *track;
+
+       link_list(fd, tracksbase);
+
+       track= tracksbase->first;
+       while(track) {
+               track->markers= newdataadr(fd, track->markers);
+
+               track= track->next;
+       }
+}
+
 static void direct_link_movieclip(FileData *fd, MovieClip *clip)
 {
        MovieTracking *tracking= &clip->tracking;
-       MovieTrackingTrack *track;
+       MovieTrackingObject *object;
 
        if(fd->movieclipmap) clip->cache= newmclipadr(fd, clip->cache);
        else clip->cache= NULL;
@@ -5980,16 +5999,8 @@ static void direct_link_movieclip(FileData *fd, MovieClip *clip)
        if(fd->movieclipmap) clip->tracking.camera.intrinsics= newmclipadr(fd, clip->tracking.camera.intrinsics);
        else clip->tracking.camera.intrinsics= NULL;
 
-       tracking->reconstruction.cameras= newdataadr(fd, tracking->reconstruction.cameras);
-
-       link_list(fd, &tracking->tracks);
-
-       track= tracking->tracks.first;
-       while(track) {
-               track->markers= newdataadr(fd, track->markers);
-
-               track= track->next;
-       }
+       direct_link_movieTracks(fd, &tracking->tracks);
+       direct_link_movieReconstruction(fd, &tracking->reconstruction);
 
        clip->tracking.act_track= newdataadr(fd, clip->tracking.act_track);
 
@@ -6000,6 +6011,16 @@ static void direct_link_movieclip(FileData *fd, MovieClip *clip)
        clip->tracking.stabilization.ok= 0;
        clip->tracking.stabilization.scaleibuf= NULL;
        clip->tracking.stabilization.rot_track= newdataadr(fd, clip->tracking.stabilization.rot_track);
+
+       link_list(fd, &tracking->objects);
+
+       object= tracking->objects.first;
+       while(object) {
+               direct_link_movieTracks(fd, &object->tracks);
+               direct_link_movieReconstruction(fd, &object->reconstruction);
+
+               object= object->next;
+       }
 }
 
 static void lib_link_movieclip(FileData *fd, Main *main)
@@ -12773,8 +12794,43 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                }
                {
                        MovieClip *clip;
-                       for(clip= main->movieclip.first; clip; clip= clip->id.next) {
+                       Object *ob;
+
+                       for (clip= main->movieclip.first; clip; clip= clip->id.next) {
+                               MovieTracking *tracking= &clip->tracking;
+                               MovieTrackingObject *tracking_object= tracking->objects.first;
+
                                clip->proxy.build_tc_flag|= IMB_TC_RECORD_RUN_NO_GAPS;
+
+                               if(!tracking->settings.object_distance)
+                                       tracking->settings.object_distance= 1.0f;
+
+                               if(tracking->objects.first == NULL)
+                                       BKE_tracking_new_object(tracking, "Camera");
+
+                               while(tracking_object) {
+                                       if(!tracking_object->scale)
+                                               tracking_object->scale= 1.0f;
+
+                                       tracking_object= tracking_object->next;
+                               }
+                       }
+
+                       for (ob= main->object.first; ob; ob= ob->id.next) {
+                               bConstraint *con;
+                               for (con= ob->constraints.first; con; con=con->next) {
+                                       bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
+
+                                       if(!cti)
+                                               continue;
+
+                                       if(cti->type==CONSTRAINT_TYPE_OBJECTSOLVER) {
+                                               bObjectSolverConstraint *data= (bObjectSolverConstraint *)con->data;
+
+                                               if(data->invmat[3][3]==0.0f)
+                                                       unit_m4(data->invmat);
+                                       }
+                               }
                        }
                }
        }