BVHTree usage optimized for transferring between meshes of 300k faces.

Mesh were the shape of a human.
Optimizing for anything less would not make sense because it happens ~instant
 
moving to 10 tree from binary tree increased speed by ~30%
initiating additional searches with the first increased speed by ~99%

Now function completes in less than two seconds on my amd 2,6ghz
This commit is contained in:
Ove Murberg Henriksen
2012-06-03 16:44:48 +00:00
parent 0d42015671
commit 7b29489016

View File

@@ -501,15 +501,15 @@ int ED_vgroup_transfer_weight(Object *ob_dst, Object *ob_src, bDeformGroup *dg_s
case BY_NEAREST_VERTEX:
/* make node tree */
bvhtree_from_mesh_verts(&tree_mesh_vertices_src, dmesh_src, 0.0, 2, 6);
bvhtree_from_mesh_verts(&tree_mesh_vertices_src, dmesh_src, FLT_EPSILON, 10, 6);
/* reset nearest */
nearest.dist = FLT_MAX;
nearest.index = -1;
/* loop trough vertices */
for(i = 0, dv_dst = dv_array_dst; i < me_dst->totvert; i++, dv_dst++, mv_dst++){
/* reset nearest */
/* nearest.index = -1; It is asumed using index of previous search as starting point result in speedup. It will be tested later */
nearest.dist = FLT_MAX;
/* transform into target space */
mul_v3_m4v3(tmp_co, tmp_mat, mv_dst->co);
@@ -533,15 +533,15 @@ int ED_vgroup_transfer_weight(Object *ob_dst, Object *ob_src, bDeformGroup *dg_s
mface_src = dmesh_src->getTessFaceArray(dmesh_src);
/* make node tree */
bvhtree_from_mesh_faces(&tree_mesh_faces_src, dmesh_src, 0.0, 2, 6);
bvhtree_from_mesh_faces(&tree_mesh_faces_src, dmesh_src, FLT_EPSILON, 10, 6);
/* reset nearest */
nearest.dist = FLT_MAX;
nearest.index = -1;
/* loop through the vertices */
for(i = 0, dv_dst = dv_array_dst; i < me_dst->totvert; i++, dv_dst++, mv_dst++) {
/* reset nearest */
/* nearest.index = -1; It is asumed using index of previous search as starting point result in speedup. It will be tested later */
nearest.dist = FLT_MAX;
/* transform into target space */
mul_v3_m4v3(tmp_co, tmp_mat, mv_dst->co);
@@ -586,15 +586,15 @@ int ED_vgroup_transfer_weight(Object *ob_dst, Object *ob_src, bDeformGroup *dg_s
mface_src = dmesh_src->getTessFaceArray(dmesh_src);
/* make node tree */
bvhtree_from_mesh_faces(&tree_mesh_faces_src, dmesh_src, 0.0, 2, 6);
bvhtree_from_mesh_faces(&tree_mesh_faces_src, dmesh_src, FLT_EPSILON, 10, 6);
/* reset nearest */
nearest.dist = FLT_MAX;
nearest.index = -1;
/* loop through the vertices */
for(i = 0, dv_dst = dv_array_dst; i < me_dst->totvert; i++, dv_dst++, mv_dst++){
/* reset nearest */
/* nearest.index = -1; It is asumed using index of previous search as starting point result in speedup. It will be tested later */
nearest.dist = FLT_MAX;
/* transform into target space */
mul_v3_m4v3(tmp_co, tmp_mat, mv_dst->co);