Update to writefile: do not save TEMPORARY or NO_COPY CD layers!
authorBastien Montagne <montagne29@wanadoo.fr>
Tue, 10 Sep 2013 15:24:31 +0000 (15:24 +0000)
committerBastien Montagne <montagne29@wanadoo.fr>
Tue, 10 Sep 2013 15:24:31 +0000 (15:24 +0000)
Neede for next commit (split normals API).

source/blender/blenkernel/BKE_customdata.h
source/blender/blenkernel/intern/customdata.c
source/blender/blenloader/intern/writefile.c

index 72aae1b2361021dc0bd24a059687f6e28756301b..d47d03fe903cf4cf8fc941af1db510a4a6c4c322 100644 (file)
@@ -56,6 +56,7 @@ extern const CustomDataMask CD_MASK_EDITMESH;
 extern const CustomDataMask CD_MASK_DERIVEDMESH;
 extern const CustomDataMask CD_MASK_BMESH;
 extern const CustomDataMask CD_MASK_FACECORNERS;
+extern const CustomDataMask CD_MASK_EVERYTHING;
 
 /* for ORIGINDEX layer type, indicates no original index for this element */
 #define ORIGINDEX_NONE -1
index d69ec6a9597803205182612f9ccf666ce209fca8..1188c1b7f4aa194a80793dbc5471c7be6716812e 100644 (file)
@@ -1217,6 +1217,16 @@ const CustomDataMask CD_MASK_BMESH =
 const CustomDataMask CD_MASK_FACECORNERS =
     CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_MTEXPOLY | CD_MASK_MLOOPUV |
     CD_MASK_MLOOPCOL;
+const CustomDataMask CD_MASK_EVERYTHING =
+    CD_MASK_MVERT | CD_MASK_MSTICKY /* DEPRECATED */ | CD_MASK_MDEFORMVERT | CD_MASK_MEDGE | CD_MASK_MFACE |
+    CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_ORIGINDEX | CD_MASK_NORMAL /* | CD_MASK_POLYINDEX */ | CD_MASK_PROP_FLT |
+    CD_MASK_PROP_INT | CD_MASK_PROP_STR | CD_MASK_ORIGSPACE | CD_MASK_ORCO | CD_MASK_MTEXPOLY | CD_MASK_MLOOPUV |
+    CD_MASK_MLOOPCOL | CD_MASK_TANGENT | CD_MASK_MDISPS | CD_MASK_PREVIEW_MCOL | CD_MASK_CLOTH_ORCO | CD_MASK_RECAST |
+    /* BMESH ONLY START */
+    CD_MASK_MPOLY | CD_MASK_MLOOP | CD_MASK_SHAPE_KEYINDEX | CD_MASK_SHAPEKEY | CD_MASK_BWEIGHT | CD_MASK_CREASE |
+    CD_MASK_ORIGSPACE_MLOOP | CD_MASK_PREVIEW_MLOOPCOL | CD_MASK_BM_ELEM_PYPTR |
+    /* BMESH ONLY END */
+    CD_MASK_PAINT_MASK | CD_MASK_GRID_PAINT_MASK | CD_MASK_MVERT_SKIN | CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE;
 
 static const LayerTypeInfo *layerType_getInfo(int type)
 {
index 90405583544ddee9d35b05488c19fa62c308df7a..875e9cb687167c523f69244fde79a3a7240ff13d 100644 (file)
@@ -1747,16 +1747,20 @@ static void write_grid_paint_mask(WriteData *wd, int count, GridPaintMask *grid_
 
 static void write_customdata(WriteData *wd, ID *id, int count, CustomData *data, int partial_type, int partial_count)
 {
+       CustomData data_tmp;
        int i;
 
+       /* This copy will automatically ignore/remove layers set as NO_COPY (and TEMPORARY). */
+       CustomData_copy(data, &data_tmp, CD_MASK_EVERYTHING, CD_REFERENCE, count);
+
        /* write external customdata (not for undo) */
-       if (data->external && !wd->current)
-               CustomData_external_write(data, id, CD_MASK_MESH, count, 0);
+       if (data_tmp.external && !wd->current)
+               CustomData_external_write(&data_tmp, id, CD_MASK_MESH, count, 0);
 
-       writestruct(wd, DATA, "CustomDataLayer", data->maxlayer, data->layers);
+       writestruct_at_address(wd, DATA, "CustomDataLayer", data_tmp.maxlayer, data->layers, data_tmp.layers);
 
-       for (i=0; i<data->totlayer; i++) {
-               CustomDataLayer *layer= &data->layers[i];
+       for (i = 0; i < data_tmp.totlayer; i++) {
+               CustomDataLayer *layer= &data_tmp.layers[i];
                const char *structname;
                int structnum, datasize;
 
@@ -1792,8 +1796,10 @@ static void write_customdata(WriteData *wd, ID *id, int count, CustomData *data,
                }
        }
 
-       if (data->external)
-               writestruct(wd, DATA, "CustomDataExternal", 1, data->external);
+       if (data_tmp.external)
+               writestruct_at_address(wd, DATA, "CustomDataExternal", 1, data->external, data_tmp.external);
+
+       CustomData_free(&data_tmp, count);
 }
 
 static void write_meshs(WriteData *wd, ListBase *idbase)