diff options
Diffstat (limited to 'source/blender/depsgraph/intern/builder/deg_builder.cc')
-rw-r--r-- | source/blender/depsgraph/intern/builder/deg_builder.cc | 133 |
1 files changed, 19 insertions, 114 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc index 5713297d658..b6256e9ceb0 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder.cc @@ -34,138 +34,43 @@ #include "DNA_object_types.h" #include "DNA_ID.h" -#include "BLI_utildefines.h" -#include "BLI_ghash.h" -#include "BLI_stack.h" +extern "C" { +#include "BKE_animsys.h" +} #include "intern/depsgraph.h" #include "intern/depsgraph_types.h" +#include "intern/eval/deg_eval_copy_on_write.h" #include "intern/nodes/deg_node.h" -#include "intern/nodes/deg_node_component.h" #include "intern/nodes/deg_node_id.h" -#include "intern/nodes/deg_node_operation.h" #include "util/deg_util_foreach.h" -#include <cstdio> +#include "DEG_depsgraph.h" namespace DEG { -static bool check_object_needs_evaluation(Object *object) -{ - if (object->recalc & OB_RECALC_ALL) { - /* Object is tagged for update anyway, no need to re-tag it. */ - return false; - } - if (object->type == OB_MESH) { - return object->derivedFinal == NULL; - } - else if (ELEM(object->type, - OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE)) - { - return object->curve_cache == NULL; - } - return false; -} - -void deg_graph_build_flush_layers(Depsgraph *graph) +void deg_graph_build_finalize(Main *bmain, Depsgraph *graph) { - BLI_Stack *stack = BLI_stack_new(sizeof(OperationDepsNode *), - "DEG flush layers stack"); - foreach (OperationDepsNode *node, graph->operations) { - IDDepsNode *id_node = node->owner->owner; - node->done = 0; - node->num_links_pending = 0; - foreach (DepsRelation *rel, node->outlinks) { - if ((rel->from->type == DEG_NODE_TYPE_OPERATION) && - (rel->flag & DEPSREL_FLAG_CYCLIC) == 0) - { - ++node->num_links_pending; - } - } - if (node->num_links_pending == 0) { - BLI_stack_push(stack, &node); - node->done = 1; - } - node->owner->layers = id_node->layers; - id_node->id->tag |= LIB_TAG_DOIT; - } - while (!BLI_stack_is_empty(stack)) { - OperationDepsNode *node; - BLI_stack_pop(stack, &node); - /* Flush layers to parents. */ - foreach (DepsRelation *rel, node->inlinks) { - if (rel->from->type == DEG_NODE_TYPE_OPERATION) { - OperationDepsNode *from = (OperationDepsNode *)rel->from; - from->owner->layers |= node->owner->layers; - } - } - /* Schedule parent nodes. */ - foreach (DepsRelation *rel, node->inlinks) { - if (rel->from->type == DEG_NODE_TYPE_OPERATION) { - OperationDepsNode *from = (OperationDepsNode *)rel->from; - if ((rel->flag & DEPSREL_FLAG_CYCLIC) == 0) { - BLI_assert(from->num_links_pending > 0); - --from->num_links_pending; - } - if (from->num_links_pending == 0 && from->done == 0) { - BLI_stack_push(stack, &from); - from->done = 1; - } - } - } - } - BLI_stack_free(stack); -} - -void deg_graph_build_finalize(Depsgraph *graph) -{ - /* STEP 1: Make sure new invisible dependencies are ready for use. - * - * TODO(sergey): This might do a bit of extra tagging, but it's kinda nice - * to do it ahead of a time and don't spend time on flushing updates on - * every frame change. + /* Re-tag IDs for update if it was tagged before the relations + * update tag. */ foreach (IDDepsNode *id_node, graph->id_nodes) { - if (id_node->layers == 0) { - ID *id = id_node->id; - if (GS(id->name) == ID_OB) { - Object *object = (Object *)id; - if (check_object_needs_evaluation(object)) { - id_node->tag_update(graph); - } + ID *id = id_node->id_orig; + id_node->finalize_build(graph); + int flag = 0; + if ((id->recalc & ID_RECALC_ALL)) { + AnimData *adt = BKE_animdata_from_id(id); + if (adt != NULL && (adt->recalc & ADT_RECALC_ANIM) != 0) { + flag |= DEG_TAG_TIME; } } - } - /* STEP 2: Flush visibility layers from children to parent. */ - deg_graph_build_flush_layers(graph); - /* STEP 3: Re-tag IDs for update if it was tagged before the relations - * update tag. - */ - foreach (IDDepsNode *id_node, graph->id_nodes) { - GHASH_FOREACH_BEGIN(ComponentDepsNode *, comp, id_node->components) - { - id_node->layers |= comp->layers; + if (!deg_copy_on_write_is_expanded(id_node->id_cow)) { + flag |= DEG_TAG_COPY_ON_WRITE; } - GHASH_FOREACH_END(); - - if ((id_node->layers & graph->layers) != 0 || graph->layers == 0) { - ID *id = id_node->id; - if ((id->recalc & ID_RECALC_ALL) && - (id->tag & LIB_TAG_DOIT)) - { - id_node->tag_update(graph); - id->tag &= ~LIB_TAG_DOIT; - } - else if (GS(id->name) == ID_OB) { - Object *object = (Object *)id; - if (object->recalc & OB_RECALC_ALL) { - id_node->tag_update(graph); - id->tag &= ~LIB_TAG_DOIT; - } - } + if (flag != 0) { + DEG_id_tag_update_ex(bmain, id_node->id_orig, flag); } - id_node->finalize_build(); } } |