Depsgraph: optimize out evaluation of hidden objects
This change makes it so that objects which are temporary hidden from the viewport (the icon toggle in outliner) do not affect on the performance of the viewport. The attached file demonstrates the issue. Before this change hiding the object does not change FPS, after this change FPS goes high when the object is hidden. F13435936 Changing the object temporary visibility is already expected to tag scene for bases updates, which flushes down the stream to the object visibility update. So the only remaining topic was to ensure the graph does a special round of visibility update on such changes. Differential Revision: https://developer.blender.org/D15813
This commit is contained in:
parent
5a1b733a67
commit
ac20970bc2
Notes:
blender-bot
2023-02-13 14:35:53 +01:00
Referenced by commit bb3a021427
, Fix T101004: Crash when invisible object becomes visible
Referenced by issue #101004, Regression: Segfault when CTRL key hit
Referenced by issue #100754, Hidden objects still affect viewport performance when they are hidden as collection
|
@ -371,6 +371,10 @@ void deg_graph_flush_updates(Depsgraph *graph)
|
|||
while (op_node != nullptr) {
|
||||
/* Tag operation as required for update. */
|
||||
op_node->flag |= DEPSOP_FLAG_NEEDS_UPDATE;
|
||||
/* Tag depsgraph visibility update when visibility operation is tagged for an update. */
|
||||
if (op_node->opcode == OperationCode::VISIBILITY) {
|
||||
graph->need_update_nodes_visibility = true;
|
||||
}
|
||||
/* Inform corresponding ID and component nodes about the change. */
|
||||
ComponentNode *comp_node = op_node->owner;
|
||||
IDNode *id_node = comp_node->owner;
|
||||
|
|
|
@ -34,10 +34,14 @@ void deg_evaluate_object_node_visibility(::Depsgraph *depsgraph, IDNode *id_node
|
|||
|
||||
DEG_debug_print_eval(depsgraph, __func__, object->id.name, &object->id);
|
||||
|
||||
const int required_flags = (graph->mode == DAG_EVAL_VIEWPORT) ? BASE_ENABLED_VIEWPORT :
|
||||
BASE_ENABLED_RENDER;
|
||||
|
||||
const bool is_enabled = object->base_flag & required_flags;
|
||||
bool is_enabled;
|
||||
if (graph->mode == DAG_EVAL_VIEWPORT) {
|
||||
is_enabled = (object->base_flag & BASE_ENABLED_VIEWPORT) &&
|
||||
((object->base_flag & BASE_HIDDEN) == 0);
|
||||
}
|
||||
else {
|
||||
is_enabled = (object->base_flag & BASE_ENABLED_RENDER);
|
||||
};
|
||||
|
||||
if (id_node->is_enabled_on_eval != is_enabled) {
|
||||
id_node->is_enabled_on_eval = is_enabled;
|
||||
|
|
Loading…
Reference in New Issue