diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2014-01-30 20:11:10 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2014-01-30 20:16:07 +0400 |
commit | 0cb49286ce45f1b2ce16db0e174170ef2a671dba (patch) | |
tree | db005c428e76c63aea23c3d298a349a3f9051737 /source/blender/editors/transform | |
parent | f54ed9f5e0f036503a8817a65d50d38e9abd43d9 (diff) |
Fix T38409: Snapping Bug
Issue partially caused by own errors (glicth in new BKE_boundbox_ray_hit_check() code causing segfault in volume snapping,
and we have to treat ortho and persp differently in case of face snapping, because in persp our ray_start might very well
already be *inside* the boundbox of the checked object), and partly due to the fact that ED_view3d_win_to_vector()
was returning wrong vector (negated one) for ortho views (see previous commit).
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 91f8da1d2ae..a51ed85913e 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -1519,10 +1519,10 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes invert_m4_m4(imat, obmat); copy_m3_m4(timat, imat); transpose_m3(timat); - + copy_v3_v3(ray_start_local, ray_start); copy_v3_v3(ray_normal_local, ray_normal); - + mul_m4_v3(imat, ray_start_local); mul_mat3_m4_v3(imat, ray_normal_local); @@ -1536,20 +1536,30 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes { BVHTreeRayHit hit; BVHTreeFromMesh treeData; - float ray_org_local[3], local_scale; - - copy_v3_v3(ray_org_local, ray_origin); - mul_m4_v3(imat, ray_org_local); + float local_scale; /* local scale in normal direction */ local_scale = normalize_v3(ray_normal_local); - /* We pass a temp ray_start, set from object's boundbox, to avoid precision issues with very far - * away ray_start values (as returned in case of ortho view3d), see T38358. + /* Only use closer ray_start in case of ortho view! In perspective one, ray_start may already + * been *inside* boundbox, leading to snap failures (see T38409). */ - len_diff -= local_scale; /* make temp start point a bit away from bbox hit point. */ - madd_v3_v3v3fl(ray_start_local, ray_org_local, ray_normal_local, - len_v3v3(ray_start_local, ray_org_local) - len_diff); + if (!((RegionView3D *)ar->regiondata)->is_persp) { + float ray_org_local[3]; + + copy_v3_v3(ray_org_local, ray_origin); + mul_m4_v3(imat, ray_org_local); + + /* We pass a temp ray_start, set from object's boundbox, to avoid precision issues with very far + * away ray_start values (as returned in case of ortho view3d), see T38358. + */ + len_diff -= local_scale; /* make temp start point a bit away from bbox hit point. */ + madd_v3_v3v3fl(ray_start_local, ray_org_local, ray_normal_local, + len_v3v3(ray_start_local, ray_org_local) - len_diff); + } + else { + len_diff = 0.0f; + } treeData.em_evil = em; bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 6); |