Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/node_tree_update.cc
| Show First 20 Lines • Show All 992 Lines • ▼ Show 20 Lines | |||||
| void update_link_validation(bNodeTree &ntree) | void update_link_validation(bNodeTree &ntree) | ||||
| { | { | ||||
| const Span<const bNode *> toposort = ntree.toposort_left_to_right(); | const Span<const bNode *> toposort = ntree.toposort_left_to_right(); | ||||
| /* Build an array of toposort indices to allow retrieving the "depth" for each node. */ | /* Build an array of toposort indices to allow retrieving the "depth" for each node. */ | ||||
| Array<int> toposort_indices(toposort.size()); | Array<int> toposort_indices(toposort.size()); | ||||
| for (const int i : toposort.index_range()) { | for (const int i : toposort.index_range()) { | ||||
| const bNode &node = *toposort[i]; | const bNode &node = *toposort[i]; | ||||
| toposort_indices[node.runtime->index_in_tree] = i; | toposort_indices[node.index()] = i; | ||||
| } | } | ||||
| LISTBASE_FOREACH (bNodeLink *, link, &ntree.links) { | LISTBASE_FOREACH (bNodeLink *, link, &ntree.links) { | ||||
| link->flag |= NODE_LINK_VALID; | link->flag |= NODE_LINK_VALID; | ||||
| const bNode &from_node = *link->fromnode; | const bNode &from_node = *link->fromnode; | ||||
| const bNode &to_node = *link->tonode; | const bNode &to_node = *link->tonode; | ||||
| if (toposort_indices[from_node.runtime->index_in_tree] > | if (toposort_indices[from_node.index()] > toposort_indices[to_node.index()]) { | ||||
| toposort_indices[to_node.runtime->index_in_tree]) { | |||||
| link->flag &= ~NODE_LINK_VALID; | link->flag &= ~NODE_LINK_VALID; | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (ntree.typeinfo->validate_link) { | if (ntree.typeinfo->validate_link) { | ||||
| const eNodeSocketDatatype from_type = eNodeSocketDatatype(link->fromsock->type); | const eNodeSocketDatatype from_type = eNodeSocketDatatype(link->fromsock->type); | ||||
| const eNodeSocketDatatype to_type = eNodeSocketDatatype(link->tosock->type); | const eNodeSocketDatatype to_type = eNodeSocketDatatype(link->tosock->type); | ||||
| if (!ntree.typeinfo->validate_link(from_type, to_type)) { | if (!ntree.typeinfo->validate_link(from_type, to_type)) { | ||||
| link->flag &= ~NODE_LINK_VALID; | link->flag &= ~NODE_LINK_VALID; | ||||
| ▲ Show 20 Lines • Show All 483 Lines • Show Last 20 Lines | |||||