diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-05-29 16:57:14 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-05-30 15:07:23 +0300 |
commit | 5c17dbd991d64257f99b179343b453bb60823d44 (patch) | |
tree | 4a24c1f396c56c36d888bf807227f54b8742f072 /source/blender/depsgraph/intern/depsgraph_query_iter.cc | |
parent | 8ed723745e1bf939ed59062256cf7808219d8748 (diff) |
Fix missing Cycles 3D viewport updates when editing materials, lamps.
This introduces a new depsgraph API for getting updated datablocks,
rather than getting it from bpy.data.
* depsgraph.ids_updated gives a list of all datablocks in the depsgraph
which have been updated.
* depsgraph.id_type_updated('TYPE') is true if any datablock of the given
type has been added, removed or modified.
More API updates are coming to properly handle multiple depsgraphs and
finer update granularity, but this should make Cycles work again.
Diffstat (limited to 'source/blender/depsgraph/intern/depsgraph_query_iter.cc')
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_query_iter.cc | 74 |
1 files changed, 72 insertions, 2 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc index 1726c7c855a..843d379058a 100644 --- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc +++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc @@ -41,6 +41,7 @@ extern "C" { #include "BKE_anim.h" #include "BKE_idprop.h" #include "BKE_layer.h" +#include "BKE_node.h" #include "BKE_object.h" } /* extern "C" */ @@ -196,13 +197,13 @@ void DEG_iterator_objects_begin(BLI_Iterator *iter, DEGObjectIterData *data) 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->data = NULL; iter->valid = false; return; } - iter->data = data; data->dupli_parent = NULL; data->dupli_list = NULL; data->dupli_object_next = NULL; @@ -269,3 +270,72 @@ void DEG_iterator_objects_end(BLI_Iterator *iter) (void) iter; #endif } + +/* ************************ DEG ID ITERATOR ********************* */ + +static void DEG_iterator_ids_step(BLI_Iterator *iter, DEG::IDDepsNode *id_node, bool only_updated) +{ + ID *id_cow = id_node->id_cow; + + if (only_updated && !(id_cow->recalc & ID_RECALC_ALL)) { + bNodeTree *ntree = ntreeFromID(id_cow); + + /* Nodetree is considered part of the datablock. */ + if (!(ntree && (ntree->id.recalc & ID_RECALC_ALL))) { + iter->skip = true; + return; + } + } + + iter->current = id_cow; + iter->skip = false; +} + +void DEG_iterator_ids_begin(BLI_Iterator *iter, DEGIDIterData *data) +{ + 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) || + (data->only_updated && !DEG_id_type_any_updated(depsgraph))) { + iter->valid = false; + return; + } + + data->id_node_index = 0; + data->num_id_nodes = num_id_nodes; + + DEG::IDDepsNode *id_node = deg_graph->id_nodes[data->id_node_index]; + DEG_iterator_ids_step(iter, id_node, data->only_updated); + + if (iter->skip) { + DEG_iterator_ids_next(iter); + } +} + +void DEG_iterator_ids_next(BLI_Iterator *iter) +{ + DEGIDIterData *data = (DEGIDIterData *)iter->data; + Depsgraph *depsgraph = data->graph; + DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph); + + do { + iter->skip = false; + + ++data->id_node_index; + if (data->id_node_index == data->num_id_nodes) { + iter->valid = false; + return; + } + + DEG::IDDepsNode *id_node = deg_graph->id_nodes[data->id_node_index]; + DEG_iterator_ids_step(iter, id_node, data->only_updated); + } while (iter->skip); +} + +void DEG_iterator_ids_end(BLI_Iterator *UNUSED(iter)) +{ +} |