diff options
Diffstat (limited to 'source/blender/nodes/intern')
-rw-r--r-- | source/blender/nodes/intern/geometry_nodes_lazy_function.cc | 46 | ||||
-rw-r--r-- | source/blender/nodes/intern/geometry_nodes_log.cc | 2 | ||||
-rw-r--r-- | source/blender/nodes/intern/node_util.cc (renamed from source/blender/nodes/intern/node_util.c) | 16 | ||||
-rw-r--r-- | source/blender/nodes/intern/socket_search_link.cc | 63 |
4 files changed, 35 insertions, 92 deletions
diff --git a/source/blender/nodes/intern/geometry_nodes_lazy_function.cc b/source/blender/nodes/intern/geometry_nodes_lazy_function.cc index 6475a16477a..197f0997160 100644 --- a/source/blender/nodes/intern/geometry_nodes_lazy_function.cc +++ b/source/blender/nodes/intern/geometry_nodes_lazy_function.cc @@ -158,8 +158,9 @@ class LazyFunctionForMultiInput : public LazyFunction { base_type_ = get_socket_cpp_type(socket); BLI_assert(base_type_ != nullptr); BLI_assert(socket.is_multi_input()); + const bNodeTree &btree = socket.owner_tree(); for (const bNodeLink *link : socket.directly_linked_links()) { - if (!link->is_muted()) { + if (!(link->is_muted() || nodeIsDanglingReroute(&btree, link->fromnode))) { inputs_.append({"Input", *base_type_}); } } @@ -603,6 +604,7 @@ class LazyFunctionForGroupNode : public LazyFunction { private: const bNode &group_node_; bool has_many_nodes_ = false; + bool use_fallback_outputs_ = false; std::optional<GeometryNodesLazyFunctionLogger> lf_logger_; std::optional<GeometryNodesLazyFunctionSideEffectProvider> lf_side_effect_provider_; std::optional<lf::GraphExecutor> graph_executor_; @@ -639,6 +641,9 @@ class LazyFunctionForGroupNode : public LazyFunction { } } } + else { + use_fallback_outputs_ = true; + } lf_logger_.emplace(lf_graph_info); lf_side_effect_provider_.emplace(); @@ -659,6 +664,11 @@ class LazyFunctionForGroupNode : public LazyFunction { * if every individual node is very small. */ lazy_threading::send_hint(); } + if (use_fallback_outputs_) { + /* The node group itself does not have an output node, so use default values as outputs. + * The group should still be executed in case it has side effects. */ + params.set_default_remaining_outputs(); + } /* The compute context changes when entering a node group. */ bke::NodeGroupComputeContext compute_context{user_data->compute_context, group_node_.name}; @@ -1073,9 +1083,7 @@ struct GeometryNodesLazyFunctionGraphBuilder { void insert_links_from_socket(const bNodeSocket &from_bsocket, lf::OutputSocket &from_lf_socket) { - const bNode &from_bnode = from_bsocket.owner_node(); - if (this->is_dangling_reroute_input(from_bnode)) { - /* Dangling reroutes should not be used as source of values. */ + if (nodeIsDanglingReroute(&btree_, &from_bsocket.owner_node())) { return; } @@ -1145,7 +1153,8 @@ struct GeometryNodesLazyFunctionGraphBuilder { if (multi_input_link == link) { break; } - if (!multi_input_link->is_muted()) { + if (!(multi_input_link->is_muted() || + nodeIsDanglingReroute(&btree_, multi_input_link->fromnode))) { link_index++; } } @@ -1174,33 +1183,6 @@ struct GeometryNodesLazyFunctionGraphBuilder { } } - bool is_dangling_reroute_input(const bNode &node) - { - if (!node.is_reroute()) { - return false; - } - const bNode *iter_node = &node; - /* It is guaranteed at a higher level that there are no link cycles. */ - while (true) { - const Span<const bNodeLink *> links = iter_node->input_socket(0).directly_linked_links(); - BLI_assert(links.size() <= 1); - if (links.is_empty()) { - return true; - } - const bNodeLink &link = *links[0]; - if (!link.is_available()) { - return false; - } - if (link.is_muted()) { - return false; - } - iter_node = link.fromnode; - if (!iter_node->is_reroute()) { - return false; - } - } - } - lf::OutputSocket *insert_type_conversion_if_necessary( lf::OutputSocket &from_socket, const CPPType &to_type, diff --git a/source/blender/nodes/intern/geometry_nodes_log.cc b/source/blender/nodes/intern/geometry_nodes_log.cc index 167bfef0f83..0f122307328 100644 --- a/source/blender/nodes/intern/geometry_nodes_log.cc +++ b/source/blender/nodes/intern/geometry_nodes_log.cc @@ -101,7 +101,7 @@ GeometryInfoLog::GeometryInfoLog(const GeometrySet &geometry_set) case GEO_COMPONENT_TYPE_INSTANCES: { const InstancesComponent &instances_component = *(const InstancesComponent *)component; InstancesInfo &info = this->instances_info.emplace(); - info.instances_num = instances_component.instances_num(); + info.instances_num = instances_component.attribute_domain_size(ATTR_DOMAIN_INSTANCE); break; } case GEO_COMPONENT_TYPE_EDIT: { diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.cc index ddab455509d..17be20b4e4b 100644 --- a/source/blender/nodes/intern/node_util.c +++ b/source/blender/nodes/intern/node_util.cc @@ -37,7 +37,7 @@ void node_free_curves(bNode *node) { - BKE_curvemapping_free(node->storage); + BKE_curvemapping_free(static_cast<CurveMapping *>(node->storage)); } void node_free_standard_storage(bNode *node) @@ -49,7 +49,7 @@ void node_free_standard_storage(bNode *node) void node_copy_curves(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, const bNode *src_node) { - dest_node->storage = BKE_curvemapping_copy(src_node->storage); + dest_node->storage = BKE_curvemapping_copy(static_cast<CurveMapping *>(src_node->storage)); } void node_copy_standard_storage(bNodeTree *UNUSED(dest_ntree), @@ -63,7 +63,7 @@ void *node_initexec_curves(bNodeExecContext *UNUSED(context), bNode *node, bNodeInstanceKey UNUSED(key)) { - BKE_curvemapping_init(node->storage); + BKE_curvemapping_init(static_cast<CurveMapping *>(node->storage)); return NULL; /* unused return */ } @@ -87,9 +87,9 @@ void node_sock_label_clear(bNodeSocket *sock) void node_math_update(bNodeTree *ntree, bNode *node) { - bNodeSocket *sock1 = BLI_findlink(&node->inputs, 0); - bNodeSocket *sock2 = BLI_findlink(&node->inputs, 1); - bNodeSocket *sock3 = BLI_findlink(&node->inputs, 2); + bNodeSocket *sock1 = static_cast<bNodeSocket *>(BLI_findlink(&node->inputs, 0)); + bNodeSocket *sock2 = static_cast<bNodeSocket *>(BLI_findlink(&node->inputs, 1)); + bNodeSocket *sock3 = static_cast<bNodeSocket *>(BLI_findlink(&node->inputs, 2)); nodeSetSocketAvailability(ntree, sock2, !ELEM(node->custom1, @@ -305,7 +305,9 @@ static bNodeSocket *node_find_linkable_socket(bNodeTree *ntree, bNode *node, bNodeSocket *to_socket) { - bNodeSocket *first = to_socket->in_out == SOCK_IN ? node->inputs.first : node->outputs.first; + bNodeSocket *first = to_socket->in_out == SOCK_IN ? + static_cast<bNodeSocket *>(node->inputs.first) : + static_cast<bNodeSocket *>((node->outputs.first)); /* Wrap around the list end. */ bNodeSocket *socket_iter = to_socket->next ? to_socket->next : first; diff --git a/source/blender/nodes/intern/socket_search_link.cc b/source/blender/nodes/intern/socket_search_link.cc index 0bd838ff002..b440952b503 100644 --- a/source/blender/nodes/intern/socket_search_link.cc +++ b/source/blender/nodes/intern/socket_search_link.cc @@ -125,64 +125,23 @@ void search_link_ops_for_declarations(GatherLinkSearchOpParams ¶ms, } } -static void search_link_ops_for_socket_templates(GatherLinkSearchOpParams ¶ms, - const bNodeSocketTemplate *templates, - const eNodeSocketInOut in_out) -{ - const bNodeType &node_type = params.node_type(); - const bNodeTreeType &node_tree_type = *params.node_tree().typeinfo; - - Set<StringRef> socket_names; - for (const bNodeSocketTemplate *socket_template = templates; socket_template->type != -1; - socket_template++) { - eNodeSocketDatatype from = (eNodeSocketDatatype)socket_template->type; - eNodeSocketDatatype to = (eNodeSocketDatatype)params.other_socket().type; - if (in_out == SOCK_IN) { - std::swap(from, to); - } - if (node_tree_type.validate_link && !node_tree_type.validate_link(from, to)) { - continue; - } - if (!socket_names.add(socket_template->name)) { - /* See comment in #search_link_ops_for_declarations. */ - continue; - } - - params.add_item( - socket_template->name, [socket_template, node_type, in_out](LinkSearchOpParams ¶ms) { - bNode &node = params.add_node(node_type); - bNodeSocket *new_node_socket = bke::node_find_enabled_socket( - node, in_out, socket_template->name); - if (new_node_socket != nullptr) { - /* Rely on the way #nodeAddLink switches in/out if necessary. */ - nodeAddLink(¶ms.node_tree, ¶ms.node, ¶ms.socket, &node, new_node_socket); - } - }); - } -} - void search_link_ops_for_basic_node(GatherLinkSearchOpParams ¶ms) { const bNodeType &node_type = params.node_type(); + if (!node_type.declare) { + return; + } - if (node_type.declare) { - if (node_type.declaration_is_dynamic) { - /* Dynamic declarations (whatever they end up being) aren't supported - * by this function, but still avoid a crash in release builds. */ - BLI_assert_unreachable(); - return; - } + if (node_type.declaration_is_dynamic) { + /* Dynamic declarations (whatever they end up being) aren't supported + * by this function, but still avoid a crash in release builds. */ + BLI_assert_unreachable(); + return; + } - const NodeDeclaration &declaration = *node_type.fixed_declaration; + const NodeDeclaration &declaration = *node_type.fixed_declaration; - search_link_ops_for_declarations(params, declaration.sockets(params.in_out())); - } - else if (node_type.inputs && params.in_out() == SOCK_IN) { - search_link_ops_for_socket_templates(params, node_type.inputs, SOCK_IN); - } - else if (node_type.outputs && params.in_out() == SOCK_OUT) { - search_link_ops_for_socket_templates(params, node_type.outputs, SOCK_OUT); - } + search_link_ops_for_declarations(params, declaration.sockets(params.in_out())); } } // namespace blender::nodes |