Page Menu
Home
Search
Configure Global Search
Log In
Paste
P3031
D14583, edits
Active
Public
Actions
Authored by
Campbell Barton (campbellbarton)
on Jun 27 2022, 1:16 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Tags
None
Subscribers
None
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index 96b6f7a53b0..e5cec3b7bf2 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -231,8 +231,8 @@ enum {
* As users/developers may not want their paths exposed in publicly distributed files.
*/
G_FILE_RECOVER_WRITE = (1 << 24),
- /** BMesh option to save as older mesh format */
- /* #define G_FILE_MESH_COMPAT (1 << 26) */
+ /** Option to save as older mesh format (v2.67 to v3.2). */
+ G_FILE_MESH_COMPAT_WRITE = (1 << 26),
/* #define G_FILE_GLSL_NO_ENV_LIGHTING (1 << 28) */ /* deprecated */
};
@@ -240,7 +240,8 @@ enum {
* Run-time only #G.fileflags which are never read or written to/from Blend files.
* This means we can change the values without worrying about do-versions.
*/
-#define G_FILE_FLAG_ALL_RUNTIME (G_FILE_NO_UI | G_FILE_RECOVER_READ | G_FILE_RECOVER_WRITE)
+#define G_FILE_FLAG_ALL_RUNTIME \
+ (G_FILE_NO_UI | G_FILE_MESH_COMPAT_WRITE | G_FILE_RECOVER_READ | G_FILE_RECOVER_WRITE)
/** #Global.moving, signals drawing in (3d) window to denote transform */
enum {
diff --git a/source/blender/blenloader/BLO_read_write.h b/source/blender/blenloader/BLO_read_write.h
index 536c3989aff..5d0bb8231d1 100644
--- a/source/blender/blenloader/BLO_read_write.h
+++ b/source/blender/blenloader/BLO_read_write.h
@@ -181,6 +181,8 @@ void BLO_write_string(BlendWriter *writer, const char *data_ptr);
*/
bool BLO_write_is_undo(BlendWriter *writer);
+bool BLO_write_use_legacy_mesh_format(const BlendWriter *writer);
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 68171f26a66..c35dfa1f764 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -422,6 +422,8 @@ typedef struct {
/** When true, write to #WriteData.current, could also call 'is_undo'. */
bool use_memfile;
+ bool use_legacy_mesh_format;
+
/**
* Wrap writing, so we can use zstd or
* other compression types later, see: G_FILE_COMPRESS
@@ -1093,6 +1095,7 @@ static bool write_file_handle(Main *mainvar,
blo_split_main(&mainlist, mainvar);
wd = mywrite_begin(ww, compare, current);
+ wd->use_legacy_mesh_format = (write_flags & G_FILE_MESH_COMPAT_WRITE) != 0;
BlendWriter writer = {wd};
sprintf(buf,
@@ -1605,4 +1608,9 @@ bool BLO_write_is_undo(BlendWriter *writer)
return writer->wd->use_memfile;
}
+bool BLO_write_use_legacy_mesh_format(const BlendWriter *writer)
+{
+ return writer->wd->use_legacy_mesh_format;
+}
+
/** \} */
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index a170fa9902b..61c75dfaa6a 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -3108,6 +3108,9 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
/* set compression flag */
SET_FLAG_FROM_TEST(fileflags, RNA_boolean_get(op->ptr, "compress"), G_FILE_COMPRESS);
+ SET_FLAG_FROM_TEST(
+ fileflags, RNA_boolean_get(op->ptr, "use_legacy_mesh_format"), G_FILE_MESH_COMPAT_WRITE);
+
const bool ok = wm_file_write(C, path, fileflags, remap_mode, use_save_as_copy, op->reports);
if ((op->flag & OP_IS_INVOKE) == 0) {
@@ -3199,6 +3202,13 @@ void WM_OT_save_as_mainfile(wmOperatorType *ot)
"Save Copy",
"Save a copy of the actual working state but does not make saved file active");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ prop = RNA_def_boolean(
+ ot->srna,
+ "use_legacy_mesh_format",
+ false,
+ "Legacy Mesh Format",
+ "Save mesh data with a legacy format that can be read by earlier versions");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Event Timeline
Campbell Barton (campbellbarton)
created this paste.
Jun 27 2022, 1:16 PM
Campbell Barton (campbellbarton)
mentioned this in
D14583: Blend Write: Add option for legacy mesh format
.
Jun 27 2022, 1:37 PM
Log In to Comment