Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/BLI_index_mask.hh')
-rw-r--r--source/blender/blenlib/BLI_index_mask.hh23
1 files changed, 21 insertions, 2 deletions
diff --git a/source/blender/blenlib/BLI_index_mask.hh b/source/blender/blenlib/BLI_index_mask.hh
index ad030e127fe..2dca3689cb1 100644
--- a/source/blender/blenlib/BLI_index_mask.hh
+++ b/source/blender/blenlib/BLI_index_mask.hh
@@ -45,11 +45,11 @@ namespace blender {
class IndexMask {
private:
- /* The underlying reference to sorted integers. */
+ /** The underlying reference to sorted integers. */
Span<int64_t> indices_;
public:
- /* Creates an IndexMask that contains no indices. */
+ /** Creates an IndexMask that contains no indices. */
IndexMask() = default;
/**
@@ -223,6 +223,25 @@ class IndexMask {
return indices_.is_empty();
}
+ IndexMask slice(IndexRange slice) const;
+ /**
+ * Create a sub-mask that is also shifted to the beginning.
+ * The shifting to the beginning allows code to work with smaller indices,
+ * which is more memory efficient.
+ *
+ * \return New index mask with the size of #slice. It is either empty or starts with 0.
+ * It might reference indices that have been appended to #r_new_indices.
+ *
+ * Example:
+ * \code{.unparsed}
+ * this: [2, 3, 5, 7, 8, 9, 10]
+ * slice: ^--------^
+ * output: [0, 2, 4, 5]
+ * \endcode
+ *
+ * All the indices in the sub-mask are shifted by 3 towards zero,
+ * so that the first index in the output is zero.
+ */
IndexMask slice_and_offset(IndexRange slice, Vector<int64_t> &r_new_indices) const;
};