diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2014-01-30 21:48:49 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2014-01-30 21:50:12 +0400 |
commit | 1e096ee816289fe8e7f4286e98b3203336bc3924 (patch) | |
tree | 9854fac45663232c4e47e043776eaa9f7c6a47cb /source/blender/editors/transform | |
parent | 0e1c1b61960ba520cc624ed7bd769aa524ecc1db (diff) |
More snapping fixes (this is ridiculous).
I hope this time we are done!
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index a51ed85913e..4a6f4c31a90 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -1514,7 +1514,7 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes BoundBox *bb; float imat[4][4]; float timat[3][3]; /* transpose inverse matrix for normals */ - float ray_start_local[3], ray_normal_local[3], len_diff = TRANSFORM_DIST_MAX_RAY; + float ray_start_local[3], ray_normal_local[3], local_scale, len_diff = TRANSFORM_DIST_MAX_RAY; invert_m4_m4(imat, obmat); copy_m3_m4(timat, imat); @@ -1526,6 +1526,9 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes mul_m4_v3(imat, ray_start_local); mul_mat3_m4_v3(imat, ray_normal_local); + /* local scale in normal direction */ + local_scale = normalize_v3(ray_normal_local); + bb = BKE_object_boundbox_get(ob); if (!BKE_boundbox_ray_hit_check(bb, ray_start_local, ray_normal_local, &len_diff)) { return retval; @@ -1536,10 +1539,6 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes { BVHTreeRayHit hit; BVHTreeFromMesh treeData; - float local_scale; - - /* local scale in normal direction */ - local_scale = normalize_v3(ray_normal_local); /* 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). @@ -1555,7 +1554,7 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes */ 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); + len_diff - len_v3v3(ray_start_local, ray_org_local)); } else { len_diff = 0.0f; |