diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 44039ad59ee..42446f8c752 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -9137,7 +9137,9 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const int ta id->icon_id = 0; id->newid = NULL; /* Needed because .blend may have been saved with crap value here... */ id->orig_id = NULL; - id->recalc = 0; + + // XXX: Need to investigate how safe is it. + // id->recalc = 0; /* this case cannot be direct_linked: it's just the ID part */ if (bhead->code == ID_LINK_PLACEHOLDER) { diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc index 36c6d246097..e9fb579a0e2 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder.cc @@ -204,7 +204,7 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph) /* Re-tag IDs for update if it was tagged before the relations * update tag. */ for (IDNode *id_node : graph->id_nodes) { - ID *id = id_node->id_orig; + ID *id_orig = id_node->id_orig; id_node->finalize_build(graph); int flag = 0; /* Tag rebuild if special evaluation flags changed. */ @@ -219,10 +219,11 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph) flag |= ID_RECALC_COPY_ON_WRITE; /* This means ID is being added to the dependency graph first * time, which is similar to "ob-visible-change" */ - if (GS(id->name) == ID_OB) { + if (GS(id_orig->name) == ID_OB) { flag |= ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY; } } + flag |= id_orig->recalc; if (flag != 0) { graph_id_tag_update(bmain, graph, id_node->id_orig, flag, DEG_UPDATE_SOURCE_RELATIONS); } diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index 583191490d2..bfb21304224 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -438,6 +438,27 @@ const char *update_source_as_string(eUpdateSource source) return "UNKNOWN"; } +int deg_recalc_flags_for_legacy_zero() +{ + return ID_RECALC_ALL & ~(ID_RECALC_PSYS_ALL | ID_RECALC_ANIMATION); +} + +int deg_recalc_flags_effective(Depsgraph *graph, int flags) +{ + if (graph != NULL) { + if (graph->mode == DAG_EVAL_RENDER) { + return 0; + } + if (!graph->is_active) { + return 0; + } + } + if (flags == 0) { + return deg_recalc_flags_for_legacy_zero(); + } + return flags; +} + /* Special tag function which tags all components which needs to be tagged * for update flag=0. * @@ -453,7 +474,7 @@ void deg_graph_node_tag_zero(Main *bmain, } ID *id = id_node->id_orig; /* TODO(sergey): Which recalc flags to set here? */ - id_node->id_cow->recalc |= ID_RECALC_ALL & ~(ID_RECALC_PSYS_ALL | ID_RECALC_ANIMATION); + id_node->id_cow->recalc |= deg_recalc_flags_for_legacy_zero(); GHASH_FOREACH_BEGIN (ComponentNode *, comp_node, id_node->components) { if (comp_node->type == NodeType::ANIMATION) { continue; @@ -598,6 +619,9 @@ void graph_id_tag_update( if (id_node != NULL) { id_node->id_cow->recalc |= flag; } + if (update_source == DEG_UPDATE_SOURCE_USER_EDIT) { + id->recalc |= deg_recalc_flags_effective(graph, flag); + } int current_flag = flag; while (current_flag != 0) { IDRecalcFlag tag = (IDRecalcFlag)(1 << bitscan_forward_clear_i(¤t_flag)); @@ -780,12 +804,17 @@ static void deg_graph_clear_id_node_func(void *__restrict data_v, id_node->is_user_modified = false; id_node->id_cow->recalc &= ~ID_RECALC_ALL; + id_node->id_orig->recalc &= ~ID_RECALC_ALL; /* Clear embedded node trees too. */ bNodeTree *ntree_cow = ntreeFromID(id_node->id_cow); if (ntree_cow) { ntree_cow->id.recalc &= ~ID_RECALC_ALL; } + bNodeTree *ntree_orig = ntreeFromID(id_node->id_orig); + if (ntree_orig) { + ntree_orig->id.recalc &= ~ID_RECALC_ALL; + } } void DEG_ids_clear_recalc(Main *UNUSED(bmain), Depsgraph *depsgraph)