[Bf-blender-cvs] [1e096ee] master: More snapping fixes (this is ridiculous).

Bastien Montagne noreply at git.blender.org
Thu Jan 30 18:54:52 CET 2014


Commit: 1e096ee816289fe8e7f4286e98b3203336bc3924
Author: Bastien Montagne
Date:   Thu Jan 30 18:48:49 2014 +0100
https://developer.blender.org/rB1e096ee816289fe8e7f4286e98b3203336bc3924

More snapping fixes (this is ridiculous).

I hope this time we are done!

===================================================================

M	source/blender/blenkernel/intern/object.c
M	source/blender/editors/transform/transform_snap.c

===================================================================

diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index d8170af..bd61439 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -3144,7 +3144,7 @@ bool BKE_boundbox_ray_hit_check(struct BoundBox *bb, const float ray_start[3], c
 
 	bool result = false;
 	int i;
-	
+
 	for (i = 0; i < 12 && (!result || r_lambda); i++) {
 		float lambda;
 		int v1, v2, v3;
@@ -3160,7 +3160,7 @@ bool BKE_boundbox_ray_hit_check(struct BoundBox *bb, const float ray_start[3], c
 			}
 		}
 	}
-	
+
 	return result;
 }
 
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index a51ed85..4a6f4c3 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;




More information about the Bf-blender-cvs mailing list