[Bf-blender-cvs] [ffb5d1205e7] temp-enum-socket: add initial enum node

Jacques Lucke noreply at git.blender.org
Mon Nov 8 16:07:01 CET 2021


Commit: ffb5d1205e70be82146ea81b52e9180c1a8d3ca3
Author: Jacques Lucke
Date:   Thu Nov 4 13:38:18 2021 +0100
Branches: temp-enum-socket
https://developer.blender.org/rBffb5d1205e70be82146ea81b52e9180c1a8d3ca3

add initial enum node

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

M	release/scripts/startup/nodeitems_builtins.py
M	source/blender/blenkernel/BKE_node.h
M	source/blender/blenkernel/intern/node.cc
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_enum.cc

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

diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index 34f447a7108..2a49cbd460b 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -754,6 +754,7 @@ geometry_node_categories = [
         NodeItem("GeometryNodeSwitch"),
         NodeItem("FunctionNodeRandomValue"),
         NodeItem("FunctionNodeAlignEulerToVector"),
+        NodeItem("FunctionNodeEnum"),
     ]),
     GeometryNodeCategory("GEO_VECTOR", "Vector", items=[
         NodeItem("ShaderNodeVectorCurve"),
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 58fea6d462c..53549dc61c3 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1575,6 +1575,7 @@ int ntreeTexExecTree(struct bNodeTree *ntree,
 #define FN_NODE_REPLACE_STRING 1218
 #define FN_NODE_INPUT_BOOL 1219
 #define FN_NODE_INPUT_INT 1220
+#define FN_NODE_ENUM 1221
 
 /** \} */
 
diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index e4b78865a2d..2de6a3e89e4 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -5906,6 +5906,7 @@ static void registerFunctionNodes()
 
   register_node_type_fn_align_euler_to_vector();
   register_node_type_fn_boolean_math();
+  register_node_type_fn_enum();
   register_node_type_fn_float_compare();
   register_node_type_fn_float_to_int();
   register_node_type_fn_input_bool();
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index f4ca9f51b1b..5cc155fbd98 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -138,6 +138,7 @@ set(SRC
 
   function/nodes/node_fn_align_euler_to_vector.cc
   function/nodes/node_fn_boolean_math.cc
+  function/nodes/node_fn_enum.cc
   function/nodes/node_fn_float_compare.cc
   function/nodes/node_fn_float_to_int.cc
   function/nodes/node_fn_input_bool.cc
diff --git a/source/blender/nodes/NOD_function.h b/source/blender/nodes/NOD_function.h
index 81f0667fe1c..03a11b709cf 100644
--- a/source/blender/nodes/NOD_function.h
+++ b/source/blender/nodes/NOD_function.h
@@ -24,6 +24,7 @@ void register_node_type_fn_legacy_random_float(void);
 
 void register_node_type_fn_align_euler_to_vector(void);
 void register_node_type_fn_boolean_math(void);
+void register_node_type_fn_enum(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);
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index 20ad4d359f1..b157d77a57e 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -268,6 +268,7 @@ DefNode(FunctionNode, FN_NODE_LEGACY_RANDOM_FLOAT, 0, "LEGACY_RANDOM_FLOAT", Leg
 DefNode(FunctionNode, FN_NODE_ALIGN_EULER_TO_VECTOR, def_fn_align_euler_to_vector, "ALIGN_EULER_TO_VECTOR", AlignEulerToVector, "Align Euler To Vector", "")
 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_ENUM, 0, "ENUM", Enum, "Enum", "")
 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", "")
diff --git a/source/blender/nodes/function/nodes/node_fn_enum.cc b/source/blender/nodes/function/nodes/node_fn_enum.cc
new file mode 100644
index 00000000000..d73fb8d1442
--- /dev/null
+++ b/source/blender/nodes/function/nodes/node_fn_enum.cc
@@ -0,0 +1,63 @@
+/*
+ * 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 <cmath>
+
+#include "RNA_enum_types.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+
+#include "node_function_util.hh"
+
+namespace blender::nodes {
+
+static void fn_node_enum_declare(NodeDeclarationBuilder &b)
+{
+  b.is_function_node();
+  b.add_input<decl::Float>(N_("Float"));
+  b.add_output<decl::Int>(N_("Integer"));
+};
+
+static void fn_node_enum_layout(uiLayout *UNUSED(layout),
+                                bContext *UNUSED(C),
+                                PointerRNA *UNUSED(ptr))
+{
+}
+
+static const fn::MultiFunction *get_multi_function(bNode &UNUSED(bnode))
+{
+  return nullptr;
+}
+
+static void fn_node_enum_build_multi_function(NodeMultiFunctionBuilder &builder)
+{
+  const fn::MultiFunction *fn = get_multi_function(builder.node());
+  builder.set_matching_fn(fn);
+}
+
+}  // namespace blender::nodes
+
+void register_node_type_fn_enum()
+{
+  static bNodeType ntype;
+
+  fn_node_type_base(&ntype, FN_NODE_ENUM, "Enum", NODE_CLASS_SCRIPT, 0);
+  ntype.declare = blender::nodes::fn_node_enum_declare;
+  ntype.build_multi_function = blender::nodes::fn_node_enum_build_multi_function;
+  ntype.draw_buttons = blender::nodes::fn_node_enum_layout;
+  nodeRegisterType(&ntype);
+}



More information about the Bf-blender-cvs mailing list