utility to allocate attributes from array allocator
This commit is contained in:
@@ -47,6 +47,18 @@ AttributeArraysCore AttributeArraysCore::NewWithSeparateAllocations(AttributesIn
|
||||
return AttributeArraysCore(info, arrays, size);
|
||||
}
|
||||
|
||||
AttributeArraysCore AttributeArraysCore::NewWithArrayAllocator(AttributesInfo &info,
|
||||
FixedArrayAllocator &allocator)
|
||||
{
|
||||
SmallVector<void *> arrays;
|
||||
for (AttributeType type : info.types()) {
|
||||
uint element_size = size_of_attribute_type(type);
|
||||
void *ptr = allocator.allocate_array(element_size);
|
||||
arrays.append(ptr);
|
||||
}
|
||||
return AttributeArraysCore(info, arrays, allocator.array_size());
|
||||
}
|
||||
|
||||
void AttributeArraysCore::free_buffers()
|
||||
{
|
||||
for (void *ptr : m_arrays) {
|
||||
|
@@ -8,10 +8,12 @@
|
||||
#include "BLI_string_ref.hpp"
|
||||
#include "BLI_range.hpp"
|
||||
#include "BLI_small_set_vector.hpp"
|
||||
#include "BLI_fixed_array_allocator.hpp"
|
||||
|
||||
namespace BParticles {
|
||||
|
||||
using BLI::ArrayRef;
|
||||
using BLI::FixedArrayAllocator;
|
||||
using BLI::float3;
|
||||
using BLI::Range;
|
||||
using BLI::SmallSetVector;
|
||||
@@ -145,6 +147,8 @@ class AttributeArraysCore {
|
||||
~AttributeArraysCore();
|
||||
|
||||
static AttributeArraysCore NewWithSeparateAllocations(AttributesInfo &info, uint size);
|
||||
static AttributeArraysCore NewWithArrayAllocator(AttributesInfo &info,
|
||||
FixedArrayAllocator &allocator);
|
||||
void free_buffers();
|
||||
|
||||
AttributesInfo &info();
|
||||
|
Reference in New Issue
Block a user