Merging r37732 through r37862 from trunk into soc-2011-tomato
[blender.git] / source / blender / blenloader / intern / writefile.c
index d5192eaf09c3e27d6f309e99e9d98a037ad9ef55..4689a69a87f3a4596c49b6252d50b3bf496743ba 100644 (file)
@@ -129,6 +129,7 @@ Any case: direct data is ALWAYS after the lib block
 #include "DNA_vfont_types.h"
 #include "DNA_world_types.h"
 #include "DNA_windowmanager_types.h"
+#include "DNA_movieclip_types.h"
 
 #include "MEM_guardedalloc.h" // MEM_freeN
 #include "BLI_blenlib.h"
@@ -2175,6 +2176,9 @@ static void write_screens(WriteData *wd, ListBase *scrbase)
                                else if(sl->spacetype==SPACE_USERPREF) {
                                        writestruct(wd, DATA, "SpaceUserPref", 1, sl);
                                }
+                               else if(sl->spacetype==SPACE_CLIP) {
+                                       writestruct(wd, DATA, "SpaceClip", 1, sl);
+                               }
 
                                sl= sl->next;
                        }
@@ -2406,6 +2410,43 @@ static void write_scripts(WriteData *wd, ListBase *idbase)
        }
 }
 
+static void write_movieclips(WriteData *wd, ListBase *idbase)
+{
+       MovieClip *clip;
+
+       clip= idbase->first;
+       while(clip) {
+               if(clip->id.us>0 || wd->current) {
+                       MovieTrackingTrack *track;
+                       MovieTrackingBundle *bundle;
+                       writestruct(wd, ID_MC, "MovieClip", 1, clip);
+
+                       if (clip->adt) write_animdata(wd, clip->adt);
+
+                       track= clip->tracking.tracks.first;
+                       while(track) {
+                               writestruct(wd, DATA, "MovieTrackingTrack", 1, track);
+                               if(track->markers)
+                                       writedata(wd, DATA, track->markersnr*sizeof(MovieTrackingMarker), track->markers);
+
+                               track= track->next;
+                       }
+
+                       bundle= clip->tracking.bundles.first;
+                       while(bundle) {
+                               writestruct(wd, DATA, "MovieTrackingBundle", 1, bundle);
+
+                               bundle= bundle->next;
+                       }
+               }
+
+               clip= clip->id.next;
+       }
+
+       /* flush helps the compression for undo-save */
+       mywrite(wd, MYWRITE_FLUSH, 0);
+}
+
 /* context is usually defined by WM, two cases where no WM is available:
  * - for forward compatibility, curscreen has to be saved
  * - for undofile, curscene needs to be saved */
@@ -2506,6 +2547,7 @@ static int write_file_handle(Main *mainvar, int handle, MemFile *compare, MemFil
        write_brushes  (wd, &mainvar->brush);
        write_scripts  (wd, &mainvar->script);
        write_gpencils (wd, &mainvar->gpencil);
+       write_movieclips (wd, &mainvar->movieclip);
        write_libraries(wd,  mainvar->next);
 
        if (write_user_block) {