diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-06-01 17:04:35 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-06-01 17:22:35 +0300 |
commit | a72daea36eb1585c5e4d7b6911381c53b480b055 (patch) | |
tree | 3adf527394df4732c5065009f540d08e6206e4d4 | |
parent | 3a7361ec395293477bb395832459339348fb8e8b (diff) |
Depsgraph: use explicit marking of component entry/exit operations
This isn't used too often, and haivng such API will let us to skip
specifying operation type for all oeprations.
6 files changed, 80 insertions, 33 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 3330795d053..78d0b2b323e 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -446,10 +446,13 @@ void DepsgraphNodeBuilder::build_object(Scene *scene, Base *base, Object *ob) void DepsgraphNodeBuilder::build_object_transform(Scene *scene, Object *ob) { + OperationDepsNode *op_node; + /* local transforms (from transform channels - loc/rot/scale + deltas) */ - add_operation_node(&ob->id, DEG_NODE_TYPE_TRANSFORM, + op_node = add_operation_node(&ob->id, DEG_NODE_TYPE_TRANSFORM, DEPSOP_TYPE_INIT, function_bind(BKE_object_eval_local_transform, _1, scene, ob), DEG_OPCODE_TRANSFORM_LOCAL); + op_node->set_as_entry(); /* object parent */ if (ob->parent) { @@ -475,9 +478,10 @@ void DepsgraphNodeBuilder::build_object_transform(Scene *scene, Object *ob) DEG_OPCODE_OBJECT_UBEREVAL); /* object transform is done */ - add_operation_node(&ob->id, DEG_NODE_TYPE_TRANSFORM, + op_node = add_operation_node(&ob->id, DEG_NODE_TYPE_TRANSFORM, DEPSOP_TYPE_POST, function_bind(BKE_object_eval_done, _1, ob), DEG_OPCODE_TRANSFORM_FINAL); + op_node->set_as_exit(); } /** @@ -735,18 +739,20 @@ void DepsgraphNodeBuilder::build_shapekeys(Key *key) void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob) { ID *obdata = (ID *)ob->data; + OperationDepsNode *op_node; /* TODO(sergey): This way using this object's properties as driver target * works fine. * * Does this depend on other nodes? */ - add_operation_node(&ob->id, + op_node = add_operation_node(&ob->id, DEG_NODE_TYPE_PARAMETERS, DEPSOP_TYPE_POST, NULL, DEG_OPCODE_PLACEHOLDER, "Parameters Eval"); + op_node->set_as_exit(); /* Temporary uber-update node, which does everything. * It is for the being we're porting old dependencies into the new system. @@ -755,18 +761,20 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob) * * TODO(sergey): Get rid of this node. */ - add_operation_node(&ob->id, + op_node = add_operation_node(&ob->id, DEG_NODE_TYPE_GEOMETRY, DEPSOP_TYPE_POST, function_bind(BKE_object_eval_uber_data, _1, scene, ob), DEG_OPCODE_GEOMETRY_UBEREVAL); + op_node->set_as_exit(); - add_operation_node(&ob->id, + op_node = add_operation_node(&ob->id, DEG_NODE_TYPE_GEOMETRY, DEPSOP_TYPE_INIT, NULL, DEG_OPCODE_PLACEHOLDER, "Eval Init"); + op_node->set_as_entry(); // TODO: "Done" operation @@ -821,7 +829,7 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob) //Mesh *me = (Mesh *)ob->data; /* evaluation operations */ - add_operation_node(obdata, + op_node = add_operation_node(obdata, DEG_NODE_TYPE_GEOMETRY, DEPSOP_TYPE_INIT, function_bind(BKE_mesh_eval_geometry, @@ -829,6 +837,7 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob) (Mesh *)obdata), DEG_OPCODE_PLACEHOLDER, "Geometry Eval"); + op_node->set_as_entry(); break; } @@ -840,7 +849,7 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob) if (mom == ob) { /* metaball evaluation operations */ /* NOTE: only the motherball gets evaluated! */ - add_operation_node(obdata, + op_node = add_operation_node(obdata, DEG_NODE_TYPE_GEOMETRY, DEPSOP_TYPE_INIT, function_bind(BKE_mball_eval_geometry, @@ -848,6 +857,7 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob) (MetaBall *)obdata), DEG_OPCODE_PLACEHOLDER, "Geometry Eval"); + op_node->set_as_entry(); } break; } @@ -858,7 +868,7 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob) { /* Curve/nurms evaluation operations. */ /* - calculate curve geometry (including path) */ - add_operation_node(obdata, + op_node = add_operation_node(obdata, DEG_NODE_TYPE_GEOMETRY, DEPSOP_TYPE_INIT, function_bind(BKE_curve_eval_geometry, @@ -866,6 +876,7 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob) (Curve *)obdata), DEG_OPCODE_PLACEHOLDER, "Geometry Eval"); + op_node->set_as_entry(); /* Calculate curve path - this is used by constraints, etc. */ if (ELEM(ob->type, OB_CURVE, OB_FONT)) { @@ -898,7 +909,7 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob) case OB_LATTICE: { /* Lattice evaluation operations. */ - add_operation_node(obdata, + op_node = add_operation_node(obdata, DEG_NODE_TYPE_GEOMETRY, DEPSOP_TYPE_INIT, function_bind(BKE_lattice_eval_geometry, @@ -906,13 +917,15 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob) (Lattice *)obdata), DEG_OPCODE_PLACEHOLDER, "Geometry Eval"); + op_node->set_as_entry(); break; } } - add_operation_node(obdata, DEG_NODE_TYPE_GEOMETRY, + op_node = add_operation_node(obdata, DEG_NODE_TYPE_GEOMETRY, DEPSOP_TYPE_POST, NULL, DEG_OPCODE_PLACEHOLDER, "Eval Done"); + op_node->set_as_exit(); /* Parameters for driver sources. */ add_operation_node(obdata, DEG_NODE_TYPE_PARAMETERS, DEPSOP_TYPE_EXEC, NULL, @@ -977,12 +990,14 @@ void DepsgraphNodeBuilder::build_nodetree(bNodeTree *ntree) /* nodetree itself */ ID *ntree_id = &ntree->id; + OperationDepsNode *op_node; build_animdata(ntree_id); /* Parameters for drivers. */ - add_operation_node(ntree_id, DEG_NODE_TYPE_PARAMETERS, DEPSOP_TYPE_POST, NULL, + op_node = add_operation_node(ntree_id, DEG_NODE_TYPE_PARAMETERS, DEPSOP_TYPE_POST, NULL, DEG_OPCODE_PLACEHOLDER, "Parameters Eval"); + op_node->set_as_exit(); /* nodetree's nodes... */ LINKLIST_FOREACH (bNode *, bnode, &ntree->nodes) { 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 29d80290bd3..00b9ef8bf6a 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc @@ -113,6 +113,7 @@ void DepsgraphNodeBuilder::build_splineik_pose(Scene *scene, Object *ob, bPoseCh void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *ob) { bArmature *arm = (bArmature *)ob->data; + OperationDepsNode *op_node; /* animation and/or drivers linking posebones to base-armature used to define them * NOTE: AnimData here is really used to control animated deform properties, @@ -175,18 +176,21 @@ void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *ob) */ /* pose eval context */ - add_operation_node(&ob->id, DEG_NODE_TYPE_EVAL_POSE, + op_node = add_operation_node(&ob->id, DEG_NODE_TYPE_EVAL_POSE, DEPSOP_TYPE_INIT, function_bind(BKE_pose_eval_init, _1, scene, ob, ob->pose), DEG_OPCODE_POSE_INIT); + op_node->set_as_entry(); - add_operation_node(&ob->id, DEG_NODE_TYPE_EVAL_POSE, + op_node = add_operation_node(&ob->id, DEG_NODE_TYPE_EVAL_POSE, DEPSOP_TYPE_POST, function_bind(BKE_pose_eval_flush, _1, scene, ob, ob->pose), DEG_OPCODE_POSE_DONE); + op_node->set_as_exit(); /* bones */ LINKLIST_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { /* node for bone eval */ - add_operation_node(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, + op_node = add_operation_node(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, DEPSOP_TYPE_INIT, NULL, // XXX: BKE_pose_eval_bone_local DEG_OPCODE_BONE_LOCAL); + op_node->set_as_entry(); add_operation_node(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, DEPSOP_TYPE_EXEC, function_bind(BKE_pose_eval_bone, _1, scene, ob, pchan), // XXX: BKE_pose_eval_bone_pose @@ -196,9 +200,10 @@ void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *ob) DEPSOP_TYPE_OUT, NULL, /* NOTE: dedicated noop for easier relationship construction */ DEG_OPCODE_BONE_READY); - add_operation_node(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, + op_node = add_operation_node(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, DEPSOP_TYPE_POST, function_bind(BKE_pose_bone_done, _1, pchan), DEG_OPCODE_BONE_DONE); + op_node->set_as_exit(); /* constraints */ if (pchan->constraints.first != NULL) { @@ -236,6 +241,8 @@ void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *ob) void DepsgraphNodeBuilder::build_proxy_rig(Object *ob) { ID *obdata = (ID *)ob->data; + OperationDepsNode *op_node; + build_animdata(obdata); BLI_assert(ob->pose != NULL); @@ -246,31 +253,35 @@ void DepsgraphNodeBuilder::build_proxy_rig(Object *ob) BKE_pose_update_constraint_flags(ob->pose); } - add_operation_node(&ob->id, + op_node = add_operation_node(&ob->id, DEG_NODE_TYPE_EVAL_POSE, DEPSOP_TYPE_INIT, function_bind(BKE_pose_eval_proxy_copy, _1, ob), DEG_OPCODE_POSE_INIT); + op_node->set_as_entry(); LINKLIST_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { - add_operation_node(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, + op_node = add_operation_node(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, DEPSOP_TYPE_INIT, NULL, DEG_OPCODE_BONE_LOCAL); + op_node->set_as_entry(); add_operation_node(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, DEPSOP_TYPE_EXEC, NULL, DEG_OPCODE_BONE_READY); - add_operation_node(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, + op_node = add_operation_node(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, DEPSOP_TYPE_POST, NULL, DEG_OPCODE_BONE_DONE); + op_node->set_as_exit(); } - add_operation_node(&ob->id, + op_node = add_operation_node(&ob->id, DEG_NODE_TYPE_EVAL_POSE, DEPSOP_TYPE_POST, NULL, DEG_OPCODE_POSE_DONE); + op_node->set_as_exit(); } } // namespace DEG diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.cc b/source/blender/depsgraph/intern/nodes/deg_node_component.cc index ce44a82b75d..80a1ce3f98e 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node_component.cc +++ b/source/blender/depsgraph/intern/nodes/deg_node_component.cc @@ -213,17 +213,6 @@ OperationDepsNode *ComponentDepsNode::add_operation(eDepsOperation_Type optype, OperationIDKey *key = OBJECT_GUARDED_NEW(OperationIDKey, opcode, name, name_tag); BLI_ghash_insert(operations_map, key, op_node); - /* set as entry/exit node of component (if appropriate) */ - if (optype == DEPSOP_TYPE_INIT) { - BLI_assert(this->entry_operation == NULL); - this->entry_operation = op_node; - } - else if (optype == DEPSOP_TYPE_POST) { - // XXX: review whether DEPSOP_TYPE_OUT is better than DEPSOP_TYPE_POST, or maybe have both? - BLI_assert(this->exit_operation == NULL); - this->exit_operation = op_node; - } - /* set backlink */ op_node->owner = this; } @@ -242,6 +231,18 @@ OperationDepsNode *ComponentDepsNode::add_operation(eDepsOperation_Type optype, return op_node; } +void ComponentDepsNode::set_entry_operation(OperationDepsNode *op_node) +{ + BLI_assert(entry_operation == NULL); + entry_operation = op_node; +} + +void ComponentDepsNode::set_exit_operation(OperationDepsNode *op_node) +{ + BLI_assert(exit_operation == NULL); + exit_operation = op_node; +} + void ComponentDepsNode::clear_operations() { if (operations_map != NULL) { diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.h b/source/blender/depsgraph/intern/nodes/deg_node_component.h index 969771a29c9..0eb4e42950c 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node_component.h +++ b/source/blender/depsgraph/intern/nodes/deg_node_component.h @@ -105,6 +105,13 @@ struct ComponentDepsNode : public DepsNode { const char *name, int name_tag); + /* Entry/exit operations management. + * + * Use those instead of direct set since this will perform sanity checks. + */ + void set_entry_operation(OperationDepsNode *op_node); + void set_exit_operation(OperationDepsNode *op_node); + void clear_operations(); void tag_update(Depsgraph *graph); diff --git a/source/blender/depsgraph/intern/nodes/deg_node_operation.cc b/source/blender/depsgraph/intern/nodes/deg_node_operation.cc index 5af5ef1b4d1..7467264f612 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node_operation.cc +++ b/source/blender/depsgraph/intern/nodes/deg_node_operation.cc @@ -84,6 +84,18 @@ void OperationDepsNode::tag_update(Depsgraph *graph) graph->add_entry_tag(this); } +void OperationDepsNode::set_as_entry() +{ + BLI_assert(owner != NULL); + owner->set_entry_operation(this); +} + +void OperationDepsNode::set_as_exit() +{ + BLI_assert(owner != NULL); + owner->set_exit_operation(this); +} + DEG_DEPSNODE_DEFINE(OperationDepsNode, DEG_NODE_TYPE_OPERATION, "Operation"); static DepsNodeFactoryImpl<OperationDepsNode> DNTI_OPERATION; diff --git a/source/blender/depsgraph/intern/nodes/deg_node_operation.h b/source/blender/depsgraph/intern/nodes/deg_node_operation.h index f5e034734d9..3ff215a31b2 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node_operation.h +++ b/source/blender/depsgraph/intern/nodes/deg_node_operation.h @@ -54,8 +54,6 @@ typedef enum eDepsOperation_Flag { /* Atomic Operation - Base type for all operations */ struct OperationDepsNode : public DepsNode { - - OperationDepsNode(); ~OperationDepsNode(); @@ -69,13 +67,16 @@ struct OperationDepsNode : public DepsNode { OperationDepsNode *get_entry_operation() { return this; } OperationDepsNode *get_exit_operation() { return this; } + /* Set this operation as compoonent's entry/exit operation. */ + void set_as_entry(); + void set_as_exit(); + /* Component that contains the operation. */ ComponentDepsNode *owner; /* Callback for operation. */ DepsEvalOperationCb evaluate; - /* How many inlinks are we still waiting on before we can be evaluated. */ uint32_t num_links_pending; float eval_priority; |