120 scheduled_nodes_queue;
124 const auto schedule_node = [&](
const NodeInContext &ctx_node) {
125 if (scheduled_nodes_set.
add(ctx_node)) {
126 scheduled_nodes_queue.push(ctx_node);
130 const auto forward_group_node_input_into_group =
132 const bNode &
node = ctx_group_node_input.socket->owner_node();
138 group_tree->ensure_topology_cache();
139 if (group_tree->has_available_link_cycle()) {
143 ctx_group_node_input.context,
node.identifier, &
node.owner_tree());
144 const int socket_index = ctx_group_node_input.socket->index();
146 for (
const bNode *group_input_node : group_tree->group_input_nodes()) {
147 if (propagate_value_fn(ctx_group_node_input,
148 {&group_context, &group_input_node->output_socket(socket_index)}))
150 schedule_node({&group_context, group_input_node});
155 const auto forward_output = [&](
const SocketInContext &ctx_output_socket) {
157 for (
const bNodeLink *link : ctx_output_socket.socket->directly_linked_links()) {
158 if (!link->is_used()) {
161 const bNode &target_node = *link->tonode;
163 if (!propagate_value_fn(ctx_output_socket, {context, &target_socket})) {
166 schedule_node({context, &target_node});
167 if (target_node.is_group()) {
168 forward_group_node_input_into_group({context, &target_socket});
175 if (ctx_socket.socket->is_input()) {
176 const bNode &
node = ctx_socket.socket->owner_node();
177 if (
node.is_group()) {
178 forward_group_node_input_into_group(ctx_socket);
180 schedule_node({ctx_socket.context, &
node});
183 forward_output(ctx_socket);
192 while (!scheduled_nodes_queue.empty()) {
194 scheduled_nodes_queue.pop();
199 if (
node.is_reroute()) {
200 if (propagate_value_fn({context, &
node.input_socket(0)}, {context, &
node.output_socket(0)}))
202 forward_output({context, &
node.output_socket(0)});
205 if (
node.is_type(
"NodeImplicitConversion"_ustr)) {
206 if (propagate_value_fn({context, &
node.input_socket(0)}, {context, &
node.output_socket(0)}))
208 forward_output({context, &
node.output_socket(0)});
211 else if (
node.is_muted()) {
213 if (propagate_value_fn({context, link.in}, {context, link.out})) {
214 forward_output({context, link.out});
218 else if (
node.is_group()) {
223 group->ensure_topology_cache();
224 if (group->has_available_link_cycle()) {
227 const bNode *group_output = group->group_output_node();
232 context,
node.identifier, &
node.owner_tree());
235 for (
const int index : group->interface_outputs().index_range()) {
236 if (propagate_value_fn({&group_context, &group_output->input_socket(
index)},
239 forward_output({context, &
node.output_socket(
index)});
243 else if (
node.is_group_input()) {
245 forward_output({context, output_socket});
250 evaluate_node_fn(ctx_node, sockets_vec);
252 forward_output({context, socket});
266 get_inputs_to_propagate_fn)
270 scheduled_nodes_queue;
276 const auto schedule_node = [&](
const NodeInContext &ctx_node) {
277 if (scheduled_nodes_set.
add(ctx_node)) {
278 scheduled_nodes_queue.push(ctx_node);
282 const auto forward_group_node_output_into_group = [&](
const SocketInContext &ctx_output_socket) {
284 const bNode &group_node = ctx_output_socket.socket->owner_node();
289 group->ensure_topology_cache();
290 if (group->has_available_link_cycle()) {
293 const bNode *group_output = group->group_output_node();
298 context, group_node.
identifier, &group_node.owner_tree());
301 {&group_context, &group_output->input_socket(ctx_output_socket.socket->index())});
302 schedule_node({&group_context, group_output});
305 const auto forward_group_input_to_parent = [&](
const SocketInContext &ctx_output_socket) {
307 ctx_output_socket.context);
308 if (!group_context) {
312 const bNodeTree &caller_tree = *group_context->tree();
313 caller_tree.ensure_topology_cache();
314 if (caller_tree.has_available_link_cycle()) {
317 const bNode &caller_node = *group_context->node();
318 const bNodeSocket &caller_input_socket = caller_node.input_socket(
319 ctx_output_socket.socket->index());
323 propagate_value_fn(ctx_output_socket, {parent_context, &caller_input_socket});
324 schedule_node({parent_context, &caller_node});
327 const auto forward_input = [&](
const SocketInContext &ctx_input_socket) {
329 if (!ctx_input_socket.socket->is_logically_linked()) {
330 eval_targets.
sockets.add(ctx_input_socket);
333 for (
const bNodeLink *link : ctx_input_socket.socket->directly_linked_links()) {
334 if (!link->is_used()) {
337 const bNode &origin_node = *link->fromnode;
338 const bNodeSocket &origin_socket = *link->fromsock;
339 if (!propagate_value_fn(ctx_input_socket, {context, &origin_socket})) {
342 schedule_node({context, &origin_node});
343 if (origin_node.is_group()) {
344 forward_group_node_output_into_group({context, &origin_socket});
347 if (origin_node.is_group_input()) {
348 forward_group_input_to_parent({context, &origin_socket});
356 if (ctx_socket.socket->is_input()) {
357 forward_input(ctx_socket);
360 const bNode &
node = ctx_socket.socket->owner_node();
361 if (
node.is_group()) {
362 forward_group_node_output_into_group(ctx_socket);
364 else if (
node.is_group_input()) {
365 forward_group_input_to_parent(ctx_socket);
368 schedule_node({ctx_socket.context, &
node});
378 while (!scheduled_nodes_queue.empty()) {
380 scheduled_nodes_queue.pop();
389 else if (
node.is_reroute()) {
390 propagate_value_fn({context, &
node.output_socket(0)}, {context, &
node.input_socket(0)});
391 forward_input({context, &
node.input_socket(0)});
393 else if (
node.is_type(
"NodeImplicitConversion"_ustr)) {
394 propagate_value_fn({context, &
node.output_socket(0)}, {context, &
node.input_socket(0)});
395 forward_input({context, &
node.input_socket(0)});
397 else if (
node.is_muted()) {
399 if (propagate_value_fn({context, link.out}, {context, link.in})) {
400 forward_input({context, link.in});
404 else if (
node.is_group()) {
408 get_inputs_to_propagate_fn(ctx_node, sockets_vec);
410 forward_input({context, socket});
413 else if (
node.is_group_output()) {
415 get_inputs_to_propagate_fn(ctx_node, sockets_vec);
417 forward_input({context, socket});
422 evaluate_node_fn(ctx_node, sockets_vec);
423 for (
const bNodeSocket *input_socket : sockets_vec) {
424 forward_input({context, input_socket});