Merging r46725 through r46963 from trunk into soc-2011-tomato
[blender.git] / source / blender / blenloader / intern / writefile.c
index f14837f..29cfd7f 100644 (file)
@@ -133,6 +133,7 @@ Any case: direct data is ALWAYS after the lib block
 #include "DNA_world_types.h"
 #include "DNA_windowmanager_types.h"
 #include "DNA_movieclip_types.h"
+#include "DNA_mask_types.h"
 
 #include "MEM_guardedalloc.h" // MEM_freeN
 #include "BLI_bitmap.h"
@@ -2754,6 +2755,48 @@ static void write_movieclips(WriteData *wd, ListBase *idbase)
        mywrite(wd, MYWRITE_FLUSH, 0);
 }
 
+static void write_masks(WriteData *wd, ListBase *idbase)
+{
+       Mask *mask;
+
+       mask = idbase->first;
+       while (mask) {
+               if (mask->id.us > 0 || wd->current) {
+                       MaskObject *maskobj;
+
+                       writestruct(wd, ID_MSK, "Mask", 1, mask);
+
+                       if (mask->adt)
+                               write_animdata(wd, mask->adt);
+
+                       for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) {
+                               MaskSpline *spline;
+
+                               writestruct(wd, DATA, "MaskObject", 1, maskobj);
+
+                               for (spline = maskobj->splines.first; spline; spline = spline->next) {
+                                       int i;
+
+                                       writestruct(wd, DATA, "MaskSpline", 1, spline);
+                                       writestruct(wd, DATA, "MaskSplinePoint", spline->tot_point, spline->points);
+
+                                       for (i = 0; i < spline->tot_point; i++) {
+                                               MaskSplinePoint *point = &spline->points[i];
+
+                                               if (point->tot_uw)
+                                                       writestruct(wd, DATA, "MaskSplinePointUW", point->tot_uw, point->uw);
+                                       }
+                               }
+                       }
+               }
+
+               mask = mask->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 */
@@ -2837,7 +2880,9 @@ static int write_file_handle(Main *mainvar, int handle, MemFile *compare, MemFil
                write_windowmanagers(wd, &mainvar->wm);
                write_screens  (wd, &mainvar->screen);
        }
+       write_gpencils (wd, &mainvar->gpencil);
        write_movieclips (wd, &mainvar->movieclip);
+       write_masks    (wd, &mainvar->mask);
        write_scenes   (wd, &mainvar->scene);
        write_curves   (wd, &mainvar->curve);
        write_mballs   (wd, &mainvar->mball);
@@ -2862,7 +2907,6 @@ static int write_file_handle(Main *mainvar, int handle, MemFile *compare, MemFil
        write_nodetrees(wd, &mainvar->nodetree);
        write_brushes  (wd, &mainvar->brush);
        write_scripts  (wd, &mainvar->script);
-       write_gpencils (wd, &mainvar->gpencil);
        write_libraries(wd,  mainvar->next);
 
        if (write_user_block) {