[Bf-blender-cvs] [781289e31fb] master: Geometry Nodes: add Boolean and Integer Input nodes

Dorian noreply at git.blender.org
Fri Oct 22 15:08:11 CEST 2021


Commit: 781289e31fbec004584b3789c801d1db012dfaa4
Author: Dorian
Date:   Fri Oct 22 14:59:15 2021 +0200
Branches: master
https://developer.blender.org/rB781289e31fbec004584b3789c801d1db012dfaa4

Geometry Nodes: add Boolean and Integer Input nodes

These nodes just output a single value of their respective types,
making it possible to control multiple inputs with the same value.

Differential Revision: https://developer.blender.org/D12932

===================================================================

M	release/scripts/startup/nodeitems_builtins.py
M	source/blender/blenkernel/BKE_node.h
M	source/blender/blenkernel/intern/node.cc
M	source/blender/makesdna/DNA_node_types.h
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/nodes/CMakeLists.txt
M	source/blender/nodes/NOD_function.h
M	source/blender/nodes/NOD_static_types.h
A	source/blender/nodes/function/nodes/node_fn_input_bool.cc
A	source/blender/nodes/function/nodes/node_fn_input_int.cc

===================================================================

diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index e481b360300..418311cf27e 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -172,7 +172,9 @@ def geometry_input_node_items(context):
         yield NodeItemCustom(draw=lambda self, layout, context: layout.separator())
 
     yield NodeItem("GeometryNodeCollectionInfo")
+    yield NodeItem("FunctionNodeInputBool")
     yield NodeItem("FunctionNodeInputColor")
+    yield NodeItem("FunctionNodeInputInt")
     yield NodeItem("GeometryNodeIsViewport")
     yield NodeItem("GeometryNodeInputMaterial")
     yield NodeItem("GeometryNodeObjectInfo")
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index a9bba3908ce..7a9c23d3f54 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1568,6 +1568,8 @@ int ntreeTexExecTree(struct bNodeTree *ntree,
 #define FN_NODE_ALIGN_EULER_TO_VECTOR 1216
 #define FN_NODE_INPUT_COLOR 1217
 #define FN_NODE_REPLACE_STRING 1218
+#define FN_NODE_INPUT_BOOL 1219
+#define FN_NODE_INPUT_INT 1220
 
 /** \} */
 
diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index 6b626af7dd2..d403d048173 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -5876,6 +5876,8 @@ static void registerFunctionNodes()
   register_node_type_fn_boolean_math();
   register_node_type_fn_float_compare();
   register_node_type_fn_float_to_int();
+  register_node_type_fn_input_bool();
+  register_node_type_fn_input_int();
   register_node_type_fn_input_special_characters();
   register_node_type_fn_input_string();
   register_node_type_fn_input_vector();
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 12b81433ffd..b585cbd6306 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1291,6 +1291,14 @@ typedef struct NodeAttributeCurveMap {
   CurveMapping *curve_rgb;
 } NodeAttributeCurveMap;
 
+typedef struct NodeInputBool {
+  uint8_t boolean;
+} NodeInputBool;
+
+typedef struct NodeInputInt {
+  int integer;
+} NodeInputInt;
+
 typedef struct NodeInputVector {
   float vector[3];
 } NodeInputVector;
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 438344304cf..f0508ee5317 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -5014,6 +5014,34 @@ static void def_fn_input_color(StructRNA *srna)
   RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 }
 
