Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-11-08 20:06:51 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-11-09 12:33:44 +0300
commitf424d5b5c9da1e8ce79ce34e5854e8d90ffe2460 (patch)
tree5fc59fc41f7c6759e2d7cec33b2e78e2cc585225
parentad986ae29ec6024394e179dca57c5749b1734a36 (diff)
Depsgraph: Cleanup, remove scene being passed all over
Use the state one instead.
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc72
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.h28
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc28
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc4
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc3
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.h4
6 files changed, 73 insertions, 66 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 89a2dba87c8..fdbd4100640 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -117,7 +117,6 @@ namespace {
struct BuilderWalkUserData {
DepsgraphNodeBuilder *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, NULL, *obpoin);
+ data->builder->build_object(NULL, *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, NULL, (Object *)id);
+ data->builder->build_object(NULL, (Object *)id);
}
}
}
@@ -154,7 +153,8 @@ void constraint_walk(bConstraint * /*con*/,
DepsgraphNodeBuilder::DepsgraphNodeBuilder(Main *bmain, Depsgraph *graph)
: bmain_(bmain),
- graph_(graph)
+ graph_(graph),
+ scene_(NULL)
{
}
@@ -296,9 +296,7 @@ void DepsgraphNodeBuilder::begin_build() {
FOREACH_NODETREE_END;
}
-void DepsgraphNodeBuilder::build_group(Scene *scene,
- Base *base,
- Group *group)
+void DepsgraphNodeBuilder::build_group(Base *base, Group *group)
{
ID *group_id = &group->id;
if (group_id->tag & LIB_TAG_DOIT) {
@@ -307,11 +305,11 @@ void DepsgraphNodeBuilder::build_group(Scene *scene,
group_id->tag |= LIB_TAG_DOIT;
LINKLIST_FOREACH (GroupObject *, go, &group->gobject) {
- build_object(scene, base, go->ob);
+ build_object(base, go->ob);
}
}
-void DepsgraphNodeBuilder::build_object(Scene *scene, Base *base, Object *ob)
+void DepsgraphNodeBuilder::build_object(Base *base, Object *ob)
{
const bool has_object = (ob->id.tag & LIB_TAG_DOIT);
IDDepsNode *id_node = (has_object)
@@ -339,21 +337,19 @@ void DepsgraphNodeBuilder::build_object(Scene *scene, Base *base, Object *ob)
ob->customdata_mask = 0;
/* Standard components. */
- build_object_transform(scene, ob);
+ build_object_transform(ob);
if (ob->parent != NULL) {
- build_object(scene, NULL, ob->parent);
+ build_object(NULL, ob->parent);
}
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);
}
@@ -367,7 +363,7 @@ void DepsgraphNodeBuilder::build_object(Scene *scene, Base *base, Object *ob)
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.
*/
@@ -384,7 +380,7 @@ void DepsgraphNodeBuilder::build_object(Scene *scene, Base *base, Object *ob)
build_proxy_rig(ob);
}
else {
- build_rig(scene, ob);
+ build_rig(ob);
}
break;
@@ -417,7 +413,7 @@ void DepsgraphNodeBuilder::build_object(Scene *scene, Base *base, Object *ob)
/* particle systems */
if (ob->particlesystem.first != NULL) {
- build_particles(scene, ob);
+ build_particles(ob);
}
/* Grease pencil. */
@@ -428,35 +424,35 @@ void DepsgraphNodeBuilder::build_object(Scene *scene, Base *base, Object *ob)
/* Object that this is a proxy for. */
if (ob->proxy) {
ob->proxy->proxy_from = ob;
- build_object(scene, base, ob->proxy);
+ build_object(base, ob->proxy);
}
/* Object dupligroup. */
if (ob->dup_group != NULL) {
- build_group(scene, base, ob->dup_group);
+ build_group(base, ob->dup_group);
}
}
-void DepsgraphNodeBuilder::build_object_transform(Scene *scene, Object *ob)
+void DepsgraphNodeBuilder::build_object_transform(Object *ob)
{
OperationDepsNode *op_node;
/* local transforms (from transform channels - loc/rot/scale + deltas) */
op_node = add_operation_node(&ob->id, DEG_NODE_TYPE_TRANSFORM,
- function_bind(BKE_object_eval_local_transform, _1, scene, ob),
+ function_bind(BKE_object_eval_local_transform, _1, scene_, ob),
DEG_OPCODE_TRANSFORM_LOCAL);
op_node->set_as_entry();
/* object parent */
if (ob->parent) {
add_operation_node(&ob->id, DEG_NODE_TYPE_TRANSFORM,
- function_bind(BKE_object_eval_parent, _1, scene, ob),
+ function_bind(BKE_object_eval_parent, _1, scene_, ob),
DEG_OPCODE_TRANSFORM_PARENT);
}
/* object constraints */
if (ob->constraints.first) {
- build_object_constraints(scene, ob);
+ build_object_constraints(ob);
}
/* Temporary uber-update node, which does everything.
@@ -467,7 +463,7 @@ void DepsgraphNodeBuilder::build_object_transform(Scene *scene, Object *ob)
* TODO(sergey): Get rid of this node.
*/
add_operation_node(&ob->id, DEG_NODE_TYPE_TRANSFORM,
- function_bind(BKE_object_eval_uber_transform, _1, scene, ob),
+ function_bind(BKE_object_eval_uber_transform, _1, scene_, ob),
DEG_OPCODE_TRANSFORM_OBJECT_UBEREVAL);
/* object transform is done */
@@ -494,11 +490,11 @@ 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, scene, ob),
+ function_bind(BKE_object_eval_constraints, _1, scene_, ob),
DEG_OPCODE_TRANSFORM_CONSTRAINTS);
}
@@ -650,7 +646,7 @@ void DepsgraphNodeBuilder::build_rigidbody(Scene *scene)
}
}
-void DepsgraphNodeBuilder::build_particles(Scene *scene, Object *ob)
+void DepsgraphNodeBuilder::build_particles(Object *ob)
{
/**
* Particle Systems Nodes
@@ -674,7 +670,7 @@ void DepsgraphNodeBuilder::build_particles(Scene *scene, Object *ob)
add_operation_node(psys_comp,
function_bind(BKE_particle_system_eval_init,
_1,
- scene,
+ scene_,
ob),
DEG_OPCODE_PARTICLE_SYSTEM_EVAL_INIT);
@@ -698,13 +694,13 @@ void DepsgraphNodeBuilder::build_particles(Scene *scene, Object *ob)
// TODO...
}
-void DepsgraphNodeBuilder::build_cloth(Scene *scene, Object *object)
+void DepsgraphNodeBuilder::build_cloth(Object *object)
{
add_operation_node(&object->id,
DEG_NODE_TYPE_CACHE,
function_bind(BKE_object_eval_cloth,
_1,
- scene,
+ scene_,
object),
DEG_OPCODE_GEOMETRY_CLOTH_MODIFIER);
}
@@ -721,7 +717,7 @@ 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)
{
ID *obdata = (ID *)ob->data;
OperationDepsNode *op_node;
@@ -746,7 +742,10 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob)
*/
op_node = add_operation_node(&ob->id,
DEG_NODE_TYPE_GEOMETRY,
- function_bind(BKE_object_eval_uber_data, _1, scene, ob),
+ function_bind(BKE_object_eval_uber_data,
+ _1,
+ scene_,
+ ob),
DEG_OPCODE_GEOMETRY_UBEREVAL);
op_node->set_as_exit();
@@ -762,7 +761,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);
}
}
@@ -813,8 +812,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 */
@@ -851,13 +849,13 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob)
*/
Curve *cu = (Curve *)obdata;
if (cu->bevobj != NULL) {
- build_object(scene, NULL, cu->bevobj);
+ build_object(NULL, cu->bevobj);
}
if (cu->taperobj != NULL) {
- build_object(scene, NULL, cu->taperobj);
+ build_object(NULL, cu->taperobj);
}
if (ob->type == OB_FONT && cu->textoncurve != NULL) {
- build_object(scene, NULL, cu->textoncurve);
+ build_object(NULL, cu->textoncurve);
}
break;
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
index db57b2921ea..ec9fe6a40a2 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@ -119,28 +119,26 @@ struct DepsgraphNodeBuilder {
int name_tag = -1);
void build_scene(Scene *scene);
- void build_group(Scene *scene, Base *base, Group *group);
- void build_object(Scene *scene, Base *base, Object *ob);
- 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_group(Base *base, Group *group);
+ void build_object(Base *base, Object *ob);
+ 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_cloth(Scene *scene, Object *object);
+ void build_particles(Object *ob);
+ 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);
@@ -156,8 +154,12 @@ struct DepsgraphNodeBuilder {
void build_movieclip(MovieClip *clip);
protected:
+ /* State which never changes, same for the whole builder time. */
Main *bmain_;
Depsgraph *graph_;
+
+ /* State which demotes currently built entities. */
+ Scene *scene_;
};
} // 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 f99be191529..a1f20b1c683 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
@@ -64,16 +64,16 @@ 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, scene, ob, pchan),
+ function_bind(BKE_pose_constraints_evaluate, _1, scene_, ob, pchan),
DEG_OPCODE_BONE_CONSTRAINTS);
}
/* IK Solver Eval Steps */
-void DepsgraphNodeBuilder::build_ik_pose(Scene *scene, Object *ob, bPoseChannel *pchan, bConstraint *con)
+void DepsgraphNodeBuilder::build_ik_pose(Object *ob, bPoseChannel *pchan, bConstraint *con)
{
bKinematicConstraint *data = (bKinematicConstraint *)con->data;
@@ -91,12 +91,12 @@ void DepsgraphNodeBuilder::build_ik_pose(Scene *scene, Object *ob, bPoseChannel
/* 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, scene, ob, rootchan),
+ function_bind(BKE_pose_iktree_evaluate, _1, scene_, ob, rootchan),
DEG_OPCODE_POSE_IK_SOLVER);
}
/* Spline IK Eval Steps */
-void DepsgraphNodeBuilder::build_splineik_pose(Scene *scene, Object *ob, bPoseChannel *pchan, bConstraint *con)
+void DepsgraphNodeBuilder::build_splineik_pose(Object *ob, bPoseChannel *pchan, bConstraint *con)
{
bSplineIKConstraint *data = (bSplineIKConstraint *)con->data;
@@ -107,12 +107,12 @@ void DepsgraphNodeBuilder::build_splineik_pose(Scene *scene, Object *ob, bPoseCh
* Store the "root bone" of this chain in the solver, so it knows where to start.
*/
add_operation_node(&ob->id, DEG_NODE_TYPE_EVAL_POSE, rootchan->name,
- function_bind(BKE_pose_splineik_evaluate, _1, scene, ob, rootchan),
+ function_bind(BKE_pose_splineik_evaluate, _1, scene_, ob, rootchan),
DEG_OPCODE_POSE_SPLINE_IK_SOLVER);
}
/* Pose/Armature Bones Graph */
-void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *ob)
+void DepsgraphNodeBuilder::build_rig(Object *ob)
{
bArmature *arm = (bArmature *)ob->data;
OperationDepsNode *op_node;
@@ -179,18 +179,18 @@ void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *ob)
/* pose eval context */
op_node = add_operation_node(&ob->id,
DEG_NODE_TYPE_EVAL_POSE,
- function_bind(BKE_pose_eval_init, _1, scene, ob, ob->pose),
+ function_bind(BKE_pose_eval_init, _1, scene_, ob, ob->pose),
DEG_OPCODE_POSE_INIT);
op_node->set_as_entry();
op_node = add_operation_node(&ob->id,
DEG_NODE_TYPE_EVAL_POSE,
- function_bind(BKE_pose_eval_init_ik, _1, scene, ob, ob->pose),
+ function_bind(BKE_pose_eval_init_ik, _1, scene_, ob, ob->pose),
DEG_OPCODE_POSE_INIT_IK);
op_node = add_operation_node(&ob->id,
DEG_NODE_TYPE_EVAL_POSE,
- function_bind(BKE_pose_eval_flush, _1, scene, ob, ob->pose),
+ function_bind(BKE_pose_eval_flush, _1, scene_, ob, ob->pose),
DEG_OPCODE_POSE_DONE);
op_node->set_as_exit();
@@ -202,7 +202,7 @@ void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *ob)
op_node->set_as_entry();
add_operation_node(&ob->id, DEG_NODE_TYPE_BONE, pchan->name,
- function_bind(BKE_pose_eval_bone, _1, scene, ob, pchan),
+ function_bind(BKE_pose_eval_bone, _1, scene_, ob, pchan),
DEG_OPCODE_BONE_POSE_PARENT);
add_operation_node(&ob->id, DEG_NODE_TYPE_BONE, pchan->name,
@@ -216,7 +216,7 @@ void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *ob)
/* constraints */
if (pchan->constraints.first != NULL) {
- build_pose_constraints(scene, ob, pchan);
+ build_pose_constraints(ob, pchan);
}
/**
@@ -233,11 +233,11 @@ void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *ob)
LINKLIST_FOREACH (bConstraint *, con, &pchan->constraints) {
switch (con->type) {
case CONSTRAINT_TYPE_KINEMATIC:
- build_ik_pose(scene, ob, pchan, con);
+ build_ik_pose(ob, pchan, con);
break;
case CONSTRAINT_TYPE_SPLINEIK:
- build_splineik_pose(scene, ob, pchan, con);
+ build_splineik_pose(ob, pchan, con);
break;
default:
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 4d048d30d55..8a3c1c6727f 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc
@@ -78,10 +78,12 @@ void DepsgraphNodeBuilder::build_scene(Scene *scene)
build_scene(scene->set);
}
+ scene_ = scene;
+
/* scene objects */
LINKLIST_FOREACH (Base *, base, &scene->base) {
Object *ob = base->object;
- build_object(scene, base, ob);
+ build_object(base, ob);
}
/* rigidbody */
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 4218771b48d..6a7906717d5 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -195,7 +195,8 @@ RNAPathKey::RNAPathKey(ID *id, const char *path) :
DepsgraphRelationBuilder::DepsgraphRelationBuilder(Main *bmain,
Depsgraph *graph)
: bmain_(bmain),
- graph_(graph)
+ graph_(graph),
+ scene_(NULL)
{
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
index ef012cf6c9b..c14cbc3a309 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
@@ -252,8 +252,12 @@ protected:
bool needs_animdata_node(ID *id);
private:
+ /* State which never changes, same for the whole builder time. */
Main *bmain_;
Depsgraph *graph_;
+
+ /* State which demotes currently built entities. */
+ Scene *scene_;
};
struct DepsNodeHandle