[Bf-blender-cvs] [c49ca5c99f1] functions: rename Vec3 to float3

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


Commit: c49ca5c99f13015d8113850bb90d3efd7dec688a
Author: Jacques Lucke
Date:   Mon Jun 10 10:53:36 2019 +0200
Branches: functions
https://developer.blender.org/rBc49ca5c99f13015d8113850bb90d3efd7dec688a

rename Vec3 to float3

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

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

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

diff --git a/source/blender/blenlib/BLI_math.hpp b/source/blender/blenlib/BLI_math.hpp
index c2f5741b11c..f73213995df 100644
--- a/source/blender/blenlib/BLI_math.hpp
+++ b/source/blender/blenlib/BLI_math.hpp
@@ -2,27 +2,27 @@
 
 namespace BLI {
 
-struct Vec3 {
+struct float3 {
   float x, y, z;
 
-  friend Vec3 operator+(Vec3 a, Vec3 b)
+  friend float3 operator+(float3 a, float3 b)
   {
     return {a.x + b.x, a.y + b.y, a.z + b.z};
   }
 
-  void operator+=(Vec3 b)
+  void operator+=(float3 b)
   {
     this->x += b.x;
     this->y += b.y;
     this->z += b.z;
   }
 
-  friend Vec3 operator*(Vec3 a, Vec3 b)
+  friend float3 operator*(float3 a, float3 b)
   {
     return {a.x * b.x, a.y * b.y, a.z * b.z};
   }
 
-  friend Vec3 operator*(Vec3 a, float b)
+  friend float3 operator*(float3 a, float b)
   {
     return {a.x * b, a.y * b, a.z * b};
   }
diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp b/source/blender/simulations/bparticles/c_wrapper.cpp
index 9f8dadeae1d..1041b35c38a 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -24,9 +24,9 @@ using BParticles::StateBase;
 using BParticles::WrappedState;
 
 using BLI::ArrayRef;
+using BLI::float3;
 using BLI::SmallVector;
 using BLI::StringRef;
-using BLI::Vec3;
 
 WRAPPERS(BParticles::Description *, BParticlesDescription);
 WRAPPERS(BParticles::Solver *, BParticlesSolver);
@@ -41,7 +41,7 @@ class TestForce : public BParticles::Force {
   {
   }
 
-  void add_force(NamedBuffers &UNUSED(buffers), ArrayRef<Vec3> dst) override
+  void add_force(NamedBuffers &UNUSED(buffers), ArrayRef<float3> dst) override
   {
     for (uint i = 0; i < dst.size(); i++) {
       dst[i].z += m_strength;
@@ -58,11 +58,11 @@ class TurbulenceForce : public BParticles::Force {
   {
   }
 
-  void add_force(NamedBuffers &buffers, ArrayRef<Vec3> dst) override
+  void add_force(NamedBuffers &buffers, ArrayRef<float3> dst) override
   {
-    auto positions = buffers.vec3_buffer("Position");
+    auto positions = buffers.float3_buffer("Position");
     for (uint i = 0; i < dst.size(); i++) {
-      Vec3 pos = positions[i];
+      float3 pos = positions[i];
       float value = BLI_hnoise(0.5f, pos.x, pos.y, pos.z);
       dst[i].z += value * m_strength;
     }
@@ -82,8 +82,8 @@ class TestEmitter : public BParticles::Emitter {
     EmitterBuffers &dst = request_buffers();
     BLI_assert(dst.size() > 0);
 
-    auto positions = dst.vec3_buffer("Position");
-    auto velocities = dst.vec3_buffer("Velocity");
+    auto positions = dst.float3_buffer("Position");
+    auto velocities = dst.float3_buffer("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 ce292d21853..a1d59076514 100644
--- a/source/blender/simulations/bparticles/core.hpp
+++ b/source/blender/simulations/bparticles/core.hpp
@@ -19,10 +19,10 @@ class EmitterInfo;
 class EmitterInfoBuilder;
 
 using BLI::ArrayRef;
+using BLI::float3;
 using BLI::SmallSetVector;
 using BLI::SmallVector;
 using BLI::StringRef;
-using BLI::Vec3;
 using std::unique_ptr;
 
 class NamedBuffers {
@@ -30,14 +30,14 @@ class NamedBuffers {
   virtual ~NamedBuffers();
   virtual uint size() = 0;
   virtual ArrayRef<float> float_buffer(StringRef name) = 0;
-  virtual ArrayRef<Vec3> vec3_buffer(StringRef name) = 0;
+  virtual ArrayRef<float3> float3_buffer(StringRef name) = 0;
   virtual ArrayRef<uint8_t> byte_buffer(StringRef name) = 0;
 };
 
 class Force {
  public:
   virtual ~Force();
-  virtual void add_force(NamedBuffers &buffers, ArrayRef<Vec3> dst) = 0;
+  virtual void add_force(NamedBuffers &buffers, ArrayRef<float3> dst) = 0;
 };
 
 class EmitterBuffers {
@@ -66,9 +66,9 @@ class EmitterBuffers {
     return m_buffers.float_buffer(name);
   }
 
-  ArrayRef<Vec3> vec3_buffer(StringRef name)
+  ArrayRef<float3> float3_buffer(StringRef name)
   {
-    return m_buffers.vec3_buffer(name);
+    return m_buffers.float3_buffer(name);
   }
 
   ArrayRef<uint8_t> byte_buffer(StringRef name)
diff --git a/source/blender/simulations/bparticles/particles_container.cpp b/source/blender/simulations/bparticles/particles_container.cpp
index 19e74873a24..72a27307d8f 100644
--- a/source/blender/simulations/bparticles/particles_container.cpp
+++ b/source/blender/simulations/bparticles/particles_container.cpp
@@ -4,12 +4,12 @@ namespace BParticles {
 
 ParticlesBlock::ParticlesBlock(ParticlesContainer &container,
                                ArrayRef<float *> float_buffers,
-                               ArrayRef<Vec3 *> vec3_buffers,
+                               ArrayRef<float3 *> float3_buffers,
                                ArrayRef<uint8_t *> byte_buffers,
                                uint active_amount)
     : m_container(container),
       m_float_buffers(float_buffers.to_small_vector()),
-      m_vec3_buffers(vec3_buffers.to_small_vector()),
+      m_vec3_buffers(float3_buffers.to_small_vector()),
       m_byte_buffers(byte_buffers.to_small_vector()),
       m_active_amount(active_amount)
 {
@@ -46,15 +46,15 @@ ParticlesBlock *ParticlesContainer::new_block()
   for (uint i = 0; i < m_float_attribute_names.size(); i++) {
     float_buffers.append((float *)MEM_malloc_arrayN(m_block_size, sizeof(float), __func__));
   }
-  SmallVector<Vec3 *> vec3_buffers;
+  SmallVector<float3 *> float3_buffers;
   for (uint i = 0; i < m_vec3_attribute_names.size(); i++) {
-    vec3_buffers.append((Vec3 *)MEM_malloc_arrayN(m_block_size, sizeof(Vec3), __func__));
+    float3_buffers.append((float3 *)MEM_malloc_arrayN(m_block_size, sizeof(float3), __func__));
   }
   SmallVector<uint8_t *> byte_buffers;
   for (uint i = 0; i < m_byte_attribute_names.size(); i++) {
     byte_buffers.append((uint8_t *)MEM_malloc_arrayN(m_block_size, sizeof(uint8_t), __func__));
   }
-  ParticlesBlock *block = new ParticlesBlock(*this, float_buffers, vec3_buffers, byte_buffers);
+  ParticlesBlock *block = new ParticlesBlock(*this, float_buffers, float3_buffers, byte_buffers);
   m_blocks.add_new(block);
   return block;
 }
@@ -69,7 +69,7 @@ void ParticlesContainer::release_block(ParticlesBlock *block)
   for (float *buffer : block->float_buffers()) {
     MEM_freeN((void *)buffer);
   }
-  for (Vec3 *buffer : block->vec3_buffers()) {
+  for (float3 *buffer : block->float3_buffers()) {
     MEM_freeN((void *)buffer);
   }
   for (uint8_t *buffer : block->byte_buffers()) {
@@ -105,7 +105,8 @@ void ParticlesBlock::MoveUntilFull(ParticlesBlock *from, ParticlesBlock *to)
 
   move_buffers<float>(
       from->float_buffers(), to->float_buffers(), src_start, dst_start, move_amount);
-  move_buffers<Vec3>(from->vec3_buffers(), to->vec3_buffers(), src_start, dst_start, move_amount);
+  move_buffers<float3>(
+      from->float3_buffers(), to->float3_buffers(), src_start, dst_start, move_amount);
   move_buffers<uint8_t>(
       from->byte_buffers(), to->byte_buffers(), src_start, dst_start, move_amount);
 
diff --git a/source/blender/simulations/bparticles/particles_container.hpp b/source/blender/simulations/bparticles/particles_container.hpp
index 79655061014..7bb3647fe8e 100644
--- a/source/blender/simulations/bparticles/particles_container.hpp
+++ b/source/blender/simulations/bparticles/particles_container.hpp
@@ -11,11 +11,11 @@
 namespace BParticles {
 
 using BLI::ArrayRef;
+using BLI::float3;
 using BLI::SmallSet;
 using BLI::SmallSetVector;
 using BLI::SmallVector;
 using BLI::StringRef;
-using BLI::Vec3;
 
 class ParticlesContainer;
 class ParticlesBlock;
@@ -66,7 +66,7 @@ class ParticlesBlockSlice : public NamedBuffers {
   uint size() override;
 
   ArrayRef<float> float_buffer(StringRef name) override;
-  ArrayRef<Vec3> vec3_buffer(StringRef name) override;
+  ArrayRef<float3> float3_buffer(StringRef name) override;
   ArrayRef<uint8_t> byte_buffer(StringRef name) override;
 
   ParticlesBlockSlice take_front(uint n);
@@ -75,14 +75,14 @@ class ParticlesBlockSlice : public NamedBuffers {
 class ParticlesBlock {
   ParticlesContainer &m_container;
   SmallVector<float *> m_float_buffers;
-  SmallVector<Vec3 *> m_vec3_buffers;
+  SmallVector<float3 *> m_vec3_buffers;
   SmallVector<uint8_t *> m_byte_buffers;
   uint m_active_amount;
 
  public:
   ParticlesBlock(ParticlesContainer &container,
                  ArrayRef<float *> float_buffers,
-                 ArrayRef<Vec3 *> vec3_buffers,
+                 ArrayRef<float3 *> float3_buffers,
                  ArrayRef<uint8_t *> byte_buffers,
                  uint active_amount = 0);
 
@@ -98,11 +98,11 @@ class ParticlesBlock {
   void clear();
 
   ArrayRef<float *> float_buffers();
-  ArrayRef<Vec3 *> vec3_buffers();
+  ArrayRef<float3 *> float3_buffers();
   ArrayRef<uint8_t *> byte_buffers();
 
   float *float_buffer(StringRef name);
-  Vec3 *vec3_buffer(StringRef name);
+  float3 *float3_buffer(StringRef name);
   uint8_t *byte_buffer(StringRef name);
 
   ParticlesBlockSlice slice(uint start, uint length);
@@ -206,7 +206,7 @@ inline ArrayRef<float *> ParticlesBlock::float_buffers()
   return m_float_buffers;
 }
 
-inline ArrayRef<Vec3 *> ParticlesBlock::vec3_buffers()
+inline ArrayRef<float3 *> ParticlesBlock::float3_buffers()
 {
   return m_vec3_buffers;
 }
@@ -222,7 +222,7 @@ inline float *ParticlesBlock::float_buffer(StringRef name)
   return m_float_buffers[index];
 }
 
-inline Vec3 *ParticlesBlock::vec3_buffer(StringRef name)
+inline float3 *ParticlesBlock::float3_buffer(StringRef name)
 {
   uint index = m_container.vec3_buffer_index(name);
   return m_vec3_buffers[index];
@@ -254,7 +254,7 @@ inline void ParticlesBlock::move(uint old_index, uint new_index)
   for (float *buffer : m_float_buffers) {
     buffer[new_index] = buffer[old_index];
   }
-  for (Vec3 *buffer : m_vec3_buffers) {
+  for (float3 *buffer : m_vec3_buffers) {
     buffer[new_index] = buffer[old_index];
   }
 }
@@ -283,9 +283,9 @@ inline ArrayRef<float> ParticlesBlockSlice::float_buffer(StringRef name)
   return ArrayRef<float>(m_block->float_buffer(name) + m_start, m_length);
 }
 
-inline ArrayRef<Vec3> ParticlesBlockS

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list