[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24518] trunk/blender/source/blender: Project snapping is too slow for sintel's head at subsurf level 2, ifdef' d out per face snapping and added BVH raycasting.

Campbell Barton ideasman42 at gmail.com
Thu Nov 12 12:45:29 CET 2009


Revision: 24518
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24518
Author:   campbellbarton
Date:     2009-11-12 12:45:29 +0100 (Thu, 12 Nov 2009)

Log Message:
-----------
Project snapping is too slow for sintel's head at subsurf level 2, ifdef'd out per face snapping and added BVH raycasting.

adjust epsilon value for isect_ray_tri_v3()

from the comment...
/* note: these values were 0.000001 in 2.4x but for projection snapping on
 * a human head (1BU==1m), subsurf level 2, this gave many errors */
- 0.000001 -> 0.00000001

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/math_geom.c
    trunk/blender/source/blender/editors/transform/transform_snap.c

Modified: trunk/blender/source/blender/blenlib/intern/math_geom.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_geom.c	2009-11-12 09:00:04 UTC (rev 24517)
+++ trunk/blender/source/blender/blenlib/intern/math_geom.c	2009-11-12 11:45:29 UTC (rev 24518)
@@ -433,7 +433,9 @@
 	
 	cross_v3_v3v3(p, d, e2);
 	a = dot_v3v3(e1, p);
-	if ((a > -0.000001) && (a < 0.000001)) return 0;
+	/* note: these values were 0.000001 in 2.4x but for projection snapping on
+	 * a human head (1BU==1m), subsurf level 2, this gave many errors */
+	if ((a > -0.00000001) && (a < 0.00000001)) return 0;
 	f = 1.0f/a;
 	
 	sub_v3_v3v3(s, p1, v0);

Modified: trunk/blender/source/blender/editors/transform/transform_snap.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_snap.c	2009-11-12 09:00:04 UTC (rev 24517)
+++ trunk/blender/source/blender/editors/transform/transform_snap.c	2009-11-12 11:45:29 UTC (rev 24518)
@@ -1224,6 +1224,35 @@
 			{
 				case SCE_SNAP_MODE_FACE:
 				{ 
+#if 1				// Added for durian
+					BVHTreeRayHit hit;
+					BVHTreeFromMesh treeData;
+
+					bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 6);
+
+					hit.index = -1;
+					hit.dist = *depth;
+
+					if(treeData.tree && BLI_bvhtree_ray_cast(treeData.tree, ray_start_local, ray_normal_local, 0.0f, &hit, treeData.raycast_callback, &treeData) != -1)
+					{
+						if(hit.dist<=*depth) {
+							*depth= hit.dist;
+							copy_v3_v3(loc, hit.co);
+							copy_v3_v3(no, hit.no);
+
+							/* back to worldspace */
+							mul_m4_v3(obmat, loc);
+							copy_v3_v3(no, hit.no);
+
+							mul_m3_v3(timat, no);
+							normalize_v3(no);
+
+							retval |= 1;
+						}
+					}
+					break;
+
+#else
 					MVert *verts = dm->getVertArray(dm);
 					MFace *faces = dm->getFaceArray(dm);
 					int *index_array = NULL;
@@ -1293,6 +1322,7 @@
 					{
 						EM_free_index_arrays();
 					}
+#endif
 					break;
 				}
 				case SCE_SNAP_MODE_VERTEX:





More information about the Bf-blender-cvs mailing list