[Bf-blender-cvs] [2d73ff23806] functions: rename buffer accessors

Jacques Lucke noreply at git.blender.org
Mon Jun 10 12:05:41 CEST 2019


Commit: 2d73ff238063cd9c5b47e3342829fd6f8696f98c
Author: Jacques Lucke
Date:   Mon Jun 10 11:07:40 2019 +0200
Branches: functions
https://developer.blender.org/rB2d73ff238063cd9c5b47e3342829fd6f8696f98c

rename buffer accessors

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

M	source/blender/simulations/bparticles/c_wrapper.cpp
M	source/blender/simulations/bparticles/core.hpp
M	source/blender/simulations/bparticles/particles_container.hpp
M	source/blender/simulations/bparticles/playground_solver.cpp

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

diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp b/source/blender/simulations/bparticles/c_wrapper.cpp
index 1041b35c38a..335b1ccd4ca 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -60,7 +60,7 @@ class TurbulenceForce : public BParticles::Force {
 
   void add_force(NamedBuffers &buffers, ArrayRef<float3> dst) override
   {
-    auto positions = buffers.float3_buffer("Position");
+    auto positions = buffers.get_float3("Position");
     for (uint i = 0; i < dst.size(); i++) {
       float3 pos = positions[i];
       float value = BLI_hnoise(0.5f, pos.x, pos.y, pos.z);
@@ -82,8 +82,8 @@ class TestEmitter : public BParticles::Emitter {
     EmitterBuffers &dst = request_buffers();
     BLI_assert(dst.size() > 0);
 
-    auto positions = dst.float3_buffer("Position");
-    auto velocities = dst.float3_buffer("Velocity");
+    auto positions = dst.buffers().get_float3("Position");
+    auto velocities = dst.buffers().get_float3("Velocity");
 
     for (uint i = 0; i < dst.size(); i++) {
       positions[i] = {(float)(rand() % 10000) / 3000.0f, 0, 1};
diff --git a/source/blender/simulations/bparticles/core.hpp b/source/blender/simulations/bparticles/core.hpp
index a1d59076514..7ddb83a4c9d 100644
--- a/source/blender/simulations/bparticles/core.hpp
+++ b/source/blender/simulations/bparticles/core.hpp
@@ -29,9 +29,9 @@ class NamedBuffers {
  public:
   virtual ~NamedBuffers();
   virtual uint size() = 0;
-  virtual ArrayRef<float> float_buffer(StringRef name) = 0;
-  virtual ArrayRef<float3> float3_buffer(StringRef name) = 0;
-  virtual ArrayRef<uint8_t> byte_buffer(StringRef name) = 0;
+  virtual ArrayRef<float> get_float(StringRef name) = 0;
+  virtual ArrayRef<float3> get_float3(StringRef name) = 0;
+  virtual ArrayRef<uint8_t> get_byte(StringRef name) = 0;
 };
 
 class Force {
@@ -61,19 +61,9 @@ class EmitterBuffers {
     return m_emitted_amount;
   }
 
-  ArrayRef<float> float_buffer(StringRef name)
+  NamedBuffers &buffers()
   {
-    return m_buffers.float_buffer(name);
-  }
-
-  ArrayRef<float3> float3_buffer(StringRef name)
-  {
-    return m_buffers.float3_buffer(name);
-  }
-
-  ArrayRef<uint8_t> byte_buffer(StringRef name)
-  {
-    return m_buffers.byte_buffer(name);
+    return m_buffers;
   }
 
   uint size()
diff --git a/source/blender/simulations/bparticles/particles_container.hpp b/source/blender/simulations/bparticles/particles_container.hpp
index 7bb3647fe8e..2f9e0668e84 100644
--- a/source/blender/simulations/bparticles/particles_container.hpp
+++ b/source/blender/simulations/bparticles/particles_container.hpp
@@ -65,9 +65,9 @@ class ParticlesBlockSlice : public NamedBuffers {
   ParticlesBlock *block();
   uint size() override;
 
-  ArrayRef<float> float_buffer(StringRef name) override;
-  ArrayRef<float3> float3_buffer(StringRef name) override;
-  ArrayRef<uint8_t> byte_buffer(StringRef name) override;
+  ArrayRef<float> get_float(StringRef name) override;
+  ArrayRef<float3> get_float3(StringRef name) override;
+  ArrayRef<uint8_t> get_byte(StringRef name) override;
 
   ParticlesBlockSlice take_front(uint n);
 };
@@ -278,17 +278,17 @@ inline uint ParticlesBlockSlice::size()
   return m_length;
 }
 
-inline ArrayRef<float> ParticlesBlockSlice::float_buffer(StringRef name)
+inline ArrayRef<float> ParticlesBlockSlice::get_float(StringRef name)
 {
   return ArrayRef<float>(m_block->float_buffer(name) + m_start, m_length);
 }
 
-inline ArrayRef<float3> ParticlesBlockSlice::float3_buffer(StringRef name)
+inline ArrayRef<float3> ParticlesBlockSlice::get_float3(StringRef name)
 {
   return ArrayRef<float3>(m_block->float3_buffer(name) + m_start, m_length);
 }
 
-inline ArrayRef<uint8_t> ParticlesBlockSlice::byte_buffer(StringRef name)
+inline ArrayRef<uint8_t> ParticlesBlockSlice::get_byte(StringRef name)
 {
   return ArrayRef<uint8_t>(m_block->byte_buffer(name) + m_start, m_length);
 }
diff --git a/source/blender/simulations/bparticles/playground_solver.cpp b/source/blender/simulations/bparticles/playground_solver.cpp
index aa14f97caa5..f83f597deca 100644
--- a/source/blender/simulations/bparticles/playground_solver.cpp
+++ b/source/blender/simulations/bparticles/playground_solver.cpp
@@ -50,9 +50,9 @@ class SimpleSolver : public Solver {
 
   BLI_NOINLINE void step_new_particles(ParticlesBlockSlice slice, MyState &state)
   {
-    auto positions = slice.float3_buffer("Position");
-    auto velocities = slice.float3_buffer("Velocity");
-    auto birth_times = slice.float_buffer("Birth Time");
+    auto positions = slice.get_float3("Position");
+    auto velocities = slice.get_float3("Velocity");
+    auto birth_times = slice.get_float("Birth Time");
 
     SmallVector<float3> combined_force(slice.size());
     this->compute_combined_force(slice, combined_force);
@@ -66,8 +66,8 @@ class SimpleSolver : public Solver {
 
   BLI_NOINLINE void step_slice(MyState &state, ParticlesBlockSlice slice, float elapsed_seconds)
   {
-    auto positions = slice.float3_buffer("Position");
-    auto velocities = slice.float3_buffer("Velocity");
+    auto positions = slice.get_float3("Position");
+    auto velocities = slice.get_float3("Velocity");
 
     SmallVector<float3> combined_force(slice.size());
     this->compute_combined_force(slice, combined_force);
@@ -77,8 +77,8 @@ class SimpleSolver : public Solver {
       velocities[i] += combined_force[i] * elapsed_seconds;
     }
 
-    auto birth_times = slice.float_buffer("Birth Time");
-    auto kill_states = slice.byte_buffer("Kill State");
+    auto birth_times = slice.get_float("Birth Time");
+    auto kill_states = slice.get_byte("Kill State");
 
     for (uint i = 0; i < slice.size(); i++) {
       float age = state.seconds_since_start - birth_times[i];
@@ -145,16 +145,16 @@ class SimpleSolver : public Solver {
 
       for (auto &name : state.particles->float_attribute_names()) {
         if (!emitter.uses_float_attribute(name)) {
-          emitted_data.float_buffer(name).fill(0);
+          emitted_data.get_float(name).fill(0);
         }
       }
       for (auto &name : state.particles->vec3_attribute_names()) {
         if (!emitter.uses_vec3_attribute(name)) {
-          emitted_data.float3_buffer(name).fill(float3{0, 0, 0});
+          emitted_data.get_float3(name).fill(float3{0, 0, 0});
         }
       }
 
-      auto birth_times = emitted_data.float_buffer("Birth Time");
+      auto birth_times = emitted_data.get_float("Birth Time");
       for (float &birth_time : birth_times) {
         float fac = (rand() % 1000) / 1000.0f;
         birth_time = state.seconds_since_start - elapsed_seconds * fac;



More information about the Bf-blender-cvs mailing list