[Bf-blender-cvs] [8f6e2de] depsgraph_refactor: Depsgraph: Add Component::has_operation which checks whether operation exists or not
Sergey Sharybin
noreply at git.blender.org
Wed Jan 7 13:30:11 CET 2015
Commit: 8f6e2de35f766374642ff0f216352bf6413d40cd
Author: Sergey Sharybin
Date: Wed Jan 7 17:27:57 2015 +0500
Branches: depsgraph_refactor
https://developer.blender.org/rB8f6e2de35f766374642ff0f216352bf6413d40cd
Depsgraph: Add Component::has_operation which checks whether operation exists or not
This way we can explicitly distinguish situations when operation is allowed to not
exist (i.e. when doing a check before adding new one) and when operation expects to
be there (when adding relation i.e.).
Also corrected obdata geometry key when adding relation.
===================================================================
M source/blender/depsgraph/intern/depsgraph_build_relations.cpp
M source/blender/depsgraph/intern/depsnode_component.cpp
M source/blender/depsgraph/intern/depsnode_component.h
===================================================================
diff --git a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
index e53ea7a..68de63e 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
@@ -1191,7 +1191,7 @@ void DepsgraphRelationBuilder::build_obdata_geom(Scene *scene, Object *ob)
/* get nodes for result of obdata's evaluation, and geometry evaluation on object */
ComponentKey geom_key(&ob->id, DEPSNODE_TYPE_GEOMETRY);
ComponentKey obdata_geom_key(obdata, DEPSNODE_TYPE_GEOMETRY);
- OperationKey geom_eval_key(&ob->id, DEPSNODE_TYPE_GEOMETRY, "Geometry Eval");
+ OperationKey geom_eval_key(obdata, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_PLACEHOLDER, "Geometry Eval");
/* link components to each other */
add_relation(obdata_geom_key, geom_key, DEPSREL_TYPE_DATABLOCK, "Object Geometry Base Data");
@@ -1315,7 +1315,7 @@ void DepsgraphRelationBuilder::build_obdata_geom(Scene *scene, Object *ob)
OperationKey mod_key(&ob->id, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_GEOMETRY_MODIFIER, md->name);
add_relation(mod_key, obdata_ubereval_key, DEPSREL_TYPE_OPERATION, "Object Geometry UberEval");
}
- else {
+ else if (obdata != NULL) {
add_relation(geom_eval_key, obdata_ubereval_key, DEPSREL_TYPE_OPERATION, "Object Geometry UberEval");
}
}
diff --git a/source/blender/depsgraph/intern/depsnode_component.cpp b/source/blender/depsgraph/intern/depsnode_component.cpp
index 54a25dd..934fe1b 100644
--- a/source/blender/depsgraph/intern/depsnode_component.cpp
+++ b/source/blender/depsgraph/intern/depsnode_component.cpp
@@ -107,6 +107,7 @@ OperationDepsNode *ComponentDepsNode::find_operation(OperationIDKey key) const
else {
fprintf(stderr, "%s: find_operation(%s) failed\n",
this->identifier().c_str(), key.identifier().c_str());
+ BLI_assert(!"Request for non-existing operation, should not happen");
return NULL;
}
}
@@ -117,9 +118,25 @@ OperationDepsNode *ComponentDepsNode::find_operation(eDepsOperation_Code opcode,
return find_operation(key);
}
+OperationDepsNode *ComponentDepsNode::has_operation(OperationIDKey key) const
+{
+ OperationMap::const_iterator it = this->operations.find(key);
+ if (it != this->operations.end()) {
+ return it->second;
+ }
+ return NULL;
+}
+
+OperationDepsNode *ComponentDepsNode::has_operation(eDepsOperation_Code opcode,
+ const string &name) const
+{
+ OperationIDKey key(opcode, name);
+ return has_operation(key);
+}
+
OperationDepsNode *ComponentDepsNode::add_operation(eDepsOperation_Type optype, DepsEvalOperationCb op, eDepsOperation_Code opcode, const string &name)
{
- OperationDepsNode *op_node = find_operation(opcode, name);
+ OperationDepsNode *op_node = has_operation(opcode, name);
if (!op_node) {
DepsNodeFactory *factory = DEG_get_node_factory(DEPSNODE_TYPE_OPERATION);
op_node = (OperationDepsNode *)factory->create_node(this->owner->id, "", name);
diff --git a/source/blender/depsgraph/intern/depsnode_component.h b/source/blender/depsgraph/intern/depsnode_component.h
index f892a7e..fa36d25 100644
--- a/source/blender/depsgraph/intern/depsnode_component.h
+++ b/source/blender/depsgraph/intern/depsnode_component.h
@@ -101,10 +101,15 @@ struct ComponentDepsNode : public DepsNode {
void copy(DepsgraphCopyContext *dcc, const ComponentDepsNode *src);
string identifier() const;
-
+
+ /* Find an existing operation, will throw an assert() if it does not exist. */
OperationDepsNode *find_operation(OperationIDKey key) const;
OperationDepsNode *find_operation(eDepsOperation_Code opcode, const string &name) const;
-
+
+ /* Check operation exists and return it. */
+ OperationDepsNode *has_operation(OperationIDKey key) const;
+ OperationDepsNode *has_operation(eDepsOperation_Code opcode, const string &name) const;
+
/* Create a new node for representing an operation and add this to graph
* ! If an existing node is found, it will be modified. This helps when node may
* have been partially created earlier (e.g. parent ref before parent item is added)
More information about the Bf-blender-cvs
mailing list