Cleanup: Remove node tree runtime fields

`done` was only used in one place, and `is_updating` was never read.
Generally we should avoid adding this sort of temporary data to longer
lived structs.
This commit is contained in:
Hans Goudey
2022-11-30 11:41:01 -06:00
parent 507b724056
commit 7cdcb76815
3 changed files with 10 additions and 21 deletions

View File

@@ -46,11 +46,6 @@ class bNodeTreeRuntime : NonCopyable, NonMovable {
*/
uint8_t runtime_flag = 0;
/** Flag to prevent re-entrant update calls. */
short is_updating = 0;
/** Generic temporary flag for recursion check (DFS/BFS). */
short done = 0;
/** Execution data.
*
* XXX It would be preferable to completely move this data out of the underlying node tree,

View File

@@ -2793,18 +2793,19 @@ static bool node_shader_script_update_poll(bContext *C)
static bool node_shader_script_update_text_recursive(RenderEngine *engine,
RenderEngineType *type,
bNodeTree *ntree,
Text *text)
Text *text,
Set<bNodeTree *> &done_trees)
{
bool found = false;
ntree->runtime->done = true;
done_trees.add_new(ntree);
/* update each script that is using this text datablock */
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == NODE_GROUP) {
bNodeTree *ngroup = (bNodeTree *)node->id;
if (ngroup && !ngroup->runtime->done) {
found |= node_shader_script_update_text_recursive(engine, type, ngroup, text);
if (ngroup && !done_trees.contains(ngroup)) {
found |= node_shader_script_update_text_recursive(engine, type, ngroup, text, done_trees);
}
}
else if (node->type == SH_NODE_SCRIPT && node->id == &text->id) {
@@ -2852,18 +2853,14 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op)
Text *text = (Text *)CTX_data_pointer_get_type(C, "edit_text", &RNA_Text).data;
if (text) {
/* clear flags for recursion check */
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
ntree->runtime->done = false;
}
}
FOREACH_NODETREE_END;
Set<bNodeTree *> done_trees;
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
if (!ntree->runtime->done) {
found |= node_shader_script_update_text_recursive(engine, type, ntree, text);
if (!done_trees.contains(ntree)) {
found |= node_shader_script_update_text_recursive(
engine, type, ntree, text, done_trees);
}
}
}

View File

@@ -902,8 +902,6 @@ static void node_link_exit(bContext &C, wmOperator &op, const bool apply_links)
bNodeTree &ntree = *snode.edittree;
bNodeLinkDrag *nldrag = (bNodeLinkDrag *)op.customdata;
/* avoid updates while applying links */
ntree.runtime->is_updating = true;
for (bNodeLink *link : nldrag->links) {
link->flag &= ~NODE_LINK_DRAGGED;
@@ -929,7 +927,6 @@ static void node_link_exit(bContext &C, wmOperator &op, const bool apply_links)
nodeRemLink(&ntree, link);
}
}
ntree.runtime->is_updating = false;
ED_node_tree_propagate_change(&C, bmain, &ntree);