Simulation: add depsgraph relations for ids referenced by node tree

I'll really have to refactor `ntreeUpdateTree` soon to avoid scanning
all node trees multiple times.
This commit is contained in:
2020-07-23 12:09:28 +02:00
parent 6596891121
commit 634585aa68
13 changed files with 287 additions and 99 deletions

View File

@@ -61,6 +61,7 @@
#include "BKE_lib_query.h"
#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_simulation.h"
#include "BLI_ghash.h"
#include "BLI_threads.h"
@@ -3638,6 +3639,16 @@ void ntreeUpdateAllUsers(Main *main, ID *ngroup)
FOREACH_NODETREE_END;
}
static void ntreeUpdateSimulationDependencies(Main *main, bNodeTree *simulation_ntree)
{
FOREACH_NODETREE_BEGIN (main, ntree, owner_id) {
if (GS(owner_id->name) == ID_SIM && ntree == simulation_ntree) {
BKE_simulation_update_dependencies((Simulation *)owner_id, main);
}
}
FOREACH_NODETREE_END;
}
void ntreeUpdateTree(Main *bmain, bNodeTree *ntree)
{
bNode *node;
@@ -3695,6 +3706,11 @@ void ntreeUpdateTree(Main *bmain, bNodeTree *ntree)
ntree_validate_links(ntree);
}
if (bmain != NULL && ntree->typeinfo == ntreeType_Simulation &&
(ntree->id.flag & LIB_EMBEDDED_DATA)) {
ntreeUpdateSimulationDependencies(bmain, ntree);
}
/* clear update flags */
for (node = ntree->nodes.first; node; node = node->next) {
node->update = 0;