Original Post
I came up with a method for testing AABB collisions, I don't know if its any good. It appears to work for every type of intersection I've tested, including when neither min or max are inside the other or when both are. Do you think this method might be faster than the simple testing if mins are greater than maxes? It avoids branching at the cost of some subtraction, but I just want to know if its a valid method in respect to that one?
bool AABox::intersect(const AABox& b) const
{
return ((int(max.x - b.min.x) ^ int(min.x - b.max.x)) <= 0 &&
(int(max.y - b.min.y) ^ int(min.y - b.max.y)) <= 0 &&
(int(max.z - b.min.z) ^ int(min.z - b.max.z)) <= 0);
}
If it isn't clear in the code, this method essentially tests to see if subtracting the other min from the max is the same sign as the other max from the min.