 			B.min = device_aabb_data[body_number[k]];
 			B.max = device_aabb_data[body_number[k] + number_of_models_const];
 			int2 FB = device_fam_data[body_number[k]];
-			if ((FA.x == FB.y || FB.x == FA.y) == false && AABB_Contact_Pt(A, B, Bin) == true) {
+			bool inContact = (A.min.x <= B.max.x && B.min.x <= A.max.x) && (A.min.y <= B.max.y && B.min.y <= A.max.y) && (A.min.z <= B.max.z && B.min.z <= A.max.z);
+			if ((FA.x == FB.y || FB.x == FA.y) == false && inContact == true) {
 				count++;
 			}
 		}

			B.max = device_aabb_data[body_number[k] + number_of_models_const];
			B_type = device_typ_data[body_number[k]];
			int2 FB = device_fam_data[body_number[k]];
			if ((FA.x == FB.y || FB.x == FA.y) == false && AABB_Contact_Pt(A, B, Bin) == true) {
				//int type=Contact_Type(A_aux.x, B_aux.x);
				pair[offset + count] = ((long long) A_type.y << 32 | (long long) B_type.y); //the two indicies of the objects that make up the contact
				count++;

	return false;
}
__device__ __host__ bool AABB_Contact_Pt(const AABB& A, const AABB& B, uint &Bin) {
//	float3 Pa, Pb;

	//return (F3(A.min+A.max)*.5+F3(B.min+B.max)*.5)*.5;
//	float3 centerA=(A.min+A.max)*.5;
