diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-04-05 12:11:44 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-04-05 12:39:30 +0300 |
commit | ba5b792dd997d634c0901bddbca4ebb82d6ebbbe (patch) | |
tree | 312deb9e5022f9d57c2fd9ed5018b55ac3869b12 /source/blender/depsgraph/intern/builder | |
parent | 1f6037c887863e67a5a8b211738e04fd6dce16ad (diff) |
Depsgraph: Remove all layer bit flags related checks
These bits became obsolete with the new layer system, so we can
simplify some code around them or avoid existing workarounds which
were trying to keep things working for them.
There are still work needed to be done for on_visible_change to
avoid unnecessary updates, but that can also happen later.
Diffstat (limited to 'source/blender/depsgraph/intern/builder')
5 files changed, 17 insertions, 131 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc index 828da6cb056..137b507acfc 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder.cc @@ -60,119 +60,21 @@ string deg_fcurve_id_name(const FCurve *fcu) return string(fcu->rna_path) + index_buf; } -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) -{ - std::stack<OperationDepsNode *> 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 == DEPSNODE_TYPE_OPERATION) && - (rel->flag & DEPSREL_FLAG_CYCLIC) == 0) - { - ++node->num_links_pending; - } - } - if (node->num_links_pending == 0) { - stack.push(node); - node->done = 1; - } - node->owner->layers = id_node->layers; - id_node->id->tag |= LIB_TAG_DOIT; - } - while (!stack.empty()) { - OperationDepsNode *node = stack.top(); - stack.pop(); - /* Flush layers to parents. */ - foreach (DepsRelation *rel, node->inlinks) { - if (rel->from->type == DEPSNODE_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 == DEPSNODE_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) { - stack.push(from); - from->done = 1; - } - } - } - } -} - 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. - */ - GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, graph->id_hash) - { - 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); - } - } - } - } - GHASH_FOREACH_END(); - /* 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 + /* Re-tag IDs for update if it was tagged before the relations * update tag. */ GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, graph->id_hash) { - GHASH_FOREACH_BEGIN(ComponentDepsNode *, comp, id_node->components) - { - id_node->layers |= comp->layers; + ID *id = id_node->id; + if ((id->tag & LIB_TAG_ID_RECALC_ALL)) { + id_node->tag_update(graph); } - GHASH_FOREACH_END(); - - if ((id_node->layers & graph->layers) != 0 || graph->layers == 0) { - ID *id = id_node->id; - if ((id->tag & LIB_TAG_ID_RECALC_ALL) && - (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; - } - 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; - } } } id_node->finalize_build(); diff --git a/source/blender/depsgraph/intern/builder/deg_builder.h b/source/blender/depsgraph/intern/builder/deg_builder.h index 3cc51a2d7db..bdc030e3810 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder.h +++ b/source/blender/depsgraph/intern/builder/deg_builder.h @@ -42,6 +42,5 @@ struct Depsgraph; string deg_fcurve_id_name(const FCurve *fcu); void deg_graph_build_finalize(struct Depsgraph *graph); -void deg_graph_build_flush_layers(struct Depsgraph *graph); } // namespace DEG diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index b6071b10757..24354a94d88 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -387,29 +387,14 @@ SubgraphDepsNode *DepsgraphNodeBuilder::build_subgraph(Group *group) void DepsgraphNodeBuilder::build_object(Scene *scene, Object *ob) { - const bool has_object = (ob->id.tag & LIB_TAG_DOIT); - IDDepsNode *id_node = (has_object) - ? m_graph->find_id_node(&ob->id) - : add_id_node(&ob->id); - /* Update node layers. - * Do it for both new and existing ID nodes. This is so because several - * bases might be sharing same object. - */ - - /* Blender 2.8 transition: we don't have bases and do not have - * layer masks, but still want objects to be updated - */ - id_node->layers |= ((1 << 20) - 1); - - if (ob == scene->camera) { - /* Camera should always be updated, it used directly by viewport. */ - id_node->layers |= (unsigned int)(-1); - } /* Skip rest of components if the ID node was already there. */ - if (has_object) { + if (ob->id.tag & LIB_TAG_DOIT) { return; } ob->id.tag |= LIB_TAG_DOIT; + + /* Create ID node for obejct and begin init. */ + IDDepsNode *id_node = add_id_node(&ob->id); ob->customdata_mask = 0; /* Standard components. */ diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index da788297a2f..ae12d00e035 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -274,10 +274,10 @@ void DepsgraphRelationBuilder::add_operation_relation( } } -void DepsgraphRelationBuilder::add_collision_relations(const OperationKey &key, Scene *scene, Object *ob, Group *group, int layer, bool dupli, const char *name) +void DepsgraphRelationBuilder::add_collision_relations(const OperationKey &key, Scene *scene, Object *ob, Group *group, bool dupli, const char *name) { unsigned int numcollobj; - Object **collobjs = get_collisionobjects_ext(scene, ob, group, layer, &numcollobj, eModifierType_Collision, dupli); + Object **collobjs = get_collisionobjects_ext(scene, ob, group, &numcollobj, eModifierType_Collision, dupli); for (unsigned int i = 0; i < numcollobj; i++) { @@ -329,7 +329,7 @@ void DepsgraphRelationBuilder::add_forcefield_relations(const OperationKey &key, } if (add_absorption && (eff->pd->flag & PFIELD_VISIBILITY)) { - add_collision_relations(key, scene, ob, NULL, eff->ob->lay, true, "Force Absorption"); + add_collision_relations(key, scene, ob, NULL, true, "Force Absorption"); } } } @@ -1308,10 +1308,10 @@ void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob) /* collisions */ if (part->type != PART_HAIR) { - add_collision_relations(psys_key, scene, ob, part->collision_group, ob->lay, true, "Particle Collision"); + add_collision_relations(psys_key, scene, ob, part->collision_group, true, "Particle Collision"); } else if ((psys->flag & PSYS_HAIR_DYNAMICS) && psys->clmd && psys->clmd->coll_parms) { - add_collision_relations(psys_key, scene, ob, psys->clmd->coll_parms->group, ob->lay | scene->lay, true, "Hair Collision"); + add_collision_relations(psys_key, scene, ob, psys->clmd->coll_parms->group, true, "Hair Collision"); } /* effectors */ diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h index 557f2dd36b8..98307e2fc8f 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h @@ -232,7 +232,7 @@ struct DepsgraphRelationBuilder void build_mask(Mask *mask); void build_movieclip(MovieClip *clip); - void add_collision_relations(const OperationKey &key, Scene *scene, Object *ob, Group *group, int layer, bool dupli, const char *name); + void add_collision_relations(const OperationKey &key, Scene *scene, Object *ob, Group *group, bool dupli, const char *name); void add_forcefield_relations(const OperationKey &key, Scene *scene, Object *ob, ParticleSystem *psys, EffectorWeights *eff, bool add_absorption, const char *name); struct LayerCollectionState { |