Where you find minb-maxa, you need the check the opposite as well, mina-maxb, and take the smallest, because the overlap can be either way. The axis would flip as well.
In the first function, you can get the extents without looking at all four corners. Find the dot product of the axis with the chassis position first, without adding the corner. Then the size on that axis is width*abs(dot(box x, axis)) + height*abs(dot(box y, axis)).
20 replies to this topic