]> git.localhorst.tv Git - orbi.git/blobdiff - src/world/AABB.cpp
hbox/vbox implementation
[orbi.git] / src / world / AABB.cpp
index 0ed5a63934b8e1e11a9243a3e76b0a3255279253..edce97e313dfe3f832dab4204f6ca0d100dc7643 100644 (file)
@@ -1,6 +1,7 @@
 #include "AABB.h"
 
 #include "Collision.h"
+#include "../graphics/const.h"
 
 
 namespace orbi {
@@ -19,7 +20,7 @@ bool AABB::Intersects(const AABB &other, Collision &coll) const {
        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;
@@ -33,6 +34,7 @@ bool AABB::Intersects(const AABB &other, Collision &coll) const {
                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;