diff options
author | Hans Goudey <h.goudey@me.com> | 2021-02-16 22:06:18 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-02-16 22:06:18 +0300 |
commit | eb2e260540439e75cd8fb74e9bb41d1e87213496 (patch) | |
tree | fd501b49b6df6d9acc9c08c5e4e34223caf3e478 | |
parent | c075b8bff22073b890679855b3342a57640bfba4 (diff) |
Cleanup: Used derived node in geometry exec params
Since the derived node tree is already build for the evaluation system,
it's simpler to pass a derived node to the params struct. This will also
allow context lookups in nested node groups for node error messages,
since the derived node has that information readily accessible.
-rw-r--r-- | source/blender/modifiers/intern/MOD_nodes.cc | 3 | ||||
-rw-r--r-- | source/blender/nodes/NOD_geometry_exec.hh | 8 | ||||
-rw-r--r-- | source/blender/nodes/intern/node_geometry_exec.cc | 36 |
3 files changed, 24 insertions, 23 deletions
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index 0fec7cfe937..706ef8578ac 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -331,7 +331,6 @@ class GeometryNodesEvaluator { void compute_output_and_forward(const DOutputSocket &socket_to_compute) { const DNode &node = socket_to_compute.node(); - const bNode &bnode = *node.bnode(); if (!socket_to_compute.is_available()) { /* If the output is not available, use a default value. */ @@ -360,7 +359,7 @@ class GeometryNodesEvaluator { /* Execute the node. */ GValueMap<StringRef> node_outputs_map{allocator_}; GeoNodeExecParams params{ - bnode, node_inputs_map, node_outputs_map, handle_map_, self_object_, depsgraph_}; + node, node_inputs_map, node_outputs_map, handle_map_, self_object_, depsgraph_}; this->execute_node(node, params); /* Forward computed outputs to linked input sockets. */ diff --git a/source/blender/nodes/NOD_geometry_exec.hh b/source/blender/nodes/NOD_geometry_exec.hh index 1149ab51ad0..18de52ed6d4 100644 --- a/source/blender/nodes/NOD_geometry_exec.hh +++ b/source/blender/nodes/NOD_geometry_exec.hh @@ -25,6 +25,8 @@ #include "DNA_node_types.h" +#include "NOD_derived_node_tree.hh" + struct Depsgraph; namespace blender::nodes { @@ -55,7 +57,7 @@ using fn::GValueMap; class GeoNodeExecParams { private: - const bNode &node_; + const DNode &node_; GValueMap<StringRef> &input_values_; GValueMap<StringRef> &output_values_; const PersistentDataHandleMap &handle_map_; @@ -63,7 +65,7 @@ class GeoNodeExecParams { Depsgraph *depsgraph_; public: - GeoNodeExecParams(const bNode &node, + GeoNodeExecParams(const DNode &node, GValueMap<StringRef> &input_values, GValueMap<StringRef> &output_values, const PersistentDataHandleMap &handle_map, @@ -178,7 +180,7 @@ class GeoNodeExecParams { */ const bNode &node() const { - return node_; + return *node_.bnode(); } const PersistentDataHandleMap &handle_map() const diff --git a/source/blender/nodes/intern/node_geometry_exec.cc b/source/blender/nodes/intern/node_geometry_exec.cc index 3de8209859b..7f4f75c294f 100644 --- a/source/blender/nodes/intern/node_geometry_exec.cc +++ b/source/blender/nodes/intern/node_geometry_exec.cc @@ -14,6 +14,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "NOD_derived_node_tree.hh" #include "NOD_geometry_exec.hh" #include "NOD_type_callbacks.hh" @@ -23,12 +24,9 @@ namespace blender::nodes { const bNodeSocket *GeoNodeExecParams::find_available_socket(const StringRef name) const { - LISTBASE_FOREACH (const bNodeSocket *, socket, &node_.inputs) { - if ((socket->flag & SOCK_UNAVAIL) != 0) { - continue; - } - if (name == socket->name) { - return socket; + for (const DSocket *socket : node_.inputs()) { + if (socket->is_available() && socket->name() == name) { + return socket->bsocket(); } } @@ -144,18 +142,19 @@ void GeoNodeExecParams::check_extract_input(StringRef identifier, const CPPType *requested_type) const { bNodeSocket *found_socket = nullptr; - LISTBASE_FOREACH (bNodeSocket *, socket, &node_.inputs) { - if (identifier == socket->identifier) { - found_socket = socket; + for (const DSocket *socket : node_.inputs()) { + if (socket->identifier() == identifier) { + found_socket = socket->bsocket(); break; } } + if (found_socket == nullptr) { std::cout << "Did not find an input socket with the identifier '" << identifier << "'.\n"; std::cout << "Possible identifiers are: "; - LISTBASE_FOREACH (bNodeSocket *, socket, &node_.inputs) { - if ((socket->flag & SOCK_UNAVAIL) == 0) { - std::cout << "'" << socket->identifier << "', "; + for (const DSocket *socket : node_.inputs()) { + if (socket->is_available()) { + std::cout << "'" << socket->identifier() << "', "; } } std::cout << "\n"; @@ -185,18 +184,19 @@ void GeoNodeExecParams::check_extract_input(StringRef identifier, void GeoNodeExecParams::check_set_output(StringRef identifier, const CPPType &value_type) const { bNodeSocket *found_socket = nullptr; - LISTBASE_FOREACH (bNodeSocket *, socket, &node_.outputs) { - if (identifier == socket->identifier) { - found_socket = socket; + for (const DSocket *socket : node_.outputs()) { + if (socket->identifier() == identifier) { + found_socket = socket->bsocket(); break; } } + if (found_socket == nullptr) { std::cout << "Did not find an output socket with the identifier '" << identifier << "'.\n"; std::cout << "Possible identifiers are: "; - LISTBASE_FOREACH (bNodeSocket *, socket, &node_.outputs) { - if ((socket->flag & SOCK_UNAVAIL) == 0) { - std::cout << "'" << socket->identifier << "', "; + for (const DSocket *socket : node_.outputs()) { + if (socket->is_available()) { + std::cout << "'" << socket->identifier() << "', "; } } std::cout << "\n"; |