[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47376] branches/meshdata_transfer/source/ blender/editors/object/object_vgroup.c: BVHTree usage optimized for transferring between meshes of 300k faces.

Ove Murberg Henriksen sorayasilvermoon at hotmail.com
Sun Jun 3 18:44:55 CEST 2012


Revision: 47376
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47376
Author:   cyborgmuppet
Date:     2012-06-03 16:44:48 +0000 (Sun, 03 Jun 2012)
Log Message:
-----------
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 

Modified Paths:
--------------
    branches/meshdata_transfer/source/blender/editors/object/object_vgroup.c

Modified: branches/meshdata_transfer/source/blender/editors/object/object_vgroup.c
===================================================================
--- branches/meshdata_transfer/source/blender/editors/object/object_vgroup.c	2012-06-03 16:23:47 UTC (rev 47375)
+++ branches/meshdata_transfer/source/blender/editors/object/object_vgroup.c	2012-06-03 16:44:48 UTC (rev 47376)
@@ -501,15 +501,15 @@
 
 		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 @@
 			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 @@
 			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);
 




More information about the Bf-blender-cvs mailing list