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/functions
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/functions')
-rw-r--r--source/blender/functions/intern/field.cc21
1 files changed, 3 insertions, 18 deletions
diff --git a/source/blender/functions/intern/field.cc b/source/blender/functions/intern/field.cc
index 47f6a0f19ca..fd5eab57d33 100644
--- a/source/blender/functions/intern/field.cc
+++ b/source/blender/functions/intern/field.cc
@@ -708,20 +708,11 @@ GPointer FieldConstant::value() const
*/
static IndexMask index_mask_from_selection(const IndexMask full_mask,
- VArray<bool> &selection,
+ const VArray<bool> &selection,
ResourceScope &scope)
{
- if (selection.is_span()) {
- Span<bool> span = selection.get_internal_span();
- return index_mask_ops::find_indices_based_on_predicate(
- full_mask, 4096, scope.construct<Vector<int64_t>>(), [&](const int curve_index) {
- return span[curve_index];
- });
- }
- return index_mask_ops::find_indices_based_on_predicate(
- full_mask, 1024, scope.construct<Vector<int64_t>>(), [&](const int curve_index) {
- return selection[curve_index];
- });
+ return index_mask_ops::find_indices_from_virtual_array(
+ full_mask, selection, 1024, scope.construct<Vector<int64_t>>());
}
int FieldEvaluator::add_with_destination(GField field, GVMutableArray dst)
@@ -764,12 +755,6 @@ static IndexMask evaluate_selection(const Field<bool> &selection_field,
if (selection_field) {
VArray<bool> selection =
evaluate_fields(scope, {selection_field}, full_mask, context)[0].typed<bool>();
- if (selection.is_single()) {
- if (selection.get_internal_single()) {
- return full_mask;
- }
- return IndexRange(0);
- }
return index_mask_from_selection(full_mask, selection, scope);
}
return full_mask;