Fix T81467: Crash with KD-Tree Weld Modifier

The problem is related to the `use_index_order` option of `BLI_kdtree_3d_calc_duplicates_fast`.
With this option, the higher index is expected to be less than `tree->nodes_len`.
This commit is contained in:
Germano Cavalcante 2020-10-12 20:01:42 -03:00
parent 8427e02abc
commit 8335c26119
Notes: blender-bot 2023-02-14 10:32:59 +01:00
Referenced by issue #81667, Measure tool multi 3dview and quad view inconsistencies
Referenced by issue #81467, Crash in weld modifier
1 changed files with 3 additions and 3 deletions

View File

@ -1687,9 +1687,9 @@ static Mesh *weldModifier_doWeld(WeldModifierData *wmd, const ModifierEvalContex
}
#else
{
KDTree_3d *tree = BLI_kdtree_3d_new(totvert);
KDTree_3d *tree = BLI_kdtree_3d_new(v_mask ? v_mask_act : totvert);
for (uint i = 0; i < totvert; i++) {
if (!(v_mask && !BLI_BITMAP_TEST(v_mask, i))) {
if (!v_mask || BLI_BITMAP_TEST(v_mask, i)) {
BLI_kdtree_3d_insert(tree, i, mvert[i].co);
}
vert_dest_map[i] = OUT_OF_CONTEXT;
@ -1697,7 +1697,7 @@ static Mesh *weldModifier_doWeld(WeldModifierData *wmd, const ModifierEvalContex
BLI_kdtree_3d_balance(tree);
vert_kill_len = BLI_kdtree_3d_calc_duplicates_fast(
tree, wmd->merge_dist, true, (int *)vert_dest_map);
tree, wmd->merge_dist, false, (int *)vert_dest_map);
BLI_kdtree_3d_free(tree);
}
#endif