From 5eef5b0d61aa995c1254eb2704faef03bc695498 Mon Sep 17 00:00:00 2001 From: Falk David Date: Wed, 9 Aug 2023 16:14:33 +0200 Subject: [PATCH] Fix #110447: Curves random selection is reversed In edit mode, the "Select Random" operator selected the inverse. For a probability of 1, no elements were selected and vice versa. This was because the selection actually deselects elements, but used a mask of elements that was not inverted. The fix takes the complement of the mask of elements, so the deselection now does the right thing. Pull Request: https://projects.blender.org/blender/blender/pulls/110963 --- source/blender/editors/curves/intern/curves_ops.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/curves/intern/curves_ops.cc b/source/blender/editors/curves/intern/curves_ops.cc index 466c26def76..389ba99ed89 100644 --- a/source/blender/editors/curves/intern/curves_ops.cc +++ b/source/blender/editors/curves/intern/curves_ops.cc @@ -893,8 +893,9 @@ static int select_random_exec(bContext *C, wmOperator *op) const eAttrDomain selection_domain = eAttrDomain(curves_id->selection_domain); IndexMaskMemory memory; - const IndexMask random_elements = random_mask( - curves, selection_domain, seed, probability, memory); + const IndexMask inv_random_elements = random_mask( + curves, selection_domain, seed, probability, memory) + .complement(curves.points_range(), memory); const bool was_anything_selected = has_anything_selected(curves); bke::GSpanAttributeWriter selection = ensure_selection_attribute( @@ -903,7 +904,7 @@ static int select_random_exec(bContext *C, wmOperator *op) curves::fill_selection_true(selection.span); } - curves::fill_selection_false(selection.span, random_elements); + curves::fill_selection_false(selection.span, inv_random_elements); selection.finish(); /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic