mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Compositor: Support Warning node
This patch adds support for the Warning node in the compositor, which already exist in Geometry Nodes. Partially resolves #144443. Pull Request: https://projects.blender.org/blender/blender/pulls/158632
This commit is contained in:
parent
dd141a488a
commit
5f2067df3e
5 changed files with 48 additions and 3 deletions
|
|
@ -81,6 +81,7 @@ class NODE_MT_compositor_node_output_base(node_add_menu.NodeMenu):
|
|||
self.node_operator(layout, "NodeEnableOutput")
|
||||
self.node_operator(layout, "NodeGroupOutput")
|
||||
self.node_operator(layout, "CompositorNodeViewer")
|
||||
self.node_operator_with_searchable_enum(context, layout, "GeometryNodeWarning", "warning_type")
|
||||
if context.space_data.node_tree_sub_type == 'SCENE':
|
||||
layout.separator()
|
||||
self.node_operator(layout, "CompositorNodeOutputFile")
|
||||
|
|
|
|||
|
|
@ -837,7 +837,7 @@ class NODE_PT_active_node_generic(Panel):
|
|||
col.prop(node, "show_options")
|
||||
col.prop(node, "mute")
|
||||
|
||||
if tree.type == 'GEOMETRY':
|
||||
if tree.type in ('GEOMETRY', 'COMPOSITING'):
|
||||
layout.prop(node, "warning_propagation", text="Propagate")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -121,6 +121,13 @@ static void add_output_nodes(const Context &context,
|
|||
}
|
||||
}
|
||||
|
||||
/* Add Warning nodes. */
|
||||
for (const bNode *node : node_group.nodes_by_type("GeometryNodeWarning"_ustr)) {
|
||||
if (!node->is_muted()) {
|
||||
node_stack.push(node);
|
||||
}
|
||||
}
|
||||
|
||||
/* Add File Output nodes. */
|
||||
if (flag_is_set(needed_outputs_types, NodeGroupOutputTypes::FileOutputNode)) {
|
||||
for (const bNode *node : node_group.nodes_by_type("CompositorNodeOutputFile"_ustr)) {
|
||||
|
|
|
|||
|
|
@ -2168,7 +2168,7 @@ static void node_add_error_message_button(const TreeDrawContext &tree_draw_ctx,
|
|||
const rctf &rect,
|
||||
float &icon_offset)
|
||||
{
|
||||
if (ntree.type == NTREE_GEOMETRY) {
|
||||
if (ELEM(ntree.type, NTREE_GEOMETRY, NTREE_COMPOSIT)) {
|
||||
nodes::eval_log::NodeTreeLog *geo_tree_log = [&]() -> nodes::eval_log::NodeTreeLog * {
|
||||
const bNodeTreeZones *zones = node.owner_tree().zones();
|
||||
if (!zones) {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
#include "RNA_access.hh"
|
||||
#include "RNA_enum_types.hh"
|
||||
|
||||
#include "COM_node_operation.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
namespace nodes::node_geo_warning_cc {
|
||||
|
|
@ -70,6 +72,40 @@ class LazyFunctionForWarningNode : public LazyFunction {
|
|||
}
|
||||
};
|
||||
|
||||
using namespace blender::compositor;
|
||||
|
||||
class WarningOperation : public NodeOperation {
|
||||
public:
|
||||
using NodeOperation::NodeOperation;
|
||||
|
||||
void execute() override
|
||||
{
|
||||
const Result &input_show = this->get_input("Show");
|
||||
Result &output_show = this->get_result("Show");
|
||||
output_show.share_data(input_show);
|
||||
if (!input_show.get_single_value_default<bool>()) {
|
||||
return;
|
||||
}
|
||||
|
||||
nodes::eval_log::NodesEvalLog *log = this->context().nodes_evaluation_log();
|
||||
if (!log) {
|
||||
return;
|
||||
}
|
||||
nodes::eval_log::NodeTreeLogger &tree_logger = log->get_local_tree_logger(
|
||||
this->get_compute_context());
|
||||
|
||||
const std::string message = this->get_input("Message").get_single_value_default<std::string>();
|
||||
tree_logger.node_warnings.append(
|
||||
*tree_logger.allocator,
|
||||
{this->node().identifier, {NodeWarningType(this->node().custom1), std::move(message)}});
|
||||
}
|
||||
};
|
||||
|
||||
static NodeOperation *get_compositor_operation(Context &context, const bNode &node)
|
||||
{
|
||||
return new WarningOperation(context, node);
|
||||
}
|
||||
|
||||
static void node_layout(ui::Layout &layout, bContext * /*C*/, PointerRNA *ptr)
|
||||
{
|
||||
layout.use_property_split_set(true);
|
||||
|
|
@ -104,7 +140,7 @@ static void node_register()
|
|||
{
|
||||
static bke::bNodeType ntype;
|
||||
|
||||
geo_node_type_base(&ntype, "GeometryNodeWarning"_ustr, GEO_NODE_WARNING);
|
||||
geo_cmp_node_type_base(&ntype, "GeometryNodeWarning"_ustr, GEO_NODE_WARNING);
|
||||
ntype.ui_name = "Warning";
|
||||
ntype.ui_description = "Create custom warnings in node groups";
|
||||
ntype.enum_name_legacy = "WARNING";
|
||||
|
|
@ -112,6 +148,7 @@ static void node_register()
|
|||
ntype.declare = node_declare;
|
||||
ntype.labelfunc = node_label;
|
||||
ntype.draw_buttons = node_layout;
|
||||
ntype.get_compositor_operation = get_compositor_operation;
|
||||
bke::node_register_type(ntype);
|
||||
|
||||
node_rna(ntype.rna_ext.srna);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue