Project snapping is too slow for sintel's head at subsurf level 2, ifdef'd out per...
authorCampbell Barton <ideasman42@gmail.com>
Thu, 12 Nov 2009 11:45:29 +0000 (11:45 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 12 Nov 2009 11:45:29 +0000 (11:45 +0000)
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

source/blender/blenlib/intern/math_geom.c
source/blender/editors/transform/transform_snap.c

index fe4bdb8994dea03379ae19a7d825c94d159959d3..9ce70ee2ee71b8143151108997090b01cc22f637 100644 (file)
@@ -433,7 +433,9 @@ int isect_ray_tri_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2
        
        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);
index 1cbfcc5591136dac2b0b732b8cbef6fd8ef0d409..062452d9e42ed155d2a75123c062fcacac55614a 100644 (file)
@@ -1224,6 +1224,35 @@ int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, E
                        {
                                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 @@ int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, E
                                        {
                                                EM_free_index_arrays();
                                        }
+#endif
                                        break;
                                }
                                case SCE_SNAP_MODE_VERTEX: