[Bf-blender-cvs] [686fa5ca845] functions: utility to allocate attributes from array allocator
Jacques Lucke
noreply at git.blender.org
Sun Jun 30 16:00:53 CEST 2019
Commit: 686fa5ca8457260269558c0695c75a97fcad78b9
Author: Jacques Lucke
Date: Sun Jun 30 11:12:02 2019 +0200
Branches: functions
https://developer.blender.org/rB686fa5ca8457260269558c0695c75a97fcad78b9
utility to allocate attributes from array allocator
===================================================================
M source/blender/simulations/bparticles/attributes.cpp
M source/blender/simulations/bparticles/attributes.hpp
===================================================================
diff --git a/source/blender/simulations/bparticles/attributes.cpp b/source/blender/simulations/bparticles/attributes.cpp
index 229ca4585c4..f51b32fcc4f 100644
--- a/source/blender/simulations/bparticles/attributes.cpp
+++ b/source/blender/simulations/bparticles/attributes.cpp
@@ -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) {
diff --git a/source/blender/simulations/bparticles/attributes.hpp b/source/blender/simulations/bparticles/attributes.hpp
index 85f36e1c0b8..b3750a3e18b 100644
--- a/source/blender/simulations/bparticles/attributes.hpp
+++ b/source/blender/simulations/bparticles/attributes.hpp
@@ -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();
More information about the Bf-blender-cvs
mailing list