Depsgraph: Add extra name tag for operation nodes

The idea here is to address issue that name on it's own is not
always unique: for example, when adding driver operations the
name used for nodes is the RNA path (and multiple drivers can
write to different array indices of the path). Basically, now
it's possible to pass extra integer value to distinguish
operations in such cases.

So now we've already switched from sprintf() to construct unique
operation name to pass RNA path and array index.

There should be no functional changes yet, but this work is
required for further work about replacing string with const
char*.
This commit is contained in:
2016-11-03 14:31:27 +01:00
parent d872aeaf51
commit c9eca0c6c9
6 changed files with 177 additions and 61 deletions

View File

@@ -138,9 +138,11 @@ OperationDepsNode *ComponentDepsNode::find_operation(OperationIDKey key) const
}
}
OperationDepsNode *ComponentDepsNode::find_operation(eDepsOperation_Code opcode, const string &name) const
OperationDepsNode *ComponentDepsNode::find_operation(eDepsOperation_Code opcode,
const string &name,
int name_tag) const
{
OperationIDKey key(opcode, name);
OperationIDKey key(opcode, name, name_tag);
return find_operation(key);
}
@@ -150,21 +152,26 @@ OperationDepsNode *ComponentDepsNode::has_operation(OperationIDKey key) const
}
OperationDepsNode *ComponentDepsNode::has_operation(eDepsOperation_Code opcode,
const string &name) const
const string &name,
int name_tag) const
{
OperationIDKey key(opcode, name);
OperationIDKey key(opcode, name, name_tag);
return has_operation(key);
}
OperationDepsNode *ComponentDepsNode::add_operation(eDepsOperation_Type optype, DepsEvalOperationCb op, eDepsOperation_Code opcode, const string &name)
OperationDepsNode *ComponentDepsNode::add_operation(eDepsOperation_Type optype,
DepsEvalOperationCb op,
eDepsOperation_Code opcode,
const string &name,
int name_tag)
{
OperationDepsNode *op_node = has_operation(opcode, name);
OperationDepsNode *op_node = has_operation(opcode, name, name_tag);
if (!op_node) {
DepsNodeFactory *factory = deg_get_node_factory(DEPSNODE_TYPE_OPERATION);
op_node = (OperationDepsNode *)factory->create_node(this->owner->id, "", name);
/* register opnode in this component's operation set */
OperationIDKey *key = OBJECT_GUARDED_NEW(OperationIDKey, opcode, name);
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) */