Cleanup: Deduplicate functions for creating attributes
This commit is contained in:
parent
6862caea5e
commit
8c96ee8903
|
@ -207,6 +207,16 @@ class NamedLegacyCustomDataProvider final : public DynamicAttributesProvider {
|
|||
void foreach_domain(const FunctionRef<void(AttributeDomain)> callback) const final;
|
||||
};
|
||||
|
||||
template<typename T> GVArray make_array_read_attribute(const void *data, const int domain_size)
|
||||
{
|
||||
return VArray<T>::ForSpan(Span<T>((const T *)data, domain_size));
|
||||
}
|
||||
|
||||
template<typename T> GVMutableArray make_array_write_attribute(void *data, const int domain_size)
|
||||
{
|
||||
return VMutableArray<T>::ForSpan(MutableSpan<T>((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
|
||||
|
|
|
@ -439,18 +439,6 @@ class InstancePositionAttributeProvider final : public BuiltinAttributeProvider
|
|||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
static GVArray make_array_read_attribute(const void *data, const int domain_size)
|
||||
{
|
||||
return VArray<T>::ForSpan(Span<T>((const T *)data, domain_size));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static GVMutableArray make_array_write_attribute(void *data, const int domain_size)
|
||||
{
|
||||
return VMutableArray<T>::ForSpan(MutableSpan<T>((T *)data, domain_size));
|
||||
}
|
||||
|
||||
static ComponentAttributeProviders create_attribute_providers_for_instances()
|
||||
{
|
||||
static InstancePositionAttributeProvider position;
|
||||
|
|
|
@ -854,18 +854,6 @@ static GVMutableArray make_derived_write_attribute(void *data, const int domain_
|
|||
MutableSpan<StructT>((StructT *)data, domain_size));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static GVArray make_array_read_attribute(const void *data, const int domain_size)
|
||||
{
|
||||
return VArray<T>::ForSpan(Span<T>((const T *)data, domain_size));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static GVMutableArray make_array_write_attribute(void *data, const int domain_size)
|
||||
{
|
||||
return VMutableArray<T>::ForSpan(MutableSpan<T>((T *)data, domain_size));
|
||||
}
|
||||
|
||||
static float3 get_vertex_position(const MVert &vert)
|
||||
{
|
||||
return float3(vert.co);
|
||||
|
|
|
@ -117,18 +117,6 @@ int PointCloudComponent::attribute_domain_size(const AttributeDomain domain) con
|
|||
|
||||
namespace blender::bke {
|
||||
|
||||
template<typename T>
|
||||
static GVArray make_array_read_attribute(const void *data, const int domain_size)
|
||||
{
|
||||
return VArray<T>::ForSpan(Span<T>((const T *)data, domain_size));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static GVMutableArray make_array_write_attribute(void *data, const int domain_size)
|
||||
{
|
||||
return VMutableArray<T>::ForSpan(MutableSpan<T>((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.
|
||||
|
|
Loading…
Reference in New Issue