utility to allocate attributes from array allocator

This commit is contained in:
2019-06-30 11:12:02 +02:00
parent 0fd83de6c3
commit 686fa5ca84
2 changed files with 16 additions and 0 deletions

View File

@@ -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) {

View File

@@ -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();