Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-12-03 18:20:09 +0300
committerJacques Lucke <jacques@blender.org>2020-12-03 18:20:09 +0300
commit2c181521ec0c4e0fca579fb512801410570800fb (patch)
tree83828b66f9ce5049ad5cb5b105df8a9fe20e4ff8 /source/blender/blenkernel/BKE_attribute_access.hh
parent675d84826e596d09b6ddba06915c949da61f087f (diff)
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.
Diffstat (limited to 'source/blender/blenkernel/BKE_attribute_access.hh')
-rw-r--r--source/blender/blenkernel/BKE_attribute_access.hh25
1 files changed, 23 insertions, 2 deletions
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_;