Previously, the data-block dependencies were always detected in `update_depsgraph` in `MOD_nodes.cc`. This would only be called when something called `DEG_relations_tag_update` before. We don't want to trigger a depsgraph rebuild after each operation in the node editor, as that would be expensive. However, that also meant that we often had to add data-block dependencies that are not actually used, but might be used if the user changed e.g. a link. A typical example for that is a object socket that has a default value, but the socket is also linked. Now, the dependencies referenced by the node tree are collected by the node tree update code which runs after all changes. This way we can detect whether the dependencies have changed. Only if they have changed, a depsgraph rebuild is triggered. This now allows also taking into account the mute status of nodes and whether an input is linked. There are still more things that could be taken into account. Most obviously whether a node is connected to an output. This can be done later. The most tricky aspect here is probably that we also have to consider all viewer nodes as output, because at the time the node runs, it's not known which viewer will actually be used (which depends on other editors). This also cleans up some special cases we had for e.g. the scene time node where we always had to trigger a depsgraph rebuild when it was added/removed because of its time dependence. This is now part of a more general system. This fixes #109219. Pull Request: https://projects.blender.org/blender/blender/pulls/131446
70 lines
2.6 KiB
C++
70 lines
2.6 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
#include "BLI_compute_context.hh"
|
|
#include "BLI_function_ref.hh"
|
|
#include "BLI_multi_value_map.hh"
|
|
#include "BLI_set.hh"
|
|
|
|
#include "BKE_idprop.hh"
|
|
#include "BKE_node.hh"
|
|
|
|
struct bNodeTree;
|
|
struct bNodeTreeInterfaceSocket;
|
|
namespace blender::bke {
|
|
struct GeometrySet;
|
|
}
|
|
struct IDProperty;
|
|
namespace blender::nodes {
|
|
struct GeoNodesCallData;
|
|
namespace geo_eval_log {
|
|
class GeoModifierLog;
|
|
} // namespace geo_eval_log
|
|
} // namespace blender::nodes
|
|
|
|
namespace blender::nodes {
|
|
|
|
constexpr StringRef input_use_attribute_suffix = "_use_attribute";
|
|
constexpr StringRef input_attribute_name_suffix = "_attribute_name";
|
|
|
|
std::optional<StringRef> input_attribute_name_get(const IDProperty &props,
|
|
const bNodeTreeInterfaceSocket &io_input);
|
|
|
|
/**
|
|
* \return Whether using an attribute to input values of this type is supported.
|
|
*/
|
|
bool socket_type_has_attribute_toggle(eNodeSocketDatatype type);
|
|
|
|
/**
|
|
* \return Whether using an attribute to input values of this type is supported, and the node
|
|
* group's input for this socket accepts a field rather than just single values.
|
|
*/
|
|
bool input_has_attribute_toggle(const bNodeTree &node_tree, const int socket_index);
|
|
|
|
bool id_property_type_matches_socket(const bNodeTreeInterfaceSocket &socket,
|
|
const IDProperty &property,
|
|
bool use_name_for_ids = false);
|
|
|
|
std::unique_ptr<IDProperty, bke::idprop::IDPropertyDeleter> id_property_create_from_socket(
|
|
const bNodeTreeInterfaceSocket &socket, bool use_name_for_ids);
|
|
|
|
bke::GeometrySet execute_geometry_nodes_on_geometry(const bNodeTree &btree,
|
|
const IDProperty *properties,
|
|
const ComputeContext &base_compute_context,
|
|
GeoNodesCallData &call_data,
|
|
bke::GeometrySet input_geometry);
|
|
|
|
void update_input_properties_from_node_tree(const bNodeTree &tree,
|
|
const IDProperty *old_properties,
|
|
IDProperty &properties,
|
|
bool use_name_for_ids = false);
|
|
|
|
void update_output_properties_from_node_tree(const bNodeTree &tree,
|
|
const IDProperty *old_properties,
|
|
IDProperty &properties);
|
|
|
|
} // namespace blender::nodes
|