[Bf-blender-cvs] [bd514d20e0a] functions: remove more redundant code

Jacques Lucke noreply at git.blender.org
Mon Jul 29 17:57:59 CEST 2019


Commit: bd514d20e0ac9fa6530fa08f5e9505156b576d18
Author: Jacques Lucke
Date:   Mon Jul 29 17:21:21 2019 +0200
Branches: functions
https://developer.blender.org/rBbd514d20e0ac9fa6530fa08f5e9505156b576d18

remove more redundant code

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

M	source/blender/simulations/bparticles/actions.cpp
M	source/blender/simulations/bparticles/emitters.cpp
M	source/blender/simulations/bparticles/particle_set.cpp
M	source/blender/simulations/bparticles/particle_set.hpp

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

diff --git a/source/blender/simulations/bparticles/actions.cpp b/source/blender/simulations/bparticles/actions.cpp
index 1df09a9ec70..fc2d6729ac9 100644
--- a/source/blender/simulations/bparticles/actions.cpp
+++ b/source/blender/simulations/bparticles/actions.cpp
@@ -78,7 +78,7 @@ void ExplodeAction::execute(ActionInterface &interface)
                                                               new_birth_times.size());
   new_particles.set<float3>("Position", new_positions);
   new_particles.set<float3>("Velocity", new_velocities);
-  new_particles.fill_float("Size", 0.1f);
+  new_particles.fill<float>("Size", 0.1f);
   new_particles.set<float>("Birth Time", new_birth_times);
 
   m_post_action->execute(interface);
diff --git a/source/blender/simulations/bparticles/emitters.cpp b/source/blender/simulations/bparticles/emitters.cpp
index 965dee569f0..e1e8e64f05f 100644
--- a/source/blender/simulations/bparticles/emitters.cpp
+++ b/source/blender/simulations/bparticles/emitters.cpp
@@ -162,7 +162,7 @@ void CustomFunctionEmitter::emit(EmitterInterface &interface)
 
   auto new_particles = interface.particle_allocator().request(m_particle_type_name,
                                                               new_particle_amount);
-  new_particles.fill_float("Birth Time", interface.time_span().end());
+  new_particles.fill<float>("Birth Time", interface.time_span().end());
 
   for (uint i = 0; i < m_function->output_amount(); i++) {
     auto &type = m_function->output_type(i);
@@ -186,13 +186,13 @@ void CustomFunctionEmitter::emit(EmitterInterface &interface)
       new_particles.set_repeated<int32_t>(attribute_index, *list.ptr());
     }
     else if (type == float_type) {
-      new_particles.fill_float(attribute_index, fn_out.get<float>(i));
+      new_particles.fill<float>(attribute_index, fn_out.get<float>(i));
     }
     else if (type == float3_type) {
-      new_particles.fill_float3(attribute_index, fn_out.get<float3>(i));
+      new_particles.fill<float3>(attribute_index, fn_out.get<float3>(i));
     }
     else if (type == int32_type) {
-      new_particles.fill_integer(attribute_index, fn_out.get<int32_t>(i));
+      new_particles.fill<int32_t>(attribute_index, fn_out.get<int32_t>(i));
     }
   }
 }
@@ -217,8 +217,8 @@ void InitialGridEmitter::emit(EmitterInterface &interface)
   auto new_particles = interface.particle_allocator().request(m_particle_type_name,
                                                               new_positions.size());
   new_particles.set<float3>("Position", new_positions);
-  new_particles.fill_float("Birth Time", interface.time_span().start());
-  new_particles.fill_float("Size", m_size);
+  new_particles.fill<float>("Birth Time", interface.time_span().start());
+  new_particles.fill<float>("Size", m_size);
 }
 
 }  // namespace BParticles
diff --git a/source/blender/simulations/bparticles/particle_set.cpp b/source/blender/simulations/bparticles/particle_set.cpp
index 0c5a3c3571b..6ada6e1fad5 100644
--- a/source/blender/simulations/bparticles/particle_set.cpp
+++ b/source/blender/simulations/bparticles/particle_set.cpp
@@ -80,48 +80,4 @@ void ParticleSets::fill_elements(uint index, void *value)
   }
 }
 
-void ParticleSets::fill_byte(uint index, uint8_t value)
-{
-  this->fill_elements(index, (void *)&value);
-}
-
-void ParticleSets::fill_byte(StringRef name, uint8_t value)
-{
-  uint index = m_attributes_info.attribute_index(name);
-  this->fill_byte(index, value);
-}
-
-void ParticleSets::fill_integer(uint index, int32_t value)
-{
-  this->fill_elements(index, (void *)&value);
-}
-
-void ParticleSets::fill_integer(StringRef name, int32_t value)
-{
-  uint index = m_attributes_info.attribute_index(name);
-  this->fill_integer(index, value);
-}
-
-void ParticleSets::fill_float(uint index, float value)
-{
-  this->fill_elements(index, (void *)&value);
-}
-
-void ParticleSets::fill_float(StringRef name, float value)
-{
-  uint index = m_attributes_info.attribute_index(name);
-  this->fill_float(index, value);
-}
-
-void ParticleSets::fill_float3(uint index, float3 value)
-{
-  this->fill_elements(index, (void *)&value);
-}
-
-void ParticleSets::fill_float3(StringRef name, float3 value)
-{
-  uint index = m_attributes_info.attribute_index(name);
-  this->fill_float3(index, value);
-}
-
 };  // namespace BParticles
diff --git a/source/blender/simulations/bparticles/particle_set.hpp b/source/blender/simulations/bparticles/particle_set.hpp
index 4130ddda5a6..24f9129546c 100644
--- a/source/blender/simulations/bparticles/particle_set.hpp
+++ b/source/blender/simulations/bparticles/particle_set.hpp
@@ -89,14 +89,17 @@ class ParticleSets {
     this->set_repeated<T>(index, data);
   }
 
-  void fill_byte(uint index, uint8_t value);
-  void fill_byte(StringRef name, uint8_t value);
-  void fill_integer(uint index, int32_t value);
-  void fill_integer(StringRef name, int32_t value);
-  void fill_float(uint index, float value);
-  void fill_float(StringRef name, float value);
-  void fill_float3(uint index, float3 value);
-  void fill_float3(StringRef name, float3 value);
+  template<typename T> void fill(uint index, T value)
+  {
+    BLI_assert(m_attributes_info.type_of(index) == attribute_type_by_type<T>::value);
+    this->fill_elements(index, (void *)&value);
+  }
+
+  template<typename T> void fill(StringRef name, T value)
+  {
+    uint index = m_attributes_info.attribute_index(name);
+    this->fill<T>(index, value);
+  }
 
   StringRefNull particle_type_name();



More information about the Bf-blender-cvs mailing list