diff options
author | Jacques Lucke <jacques@blender.org> | 2021-04-21 17:57:43 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-04-21 17:57:43 +0300 |
commit | b9cbf7fc8067cea725f7c6c410ce626f08bf85f7 (patch) | |
tree | ec8b72d1714c8e585a12c755c9fe84551c9ecfe6 /source/blender/blenkernel | |
parent | 9fa9854e2a4f47ff991b8f4bf6d915131436ee3b (diff) |
Geometry Nodes: add utility to convert CPPType to static type
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_attribute_math.hh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_attribute_math.hh b/source/blender/blenkernel/BKE_attribute_math.hh index 16fc0db60fb..5f3a8a3556a 100644 --- a/source/blender/blenkernel/BKE_attribute_math.hh +++ b/source/blender/blenkernel/BKE_attribute_math.hh @@ -21,8 +21,12 @@ #include "DNA_customdata_types.h" +#include "FN_cpp_type.hh" + namespace blender::attribute_math { +using fn::CPPType; + /** * Utility function that simplifies calling a templated function based on a custom data type. */ @@ -54,6 +58,31 @@ void convert_to_static_type(const CustomDataType data_type, const Func &func) } } +template<typename Func> void convert_to_static_type(const fn::CPPType &cpp_type, const Func &func) +{ + if (cpp_type.is<float>()) { + func(float()); + } + else if (cpp_type.is<float2>()) { + func(float2()); + } + else if (cpp_type.is<float3>()) { + func(float3()); + } + else if (cpp_type.is<int>()) { + func(int()); + } + else if (cpp_type.is<bool>()) { + func(bool()); + } + else if (cpp_type.is<Color4f>()) { + func(Color4f()); + } + else { + BLI_assert_unreachable(); + } +} + /* -------------------------------------------------------------------- */ /** \name Mix three values of the same type. * |