diff options
-rw-r--r-- | source/blender/blenloader/BLO_read_write.h | 2 | ||||
-rw-r--r-- | source/blender/blenloader/BLO_writefile.h | 1 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 14 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 14 |
4 files changed, 28 insertions, 3 deletions
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/BLO_writefile.h b/source/blender/blenloader/BLO_writefile.h index 93f1ea5090f..a2c2c036f5a 100644 --- a/source/blender/blenloader/BLO_writefile.h +++ b/source/blender/blenloader/BLO_writefile.h @@ -44,6 +44,7 @@ struct BlendFileWriteParams { uint use_save_versions : 1; /** On write, restore paths after editing them (see #BLO_WRITE_PATH_REMAP_RELATIVE). */ uint use_save_as_copy : 1; + uint use_legacy_mesh_format : 1; uint use_userdef : 1; const struct BlendThumbnail *thumb; }; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 68171f26a66..e34abbd32ec 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 @@ -1083,6 +1085,7 @@ static bool write_file_handle(Main *mainvar, MemFile *current, int write_flags, bool use_userdef, + const bool use_legacy_mesh_format, const BlendThumbnail *thumb) { BHead bhead; @@ -1093,6 +1096,7 @@ static bool write_file_handle(Main *mainvar, blo_split_main(&mainlist, mainvar); wd = mywrite_begin(ww, compare, current); + wd->use_legacy_mesh_format = use_legacy_mesh_format; BlendWriter writer = {wd}; sprintf(buf, @@ -1432,7 +1436,8 @@ bool BLO_write_file(Main *mainvar, } /* actual file writing */ - const bool err = write_file_handle(mainvar, &ww, NULL, NULL, write_flags, use_userdef, thumb); + const bool err = write_file_handle( + mainvar, &ww, NULL, NULL, write_flags, use_userdef, params->use_legacy_mesh_format, thumb); ww.close(&ww); @@ -1476,7 +1481,7 @@ bool BLO_write_file_mem(Main *mainvar, MemFile *compare, MemFile *current, int w bool use_userdef = false; const bool err = write_file_handle( - mainvar, NULL, compare, current, write_flags, use_userdef, NULL); + mainvar, NULL, compare, current, write_flags, use_userdef, false, NULL); return (err == 0); } @@ -1605,4 +1610,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 a4d5bed21da..b796176fb3a 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1719,6 +1719,7 @@ static bool wm_file_write(bContext *C, int fileflags, eBLO_WritePathRemap remap_mode, bool use_save_as_copy, + const bool use_legacy_mesh_format, ReportList *reports) { Main *bmain = CTX_data_main(C); @@ -1830,6 +1831,7 @@ static bool wm_file_write(bContext *C, .remap_mode = remap_mode, .use_save_versions = true, .use_save_as_copy = use_save_as_copy, + .use_legacy_mesh_format = use_legacy_mesh_format, .thumb = thumb, }, reports)) { @@ -3064,6 +3066,8 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op) char path[FILE_MAX]; const bool is_save_as = (op->type->invoke == wm_save_as_mainfile_invoke); const bool use_save_as_copy = is_save_as && RNA_boolean_get(op->ptr, "copy"); + const bool use_legacy_mesh_format = is_save_as && + RNA_boolean_get(op->ptr, "use_legacy_mesh_format"); /* We could expose all options to the users however in most cases remapping * existing relative paths is a good default. @@ -3107,7 +3111,8 @@ 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); - const bool ok = wm_file_write(C, path, fileflags, remap_mode, use_save_as_copy, op->reports); + const bool ok = wm_file_write( + C, path, fileflags, remap_mode, use_save_as_copy, use_legacy_mesh_format, op->reports); if ((op->flag & OP_IS_INVOKE) == 0) { /* OP_IS_INVOKE is set when the operator is called from the GUI. @@ -3198,6 +3203,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)) |