diff options
author | Jacques Lucke <jacques@blender.org> | 2021-11-24 15:39:09 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-11-24 15:39:20 +0300 |
commit | 65f547c3fc116860b9c7eaf6e3d8abd2651f5168 (patch) | |
tree | 2b93be1b725f0f941af45f215c861fbf01c63166 /source/blender/nodes | |
parent | 9fc5a9c78f57f11d72ab6dbaf819945c862367e1 (diff) |
Geometry Nodes: add utility to show debug messages in node editor
This is only meant to be used for development purposes for now,
not to show warnings to the user.
Differential Revision: https://developer.blender.org/D13348
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/NOD_geometry_nodes_eval_log.hh | 13 | ||||
-rw-r--r-- | source/blender/nodes/intern/geometry_nodes_eval_log.cc | 14 |
2 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/nodes/NOD_geometry_nodes_eval_log.hh b/source/blender/nodes/NOD_geometry_nodes_eval_log.hh index 0fbc1803db6..53ead9af241 100644 --- a/source/blender/nodes/NOD_geometry_nodes_eval_log.hh +++ b/source/blender/nodes/NOD_geometry_nodes_eval_log.hh @@ -176,6 +176,11 @@ struct NodeWithExecutionTime { std::chrono::microseconds exec_time; }; +struct NodeWithDebugMessage { + DNode node; + std::string message; +}; + /** The same value can be referenced by multiple sockets when they are linked. */ struct ValueOfSockets { Span<DSocket> sockets; @@ -197,6 +202,7 @@ class LocalGeoLogger { Vector<ValueOfSockets> values_; Vector<NodeWithWarning> node_warnings_; Vector<NodeWithExecutionTime> node_exec_times_; + Vector<NodeWithDebugMessage> node_debug_messages_; friend ModifierLog; @@ -210,6 +216,7 @@ class LocalGeoLogger { void log_multi_value_socket(DSocket socket, Span<GPointer> values); void log_node_warning(DNode node, NodeWarningType type, std::string message); void log_execution_time(DNode node, std::chrono::microseconds exec_time); + void log_debug_message(DNode node, std::string message); }; /** The root logger class. */ @@ -283,6 +290,7 @@ class NodeLog { Vector<SocketLog> input_logs_; Vector<SocketLog> output_logs_; Vector<NodeWarning, 0> warnings_; + Vector<std::string, 0> debug_messages_; std::chrono::microseconds exec_time_; friend ModifierLog; @@ -307,6 +315,11 @@ class NodeLog { return warnings_; } + Span<std::string> debug_messages() const + { + return debug_messages_; + } + std::chrono::microseconds execution_time() const { return exec_time_; diff --git a/source/blender/nodes/intern/geometry_nodes_eval_log.cc b/source/blender/nodes/intern/geometry_nodes_eval_log.cc index 4cba9669647..f504dbfd4b4 100644 --- a/source/blender/nodes/intern/geometry_nodes_eval_log.cc +++ b/source/blender/nodes/intern/geometry_nodes_eval_log.cc @@ -72,6 +72,11 @@ ModifierLog::ModifierLog(GeoLogger &logger) node_with_exec_time.node); node_log.exec_time_ = node_with_exec_time.exec_time; } + + for (NodeWithDebugMessage &debug_message : local_logger.node_debug_messages_) { + NodeLog &node_log = this->lookup_or_add_node_log(log_by_tree_context, debug_message.node); + node_log.debug_messages_.append(debug_message.message); + } } } @@ -484,4 +489,13 @@ void LocalGeoLogger::log_execution_time(DNode node, std::chrono::microseconds ex node_exec_times_.append({node, exec_time}); } +/** + * Log a message that will be displayed in the node editor next to the node. This should only be + * used for debugging purposes and not to display information to users. + */ +void LocalGeoLogger::log_debug_message(DNode node, std::string message) +{ + node_debug_messages_.append({node, std::move(message)}); +} + } // namespace blender::nodes::geometry_nodes_eval_log |