[Bf-blender-cvs] [30f6bc81f5b] undo-experiments-swap-reread-datablocks: Merge branch 'undo-experiments' into undo-experiments-swap-reread-datablocks
Bastien Montagne
noreply at git.blender.org
Thu Feb 6 18:35:44 CET 2020
Commit: 30f6bc81f5bfa203400778d7d1d172a4b644f7e8
Author: Bastien Montagne
Date: Thu Feb 6 18:35:30 2020 +0100
Branches: undo-experiments-swap-reread-datablocks
https://developer.blender.org/rB30f6bc81f5bfa203400778d7d1d172a4b644f7e8
Merge branch 'undo-experiments' into undo-experiments-swap-reread-datablocks
Conflicts:
source/blender/blenloader/intern/readfile.c
===================================================================
===================================================================
diff --cc source/blender/blenloader/intern/readfile.c
index 04d4416ad40,749bfea2aac..f2f6a09321a
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@@ -2711,7 -2729,31 +2729,31 @@@ static void direct_link_id_override_pro
link_list_ex(fd, &op->operations, direct_link_id_override_property_operation_cb);
}
- static void direct_link_id(FileData *fd, ID *id)
-static void direct_link_id(FileData *fd, ID *id);
++static void direct_link_id(FileData *fd, ID *id, ID *id_old);
+ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree);
+ static void direct_link_collection(FileData *fd, Collection *collection);
+
-static void direct_link_id_private_id(FileData *fd, ID *id)
++static void direct_link_id_private_id(FileData *fd, ID *id, ID *id_old)
+ {
+ /* Handle 'private IDs'. */
+ bNodeTree **nodetree = BKE_ntree_ptr_from_id(id);
+ if (nodetree != NULL && *nodetree != NULL) {
+ *nodetree = newdataadr(fd, *nodetree);
- direct_link_id(fd, (ID *)*nodetree);
++ direct_link_id(fd, (ID *)*nodetree, id_old != NULL ? (ID *)ntreeFromID(id_old) : NULL);
+ direct_link_nodetree(fd, *nodetree);
+ }
+
+ if (GS(id->name) == ID_SCE) {
+ Scene *scene = (Scene *)id;
+ if (scene->master_collection != NULL) {
+ scene->master_collection = newdataadr(fd, scene->master_collection);
- direct_link_id(fd, &scene->master_collection->id);
++ direct_link_id(fd, &scene->master_collection->id, &((Scene *)id_old)->master_collection->id);
+ direct_link_collection(fd, scene->master_collection);
+ }
+ }
+ }
+
-static void direct_link_id(FileData *fd, ID *id)
++static void direct_link_id(FileData *fd, ID *id, ID *id_old)
{
/*link direct data of ID properties*/
if (id->properties) {
@@@ -2727,6 -2769,18 +2769,34 @@@
id->tag = 0;
id->flag &= ~LIB_INDIRECT_WEAK_LINK;
+ /* NOTE: It is important to not clear the recalc flags for undo/redo.
+ * Preserving recalc flags on redo/undo is the only way to make dependency graph detect
+ * that animation is to be evaluated on undo/redo. If this is not enforced by the recalc
+ * flags dependency graph does not do animation update to avoid loss of unkeyed changes.,
+ * which conflicts with undo/redo of changes to animation data itself.
+ *
+ * But for regular file load we clear the flag, since the flags might have been changed since
+ * the version the file has been saved with. */
- if (!fd->memfile) {
++ if (fd->memfile == NULL) {
+ id->recalc = 0;
++ id->recalc_undo_accumulated = 0;
++ }
++ else {
++ if (fd->undo_direction < 0) {
++ /* We are coming from the future (i.e. do an actual undo, and not a redo), and we found an
++ * old (aka existing) ID: we use its 'accumulated recalc flags since last memfile undo step
++ * saving' as recalc flags of our newly read ID. */
++ if (id_old != NULL) {
++ id->recalc = id_old->recalc_undo_accumulated;
++ }
++ }
++ else {
++ /* We are coming from the past (i.e. do a redo), and we found an, we use saved 'accumulated
++ * recalc flags since last memfile undo step saving' as recalc flags of our newly read ID. */
++ id->recalc = id->recalc_undo_accumulated;
++ }
+ }
+
/* Link direct data of overrides. */
if (id->override_library) {
id->override_library = newdataadr(fd, id->override_library);
@@@ -2738,6 -2792,9 +2808,9 @@@
if (drawdata) {
BLI_listbase_clear((ListBase *)drawdata);
}
+
+ /* Handle 'private IDs'. */
- direct_link_id_private_id(fd, id);
++ direct_link_id_private_id(fd, id, id_old);
}
/** \} */
@@@ -9628,7 -9216,7 +9249,7 @@@ static BHead *read_libblock(FileData *f
}
/* init pointers direct data */
-- direct_link_id(fd, id);
++ direct_link_id(fd, id, id_old);
/* That way, we know which data-lock needs do_versions (required currently for linking). */
/* Note: doing this after direct_link_id(), which resets that field. */
More information about the Bf-blender-cvs
mailing list