Fix #113182: Crash when animating Viewport visibility of Curves / GPv3 object

This is actually a deeper issue, which roots to the fact that updating
relations of the dependency graph does not properly handle cases when an
operation was previously skipped from evaluation (i.e. as a visibility
optimization).

The fix is to preserve needs-update flag throughout relations update of
a dependency graph, similar to the entry tags.

Pull Request: https://projects.blender.org/blender/blender/pulls/120477
This commit is contained in:
Sergey Sharybin
2024-04-10 16:26:31 +02:00
committed by Sergey Sharybin
parent 99ebc1f7d3
commit 70b3b018c1
2 changed files with 22 additions and 1 deletions

View File

@@ -406,6 +406,12 @@ void DepsgraphNodeBuilder::begin_build()
saved_entry_tags_.append_as(op_node);
}
for (const OperationNode *op_node : graph_->operations) {
if (op_node->flag & DEPSOP_FLAG_NEEDS_UPDATE) {
needs_update_operations_.append_as(op_node);
}
}
/* Make sure graph has no nodes left from previous state. */
graph_->clear_all_nodes();
graph_->operations.clear();
@@ -537,6 +543,16 @@ void DepsgraphNodeBuilder::tag_previously_tagged_nodes()
* that originally node was explicitly tagged for user update. */
operation_node->tag_update(graph_, DEG_UPDATE_SOURCE_USER_EDIT);
}
/* Restore needs-update flags since the previous state of the dependency graph, ensuring the
* previously-skipped operations are properly re-evaluated when needed. */
for (const OperationKey &operation_key : needs_update_operations_) {
OperationNode *operation_node = find_operation_node(operation_key);
if (operation_node == nullptr) {
continue;
}
operation_node->flag |= DEPSOP_FLAG_NEEDS_UPDATE;
}
}
void DepsgraphNodeBuilder::end_build()

View File

@@ -291,9 +291,14 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder {
};
protected:
/* Entry tags from the previous state of the dependency graph.
/* Entry tags and non-updated operations from the previous state of the dependency graph.
* The entry tags are operations which were directly tagged, the matching operations from the
* new dependency graph will be tagged. The needs-update operations are possibly indirectly
* modified operations, whose complementary part from the new dependency graph will only be
* marked as needs-update.
* Stored before the graph is re-created so that they can be transferred over. */
Vector<PersistentOperationKey> saved_entry_tags_;
Vector<PersistentOperationKey> needs_update_operations_;
struct BuilderWalkUserData {
DepsgraphNodeBuilder *builder;