Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2019-12-31 16:41:13 +0300
committerJacques Lucke <mail@jlucke.com>2019-12-31 16:59:58 +0300
commit0cda96f1bee70acde714849fd2c28a71a34ef9fa (patch)
treecde5e827d6211e34c864baac5f944a107535a9e5 /source/blender/simulations
parentc2d3708224c1df8976f8a54ad80e9bce62f8839c (diff)
initial particle set
Diffstat (limited to 'source/blender/simulations')
-rw-r--r--source/blender/simulations/bparticles/particle_set.cpp35
-rw-r--r--source/blender/simulations/bparticles/particle_set.hpp50
2 files changed, 85 insertions, 0 deletions
diff --git a/source/blender/simulations/bparticles/particle_set.cpp b/source/blender/simulations/bparticles/particle_set.cpp
new file mode 100644
index 00000000000..f2f60994581
--- /dev/null
+++ b/source/blender/simulations/bparticles/particle_set.cpp
@@ -0,0 +1,35 @@
+#include "particle_set.hpp"
+
+namespace BParticles {
+
+ParticleSet::ParticleSet(const AttributesInfoBuilder &attributes_info_builder, uint size)
+ : m_attributes_info(BLI::make_unique<AttributesInfo>(attributes_info_builder)),
+ m_size(size),
+ m_capacity(size)
+{
+}
+
+void ParticleSet::update_attributes(const AttributesInfoBuilder &new_attributes_info_builder)
+{
+ auto new_attributes_info = BLI::make_unique<AttributesInfo>(new_attributes_info_builder);
+ FN::AttributesInfoDiff diff{*m_attributes_info, *new_attributes_info};
+
+ Vector<void *> new_buffers(diff.new_buffer_amount());
+ diff.update(m_capacity, m_size, m_attribute_buffers, new_buffers);
+
+ m_attribute_buffers = std::move(new_buffers);
+ m_attributes_info = std::move(new_attributes_info);
+}
+
+void ParticleSet::destruct_and_reorder(IndexMask indices_to_destruct)
+{
+ this->attributes().destruct_and_reorder(indices_to_destruct);
+ m_size = m_size - indices_to_destruct.size();
+}
+
+void ParticleSet::add_particles(ParticleSet &particles)
+{
+ /* TODO */
+}
+
+} // namespace BParticles
diff --git a/source/blender/simulations/bparticles/particle_set.hpp b/source/blender/simulations/bparticles/particle_set.hpp
new file mode 100644
index 00000000000..4e1e8e675ac
--- /dev/null
+++ b/source/blender/simulations/bparticles/particle_set.hpp
@@ -0,0 +1,50 @@
+#pragma once
+
+#include "FN_attributes_ref.h"
+
+namespace BParticles {
+
+using BLI::IndexMask;
+using BLI::Vector;
+using FN::AttributesInfo;
+using FN::AttributesInfoBuilder;
+using FN::AttributesRef;
+
+class ParticleSet {
+ private:
+ std::unique_ptr<AttributesInfo> m_attributes_info;
+ Vector<void *> m_attribute_buffers;
+ uint m_size;
+ uint m_capacity;
+
+ public:
+ ParticleSet(const AttributesInfoBuilder &attributes_info_builder, uint size);
+ ~ParticleSet();
+
+ const AttributesInfo &attributes_info() const
+ {
+ return *m_attributes_info;
+ }
+
+ AttributesRef attributes()
+ {
+ return AttributesRef(*m_attributes_info, m_attribute_buffers, m_size);
+ }
+
+ uint size() const
+ {
+ return m_size;
+ }
+
+ void add_particles(ParticleSet &particles);
+
+ void update_attributes(const AttributesInfoBuilder &new_attributes_info_builder);
+ void destruct_and_reorder(IndexMask indices_to_destruct);
+
+ friend bool operator==(const ParticleSet &a, const ParticleSet &b)
+ {
+ return &a == &b;
+ }
+};
+
+} // namespace BParticles