From 4f4af0cbe17fe9781aeaefb7e0d2f554bdb9c1a5 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 20 Jul 2020 15:30:12 +0200 Subject: Particles: support removing particles during the simulation This still cannot be controlled by the user. Currently, all particles are killed after two seconds --- source/blender/blenlib/BLI_span.hh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source/blender/blenlib') diff --git a/source/blender/blenlib/BLI_span.hh b/source/blender/blenlib/BLI_span.hh index 67bb32304de..2d875fe73be 100644 --- a/source/blender/blenlib/BLI_span.hh +++ b/source/blender/blenlib/BLI_span.hh @@ -593,6 +593,21 @@ template class MutableSpan { return start_[size_ - 1]; } + /** + * Does a linear search to count how often the value is in the array. + * Returns the number of occurrences. + */ + int64_t count(const T &value) const + { + int64_t counter = 0; + for (const T &element : *this) { + if (element == value) { + counter++; + } + } + return counter; + } + /** * Returns a new span to the same underlying memory buffer. No conversions are done. */ -- cgit v1.2.3