From 5ef5a9fc24668aa264fe0558db9c0fb1246aa37f Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Fri, 3 Dec 2021 20:26:10 -0500 Subject: Compositor: Migrate most nodes to new socket builder API This patch leaves a out a few nodes: - Group Nodes - Image input node - File output node - Switch View - Cryptomatte These nodes above are a bit more complicated and should be worked on individually. Differential Revision: https://developer.blender.org/D13266 --- .../composite/nodes/node_composite_stabilize2d.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc') diff --git a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc index e5ce2e8ceb9..a6a18705f2f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc +++ b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc @@ -26,17 +26,17 @@ #include "BKE_context.h" #include "BKE_lib_id.h" -/* **************** Translate ******************** */ +/* **************** Stabilize 2D ******************** */ -static bNodeSocketTemplate cmp_node_stabilize2d_in[] = { - {SOCK_RGBA, N_("Image"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, - {-1, ""}, -}; +namespace blender::nodes { -static bNodeSocketTemplate cmp_node_stabilize2d_out[] = { - {SOCK_RGBA, N_("Image")}, - {-1, ""}, -}; +static void cmp_node_stabilize2d_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Image")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_output(N_("Image")); +} + +} // namespace blender::nodes static void init(const bContext *C, PointerRNA *ptr) { @@ -55,7 +55,7 @@ void register_node_type_cmp_stabilize2d(void) static bNodeType ntype; cmp_node_type_base(&ntype, CMP_NODE_STABILIZE2D, "Stabilize 2D", NODE_CLASS_DISTORT, 0); - node_type_socket_templates(&ntype, cmp_node_stabilize2d_in, cmp_node_stabilize2d_out); + ntype.declare = blender::nodes::cmp_node_stabilize2d_declare; ntype.initfunc_api = init; nodeRegisterType(&ntype); -- cgit v1.2.3 From 0578921063fbb081239439062215f2538a31af4b Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Sun, 5 Dec 2021 16:38:00 -0500 Subject: Cleanup: clang-tidy: modernize-redundant-void-arg This change follows up on recent c --> c++ conversions --- source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc') diff --git a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc index a6a18705f2f..841cc6a5da3 100644 --- a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc +++ b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc @@ -50,7 +50,7 @@ static void init(const bContext *C, PointerRNA *ptr) node->custom1 = 1; } -void register_node_type_cmp_stabilize2d(void) +void register_node_type_cmp_stabilize2d() { static bNodeType ntype; -- cgit v1.2.3 From 0f48b37aae0230119523a9718b331961bd989a78 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 7 Dec 2021 13:26:39 +0100 Subject: Revert moving all shader nodes to c++ This reverts to following commits: * rB5cad004d716da02f511bd34983ac7da820308676 * rB97e3a2d935ba9b21b127eda7ca104d4bcf4e48bd * rBf60b95b5320f8d6abe6a629fe8fc4f1b94d0d91c * rB0bd3cad04edf4bf9b9d3b1353f955534aa5e6740 * rBf72cc47d8edf849af98e196f721022bacf86a5e7 * rB3f7014ecc9d523997062eadd62888af5fc70a2b6 * rB0578921063fbb081239439062215f2538a31af4b * rBc20098e6ec6adee874a12e510aa4a56d89f92838 * rBd5efda72f501ad95679d7ac554086a1fb18c1ac0 The original move to c++ that the other commits depended upon had some issues that should be fixed before committing it again. The issues were reported in T93797, T93809 and T93798. We should also find a better rule for not using c-style casts going forward, although that wouldn't have been reason enough to revert the commits. Introducing something like a `MEM_new` and `MEM_delete` function might help with the the most common case of casting the return type of `MEM_malloc`. Going forward, I recommend first committing the changes that don't require converting files to c++. Then convert the shading node files in smaller chunks. Especially don't mix fairly low risk changes like moving some simple nodes, with higher risk changes. --- source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc') diff --git a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc index 841cc6a5da3..a6a18705f2f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc +++ b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc @@ -50,7 +50,7 @@ static void init(const bContext *C, PointerRNA *ptr) node->custom1 = 1; } -void register_node_type_cmp_stabilize2d() +void register_node_type_cmp_stabilize2d(void) { static bNodeType ntype; -- cgit v1.2.3 From b9641cfc37bc54376d48ba32438bd858f6c30c52 Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Tue, 7 Dec 2021 12:36:33 -0500 Subject: Cleanup: clang-tidy: modernize-redundant-void-arg Re commits part of rB0578921063fbb081239439062215f2538a31af4b --- source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc') diff --git a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc index a6a18705f2f..841cc6a5da3 100644 --- a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc +++ b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc @@ -50,7 +50,7 @@ static void init(const bContext *C, PointerRNA *ptr) node->custom1 = 1; } -void register_node_type_cmp_stabilize2d(void) +void register_node_type_cmp_stabilize2d() { static bNodeType ntype; -- cgit v1.2.3 From 4e98d974b596cdb7b04872b9c8fb43fc284696e9 Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Wed, 15 Dec 2021 21:30:04 -0500 Subject: Nodes: Begin splitting composite node buttons into individual files Currently, most node buttons are defined in `drawnode.cc` however, this is inconvenient because it requires editing many files when adding new nodes. The goal is to minimize the number of files needed to add or update a node. This commit moves most of the node layout functions for composite nodes into their respected `source/blender/nodes/composite/nodes` file. In the future, these functions will be simplified to `node_layout` once files have their own namespace. See {D13466} for more information. Reviewed By: HooglyBoogly Differential Revision: https://developer.blender.org/D13523 --- .../composite/nodes/node_composite_stabilize2d.cc | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc') diff --git a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc index 841cc6a5da3..de6cc21ccd5 100644 --- a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc +++ b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc @@ -21,11 +21,14 @@ * \ingroup cmpnodes */ -#include "node_composite_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" #include "BKE_context.h" #include "BKE_lib_id.h" +#include "node_composite_util.hh" + /* **************** Stabilize 2D ******************** */ namespace blender::nodes { @@ -50,12 +53,36 @@ static void init(const bContext *C, PointerRNA *ptr) node->custom1 = 1; } +static void node_composit_buts_stabilize2d(uiLayout *layout, bContext *C, PointerRNA *ptr) +{ + bNode *node = (bNode *)ptr->data; + + uiTemplateID(layout, + C, + ptr, + "clip", + nullptr, + "CLIP_OT_open", + nullptr, + UI_TEMPLATE_ID_FILTER_ALL, + false, + nullptr); + + if (!node->id) { + return; + } + + uiItemR(layout, ptr, "filter_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); + uiItemR(layout, ptr, "invert", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); +} + void register_node_type_cmp_stabilize2d() { static bNodeType ntype; cmp_node_type_base(&ntype, CMP_NODE_STABILIZE2D, "Stabilize 2D", NODE_CLASS_DISTORT, 0); ntype.declare = blender::nodes::cmp_node_stabilize2d_declare; + ntype.draw_buttons = node_composit_buts_stabilize2d; ntype.initfunc_api = init; nodeRegisterType(&ntype); -- cgit v1.2.3