[Bf-blender-cvs] [c15103f454e] functions: steps towards a second list type
Jacques Lucke
noreply at git.blender.org
Mon Mar 11 17:58:45 CET 2019
Commit: c15103f454ef799a6c6be586be4b6123a9e513f2
Author: Jacques Lucke
Date: Mon Mar 11 17:58:36 2019 +0100
Branches: functions
https://developer.blender.org/rBc15103f454ef799a6c6be586be4b6123a9e513f2
steps towards a second list type
===================================================================
M release/scripts/startup/function_nodes/sockets.py
M source/blender/functions/functions/lists.cpp
M source/blender/functions/functions/lists.hpp
M source/blender/functions/types/numeric_lists.cpp
M source/blender/functions/types/numeric_lists.hpp
===================================================================
diff --git a/release/scripts/startup/function_nodes/sockets.py b/release/scripts/startup/function_nodes/sockets.py
index d019515b3d0..ade672ea393 100644
--- a/release/scripts/startup/function_nodes/sockets.py
+++ b/release/scripts/startup/function_nodes/sockets.py
@@ -45,4 +45,9 @@ class VectorSocket(bpy.types.NodeSocket, DataSocket):
class FloatListSocket(bpy.types.NodeSocket, DataSocket):
bl_idname = "fn_FloatListSocket"
bl_label = "Float List Socket"
- color = (0, 0.3, 0.5, 0.5)
\ No newline at end of file
+ color = (0, 0.3, 0.5, 0.5)
+
+class VectorListSocket(bpy.types.NodeSocket, DataSocket):
+ bl_idname = "fn_VectorListSocket"
+ bl_label = "Vector List Socket"
+ color = (0, 0, 0.5, 0.5)
\ No newline at end of file
diff --git a/source/blender/functions/functions/lists.cpp b/source/blender/functions/functions/lists.cpp
index 4f13713932c..24f434b6e6a 100644
--- a/source/blender/functions/functions/lists.cpp
+++ b/source/blender/functions/functions/lists.cpp
@@ -22,18 +22,38 @@ namespace FN { namespace Functions {
}
};
- LAZY_INIT_REF__NO_ARG(SharedFunction, append_float)
+ template<typename T>
+ SharedFunction build_append_function(
+ std::string name,
+ SharedType &base_type,
+ SharedType &list_type)
{
- auto fn = SharedFunction::New("Append Float", Signature({
- InputParameter("List", get_float_list_type()),
- InputParameter("Value", get_float_type()),
+ auto fn = SharedFunction::New(name, Signature({
+ InputParameter("List", list_type),
+ InputParameter("Value", base_type),
}, {
- OutputParameter("List", get_float_list_type()),
+ OutputParameter("List", list_type),
}));
- fn->add_body(new AppendToList<float>());
+ fn->add_body(new AppendToList<T>());
return fn;
}
+ LAZY_INIT_REF__NO_ARG(SharedFunction, append_float)
+ {
+ return build_append_function<float>(
+ "Append Float",
+ get_float_type(),
+ get_float_list_type());
+ }
+
+ LAZY_INIT_REF__NO_ARG(SharedFunction, append_fvec3)
+ {
+ return build_append_function<Vector>(
+ "Append Vector",
+ get_fvec3_type(),
+ get_fvec3_list_type());
+ }
+
template<typename T>
class GetListElement : public TupleCallBody {
@@ -54,22 +74,42 @@ namespace FN { namespace Functions {
}
};
- LAZY_INIT_REF__NO_ARG(SharedFunction, get_float_list_element)
+ template<typename T>
+ SharedFunction build_get_element_function(
+ std::string name,
+ SharedType &base_type,
+ SharedType &list_type)
{
- auto fn = SharedFunction::New("Get Float List Element", Signature({
- InputParameter("List", get_float_list_type()),
+ auto fn = SharedFunction::New(name, Signature({
+ InputParameter("List", list_type),
InputParameter("Index", get_int32_type()),
- InputParameter("Fallback", get_float_type()),
+ InputParameter("Fallback", base_type),
}, {
- OutputParameter("Element", get_float_type()),
+ OutputParameter("Element", base_type),
}));
- fn->add_body(new GetListElement<float>());
+ fn->add_body(new GetListElement<T>());
return fn;
}
+ LAZY_INIT_REF__NO_ARG(SharedFunction, get_float_list_element)
+ {
+ return build_get_element_function<float>(
+ "Get Float List Element",
+ get_float_type(),
+ get_float_list_type());
+ }
+
+ LAZY_INIT_REF__NO_ARG(SharedFunction, get_fvec3_list_element)
+ {
+ return build_get_element_function<Vector>(
+ "Get Vector List Element",
+ get_fvec3_type(),
+ get_fvec3_list_type());
+ }
+
template<typename T>
- class CombineList : public TupleCallBody {
+ class CombineLists : public TupleCallBody {
void call(Tuple &fn_in, Tuple &fn_out) const override
{
auto list1 = fn_in.relocate_out<SharedList<T>>(0);
@@ -82,18 +122,33 @@ namespace FN { namespace Functions {
}
};
- LAZY_INIT_REF__NO_ARG(SharedFunction, combine_float_lists)
+ template<typename T>
+ SharedFunction build_combine_lists_function(
+ std::string name,
+ SharedType &list_type)
{
- SharedType &float_list_ty = get_float_list_type();
-
- auto fn = SharedFunction::New("Combine Float Lists", Signature({
- InputParameter("List 1", float_list_ty),
- InputParameter("List 2", float_list_ty),
+ auto fn = SharedFunction::New(name, Signature({
+ InputParameter("List 1", list_type),
+ InputParameter("List 2", list_type),
}, {
- OutputParameter("List", float_list_ty),
+ OutputParameter("List", list_type),
}));
- fn->add_body(new CombineList<float>());
+ fn->add_body(new CombineLists<float>());
return fn;
}
+ LAZY_INIT_REF__NO_ARG(SharedFunction, combine_float_lists)
+ {
+ return build_combine_lists_function<float>(
+ "Combine Float Lists",
+ get_float_list_type());
+ }
+
+ LAZY_INIT_REF__NO_ARG(SharedFunction, combine_fvec3_lists)
+ {
+ return build_combine_lists_function<Vector>(
+ "Combine Vector Lists",
+ get_fvec3_list_type());
+ }
+
} } /* namespace FN::Functions */
\ No newline at end of file
diff --git a/source/blender/functions/functions/lists.hpp b/source/blender/functions/functions/lists.hpp
index af7b80561d0..3f6522b78a6 100644
--- a/source/blender/functions/functions/lists.hpp
+++ b/source/blender/functions/functions/lists.hpp
@@ -8,4 +8,8 @@ namespace FN { namespace Functions {
SharedFunction &get_float_list_element();
SharedFunction &combine_float_lists();
+ SharedFunction &append_fvec3();
+ SharedFunction &get_fvec3_list_element();
+ SharedFunction &combine_fvec3_lists();
+
} } /* namespace FN::Functions */
\ No newline at end of file
diff --git a/source/blender/functions/types/numeric_lists.cpp b/source/blender/functions/types/numeric_lists.cpp
index 336afd4a1c9..b9fad3bd1c3 100644
--- a/source/blender/functions/types/numeric_lists.cpp
+++ b/source/blender/functions/types/numeric_lists.cpp
@@ -86,4 +86,12 @@ namespace FN { namespace Types {
return type;
}
+ LAZY_INIT_REF__NO_ARG(SharedType, get_fvec3_list_type)
+ {
+ SharedType type = SharedType::New("FVec3 List");
+ type->extend(new ListCPPTypeInfo<Vector>());
+ type->extend(ListLLVMTypeInfo<Vector>::Create());
+ return type;
+ }
+
} } /* namespace FN::Types */
\ No newline at end of file
diff --git a/source/blender/functions/types/numeric_lists.hpp b/source/blender/functions/types/numeric_lists.hpp
index 0ba1f085ff7..491171e25e4 100644
--- a/source/blender/functions/types/numeric_lists.hpp
+++ b/source/blender/functions/types/numeric_lists.hpp
@@ -2,11 +2,14 @@
#include "FN_core.hpp"
#include "lists.hpp"
+#include "numeric.hpp"
namespace FN { namespace Types {
using SharedFloatList = SharedList<float>;
+ using SharedFVec3List = SharedList<Vector>;
SharedType &get_float_list_type();
+ SharedType &get_fvec3_list_type();
} } /* namespace FN::Types */
\ No newline at end of file
More information about the Bf-blender-cvs
mailing list