WIP loading bmesh in trunk, some conversion functions for this purpose.
[blender.git] / source / blender / blenloader / intern / writefile.c
index ad5eda038723a764b74b6efa7fcb142a2ac7741e..e9c14404057dcc361e17ab3f78133deb9dc460ff 100644 (file)
@@ -174,6 +174,10 @@ typedef struct {
        MemFile *compare, *current;
        
        int tot, count, error, memsize;
+
+#ifdef USE_BMESH_SAVE_AS_COMPAT
+       char use_mesh_compat; /* option to save with older mesh format */
+#endif
 } WriteData;
 
 static WriteData *writedata_new(int file)
@@ -1691,27 +1695,9 @@ static void write_meshs(WriteData *wd, ListBase *idbase)
 
                        writedata(wd, DATA, sizeof(void *)*mesh->totcol, mesh->mat);
 
-                       if(mesh->pv) {
-                               write_customdata(wd, &mesh->id, mesh->pv->totvert, &mesh->vdata, -1, 0);
-                               write_customdata(wd, &mesh->id, mesh->pv->totedge, &mesh->edata,
-                                       CD_MEDGE, mesh->totedge);
-                               write_customdata(wd, &mesh->id, mesh->pv->totface, &mesh->fdata,
-                                       CD_MFACE, mesh->totface);
-                       }
-                       else {
-                               write_customdata(wd, &mesh->id, mesh->totvert, &mesh->vdata, -1, 0);
-                               write_customdata(wd, &mesh->id, mesh->totedge, &mesh->edata, -1, 0);
-                               write_customdata(wd, &mesh->id, mesh->totface, &mesh->fdata, -1, 0);
-                       }
-
-                       /* PMV data */
-                       if(mesh->pv) {
-                               writestruct(wd, DATA, "PartialVisibility", 1, mesh->pv);
-                               writedata(wd, DATA, sizeof(unsigned int)*mesh->pv->totvert, mesh->pv->vert_map);
-                               writedata(wd, DATA, sizeof(int)*mesh->pv->totedge, mesh->pv->edge_map);
-                               writestruct(wd, DATA, "MFace", mesh->pv->totface, mesh->pv->old_faces);
-                               writestruct(wd, DATA, "MEdge", mesh->pv->totedge, mesh->pv->old_edges);
-                       }
+                       write_customdata(wd, &mesh->id, mesh->totvert, &mesh->vdata, -1, 0);
+                       write_customdata(wd, &mesh->id, mesh->totedge, &mesh->edata, -1, 0);
+                       write_customdata(wd, &mesh->id, mesh->totface, &mesh->fdata, -1, 0);
                }
                mesh= mesh->id.next;
        }
@@ -2592,7 +2578,10 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar)
        fg.curscene= screen->scene;
        fg.displaymode= G.displaymode;
        fg.winpos= G.winpos;
-       fg.fileflags= (fileflags & ~(G_FILE_NO_UI|G_FILE_RELATIVE_REMAP));      // prevent to save this, is not good convention, and feature with concerns...
+
+       /* prevent to save this, is not good convention, and feature with concerns... */
+       fg.fileflags= (fileflags & ~(G_FILE_NO_UI|G_FILE_RELATIVE_REMAP|G_FILE_MESH_COMPAT));
+
        fg.globalf= G.f;
        BLI_strncpy(fg.filename, mainvar->name, sizeof(fg.filename));
 
@@ -2635,7 +2624,11 @@ static int write_file_handle(Main *mainvar, int handle, MemFile *compare, MemFil
        blo_split_main(&mainlist, mainvar);
 
        wd= bgnwrite(handle, compare, current);
-       
+
+#ifdef USE_BMESH_SAVE_AS_COMPAT
+       wd->use_mesh_compat = (write_flags & G_FILE_MESH_COMPAT) != 0;
+#endif
+
        sprintf(buf, "BLENDER%c%c%.3d", (sizeof(void*)==8)?'-':'_', (ENDIAN_ORDER==B_ENDIAN)?'V':'v', BLENDER_VERSION);
        mywrite(wd, buf, 12);