diff options
author | Victor-Louis De Gusseme <victorlouis> | 2021-09-21 02:39:39 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-09-21 02:39:39 +0300 |
commit | 05f3f11d553e97f27fc88b1dada9387acdb768a6 (patch) | |
tree | 0826726565b83168598ab5e4c88501ee66f435c0 /source/blender/blenlib/BLI_array.hh | |
parent | 13a4bccdb196770b4f357c2a3c312bd4629ecb36 (diff) |
Geometry Nodes: Attribute Statistic Node
This nodes evaluates a field on a geometry and outputs various
statistics about the entire data set, like min, max, or even
the standard deviation. It works for float and vector types currently,
though more types could be supported in the future.
- All statistics are calculated element-wise for vectors.
- "Product" was not added since the result could very easily overflow.
- The "Size" output was not added since it isn't specific to an
attribute and would fit better in another node.
The implementation shares work as much as possible when multiple
statistics are needed.
This node has been in development since the beginning of this year,
with additions from Johnny Matthews and Hans Goudey.
Differential Revision: https://developer.blender.org/D10202
Diffstat (limited to 'source/blender/blenlib/BLI_array.hh')
-rw-r--r-- | source/blender/blenlib/BLI_array.hh | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_array.hh b/source/blender/blenlib/BLI_array.hh index fc8fc615feb..352bf379d4d 100644 --- a/source/blender/blenlib/BLI_array.hh +++ b/source/blender/blenlib/BLI_array.hh @@ -277,6 +277,21 @@ class Array { } /** + * Return a reference to the first element in the array. + * This invokes undefined behavior when the array is empty. + */ + const T &first() const + { + BLI_assert(size_ > 0); + return *data_; + } + T &first() + { + BLI_assert(size_ > 0); + return *data_; + } + + /** * Return a reference to the last element in the array. * This invokes undefined behavior when the array is empty. */ |