diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-08 16:37:31 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-08 17:07:31 +0300 |
commit | 2a1e8287114de1c1907d9ef458342c433449c3fa (patch) | |
tree | 86a0b5e13363f6bd98950c99fbdc78939fc92cad | |
parent | 19c14f0c8ac6236eedff2a1c5f3581b4fca79bf1 (diff) |
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.
-rw-r--r-- | source/blender/depsgraph/DEG_depsgraph_query.h | 8 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_query.cc | 31 |
2 files changed, 22 insertions, 17 deletions
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); } |