]> git.localhorst.tv Git - orbi.git/blobdiff - src/world/World.cpp
some cleanup
[orbi.git] / src / world / World.cpp
index f4d80f95476beab74a2e32eac354f5f10c062659..7276ece6fdaa5b16519e3e24c0724e16a6b2d7f8 100644 (file)
@@ -1,5 +1,6 @@
 #include "World.h"
 
+#include "Collision.h"
 #include "../graphics/const.h"
 
 
@@ -50,17 +51,15 @@ void World::Update(float dt) {
                for (Vector<int> pos(cBegin); pos.y < cEnd.y; ++pos.y) {
                        for (pos.x = cBegin.x; pos.x < cEnd.x; ++pos.x) {
                                if (!TileAt(pos).IsSolid()) continue;
-                               const AABB tBounds(pos, Vector<float>(1, 1));
-                               Vector<float> pos;
-                               Vector<float> norm;
-                               Vector<float> depth;
-                               if (!e.bounds.Intersects(tBounds, pos, norm, depth)) {
+                               const AABB &tBounds = TileShapeAt(pos);
+                               Collision coll;
+                               if (!e.bounds.Intersects(tBounds, coll)) {
                                        continue;
                                }
-                               if (depth.x < min.x) min.x = depth.x;
-                               if (depth.x > max.x) max.x = depth.x;
-                               if (depth.y < min.y) min.y = depth.y;
-                               if (depth.y > max.y) max.y = depth.y;
+                               if (coll.depth.x < min.x) min.x = coll.depth.x;
+                               if (coll.depth.x > max.x) max.x = coll.depth.x;
+                               if (coll.depth.y < min.y) min.y = coll.depth.y;
+                               if (coll.depth.y > max.y) max.y = coll.depth.y;
                        }
                }
 
@@ -93,6 +92,12 @@ void World::Update(float dt) {
 }
 
 
+const AABB &World::TileShapeAt(Vector<int> pos) const {
+       tileShape = AABB(pos, Vector<float>(1, 1));
+       return tileShape;
+}
+
+
 Entity &World::AddEntity(const Entity &e) {
        entities.emplace_back(e);
        return entities.back();