diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-11-12 14:45:29 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-11-12 14:45:29 +0300 |
commit | c53a8105da40e6c6a3dc0489699bea76236d85e6 (patch) | |
tree | c1ec10d204dbecb7a0d3805e6d5d291b1f8c2309 /source/blender/editors/transform/transform_snap.c | |
parent | fa14e50650702a6c66ac733a6ea562418f6898fa (diff) |
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
Diffstat (limited to 'source/blender/editors/transform/transform_snap.c')
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 1cbfcc55911..062452d9e42 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -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: |