More snapping fixes (this is ridiculous).
I hope this time we are done!
This commit is contained in:
		@@ -3144,7 +3144,7 @@ bool BKE_boundbox_ray_hit_check(struct BoundBox *bb, const float ray_start[3], c
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	bool result = false;
 | 
						bool result = false;
 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
	
 | 
					
 | 
				
			||||||
	for (i = 0; i < 12 && (!result || r_lambda); i++) {
 | 
						for (i = 0; i < 12 && (!result || r_lambda); i++) {
 | 
				
			||||||
		float lambda;
 | 
							float lambda;
 | 
				
			||||||
		int v1, v2, v3;
 | 
							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;
 | 
						return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1514,7 +1514,7 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes
 | 
				
			|||||||
		BoundBox *bb;
 | 
							BoundBox *bb;
 | 
				
			||||||
		float imat[4][4];
 | 
							float imat[4][4];
 | 
				
			||||||
		float timat[3][3]; /* transpose inverse matrix for normals */
 | 
							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);
 | 
							invert_m4_m4(imat, obmat);
 | 
				
			||||||
		copy_m3_m4(timat, imat);
 | 
							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_m4_v3(imat, ray_start_local);
 | 
				
			||||||
		mul_mat3_m4_v3(imat, ray_normal_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);
 | 
							bb = BKE_object_boundbox_get(ob);
 | 
				
			||||||
		if (!BKE_boundbox_ray_hit_check(bb, ray_start_local, ray_normal_local, &len_diff)) {
 | 
							if (!BKE_boundbox_ray_hit_check(bb, ray_start_local, ray_normal_local, &len_diff)) {
 | 
				
			||||||
			return retval;
 | 
								return retval;
 | 
				
			||||||
@@ -1536,10 +1539,6 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes
 | 
				
			|||||||
			{
 | 
								{
 | 
				
			||||||
				BVHTreeRayHit hit;
 | 
									BVHTreeRayHit hit;
 | 
				
			||||||
				BVHTreeFromMesh treeData;
 | 
									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
 | 
									/* 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).
 | 
									 * 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. */
 | 
										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,
 | 
										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 {
 | 
									else {
 | 
				
			||||||
					len_diff = 0.0f;
 | 
										len_diff = 0.0f;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user