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 | |||||
| if (ntree.runtime->changed_flag & NTREE_CHANGED_INTERFACE || | if (ntree.runtime->changed_flag & NTREE_CHANGED_INTERFACE || | ||||
| ntree.runtime->changed_flag & NTREE_CHANGED_ANY) { | ntree.runtime->changed_flag & NTREE_CHANGED_ANY) { | ||||
| result.interface_changed = true; | result.interface_changed = true; | ||||
| } | } | ||||
| #ifdef DEBUG | #ifdef DEBUG | ||||
| /* Check the uniqueness of node identifiers. */ | /* Check the uniqueness of node identifiers. */ | ||||
| Set<int32_t> node_identifiers; | Set<int32_t> node_identifiers; | ||||
| for (bNode *node : ntree.all_nodes()) { | const Span<const bNode *> nodes = ntree.all_nodes(); | ||||
| BLI_assert(node->identifier > 0); | for (const int i : nodes.index_range()) { | ||||
| node_identifiers.add_new(node->identifier); | const bNode &node = *nodes[i]; | ||||
| BLI_assert(node.identifier > 0); | |||||
| node_identifiers.add_new(node.identifier); | |||||
| BLI_assert(node.runtime->index_in_tree == i); | |||||
| } | } | ||||
| #endif | #endif | ||||
| return result; | return result; | ||||
| } | } | ||||
| void update_socket_link_and_use(bNodeTree &tree) | void update_socket_link_and_use(bNodeTree &tree) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 250 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 | |||||