[Bf-blender-cvs] [37c0e0e6e97] functions: cleanup: separate declarations from implementations

Jacques Lucke noreply at git.blender.org
Mon Jul 1 12:12:33 CEST 2019


Commit: 37c0e0e6e97c14a99dbf015e8ecdf58f30f6ca6e
Author: Jacques Lucke
Date:   Mon Jul 1 11:42:15 2019 +0200
Branches: functions
https://developer.blender.org/rB37c0e0e6e97c14a99dbf015e8ecdf58f30f6ca6e

cleanup: separate declarations from implementations

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

M	source/blender/simulations/bparticles/core.cpp
M	source/blender/simulations/bparticles/core.hpp

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

diff --git a/source/blender/simulations/bparticles/core.cpp b/source/blender/simulations/bparticles/core.cpp
index f25eef3e64f..886d12e276d 100644
--- a/source/blender/simulations/bparticles/core.cpp
+++ b/source/blender/simulations/bparticles/core.cpp
@@ -92,6 +92,11 @@ AttributesInfo &BlockAllocator::attributes_info(uint particle_type_id)
 /* Emitter Interface
  ******************************************/
 
+EmitterInterface::EmitterInterface(BlockAllocator &allocator, TimeSpan time_span)
+    : m_block_allocator(allocator), m_time_span(time_span)
+{
+}
+
 EmitterInterface::~EmitterInterface()
 {
   for (TimeSpanEmitTarget *target : m_targets) {
@@ -147,6 +152,38 @@ InstantEmitTarget &EventExecuteInterface::request_emit_target(uint particle_type
 /* EmitTarget
  ******************************************/
 
+EmitTargetBase::EmitTargetBase(uint particle_type_id,
+                               AttributesInfo &attributes_info,
+                               ArrayRef<ParticlesBlock *> blocks,
+                               ArrayRef<Range<uint>> ranges)
+    : m_particle_type_id(particle_type_id),
+      m_attributes_info(attributes_info),
+      m_blocks(blocks),
+      m_ranges(ranges)
+{
+  BLI_assert(blocks.size() == ranges.size());
+  for (auto range : ranges) {
+    m_size += range.size();
+  }
+}
+
+InstantEmitTarget::InstantEmitTarget(uint particle_type_id,
+                                     AttributesInfo &attributes_info,
+                                     ArrayRef<ParticlesBlock *> blocks,
+                                     ArrayRef<Range<uint>> ranges)
+    : EmitTargetBase(particle_type_id, attributes_info, blocks, ranges)
+{
+}
+
+TimeSpanEmitTarget::TimeSpanEmitTarget(uint particle_type_id,
+                                       AttributesInfo &attributes_info,
+                                       ArrayRef<ParticlesBlock *> blocks,
+                                       ArrayRef<Range<uint>> ranges,
+                                       TimeSpan time_span)
+    : EmitTargetBase(particle_type_id, attributes_info, blocks, ranges), m_time_span(time_span)
+{
+}
+
 void EmitTargetBase::set_elements(uint index, void *data)
 {
   AttributeType type = m_attributes_info.type_of(index);
@@ -266,4 +303,41 @@ void TimeSpanEmitTarget::set_randomized_birth_moments()
   this->set_float("Birth Time", birth_times);
 }
 
+/* EventFilterInterface
+ *****************************************/
+
+EventFilterInterface::EventFilterInterface(ParticleSet particles,
+                                           AttributeArrays &attribute_offsets,
+                                           ArrayRef<float> durations,
+                                           float end_time,
+                                           EventStorage &r_event_storage,
+                                           SmallVector<uint> &r_filtered_indices,
+                                           SmallVector<float> &r_filtered_time_factors)
+    : m_particles(particles),
+      m_attribute_offsets(attribute_offsets),
+      m_durations(durations),
+      m_end_time(end_time),
+      m_event_storage(r_event_storage),
+      m_filtered_indices(r_filtered_indices),
+      m_filtered_time_factors(r_filtered_time_factors)
+{
+}
+
+/* EventExecuteInterface
+ *************************************************/
+
+EventExecuteInterface::EventExecuteInterface(ParticleSet particles,
+                                             BlockAllocator &block_allocator,
+                                             ArrayRef<float> current_times,
+                                             EventStorage &event_storage,
+                                             AttributeArrays attribute_offsets)
+    : m_particles(particles),
+      m_block_allocator(block_allocator),
+      m_current_times(current_times),
+      m_kill_states(m_particles.attributes().get_byte("Kill State")),
+      m_event_storage(event_storage),
+      m_attribute_offsets(attribute_offsets)
+{
+}
+
 }  // namespace BParticles
diff --git a/source/blender/simulations/bparticles/core.hpp b/source/blender/simulations/bparticles/core.hpp
index a61e4e21344..cbf30c37c99 100644
--- a/source/blender/simulations/bparticles/core.hpp
+++ b/source/blender/simulations/bparticles/core.hpp
@@ -28,26 +28,10 @@ class ParticlesState {
   ParticlesState(ParticlesState &other) = delete;
   ~ParticlesState();
 
-  SmallMap<uint, ParticlesContainer *> &particle_containers()
-  {
-    return m_container_by_id;
-  }
-
-  ParticlesContainer &particle_container(uint type_id)
-  {
-    return *m_container_by_id.lookup(type_id);
-  }
+  SmallMap<uint, ParticlesContainer *> &particle_containers();
 
-  uint particle_container_id(ParticlesContainer &container)
-  {
-    for (auto item : m_container_by_id.items()) {
-      if (item.value == &container) {
-        return item.key;
-      }
-    }
-    BLI_assert(false);
-    return 0;
-  }
+  ParticlesContainer &particle_container(uint type_id);
+  uint particle_container_id(ParticlesContainer &container);
 };
 
 /**
@@ -73,16 +57,8 @@ class BlockAllocator {
                              SmallVector<Range<uint>> &r_ranges);
 
   AttributesInfo &attributes_info(uint particle_type_id);
-
-  ParticlesState &particles_state()
-  {
-    return m_state;
-  }
-
-  ArrayRef<ParticlesBlock *> allocated_blocks()
-  {
-    return m_allocated_blocks;
-  }
+  ParticlesState &particles_state();
+  ArrayRef<ParticlesBlock *> allocated_blocks();
 };
 
 class EmitTargetBase {
@@ -98,17 +74,7 @@ class EmitTargetBase {
   EmitTargetBase(uint particle_type_id,
                  AttributesInfo &attributes_info,
                  ArrayRef<ParticlesBlock *> blocks,
-                 ArrayRef<Range<uint>> ranges)
-      : m_particle_type_id(particle_type_id),
-        m_attributes_info(attributes_info),
-        m_blocks(blocks),
-        m_ranges(ranges)
-  {
-    BLI_assert(blocks.size() == ranges.size());
-    for (auto range : ranges) {
-      m_size += range.size();
-    }
-  }
+                 ArrayRef<Range<uint>> ranges);
 
   EmitTargetBase(EmitTargetBase &other) = delete;
 
@@ -126,30 +92,11 @@ class EmitTargetBase {
   void fill_float3(uint index, float3 value);
   void fill_float3(StringRef name, float3 value);
 
-  ArrayRef<ParticlesBlock *> blocks()
-  {
-    return m_blocks;
-  }
-
-  ArrayRef<Range<uint>> ranges()
-  {
-    return m_ranges;
-  }
-
-  uint part_amount()
-  {
-    return m_ranges.size();
-  }
-
-  AttributeArrays attributes(uint part)
-  {
-    return m_blocks[part]->slice(m_ranges[part]);
-  }
-
-  uint particle_type_id()
-  {
-    return m_particle_type_id;
-  }
+  ArrayRef<ParticlesBlock *> blocks();
+  ArrayRef<Range<uint>> ranges();
+  uint part_amount();
+  AttributeArrays attributes(uint part);
+  uint particle_type_id();
 
  private:
   void set_elements(uint index, void *data);
@@ -161,10 +108,7 @@ class InstantEmitTarget : public EmitTargetBase {
   InstantEmitTarget(uint particle_type_id,
                     AttributesInfo &attributes_info,
                     ArrayRef<ParticlesBlock *> blocks,
-                    ArrayRef<Range<uint>> ranges)
-      : EmitTargetBase(particle_type_id, attributes_info, blocks, ranges)
-  {
-  }
+                    ArrayRef<Range<uint>> ranges);
 };
 
 class TimeSpanEmitTarget : public EmitTargetBase {
@@ -176,10 +120,7 @@ class TimeSpanEmitTarget : public EmitTargetBase {
                      AttributesInfo &attributes_info,
                      ArrayRef<ParticlesBlock *> blocks,
                      ArrayRef<Range<uint>> ranges,
-                     TimeSpan time_span)
-      : EmitTargetBase(particle_type_id, attributes_info, blocks, ranges), m_time_span(time_span)
-  {
-  }
+                     TimeSpan time_span);
 
   void set_birth_moment(float time_factor);
   void set_randomized_birth_moments();
@@ -192,29 +133,14 @@ class EmitterInterface {
   TimeSpan m_time_span;
 
  public:
-  EmitterInterface(BlockAllocator &allocator, TimeSpan time_span)
-      : m_block_allocator(allocator), m_time_span(time_span)
-  {
-  }
-
+  EmitterInterface(BlockAllocator &allocator, TimeSpan time_span);
   ~EmitterInterface();
 
-  ArrayRef<TimeSpanEmitTarget *> targets()
-  {
-    return m_targets;
-  }
+  ArrayRef<TimeSpanEmitTarget *> targets();
 
   TimeSpanEmitTarget &request(uint particle_type_id, uint size);
-
-  TimeSpan time_span()
-  {
-    return m_time_span;
-  }
-
-  bool is_first_step()
-  {
-    return m_time_span.start() < 0.00001f;
-  }
+  TimeSpan time_span();
+  bool is_first_step();
 };
 
 struct ParticleSet {
@@ -228,55 +154,19 @@ struct ParticleSet {
   ArrayRef<uint> m_particle_indices;
 
  public:
-  ParticleSet(ParticlesBlock &block, ArrayRef<uint> particle_indices)
-      : m_block(&block), m_particle_indices(particle_indices)
-  {
-  }
+  ParticleSet(ParticlesBlock &block, ArrayRef<uint> particle_indices);
 
-  ParticlesBlock &block()
-  {
-    return *m_block;
-  }
-
-  AttributeArrays attributes()
-  {
-    return m_block->slice_all();
-  }
-
-  ArrayRef<uint> indices()
-  {
-    return m_particle_indices;
-  }
-
-  uint get_particle_index(uint i)
-  {
-    return m_particle_indices[i];
-  }
-
-  Range<uint> range()
-  {
-    return Range<uint>(0, m_particle_indices.size());
-  }
-
-  uint size()
-  {
-    return m_particle_indices.size();
-  }
+  ParticlesBlock &block();
+  AttributeArrays attributes();
+  ArrayRef<uint> indices();
+  uint get_particle_index(uint i);
+  Range<uint> range();
+  uint size();
 
   /**
    * Returns true when get_particle_index(i) == i for all i, otherwise false.
    */
-  bool indices_are_trivial()
-  {
-    if (m_particle_indices.size() == 0) {
-      return true;
-    }
-    else {
-      /* This works due to the invariants mentioned above. */
-      return m_particle_indices.first() == 0 &&
-             m_particle_indices.last() == m_particle_indices.size() - 1;
-    }
-  }
+  bool indices_are_trivial();
 };
 
 class EventStorage {
@@ -285,21 +175,11 @@ class EventStorage {
   uint m_stride;
 
  public:
-  EventStorage(void *array, uint stride) : m_array(array), m_stride(stride)
-  {
-  }
-
+  EventStorage(void *array, uint stride);
   EventStorage(EventStorage &other) = delete;
 
-  vo

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list