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:
authorHans Goudey <h.goudey@me.com>2022-06-23 19:50:53 +0300
committerHans Goudey <h.goudey@me.com>2022-06-23 19:51:33 +0300
commit3e5a4d14124029dd3ccb111de2db299bb405d668 (patch)
treea9f0af8c3ca47b00037e4d7a8bd5f989d70be088 /source/blender/blenlib/BLI_index_mask_ops.hh
parent633c2f07da2926e42f5bb5d43d16dd23767c498c (diff)
Geometry Nodes: Optimize selection for virtual array input
This makes calculation of selected indices slightly faster when the input is a virtual array (the direct output of various nodes like Face Area, etc). The utility can be helpful for other areas that need to find selected indices besides field evaluation. With the face area node used as a selection with 4 million faces, the speedup is 3.51 ms to 3.39 ms, just a slight speedup. Differential Revision: https://developer.blender.org/D15127
Diffstat (limited to 'source/blender/blenlib/BLI_index_mask_ops.hh')
-rw-r--r--source/blender/blenlib/BLI_index_mask_ops.hh14
1 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_index_mask_ops.hh b/source/blender/blenlib/BLI_index_mask_ops.hh
index 48a1f27a2fa..f67abb1d550 100644
--- a/source/blender/blenlib/BLI_index_mask_ops.hh
+++ b/source/blender/blenlib/BLI_index_mask_ops.hh
@@ -13,6 +13,7 @@
#include "BLI_index_mask.hh"
#include "BLI_task.hh"
#include "BLI_vector.hh"
+#include "BLI_virtual_array.hh"
namespace blender::index_mask_ops {
@@ -57,4 +58,17 @@ inline IndexMask find_indices_based_on_predicate(const IndexMask indices_to_chec
return detail::find_indices_based_on_predicate__merge(indices_to_check, sub_masks, r_indices);
}
+/**
+ * Find the true indices in a virtual array. This is a version of
+ * #find_indices_based_on_predicate optimised for a virtual array input.
+ *
+ * \param parallel_grain_size: The grain size for when the virtual array isn't a span or a single
+ * value internally. This should be adjusted based on the expected cost of evaluating the virtual
+ * array-- more expensive virtual arrays should have smaller grain sizes.
+ */
+IndexMask find_indices_from_virtual_array(IndexMask indices_to_check,
+ const VArray<bool> &virtual_array,
+ int64_t parallel_grain_size,
+ Vector<int64_t> &r_indices);
+
} // namespace blender::index_mask_ops