Fix performance issue when tagging relations for update
The relations update code does tagging needed to ensure that the array of bases is updated when relations are updated. It was done by tagging the Scene ID node, and potentially recursing into all dependent depsgraph nodes. If there is a driver on a scene property it was unnecessarily re-evaluated. This solves the slow behavior of adding objects in the test file from #117335. Pull Request: https://projects.blender.org/blender/blender/pulls/117403
This commit is contained in:
committed by
Sergey Sharybin
parent
1903f58eac
commit
29aaa2922d
@@ -281,15 +281,19 @@ void DEG_graph_tag_relations_update(Depsgraph *graph)
|
|||||||
DEG_DEBUG_PRINTF(graph, TAG, "%s: Tagging relations for update.\n", __func__);
|
DEG_DEBUG_PRINTF(graph, TAG, "%s: Tagging relations for update.\n", __func__);
|
||||||
deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph);
|
deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph);
|
||||||
deg_graph->need_update_relations = true;
|
deg_graph->need_update_relations = true;
|
||||||
/* NOTE: When relations are updated, it's quite possible that
|
|
||||||
* we've got new bases in the scene. This means, we need to
|
/* NOTE: When relations are updated, it's quite possible that we've got new bases in the scene.
|
||||||
* re-create flat array of bases in view layer.
|
* This means, we need to re-create flat array of bases in view layer. */
|
||||||
*
|
/* TODO(sergey): It is expected that bases manipulation tags scene for update to tag bases array
|
||||||
* TODO(sergey): Try to make it so we don't flush updates
|
* for re-creation. Once it is ensured to happen from all places this implicit tag can be
|
||||||
* to the whole depsgraph. */
|
* removed. */
|
||||||
deg::IDNode *id_node = deg_graph->find_id_node(°_graph->scene->id);
|
deg::IDNode *id_node = deg_graph->find_id_node(°_graph->scene->id);
|
||||||
if (id_node != nullptr) {
|
if (id_node != nullptr) {
|
||||||
id_node->tag_update(deg_graph, deg::DEG_UPDATE_SOURCE_RELATIONS);
|
graph_id_tag_update(deg_graph->bmain,
|
||||||
|
deg_graph,
|
||||||
|
°_graph->scene->id,
|
||||||
|
ID_RECALC_BASE_FLAGS,
|
||||||
|
deg::DEG_UPDATE_SOURCE_RELATIONS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user