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.
This commit is contained in:
parent
3a7361ec39
commit
a72daea36e
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue