[Bf-blender-cvs] [92518a7057a] temp-geometry-nodes-expandable-geometry-socket-prototype: initial array cpp type

Jacques Lucke noreply at git.blender.org
Mon Aug 2 13:44:14 CEST 2021


Commit: 92518a7057a596c5f651a719a2e2bc0eab3c8147
Author: Jacques Lucke
Date:   Mon Aug 2 13:29:18 2021 +0200
Branches: temp-geometry-nodes-expandable-geometry-socket-prototype
https://developer.blender.org/rB92518a7057a596c5f651a719a2e2bc0eab3c8147

initial array cpp type

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

A	source/blender/functions/FN_array_cpp_type.hh
M	source/blender/nodes/intern/node_socket.cc

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

diff --git a/source/blender/functions/FN_array_cpp_type.hh b/source/blender/functions/FN_array_cpp_type.hh
new file mode 100644
index 00000000000..181ea543a70
--- /dev/null
+++ b/source/blender/functions/FN_array_cpp_type.hh
@@ -0,0 +1,52 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#pragma once
+
+#include "BLI_array.hh"
+
+#include "FN_cpp_type.hh"
+
+namespace blender::fn {
+
+template<typename T> struct ArrayCPPTypeParam {
+};
+
+class ArrayCPPType : public CPPType {
+ private:
+  const CPPType &element_type_;
+
+ public:
+  template<typename ElementT, int64_t InlineBufferCapacity, typename Allocator>
+  ArrayCPPType(ArrayCPPTypeParam<Array<ElementT, InlineBufferCapacity, Allocator>> /* unused */,
+               StringRef debug_name)
+      : CPPType(
+            CPPTypeParam<Array<ElementT, InlineBufferCapacity, Allocator>, CPPTypeFlags::None>(),
+            debug_name),
+        element_type_(CPPType::get<ElementT>())
+  {
+  }
+};
+
+}  // namespace blender::fn
+
+#define MAKE_ARRAY_CPP_TYPE(IDENTIFIER, TYPE_NAME) \
+  template<> const blender::fn::CPPType &blender::fn::CPPType::get_impl<TYPE_NAME>() \
+  { \
+    static blender::fn::ArrayCPPType cpp_type{blender::fn::ArrayCPPTypeParam<TYPE_NAME>(), \
+                                              STRINGIFY(IDENTIFIER)}; \
+    return cpp_type; \
+  }
diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc
index 4be3fd2468b..8f4cec37f0e 100644
--- a/source/blender/nodes/intern/node_socket.cc
+++ b/source/blender/nodes/intern/node_socket.cc
@@ -47,6 +47,7 @@
 #include "NOD_node_tree_multi_function.hh"
 #include "NOD_socket.h"
 
+#include "FN_array_cpp_type.hh"
 #include "FN_cpp_type_make.hh"
 
 struct bNodeSocket *node_add_socket_from_template(struct bNodeTree *ntree,
@@ -678,6 +679,12 @@ static bNodeSocketType *make_socket_type_string()
   return socktype;
 }
 
+MAKE_ARRAY_CPP_TYPE(IntArray, blender::Array<int>)
+MAKE_ARRAY_CPP_TYPE(FloatArray, blender::Array<float>)
+MAKE_ARRAY_CPP_TYPE(Float3Array, blender::Array<blender::float3>)
+MAKE_ARRAY_CPP_TYPE(BoolArray, blender::Array<bool>)
+MAKE_ARRAY_CPP_TYPE(ColorArray, blender::Array<blender::ColorGeometry4f>)
+
 MAKE_CPP_TYPE(Object, Object *, CPPTypeFlags::BasicType)
 MAKE_CPP_TYPE(Collection, Collection *, CPPTypeFlags::BasicType)
 MAKE_CPP_TYPE(Texture, Tex *, CPPTypeFlags::BasicType)



More information about the Bf-blender-cvs mailing list