[Bf-blender-cvs] [54602b70f04] builtin-simulation-nodes: add switch node ui

Jacques Lucke noreply at git.blender.org
Mon Mar 30 14:15:18 CEST 2020


Commit: 54602b70f0422bee73053df2227d906dcec87670
Author: Jacques Lucke
Date:   Mon Mar 30 14:15:09 2020 +0200
Branches: builtin-simulation-nodes
https://developer.blender.org/rB54602b70f0422bee73053df2227d906dcec87670

add switch node ui

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

M	release/scripts/startup/nodeitems_builtins.py
M	source/blender/blenkernel/BKE_node.h
M	source/blender/blenkernel/intern/node.c
M	source/blender/editors/space_node/drawnode.c
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
M	source/blender/nodes/function/nodes/node_fn_separate_rgb.cc
A	source/blender/nodes/function/nodes/node_fn_switch.cc

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

diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index ca624cd3e87..17dd8a0a601 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -530,6 +530,7 @@ simulation_node_categories = [
         NodeItem("FunctionNodeInstanceIdentifier"),
         NodeItem("FunctionNodeStringConcatenation"),
         NodeItem("FunctionNodeObjectTransforms"),
+        NodeItem("FunctionNodeSwitch"),
     ]),
     FunctionNodeCategory("SURFACE", "Surface", items=[
         NodeItem("FunctionNodeClosestSurface"),
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index b24ce862d69..259239aec27 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1031,6 +1031,7 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree,
 #define FN_NODE_INSTANCE_IDENTIFIER 1115
 #define FN_NODE_STRING_CONCATENATION 1116
 #define FN_NODE_OBJECT_TRANSFORMS 1117
+#define FN_NODE_SWITCH 1118
 
 /* custom defines options for Material node */
 // #define SH_NODE_MAT_DIFF 1
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 1a853cfa0b1..6919624be50 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -4243,6 +4243,7 @@ static void registerFunctionNodes(void)
   register_node_type_fn_instance_identifier();
   register_node_type_fn_string_concatenation();
   register_node_type_fn_object_transforms();
+  register_node_type_fn_switch();
 }
 
 void init_nodesystem(void)
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index f4b9d352141..98060cecffc 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -3181,6 +3181,11 @@ static void node_function_buts_float_compare(uiLayout *layout,
   uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
 }
 
+static void node_function_buts_switch(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+  uiItemR(layout, ptr, "data_type", 0, "", ICON_NONE);
+}
+
 static void node_function_set_butfunc(bNodeType *ntype)
 {
   switch (ntype->type) {
@@ -3196,6 +3201,9 @@ static void node_function_set_butfunc(bNodeType *ntype)
     case FN_NODE_FLOAT_COMPARE:
       ntype->draw_buttons = node_function_buts_float_compare;
       break;
+    case FN_NODE_SWITCH:
+      ntype->draw_buttons = node_function_buts_switch;
+      break;
   }
 }
 
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index fed3c7aecfa..e618924d4fa 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -91,7 +91,7 @@ static const EnumPropertyItem node_socket_type_items[] = {
     {0, NULL, 0, NULL, NULL},
 };
 
-static const EnumPropertyItem node_socket_particle_attribute_types[] = {
+static const EnumPropertyItem node_socket_particle_attribute_type_items[] = {
     {SOCK_FLOAT, "FLOAT", 0, "Float", ""},
     {SOCK_INT, "INT", 0, "Int", ""},
     {SOCK_BOOLEAN, "BOOLEAN", 0, "Boolean", ""},
@@ -103,6 +103,19 @@ static const EnumPropertyItem node_socket_particle_attribute_types[] = {
     {0, NULL, 0, NULL, NULL},
 };
 
+static const EnumPropertyItem node_socket_data_type_items[] = {
+    {SOCK_FLOAT, "FLOAT", 0, "Float", ""},
+    {SOCK_INT, "INT", 0, "Int", ""},
+    {SOCK_BOOLEAN, "BOOLEAN", 0, "Boolean", ""},
+    {SOCK_VECTOR, "VECTOR", 0, "Vector", ""},
+    {SOCK_STRING, "STRING", 0, "String", ""},
+    {SOCK_RGBA, "RGBA", 0, "Color", ""},
+    {SOCK_OBJECT, "OBJECT", 0, "Object", ""},
+    {SOCK_IMAGE, "IMAGE", 0, "Image", ""},
+    {SOCK_SURFACE_HOOK, "SURFACE_HOOK", 0, "Surface Hook", ""},
+    {0, NULL, 0, NULL, NULL},
+};
+
 static const EnumPropertyItem node_quality_items[] = {
     {NTREE_QUALITY_HIGH, "HIGH", 0, "High", "High quality"},
     {NTREE_QUALITY_MEDIUM, "MEDIUM", 0, "Medium", "Medium quality"},
@@ -4203,6 +4216,17 @@ static void def_float_compare(StructRNA *srna)
   RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_FunctionNode_socket_update");
 }
 
+static void def_fn_switch(StructRNA *srna)
+{
+  PropertyRNA *prop;
+
+  prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_sdna(prop, NULL, "custom1");
+  RNA_def_property_enum_items(prop, node_socket_data_type_items);
+  RNA_def_property_ui_text(prop, "Data Type", "Data type for inputs and outputs");
+  RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_FunctionNode_socket_update");
+}
+
 static void def_rgb_curve(StructRNA *srna)
 {
   PropertyRNA *prop;
@@ -8108,7 +8132,7 @@ static void def_sim_particle_attribute(StructRNA *srna)
 
   prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE);
   RNA_def_property_enum_sdna(prop, NULL, "custom1");
-  RNA_def_property_enum_items(prop, node_socket_particle_attribute_types);
+  RNA_def_property_enum_items(prop, node_socket_particle_attribute_type_items);
   RNA_def_property_ui_text(
       prop,
       "Data Type",
@@ -8122,7 +8146,7 @@ static void def_sim_set_particle_attribute(StructRNA *srna)
 
   prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE);
   RNA_def_property_enum_sdna(prop, NULL, "custom1");
-  RNA_def_property_enum_items(prop, node_socket_particle_attribute_types);
+  RNA_def_property_enum_items(prop, node_socket_particle_attribute_type_items);
   RNA_def_property_ui_text(
       prop,
       "Data Type",
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 3501ba2563e..02b3f52e33d 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -136,16 +136,17 @@ set(SRC
   function/nodes/node_fn_combine_xyz.cc
   function/nodes/node_fn_float_compare.cc
   function/nodes/node_fn_float_math.cc
+  function/nodes/node_fn_instance_identifier.cc
+  function/nodes/node_fn_object_transforms.cc
   function/nodes/node_fn_separate_hsv.cc
   function/nodes/node_fn_separate_rgb.cc
   function/nodes/node_fn_separate_xyz.cc
-  function/nodes/node_fn_surface_color.cc
-  function/nodes/node_fn_instance_identifier.cc
   function/nodes/node_fn_string_concatenation.cc
-  function/nodes/node_fn_object_transforms.cc
+  function/nodes/node_fn_surface_color.cc
   function/nodes/node_fn_surface_normal.cc
   function/nodes/node_fn_surface_position.cc
   function/nodes/node_fn_surface_weight.cc
+  function/nodes/node_fn_switch.cc
   function/nodes/node_fn_vector_math.cc
   function/node_fn_util.cc
 
diff --git a/source/blender/nodes/NOD_function.h b/source/blender/nodes/NOD_function.h
index ea2226eb10a..69e0a3ee6ea 100644
--- a/source/blender/nodes/NOD_function.h
+++ b/source/blender/nodes/NOD_function.h
@@ -23,6 +23,7 @@ void register_node_type_fn_float_compare(void);
 void register_node_type_fn_instance_identifier(void);
 void register_node_type_fn_string_concatenation(void);
 void register_node_type_fn_object_transforms(void);
+void register_node_type_fn_switch(void);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index ccb0cf7dc08..faf0fe4aa3c 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -289,6 +289,7 @@ DefNode(FunctionNode, FN_NODE_FLOAT_COMPARE, def_float_compare, "FLOAT_COMPARE",
 DefNode(FunctionNode, FN_NODE_INSTANCE_IDENTIFIER, 0, "INSTANCE_IDENTIFIER", InstanceIdentifier, "Instance Identifier", "");
 DefNode(FunctionNode, FN_NODE_STRING_CONCATENATION, 0, "STRING_CONCATENATION", StringConcatenation, "String Concatenation", "");
 DefNode(FunctionNode, FN_NODE_OBJECT_TRANSFORMS, 0, "OBJECT_TRANSFORMS", ObjectTransforms, "Object Transforms", "");
+DefNode(FunctionNode, FN_NODE_SWITCH, def_fn_switch, "SWITCH", Switch, "Switch", "");
 
 /* undefine macros */
 #undef DefNode
diff --git a/source/blender/nodes/function/nodes/node_fn_separate_rgb.cc b/source/blender/nodes/function/nodes/node_fn_separate_rgb.cc
index e0787e6e19a..704b7a46958 100644
--- a/source/blender/nodes/function/nodes/node_fn_separate_rgb.cc
+++ b/source/blender/nodes/function/nodes/node_fn_separate_rgb.cc
@@ -1,7 +1,7 @@
 #include "node_fn_util.h"
 
 static bNodeSocketTemplate fn_node_separate_rgb_in[] = {
-    {SOCK_RGBA, N_("Color")},
+    {SOCK_RGBA, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f},
     {-1, ""},
 };
 
diff --git a/source/blender/nodes/function/nodes/node_fn_switch.cc b/source/blender/nodes/function/nodes/node_fn_switch.cc
new file mode 100644
index 00000000000..f0a49a1ed50
--- /dev/null
+++ b/source/blender/nodes/function/nodes/node_fn_switch.cc
@@ -0,0 +1,63 @@
+#include "BLI_listbase.h"
+#include "node_fn_util.h"
+
+static bNodeSocketTemplate fn_node_switch_in[] = {
+    {SOCK_BOOLEAN, N_("Switch")},
+
+    {SOCK_FLOAT, N_("If False"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
+    {SOCK_INT, N_("If False"), 0, 0, 0, 0, -10000, 10000},
+    {SOCK_BOOLEAN, N_("If False")},
+    {SOCK_VECTOR, N_("If False"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
+    {SOCK_STRING, N_("If False")},
+    {SOCK_RGBA, N_("If False"), 0.8f, 0.8f, 0.8f, 1.0f},
+    {SOCK_OBJECT, N_("If False")},
+    {SOCK_IMAGE, N_("If False")},
+    {SOCK_SURFACE_HOOK, N_("If False")},
+
+    {SOCK_FLOAT, N_("If True"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
+    {SOCK_INT, N_("If True"), 0, 0, 0, 0, -10000, 10000},
+    {SOCK_BOOLEAN, N_("If True")},
+    {SOCK_VECTOR, N_("If True"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
+    {SOCK_STRING, N_("If True")},
+    {SOCK_RGBA, N_("If True"), 0.8f, 0.8f, 0.8f, 1.0f},
+    {SOCK_OBJECT, N_("If True")},
+    {SOCK_IMAGE, N_("If True")},
+    {SOCK_SURFACE_HOOK, N_("If True")},
+
+    {-1, ""},
+};
+
+static bNodeSocketTemplate fn_node_switch_out[] = {
+    {SOCK_FLOAT, N_("Result")},
+    {SOCK_INT, N_("Result")},
+    {SOCK_BOOLEAN, N_("Result")},
+    {SOCK_VECTOR, N_("Result")},
+    {SOCK_STRING, N_("Result")},
+    {SOCK_RGBA, N_("Result")},
+    {SOCK_OBJECT, N_("Result")},
+    {SOCK_IMAGE, N_("Result")},
+    {SOCK_SURFACE_HOOK, N_("Result")},
+    {-1, ""},
+};
+
+static void 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list