From b9cbf7fc8067cea725f7c6c410ce626f08bf85f7 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 21 Apr 2021 16:57:43 +0200 Subject: Geometry Nodes: add utility to convert CPPType to static type --- source/blender/blenkernel/BKE_attribute_math.hh | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'source/blender/blenkernel/BKE_attribute_math.hh') 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 void convert_to_static_type(const fn::CPPType &cpp_type, const Func &func) +{ + if (cpp_type.is()) { + func(float()); + } + else if (cpp_type.is()) { + func(float2()); + } + else if (cpp_type.is()) { + func(float3()); + } + else if (cpp_type.is()) { + func(int()); + } + else if (cpp_type.is()) { + func(bool()); + } + else if (cpp_type.is()) { + func(Color4f()); + } + else { + BLI_assert_unreachable(); + } +} + /* -------------------------------------------------------------------- */ /** \name Mix three values of the same type. * -- cgit v1.2.3