Weld Modifier: Reduce size of the leaf nodes to half

This improves performance by reducing the amount of false positives.

A self overlap is made, so the distance from the vertices in the
overlap nodes is actually added.
This commit is contained in:
Germano Cavalcante 2020-01-18 15:28:49 -03:00
parent 5472ae6fdf
commit deb59c25c0
1 changed files with 2 additions and 1 deletions

View File

@ -1602,6 +1602,7 @@ static bool bvhtree_weld_overlap_cb(void *userdata, int index_a, int index_b, in
struct WeldOverlapData *data = userdata;
const MVert *mvert = data->mvert;
const float dist_sq = len_squared_v3v3(mvert[index_a].co, mvert[index_b].co);
BLI_assert(dist_sq <= ((data->merge_dist_sq + FLT_EPSILON) * 3));
return dist_sq <= data->merge_dist_sq;
}
return false;
@ -1646,7 +1647,7 @@ static Mesh *weldModifier_doWeld(WeldModifierData *wmd, const ModifierEvalContex
/* TODO: For a better performanse use KD-Tree. */
struct BVHTreeFromMesh treedata;
BVHTree *bvhtree = bvhtree_from_mesh_verts_ex(
&treedata, mvert, totvert, false, v_mask, v_mask_act, wmd->merge_dist, 2, 6, 0, NULL);
&treedata, mvert, totvert, false, v_mask, v_mask_act, wmd->merge_dist / 2, 2, 6, 0, NULL);
if (v_mask) {
MEM_freeN(v_mask);