Depsgraph: Introduce flat list of ID nodes

The idea is to allow iterating over ID nodes in exact order of their
construction, and in order which will not change dependent on memory
pointers or anything.
This commit is contained in:
Sergey Sharybin 2017-11-08 14:29:58 +01:00
parent a41fe949d8
commit 8fe556a337
2 changed files with 13 additions and 3 deletions

View File

@ -282,6 +282,7 @@ IDDepsNode *Depsgraph::add_id_node(ID *id, const char *name)
id->tag |= LIB_TAG_DOIT;
/* register */
BLI_ghash_insert(id_hash, id, id_node);
id_nodes.push_back(id_node);
}
return id_node;
}
@ -289,6 +290,7 @@ IDDepsNode *Depsgraph::add_id_node(ID *id, const char *name)
void Depsgraph::clear_id_nodes()
{
BLI_ghash_clear(id_hash, NULL, id_node_deleter);
id_nodes.clear();
}
/* Add new relationship between two nodes. */
@ -410,7 +412,6 @@ void Depsgraph::add_entry_tag(OperationDepsNode *node)
void Depsgraph::clear_all_nodes()
{
clear_id_nodes();
BLI_ghash_clear(id_hash, NULL, NULL);
if (time_source != NULL) {
OBJECT_GUARDED_DELETE(time_source, TimeSourceDepsNode);
time_source = NULL;

View File

@ -91,7 +91,9 @@ struct DepsRelation {
/* Dependency Graph object */
struct Depsgraph {
// TODO(sergey): Go away from C++ container and use some native BLI.
typedef vector<OperationDepsNode *> OperationNodes;
typedef vector<IDDepsNode *> IDDepsNodes;
Depsgraph();
~Depsgraph();
@ -141,10 +143,17 @@ struct Depsgraph {
/* Core Graph Functionality ........... */
/* <ID : IDDepsNode> mapping from ID blocks to nodes representing these blocks
* (for quick lookups). */
/* <ID : IDDepsNode> mapping from ID blocks to nodes representing these
* blocks, used for quick lookups.
*/
GHash *id_hash;
/* Ordered list of ID nodes, order matches ID allocation order.
* Used for faster iteration, especially for areas which are critical to
* keep exact order of iteration.
*/
IDDepsNodes id_nodes;
/* Top-level time source node. */
TimeSourceDepsNode *time_source;