[Bf-blender-cvs] [1813f00b949] blender2.8: Fix missing fallback in recent aabb precalc func

Campbell Barton noreply at git.blender.org
Sat May 12 08:20:37 CEST 2018


Commit: 1813f00b94982727bf545cd4c49ec2d2fee86f7a
Author: Campbell Barton
Date:   Sat May 12 08:19:20 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB1813f00b94982727bf545cd4c49ec2d2fee86f7a

Fix missing fallback in recent aabb precalc func

Also comment unused vars

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

M	source/blender/blenlib/intern/math_geom.c
M	source/blender/editors/transform/transform_snap_object.c

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

diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 582ecb92274..7419d65bdee 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -806,10 +806,21 @@ void dist_squared_to_projected_aabb_precalc(
 		//normalize_v3(neasrest_precalc->ray_direction);
 	}
 #else
-	isect_plane_plane_v3(
+	if (!isect_plane_plane_v3(
 	        px, py,
 	        neasrest_precalc->ray_origin,
-	        neasrest_precalc->ray_direction);
+	        neasrest_precalc->ray_direction))
+	{
+		if (projmat[3][3] == 0.0f) {
+			/* Perspective projection. */
+			cross_v3_v3v3(neasrest_precalc->ray_direction, py, px);
+		}
+		else {
+			/* Orthographic projection. */
+			cross_v3_v3v3(neasrest_precalc->ray_direction, py, px);
+			//normalize_v3(neasrest_precalc->ray_direction);
+		}
+	}
 #endif
 	float win_half[2];
 	mul_v2_v2fl(win_half, winsize, 0.5f);
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index 5ef2ce479e7..ed7ada26bd7 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -1432,6 +1432,8 @@ static bool snapMesh(
         /* return args */
         float r_loc[3], float r_no[3])
 {
+// #define USE_RAY_MIN
+
 	bool retval = false;
 
 	if (snapdata->snap_to == SCE_SNAP_MODE_EDGE) {
@@ -1448,7 +1450,7 @@ static bool snapMesh(
 	float imat[4][4];
 	float timat[3][3]; /* transpose inverse matrix for normals */
 	float ray_normal_local[3];
-	float local_scale;
+
 
 	invert_m4_m4(imat, obmat);
 	transpose_m3_m4(timat, imat);
@@ -1457,16 +1459,18 @@ static bool snapMesh(
 
 	mul_mat3_m4_v3(imat, ray_normal_local);
 
+#ifdef USE_RAY_MIN
 	/* local scale in normal direction */
-	local_scale = normalize_v3(ray_normal_local);
+	const float local_scale = normalize_v3(ray_normal_local);
+#endif
 
 	float lpmat[4][4];
 	float ray_org_local[3];
-	float ray_min_dist;
 
 	mul_m4_m4m4(lpmat, snapdata->pmat, obmat);
-	ray_min_dist = snapdata->depth_range[0] * local_scale;
-
+#ifdef USE_RAY_MIN
+	const float ray_min_dist = snapdata->depth_range[0] * local_scale;
+#endif
 	copy_v3_v3(ray_org_local, snapdata->ray_origin);
 	mul_m4_v3(imat, ray_org_local);



More information about the Bf-blender-cvs mailing list