diff options
author | Jacques Lucke <jacques@blender.org> | 2020-07-20 16:30:12 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-07-20 16:31:05 +0300 |
commit | 4f4af0cbe17fe9781aeaefb7e0d2f554bdb9c1a5 (patch) | |
tree | e8765dd53aee71b6a84420d692526b33157e5896 /source/blender/blenlib/BLI_span.hh | |
parent | 9016a29f194194085acfd937f31b80be0f1b0c8e (diff) |
Particles: support removing particles during the simulation
This still cannot be controlled by the user. Currently, all particles are
killed after two seconds
Diffstat (limited to 'source/blender/blenlib/BLI_span.hh')
-rw-r--r-- | source/blender/blenlib/BLI_span.hh | 15 |
1 files changed, 15 insertions, 0 deletions
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 @@ -594,6 +594,21 @@ template<typename T> class MutableSpan { } /** + * 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. */ template<typename NewT> MutableSpan<NewT> cast() const |