4 #include "../graphics/const.h"
9 bool AABB::Intersects(const AABB &other) 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;
17 bool AABB::Intersects(const AABB &other, Collision &coll) const {
18 if (!Intersects(other)) return false;
21 diff.lt = max(lt, other.lt);
22 diff.rb = min(rb, other.rb);
23 const Vector<float> sdiff = diff.Size();
25 if (sdiff.x < sdiff.y) {
26 coll.pos.y = diff.Center().y;
28 coll.depth.y = sdiff.y * sigma(Center().y - other.Center().y);
29 if (Center().x < other.Center().x) {
32 coll.depth.x = other.Left() - Right();
36 coll.depth.x = other.Right() - Left();
39 coll.pos.x = diff.Center().x;
42 coll.depth.x = sdiff.x * sigma(Center().x - other.Center().x);
43 if (Center().y < other.Center().y) {
44 coll.pos.y = Bottom();
46 coll.depth.y = other.Top() - Bottom();
50 coll.depth.y = other.Bottom() - Top();