+static void def_fn_input_bool(StructRNA *srna)
+{
+  PropertyRNA *prop;
+
+  RNA_def_struct_sdna_from(srna, "NodeInputBool", "storage");
+
+  prop = RNA_def_property(srna, "boolean", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "boolean", 1);
+  RNA_def_property_ui_text(
+    prop, "Boolean", "Input value used for unconnected socket");
+  RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
+}
+
+static void def_fn_input_int(StructRNA *srna)
+{
+  PropertyRNA *prop;
+
+  RNA_def_struct_sdna_from(srna, "NodeInputInt", "storage");
+
+  prop = RNA_def_property(srna, "integer", PROP_INT, PROP_NONE);
+  RNA_def_property_int_sdna(prop, NULL, "integer");
+  RNA_def_property_int_default(prop, 1);
+  RNA_def_property_ui_text(
+    prop, "Integer", "Input value used for unconnected socket");
+  RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+}
+
 static void def_fn_input_vector(StructRNA *srna)
 {
   PropertyRNA *prop;
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 8630bcd3b73..3e62fcb47f5 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -140,7 +140,9 @@ set(SRC
   function/nodes/node_fn_boolean_math.cc
   function/nodes/node_fn_float_compare.cc
   function/nodes/node_fn_float_to_int.cc
+  function/nodes/node_fn_input_bool.cc
   function/nodes/node_fn_input_color.cc
+  function/nodes/node_fn_input_int.cc
   function/nodes/node_fn_input_special_characters.cc
   function/nodes/node_fn_input_string.cc
   function/nodes/node_fn_input_vector.cc
diff --git a/source/blender/nodes/NOD_function.h b/source/blender/nodes/NOD_function.h
index e3e75b6fa7a..0652a0d1e94 100644
--- a/source/blender/nodes/NOD_function.h
+++ b/source/blender/nodes/NOD_function.h
@@ -26,6 +26,8 @@ void register_node_type_fn_align_euler_to_vector(void);
 void register_node_type_fn_boolean_math(void);
 void register_node_type_fn_float_compare(void);
 void register_node_type_fn_float_to_int(void);
+void register_node_type_fn_input_bool(void);
+void register_node_type_fn_input_int(void);
 void register_node_type_fn_input_special_characters(void);
 void register_node_type_fn_input_string(void);
 void register_node_type_fn_input_vector(void);
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index b5254f2e898..843d414f426 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -269,7 +269,9 @@ DefNode(FunctionNode, FN_NODE_ALIGN_EULER_TO_VECTOR, def_fn_align_euler_to_vecto
 DefNode(FunctionNode, FN_NODE_BOOLEAN_MATH,  def_boolean_math,  "BOOLEAN_MATH",  BooleanMath,  "Boolean Math", "")
 DefNode(FunctionNode, FN_NODE_COMPARE_FLOATS, def_float_compare, "COMPARE_FLOATS", CompareFloats, "Compare Floats", "")
 DefNode(FunctionNode, FN_NODE_FLOAT_TO_INT, def_float_to_int, "FLOAT_TO_INT", FloatToInt, "Float to Integer", "")
+DefNode(FunctionNode, FN_NODE_INPUT_BOOL, def_fn_input_bool, "INPUT_BOOL", InputBool, "Boolean", "")
 DefNode(FunctionNode, FN_NODE_INPUT_COLOR, def_fn_input_color, "INPUT_COLOR", InputColor, "Color", "")
+DefNode(FunctionNode, FN_NODE_INPUT_INT, def_fn_input_int, "INPUT_INT", InputInt, "Integer", "")
 DefNode(FunctionNode, FN_NODE_INPUT_SPECIAL_CHARACTERS, 0, "INPUT_SPECIAL_CHARACTERS", InputSpecialCharacters, "Special Characters", "")
 DefNode(FunctionNode, FN_NODE_INPUT_STRING, def_fn_input_string, "INPUT_STRING", InputString, "String", "")
 DefNode(FunctionNode, FN_NODE_INPUT_VECTOR, def_fn_input_vector, "INPUT_VECTOR", InputVector, "Vector", "")
diff --git a/source/blender/nodes/function/nodes/node_fn_input_bool.cc b/source/blender/nodes/function/nodes/node_fn_input_bool.cc
new file mode 100644
index 00000000000..58f8969f1b6
--- /dev/null
+++ b/source/blender/nodes/function/nodes/node_fn_input_bool.cc
@@ -0,0 +1,64 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "node_function_util.hh"
+
+#include "BLI_hash.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+
+namespace blender::nodes {
+
+static void fn_node_input_bool_declare(NodeDeclarationBuilder &b)
+{
+  b.add_output<decl::Bool>("Boolean");
+};
+
+static void fn_node_input_bool_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+  uiLayout *col = uiLayoutColumn(layout, true);
+  uiItemR(col, ptr, "boolean", UI_ITEM_R_EXPAND, IFACE_("Value"), ICON_NONE);
+}
+
+static void fn_node_input_bool_build_multi_function(NodeMultiFunctionBuilder &builder)
+{
+  bNode &bnode = builder.node();
+  NodeInputBool *node_storage = static_cast<NodeInputBool *>(bnode.storage);
+  builder.construct_and_set_matching_fn<fn::CustomMF_Constant<bool>>(node_storage->boolean);
+}
+
+static void fn_node_input_bool_init(bNodeTree *UNUSED(ntree), bNode *node)
+{
+  NodeInputBool *data = (NodeInputBool *)MEM_callocN(sizeof(NodeInputBool), __func__);
+  node->storage = data;
+}
+
+}  // namespace blender::nodes
+
+void register_node_type_fn_input_bool()
+{
+  static bNodeType ntype;
+
+  fn_node_type_base(&ntype, FN_NODE_INPUT_BOOL, "Boolean", 0, 0);
+  ntype.declare = blender::nodes::fn_node_input_bool_declare;
+  node_type_init(&ntype, blender::nodes::fn_node_input_bool_init);
+  node_type_storage(
+      &ntype, "NodeInputBool", node_free_standard_storage, node_copy_standard_storage);
+  ntype.build_multi_function = blender::nodes::fn_node_input_bool_build_multi_function;
+  ntype.draw_buttons = blender::nodes::fn_node_input_bool_layout;
+  nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/function/nodes/node_fn_input_int.cc b/source/blender/nodes/function/nodes/node_fn_input_int.cc
new file mode 100644
index 00000000000..db52d569ac5
--- /dev/null
+++ b/source/blender/nodes/function/nodes/node_fn_input_int.cc
@@ -0,0 +1,64 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "node_function_util.hh"
+
+#include "BLI_hash.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+
+namespace blender::nodes {
+
+static void fn_node_input_int_declare(NodeDeclarat

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list