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
This commit is contained in:
parent
fa14e50650
commit
c53a8105da
@ -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);
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user