[Bf-blender-cvs] [0cda96f1bee] functions: initial particle set

Jacques Lucke noreply at git.blender.org
Thu Jan 2 16:37:42 CET 2020


Commit: 0cda96f1bee70acde714849fd2c28a71a34ef9fa
Author: Jacques Lucke
Date:   Tue Dec 31 14:41:13 2019 +0100
Branches: functions
https://developer.blender.org/rB0cda96f1bee70acde714849fd2c28a71a34ef9fa

initial particle set

===================================================================

A	source/blender/simulations/bparticles/particle_set.cpp
A	source/blender/simulations/bparticles/particle_set.hpp

===================================================================

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



More information about the Bf-blender-cvs mailing list