The purpose of `NodeTreeRef` was to speed up various queries on a read-only `bNodeTree`. Not that we have runtime data in nodes and sockets, we can also store the result of some queries there. This has some benefits: * No need for a read-only separate node tree data structure which increased complexity. * Makes it easier to reuse cached queries in more parts of Blender that can benefit from it. A downside is that we loose some type safety that we got by having different types for input and output sockets, as well as internal and non-internal links. This patch also refactors `DerivedNodeTree` so that it does not use `NodeTreeRef` anymore, but uses `bNodeTree` directly instead. To provide a convenient API (that is also close to what `NodeTreeRef` has), a new approach is implemented: `bNodeTree`, `bNode`, `bNodeSocket` and `bNodeLink` now have C++ methods declared in `DNA_node_types.h` which are implemented in `BKE_node_runtime.hh`. To make this work, `makesdna` now skips c++ sections when parsing dna header files. No user visible changes are expected. Differential Revision: https://developer.blender.org/D15491
26 lines
688 B
C++
26 lines
688 B
C++
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#include "NOD_multi_function.hh"
|
|
|
|
#include "BKE_node.h"
|
|
|
|
namespace blender::nodes {
|
|
|
|
NodeMultiFunctions::NodeMultiFunctions(const DerivedNodeTree &tree)
|
|
{
|
|
for (const bNodeTree *btree : tree.used_btrees()) {
|
|
for (const bNode *bnode : btree->all_nodes()) {
|
|
if (bnode->typeinfo->build_multi_function == nullptr) {
|
|
continue;
|
|
}
|
|
NodeMultiFunctionBuilder builder{*bnode, *btree};
|
|
bnode->typeinfo->build_multi_function(builder);
|
|
if (builder.built_fn_ != nullptr) {
|
|
map_.add_new(bnode, {builder.built_fn_, std::move(builder.owned_built_fn_)});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
} // namespace blender::nodes
|