#include "AABB.h"
#include "Collision.h"
+#include "../graphics/const.h"
namespace orbi {
-bool AABB::Intersects(const AABB &other, Collision &coll) const {
+bool AABB::Intersects(const AABB &other) const {
if (Bottom() < other.Top()) return false;
if (other.Bottom() < Top()) return false;
if (Right() < other.Left()) return false;
if (other.Right() < Left()) return false;
+ return true;
+}
+
+bool AABB::Intersects(const AABB &other, Collision &coll) const {
+ if (!Intersects(other)) return false;
AABB diff;
diff.lt = max(lt, other.lt);
if (sdiff.x < sdiff.y) {
coll.pos.y = diff.Center().y;
coll.norm.y = 0;
- coll.depth.y = 0;
+ coll.depth.y = sdiff.y * sigma(Center().y - other.Center().y);
if (Center().x < other.Center().x) {
coll.pos.x = Right();
coll.norm.x = -1;
coll.pos.x = diff.Center().x;
coll.norm.x = 0;
coll.depth.x = 0;
+ coll.depth.x = sdiff.x * sigma(Center().x - other.Center().x);
if (Center().y < other.Center().y) {
coll.pos.y = Bottom();
coll.norm.y = -1;