5 bool AABB::Intersects(const AABB &other, Vector<float> &p, Vector<float> &n, Vector<float> &d) const {
6 if (Bottom() < other.Top()) return false;
7 if (other.Bottom() < Top()) return false;
8 if (Right() < other.Left()) return false;
9 if (other.Right() < Left()) return false;
12 diff.lt.x = std::max(Left(), other.Left());
13 diff.lt.y = std::max(Top(), other.Top());
14 diff.rb.x = std::min(Right(), other.Right());
15 diff.rb.y = std::min(Bottom(), other.Bottom());
16 const Vector<float> sdiff = diff.Size();
18 if (sdiff.x < sdiff.y) {
19 if (Center().x < other.Center().x) {
20 p = Vector<float>(Right(), ((Top() + Bottom()) / 2 + (other.Top() + other.Bottom()) / 2) / 2);
21 n = Vector<float>(-1, 0);
22 d = Vector<float>(other.Left() - Right(), 0);
24 p = Vector<float>(Left(), ((Top() + Bottom()) / 2 + (other.Top() + other.Bottom()) / 2) / 2);
25 n = Vector<float>(1, 0);
26 d = Vector<float>(other.Right() - Left(), 0);
29 if (Center().y < other.Center().y) {
30 p = Vector<float>(((Left() + Right()) / 2 + (other.Left() + other.Right()) / 2) / 2, Bottom());
31 n = Vector<float>(0, -1);
32 d = Vector<float>(0, other.Top() - Bottom());
34 p = Vector<float>(((Left() + Right()) / 2 + (other.Left() + other.Right()) / 2) / 2, Top());
35 n = Vector<float>(0, 1);
36 d = Vector<float>(0, other.Bottom() - Top());