[Bf-blender-cvs] [21414781802] functions: implicit conversions between float and integer lists

Jacques Lucke noreply at git.blender.org
Thu Apr 18 09:42:42 CEST 2019


Commit: 214147818025299bdd70aada0936334305f86cda
Author: Jacques Lucke
Date:   Thu Apr 18 09:42:29 2019 +0200
Branches: functions
https://developer.blender.org/rB214147818025299bdd70aada0936334305f86cda

implicit conversions between float and integer lists

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

M	release/scripts/startup/function_nodes/inferencing.py
M	release/scripts/startup/function_nodes/types.py
M	source/blender/functions/frontends/data_flow_nodes/inserters/conversions.cpp
M	source/blender/functions/functions/simple_conversions.cpp
M	source/blender/functions/functions/simple_conversions.hpp

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

diff --git a/release/scripts/startup/function_nodes/inferencing.py b/release/scripts/startup/function_nodes/inferencing.py
index 9f1aa8896c0..be6903357e9 100644
--- a/release/scripts/startup/function_nodes/inferencing.py
+++ b/release/scripts/startup/function_nodes/inferencing.py
@@ -182,14 +182,15 @@ def iter_obligatory_vector_decisions(graph, input_sockets, output_sockets, tree_
         other_decl = other_socket.get_decl(other_node)
         if data_sockets_are_static(other_decl):
             other_data_type = other_socket.data_type
-            if other_data_type == decl.list_type:
+            if type_infos.is_list(other_data_type) and type_infos.is_link_allowed(other_data_type, decl.list_type):
                 yield decision_id, "LIST"
         elif isinstance(other_decl, ListSocketDecl):
             list_decision_id = DecisionID(other_node, other_node, other_decl.prop_name)
             if list_decision_id in list_decisions:
-                other_base_type = list_decisions[list_decision_id]
-                if other_base_type == decl.base_type:
-                    yield decision_id, other_decl.list_or_base
+                if other_decl.list_or_base == "LIST":
+                    other_base_type = list_decisions[list_decision_id]
+                    if type_infos.is_link_allowed(other_base_type, decl.base_type):
+                        yield decision_id, "LIST"
             else:
                 old_data_type = other_socket.data_type
                 if old_data_type == decl.list_type:
@@ -239,9 +240,9 @@ def make_pack_list_decisions(tree_data, list_decisions, vector_decisions):
         origin_decl = origin_socket.get_decl(origin_node)
         if data_sockets_are_static(origin_decl):
             data_type = origin_socket.data_type
-            if data_type == decl.base_type:
+            if type_infos.is_link_allowed(data_type, decl.base_type):
                 decisions[decision_id] = "BASE"
-            elif data_type == decl.list_type:
+            elif type_infos.is_link_allowed(data_type, decl.list_type):
                 decisions[decision_id] = "LIST"
             else:
                 decisions[decision_id] = "BASE"
@@ -249,19 +250,19 @@ def make_pack_list_decisions(tree_data, list_decisions, vector_decisions):
             list_decision_id = DecisionID(origin_node, origin_node, origin_decl.prop_name)
             if list_decision_id in list_decisions:
                 other_base_type = list_decisions[list_decision_id]
-                if other_base_type == decl.base_type:
+                if type_infos.is_link_allowed(other_base_type, decl.base_type):
                     decisions[decision_id] = origin_decl.list_or_base
                 else:
                     decisions[decision_id] = "BASE"
             else:
                 old_origin_type = origin_socket.data_type
-                if old_origin_type == decl.list_type:
-                    decisions[decision_id] = "LIST"
-                else:
+                if type_infos.is_link_allowed(old_origin_type, decl.base_type):
                     decisions[decision_id] = "BASE"
+                else:
+                    decisions[decision_id] = "LIST"
         elif isinstance(origin_decl, VectorizedOutputDecl):
             other_base_type = origin_decl.base_type
-            if other_base_type == decl.base_type:
+            if type_infos.is_link_allowed(other_base_type, decl.base_type):
                 for input_prop_name in origin_decl.input_prop_names:
                     input_decision_id = DecisionID(origin_node, origin_node, input_prop_name)
                     if input_decision_id in vector_decisions:
diff --git a/release/scripts/startup/function_nodes/types.py b/release/scripts/startup/function_nodes/types.py
index 44270e8f22b..57023833847 100644
--- a/release/scripts/startup/function_nodes/types.py
+++ b/release/scripts/startup/function_nodes/types.py
@@ -27,3 +27,4 @@ type_infos.insert_list_relation("Vector", "Vector List")
 type_infos.insert_list_relation("Integer", "Integer List")
 
 type_infos.insert_implicitly_convertable_types({"Float", "Integer"})
+type_infos.insert_implicitly_convertable_types({"Float List", "Integer List"})
diff --git a/source/blender/functions/frontends/data_flow_nodes/inserters/conversions.cpp b/source/blender/functions/frontends/data_flow_nodes/inserters/conversions.cpp
index 6041d0f9611..50a06290f52 100644
--- a/source/blender/functions/frontends/data_flow_nodes/inserters/conversions.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/inserters/conversions.cpp
@@ -25,6 +25,11 @@ void register_conversion_inserters(GraphInserters &inserters)
   inserters.reg_conversion_inserter("Float", "Float List", INSERT_base_to_list);
   inserters.reg_conversion_inserter("Vector", "Vector List", INSERT_base_to_list);
   inserters.reg_conversion_inserter("Integer", "Integer List", INSERT_base_to_list);
+
+  inserters.reg_conversion_function(
+      "Float List", "Integer List", Functions::GET_FN_float_list_to_int32_list);
+  inserters.reg_conversion_function(
+      "Integer List", "Float List", Functions::GET_FN_int32_list_to_float_list);
 }
 
 }  // namespace DataFlowNodes
diff --git a/source/blender/functions/functions/simple_conversions.cpp b/source/blender/functions/functions/simple_conversions.cpp
index c8b62a586e5..9f79d64d141 100644
--- a/source/blender/functions/functions/simple_conversions.cpp
+++ b/source/blender/functions/functions/simple_conversions.cpp
@@ -1,5 +1,6 @@
 #include "simple_conversions.hpp"
 #include "FN_types.hpp"
+#include "FN_functions.hpp"
 #include "FN_tuple_call.hpp"
 
 #include "BLI_lazy_init.hpp"
@@ -53,5 +54,15 @@ LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_float_to_int32)
   return fn;
 }
 
+LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_int32_list_to_float_list)
+{
+  return to_vectorized_function(GET_FN_int32_to_float(), {true});
+}
+
+LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_float_list_to_int32_list)
+{
+  return to_vectorized_function(GET_FN_float_to_int32(), {true});
+}
+
 }  // namespace Functions
 }  // namespace FN
diff --git a/source/blender/functions/functions/simple_conversions.hpp b/source/blender/functions/functions/simple_conversions.hpp
index d141f06a0d5..5de11f3bbc1 100644
--- a/source/blender/functions/functions/simple_conversions.hpp
+++ b/source/blender/functions/functions/simple_conversions.hpp
@@ -8,5 +8,8 @@ namespace Functions {
 SharedFunction &GET_FN_int32_to_float();
 SharedFunction &GET_FN_float_to_int32();
 
+SharedFunction &GET_FN_float_list_to_int32_list();
+SharedFunction &GET_FN_int32_list_to_float_list();
+
 }  // namespace Functions
 }  // namespace FN



More information about the Bf-blender-cvs mailing list