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
This commit is contained in:
parent
f76dfe8fb4
commit
49e68f15f2
Notes:
blender-bot
2023-02-14 10:18:56 +01:00
Referenced by issue #89873, Nodetree warnings should be visible in the modifier
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 *>;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue