[Bf-blender-cvs] [b9cbf7fc806] master: Geometry Nodes: add utility to convert CPPType to static type
Jacques Lucke
noreply at git.blender.org
Wed Apr 21 17:11:19 CEST 2021
Commit: b9cbf7fc8067cea725f7c6c410ce626f08bf85f7
Author: Jacques Lucke
Date: Wed Apr 21 16:57:43 2021 +0200
Branches: master
https://developer.blender.org/rBb9cbf7fc8067cea725f7c6c410ce626f08bf85f7
Geometry Nodes: add utility to convert CPPType to static type
===================================================================
M 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<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.
*
More information about the Bf-blender-cvs
mailing list