Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <b.mont29@gmail.com>2020-03-17 14:09:06 +0300
committerBastien Montagne <b.mont29@gmail.com>2020-03-17 14:10:52 +0300
commitb02a25b7e10e5713052f5a6ccf4127ad4d995f25 (patch)
tree6cc49eb98bba6d624c0cbf2ee61bd3a755df41a1
parent055863d9c1f0195765f421b1f87e445dd070ea00 (diff)
Add accumulated recalc flags to IDs.
Those accumulated flags get cleared every time an undo step is written to memfile. Preliminary work for undo-speedup. Part of T60695/D6580.
-rw-r--r--source/blender/blenloader/intern/writefile.c17
-rw-r--r--source/blender/depsgraph/intern/depsgraph_tag.cc4
-rw-r--r--source/blender/makesdna/DNA_ID.h8
3 files changed, 28 insertions, 1 deletions
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index a92404b2372..1e50cda3eaf 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -703,7 +703,7 @@ void IDP_WriteProperty(const IDProperty *prop, void *wd)
IDP_WriteProperty_OnlyData(prop, wd);
}
-static void write_iddata(void *wd, const ID *id)
+static void write_iddata(WriteData *wd, ID *id)
{
/* ID_WM's id->properties are considered runtime only, and never written in .blend file. */
if (id->properties && !ELEM(GS(id->name), ID_WM)) {
@@ -731,6 +731,11 @@ static void write_iddata(void *wd, const ID *id)
}
}
}
+
+ /* Clear the accumulated recalc flags in case of undo step saving. */
+ if (wd->use_memfile) {
+ id->recalc_undo_accumulated = 0;
+ }
}
static void write_previews(WriteData *wd, const PreviewImage *prv_orig)
@@ -1131,6 +1136,11 @@ static void write_nodetree_nolib(WriteData *wd, bNodeTree *ntree)
for (sock = ntree->outputs.first; sock; sock = sock->next) {
write_node_socket_interface(wd, sock);
}
+
+ /* Clear the accumulated recalc flags in case of undo step saving. */
+ if (wd->use_memfile) {
+ ntree->id.recalc_undo_accumulated = 0;
+ }
}
/**
@@ -2425,6 +2435,11 @@ static void write_collection_nolib(WriteData *wd, Collection *collection)
for (CollectionChild *child = collection->children.first; child; child = child->next) {
writestruct(wd, DATA, CollectionChild, 1, child);
}
+
+ /* Clear the accumulated recalc flags in case of undo step saving. */
+ if (wd->use_memfile) {
+ collection->id.recalc_undo_accumulated = 0;
+ }
}
static void write_collection(WriteData *wd, Collection *collection)
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index b019c079dab..8decb9f6b87 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -814,12 +814,16 @@ void DEG_ids_check_recalc(
static void deg_graph_clear_id_recalc_flags(ID *id)
{
+ /* Keep incremental track of used recalc flags, to get proper update when undoing. */
+ id->recalc_undo_accumulated |= id->recalc;
id->recalc &= ~ID_RECALC_ALL;
bNodeTree *ntree = ntreeFromID(id);
/* Clear embedded node trees too. */
if (ntree) {
+ ntree->id.recalc_undo_accumulated |= ntree->id.recalc;
ntree->id.recalc &= ~ID_RECALC_ALL;
}
+ /* XXX And what about scene's master collection here? */
}
void DEG_ids_clear_recalc(Main *UNUSED(bmain), Depsgraph *depsgraph)
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index 40916cbdc61..f2923c7f144 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -245,6 +245,12 @@ typedef struct ID {
int us;
int icon_id;
int recalc;
+ /**
+ * Used by undo code. Value of recalc is stored there when reading an ID from memfile, and not
+ * touched by anything, which means it can be used as 'reference' recalc value for the next undo
+ * step, when going backward (i.e. actual undo, redo can just use recalc value directly).
+ */
+ int recalc_undo_accumulated;
/**
* A session-wide unique identifier for a given ID, that remain the same across potential
@@ -252,6 +258,8 @@ typedef struct ID {
*/
unsigned int session_uuid;
+ char _pad[4];
+
IDProperty *properties;
/** Reference linked ID which this one overrides. */