From b852db57ba24adfcfaa0ada7e9ff513a79a399a2 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 17 Mar 2020 12:29:36 +0100 Subject: Add experimental global undo speedup. The feature is hidden behind an experimental option, you'll have to enable it in the preferences to try it. This feature is not yet considered fully stable, crashes may happen, as well as .blend file corruptions (very unlikely, but still possible). In a nutshell, the ideas behind this code are to: * Detect unchanged IDs across an undo step. * Reuse as much as possible existing IDs memory, even when its content did change. * Re-use existing depsgraphs instead of building new ones from scratch. * Store accumulated recalc flags, to avoid needless re-compute of things that did not change, when the ID itself is detected as modified. See T60695 and D6580 for more technical details. --- source/blender/blenkernel/intern/blender_undo.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern/blender_undo.c') diff --git a/source/blender/blenkernel/intern/blender_undo.c b/source/blender/blenkernel/intern/blender_undo.c index 9ccc53b6318..bb705e2295c 100644 --- a/source/blender/blenkernel/intern/blender_undo.c +++ b/source/blender/blenkernel/intern/blender_undo.c @@ -61,7 +61,10 @@ #define UNDO_DISK 0 -bool BKE_memfile_undo_decode(MemFileUndoData *mfu, bContext *C) +bool BKE_memfile_undo_decode(MemFileUndoData *mfu, + const int undo_direction, + const bool use_old_bmain_data, + bContext *C) { Main *bmain = CTX_data_main(C); char mainstr[sizeof(bmain->name)]; @@ -76,8 +79,12 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu, bContext *C) success = BKE_blendfile_read(C, mfu->filename, &(const struct BlendFileReadParams){0}, NULL); } else { - success = BKE_blendfile_read_from_memfile( - C, &mfu->memfile, &(const struct BlendFileReadParams){0}, NULL); + struct BlendFileReadParams params = {0}; + params.undo_direction = undo_direction > 0 ? 1 : -1; + if (!use_old_bmain_data) { + params.skip_flags |= BLO_READ_SKIP_UNDO_OLD_MAIN; + } + success = BKE_blendfile_read_from_memfile(C, &mfu->memfile, ¶ms, NULL); } /* Restore, bmain has been re-allocated. */ -- cgit v1.2.3