From 8c96ee8903e0840816e340fcf29fe0606e19821b Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 16 Feb 2022 14:10:21 -0600 Subject: Cleanup: Deduplicate functions for creating attributes --- source/blender/blenkernel/intern/attribute_access_intern.hh | 10 ++++++++++ .../blenkernel/intern/geometry_component_instances.cc | 12 ------------ source/blender/blenkernel/intern/geometry_component_mesh.cc | 12 ------------ .../blenkernel/intern/geometry_component_pointcloud.cc | 12 ------------ 4 files changed, 10 insertions(+), 36 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/attribute_access_intern.hh b/source/blender/blenkernel/intern/attribute_access_intern.hh index 4eff878778a..bfc4c8fcde0 100644 --- a/source/blender/blenkernel/intern/attribute_access_intern.hh +++ b/source/blender/blenkernel/intern/attribute_access_intern.hh @@ -207,6 +207,16 @@ class NamedLegacyCustomDataProvider final : public DynamicAttributesProvider { void foreach_domain(const FunctionRef callback) const final; }; +template GVArray make_array_read_attribute(const void *data, const int domain_size) +{ + return VArray::ForSpan(Span((const T *)data, domain_size)); +} + +template GVMutableArray make_array_write_attribute(void *data, const int domain_size) +{ + return VMutableArray::ForSpan(MutableSpan((T *)data, domain_size)); +} + /** * This provider is used to provide access to builtin attributes. It supports making internal types * available as different types. For example, the vertex position attribute is stored as part of diff --git a/source/blender/blenkernel/intern/geometry_component_instances.cc b/source/blender/blenkernel/intern/geometry_component_instances.cc index b83a8b1ee94..0cb2b0e812b 100644 --- a/source/blender/blenkernel/intern/geometry_component_instances.cc +++ b/source/blender/blenkernel/intern/geometry_component_instances.cc @@ -439,18 +439,6 @@ class InstancePositionAttributeProvider final : public BuiltinAttributeProvider } }; -template -static GVArray make_array_read_attribute(const void *data, const int domain_size) -{ - return VArray::ForSpan(Span((const T *)data, domain_size)); -} - -template -static GVMutableArray make_array_write_attribute(void *data, const int domain_size) -{ - return VMutableArray::ForSpan(MutableSpan((T *)data, domain_size)); -} - static ComponentAttributeProviders create_attribute_providers_for_instances() { static InstancePositionAttributeProvider position; diff --git a/source/blender/blenkernel/intern/geometry_component_mesh.cc b/source/blender/blenkernel/intern/geometry_component_mesh.cc index 2f8ff944420..104166df913 100644 --- a/source/blender/blenkernel/intern/geometry_component_mesh.cc +++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc @@ -854,18 +854,6 @@ static GVMutableArray make_derived_write_attribute(void *data, const int domain_ MutableSpan((StructT *)data, domain_size)); } -template -static GVArray make_array_read_attribute(const void *data, const int domain_size) -{ - return VArray::ForSpan(Span((const T *)data, domain_size)); -} - -template -static GVMutableArray make_array_write_attribute(void *data, const int domain_size) -{ - return VMutableArray::ForSpan(MutableSpan((T *)data, domain_size)); -} - static float3 get_vertex_position(const MVert &vert) { return float3(vert.co); diff --git a/source/blender/blenkernel/intern/geometry_component_pointcloud.cc b/source/blender/blenkernel/intern/geometry_component_pointcloud.cc index f6f3c4e1b4e..3db4db307a3 100644 --- a/source/blender/blenkernel/intern/geometry_component_pointcloud.cc +++ b/source/blender/blenkernel/intern/geometry_component_pointcloud.cc @@ -117,18 +117,6 @@ int PointCloudComponent::attribute_domain_size(const AttributeDomain domain) con namespace blender::bke { -template -static GVArray make_array_read_attribute(const void *data, const int domain_size) -{ - return VArray::ForSpan(Span((const T *)data, domain_size)); -} - -template -static GVMutableArray make_array_write_attribute(void *data, const int domain_size) -{ - return VMutableArray::ForSpan(MutableSpan((T *)data, domain_size)); -} - /** * In this function all the attribute providers for a point cloud component are created. Most data * in this function is statically allocated, because it does not change over time. -- cgit v1.2.3