diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-09 11:17:47 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-09 12:33:44 +0300 |
commit | 5e38ee996cd0ca18d651d87573a1dfe61e893a13 (patch) | |
tree | fbf0d5caebb7c23b7a2707b9f2527560a014326f /source/blender/depsgraph/intern/builder | |
parent | f424d5b5c9da1e8ce79ce34e5854e8d90ffe2460 (diff) |
Depsgraph: Remove chains of scene being passed all over in relations builder
Diffstat (limited to 'source/blender/depsgraph/intern/builder')
5 files changed, 54 insertions, 48 deletions
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 8a3c1c6727f..1ea44093cd7 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc @@ -78,6 +78,7 @@ void DepsgraphNodeBuilder::build_scene(Scene *scene) build_scene(scene->set); } + /* Setup currently building context. */ scene_ = scene; /* scene objects */ diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 6a7906717d5..883a756eef1 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -117,7 +117,6 @@ namespace { struct BuilderWalkUserData { DepsgraphRelationBuilder *builder; - Scene *scene; }; static void modifier_walk(void *user_data, @@ -127,7 +126,7 @@ static void modifier_walk(void *user_data, { BuilderWalkUserData *data = (BuilderWalkUserData *)user_data; if (*obpoin) { - data->builder->build_object(data->scene, *obpoin); + data->builder->build_object(*obpoin); } } @@ -140,7 +139,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); + data->builder->build_object((Object *)id); } } } @@ -391,9 +390,7 @@ void DepsgraphRelationBuilder::begin_build() FOREACH_NODETREE_END; } -void DepsgraphRelationBuilder::build_group(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; @@ -402,7 +399,7 @@ void DepsgraphRelationBuilder::build_group(Scene *scene, DEG_OPCODE_TRANSFORM_LOCAL); LINKLIST_FOREACH (GroupObject *, go, &group->gobject) { if (!group_done) { - build_object(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"); @@ -410,7 +407,7 @@ void DepsgraphRelationBuilder::build_group(Scene *scene, group_id->tag |= LIB_TAG_DOIT; } -void DepsgraphRelationBuilder::build_object(Scene *scene, Object *ob) +void DepsgraphRelationBuilder::build_object(Object *ob) { if (ob->id.tag & LIB_TAG_DOIT) { return; @@ -439,13 +436,11 @@ void DepsgraphRelationBuilder::build_object(Scene *scene, Object *ob) 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); } @@ -456,10 +451,7 @@ void DepsgraphRelationBuilder::build_object(Scene *scene, Object *ob) 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 +504,7 @@ void DepsgraphRelationBuilder::build_object(Scene *scene, Object *ob) case OB_MBALL: case OB_LATTICE: { - build_obdata_geom(scene, ob); + build_obdata_geom(ob); break; } @@ -521,7 +513,7 @@ void DepsgraphRelationBuilder::build_object(Scene *scene, Object *ob) build_proxy_rig(ob); } else { - build_rig(scene, ob); + build_rig(ob); } break; @@ -544,7 +536,7 @@ void DepsgraphRelationBuilder::build_object(Scene *scene, Object *ob) /* Particle systems. */ if (ob->particlesystem.first != NULL) { - build_particles(scene, ob); + build_particles(ob); } /* Grease pencil. */ @@ -555,7 +547,7 @@ void DepsgraphRelationBuilder::build_object(Scene *scene, Object *ob) /* Object that this is a proxy for. */ if (ob->proxy != NULL) { ob->proxy->proxy_from = ob; - build_object(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. */ @@ -566,7 +558,7 @@ void DepsgraphRelationBuilder::build_object(Scene *scene, Object *ob) /* Object dupligroup. */ if (ob->dup_group != NULL) { - build_group(scene, ob, ob->dup_group); + build_group(ob, ob->dup_group); } } @@ -662,7 +654,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, @@ -713,8 +705,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 -> @@ -1328,7 +1320,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, @@ -1366,14 +1358,14 @@ 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, ob->lay, 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, ob->lay | scene_->lay, true, "Hair Collision"); } /* effectors */ - add_forcefield_relations(psys_key, scene, ob, psys, part->effector_weights, part->type == PART_HAIR, "Particle Field"); + add_forcefield_relations(psys_key, scene_, ob, psys, part->effector_weights, part->type == PART_HAIR, "Particle Field"); /* boids */ if (part->boids) { @@ -1412,8 +1404,7 @@ void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob) // TODO... } -void DepsgraphRelationBuilder::build_cloth(Scene * /*scene*/, - Object *object, +void DepsgraphRelationBuilder::build_cloth(Object *object, ModifierData * /*md*/) { OperationKey cache_key(&object->id, @@ -1470,7 +1461,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(Scene *scene, Object *ob) +void DepsgraphRelationBuilder::build_obdata_geom(Object *ob) { ID *obdata = (ID *)ob->data; @@ -1498,7 +1489,7 @@ void DepsgraphRelationBuilder::build_obdata_geom(Scene *scene, Object *ob) mti->updateDepsgraph( md, bmain_, - scene, + scene_, ob, reinterpret_cast< ::DepsNodeHandle* >(&handle)); } @@ -1520,7 +1511,7 @@ void DepsgraphRelationBuilder::build_obdata_geom(Scene *scene, Object *ob) } if (md->type == eModifierType_Cloth) { - build_cloth(scene, ob, md); + build_cloth(ob, md); } } } @@ -1580,8 +1571,7 @@ void DepsgraphRelationBuilder::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) { /* non-motherball -> cannot be directly evaluated! */ @@ -1602,18 +1592,18 @@ void DepsgraphRelationBuilder::build_obdata_geom(Scene *scene, Object *ob) // 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(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(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(scene, cu->textoncurve); + build_object(cu->textoncurve); add_relation(textoncurve_key, geom_key, "Text on Curve"); } } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h index c14cbc3a309..86227f4aaf8 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h @@ -185,10 +185,10 @@ struct DepsgraphRelationBuilder const char *description); void build_scene(Scene *scene); - void build_group(Scene *scene, Object *object, Group *group); - void build_object(Scene *scene, Object *ob); + 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, @@ -197,8 +197,8 @@ 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_cloth(Scene *scene, Object *object, ModifierData *md); + void build_particles(Object *ob); + void build_cloth(Object *object, ModifierData *md); void build_ik_pose(Object *ob, bPoseChannel *pchan, bConstraint *con, @@ -207,10 +207,10 @@ struct DepsgraphRelationBuilder bPoseChannel *pchan, bConstraint *con, RootPChanMap *root_map); - void build_rig(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(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); @@ -223,8 +223,20 @@ 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_forcefield_relations(const OperationKey &key, Scene *scene, Object *ob, ParticleSystem *psys, EffectorWeights *eff, bool add_absorption, const char *name); + void add_collision_relations(const OperationKey &key, + Scene *scene, + Object *ob, + Group *group, + int layer, + 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); template <typename KeyType> OperationDepsNode *find_operation_node(const KeyType &key); 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 bde3c0fae10..6ff21393ed6 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(Scene *scene, Object *ob) +void DepsgraphRelationBuilder::build_rig(Object *ob) { /* Armature-Data */ bArmature *arm = (bArmature *)ob->data; @@ -420,7 +420,7 @@ void DepsgraphRelationBuilder::build_rig(Scene *scene, Object *ob) /* 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); 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 cebb7c79bfc..bedcb5aa223 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc @@ -73,10 +73,13 @@ void DepsgraphRelationBuilder::build_scene(Scene *scene) build_scene(scene->set); } + /* Setup currently building context. */ + scene_ = scene; + /* scene objects */ LINKLIST_FOREACH (Base *, base, &scene->base) { Object *ob = base->object; - build_object(scene, ob); + build_object(ob); } /* rigidbody */ |