diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-09 12:59:15 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-09 12:59:15 +0300 |
commit | c99481b6320a77e4793c812403f7d37dfc2d5ced (patch) | |
tree | 448226ab76b4f2d92263cc115828c23f1f753540 /source | |
parent | ffe76ae9f4abe2a64d4c749623b99f70b3746d87 (diff) | |
parent | 8d7ec519dff93b04fdec548aeef4b90137d788c8 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source')
9 files changed, 259 insertions, 229 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? diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h index e7bf8c9998d..40d6a56e789 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h @@ -108,7 +108,7 @@ struct DepsgraphNodeBuilder { } } - void begin_build(Main *bmain); + void begin_build(); IDDepsNode *add_id_node(ID *id, bool do_tag = true); IDDepsNode *find_id_node(ID *id); @@ -157,34 +157,30 @@ struct DepsgraphNodeBuilder { const char *name = "", int name_tag = -1); - void build_scene(Main *bmain, - Scene *scene, + void build_scene(Scene *scene, eDepsNode_LinkedState_Type linked_state); - void build_group(Scene *scene, Group *group); - void build_object(Scene *scene, - Object *ob, + void build_group(Group *group); + void build_object(Object *ob, eDepsNode_LinkedState_Type linked_state); - void build_object_transform(Scene *scene, Object *ob); - void build_object_constraints(Scene *scene, Object *ob); - void build_pose_constraints(Scene *scene, Object *ob, bPoseChannel *pchan); + void build_object_transform(Object *ob); + void build_object_constraints(Object *ob); + void build_pose_constraints(Object *ob, bPoseChannel *pchan); void build_rigidbody(Scene *scene); - void build_particles(Scene *scene, Object *ob); + void build_particles(Object *ob); void build_particle_settings(ParticleSettings *part); - void build_cloth(Scene *scene, Object *object); + void build_cloth(Object *object); void build_animdata(ID *id); OperationDepsNode *build_driver(ID *id, FCurve *fcurve); - void build_ik_pose(Scene *scene, - Object *ob, + void build_ik_pose(Object *ob, bPoseChannel *pchan, bConstraint *con); - void build_splineik_pose(Scene *scene, - Object *ob, + void build_splineik_pose(Object *ob, bPoseChannel *pchan, bConstraint *con); - void build_rig(Scene *scene, Object *ob); + void build_rig(Object *ob); void build_proxy_rig(Object *ob); void build_shapekeys(Key *key); - void build_obdata_geom(Scene *scene, Object *ob); + void build_obdata_geom(Object *ob); void build_camera(Object *ob); void build_lamp(Object *ob); void build_nodetree(bNodeTree *ntree); @@ -212,9 +208,14 @@ struct DepsgraphNodeBuilder { LayerCollectionState *state); void build_scene_layer_collections(Scene *scene); protected: - Main *m_bmain; - Depsgraph *m_graph; - GHash *m_cow_id_hash; + /* State which never changes, same for the whole builder time. */ + Main *bmain_; + Depsgraph *graph_; + + /* State which demotes currently built entities. */ + Scene *scene_; + + GHash *cow_id_hash_; }; } // namespace DEG diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc index dabebb9d4a9..7b78156b8f8 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc @@ -66,23 +66,20 @@ extern "C" { namespace DEG { -void DepsgraphNodeBuilder::build_pose_constraints(Scene *scene, - Object *ob, - bPoseChannel *pchan) +void DepsgraphNodeBuilder::build_pose_constraints(Object *ob, bPoseChannel *pchan) { /* create node for constraint stack */ add_operation_node(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, function_bind(BKE_pose_constraints_evaluate, _1, - get_cow_datablock(scene), + get_cow_datablock(scene_), get_cow_datablock(ob), pchan), DEG_OPCODE_BONE_CONSTRAINTS); } /* IK Solver Eval Steps */ -void DepsgraphNodeBuilder::build_ik_pose(Scene *scene, - Object *ob, +void DepsgraphNodeBuilder::build_ik_pose(Object *ob, bPoseChannel *pchan, bConstraint *con) { @@ -102,16 +99,16 @@ void DepsgraphNodeBuilder::build_ik_pose(Scene *scene, /* Operation node for evaluating/running IK Solver. */ add_operation_node(&ob->id, DEG_NODE_TYPE_EVAL_POSE, rootchan->name, - function_bind(BKE_pose_iktree_evaluate, _1, - get_cow_datablock(scene), + function_bind(BKE_pose_iktree_evaluate, + _1, + get_cow_datablock(scene_), get_cow_datablock(ob), rootchan), DEG_OPCODE_POSE_IK_SOLVER); } /* Spline IK Eval Steps */ -void DepsgraphNodeBuilder::build_splineik_pose(Scene *scene, - Object *ob, +void DepsgraphNodeBuilder::build_splineik_pose(Object *ob, bPoseChannel *pchan, bConstraint *con) { @@ -127,14 +124,14 @@ void DepsgraphNodeBuilder::build_splineik_pose(Scene *scene, add_operation_node(&ob->id, DEG_NODE_TYPE_EVAL_POSE, rootchan->name, function_bind(BKE_pose_splineik_evaluate, _1, - get_cow_datablock(scene), + get_cow_datablock(scene_), get_cow_datablock(ob), rootchan), DEG_OPCODE_POSE_SPLINE_IK_SOLVER); } /* Pose/Armature Bones Graph */ -void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *object) +void DepsgraphNodeBuilder::build_rig(Object *object) { bArmature *armature = (bArmature *)object->data; const short armature_tag = armature->id.tag; @@ -145,12 +142,12 @@ void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *object) /* NOTE: We need to expand both object and armature, so this way we can * safely create object level pose. */ - scene_cow = get_cow_datablock(scene); + scene_cow = get_cow_datablock(scene_); object_cow = expand_cow_datablock(object); armature_cow = expand_cow_datablock(armature); } else { - scene_cow = scene; + scene_cow = scene_; object_cow = object; armature_cow = armature; } @@ -273,7 +270,7 @@ void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *object) op_node->set_as_exit(); /* Build constraints. */ if (pchan->constraints.first != NULL) { - build_pose_constraints(scene, object, pchan); + build_pose_constraints(object, pchan); } /** * IK Solvers. @@ -290,11 +287,11 @@ void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *object) LINKLIST_FOREACH (bConstraint *, con, &pchan->constraints) { switch (con->type) { case CONSTRAINT_TYPE_KINEMATIC: - build_ik_pose(scene, object, pchan, con); + build_ik_pose(object, pchan, con); break; case CONSTRAINT_TYPE_SPLINEIK: - build_splineik_pose(scene, object, pchan, con); + build_splineik_pose(object, pchan, con); break; default: @@ -304,7 +301,7 @@ void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *object) /* Custom shape. */ /* NOTE: Custom shape datablock is already remapped to CoW version. */ if (pchan->custom != NULL) { - build_object(scene, get_orig_datablock(pchan->custom), DEG_ID_LINKED_INDIRECTLY); + build_object(get_orig_datablock(pchan->custom), DEG_ID_LINKED_INDIRECTLY); } } } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc index 097720f514a..941a9bed5f1 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc @@ -65,7 +65,7 @@ extern "C" { namespace DEG { -void DepsgraphNodeBuilder::build_scene(Main *bmain, Scene *scene, eDepsNode_LinkedState_Type linked_state) +void DepsgraphNodeBuilder::build_scene(Scene *scene, eDepsNode_LinkedState_Type linked_state) { /* scene ID block */ add_id_node(&scene->id); @@ -77,20 +77,23 @@ void DepsgraphNodeBuilder::build_scene(Main *bmain, Scene *scene, eDepsNode_Link // XXX: depending on how this goes, that scene itself could probably store its // own little partial depsgraph? if (scene->set) { - build_scene(bmain, scene->set, DEG_ID_LINKED_VIA_SET); + build_scene(scene->set, DEG_ID_LINKED_VIA_SET); } + /* Setup currently building context. */ + scene_ = scene; + /* scene objects */ int select_color = 1; for (SceneLayer *sl = (SceneLayer *)scene->render_layers.first; sl; sl = sl->next) { for (Base *base = (Base *)sl->object_bases.first; base; base = base->next) { /* object itself */ - build_object(scene, base->object, linked_state); + build_object(base->object, linked_state); base->object->select_color = select_color++; } } if (scene->camera != NULL) { - build_object(scene, scene->camera, linked_state); + build_object(scene->camera, linked_state); } /* rigidbody */ @@ -122,17 +125,17 @@ void DepsgraphNodeBuilder::build_scene(Main *bmain, Scene *scene, eDepsNode_Link } /* Cache file. */ - LINKLIST_FOREACH (CacheFile *, cachefile, &bmain->cachefiles) { + LINKLIST_FOREACH (CacheFile *, cachefile, &bmain_->cachefiles) { build_cachefile(cachefile); } /* Masks. */ - LINKLIST_FOREACH (Mask *, mask, &bmain->mask) { + LINKLIST_FOREACH (Mask *, mask, &bmain_->mask) { build_mask(mask); } /* Movie clips. */ - LINKLIST_FOREACH (MovieClip *, clip, &bmain->movieclip) { + LINKLIST_FOREACH (MovieClip *, clip, &bmain_->movieclip) { build_movieclip(clip); } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 91902ed0ea6..34df44ae046 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -118,8 +118,6 @@ namespace { struct BuilderWalkUserData { DepsgraphRelationBuilder *builder; - Main *bmain; - Scene *scene; }; static void modifier_walk(void *user_data, @@ -129,7 +127,7 @@ static void modifier_walk(void *user_data, { BuilderWalkUserData *data = (BuilderWalkUserData *)user_data; if (*obpoin) { - data->builder->build_object(data->bmain, data->scene, *obpoin); + data->builder->build_object(*obpoin); } } @@ -142,7 +140,7 @@ void constraint_walk(bConstraint * /*con*/, if (*idpoin) { ID *id = *idpoin; if (GS(id->name) == ID_OB) { - data->builder->build_object(data->bmain, data->scene, (Object *)id); + data->builder->build_object((Object *)id); } } } @@ -194,8 +192,11 @@ RNAPathKey::RNAPathKey(ID *id, const char *path) : } } -DepsgraphRelationBuilder::DepsgraphRelationBuilder(Depsgraph *graph) : - m_graph(graph) +DepsgraphRelationBuilder::DepsgraphRelationBuilder(Main *bmain, + Depsgraph *graph) + : bmain_(bmain), + graph_(graph), + scene_(NULL) { } @@ -207,14 +208,14 @@ TimeSourceDepsNode *DepsgraphRelationBuilder::find_node( return NULL; } else { - return m_graph->time_source; + return graph_->time_source; } } ComponentDepsNode *DepsgraphRelationBuilder::find_node( const ComponentKey &key) const { - IDDepsNode *id_node = m_graph->find_id_node(key.id); + IDDepsNode *id_node = graph_->find_id_node(key.id); if (!id_node) { fprintf(stderr, "find_node component: Could not find ID %s\n", (key.id != NULL) ? key.id->name : "<null>"); @@ -228,7 +229,7 @@ ComponentDepsNode *DepsgraphRelationBuilder::find_node( OperationDepsNode *DepsgraphRelationBuilder::find_node( const OperationKey &key) const { - IDDepsNode *id_node = m_graph->find_id_node(key.id); + IDDepsNode *id_node = graph_->find_id_node(key.id); if (!id_node) { fprintf(stderr, "find_node operation: Could not find ID\n"); return NULL; @@ -253,13 +254,13 @@ OperationDepsNode *DepsgraphRelationBuilder::find_node( DepsNode *DepsgraphRelationBuilder::find_node(const RNAPathKey &key) const { - return m_graph->find_node_from_pointer(&key.ptr, key.prop); + return graph_->find_node_from_pointer(&key.ptr, key.prop); } OperationDepsNode *DepsgraphRelationBuilder::has_node( const OperationKey &key) const { - IDDepsNode *id_node = m_graph->find_id_node(key.id); + IDDepsNode *id_node = graph_->find_id_node(key.id); if (!id_node) { return NULL; } @@ -276,7 +277,7 @@ void DepsgraphRelationBuilder::add_time_relation(TimeSourceDepsNode *timesrc, const char *description) { if (timesrc && node_to) { - m_graph->add_new_relation(timesrc, node_to, description); + graph_->add_new_relation(timesrc, node_to, description); } else { DEG_DEBUG_PRINTF("add_time_relation(%p = %s, %p = %s, %s) Failed\n", @@ -292,7 +293,7 @@ void DepsgraphRelationBuilder::add_operation_relation( const char *description) { if (node_from && node_to) { - m_graph->add_new_relation(node_from, node_to, description); + graph_->add_new_relation(node_from, node_to, description); } else { DEG_DEBUG_PRINTF("add_operation_relation(%p = %s, %p = %s, %s) Failed\n", @@ -367,31 +368,30 @@ void DepsgraphRelationBuilder::add_forcefield_relations(const OperationKey &key, Depsgraph *DepsgraphRelationBuilder::getGraph() { - return m_graph; + return graph_; } /* **** Functions to build relations between entities **** */ -void DepsgraphRelationBuilder::begin_build(Main *bmain) +void DepsgraphRelationBuilder::begin_build() { /* LIB_TAG_DOIT is used to indicate whether node for given ID was already * created or not. */ - 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 notr 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; } - } FOREACH_NODETREE_END + } + FOREACH_NODETREE_END } -void DepsgraphRelationBuilder::build_group(Main *bmain, - Scene *scene, - Object *object, - Group *group) +void DepsgraphRelationBuilder::build_group(Object *object, Group *group) { ID *group_id = &group->id; bool group_done = (group_id->tag & LIB_TAG_DOIT) != 0; @@ -400,7 +400,7 @@ void DepsgraphRelationBuilder::build_group(Main *bmain, DEG_OPCODE_TRANSFORM_LOCAL); LINKLIST_FOREACH (GroupObject *, go, &group->gobject) { if (!group_done) { - build_object(bmain, scene, go->ob); + build_object(go->ob); } ComponentKey dupli_transform_key(&go->ob->id, DEG_NODE_TYPE_TRANSFORM); add_relation(dupli_transform_key, object_local_transform_key, "Dupligroup"); @@ -408,7 +408,7 @@ void DepsgraphRelationBuilder::build_group(Main *bmain, group_id->tag |= LIB_TAG_DOIT; } -void DepsgraphRelationBuilder::build_object(Main *bmain, Scene *scene, Object *ob) +void DepsgraphRelationBuilder::build_object(Object *ob) { if (ob->id.tag & LIB_TAG_DOIT) { return; @@ -437,15 +437,11 @@ void DepsgraphRelationBuilder::build_object(Main *bmain, Scene *scene, Object *o if (ob->modifiers.first != NULL) { BuilderWalkUserData data; data.builder = this; - data.bmain = bmain; - data.scene = scene; modifiers_foreachObjectLink(ob, modifier_walk, &data); } if (ob->constraints.first != NULL) { BuilderWalkUserData data; data.builder = this; - data.bmain = bmain; - data.scene = scene; BKE_constraints_id_loop(&ob->constraints, constraint_walk, &data); } @@ -456,10 +452,7 @@ void DepsgraphRelationBuilder::build_object(Main *bmain, Scene *scene, Object *o DEG_OPCODE_TRANSFORM_CONSTRAINTS); /* constraint relations */ - // TODO: provide base op - // XXX: this is broken - build_constraints(scene, - &ob->id, + build_constraints(&ob->id, DEG_NODE_TYPE_TRANSFORM, "", &ob->constraints, @@ -512,7 +505,7 @@ void DepsgraphRelationBuilder::build_object(Main *bmain, Scene *scene, Object *o case OB_MBALL: case OB_LATTICE: { - build_obdata_geom(bmain, scene, ob); + build_obdata_geom(ob); break; } @@ -521,7 +514,7 @@ void DepsgraphRelationBuilder::build_object(Main *bmain, Scene *scene, Object *o build_proxy_rig(ob); } else { - build_rig(bmain, scene, ob); + build_rig(ob); } break; @@ -548,7 +541,7 @@ void DepsgraphRelationBuilder::build_object(Main *bmain, Scene *scene, Object *o /* Particle systems. */ if (ob->particlesystem.first != NULL) { - build_particles(scene, ob); + build_particles(ob); } /* Grease pencil. */ @@ -559,7 +552,7 @@ void DepsgraphRelationBuilder::build_object(Main *bmain, Scene *scene, Object *o /* Object that this is a proxy for. */ if (ob->proxy != NULL) { ob->proxy->proxy_from = ob; - build_object(bmain, scene, ob->proxy); + build_object(ob->proxy); /* TODO(sergey): This is an inverted relation, matches old depsgraph * behavior and need to be investigated if it still need to be inverted. */ @@ -570,7 +563,7 @@ void DepsgraphRelationBuilder::build_object(Main *bmain, Scene *scene, Object *o /* Object dupligroup. */ if (ob->dup_group != NULL) { - build_group(bmain, scene, ob, ob->dup_group); + build_group(ob, ob->dup_group); } } @@ -666,7 +659,7 @@ void DepsgraphRelationBuilder::build_object_parent(Object *ob) } } -void DepsgraphRelationBuilder::build_constraints(Scene *scene, ID *id, +void DepsgraphRelationBuilder::build_constraints(ID *id, eDepsNode_Type component_type, const char *component_subdata, ListBase *constraints, @@ -717,8 +710,8 @@ void DepsgraphRelationBuilder::build_constraints(Scene *scene, ID *id, else if (cti->type == CONSTRAINT_TYPE_OBJECTSOLVER) { depends_on_camera = true; } - if (depends_on_camera && scene->camera) { - ComponentKey camera_key(&scene->camera->id, DEG_NODE_TYPE_TRANSFORM); + if (depends_on_camera && scene_->camera != NULL) { + ComponentKey camera_key(&scene_->camera->id, DEG_NODE_TYPE_TRANSFORM); add_relation(camera_key, constraint_op_key, cti->name); } /* TODO(sergey): This is more a TimeSource -> MovieClip -> @@ -1018,7 +1011,7 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcu) /* Drivers on armature-level bone settings (i.e. bbone stuff), * which will affect the evaluation of corresponding pose bones. */ - IDDepsNode *arm_node = m_graph->find_id_node(id); + IDDepsNode *arm_node = graph_->find_id_node(id); char *bone_name = BLI_str_quoted_substrN(rna_path, "bones["); if (arm_node != NULL && bone_name != NULL) { /* Find objects which use this, and make their eval callbacks @@ -1342,7 +1335,7 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene) } } -void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob) +void DepsgraphRelationBuilder::build_particles(Object *ob) { TimeSourceKey time_src_key; OperationKey obdata_ubereval_key(&ob->id, @@ -1405,7 +1398,7 @@ void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob) /* collisions */ if (part->type != PART_HAIR) { add_collision_relations(psys_key, - scene, + scene_, ob, part->collision_group, true, @@ -1416,7 +1409,7 @@ void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob) psys->clmd->coll_parms != NULL) { add_collision_relations(psys_key, - scene, + scene_, ob, psys->clmd->coll_parms->group, true, @@ -1425,7 +1418,7 @@ void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob) /* effectors */ add_forcefield_relations(psys_key, - scene, + scene_, ob, psys, part->effector_weights, @@ -1488,8 +1481,7 @@ void DepsgraphRelationBuilder::build_particle_settings(ParticleSettings *part) add_relation(eval_key, recalc_clear_key, "Particle Settings Clear Recalc"); } -void DepsgraphRelationBuilder::build_cloth(Scene * /*scene*/, - Object *object, +void DepsgraphRelationBuilder::build_cloth(Object *object, ModifierData * /*md*/) { OperationKey cache_key(&object->id, @@ -1546,7 +1538,7 @@ void DepsgraphRelationBuilder::build_shapekeys(ID *obdata, Key *key) * re-evaluation of the individual instances of this geometry. */ // TODO: Materials and lighting should probably get their own component, instead of being lumped under geometry? -void DepsgraphRelationBuilder::build_obdata_geom(Main *bmain, Scene *scene, Object *ob) +void DepsgraphRelationBuilder::build_obdata_geom(Object *ob) { ID *obdata = (ID *)ob->data; @@ -1568,7 +1560,7 @@ void DepsgraphRelationBuilder::build_obdata_geom(Main *bmain, Scene *scene, Obje * things like data mask to be used. We add relation here to ensure object is * never evaluated prior to Scene's CoW is ready. */ - OperationKey scene_key(&scene->id, + OperationKey scene_key(&scene_->id, DEG_NODE_TYPE_PARAMETERS, DEG_OPCODE_PLACEHOLDER, "Scene Eval"); @@ -1583,8 +1575,8 @@ void DepsgraphRelationBuilder::build_obdata_geom(Main *bmain, Scene *scene, Obje DepsNodeHandle handle = create_node_handle(obdata_ubereval_key); mti->updateDepsgraph( md, - bmain, - scene, + bmain_, + scene_, ob, reinterpret_cast< ::DepsNodeHandle* >(&handle)); } @@ -1606,7 +1598,7 @@ void DepsgraphRelationBuilder::build_obdata_geom(Main *bmain, Scene *scene, Obje } if (md->type == eModifierType_Cloth) { - build_cloth(scene, ob, md); + build_cloth(ob, md); } } } @@ -1674,8 +1666,7 @@ void DepsgraphRelationBuilder::build_obdata_geom(Main *bmain, Scene *scene, Obje 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) { /* non-motherball -> cannot be directly evaluated! */ @@ -1696,18 +1687,18 @@ void DepsgraphRelationBuilder::build_obdata_geom(Main *bmain, Scene *scene, Obje // XXX: these needs geom data, but where is geom stored? if (cu->bevobj) { ComponentKey bevob_key(&cu->bevobj->id, DEG_NODE_TYPE_GEOMETRY); - build_object(bmain, scene, cu->bevobj); + build_object(cu->bevobj); add_relation(bevob_key, geom_key, "Curve Bevel"); } if (cu->taperobj) { ComponentKey taperob_key(&cu->taperobj->id, DEG_NODE_TYPE_GEOMETRY); - build_object(bmain, scene, cu->taperobj); + build_object(cu->taperobj); add_relation(taperob_key, geom_key, "Curve Taper"); } if (ob->type == OB_FONT) { if (cu->textoncurve) { ComponentKey textoncurve_key(&cu->textoncurve->id, DEG_NODE_TYPE_GEOMETRY); - build_object(bmain, scene, cu->textoncurve); + build_object(cu->textoncurve); add_relation(textoncurve_key, geom_key, "Text on Curve"); } } @@ -1826,23 +1817,40 @@ void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree) ComponentKey shading_key(ntree_id, DEG_NODE_TYPE_SHADING); /* nodetree's nodes... */ LINKLIST_FOREACH (bNode *, bnode, &ntree->nodes) { - if (bnode->id) { - if (GS(bnode->id->name) == ID_MA) { - build_material((Material *)bnode->id); - } - else if (bnode->type == ID_TE) { - build_texture((Tex *)bnode->id); - } - else if (bnode->type == NODE_GROUP) { - bNodeTree *group_ntree = (bNodeTree *)bnode->id; - if ((group_ntree->id.tag & LIB_TAG_DOIT) == 0) { - build_nodetree(group_ntree); - group_ntree->id.tag |= LIB_TAG_DOIT; - } - ComponentKey group_shading_key(&group_ntree->id, - DEG_NODE_TYPE_SHADING); - add_relation(group_shading_key, shading_key, "Group Node"); + ID *id = bnode->id; + if (id == NULL) { + continue; + } + ID_Type id_type = GS(id->name); + if (id_type == ID_MA) { + build_material((Material *)bnode->id); + } + else if (id_type == ID_TE) { + build_texture((Tex *)bnode->id); + } + else if (id_type == ID_IM) { + /* nothing for now. */ + } + else if (id_type == ID_OB) { + build_object((Object *)id); + } + 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); + group_ntree->id.tag |= LIB_TAG_DOIT; } + ComponentKey group_shading_key(&group_ntree->id, + DEG_NODE_TYPE_SHADING); + add_relation(group_shading_key, shading_key, "Group Node"); + } + else { + BLI_assert(!"Unknown ID type used for node"); } } @@ -1990,7 +1998,7 @@ void DepsgraphRelationBuilder::build_lightprobe(Object *object) void DepsgraphRelationBuilder::build_copy_on_write_relations() { - foreach (IDDepsNode *id_node, m_graph->id_nodes) { + foreach (IDDepsNode *id_node, graph_->id_nodes) { build_copy_on_write_relations(id_node); } } @@ -2026,13 +2034,13 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDDepsNode *id_node */ OperationDepsNode *op_entry = comp_node->get_entry_operation(); if (op_entry != NULL) { - m_graph->add_new_relation(op_cow, op_entry, "CoW Dependency"); + graph_->add_new_relation(op_cow, op_entry, "CoW Dependency"); } /* All dangling operations should also be executed after copy-on-write. */ GHASH_FOREACH_BEGIN(OperationDepsNode *, op_node, comp_node->operations_map) { if (op_node->inlinks.size() == 0) { - m_graph->add_new_relation(op_cow, op_node, "CoW Dependency"); + graph_->add_new_relation(op_cow, op_node, "CoW Dependency"); } } GHASH_FOREACH_END(); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h index e8bdc662bd6..81636db0bcf 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h @@ -167,9 +167,9 @@ struct RNAPathKey struct DepsgraphRelationBuilder { - DepsgraphRelationBuilder(Depsgraph *graph); + DepsgraphRelationBuilder(Main *bmain, Depsgraph *graph); - void begin_build(Main *bmain); + void begin_build(); template <typename KeyFrom, typename KeyTo> void add_relation(const KeyFrom& key_from, @@ -186,11 +186,11 @@ struct DepsgraphRelationBuilder const DepsNodeHandle *handle, const char *description); - void build_scene(Main *bmain, Scene *scene); - void build_group(Main *bmain, Scene *scene, Object *object, Group *group); - void build_object(Main *bmain, Scene *scene, Object *ob); + void build_scene(Scene *scene); + void build_group(Object *object, Group *group); + void build_object(Object *ob); void build_object_parent(Object *ob); - void build_constraints(Scene *scene, ID *id, + void build_constraints(ID *id, eDepsNode_Type component_type, const char *component_subdata, ListBase *constraints, @@ -199,9 +199,9 @@ struct DepsgraphRelationBuilder void build_driver(ID *id, FCurve *fcurve); void build_world(World *world); void build_rigidbody(Scene *scene); - void build_particles(Scene *scene, Object *ob); + void build_particles(Object *ob); void build_particle_settings(ParticleSettings *part); - void build_cloth(Scene *scene, Object *object, ModifierData *md); + void build_cloth(Object *object, ModifierData *md); void build_ik_pose(Object *ob, bPoseChannel *pchan, bConstraint *con, @@ -210,10 +210,10 @@ struct DepsgraphRelationBuilder bPoseChannel *pchan, bConstraint *con, RootPChanMap *root_map); - void build_rig(Main *bmain, Scene *scene, Object *ob); + void build_rig(Object *ob); void build_proxy_rig(Object *ob); void build_shapekeys(ID *obdata, Key *key); - void build_obdata_geom(Main *bmain, Scene *scene, Object *ob); + void build_obdata_geom(Object *ob); void build_camera(Object *ob); void build_lamp(Object *ob); void build_nodetree(bNodeTree *ntree); @@ -228,10 +228,15 @@ struct DepsgraphRelationBuilder void build_lightprobe(Object *object); void add_collision_relations(const OperationKey &key, - Scene *scene, Object *ob, Group *group, - bool dupli, const char *name); + Scene *scene, + Object *ob, + Group *group, + bool dupli, + const char *name); void add_forcefield_relations(const OperationKey &key, - Scene *scene, Object *ob, ParticleSystem *psys, + Scene *scene, + Object *ob, + ParticleSystem *psys, EffectorWeights *eff, bool add_absorption, const char *name); @@ -278,7 +283,12 @@ protected: bool needs_animdata_node(ID *id); private: - Depsgraph *m_graph; + /* State which never changes, same for the whole builder time. */ + Main *bmain_; + Depsgraph *graph_; + + /* State which demotes currently built entities. */ + Scene *scene_; }; struct DepsNodeHandle diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc index c23d6d3a2bd..476e793d3f7 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc @@ -302,7 +302,7 @@ void DepsgraphRelationBuilder::build_splineik_pose(Object *ob, } /* Pose/Armature Bones Graph */ -void DepsgraphRelationBuilder::build_rig(Main *bmain, Scene *scene, Object *ob) +void DepsgraphRelationBuilder::build_rig(Object *ob) { /* Armature-Data */ bArmature *arm = (bArmature *)ob->data; @@ -415,7 +415,7 @@ void DepsgraphRelationBuilder::build_rig(Main *bmain, Scene *scene, Object *ob) /* Buil constraints. */ if (pchan->constraints.first != NULL) { /* constraints stack and constraint dependencies */ - build_constraints(scene, &ob->id, DEG_NODE_TYPE_BONE, pchan->name, &pchan->constraints, &root_map); + build_constraints(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, &pchan->constraints, &root_map); /* pose -> constraints */ OperationKey constraints_key(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_CONSTRAINTS); @@ -441,7 +441,7 @@ void DepsgraphRelationBuilder::build_rig(Main *bmain, Scene *scene, Object *ob) add_relation(bone_done_key, flush_key, "PoseEval Result-Bone Link"); /* Custom shape. */ if (pchan->custom != NULL) { - build_object(bmain, scene, pchan->custom); + build_object(pchan->custom); } } } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc index b8a2fe4851d..af37decdbc7 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc @@ -68,23 +68,26 @@ extern "C" { namespace DEG { -void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene) +void DepsgraphRelationBuilder::build_scene(Scene *scene) { if (scene->set) { - build_scene(bmain, scene->set); + build_scene(scene->set); } /* XXX store scene to access from DAG_get_scene */ - m_graph->scene = scene; + graph_->scene = scene; + + /* Setup currently building context. */ + scene_ = scene; /* scene objects */ for (SceneLayer *sl = (SceneLayer *)scene->render_layers.first; sl; sl = sl->next) { for (Base *base = (Base *)sl->object_bases.first; base; base = base->next) { - build_object(bmain, scene, base->object); + build_object(base->object); } } if (scene->camera != NULL) { - build_object(bmain, scene, scene->camera); + build_object(scene->camera); } /* rigidbody */ @@ -113,12 +116,12 @@ void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene) } /* Masks. */ - LINKLIST_FOREACH (Mask *, mask, &bmain->mask) { + LINKLIST_FOREACH (Mask *, mask, &bmain_->mask) { build_mask(mask); } /* Movie clips. */ - LINKLIST_FOREACH (MovieClip *, clip, &bmain->movieclip) { + LINKLIST_FOREACH (MovieClip *, clip, &bmain_->movieclip) { build_movieclip(clip); } @@ -126,8 +129,8 @@ void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene) build_scene_layer_collections(scene); /* TODO(sergey): Do this flush on CoW object? */ - for (Depsgraph::OperationNodes::const_iterator it_op = m_graph->operations.begin(); - it_op != m_graph->operations.end(); + for (Depsgraph::OperationNodes::const_iterator it_op = graph_->operations.begin(); + it_op != graph_->operations.end(); ++it_op) { OperationDepsNode *node = *it_op; diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc index ab7e28e1638..c8c36646ade 100644 --- a/source/blender/depsgraph/intern/depsgraph_build.cc +++ b/source/blender/depsgraph/intern/depsgraph_build.cc @@ -216,15 +216,15 @@ void DEG_graph_build_from_scene(Depsgraph *graph, Main *bmain, Scene *scene) /* 1) Generate all the nodes in the graph first */ DEG::DepsgraphNodeBuilder node_builder(bmain, deg_graph); - node_builder.begin_build(bmain); - node_builder.build_scene(bmain, scene, DEG::DEG_ID_LINKED_DIRECTLY); + node_builder.begin_build(); + node_builder.build_scene(scene, DEG::DEG_ID_LINKED_DIRECTLY); /* 2) Hook up relationships between operations - to determine evaluation * order. */ - DEG::DepsgraphRelationBuilder relation_builder(deg_graph); - relation_builder.begin_build(bmain); - relation_builder.build_scene(bmain, scene); + DEG::DepsgraphRelationBuilder relation_builder(bmain, deg_graph); + relation_builder.begin_build(); + relation_builder.build_scene(scene); if (DEG_depsgraph_use_copy_on_write()) { relation_builder.build_copy_on_write_relations(); } |