diff options
author | Hans Goudey <h.goudey@me.com> | 2021-07-23 00:53:35 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-07-23 00:53:35 +0300 |
commit | 49e68f15f204a18a1c983cacf535d3315d742732 (patch) | |
tree | 41018ad9fded96a15d76c311e51876577339dcd0 | |
parent | f76dfe8fb45c9c270c295ff76f6fd058e2b64d0d (diff) |
Geometry Nodes: Display Node Warnings in Modifier
With this commit, node warnings added to nodes during evaluation
(not "Info" warnings) will also draw in the modifier. In the future
there could be a "search for this node" button as well.
Differential Revision: https://developer.blender.org/D11983
-rw-r--r-- | source/blender/modifiers/intern/MOD_nodes.cc | 12 | ||||
-rw-r--r-- | source/blender/nodes/NOD_geometry_nodes_eval_log.hh | 3 | ||||
-rw-r--r-- | source/blender/nodes/intern/geometry_nodes_eval_log.cc | 18 |
3 files changed, 33 insertions, 0 deletions
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index 87fce26c45e..d46ac4c0a8b 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -1133,6 +1133,18 @@ static void panel_draw(const bContext *C, Panel *panel) } } + /* Draw node warnings. */ + if (nmd->runtime_eval_log != nullptr) { + const geo_log::ModifierLog &log = *static_cast<geo_log::ModifierLog *>(nmd->runtime_eval_log); + log.foreach_node_log([layout](const geo_log::NodeLog &node_log) { + for (const geo_log::NodeWarning &warning : node_log.warnings()) { + if (warning.type != geo_log::NodeWarningType::Info) { + uiItemL(layout, warning.message.c_str(), ICON_ERROR); + } + } + }); + } + modifier_panel_end(layout, ptr); } diff --git a/source/blender/nodes/NOD_geometry_nodes_eval_log.hh b/source/blender/nodes/NOD_geometry_nodes_eval_log.hh index b85862a0176..00d97b24646 100644 --- a/source/blender/nodes/NOD_geometry_nodes_eval_log.hh +++ b/source/blender/nodes/NOD_geometry_nodes_eval_log.hh @@ -31,6 +31,7 @@ */ #include "BLI_enumerable_thread_specific.hh" +#include "BLI_function_ref.hh" #include "BLI_linear_allocator.hh" #include "BLI_map.hh" @@ -267,6 +268,7 @@ class TreeLog { const NodeLog *lookup_node_log(StringRef node_name) const; const NodeLog *lookup_node_log(const bNode &node) const; const TreeLog *lookup_child_log(StringRef node_name) const; + void foreach_node_log(FunctionRef<void(const NodeLog &)> fn) const; }; /** Contains information about an entire geometry nodes evaluation. */ @@ -296,6 +298,7 @@ class ModifierLog { const bNodeSocket &socket); static const NodeLog *find_node_by_spreadsheet_editor_context( const SpaceSpreadsheet &sspreadsheet); + void foreach_node_log(FunctionRef<void(const NodeLog &)> fn) const; private: using LogByTreeContext = Map<const DTreeContext *, TreeLog *>; diff --git a/source/blender/nodes/intern/geometry_nodes_eval_log.cc b/source/blender/nodes/intern/geometry_nodes_eval_log.cc index 3024cc51cad..7487f11d77d 100644 --- a/source/blender/nodes/intern/geometry_nodes_eval_log.cc +++ b/source/blender/nodes/intern/geometry_nodes_eval_log.cc @@ -99,6 +99,13 @@ SocketLog &ModifierLog::lookup_or_add_socket_log(LogByTreeContext &log_by_tree_c return socket_log; } +void ModifierLog::foreach_node_log(FunctionRef<void(const NodeLog &)> fn) const +{ + if (root_tree_logs_) { + root_tree_logs_->foreach_node_log(fn); + } +} + const NodeLog *TreeLog::lookup_node_log(StringRef node_name) const { const destruct_ptr<NodeLog> *node_log = node_logs_.lookup_ptr_as(node_name); @@ -122,6 +129,17 @@ const TreeLog *TreeLog::lookup_child_log(StringRef node_name) const return tree_log->get(); } +void TreeLog::foreach_node_log(FunctionRef<void(const NodeLog &)> fn) const +{ + for (auto node_log : node_logs_.items()) { + fn(*node_log.value); + } + + for (auto child : child_logs_.items()) { + child.value->foreach_node_log(fn); + } +} + const SocketLog *NodeLog::lookup_socket_log(eNodeSocketInOut in_out, int index) const { BLI_assert(index >= 0); |