diff options
Diffstat (limited to 'source/blender/depsgraph/intern/builder/deg_builder_nodes.cc')
-rw-r--r-- | source/blender/depsgraph/intern/builder/deg_builder_nodes.cc | 162 |
1 files changed, 85 insertions, 77 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 0c1a3d21f84..58c9b6f10ca 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -118,7 +118,6 @@ namespace { struct BuilderWalkUserData { DepsgraphNodeBuilder *builder; - Scene *scene; }; static void modifier_walk(void *user_data, @@ -128,7 +127,7 @@ static void modifier_walk(void *user_data, { BuilderWalkUserData *data = (BuilderWalkUserData *)user_data; if (*obpoin) { - data->builder->build_object(data->scene, *obpoin, DEG_ID_LINKED_INDIRECTLY); + data->builder->build_object(*obpoin, DEG_ID_LINKED_INDIRECTLY); } } @@ -141,7 +140,7 @@ void constraint_walk(bConstraint * /*con*/, if (*idpoin) { ID *id = *idpoin; if (GS(id->name) == ID_OB) { - data->builder->build_object(data->scene, (Object *)id, DEG_ID_LINKED_INDIRECTLY); + data->builder->build_object((Object *)id, DEG_ID_LINKED_INDIRECTLY); } } } @@ -159,34 +158,35 @@ void free_copy_on_write_datablock(void *id_v) /* **** General purpose functions **** */ -DepsgraphNodeBuilder::DepsgraphNodeBuilder(Main *bmain, Depsgraph *graph) : - m_bmain(bmain), - m_graph(graph), - m_cow_id_hash(NULL) +DepsgraphNodeBuilder::DepsgraphNodeBuilder(Main *bmain, Depsgraph *graph) + : bmain_(bmain), + graph_(graph), + scene_(NULL), + cow_id_hash_(NULL) { } DepsgraphNodeBuilder::~DepsgraphNodeBuilder() { - if (m_cow_id_hash != NULL) { - BLI_ghash_free(m_cow_id_hash, NULL, free_copy_on_write_datablock); + if (cow_id_hash_ != NULL) { + BLI_ghash_free(cow_id_hash_, NULL, free_copy_on_write_datablock); } } IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id, bool do_tag) { if (!DEG_depsgraph_use_copy_on_write()) { - return m_graph->add_id_node(id); + return graph_->add_id_node(id); } IDDepsNode *id_node = NULL; - ID *id_cow = (ID *)BLI_ghash_lookup(m_cow_id_hash, id); + ID *id_cow = (ID *)BLI_ghash_lookup(cow_id_hash_, id); if (id_cow != NULL) { /* TODO(sergey): Is it possible to lookup and pop element from GHash * at the same time? */ - BLI_ghash_remove(m_cow_id_hash, id, NULL, NULL); + BLI_ghash_remove(cow_id_hash_, id, NULL, NULL); } - id_node = m_graph->add_id_node(id, do_tag, id_cow); + id_node = graph_->add_id_node(id, do_tag, id_cow); /* Currently all ID nodes are supposed to have copy-on-write logic. * * NOTE: Zero number of components indicates that ID node was just created. @@ -195,22 +195,22 @@ IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id, bool do_tag) ComponentDepsNode *comp_cow = id_node->add_component(DEG_NODE_TYPE_COPY_ON_WRITE); OperationDepsNode *op_cow = comp_cow->add_operation( - function_bind(deg_evaluate_copy_on_write, _1, m_graph, id_node), - DEG_OPCODE_COPY_ON_WRITE, - "", -1); - m_graph->operations.push_back(op_cow); + function_bind(deg_evaluate_copy_on_write, _1, graph_, id_node), + DEG_OPCODE_COPY_ON_WRITE, + "", -1); + graph_->operations.push_back(op_cow); } return id_node; } IDDepsNode *DepsgraphNodeBuilder::find_id_node(ID *id) { - return m_graph->find_id_node(id); + return graph_->find_id_node(id); } TimeSourceDepsNode *DepsgraphNodeBuilder::add_time_source() { - return m_graph->add_time_source(); + return graph_->add_time_source(); } ComponentDepsNode *DepsgraphNodeBuilder::add_component_node( @@ -236,7 +236,7 @@ OperationDepsNode *DepsgraphNodeBuilder::add_operation_node( name_tag); if (op_node == NULL) { op_node = comp_node->add_operation(op, opcode, name, name_tag); - m_graph->operations.push_back(op_node); + graph_->operations.push_back(op_node); } else { fprintf(stderr, @@ -318,7 +318,7 @@ OperationDepsNode *DepsgraphNodeBuilder::find_operation_node( ID *DepsgraphNodeBuilder::get_cow_id(const ID *id_orig) const { - return m_graph->get_cow_id(id_orig); + return graph_->get_cow_id(id_orig); } ID *DepsgraphNodeBuilder::ensure_cow_id(ID *id_orig) @@ -333,7 +333,7 @@ ID *DepsgraphNodeBuilder::ensure_cow_id(ID *id_orig) ID *DepsgraphNodeBuilder::expand_cow_id(IDDepsNode *id_node) { - return deg_expand_copy_on_write_datablock(m_graph, id_node, this, true); + return deg_expand_copy_on_write_datablock(graph_, id_node, this, true); } ID *DepsgraphNodeBuilder::expand_cow_id(ID *id_orig) @@ -344,17 +344,17 @@ ID *DepsgraphNodeBuilder::expand_cow_id(ID *id_orig) /* **** Build functions for entity nodes **** */ -void DepsgraphNodeBuilder::begin_build(Main *bmain) { +void DepsgraphNodeBuilder::begin_build() { /* LIB_TAG_DOIT is used to indicate whether node for given ID was already * created or not. This flag is being set in add_id_node(), so functions * shouldn't bother with setting it, they only might query this flag when * needed. */ - BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false); + BKE_main_id_tag_all(bmain_, LIB_TAG_DOIT, false); /* XXX nested node trees are not included in tag-clearing above, * so we need to do this manually. */ - FOREACH_NODETREE(bmain, nodetree, id) + FOREACH_NODETREE(bmain_, nodetree, id) { if (id != (ID *)nodetree) { nodetree->id.tag &= ~LIB_TAG_DOIT; @@ -366,13 +366,13 @@ void DepsgraphNodeBuilder::begin_build(Main *bmain) { /* Store existing copy-on-write versions of datablock, so we can re-use * them for new ID nodes. */ - m_cow_id_hash = BLI_ghash_ptr_new("Depsgraph id hash"); - foreach (IDDepsNode *id_node, m_graph->id_nodes) { + cow_id_hash_ = BLI_ghash_ptr_new("Depsgraph id hash"); + foreach (IDDepsNode *id_node, graph_->id_nodes) { if (GS(id_node->id_orig->name) != ID_SCE) { continue; } if (deg_copy_on_write_is_expanded(id_node->id_cow)) { - BLI_ghash_insert(m_cow_id_hash, + BLI_ghash_insert(cow_id_hash_, id_node->id_orig, id_node->id_cow); id_node->id_cow = NULL; @@ -381,12 +381,12 @@ void DepsgraphNodeBuilder::begin_build(Main *bmain) { } /* Make sure graph has no nodes left from previous state. */ - m_graph->clear_all_nodes(); - m_graph->operations.clear(); - BLI_gset_clear(m_graph->entry_tags, NULL); + graph_->clear_all_nodes(); + graph_->operations.clear(); + BLI_gset_clear(graph_->entry_tags, NULL); } -void DepsgraphNodeBuilder::build_group(Scene *scene, Group *group) +void DepsgraphNodeBuilder::build_group(Group *group) { ID *group_id = &group->id; if (group_id->tag & LIB_TAG_DOIT) { @@ -395,12 +395,11 @@ void DepsgraphNodeBuilder::build_group(Scene *scene, Group *group) group_id->tag |= LIB_TAG_DOIT; LINKLIST_FOREACH (GroupObject *, go, &group->gobject) { - build_object(scene, go->ob, DEG_ID_LINKED_INDIRECTLY); + build_object(go->ob, DEG_ID_LINKED_INDIRECTLY); } } -void DepsgraphNodeBuilder::build_object(Scene *scene, - Object *ob, +void DepsgraphNodeBuilder::build_object(Object *ob, eDepsNode_LinkedState_Type linked_state) { /* Skip rest of components if the ID node was already there. */ @@ -418,21 +417,19 @@ void DepsgraphNodeBuilder::build_object(Scene *scene, ob->customdata_mask = 0; /* Standard components. */ - build_object_transform(scene, ob); + build_object_transform(ob); if (ob->parent != NULL) { - build_object(scene, ob->parent, linked_state); + build_object(ob->parent, linked_state); } if (ob->modifiers.first != NULL) { BuilderWalkUserData data; data.builder = this; - data.scene = scene; modifiers_foreachObjectLink(ob, modifier_walk, &data); } if (ob->constraints.first != NULL) { BuilderWalkUserData data; data.builder = this; - data.scene = scene; BKE_constraints_id_loop(&ob->constraints, constraint_walk, &data); } @@ -446,7 +443,7 @@ void DepsgraphNodeBuilder::build_object(Scene *scene, case OB_SURF: case OB_MBALL: case OB_LATTICE: - build_obdata_geom(scene, ob); + build_obdata_geom(ob); /* TODO(sergey): Only for until we support granular * update of curves. */ @@ -463,7 +460,7 @@ void DepsgraphNodeBuilder::build_object(Scene *scene, build_proxy_rig(ob); } else { - build_rig(scene, ob); + build_rig(ob); } break; @@ -500,7 +497,7 @@ void DepsgraphNodeBuilder::build_object(Scene *scene, /* particle systems */ if (ob->particlesystem.first != NULL) { - build_particles(scene, ob); + build_particles(ob); } /* Grease pencil. */ @@ -511,19 +508,19 @@ void DepsgraphNodeBuilder::build_object(Scene *scene, /* Object that this is a proxy for. */ if (ob->proxy) { ob->proxy->proxy_from = ob; - build_object(scene, ob->proxy, DEG_ID_LINKED_INDIRECTLY); + build_object(ob->proxy, DEG_ID_LINKED_INDIRECTLY); } /* Object dupligroup. */ if (ob->dup_group != NULL) { - build_group(scene, ob->dup_group); + build_group(ob->dup_group); } } -void DepsgraphNodeBuilder::build_object_transform(Scene *scene, Object *ob) +void DepsgraphNodeBuilder::build_object_transform(Object *ob) { OperationDepsNode *op_node; - Scene *scene_cow = get_cow_datablock(scene); + Scene *scene_cow = get_cow_datablock(scene_); Object *ob_cow = get_cow_datablock(ob); /* local transforms (from transform channels - loc/rot/scale + deltas) */ @@ -545,7 +542,7 @@ void DepsgraphNodeBuilder::build_object_transform(Scene *scene, Object *ob) /* object constraints */ if (ob->constraints.first != NULL) { - build_object_constraints(scene, ob); + build_object_constraints(ob); } /* Rest of transformation update. */ @@ -579,12 +576,12 @@ void DepsgraphNodeBuilder::build_object_transform(Scene *scene, Object *ob) * * -- Aligorith, August 2013 */ -void DepsgraphNodeBuilder::build_object_constraints(Scene *scene, Object *ob) +void DepsgraphNodeBuilder::build_object_constraints(Object *ob) { /* create node for constraint stack */ add_operation_node(&ob->id, DEG_NODE_TYPE_TRANSFORM, function_bind(BKE_object_eval_constraints, _1, - get_cow_datablock(scene), + get_cow_datablock(scene_), get_cow_datablock(ob)), DEG_OPCODE_TRANSFORM_CONSTRAINTS); } @@ -758,7 +755,7 @@ void DepsgraphNodeBuilder::build_rigidbody(Scene *scene) } } -void DepsgraphNodeBuilder::build_particles(Scene *scene, Object *ob) +void DepsgraphNodeBuilder::build_particles(Object *ob) { /** * Particle Systems Nodes @@ -780,7 +777,7 @@ void DepsgraphNodeBuilder::build_particles(Scene *scene, Object *ob) add_component_node(&ob->id, DEG_NODE_TYPE_EVAL_PARTICLES); /* TODO(sergey): Need to get COW of PSYS. */ - Scene *scene_cow = get_cow_datablock(scene); + Scene *scene_cow = get_cow_datablock(scene_); Object *ob_cow = get_cow_datablock(ob); add_operation_node(psys_comp, @@ -839,9 +836,9 @@ void DepsgraphNodeBuilder::build_particle_settings(ParticleSettings *part) { DEG_OPCODE_PARTICLE_SETTINGS_RECALC_CLEAR); } -void DepsgraphNodeBuilder::build_cloth(Scene *scene, Object *object) +void DepsgraphNodeBuilder::build_cloth(Object *object) { - Scene *scene_cow = get_cow_datablock(scene); + Scene *scene_cow = get_cow_datablock(scene_); Object *object_cow = get_cow_datablock(object); add_operation_node(&object->id, DEG_NODE_TYPE_CACHE, @@ -864,10 +861,10 @@ void DepsgraphNodeBuilder::build_shapekeys(Key *key) /* ObData Geometry Evaluation */ // XXX: what happens if the datablock is shared! -void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob) +void DepsgraphNodeBuilder::build_obdata_geom(Object *ob) { OperationDepsNode *op_node; - Scene *scene_cow = get_cow_datablock(scene); + Scene *scene_cow = get_cow_datablock(scene_); Object *object_cow = get_cow_datablock(ob); /* TODO(sergey): This way using this object's properties as driver target @@ -909,7 +906,7 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob) /* Cloyth modifier. */ LINKLIST_FOREACH (ModifierData *, md, &ob->modifiers) { if (md->type == eModifierType_Cloth) { - build_cloth(scene, ob); + build_cloth(ob); } } @@ -975,8 +972,7 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob) case OB_MBALL: { - Object *mom = BKE_mball_basis_find(scene, ob); - + Object *mom = BKE_mball_basis_find(scene_, ob); /* Motherball - mom depends on children! */ if (mom == ob) { /* metaball evaluation operations */ @@ -1012,13 +1008,13 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob) */ Curve *cu = (Curve *)obdata; if (cu->bevobj != NULL) { - build_object(scene, cu->bevobj, DEG_ID_LINKED_INDIRECTLY); + build_object(cu->bevobj, DEG_ID_LINKED_INDIRECTLY); } if (cu->taperobj != NULL) { - build_object(scene, cu->taperobj, DEG_ID_LINKED_INDIRECTLY); + build_object(cu->taperobj, DEG_ID_LINKED_INDIRECTLY); } if (ob->type == OB_FONT && cu->textoncurve != NULL) { - build_object(scene, cu->textoncurve, DEG_ID_LINKED_INDIRECTLY); + build_object(cu->textoncurve, DEG_ID_LINKED_INDIRECTLY); } break; } @@ -1132,24 +1128,36 @@ void DepsgraphNodeBuilder::build_nodetree(bNodeTree *ntree) /* nodetree's nodes... */ LINKLIST_FOREACH (bNode *, bnode, &ntree->nodes) { ID *id = bnode->id; - if (id != NULL) { - ID_Type id_type = GS(id->name); - if (id_type == ID_MA) { - build_material((Material *)id); - } - else if (id_type == ID_TE) { - build_texture((Tex *)id); - } - else if (id_type == ID_IM) { - build_image((Image *)id); - } - else if (bnode->type == NODE_GROUP) { - bNodeTree *group_ntree = (bNodeTree *)id; - if ((group_ntree->id.tag & LIB_TAG_DOIT) == 0) { - build_nodetree(group_ntree); - } + if (id == NULL) { + continue; + } + ID_Type id_type = GS(id->name); + if (id_type == ID_MA) { + build_material((Material *)id); + } + else if (id_type == ID_TE) { + build_texture((Tex *)id); + } + else if (id_type == ID_IM) { + build_image((Image *)id); + } + else if (id_type == ID_OB) { + build_object((Object *)id, DEG_ID_LINKED_INDIRECTLY); + } + else if (id_type == ID_SCE) { + /* Scenes are used by compositor trees, and handled by render + * pipeline. No need to build dependencies for them here. + */ + } + else if (bnode->type == NODE_GROUP) { + bNodeTree *group_ntree = (bNodeTree *)id; + if ((group_ntree->id.tag & LIB_TAG_DOIT) == 0) { + build_nodetree(group_ntree); } } + else { + BLI_assert(!"Unknown ID type used for node"); + } } // TODO: link from nodetree to owner_component? |