[Bf-blender-cvs] [1ed83f1004b] functions: use another constructor for IndexRange

Jacques Lucke noreply at git.blender.org
Thu Sep 5 19:11:36 CEST 2019


Commit: 1ed83f1004bdccf0e4e0199b97b6c86d5443294e
Author: Jacques Lucke
Date:   Thu Sep 5 11:51:54 2019 +0200
Branches: functions
https://developer.blender.org/rB1ed83f1004bdccf0e4e0199b97b6c86d5443294e

use another constructor for IndexRange

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

M	source/blender/blenkernel/BKE_attributes_ref.hpp
M	source/blender/blenlib/BLI_range.hpp
M	source/blender/functions/core/data_graph.hpp
M	source/blender/simulations/bparticles/action_contexts.hpp
M	source/blender/simulations/bparticles/action_interface.hpp
M	source/blender/simulations/bparticles/c_wrapper.cpp
M	source/blender/simulations/bparticles/particle_function_input_providers.cpp
M	source/blender/simulations/bparticles/particles_container.hpp
M	source/blender/simulations/bparticles/simulate.cpp

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

diff --git a/source/blender/blenkernel/BKE_attributes_ref.hpp b/source/blender/blenkernel/BKE_attributes_ref.hpp
index 6744d1eea14..c30392eb60a 100644
--- a/source/blender/blenkernel/BKE_attributes_ref.hpp
+++ b/source/blender/blenkernel/BKE_attributes_ref.hpp
@@ -17,9 +17,9 @@ namespace BKE {
 using BLI::ArrayRef;
 using BLI::float2;
 using BLI::float3;
+using BLI::IndexRange;
 using BLI::MutableArrayRef;
 using BLI::Optional;
-using BLI::IndexRange;
 using BLI::rgba_b;
 using BLI::rgba_f;
 using BLI::SetVector;
@@ -239,7 +239,7 @@ class AttributesInfo {
    */
   IndexRange attribute_indices() const
   {
-    return IndexRange(0, this->size());
+    return IndexRange(this->size());
   }
 
   /**
@@ -272,7 +272,7 @@ class AttributesRef {
 
  public:
   AttributesRef(AttributesInfo &info, ArrayRef<void *> buffers, uint size)
-      : AttributesRef(info, buffers, IndexRange(0, size))
+      : AttributesRef(info, buffers, IndexRange(size))
   {
   }
 
diff --git a/source/blender/blenlib/BLI_range.hpp b/source/blender/blenlib/BLI_range.hpp
index d0d4c021158..f0eed080c81 100644
--- a/source/blender/blenlib/BLI_range.hpp
+++ b/source/blender/blenlib/BLI_range.hpp
@@ -43,6 +43,10 @@ class IndexRange {
  public:
   IndexRange() = default;
 
+  explicit IndexRange(uint one_after_last) : m_start(0), m_one_after_last(one_after_last)
+  {
+  }
+
   /**
    * Construct a new range.
    * Asserts when start is larger than one_after_last.
diff --git a/source/blender/functions/core/data_graph.hpp b/source/blender/functions/core/data_graph.hpp
index bea6589afb4..1d50662f5a4 100644
--- a/source/blender/functions/core/data_graph.hpp
+++ b/source/blender/functions/core/data_graph.hpp
@@ -219,7 +219,7 @@ class DataGraph : public RefCounter {
 
   IndexRange node_ids() const
   {
-    return IndexRange(0, m_nodes.size());
+    return IndexRange(m_nodes.size());
   }
 
   SharedFunction &function_of_node(uint node_id) const
diff --git a/source/blender/simulations/bparticles/action_contexts.hpp b/source/blender/simulations/bparticles/action_contexts.hpp
index f5a53377f4a..465723a8353 100644
--- a/source/blender/simulations/bparticles/action_contexts.hpp
+++ b/source/blender/simulations/bparticles/action_contexts.hpp
@@ -37,7 +37,7 @@ class MeshSurfaceContext : public ActionContext {
         m_looptri_indices(looptri_indices),
         m_world_surface_velocities(world_surface_velocities)
   {
-    this->compute_barycentric_coords(IndexRange(0, m_local_positions.size()).as_array_ref());
+    this->compute_barycentric_coords(IndexRange(m_local_positions.size()).as_array_ref());
   }
 
   MeshSurfaceContext(Object *object,
diff --git a/source/blender/simulations/bparticles/action_interface.hpp b/source/blender/simulations/bparticles/action_interface.hpp
index d2c5afce318..c67c5f5e4f3 100644
--- a/source/blender/simulations/bparticles/action_interface.hpp
+++ b/source/blender/simulations/bparticles/action_interface.hpp
@@ -147,7 +147,7 @@ inline void Action::execute_from_emitter(AttributesRefGroup &new_particles,
     durations.fill(0);
 
     ActionInterface action_interface(emitter_interface.particle_allocator(),
-                                     IndexRange(0, range_size).as_array_ref(),
+                                     IndexRange(range_size).as_array_ref(),
                                      attributes,
                                      offsets,
                                      attributes.get<float>("Birth Time"),
@@ -206,7 +206,7 @@ inline void Action::execute_for_new_particles(AttributesRefGroup &new_particles,
     durations.fill(0);
 
     ActionInterface new_interface(action_interface.particle_allocator(),
-                                  IndexRange(0, range_size).as_array_ref(),
+                                  IndexRange(range_size).as_array_ref(),
                                   attributes,
                                   offsets,
                                   attributes.get<float>("Birth Time"),
@@ -232,7 +232,7 @@ inline void Action::execute_for_new_particles(AttributesRefGroup &new_particles,
     durations.fill(0);
 
     ActionInterface new_interface(offset_handler_interface.particle_allocator(),
-                                  IndexRange(0, range_size).as_array_ref(),
+                                  IndexRange(range_size).as_array_ref(),
                                   attributes,
                                   offsets,
                                   attributes.get<float>("Birth Time"),
diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp b/source/blender/simulations/bparticles/c_wrapper.cpp
index f2fc357f240..bd7639f7f57 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -152,7 +152,7 @@ static Mesh *distribute_tetrahedons(ArrayRef<float3> centers,
       mesh->totloop);
 
   BLI::Task::parallel_range(
-      IndexRange(0, amount), 1000, [mesh, centers, scales, colors, loop_colors](IndexRange range) {
+      IndexRange(amount), 1000, [mesh, centers, scales, colors, loop_colors](IndexRange range) {
         distribute_tetrahedons_range(mesh, loop_colors, range, centers, scales, colors);
       });
 
diff --git a/source/blender/simulations/bparticles/particle_function_input_providers.cpp b/source/blender/simulations/bparticles/particle_function_input_providers.cpp
index 90e322ee0ec..c420570e2a7 100644
--- a/source/blender/simulations/bparticles/particle_function_input_providers.cpp
+++ b/source/blender/simulations/bparticles/particle_function_input_providers.cpp
@@ -99,7 +99,7 @@ Optional<ParticleFunctionInputArray> SurfaceImageInputProvider::get(
   if (dynamic_cast<MeshSurfaceContext *>(action_context)) {
     auto *surface_info = dynamic_cast<MeshSurfaceContext *>(action_context);
     return this->compute_colors(
-        interface, surface_info, IndexRange(0, interface.attributes().size()).as_array_ref());
+        interface, surface_info, IndexRange(interface.attributes().size()).as_array_ref());
   }
   else if (dynamic_cast<SourceParticleActionContext *>(action_context)) {
     auto *source = dynamic_cast<SourceParticleActionContext *>(action_context);
@@ -162,7 +162,7 @@ Optional<ParticleFunctionInputArray> VertexWeightInputProvider::get(
   if (dynamic_cast<MeshSurfaceContext *>(action_context)) {
     auto *surface_info = dynamic_cast<MeshSurfaceContext *>(action_context);
     return this->compute_weights(
-        interface, surface_info, IndexRange(0, interface.attributes().size()).as_array_ref());
+        interface, surface_info, IndexRange(interface.attributes().size()).as_array_ref());
   }
   else if (dynamic_cast<SourceParticleActionContext *>(action_context)) {
     auto *source_info = dynamic_cast<SourceParticleActionContext *>(action_context);
diff --git a/source/blender/simulations/bparticles/particles_container.hpp b/source/blender/simulations/bparticles/particles_container.hpp
index 39340c678a3..9df5009e96d 100644
--- a/source/blender/simulations/bparticles/particles_container.hpp
+++ b/source/blender/simulations/bparticles/particles_container.hpp
@@ -264,7 +264,7 @@ template<typename T> Vector<T> ParticlesContainer::flatten_attribute(StringRef a
 
 inline IndexRange ParticlesBlock::active_range()
 {
-  return IndexRange(0, m_active_amount);
+  return IndexRange(m_active_amount);
 }
 
 inline uint &ParticlesBlock::active_amount()
@@ -325,12 +325,12 @@ inline AttributesRef ParticlesBlock::attributes_slice(uint start, uint length)
 
 inline AttributesRef ParticlesBlock::attributes_all()
 {
-  return this->attributes_slice(IndexRange(0, m_container.block_size()));
+  return this->attributes_slice(IndexRange(m_container.block_size()));
 }
 
 inline AttributesRef ParticlesBlock::attributes()
 {
-  return this->attributes_slice(IndexRange(0, m_active_amount));
+  return this->attributes_slice(IndexRange(m_active_amount));
 }
 
 inline ArrayRef<void *> ParticlesBlock::attribute_buffers()
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index 4eb92acb4f9..dfe485877c8 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -253,7 +253,7 @@ BLI_NOINLINE static void simulate_with_max_n_events(BlockStepData &step_data,
     VectorAdaptor<uint> pindices_output(pindices_A.begin(), amount_left);
     simulate_to_next_event(step_data,
                            particle_allocator,
-                           IndexRange(0, amount_left).as_array_ref(),
+                           IndexRange(amount_left).as_array_ref(),
                            type_info,
                            pindices_output);
     amount_left = pindices_output.size();



More information about the Bf-blender-cvs mailing list