Commit: 2a1e8287114de1c1907d9ef458342c433449c3fa
Author: Sergey Sharybin
Date:   Wed Nov 8 14:37:31 2017 +0100
Branches: blender2.8
https://developer.blender.org/rB2a1e8287114de1c1907d9ef458342c433449c3fa

Depsgraph: Use iterator over flat array for depsgraph_query

This way iteration order is much more predictable. This also solves issue with
randomly failing Cycles regression tests.

===================================================================

M       source/blender/depsgraph/DEG_depsgraph_query.h
M       source/blender/depsgraph/intern/depsgraph_query.cc

===================================================================

diff --git a/source/blender/depsgraph/DEG_depsgraph_query.h 
b/source/blender/depsgraph/DEG_depsgraph_query.h
index 59158ef0454..ddd0f16b3bf 100644
--- a/source/blender/depsgraph/DEG_depsgraph_query.h
+++ b/source/blender/depsgraph/DEG_depsgraph_query.h
@@ -33,8 +33,6 @@
 #ifndef __DEG_DEPSGRAPH_QUERY_H__
 #define __DEG_DEPSGRAPH_QUERY_H__
 
-#include "BLI_ghash.h"
-
 #include "DEG_depsgraph.h"
 
 struct ID;
@@ -102,9 +100,9 @@ typedef struct DEGObjectsIteratorData {
         */
        struct Object temp_dupli_object;
 
-       /* **** ghash **** */
-       struct GHashIterator gh_iter;
-
+       /* **** Iteration ober ID nodes **** */
+       size_t id_node_index;
+       size_t num_id_nodes;
 } DEGObjectsIteratorData;
 
 void DEG_objects_iterator_begin(struct BLI_Iterator *iter, 
DEGObjectsIteratorData *data);
diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc 
b/source/blender/depsgraph/intern/depsgraph_query.cc
index 4431df80b69..864db49f601 100644
--- a/source/blender/depsgraph/intern/depsgraph_query.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query.cc
@@ -256,23 +256,29 @@ static void deg_objects_iterator_step(BLI_Iterator *iter, 
DEG::IDDepsNode *id_no
 
 void DEG_objects_iterator_begin(BLI_Iterator *iter, DEGObjectsIteratorData 
*data)
 {
-       Depsgraph *graph = data->graph;
+       Depsgraph *depsgraph = data->graph;
+       DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph 
*>(depsgraph);
+       const size_t num_id_nodes = deg_graph->id_nodes.size();
 
-       iter->data = data;
+       if (num_id_nodes == 0) {
+               iter->valid = false;
+               return;
+       }
 
+       /* TODO(sergey): What evaluation type we want here? */
        DEG_evaluation_context_init(&data->eval_ctx, DAG_EVAL_RENDER);
-       data->eval_ctx.scene_layer = DEG_get_evaluated_scene_layer(graph);
+       data->eval_ctx.scene_layer = DEG_get_evaluated_scene_layer(depsgraph);
 
+       iter->data = data;
        data->dupli_parent = NULL;
        data->dupli_list = NULL;
        data->dupli_object_next = NULL;
        data->dupli_object_current = NULL;
-       data->scene = DEG_get_evaluated_scene(graph);
-
-       DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
-       BLI_ghashIterator_init(&data->gh_iter, deg_graph->id_hash);
+       data->scene = DEG_get_evaluated_scene(depsgraph);
+       data->id_node_index = 0;
+       data->num_id_nodes = num_id_nodes;
 
-       DEG::IDDepsNode *id_node = (DEG::IDDepsNode *) 
BLI_ghashIterator_getValue(&data->gh_iter);
+       DEG::IDDepsNode *id_node = deg_graph->id_nodes[data->id_node_index];
        deg_objects_iterator_step(iter, id_node);
 
        if (iter->skip) {
@@ -283,6 +289,8 @@ void DEG_objects_iterator_begin(BLI_Iterator *iter, 
DEGObjectsIteratorData *data
 void DEG_objects_iterator_next(BLI_Iterator *iter)
 {
        DEGObjectsIteratorData *data = (DEGObjectsIteratorData *)iter->data;
+       Depsgraph *depsgraph = data->graph;
+       DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph 
*>(depsgraph);
        do {
                if (data->dupli_list) {
                        if (deg_objects_dupli_iterator_next(iter)) {
@@ -297,14 +305,13 @@ void DEG_objects_iterator_next(BLI_Iterator *iter)
                        }
                }
 
-               BLI_ghashIterator_step(&data->gh_iter);
-               if (BLI_ghashIterator_done(&data->gh_iter)) {
+               ++data->id_node_index;
+               if (data->id_node_index == data->num_id_nodes) {
                        iter->valid = false;
                        return;
                }
 
-               DEG::IDDepsNode *id_node = (DEG::IDDepsNode *) 
BLI_ghashIterator_getValue(&data->gh_iter);
-
+               DEG::IDDepsNode *id_node = 
deg_graph->id_nodes[data->id_node_index];
                deg_objects_iterator_step(iter, id_node);
        } while (iter->skip);
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to