Sculpt Branch:
[blender-staging.git] / source / blender / blenloader / intern / writefile.c
index 3d654f5ebc97e627b0df557f115713390b08a5be..bc0db6d4cd1cd1f44e007400ec32dee09b24352a 100644 (file)
@@ -1222,12 +1222,6 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
                        writestruct(wd, DATA, "MDefInfluence", mmd->totinfluence, mmd->dyninfluences);
                        writedata(wd, DATA, sizeof(int)*mmd->totvert, mmd->dynverts);
                }
-               else if (md->type==eModifierType_Multires) {
-                       MultiresModifierData *mmd = (MultiresModifierData*) md;
-
-                       if(mmd->undo_verts)
-                               writestruct(wd, DATA, "MVert", mmd->undo_verts_tot, mmd->undo_verts);
-               }
        }
 }
 
@@ -1448,15 +1442,17 @@ static void write_dverts(WriteData *wd, int count, MDeformVert *dvlist)
        }
 }
 
-static void write_mdisps(WriteData *wd, int count, MDisps *mdlist)
+static void write_mdisps(WriteData *wd, int count, MDisps *mdlist, int external)
 {
        if(mdlist) {
                int i;
                
                writestruct(wd, DATA, "MDisps", count, mdlist);
-               for(i = 0; i < count; ++i) {
-                       if(mdlist[i].disps)
-                               writedata(wd, DATA, sizeof(float)*3*mdlist[i].totdisp, mdlist[i].disps);
+               if(!external) {
+                       for(i = 0; i < count; ++i) {
+                               if(mdlist[i].disps)
+                                       writedata(wd, DATA, sizeof(float)*3*mdlist[i].totdisp, mdlist[i].disps);
+                       }
                }
        }
 }
@@ -1465,6 +1461,10 @@ static void write_customdata(WriteData *wd, int count, CustomData *data, int par
 {
        int i;
 
+       /* write external customdata */
+       if(data->external && !wd->current)
+               CustomData_external_write(data, CD_MASK_MESH, count, 0);
+
        writestruct(wd, DATA, "CustomDataLayer", data->maxlayer, data->layers);
 
        for (i=0; i<data->totlayer; i++) {
@@ -1477,7 +1477,7 @@ static void write_customdata(WriteData *wd, int count, CustomData *data, int par
                        write_dverts(wd, count, layer->data);
                }
                else if (layer->type == CD_MDISPS) {
-                       write_mdisps(wd, count, layer->data);
+                       write_mdisps(wd, count, layer->data, layer->flag & CD_FLAG_EXTERNAL);
                }
                else {
                        CustomData_file_write_info(layer->type, &structname, &structnum);
@@ -1494,6 +1494,9 @@ static void write_customdata(WriteData *wd, int count, CustomData *data, int par
                                printf("error: this CustomDataLayer must not be written to file\n");
                }
        }
+
+       if(data->external)
+               writestruct(wd, DATA, "CustomDataExternal", 1, data->external);
 }
 
 static void write_meshs(WriteData *wd, ListBase *idbase)