option to save as older mesh format (ifdef'd for now)
authorCampbell Barton <ideasman42@gmail.com>
Tue, 27 Dec 2011 13:17:58 +0000 (13:17 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 27 Dec 2011 13:17:58 +0000 (13:17 +0000)
source/blender/blenkernel/BKE_global.h
source/blender/blenloader/intern/writefile.c
source/blender/makesdna/DNA_mesh_types.h
source/blender/windowmanager/intern/wm_operators.c

index 5ccdd7c04af30628e628f28d769993d299840a08..7668d5392daa403f4ab806bfe0abae7b96a56c6b 100644 (file)
@@ -141,6 +141,7 @@ typedef struct Global {
 #define G_FILE_RECOVER                  (1 << 23)
 #define G_FILE_RELATIVE_REMAP   (1 << 24)
 #define G_FILE_HISTORY                  (1 << 25)
+#define G_FILE_MESH_COMPAT              (1 << 26)                              /* BMesh option to save as older mesh format */
 
 /* G.windowstate */
 #define G_WINDOWSTATE_USERDEF          0
index 00710e67cf2eac3fe21149e0ade0b9a3d7afde1e..f4575c3b1e305663ed67a431d2557bce376d164b 100644 (file)
@@ -174,6 +174,10 @@ typedef struct {
        MemFile *compare, *current;
        
        int tot, count, error, memsize;
+
+#ifdef USE_MESH_FORWARDS_COMAT
+       char use_mesh_compat; /* option to save with older mesh format */
+#endif
 } WriteData;
 
 static WriteData *writedata_new(int file)
@@ -2574,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));
 
@@ -2617,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_MESH_FORWARDS_COMAT
+       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);
 
index f8062aeccc7ffe8a8ab7e7e5a32dda703b584d11..4bca7e7a77f37802d889b9c217472b17e6e9e6f9 100644 (file)
@@ -192,4 +192,12 @@ typedef struct TFace {
 
 #define MESH_MAX_VERTS 2000000000L
 
+/* this is so we can save bmesh files that load in trunk, ignoring NGons
+ * will eventually be removed */
+
+#if 0 /* enable in bmesh branch only for now */
+#define USE_MESH_FORWARDS_COMAT
+#endif
+
+
 #endif
index b6f59418f0a7f96c885dc6801b09e000c218275a..db8f9794c886f21ba8c648e01cb3839ea49de646 100644 (file)
@@ -46,6 +46,7 @@
 #include "DNA_scene_types.h"
 #include "DNA_userdef_types.h"
 #include "DNA_windowmanager_types.h"
+#include "DNA_mesh_types.h" /* only for USE_MESH_FORWARDS_COMAT */
 
 #include "BLF_translation.h"
 
@@ -2011,6 +2012,9 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot)
        RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file");
        RNA_def_boolean(ot->srna, "relative_remap", 1, "Remap Relative", "Remap relative paths when saving in a different directory");
        RNA_def_boolean(ot->srna, "copy", 0, "Save Copy", "Save a copy of the actual working state but does not make saved file active");
+#ifdef USE_MESH_FORWARDS_COMAT
+       RNA_def_boolean(ot->srna, "use_mesh_compat", 0, "Legacy Mesh Format", "Save using legacy mesh format (no ngons)");
+#endif
 }
 
 /* *************** save file directly ******** */