Depsgraph: Report overall number of cycles detected
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 20 Feb 2018 16:16:41 +0000 (17:16 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 21 Feb 2018 09:11:43 +0000 (10:11 +0100)
Handy to quickly see if a fix fixed any of the cycles in a real rig,
or whether it's introduced new ones.

source/blender/depsgraph/intern/builder/deg_builder_cycle.cc

index e30b9b444902882fd524fa370d5be314aa90df87..c9fa35bd5511144a601a2b463fe0a631e376e29b 100644 (file)
@@ -87,6 +87,7 @@ void deg_graph_detect_cycles(Depsgraph *graph)
        BLI_Stack *traversal_stack = BLI_stack_new(sizeof(StackEntry),
                                                   "DEG detect cycles stack");
 
+       int num_cycles = 0;
        foreach (OperationDepsNode *node, graph->operations) {
                bool has_inlinks = false;
                foreach (DepsRelation *rel, node->inlinks) {
@@ -136,6 +137,7 @@ void deg_graph_detect_cycles(Depsgraph *graph)
                                        }
                                        /* TODO(sergey): So called russian roulette cycle solver. */
                                        rel->flag |= DEPSREL_FLAG_CYCLIC;
+                                       ++num_cycles;
                                }
                                else if (to_state == NODE_NOT_VISITED) {
                                        StackEntry new_entry;
@@ -157,6 +159,10 @@ void deg_graph_detect_cycles(Depsgraph *graph)
        }
 
        BLI_stack_free(traversal_stack);
+
+       if (num_cycles != 0) {
+               printf("Detected %d dependency cycles\n", num_cycles);
+       }
 }
 
 }  // namespace DEG