[Bf-blender-cvs] [71124e192f1] functions: minor changes
Jacques Lucke
noreply at git.blender.org
Tue Dec 17 13:54:03 CET 2019
Commit: 71124e192f15c53545e092d5a3fe8d8b25bc3084
Author: Jacques Lucke
Date: Tue Dec 17 13:27:49 2019 +0100
Branches: functions
https://developer.blender.org/rB71124e192f15c53545e092d5a3fe8d8b25bc3084
minor changes
===================================================================
M source/blender/blenlib/BLI_vector.h
M source/blender/functions/FN_attributes_ref.h
M source/blender/functions/FN_generic_array_ref.h
M source/blender/functions/FN_multi_function.h
===================================================================
diff --git a/source/blender/blenlib/BLI_vector.h b/source/blender/blenlib/BLI_vector.h
index 6d8471245f7..ee32c50a9ac 100644
--- a/source/blender/blenlib/BLI_vector.h
+++ b/source/blender/blenlib/BLI_vector.h
@@ -220,6 +220,11 @@ template<typename T, uint N = 4, typename Allocator = GuardedAllocator> class Ve
return *this;
}
+ MutableArrayRef<T> as_mutable_ref()
+ {
+ return *this;
+ }
+
Vector &operator=(const Vector &other)
{
if (this == &other) {
diff --git a/source/blender/functions/FN_attributes_ref.h b/source/blender/functions/FN_attributes_ref.h
index 8dafe39d0f4..140ec148564 100644
--- a/source/blender/functions/FN_attributes_ref.h
+++ b/source/blender/functions/FN_attributes_ref.h
@@ -290,6 +290,11 @@ class AttributesRefGroup {
Vector<ArrayRef<void *>> buffers,
Vector<IndexRange> ranges);
+ const AttributesInfo &info() const
+ {
+ return *m_info;
+ }
+
template<typename T> void set(uint index, ArrayRef<T> data)
{
BLI_assert(data.size() == m_total_size);
@@ -303,12 +308,25 @@ class AttributesRefGroup {
}
}
- const AttributesInfo &info() const
+ template<typename T> void set(StringRef name, ArrayRef<T> data)
{
- return *m_info;
+ this->set(m_info->index_of(name), data);
}
- template<typename T> void set(StringRef name, ArrayRef<T> data)
+ void set(uint index, GenericArrayRef data)
+ {
+ BLI_assert(data.size() == m_total_size);
+ BLI_assert(m_info->type_of(index) == data.type());
+
+ uint offset = 0;
+ for (AttributesRef attributes : *this) {
+ GenericMutableArrayRef array = attributes.get(index);
+ array.type().copy_to_initialized_n(data[offset], array[0], attributes.size());
+ offset += attributes.size();
+ }
+ }
+
+ void set(StringRef name, GenericArrayRef data)
{
this->set(m_info->index_of(name), data);
}
diff --git a/source/blender/functions/FN_generic_array_ref.h b/source/blender/functions/FN_generic_array_ref.h
index c69cfce8507..54ed98278e1 100644
--- a/source/blender/functions/FN_generic_array_ref.h
+++ b/source/blender/functions/FN_generic_array_ref.h
@@ -28,6 +28,12 @@ class GenericArrayRef {
BLI_assert(type.pointer_has_valid_alignment(buffer));
}
+ template<typename T>
+ GenericArrayRef(ArrayRef<T> array)
+ : GenericArrayRef(CPP_TYPE<T>(), (const void *)array.begin(), array.size())
+ {
+ }
+
const CPPType &type() const
{
return *m_type;
@@ -75,7 +81,7 @@ class GenericMutableArrayRef {
}
template<typename T>
- GenericMutableArrayRef(ArrayRef<T> array)
+ GenericMutableArrayRef(MutableArrayRef<T> array)
: GenericMutableArrayRef(CPP_TYPE<T>(), (void *)array.begin(), array.size())
{
}
diff --git a/source/blender/functions/FN_multi_function.h b/source/blender/functions/FN_multi_function.h
index f2f56fea75a..43e56ddd625 100644
--- a/source/blender/functions/FN_multi_function.h
+++ b/source/blender/functions/FN_multi_function.h
@@ -253,7 +253,7 @@ class MFParamsBuilder {
m_virtual_list_list_refs.append(list);
}
- template<typename T> void add_single_output(ArrayRef<T> array)
+ template<typename T> void add_single_output(MutableArrayRef<T> array)
{
BLI_assert(array.size() >= m_min_array_size);
this->add_single_output(GenericMutableArrayRef(array));
More information about the Bf-blender-cvs
mailing list