[Bf-blender-cvs] [2c181521ec0] master: Geometry Nodes: add custom data type getter for attribute accessor

Jacques Lucke noreply at git.blender.org
Thu Dec 3 16:26:22 CET 2020


Commit: 2c181521ec0c4e0fca579fb512801410570800fb
Author: Jacques Lucke
Date:   Thu Dec 3 16:20:09 2020 +0100
Branches: master
https://developer.blender.org/rB2c181521ec0c4e0fca579fb512801410570800fb

Geometry Nodes: add custom data type getter for attribute accessor

This is just an utility method, that avoids that the caller has to do
the conversion every time it is necessary.

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

M	source/blender/blenkernel/BKE_attribute_access.hh

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

diff --git a/source/blender/blenkernel/BKE_attribute_access.hh b/source/blender/blenkernel/BKE_attribute_access.hh
index e58fba36342..f5ee2cf2bf5 100644
--- a/source/blender/blenkernel/BKE_attribute_access.hh
+++ b/source/blender/blenkernel/BKE_attribute_access.hh
@@ -31,6 +31,9 @@ namespace blender::bke {
 
 using fn::CPPType;
 
+const CPPType *custom_data_type_to_cpp_type(const CustomDataType type);
+CustomDataType cpp_type_to_custom_data_type(const CPPType &type);
+
 /**
  * This class offers an indirection for reading an attribute.
  * This is useful for the following reasons:
@@ -47,6 +50,7 @@ class ReadAttribute {
  protected:
   const AttributeDomain domain_;
   const CPPType &cpp_type_;
+  const CustomDataType custom_data_type_;
   const int64_t size_;
 
   /* Protects the span below, so that no two threads initialize it at the same time. */
@@ -59,7 +63,10 @@ class ReadAttribute {
 
  public:
   ReadAttribute(AttributeDomain domain, const CPPType &cpp_type, const int64_t size)
-      : domain_(domain), cpp_type_(cpp_type), size_(size)
+      : domain_(domain),
+        cpp_type_(cpp_type),
+        custom_data_type_(cpp_type_to_custom_data_type(cpp_type)),
+        size_(size)
   {
   }
 
@@ -75,6 +82,11 @@ class ReadAttribute {
     return cpp_type_;
   }
 
+  CustomDataType custom_data_type() const
+  {
+    return custom_data_type_;
+  }
+
   int64_t size() const
   {
     return size_;
@@ -104,6 +116,7 @@ class WriteAttribute {
  protected:
   const AttributeDomain domain_;
   const CPPType &cpp_type_;
+  const CustomDataType custom_data_type_;
   const int64_t size_;
 
   /* When not null, this points either to the attribute array or to a temporary array. */
@@ -115,7 +128,10 @@ class WriteAttribute {
 
  public:
   WriteAttribute(AttributeDomain domain, const CPPType &cpp_type, const int64_t size)
-      : domain_(domain), cpp_type_(cpp_type), size_(size)
+      : domain_(domain),
+        cpp_type_(cpp_type),
+        custom_data_type_(cpp_type_to_custom_data_type(cpp_type)),
+        size_(size)
   {
   }
 
@@ -131,6 +147,11 @@ class WriteAttribute {
     return cpp_type_;
   }
 
+  CustomDataType custom_data_type() const
+  {
+    return custom_data_type_;
+  }
+
   int64_t size() const
   {
     return size_;



More information about the Bf-blender-cvs mailing list