diff options
author | Hans Goudey <h.goudey@me.com> | 2021-09-22 01:17:40 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-09-22 01:17:40 +0300 |
commit | 41e3bf8a8e79c8c42f72d49dea64b634aa243ff7 (patch) | |
tree | 970f85e06a569e80673e0c46f3a8d3765eb88d44 /source/blender/modifiers | |
parent | 8324ac84577cd96fe578dd905cc1eced823e2fef (diff) |
Geometry Nodes: Add legacy warning and "View Legacy" operator
This commit adds warning messages to "legacy" nodes that will be
removed in the future. The warning is shown in the node header, but
it is not printed in the terminal or displayed in the modifier. It is
also not propogated to node groups, but that is a more general task.
If the modifier's node tree has executed a deprecated node, it will
display a warning and a "Search" button that will select the nodes and
pan to them in the node editor. This doesn't open child node trees and
select nodes in there, because I want to keep this operator simple and
avoid wasting a lot of time perfecting this behavior.
Differential Revision: https://developer.blender.org/D12454
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r-- | source/blender/modifiers/intern/MOD_nodes.cc | 18 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_nodes_evaluator.cc | 8 |
2 files changed, 24 insertions, 2 deletions
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index 6b976b016e1..8c02c83d479 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -68,6 +68,8 @@ #include "UI_interface.h" #include "UI_resources.h" +#include "BLT_translation.h" + #include "WM_types.h" #include "RNA_access.h" @@ -1090,17 +1092,29 @@ static void panel_draw(const bContext *C, Panel *panel) } /* Draw node warnings. */ + bool has_legacy_node = false; 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) { + log.foreach_node_log([&](const geo_log::NodeLog &node_log) { for (const geo_log::NodeWarning &warning : node_log.warnings()) { - if (warning.type != geo_log::NodeWarningType::Info) { + if (warning.type == geo_log::NodeWarningType::Legacy) { + has_legacy_node = true; + } + else if (warning.type != geo_log::NodeWarningType::Info) { uiItemL(layout, warning.message.c_str(), ICON_ERROR); } } }); } + if (USER_EXPERIMENTAL_TEST(&U, use_geometry_nodes_fields) && has_legacy_node) { + uiLayout *row = uiLayoutRow(layout, false); + uiItemL(row, IFACE_("Node tree has legacy node"), ICON_ERROR); + uiLayout *sub = uiLayoutRow(row, false); + uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); + uiItemO(sub, "", ICON_VIEWZOOM, "NODE_OT_geometry_node_view_legacy"); + } + modifier_panel_end(layout, ptr); } diff --git a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc index 56de0f87ed8..e50c07ce6f2 100644 --- a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc +++ b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc @@ -26,6 +26,8 @@ #include "FN_generic_value_map.hh" #include "FN_multi_function.hh" +#include "BLT_translation.h" + #include "BLI_enumerable_thread_specific.hh" #include "BLI_stack.hh" #include "BLI_task.h" @@ -868,6 +870,12 @@ class GeometryNodesEvaluator { NodeParamsProvider params_provider{*this, node, node_state}; GeoNodeExecParams params{params_provider}; + if (USER_EXPERIMENTAL_TEST(&U, use_geometry_nodes_fields)) { + if (node->idname().find("Legacy") != StringRef::not_found) { + params.error_message_add(geo_log::NodeWarningType::Legacy, + TIP_("Legacy node will be removed before Blender 4.0")); + } + } bnode.typeinfo->geometry_node_execute(params); } |