Fix T55745: Checker de-select, inconsistent selection

With these changes, successive selections result in an even pattern.
This commit is contained in:
Yevgeny Makarov 2019-09-04 22:46:24 +10:00 committed by Campbell Barton
parent 4d995527a9
commit 0381727663
Notes: blender-bot 2023-02-14 05:38:34 +01:00
Referenced by issue #55745, Pick Shortest Path tool, inconsistent selection
4 changed files with 22 additions and 18 deletions

View File

@ -1311,7 +1311,7 @@ static void select_nth_bezt(Nurb *nu, BezTriple *bezt, const struct CheckerInter
while (a--) {
const int depth = abs(start - a);
if (WM_operator_properties_checker_interval_test(params, depth)) {
if (!WM_operator_properties_checker_interval_test(params, depth)) {
select_beztriple(bezt, DESELECT, SELECT, HIDDEN);
}
@ -1334,7 +1334,7 @@ static void select_nth_bp(Nurb *nu, BPoint *bp, const struct CheckerIntervalPara
while (a--) {
const int depth = abs(pnt - startpnt) + abs(row - startrow);
if (WM_operator_properties_checker_interval_test(params, depth)) {
if (!WM_operator_properties_checker_interval_test(params, depth)) {
select_bpoint(bp, DESELECT, SELECT, HIDDEN);
}

View File

@ -239,8 +239,7 @@ static void mouse_mesh_shortest_path_vert(Scene *UNUSED(scene),
}
} while ((node = node->next));
/* We need to start as if just *after* a 'skip' block... */
int depth = op_params->interval_params.skip;
int depth = -1;
node = path;
do {
if ((is_path_ordered == false) ||
@ -430,8 +429,7 @@ static void mouse_mesh_shortest_path_edge(Scene *scene,
}
} while ((node = node->next));
/* We need to start as if just *after* a 'skip' block... */
int depth = op_params->interval_params.skip;
int depth = -1;
node = path;
do {
if ((is_path_ordered == false) ||
@ -561,8 +559,7 @@ static void mouse_mesh_shortest_path_face(Scene *UNUSED(scene),
}
} while ((node = node->next));
/* We need to start as if just *after* a 'skip' block... */
int depth = op_params->interval_params.skip;
int depth = -1;
node = path;
do {
if ((is_path_ordered == false) ||

View File

@ -3734,7 +3734,7 @@ static void walker_deselect_nth(BMEditMesh *em,
if (!BM_elem_flag_test(ele, BM_ELEM_TAG)) {
/* Deselect elements that aren't at "nth" depth from active */
const int depth = BMW_current_depth(&walker) - 1;
if (WM_operator_properties_checker_interval_test(op_params, depth)) {
if (!WM_operator_properties_checker_interval_test(op_params, depth)) {
BM_elem_select_set(bm, ele, false);
}
BM_elem_flag_enable(ele, BM_ELEM_TAG);

View File

@ -500,19 +500,26 @@ void WM_operator_properties_mouse_select(wmOperatorType *ot)
*/
void WM_operator_properties_checker_interval(wmOperatorType *ot, bool nth_can_disable)
{
const int nth_default = nth_can_disable ? 1 : 2;
const int nth_min = min_ii(nth_default, 2);
const int nth_default = nth_can_disable ? 0 : 1;
const int nth_min = min_ii(nth_default, 1);
RNA_def_int(ot->srna,
"nth",
"skip",
nth_default,
nth_min,
INT_MAX,
"Nth Element",
"Skip every Nth element",
"Deselected",
"Number of deselected elements in the repetitive sequence",
nth_min,
100);
RNA_def_int(
ot->srna, "skip", 1, 1, INT_MAX, "Skip", "Number of elements to skip at once", 1, 100);
RNA_def_int(ot->srna,
"nth",
1,
1,
INT_MAX,
"Selected",
"Number of selected elements in the repetitive sequence",
1,
100);
RNA_def_int(ot->srna,
"offset",
0,
@ -527,7 +534,7 @@ void WM_operator_properties_checker_interval(wmOperatorType *ot, bool nth_can_di
void WM_operator_properties_checker_interval_from_op(struct wmOperator *op,
struct CheckerIntervalParams *op_params)
{
const int nth = RNA_int_get(op->ptr, "nth") - 1;
const int nth = RNA_int_get(op->ptr, "nth");
const int skip = RNA_int_get(op->ptr, "skip");
int offset = RNA_int_get(op->ptr, "offset");
@ -541,6 +548,6 @@ void WM_operator_properties_checker_interval_from_op(struct wmOperator *op,
bool WM_operator_properties_checker_interval_test(const struct CheckerIntervalParams *op_params,
int depth)
{
return ((op_params->nth == 0) ||
return ((op_params->skip == 0) ||
((op_params->offset + depth) % (op_params->skip + op_params->nth) >= op_params->skip));
}