4 #include "../graphics/const.h"
9 bool AABB::Intersects(const AABB &other, Collision &coll) const {
10 if (Bottom() < other.Top()) return false;
11 if (other.Bottom() < Top()) return false;
12 if (Right() < other.Left()) return false;
13 if (other.Right() < Left()) return false;
16 diff.lt = max(lt, other.lt);
17 diff.rb = min(rb, other.rb);
18 const Vector<float> sdiff = diff.Size();
20 if (sdiff.x < sdiff.y) {
21 coll.pos.y = diff.Center().y;
23 coll.depth.y = sdiff.y * sigma(Center().y - other.Center().y);
24 if (Center().x < other.Center().x) {
27 coll.depth.x = other.Left() - Right();
31 coll.depth.x = other.Right() - Left();
34 coll.pos.x = diff.Center().x;
37 coll.depth.x = sdiff.x * sigma(Center().x - other.Center().x);
38 if (Center().y < other.Center().y) {
39 coll.pos.y = Bottom();
41 coll.depth.y = other.Top() - Bottom();
45 coll.depth.y = other.Bottom() - Top();